2

As described in the title of this question, I don't understand why Magento 1.9.3.0 doesn't save the taxClassId information. Any idea?

$orders = Mage::getModel('sales/order')
            ->getCollection()
            ->addAttributeToSelect('*');

foreach ($orders as $order) {
    $theItems = $order->getAllVisibleItems();
    foreach ($theItems as $product) {
        echo $product->getTaxClassId();
    }   
}

Thanks

2 Answers 2

0

You may need to load the product model. E.g.:

$classId = Mage::getModel('catalog/product')
     ->loadByAttribute('sku',$product->getSku())
     ->getTaxClassId();
0

I know its an old question, but it might benefit who ever is looking for a faster solution that is compatible with Community edition 1.6+

Since taxClassId is a product attribute, you can get the product attribute value without loading the entire product.

$_resource = $this->getProduct()->getResource();

$orders = Mage::getModel('sales/order')
            ->getCollection()
            ->addAttributeToSelect('*');

foreach ($orders as $order) {
    $items = $order->getItemsCollection();
    foreach ($items as $item) {
        $productId = $item->getProductId();
        $taxClassId = $_resource->getAttributeRawValue($_item, 'tax_class_id', Mage::app()->getStore());
        echo $taxClassId;
        echo PHP_EOL;
    }   
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.