I need get all skus in a current category page, the code works only with getId, i want get skus: getSku, but doesnt work:
$products = Mage::getBlockSingleton('catalog/product_list')->getLoadedProductCollection();
$category = Mage::registry('current_category');
foreach ($products as $item) {
if($lista[0] != ''){
$lista[0][] = ' '.$item->getSku();
}
else{
$lista[0][] = $item->getSku();
}
$data['event'] = 'category';
$google_tag_params = array();
$google_tag_params['ecomm_prodid'] = $lista[0];
$data['google_tag_params'] = $google_tag_params;
}
This return: [null, ' ', ' ', ' ', ' ', ' ', ' ', ' ' ]
What's wrong?
Best Answer
This should give you a collection of all the products in the current category
You should then be able to do $item->getsku() as you loop through the collection.
This similar question might also help you https://stackoverflow.com/questions/29124232/magento-get-all-products-in-the-current-category