Get collection with promotional products not working
-
11-01-2021 - |
문제
I need to get a collection listing all products with a promotion, but I'm getting this error:
Fatal error: Call to a member function getBackend() on boolean
I tried those 2 solutions, but still getting the same error:
First try:
$collection = Mage::getResourceModel('reports/product_collection')->addAttributeToSelect('*')->addAttributeToFilter('promotion', 1);
Second try:
$collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('promotion', 1);
How can I solve that and get the list with only promotional products? Thanks in advance.
해결책
I solved changing my line to:
$collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('special_price', array('notnull' => true));
제휴하지 않습니다 magento.stackexchange