我为prestashop 1.7创建了模块,并且此代码有效(类扩展:ModuleFrontControllerCore)
$newProduct = new Product();
$newProduct->name = 'Example name';
$newProduct->reference = '123456789';
$newProduct->active = false;
下一步,我想将模块迁移到1.6,然后我进行了更改:
$newProduct = new ProductCore();
$newProduct->name = [(int)ConfigurationCore::get('PS_LANG_DEFAULT') => 'Example name'];
$newProduct->reference = '123456789';
$newProduct->active = false;
已添加产品,但目录中缺少名称。哪里有错误?
答案 0 :(得分:0)
解决方案:
$default_lang = ConfigurationCore::get('PS_LANG_DEFAULT');
$newProduct = new ProductCore();
$newProduct->name = [$default_lang => 'Example name'];
$newProduct->link_rewrite = [$default_lang => ToolsCore::link_rewrite('Example name')];
$newProduct->reference = '123456789';
$newProduct->active = false;