dtwfung Posted September 20, 2019 Share Posted September 20, 2019 Hi there, I am new to PS 1.7. I have been using PS 1.6 for few years. Recently, upgrade production system to 1.7. In 1.6, making new product (duplicate from old product ) can have option in copying images or not. In PS 1.7 5.x, no such option anymore. Please advise if the option has dropped or I just don't know how ? Cheers Link to comment Share on other sites More sharing options...
yama Posted October 25, 2019 Share Posted October 25, 2019 dropped. https://github.com/PrestaShop/PrestaShop/issues/13397 1 Link to comment Share on other sites More sharing options...
slashdev Posted April 20, 2021 Share Posted April 20, 2021 (edited) Hello everyone. I have good news for you. I've done it. See below how to duplicate product without images: 1. Modification of file /html/src/Adapter/Product/AdminProductDataUpdater.php look for use Validate; and add after it use Tools; look for if (!Image::duplicateProductImages($id_product_old, $product->id, $combination_images)) { and change to if (!Tools::getValue('noimage') && !Image::duplicateProductImages($id_product_old, $product->id, $combination_images)) { 2. Modification of file html/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Lists/list.html.twig look for this block {% set buttons_action = buttons_action|merge([ { "onclick": "unitProductAction(this, 'duplicate');", "icon": "content_copy", "label": "Duplicate"|trans({}, 'Admin.Actions') } ]) %} and add after it {% set buttons_action = buttons_action|merge([ { "onclick": "unitProductAction(this, 'duplicate noimage=1');", "icon": "content_copy", "label": "Duplicate without images"|trans({}, 'Admin.Actions') } ]) %} 3. Modification of file html/ADMINFOLDER/themes/default/js/bundle/product/catalog.js look for this function and function unitProductAction(element, action) { ... } and do like this (only two changes) function unitProductAction(element, action) { a = action.split(' '); action = a[0]; params = (a.length == 1) ? '' : a[1]; // <-- add this line var form = $('form#product_catalog_list'); // save action URL for redirection and update to post to bulk action instead // using form action URL allow to get route attributes and stay on the same page & ordering. var urlHandler = $(element).closest('[data-uniturl]'); var redirectUrlHandler = $(element).closest('[redirecturl]'); var redirectionInput = $('<input>') .attr('type', 'hidden') .attr('name', 'redirect_url').val(redirectUrlHandler.attr('redirecturl')); switch (action) { case 'delete': // Confirmation popup and callback... $('#catalog_deletion_modal').modal('show'); $('#catalog_deletion_modal button[value="confirm"]').off('click'); $('#catalog_deletion_modal button[value="confirm"]').on('click', function () { form.append($(redirectionInput)); var url = urlHandler.attr('data-uniturl').replace(/duplicate/, action); form.attr('action', url); form.submit(); $('#catalog_deletion_modal').modal('hide'); }); return; // Other cases, nothing to do, continue. //default: } form.append($(redirectionInput)); var url = urlHandler.attr('data-uniturl').replace(/duplicate/, action) + (params.length > 0 ? '&' + params : ''); // <-- and change this line form.attr('action', url); form.submit(); } 4. Clear cache in Performance and clear your browser cache. That's all. Have good clients $) Edited April 21, 2021 by slashdev (see edit history) 3 Link to comment Share on other sites More sharing options...
Designinfo.in Posted October 31, 2021 Share Posted October 31, 2021 @slashdevi have done this above, but on click, the page goes to the dashboard, normal duplicate button works though. Link to comment Share on other sites More sharing options...
slashdev Posted October 31, 2021 Share Posted October 31, 2021 28 minutes ago, Designinfo.in said: @slashdevi have done this above, but on click, the page goes to the dashboard, normal duplicate button works though. Have you done step 4? Link to comment Share on other sites More sharing options...
prestamax Posted January 3, 2022 Share Posted January 3, 2022 On 10/31/2021 at 9:16 AM, Designinfo.in said: @slashdevi have done this above, but on click, the page goes to the dashboard, normal duplicate button works though. You won't see the changes at the bottom of product edit page but at the product list if you hover over the three dots beside the edit button of the product. Link to comment Share on other sites More sharing options...
prestamax Posted January 4, 2022 Share Posted January 4, 2022 On 4/20/2021 at 9:13 PM, slashdev said: Hello everyone. I have good news for you. I've done it. See below how to duplicate product without images: 1. Modification of file /html/src/Adapter/Product/AdminProductDataUpdater.php look for use Validate; and add after it use Tools; look for if (!Image::duplicateProductImages($id_product_old, $product->id, $combination_images)) { and change to if (!Tools::getValue('noimage') && !Image::duplicateProductImages($id_product_old, $product->id, $combination_images)) { 2. Modification of file html/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Lists/list.html.twig look for this block {% set buttons_action = buttons_action|merge([ { "onclick": "unitProductAction(this, 'duplicate');", "icon": "content_copy", "label": "Duplicate"|trans({}, 'Admin.Actions') } ]) %} and add after it {% set buttons_action = buttons_action|merge([ { "onclick": "unitProductAction(this, 'duplicate noimage=1');", "icon": "content_copy", "label": "Duplicate without images"|trans({}, 'Admin.Actions') } ]) %} 3. Modification of file html/ADMINFOLDER/themes/default/js/bundle/product/catalog.js look for this function and function unitProductAction(element, action) { ... } and do like this (only two changes) function unitProductAction(element, action) { a = action.split(' '); action = a[0]; params = (a.length == 1) ? '' : a[1]; // <-- add this line var form = $('form#product_catalog_list'); // save action URL for redirection and update to post to bulk action instead // using form action URL allow to get route attributes and stay on the same page & ordering. var urlHandler = $(element).closest('[data-uniturl]'); var redirectUrlHandler = $(element).closest('[redirecturl]'); var redirectionInput = $('<input>') .attr('type', 'hidden') .attr('name', 'redirect_url').val(redirectUrlHandler.attr('redirecturl')); switch (action) { case 'delete': // Confirmation popup and callback... $('#catalog_deletion_modal').modal('show'); $('#catalog_deletion_modal button[value="confirm"]').off('click'); $('#catalog_deletion_modal button[value="confirm"]').on('click', function () { form.append($(redirectionInput)); var url = urlHandler.attr('data-uniturl').replace(/duplicate/, action); form.attr('action', url); form.submit(); $('#catalog_deletion_modal').modal('hide'); }); return; // Other cases, nothing to do, continue. //default: } form.append($(redirectionInput)); var url = urlHandler.attr('data-uniturl').replace(/duplicate/, action) + (params.length > 0 ? '&' + params : ''); // <-- and change this line form.attr('action', url); form.submit(); } 4. Clear cache in Performance and clear your browser cache. That's all. Have good clients $) Thank you for this helpful hack! Link to comment Share on other sites More sharing options...
yama Posted January 4, 2022 Share Posted January 4, 2022 @slashdev Did you propose your work on the pretashop's github? Link to comment Share on other sites More sharing options...
marboo Posted March 13, 2023 Share Posted March 13, 2023 On 4/20/2021 at 10:13 PM, slashdev said: Hello everyone. I have good news for you. I've done it. See below how to duplicate product without images: 1. Modification of file /html/src/Adapter/Product/AdminProductDataUpdater.php A million thanks! You cannot imagine the amount of time you saved me! <3 Link to comment Share on other sites More sharing options...
Geronimo2012 Posted August 28 Share Posted August 28 On 10/31/2021 at 9:45 AM, slashdev said: Have you done step 4? I have the same, in Prestashop 8.1.7. I cleared the cache and browser data but still I get redirected to dashboard. Link to comment Share on other sites More sharing options...
Geronimo2012 Posted August 28 Share Posted August 28 7 minutes ago, Geronimo2012 said: I have the same, in Prestashop 8.1.7. I cleared the cache and browser data but still I get redirected to dashboard. The url change does not work anymore, it results in: /admin/index.php/sell/catalog/products/unit/duplicate%20noimage=1/index.php?controller=AdminDashboard&token=xxxxxxxxxxxxxxxxxxxxxxxxxx Link to comment Share on other sites More sharing options...
yama Posted August 29 Share Posted August 29 On PS 8.1, you just need to select all pictures and click on a delete button. Not perfect but for sure not a big deal. It's not like PS 1.7 where you need to delete one by one. Link to comment Share on other sites More sharing options...
Geronimo2012 Posted August 31 Share Posted August 31 On 8/29/2024 at 5:49 AM, yama said: On PS 8.1, you just need to select all pictures and click on a delete button. Not perfect but for sure not a big deal. It's not like PS 1.7 where you need to delete one by one. If only you could multi select images, one by one is quit cumbersome. 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