Magento Checkout success page product price and SKU retrival

后端 未结 3 549
攒了一身酷
攒了一身酷 2020-12-17 03:11

I want to add Commission junction to my client site, in that they asked for each product sku\'s and price. After the confirmation page/ success page only we need to pass the

3条回答
  •  轮回少年
    2020-12-17 04:01

    Watch for an event like this:

    
        
            
                
                    
                        
                            yourmodule/observer
                            onSalesOrderPlaceAfter
                        
                    
                
            
        
    
    

    Next, you need something to handle the event.

    app/code/local/Yourcompany/Yourmodule/Model/Observer.php

    getOrder();
            /* @var $item Mage_Sales_Model_Order_Item */
            foreach ($order->getItemsCollection() as $item) {
                // Do something with $item here...
                $name = $item->getName();
                $price = $item->getPrice();
                $sku = $item->getSku();
            }
        }
    
    }
    

    See the database table "sales_flat_order_item" or do a var_dump($item->debug()) to see what sort of values are available. As it's a flat table the only way to find more information about a product is like this:

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

提交回复
热议问题