1
votes

I can't seem to find this information on the Magento site (v 1.7.0.2 (stable)) and need clarification. I've recently taken over the maintenance of a Magento-based shopping site. They have shopping cart price rules set in the promotions that don't seem to be applying correctly.

I've seemed to narrow down the issue to configurable/simple products.

Here is an example of one of the pricing rules currently set: Pricing rule - 30% any product in certain categories Conditions - None Set Actions - If ANY of these conditions are TRUE : Category is one of xxx, xxx, xxx

The problem seems to be that the company is using configurable products and when they initially create the configuarable product they place all the correct categories on it but when they create the associated simple products, they don't place any categories on the simple products.

My question, long way around to it, is shouldn't the simple product inherit the categories of their parent configurable product? Is this something that can be easily remedied?

They have about 6000 products I would have to go back add the correct categories to if I have to add them to the simple product as well.

I hope that was clear enough. Thanks everyone!

2

2 Answers

0
votes

We seem to be having the same issue, running Magento 1.9. One solution we have found is to run a cron-job to apply the categories to the simple products of a configurable product. This should work, but I don't like the solution at all - very surprising a bug like this has made it all the way to version 1.9.

0
votes

Here is some SQL that will solve this problem. You can run it in a cron or whatever. First it removes all simple products from categories, then it adds them back to the categories that their parent configurable product belongs to, based on the current simple/configurable associations.

DELETE a FROM catalog_category_product AS a
LEFT JOIN catalog_product_entity AS b
    ON a.product_id = b.entity_id
WHERE b.type_id = 'simple' AND a.category_id != <<YOUR_ROOT_CATEGORY_ID>>

INSERT INTO catalog_category_product (category_id, product_id, position)
SELECT a.category_id, c.product_id, 0 FROM catalog_category_product AS a
LEFT JOIN catalog_product_entity AS b
    ON a.product_id = b.entity_id
LEFT JOIN catalog_product_super_link AS c
    ON b.entity_id = c.parent_id
WHERE b.type_id = 'configurable' AND c.product_id IS NOT NULL
ON DUPLICATE KEY UPDATE category_id = a.category_id, product_id = c.product_id, position = 0