Magento's OOP system is very good, and this goodness sometimes creates problems for those who haven't yet gone deep into its structure.
If you closely follow the method "getUsedProducts()
" in the class "Mage_Catalog_Model_Product_Type_Configurable
", you will see that there are some "if
" logics provided, along with the usage of its properties (like "_usedProducts
", "_configurableAttributes
"). These obstruct you from getting the actual result, but the fault is not of Magento, instead the fault is because of the lack of Magento documentation.
Let me clear you about the first few lines of this method:-
Varien_Profiler::start('CONFIGURABLE:'.__METHOD__);
if (!$this->getProduct($product)->hasData($this->_usedProducts)) {
if (is_null($requiredAttributeIds) and is_null($this->getProduct($product)->getData($this->_configurableAttributes))) {
// If used products load before attributes, we will load attributes.
$this->getConfigurableAttributes($product);
// After attributes loading products loaded too.
Varien_Profiler::stop('CONFIGURABLE:'.__METHOD__);
return $this->getProduct($product)->getData($this->_usedProducts);
}
....
This method has 2 arguments - "$requiredAttributeIds
" (Configurable Attribute IDs) & "$product
" (configurable product object).
When calling this method, you are passing "null
" for the parameter "$requiredAttributeIds
", but you are providing the correct Configurable Product object "$product
".
This class has a property "_usedProducts
" (for maintaining the data of child simple products), which is set for every Configurable Product object. If this value has earlier been set, then Magento will return you the already available values to you. This is the main reason why you are getting the child products before the configurable product was updated.
So, what you can do is you can clear the full Cache Storage, along with refreshing all the Cache processes. May be then your result will work, because internally Magento stores all these used products data in cache.
Hope it helps.
It took a while but finally figured it out. When I created my attributes, in Attribute Properties where it says "Apply To:" I had only assigned it to configurable products, but you must also assign to simple products as well. (or just apply to all)
Keep in mind you will have to recreate your original configurable product before it will work.
Best Answer
I've finally found it, hours later. :)
I went through the server side code, the client js-scripts and came to the conclusion that even though the server side is updated, the js-scripts are the same. And they didn't get the data back I expected when the association was added. It all drilled down to the settings of the attribute that the configurable option was based upon (it seems the DB lookup is changed and the attribute affected the result). I found that the result sets from the db differed when a simple product was created before the upgrade, compared to a simple product created after the upgrade.
I think 1.5 is alot more picky when it comes to the settings as this attribute has been used for more then 500 products with no problem.
I changed the attribute to be valid for all product types and not mandatory. Now we can create Configurables again!