magento - 如何以编程方式从 phtml 中的可配置产品中获取选项 ID 和值?
问题描述
如果我可以访问,我正在修改 phtml 代码
$this 恰好是 Mage_Checkout_Block_Cart_Item_Renderer_Configurable 类
和
$_item = $this->getItem();
$_product = $_item->getProduct();
其中产品是购物车中的可配置产品。
基于此,我需要获取选项 ID(样本)及其值的列表。
解决方案
例如,要获取特定尺寸选项 id :
$product = $_item->getProduct();
$idStore = $_item->getOrder()->getStoreId();
$sizeSpecificAttributeCode = 'specific_size';
$sizeAttributeOptionId = $product->getResource()
->getAttributeRawValue($product->getId(), $sizeSpecificAttributeCode,$idStore);
从相同的逻辑你可以得到样本或其他选项
推荐阅读
- jquery - jQuery 2 下拉列表相等的值不同的结果
- webpack - Webpack 4 在同一文件夹中将 sass 转换为 css
- scala - 在 Scala 中将映射序列转换为键映射到值序列
- solr - Solr如何将文件内容索引到多个字段?
- c# - 时间格式问题
- c# - 同一张桌子上的两个事件
- python - 熊猫 - 联合完成列
- c# - 无法加载文件或程序集 'System.IO, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 或其依赖项之一
- msbuild - 从 MSBuild 任务中获取属性值
- ios - 使用 swift 3 使用不同的标记映射注释