0
私は以下のコードを使用して、attribute set "size"
のオプションIDを取得しています。 オプションラベルが9より大きい場合(つまり10,12,13,14 ..)、正しいIDを返しています一部のラベルでmagento getOptionIdが動作しない
オプションラベルが10未満の場合(つまり5,6,7 、8,9)。
$attr = 'size';
$attribute_label = 13;
$_product = Mage::getModel('catalog/product');
$attribute_name = $_product->getResource()->getAttribute($attribute_name);
if ($attr->usesSource()) {
echo $color_id = $attribute_name->getSource()- >getOptionId($attribute_label);
}
例:
出力私は13それ 戻り5.
出力Iは、オプションのラベルを使用する場合($ attribute_label =とオプションのラベルを($ attribute_label = 13)を使用します6)は6として返す 6.
をあなたは以下試すことができます記事 –