banan_44 Posted October 28, 2018 Share Posted October 28, 2018 Hello, when I duplicate a product, there is 'Copy of' at the beginning of the new product's title. Is there a way to remove it completely so these words would not show in future when I duplicate product? It is really annoying to remove it manually. Link to comment Share on other sites More sharing options...
joseantgv Posted October 29, 2018 Share Posted October 29, 2018 10 hours ago, banan_44 said: Hello, when I duplicate a product, there is 'Copy of' at the beginning of the new product's title. Is there a way to remove it completely so these words would not show in future when I duplicate product? It is really annoying to remove it manually. I only found this reference at file \src\Adapter\Product\AdminProductDataUpdater.php: public function duplicateProduct($productId, $namePattern = 'copy of %s') { //TODO : use the $namePattern var to input translated version of 'copy of %s', if translation requested. $product = new Product($productId); if (!Validate::isLoadedObject($product)) { throw new \Exception('AdminProductDataUpdater->duplicateProduct() received an unknown ID.', 5005); } $id_product_old = $product->id; if (empty($product->price) && Shop::getContext() == Shop::CONTEXT_GROUP) { $shops = ShopGroup::getShopsFromGroup(Shop::getContextShopGroupID()); foreach ($shops as $shop) { if ($product->isAssociatedToShop($shop['id_shop'])) { $product_price = new Product($id_product_old, false, null, $shop['id_shop']); $product->price = $product_price->price; } } } unset($product->id); unset($product->id_product); $product->indexed = 0; $product->active = 0; // change product name to prefix it foreach ($product->name as $langKey => $oldName) { if (!preg_match('/^' . str_replace('%s', '.*', preg_quote($namePattern, '/') . '$/'), $oldName)) { $newName = sprintf($namePattern, $oldName); if (mb_strlen($newName, 'UTF-8') <= 127) { $product->name[$langKey] = $newName; } } } if ($product->add() && Category::duplicateProductCategories($id_product_old, $product->id) && Product::duplicateSuppliers($id_product_old, $product->id) && ($combination_images = Product::duplicateAttributes($id_product_old, $product->id)) !== false && GroupReduction::duplicateReduction($id_product_old, $product->id) && Product::duplicateAccessories($id_product_old, $product->id) && Product::duplicateFeatures($id_product_old, $product->id) && Product::duplicateSpecificPrices($id_product_old, $product->id) && Pack::duplicate($id_product_old, $product->id) && Product::duplicateCustomizationFields($id_product_old, $product->id) && Product::duplicateTags($id_product_old, $product->id) && Product::duplicateDownload($id_product_old, $product->id)) { if ($product->hasAttributes()) { Product::updateDefaultAttribute($product->id); } if (!Image::duplicateProductImages($id_product_old, $product->id, $combination_images)) { throw new UpdateProductException('An error occurred while copying images.', 5008); } else { $this->hookDispatcher->dispatchForParameters('actionProductAdd', array('id_product' => (int)$product->id, 'product' => $product)); if (in_array($product->visibility, array('both', 'search')) && Configuration::get('PS_SEARCH_INDEXATION')) { Search::indexation(false, $product->id); } return $product->id; } } else { throw new \Exception('An error occurred while creating an object.', 5009); } } 1 Link to comment Share on other sites More sharing options...
banan_44 Posted October 29, 2018 Author Share Posted October 29, 2018 Thank mate. That did the trick Link to comment Share on other sites More sharing options...
Onices Posted October 19, 2023 Share Posted October 19, 2023 Hello 😀 This modification works well on version 1.7 but arrived on Prestashop 8 despite the fact that the code is identical the deletion of "copy of" does not change anything. Do you have any tips on how to make the same change on Prestashop 8 ? Link to comment Share on other sites More sharing options...
Zohaib-fk Posted October 22, 2023 Share Posted October 22, 2023 I think the ps_product_lang table has details about the product name,meta-title and other details, we can update a record of the product from the database table. Link to comment Share on other sites More sharing options...
ps8modules Posted October 22, 2023 Share Posted October 22, 2023 Hi, You can create an override of the Product.php file and the change will be valid in multiple versions of Prestashop. save as ./override/classes/Product.php Link to comment Share on other sites More sharing options...
JBW Posted October 25, 2023 Share Posted October 25, 2023 In 8.1 the "Copy of" was removed and the file mentioned above is depreceated. In earlier versions you can change the product name in hook actionProductAdd. Link to comment Share on other sites More sharing options...
Onices Posted February 19 Share Posted February 19 The solution was given in this post : Thank to @ps8modules.com 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