示例#1
0
 /**
  * add all visible items from a quote as tracked ecommerce items
  * 
  * @param Fooman_Jirafe_Model_JirafeTracker $piwikTracker
  * @param Mage_Sales_Model_Quote $quote 
  */
 protected function _addEcommerceItems($piwikTracker, $quote)
 {
     foreach ($quote->getAllVisibleItems() as $item) {
         if ($item->getName()) {
             //we only want to track the main configurable item
             //but not the subitem
             if ($item->getParentItem()) {
                 if ($item->getParentItem()->getProductType() == 'configurable') {
                     continue;
                 }
             }
             $itemPrice = $item->getBasePrice();
             // This is inconsistent behaviour from Magento
             // base_price should be item price in base currency
             // TODO: add test so we don't get caught out when this is fixed in a future release
             if (!$itemPrice || $itemPrice < 1.0E-5) {
                 $itemPrice = $item->getPrice();
             }
             $piwikTracker->addEcommerceItem($item->getProduct()->getData('sku'), $item->getName(), Mage::helper('foomanjirafe')->getCategory($item->getProduct()), $itemPrice, $item->getQty());
         }
     }
 }