以编程方式创建属性 - Prestashop 1.6

时间:2014-07-16 18:19:12

标签: prestashop prestashop-1.6

我正在以编程方式向Prestashop 1.6添加属性,如下所示:

$newGroup = new AttributeGroup();
$newGroup->name = $this->createMultiLangField('test');
$newGroup->public_name = $this->createMultiLangField('test');
$newGroup->group_type = 'select';
$newGroup->add();

$newAttribute = new Attribute();
$newAttribute->name = $this->createMultiLangField('test');
$newAttribute->id_attribute_group = $newGroup->id;
$newAttribute->add();

当我查看我的目录时,此属性及其组就在那里,一切似乎都是有序的。但是,当我在执行此操作后单击任何产品上的组合时,ajax加载器会无限制地旋转(我无法再在任何产品上创建组合)。有没有人经历过这样的事情?

1 个答案:

答案 0 :(得分:4)

代码应为:

$newGroup = new AttributeGroup();
$newGroup->name = $this->createMultiLangField('test');
$newGroup->public_name = $this->createMultiLangField('test');
$newGroup->group_type = 'select';
$newGroup->add();

$newAttribute = new Attribute();
$newAttribute->name = $this->createMultiLangField('test');
$newAttribute->id_attribute_group = $newGroup->id;
$newAttribute->add();