2

My code shows a particular product as enabled while at the same time the magento admin/products panel says it is disabled. Are there two fields controlling its enabled/disabled status? Any insights would be welcome. Thanks in advance.

(My code below is a paraphrased from my actual code, but the crux bit is the same)

Code Snippet:

    $products = Mage::getResourceModel('catalog/product_collection')
    ->addAttributeToSelect(array('name','sku','price','special_price','final_price','product_status','special_to_date'))
    ->load();

    foreach ($products as $product) {  

           $zeroPriceZeroSpecialCount ++;

           $zeroPriceZeroSpecialHtml .= '<br>' . $zeroPriceZeroSpecialCount . 
                '  Name = '  . $product->getName(). 
                '  SKU = ' .$product->getSku(). 
                '  Status = ' .$product->getStatus(). 
                '  Price = ' . $product->getPrice() . 
                '  Special Price = ' . $product->getSpecialPrice() . 
                '  Final Price =  ' . $product->getFinalPrice() . 
                '  Special price To Date = ' .$product->getSpecialTODate(). 
                '<br>';
   }

  echo($zeroPriceZeroSpecialHtml);

My output:

14 Name = Dynamite Baits - Strawberry And Ice Cream Liquid 250ml SKU = Status = 1 Price = 7.9900 Special Price = Final Price = 7.99 Special price To Date

What Magento Admin/Manage Products Says: Screen Shot

2

I think you have a multistore and it is turned on on store base. The setting can be changed per store. In the upperleft you can switch between them, check for the store you are visiting on the frontend.

If you do not have a multisite(you cannot switch in the upperleft between them), please take a look in the database (catalog_entity_int) for the product id entity_id and attribute_id for status(probably 96), because after importing it can happen that status is only set for a specific store and not global, remove the record and set global status again.

0

Instead of loading whole collection load the specific product and then print product data like below:

    $product = Mage::getModel('catalog/product')->load(productid);
    var_dump($product->getData());

And check the values

-1

Try with this "$products = Mage::getModel('catalog/product')->getCollection()"

1
  • Hi, didn't work I'm afraid. Same result as before. – dmacgt Mar 17 '15 at 5:09
-1

Try using

$products = Mage::getModel('catalog/category')->load(2);

Load(2) is the id of the category you are trying to get.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.