how can i get category detail on shipping.php page in magento
Hi I have to make a custom function in shipping.php
. I got all the product details but I also want to find the category details.
public function getCartDetail(){
$i=0;
foreach($this->getItems() as $item) {
$product[$i]['poroductId'] = $item->getProduct()->getId();
$product[$i]['price'] 开发者_运维百科= $item->getProduct()->getPrice();
$product[$i]['Name'] = $item->getProduct()->getName();
$product[$i]['qty'] = $item->getQty();
$product[$i]['cat_id'] = $item->getProduct()->getCategoryIds();
$i=$i+1;
}
return $product;
}
This is working on my local system but on server it gives cat_id
blank.
If getCategoryIds()
is returning nothing sometimes but not for all servers then try re-indexing the catalog data.
Since a product can be assigned to multiple categories, I suspect getCategoryIds() will be returning an array, rather than a single value.
精彩评论