07-26-2023, 03:04 PM
I am creating an import module products on PrestaShop 1.6. the product is created without problems but the categories are not included.
I used:
$product->id_category = array();
foreach($arr_cat_full as $cat){
$category = Category::searchByName(1, trim($cat), true);
$product->id_category[] = (int)$category['id_category'];
}
If I enter:
var_dump($category['id_category']);
The result is correct.
I used:
$product->id_category = array();
foreach($arr_cat_full as $cat){
$category = Category::searchByName(1, trim($cat), true);
$product->id_category[] = (int)$category['id_category'];
}
If I enter:
var_dump($category['id_category']);
The result is correct.