本文介紹了如何從 magento 電子商務中的特定類別中獲取產品的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我想從與當前產品相同的類別中獲取一個隨機產品列表,以便在產品視圖中顯示 - 到目前為止,我所挖掘的只是
I'd like to get a list of random products from the same category as the current product for displaying within the product view - so far all I've dug up is
Magento 產品按類別
有人知道怎么做嗎?
推薦答案
您基本上是加載類別,獲取產品集合,然后進行適當的過濾.
You basically load up the category, get the Product Collection and then filter appropriately.
$products = Mage::getModel('catalog/category')->load($category_id)
->getProductCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('status', 1)
->addAttributeToFilter('visibility', 4)
->addAttributeToFilter('special_price', array('neq' => ""))
->setOrder('price', 'ASC')
;
這篇關于如何從 magento 電子商務中的特定類別中獲取產品的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!