A question for any magento devs:

Why is it that an enabled product has status 1, while a disabled product has a status of 2? Usually, "enabled" or "active" or whatever gets the status 1, while the converse is 0. Is there a reason why magento uses 2 here instead?

  • Often wondered this myself, no idea though. It's presumably not a boolean value. Is there another state other than enabled or disabled? – JamesAllwood Nov 12 '13 at 9:54
  • 2
    @JamesAllwood Nope. Mage_Catalog_Model_Product_Status defines STATUS_ENABLED and STATUS_DISABLED, nothing else. – Benubird Nov 12 '13 at 10:01
  • Beautiful question, inadvertently helped answer something I was trying to figure out! – SR_Magento Jul 29 '14 at 10:44

First of all the values shouldn't even be important.
Use in your code these constants Mage_Catalog_Model_Product_Status::STATUS_ENABLED and Mage_Catalog_Model_Product_Status::STATUS_DISABLED.
The reason I found so far is that when you want to create a product, in most cases you want it to be enabled. If the value for status disabled was 0, then this will be selected because the way that the current values are passed to the form through $form->setValues($data).
When creating a product $data is empty and, in the case of dropdowns, 0 = empty.
I just remembered something else.
Initially the status had a separate table and there were 3 possible values.

insert  into {$this->getTable('catalog_product_status')}(`status_id`,`status_code`) values (1,'Enabled'),(2,'Disabled'),(3,'Out-of-stock');

And you could add more. check app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-install-0.7.0.php.
This approach was dropped in mysql4-upgrade-0.7.4-0.7.5.php and I guess that for compatibility they kept the ids of the statuses.

DROP TABLE IF EXISTS {$this->getTable('catalog_product_status')};
| improve this answer | |
  • "First of all the values shouldn't even be important." They are when you're creating a csv import file! – jscar Jun 26 '17 at 13:12
  • No they are not. You can just blindly take the values and use them in the import. – Marius Jun 26 '17 at 14:17
  • OK, I think I understand your original point now. Let me rephrase - it's important to know what the values are when doing an import :) The fact that they are 1 & 2 is counter-intuitive. Would expect 0 & 1 – jscar Jun 26 '17 at 15:55

the product status value comes from the "status" select field from product management in admin. the "enabled" and "disabled" are the options of the select field with values 1 and 2. these are not boolean values.

| improve this answer | |

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.