我在做一个Prestashop模块,我需要添加大小组合
我正在做这个`$product = new Product($idProduct);
$attribute = new ProductAttribute();
$attribute->name = $attributeName;
$attribute->public_name = $attributeName;
$attribute->add();
$idAtributoTalla = (int)$attribute->id;
$attributeValue = new AttributeGroup();
$attributeValue->id_attribute_group = $idAtributoTalla;
$attributeValue->name = array_fill(0, Language::getLanguages(false, false), $attributeValue);
$attributeValue->position = ProductAttribute::getHigherPosition($idAtributoTalla) + 1;
$attributeValue->add();
$product->update();
$product->addProductAttributeCombination($idAtributoTalla, array($idAtributoTalla));
$product->update();`
字符串
但是当我执行代码时,我有一个错误:ProductAttribute->id_attribute_group属性为空。
我试图手动添加一个组ID,但没有工作
1条答案
按热度按时间gtlvzcf81#
您正在调用
$attribute->add()
,但没有指定id_attribute_group
属性。这是必需的属性,如果没有此属性,则无法添加新的ProductAttribute。ProductAttribute对象模型被Map到表
attribute
,这是您的场景中的“大小号”(例如:37、38、39)。它必须被Map到AttributeGroup
对象模型。