i have products that belong to categories and i need to get such categories and output them as a single array. This is my this code:
$act_prod = array(0=>1,1=>10);
$active_cat = array();
foreach ($act_prod as $act) {
$cat = $this->getDi()->productTable->load($act);
$active_cat[$act] = $cat->getCategories();
}
print_r($active_cat);
Which will output:
Array ( [1] => Array ( [0] => 1 ) [10] => Array ( [0] => 2 ) )
This means product 1 belongs to category 1 and product 10 to category 2 but i dont need all that. I only need the categories like this: Array (1, 2) or Array (0=>1, 1=>2).
What should i use so i get the correct output?
Thank you.
$cat->getCategories();is returning an array. Hence, each key in your$active_catcontains an array