copy linked categories when cloning a product
This commit is contained in:
parent
749bbcba18
commit
3215e066e4
@ -147,6 +147,7 @@ RowMaterial=Raw Material
|
|||||||
CloneProduct=Clone product or service
|
CloneProduct=Clone product or service
|
||||||
ConfirmCloneProduct=Are you sure you want to clone product or service <b>%s</b>?
|
ConfirmCloneProduct=Are you sure you want to clone product or service <b>%s</b>?
|
||||||
CloneContentProduct=Clone all main information of product/service
|
CloneContentProduct=Clone all main information of product/service
|
||||||
|
CloneCategoriesProduct=Clone tags/categories linked
|
||||||
ClonePricesProduct=Clone prices
|
ClonePricesProduct=Clone prices
|
||||||
CloneCompositionProduct=Clone virtual product/service
|
CloneCompositionProduct=Clone virtual product/service
|
||||||
CloneCombinationsProduct=Clone product variants
|
CloneCombinationsProduct=Clone product variants
|
||||||
|
|||||||
@ -146,6 +146,7 @@ RowMaterial=Matière première
|
|||||||
CloneProduct=Cloner produit/service
|
CloneProduct=Cloner produit/service
|
||||||
ConfirmCloneProduct=Êtes-vous sûr de vouloir cloner le produit ou service <b>%s</b> ?
|
ConfirmCloneProduct=Êtes-vous sûr de vouloir cloner le produit ou service <b>%s</b> ?
|
||||||
CloneContentProduct=Cloner les informations générales du produit/service
|
CloneContentProduct=Cloner les informations générales du produit/service
|
||||||
|
CloneCategoriesProduct=Cloner les catégories associées
|
||||||
ClonePricesProduct=Cloner les prix
|
ClonePricesProduct=Cloner les prix
|
||||||
CloneCompositionProduct=Cloner le produits packagés
|
CloneCompositionProduct=Cloner le produits packagés
|
||||||
CloneCombinationsProduct=Cloner les variantes
|
CloneCombinationsProduct=Cloner les variantes
|
||||||
|
|||||||
@ -520,6 +520,19 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GETPOST('clone_categories'))
|
||||||
|
{
|
||||||
|
$result = $object->clone_categories($originalId, $id);
|
||||||
|
|
||||||
|
if ($result < 1)
|
||||||
|
{
|
||||||
|
$db->rollback();
|
||||||
|
setEventMessage($langs->trans('ErrorProductClone'), null, 'errors');
|
||||||
|
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$originalId);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// $object->clone_fournisseurs($originalId, $id);
|
// $object->clone_fournisseurs($originalId, $id);
|
||||||
|
|
||||||
$db->commit();
|
$db->commit();
|
||||||
@ -1982,6 +1995,7 @@ $formquestionclone=array(
|
|||||||
'text' => $langs->trans("ConfirmClone"),
|
'text' => $langs->trans("ConfirmClone"),
|
||||||
array('type' => 'text', 'name' => 'clone_ref','label' => $langs->trans("NewRefForClone"), 'value' => empty($tmpcode) ? $langs->trans("CopyOf").' '.$object->ref : $tmpcode, 'size'=>24),
|
array('type' => 'text', 'name' => 'clone_ref','label' => $langs->trans("NewRefForClone"), 'value' => empty($tmpcode) ? $langs->trans("CopyOf").' '.$object->ref : $tmpcode, 'size'=>24),
|
||||||
array('type' => 'checkbox', 'name' => 'clone_content','label' => $langs->trans("CloneContentProduct"), 'value' => 1),
|
array('type' => 'checkbox', 'name' => 'clone_content','label' => $langs->trans("CloneContentProduct"), 'value' => 1),
|
||||||
|
array('type' => 'checkbox', 'name' => 'clone_categories', 'label' => $langs->trans("CloneCategoriesProduct"), 'value' => 1),
|
||||||
array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true),
|
array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true),
|
||||||
);
|
);
|
||||||
if (! empty($conf->global->PRODUIT_SOUSPRODUITS))
|
if (! empty($conf->global->PRODUIT_SOUSPRODUITS))
|
||||||
|
|||||||
@ -3611,6 +3611,32 @@ class Product extends CommonObject
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
|
/**
|
||||||
|
* copy related categories to another product
|
||||||
|
*
|
||||||
|
* @param int $fromId Id produit source
|
||||||
|
* @param int $toId Id produit cible
|
||||||
|
* @return int < 0 si erreur, > 0 si ok
|
||||||
|
*/
|
||||||
|
function clone_categories($fromId, $toId)
|
||||||
|
{
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
|
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'categorie_product (fk_categorie, fk_product)';
|
||||||
|
$sql.= " SELECT fk_categorie, $toId FROM ".MAIN_DB_PREFIX."categorie_product";
|
||||||
|
$sql.= " WHERE fk_product = '".$fromId."'";
|
||||||
|
|
||||||
|
if (! $this->db->query($sql))
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Recopie les fournisseurs et prix fournisseurs d'un produit/service sur un autre
|
* Recopie les fournisseurs et prix fournisseurs d'un produit/service sur un autre
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user