0

I have tried searching for this one but haven't had much luck. I have over 15k products in my Magento store. At some point we set some of the product's weight to 999. Now I need to generate a list of all of the products that have that set for the weight. I have been trying to find which table in the mysql database that has this information but I can't seem to find it.

In the end I am trying to make a SQL statement that gives me all the product ids for products whose weight is set to 999.

Thank you in advance to anyone who can help.

1 Answer 1

1

The code approach:

Mage::app()->setCurrentStore(0);
$collection = Mage::getResourceModel('catalog/product_collection')
    ->addAttributeToFilter('weight', '999');
$ids = $collection->getAllIds();
//$ids is an array with what you are looking for

The SQL approach.

First get the weight attribute id.

SELECT 
    e.attribute_id 
FROM
    eav_attribute e 
LEFT JOIN 
    eav_entity_type et 
ON 
    e.entity_type_id = et.entity_type_id
WHERE 
    et.entity_type_code = 'catalog_product' AND
    e.attribute_code = 'weight'

Now get all the product ids with the weight 999

SELECT 
    entity_id 
FROM 
    catalog_product_entity_decimal
WHERE
    attribute_id = {RESULT FROM PREV QUERY} AND
    value = 999
1
  • That worked perfectly, thank you very much Marius!
    – Pat
    Commented Dec 24, 2014 at 21:14

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.