構成可能な製品に属性を設定しました。サイズ選択ドロップダウンで L サイズの製品の在庫がないことを表示したいです。
私はこれのコードを手に入れましたが、それはmagento 1.4用で、magento 1.6を使用しています
コードは
mage/catalog/block/product/view/type/configurable.php の ~85 行目には、次のようなものがあります。
foreach ($this->getAllowAttributes() as $attribute) {
$productAttribute = $attribute->getProductAttribute();
$attributeValue = $product->getData($productAttribute->getAttributeCode());
if (!isset($options[$productAttribute->getId()])) {
$options[$productAttribute->getId()] = array();
}
if (!isset($options[$productAttribute->getId()][$attributeValue])) {
$options[$productAttribute->getId()][$attributeValue] = array();
}
$options[$productAttribute->getId()][$attributeValue][] = $productId;
}
したがって、その foreach loop で、できれば foreach 行の直後に、次のコードを挿入します。
$options['qty'][$product -> getAttributeText($productAttribute->getName())] = floor($product->getStockItem()->getQty());
その後、〜128行目に次のようなものがあります:
$info['options'][] = array(
'id' => $value['value_index'],
'label' => $value['label'] ,
'price' => $this->_preparePrice($value['pricing_value'], $value['is_percent']),
'products' => isset($options[$attributeId][$value['value_index']]) ? $options[$attributeId][$value['value_index']] : array(),
);
replace it with this :
$info['options'][] = array(
'id' => $value['value_index'],
'label' => ($options['qty'][$value['label']] <= 0) ? $value['label'] . ' * out of stock' : $value['label'] . " * (".$options['qty'][$value['label']]." in stock)",
'price' => $this->_preparePrice($value['pricing_value'], $value['is_percent']),
'products' => isset($options[$attributeId][$value['value_index']]) ? $options[$attributeId][$value['value_index']] : array(),
);
magento1.6による変更点を教えてください。