Magento – get product item category and attribute_set name and id in order export

attribute-setcategory-productsexportmagento-1.9

I am trying to modify order export extension
I Wan to include product item category_id, category_name, attribute_set in the export array.

Current array look like this

protected function getOrderItemValues($item, $order, $itemInc=1) 
{

    return array(
        $itemInc,
        $item->getName(),
        $item->getStatus(),
        $this->getItemSku($item),
        $this->getItemOptions($item),
        $this->formatPrice($item->getOriginalPrice(), $order),
        $this->formatPrice($item->getData('price'), $order),
        (int)$item->getQtyOrdered(),
        (int)$item->getQtyInvoiced(),
        (int)$item->getQtyShipped(),
        (int)$item->getQtyCanceled(),
        (int)$item->getQtyRefunded(),
        $this->formatPrice($item->getTaxAmount(), $order),
        $this->formatPrice($item->getDiscountAmount(), $order),
        $this->formatPrice($this->getItemTotal($item), $order)
    );
}

Is there a method like $this->getItemCategory($item), or getAttribute etc in magento which i can use?
Thanks

Best Answer

Try this.

$product = $item->getProduct();

$attribute_set = $product->getAttributeSetId();

$category_id = $product->getCategoryIds();

Related Topic