musicmaster Posted January 26, 2012 Share Posted January 26, 2012 "Duplicate Products" is a rather slow function, specially if you need dozens of copies. So I have been experimenting if I could create a PHP function that directs the PS code to do just that. What I did was that I made a copy of index.php that I called duplo.php and then I changed the code inside it so that it didn't need arguments on the command line. So the beginning of the file looks as follows: define('_PS_ADMIN_DIR_', getcwd()); define('PS_ADMIN_DIR', _PS_ADMIN_DIR_); // Retro-compatibility $_GET['id_product'] = '118'; /* my product that I want to be copied */ $_GET['id_category'] = '13'; /* the category in which I want it copied */ $_GET['tab'] = 'AdminCatalog'; $_GET['token'] = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; /* the code as it appeared in the url */ $_GET['duplicateproduct'] = ''; $_POST = $_GET; include(PS_ADMIN_DIR.'/../config/config.inc.php'); include(PS_ADMIN_DIR.'/functions.php'); include(PS_ADMIN_DIR.'/header.inc.php'); The amazing thing when I called this file in my browser was that it made 21 copies of my product. I am puzzled and I wonder if there are other people who have been experimenting too and know some things that I don't know. Link to comment Share on other sites More sharing options...
musicmaster Posted January 26, 2012 Author Share Posted January 26, 2012 I thought that one possibility is that this is caused by the redirect. Normally duplicate does a redirect after it has duplicated an item. It goes than to another instance of index.php that has slightly different arguments. But if I use my filename "duplo.php" those arguments don't work and the same duplication is repeated. It probably times out on Opera (my browser) after 21 times. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now