如何在添加新产品时更改默认类别ID

时间:2014-02-28 15:32:59

标签: php prestashop

$categories = $this->getCategories($sub_cats);
$product->addToCategories($categories);

foreach ($categories as $category) {
    $product->category[] = $category;
}

当我想添加产品类别但我无法更改id_category_default

时,此代码效果很好

如何更改默认类别信息?

1 个答案:

答案 0 :(得分:0)

当您尝试保存默认类别时,是否调用了save()方法?

$product->id_category_default = (int)$id_category;
$product->addToCategories($categories);
$product->save();