Add new product combination in PrestaShop by core development
$attributes=array();
$attribute is a all attribute id wich you selected at the time of product add.
$p is product id
if(count(Tools::getValue('attribute'))){
$attributes=Tools::getValue('attribute');
$i=0;
$combinationAttributes = [];
foreach ($attributes as $key => $value) {
if($value==0) continue;
$combinationAttributes[] = $value;
}
if(!empty($combinationAttributes) && !$p->productAttributeExists($combinationAttributes)){
$price =0;
$weight = 0;
$ecotax = 7;
$unit_price_impact = 0;
$quantity = 1;
$reference = "";
$supplier_reference = "";
$ean13 = "";
$default = true;
$idProductAttribute = $p->addProductAttribute(
(float)$price,
(float)$weight,
$unit_price_impact,
(float)$ecotax,
(int)$quantity,
"",
strval($reference),
strval($supplier_reference),
strval($ean13),
$default,
NULL,
NULL,
1,
"");
$p->addAttributeCombinaison($idProductAttribute, $combinationAttributes);
}
}
$attribute is a all attribute id wich you selected at the time of product add.
$p is product id
if(count(Tools::getValue('attribute'))){
$attributes=Tools::getValue('attribute');
$i=0;
$combinationAttributes = [];
foreach ($attributes as $key => $value) {
if($value==0) continue;
$combinationAttributes[] = $value;
}
if(!empty($combinationAttributes) && !$p->productAttributeExists($combinationAttributes)){
$price =0;
$weight = 0;
$ecotax = 7;
$unit_price_impact = 0;
$quantity = 1;
$reference = "";
$supplier_reference = "";
$ean13 = "";
$default = true;
$idProductAttribute = $p->addProductAttribute(
(float)$price,
(float)$weight,
$unit_price_impact,
(float)$ecotax,
(int)$quantity,
"",
strval($reference),
strval($supplier_reference),
strval($ean13),
$default,
NULL,
NULL,
1,
"");
$p->addAttributeCombinaison($idProductAttribute, $combinationAttributes);
}
}
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment