在 Magento 1.5.1.0 的普通安装中,我创建了简单的产品“COLOR-RED”、“COLOR-BLUE”,并创建了一个可配置的产品“COLOR”,将这些产品与其关联。这一切正常,除了关联产品的名称未显示在可配置产品的“ super 产品属性配置”表的后端中这一事实之外。 我在 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] =>
)
)
最佳答案
您可能正在使用简单可配置产品模块。在文件 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);
一切准备就绪!
关于magento - 可配置产品的关联产品名称在管理中不可见?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8491838/