0

I am trying to get the attribute values for products in an order and show them on the checkout success page.

So far I have been able to get SKU, NAME, but MANUFACTURER won't show any value...

Here is the code I am using to get the items from the checkout session:

<?php //
    $products = array();
    $lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
    $_order = Mage::getSingleton('sales/order')->load($lastOrderId);

    /* @var $item Mage_Sales_Model_Order */
    foreach ($_order->getAllVisibleItems()  as $item) {
        $info['sku'] = trim($item->getSku());
        $info['qty'] = $item->getQtyOrdered();
        $info['name'] = $item->getName();
        $info['manufacturer'] = $item->getManufacturer();

        $products[] = $info;


    }

    $config['productInfos'] = $products;
?>

And to echo the values:

                            <?php foreach ($config['productInfos'] as $product): ?>
                                <?php echo trim(stripslashes(htmlentities($product['manufacturer']))); ?>
                                <?php echo trim(stripslashes(htmlentities($product['name']))); ?>,
                                <?php echo trim(stripslashes(htmlentities($product['sku']))); ?>,
                            <?php endforeach; ?>

Can anyone see what is wrong with my code?

1 Answer 1

2

Sales order item object do not save Manufacturer attribute to sales_flat_order_item table. If you want get Manufacturer then you need load Product by $item->getProductId();

Like:

$product=Mage::getModel('catalog/product')->load($item->getProductId());

$info['manufacturer'] = $product->getManufacturer();
4
  • Thankyou for your comments I will give it a try and post back... Sep 19, 2014 at 11:42
  • I get an error Fatal error: Call to a member function getProductId() Sep 19, 2014 at 12:26
  • hey check again.....
    – Amit Bera
    Sep 19, 2014 at 14:32
  • Sorry but I can't get past this error Fatal error: Call to a member function getProductId() Sep 19, 2014 at 20:21

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.