Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Configurable Product “Available” status should change dynamically, when it’s size & color are changed
 
VIVEK SHAH
Jr. Member
 
Total Posts:  18
Joined:  2010-06-24
Ahmedabad
 

Hello,

I have done setting and code changes for changing product “Availability” setting when it’s size and color settings are changed, for some products it is working, but not commonly for all configurable products.

Actually my issue is related to getting qty for simple product when it’s particular color is selected from drop down in configurable product, what possibly could be issue?

Can somebody help me out ?

Configurable.php

$optionPrices = array();
$prices = $attribute->getPrices();
if (is_array($prices)) {
foreach ($prices as $value) {
if(!$this->_validateAttributeValue($attributeId, $value, $options)) {
continue;
}
$currentProduct->setConfigurablePrice(
$this->_preparePrice($value[’pricing_value’], $value[’is_percent’])
);
$currentProduct->setParentId(true);
Mage::dispatchEvent(
‘catalog_product_type_configurable_price’,
array(’product’ => $currentProduct)
);
$configurablePrice = $currentProduct->getConfigurablePrice();

if (isset($options[$attributeId][$value[’value_index’]])) {
$productsIndex = $options[$attributeId][$value[’value_index’]];
} else {
$productsIndex = array();
}
$info[’options’][] = array(
‘id’ => ($options[’qty’][$value[’label’]] <= 0) ? ‘outofstock’ : $value[’value_index’],
‘label’ => $value[’label’],
‘price’ => $configurablePrice,
‘oldPrice’ => $this->_preparePrice($value[’pricing_value’], $value[’is_percent’]),
‘products’ => $productsIndex,
);
$optionPrices[] = $configurablePrice;
//$this->_registerAdditionalJsPrice($value[’pricing_value’], $value[’is_percent’]);
}
}

Configurable.js

if(options) {
var index = 1;
for(var i=0;i<options.length;i++){
var allowedProducts = [];
if(prevConfig) {
for(var j=0;j<options.products.length;j++){
if(prevConfig.config.allowedProducts
&& prevConfig.config.allowedProducts.indexOf(options.products[j])>-1){
allowedProducts.push(options.products[j]);
}
}
} else {
allowedProducts = options.products.clone();
alert(allowedProducts);
}

if(allowedProducts.size()>0){
options.allowedProducts = allowedProducts;
element.options[index] = new Option(this.getOptionLabel(options, options.price), options.id);
if (typeof options.price != ‘undefined’) {
element.options[index].setAttribute(’price’, options.price);
}
element.options[index].config = options;
index++;
}
}
}

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top