我試圖在推出購物車頁面中放置推薦商品列表,我試圖使用layaout/catalog.xml中的相關產品塊,但它適用於產品視圖頁面中的單個產品,並且在結帳購物車頁面中可以有多個產品,因此,如果能做到這一點,我該如何做出這樣的事情?Magento在結帳購物車中的相關(推薦)產品列表
2
A
回答
0
如果您在Mage_Catalog_Block_Product_List_Related::_prepareData
方法看,你會發現它是使用下面的代碼再加上一些看家:
$this->_itemCollection = $product->getRelatedProductCollection()
...
你可以創建自己的塊,抓住了產品從車,並通過相同的代碼循環。喜歡的東西:
$cartHelper = Mage::helper('checkout/cart');
$cart = $cartHelper->getCart();
$cartItems = $cart->getQuote()->getAllItems();
$relatedCollection = new Varien_Data_Collection();
foreach ($cartItems as $cartItem) {
$tempColl = $cartItem->getRelatedProductCollection();
... insert housekeeping code from Related block
... add $tempColl to $relatedCollection
}
您可能需要刪除重複的集合(toArray()
然後array_unique
),因爲它有可能是在車中的物品具有相同的相關產品,但至少應該讓你在遊戲中。
HTH, JD
3
爲了達到你需要簡單地添加「交叉銷售」的產品關係將實現這一目標。
閱讀:http://www.magentocommerce.com/knowledge-base/entry/how-do-i-set-up-product-relations/
相關問題
- 1. 結賬購物車中的可選產品(/結帳/購物車/)
- 2. CS購物車相關產品選項
- 3. Magento:產品添加到購物車
- 4. Magento產品未加入購物車
- 5. Magento購物車相同的產品添加在不同的行
- 6. 獲取Magento購物車中的產品產品
- 7. Magento添加到購物車並重定向到結帳(產品頁:在「結帳」按鈕,「添加到購物車」重定向到購物車)
- 8. 更改WooCommerce購物車中的產品價格並結帳
- 9. Magento - 結帳 - 購物車空白頁
- 10. Magento結帳購物車功能控制
- 11. Magento購物車規則爲PayPal結帳?
- 12. Magento購物車規則X +購物車中的物品
- 13. AJAX - 購物車Magento總計和購物車中的物品
- 14. 在顯示當我嘗試將產品添加到Magento的購物車結賬購物袋購物車
- 15. Magento ajax購物車沒有刪除購物車中的最後一個產品?
- 16. Magento添加到購物車按鈕直接到magento/index.php /結帳/購物車/頁
- 17. Magento的Onepage結賬增加新產品到購物車
- 18. 如何在Magento中獲取購物車中的當前產品?
- 19. magento在購物車中插入類別18的商品列表
- 20. 購物車儲備產品
- 21. Magento在購物車中的配置產品非常慢,EAV:Mage_Eav_Model_Config :: getAttribute
- 22. 如何在購物車中顯示產品的縮略圖 - Magento
- 23. 購物車 - 在結帳時售罄或更少的物品流?
- 24. 打開購物車許多產品的相同產品價格?
- 25. 如何使用阿賈克斯添加到購物車的相關產品magento
- 26. 產品在購物車中複製
- 27. Magento - 獲取給定產品ID的購物車商品
- 28. Magento在結帳/購物車中的空白頁
- 29. 在結帳購物車中的文件上傳Magento
- 30. 使用拖放在magento中添加產品到購物車