为什么我的(可配置产品)选项/属性不显示在产品页面上?

时间:2011-09-11 17:59:40

标签: magento magento-1.5 configurable-product

Magento ver。 1.5.1.0

我有一个属性设置“服装”

集合中有两个属性:“size”和“color”

尺寸是必需的,颜色是可选的(即并非所有产品都有任何颜色选项)。

我创建了一些设置了Size的简单产品,但Color只有空值。

在相关可配置产品的产品页面上,未显示任何选项输入!在产品view.phtml中,如果我回显$ this-> hasOptions(),它会打印一个空字符串,即False。

如果我将Color设置为非空值,则产品页面上会显示两个选择框,并且echo $ this-> hasOptions()会打印1,即True。

这对我来说没有意义,不确定失败了什么?

1 个答案:

答案 0 :(得分:3)

我正在与类似的东西挣扎,并注意到与你所描述的相似的行为。

首先检查产品是否实际配置正确。这是从SO中的另一篇文章中获取的,意味着是控制器的一部分。放在前端../template/catalog/product/view.phtml只是为了检查。

<?php
$_helper = $this->helper('catalog/output');
$_product = $this->getProduct();
?>

<?php 
if ($_product->isConfigurable()) {
$configurable = $_product->getTypeInstance();
$attributes = $configurable->getConfigurableAttributes($_product);
foreach ($attributes as $attribute) {
    print $attribute->getLabel();
    print "<br />";
  }
}
?>

作为答案,我认为您在自定义选项和可配置产品之间变得混乱。

相关问题