Recent Posts


Product Status is Not a Boolean


Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

Magento Version:

Let’s say you have a product object

$p = Mage::getProduct('catalog/product')->load(3425);

You can get the value of the product’s status with the magic getter method or the getData method.


However, the return value of this method is not a boolean. The value of a product object’s status (Enabled, Disable by default) is the numerical value of the select in the admin. A false status means a status value isn’t set. It doesn’t mean that the status is disabled

    echo "No Status Set";
else if($p->getStatus() == 1)
    echo "Status: Enabled";
else if($p->getStatus() == 2)
    echo "Status: Disabled";

Not rocket science, but one of those little gotchas that can easily trip you up.

Update: Fabian over on the twitters points out that there’s class constants for the various status values.


Shame on me

Copyright © Alana Storm 1975 – 2023 All Rights Reserved

Originally Posted: 10th October 2011

email hidden; JavaScript is required