1

Can Magento CE 1.8.1.0 apply global attribute variants of a configurable product?

Size: My global attribute for configurable product
For example: Test (Default configurable product)
Test-small (Different size, simple product associated of test)
Test-medium (Different size, simple product associated of test)
Test-large (different size, simple product associated of test)

My problem is if I filter small size I want to "test" product returned, not "test-small"

Please help me.

1

Layered navigation and indexing, indexes all attributes from all simple products associated with the configurable.

Therefore you can just create a configurable product, add all simple products and your configurable is found, when searched for small, medium and large.

| improve this answer | |
0

Can you expand your question? It is too narrow. What are you trying to achieve overall? Magento has methods to return an array of associated products given a simple product id.

`Mage::getResourceSingleton('catalog/product_type_configurable')->getParentIdsByChild($productId)`;

There is also a function to get the associated simple product IDs from a configurable product ID

//returns an array of array[ID]=>"ID" pairs
$childIds = Mage::getResourceSingleton('catalog/product_type_configurable')->getChildrenIds($productConfigurable->getId(), true);

I suggest some additional logic in your code to analyse your collection and extract what you want from the collection - you don't need to filter the collection so precisely because a couple of foreach loops will allow you to access what you need.

If you are concerned about speed then put the results of your foreach loops into the Magento Cache.

| improve this answer | |
  • In this example If I filter for "small size" I want to get "test" product, not "test-small" product. This is what I meant. – Ibrahim Mumcu Apr 8 '14 at 8:34
  • Then I don't know a better way other than building a collection to get the simple products that match "small size" and using getParentIdsByChild() to retrieve the configurable. – Malachy Apr 8 '14 at 8:38
  • But If I filter "small, medium, large" size, they will be return configurable product 3 times. It doesnt make sense. Right? @Malachy I'm trying to find better way. – Ibrahim Mumcu Apr 8 '14 at 8:41
  • Do you want it to just return one configurable? I don't know the details. You can just code to remove the duplicates using a foreach loop. I don't know a better way; maybe if you rewrote the resource model but I hardly think it is worth it. I have learned not to fight Magento - Work with what it gives you and add your own manipulation if you can't get what you want from a single collection call. I notice you are using Mage::getResourceModel('reports/product_collection') and not Mage::getResourceModel('catalog/product_collection') maybe that makes a difference if you can use it. – Malachy Apr 8 '14 at 10:05

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.