2
A
回答
2
聲明自己的塊的模塊中,並使用下面的代碼來獲得你所需要的產品:
function getProducts() {
$id = $this->getCategoryId(); // you will have to call setCategoryId somewhere else
$category = Mage::getModel("catalog/category")->load($id);
$products = $category->getProductCollection();
$products->addAttributeToSelect("*"); // adds all attributes
//$products->addAttributeToSelect(array("name", "color")); // more precise way to add attributes
return $products;
}
然後,在你的看法:
$products = $this->getProducts(); // this is a collection object, not an array, but we can iterate over it anyway.
foreach($products as $productObject) {
$color = $productObject->getColor();
$name = $productObject->getName();
$sku = $productObject->getSku(); // some things are retrieved even if you don't ask for them.
}
應讓你開始。有關如何檢索屬性的更多信息,請參見app/code/core/Mage/Catalog/Model/Product.php
。如果您仍然遇到問題,請發佈一些您嘗試過的代碼,然後繼續。
希望有幫助!
謝謝, Joe
相關問題
- 1. 在list.phtml中顯示產品屬性 - Magento
- 2. 在magento中回顯產品屬性head.phtml
- 3. Magento如何在產品頁面中顯示產品屬性?
- 4. Magento - 按屬性分類的產品
- 5. magento中的產品的多個屬性
- 6. 如何通過產品屬性獲取magento中的產品
- 7. 添加Magento產品屬性
- 8. Magento - 'samples_title'產品屬性
- 9. 如何使用SOAP V2拉所有產品及其屬性關閉Magento的
- 10. 加入產品對比magento使用產品屬性(類別)
- 11. 從所有類別的magento中獲取屬性的產品
- 12. 從另一產品屬性中獲取產品屬性?
- 13. Magento:從沒有產品的屬性集中獲取屬性
- 14. 在產品報告網格中添加下拉屬性Magento
- 15. Magento - 已計算產品屬性(屬性)
- 16. 如何從Magento獲取產品類別及其ID的列表?
- 17. 在產品頁面(目錄/產品/ view.phtml)中輸出產品屬性表
- 18. 用其他屬性過濾magento的產品屬性
- 19. 從Mysql Magento出口產品
- 20. Magento - 如何獲取捆綁產品的子產品的屬性
- 21. 從Magento中的可配置產品中刪除屬性
- 22. 如何創建產品屬性和屬性在magento中設置?
- 23. 產品屬性值分配到另一個產品屬性在Magento
- 24. Magento的 - 從產品
- 25. wordpress中的產品屬性
- 26. Magento產品排序產品分類
- 27. 在Magento中,如何從list.phtml中的產品ID獲取產品類型?
- 28. Magento - 產品頁面中的輸出分層屬性鏈接
- 29. 導入具有屬性的產品magento
- 30. Magento產品屬性的數量