Duplicating Carriers along with Products in PrestaShop and ThirtyBees
In this tutorial we will use a little code snippet to have carriers copy over on product duplication in PrestaShop and Thirtybees.
Watch the screencast
Duplicating product carriers in PrestaShop and ThirtyBees – text version
Create a new override in override/controllers/admin, and name it AdminProductsController.php:
class AdminProductsController extends AdminProductsControllerCore
{
}
We need to copy the original ProcessDuplicate method, and paste it into our override. You will see it’s calling a bunch of methods that start with “duplicate”. Add the following right after Product::duplicateSuppliers($id_product_old, $product->id):
&& Product::duplicateCarriers($id_product_old, $product->id)
Next, we have to add the method we are calling to the Product class. We will use another override, so let’s create Product.php in override/classes
Open it up, and paste the following, or if you have a product override already in place, just copy over the DuplicateCarriers method:
public static function duplicateCarriers($id_product_old, $id_product_new)
{
$result = Db::getInstance()->executeS('
SELECT *
FROM `'._DB_PREFIX_.'product_carrier`
WHERE `id_product` = '.(int)$id_product_old);
foreach ($result as $row) {
unset($row['id_product_carrier']);
$row['id_product'] = $id_product_new;
if (!Db::getInstance()->insert('product_carrier', $row)) {
return false;
}
}
return true;
}
Save, then reach the cache/ folder and erase class_index.php, so that the new overrides can get loaded in the system.



