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.