Question

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

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

This code works good when i want to add product categories but i cannot change id_category_default

How can i change the default category info ?

No correct solution

OTHER TIPS

Did you call the save() method when you tried to save the default category?

$product->id_category_default = (int)$id_category;
$product->addToCategories($categories);
$product->save();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top