Magento Bundle - 获取选项的属性


Magento Bundle - Get attribute of option

在 select.phtml 中的/template/bundle/catalog/product/view/options/type/bundle/option/select.phtml 下,它具有为捆绑产品的选择下拉列表创建选项的功能。

默认设置对foreach $_selections as $_selection下的选项使用echo $this->getSelectionTitlePrice($_selection, false)

这会产生 [产品选项名称] +[价格差异]

我正在捆绑服装,我想将其更改为该选项的尺码属性("pos_sizes"),因为商品名称中没有尺码,尺码属性是唯一的区别,不会有价格差异。所以我非常想将选项更改为 [POS_SIZES] 属性的下拉选项。

我尝试了许多方法,包括

$_option->getAttributeText('pos_sizes')
$attribute=Mage::getModel('catalog/product')->getResource()->getAttribute("pos_sizes")

但无法显示选项的属性。

select.phtml 顶部的可用变量是

<?php $_option      = $this->getOption(); ?>
<?php $_selections  = $_option->getSelections(); ?>
<?php $_default     = $_option->getDefaultSelection(); ?>
<?php list($_defaultQty, $_canChangeQty) = $this->_getDefaultValues(); ?>

我快到了。再玩一点就明白了。我必须首先获取 $_selection 的 ID,然后从中获取 AttributeText。

$bundledsize = Mage::getModel('catalog/product')->load($_selection->getId())->getAttributeText('pos_sizes'); 
echo $bundledsize;