0

Trying to enable all products based on category. I have category id = 14. Went into MySQL PHPMyAdmin and fetched all products from that category:

SELECT * FROM catalog_category_product where category_id=14 And then I am not sure what to do with it since the products within this table don't contain a column with enabling or disable options in it.

Is there other tables I could look int? using Magento 1.9

1
  • 1
    Have you looked at Magmi? Commented Jul 5, 2014 at 18:02

2 Answers 2

5

You really don't want to use raw SQL for this. Magento's database is less a well defined and normalized relational database, and more a general storage container for Magento's objects. A product's "Status" is actually an attribute, and that attribute data is stored in one of the product's EAV tables. Removing this row, or setting a value that some logic in Magento normally prevents might put your system in an invalid state and cause application bugs.

Additionally, your system may have observer methods that look for product status changes and perform other actions. If you directly manipulation the database tables these actions won't happen — again, potentially causing bugs.

If you're interested in learning more about this, here's a query that will let you view the value of the status attribute.

select eava.attribute_id, eava.backend_type, eava.attribute_code, eavet.entity_type_code,
cpei.entity_id as product_id, cpei.value
FROM eav_attribute eava 
LEFT JOIN eav_entity_type eavet ON eava.entity_type_id = eavet.entity_type_id
LEFT JOIN catalog_product_entity_int cpei on cpei.attribute_id = eava.attribute_id
WHERE eava.attribute_code = 'status' AND eavet.entity_type_code='catalog_product'; 

The values for this particular attribute come from the following class

#File: app/code/core/Mage/Catalog/Model/Product/Status.php
class Mage_Catalog_Model_Product_Status extends Mage_Core_Model_Abstract
{
    //...
    static public function getOptionArray()
    {
        return array(
            self::STATUS_ENABLED    => Mage::helper('catalog')->__('Enabled'),
            self::STATUS_DISABLED   => Mage::helper('catalog')->__('Disabled')
        );
    }

    //...

}
1

I could explain how to do this in the database, but as you don't seem that familiar with the database structure, I'd suggest installing this free extension -

http://www.magentocommerce.com/magento-connect/enhanced-admin-grids-editor.html

It will allow you to add a category filter to the manage product grid, so you can filter by the category, and then enable them all in a batch operation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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