在Magento 1.5.1.0的vanilla安装中,我创建了简单的产品COLOR-RED,COLOR-BLUE并创建了一个可配置的产品COLOR,其中包含与之相关的产品。除了在可配置产品的“超级产品属性配置”表的后端中未显示相关产品的名称这一事实外,这一切都很好。 我在htdocs / app / design / adminhtml / default / default / template / widget / grid.phtml中添加了一个简单的调试语句,以便在显示之前显示项目的数据。见下文,name属性不存在。 有人知道为什么吗?它是Magento中的一个错误,还是其他错误?
Array
(
[entity_id] => 1
[entity_type_id] => 4
[attribute_set_id] => 9
[type_id] => simple
[sku] => COLOR-RED
[has_options] => 0
[required_options] => 0
[created_at] => 2011-12-13 15:08:36
[updated_at] => 2011-12-13 15:08:36
[is_saleable] => 0
[inventory_in_stock] => 0
[color] => 3
[price] => 12.0000
[stock_item] => Varien_Object Object
(
[_data:protected] => Array
(
[is_in_stock] =>
)
[_hasDataChanges:protected] =>
[_origData:protected] =>
[_idFieldName:protected] =>
[_isDeleted:protected] =>
)
)
答案 0 :(得分:3)
您可能正在使用Simple Configurable Products模块。在文件app / code / community / OrganicInternet / SimpleConfigurableProducts / Adminhtml / Block / Catalog / Product / Edit / Tab / Super / Config / Grid.php中,Organic Internet的开发人员留下了一个不错的小提示;
#Copied from Magento v1.3.1 code. #Only need to comment out addFilterByRequiredOptions but there's no #nice way of doing that without cutting and pasting the method into my own #derived class. Boo. #This change stops the filtering-out of any configurable product's 'associated products' that have compulsory custom options #Have also replaced parent::_prepareCollection with Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
我认为1.3.1中使用的代码已经过时,因此如果您使用> 1.3.1,此文件将过时。所以我只看了核心文件app / code / core / Mage / Adminhtml / Block / Catalog / Product / Edit / Tab / Super / Config / Grid.php的内容,寻找差异,找到了罪魁祸首。
您只需添加此行;
->joinAttribute('name', 'catalog_product/name', 'entity_id', null, 'inner')
这两行之间;
->addFieldToFilter('attribute_set_id',$product->getAttributeSetId())
->addFieldToFilter('type_id', $allowProductTypes);
你们都准备好了!