Hello,
I am trying to create a product feed. When I load the product collection, any filter I try to not include disabled product do not work.
Code:
<?php
require_once 'app/Mage.php';
umask(0);
Mage::app('default');
$products = Mage::getModel('catalog/product')->getCollection();
$products->addAttributeToSelect('*');
//$products->addAttributeToFilter('status', array('value'=>1));
//$products->addAttributeToFilter('status', array('eq'=>'1'));
//$products->addAttributeToFilter('status', 1);
//Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
$products->load();
foreach($products as $product) {
echo $product->getData('name')."<br />";
//var_dump($product->getStatus());
}
?>
As you can see I try to filter them different ways (they are now commented out, but I tried them one by one):
$products->addAttributeToFilter(’status’, array(’value’=>1));
$products->addAttributeToFilter(’status’, array(’eq’=>’1’));
$products->addAttributeToFilter(’status’, 1);
Mage::getSingleton(’catalog/product_status’)->addVisibleFilterToCollection($products);
Also, $product->getStatus() always returns 1, even if the product is disabled
o_0
Please help! (looks like it adds to all single and double quote on this forum)
|