1
我不得到理解complety行为添加的自定义属性OS在Magento集合。接下来,I'll说明问题:Magento-不容检索集合中的产品型号
对于项目的要求,我需要添加自定义属性在GoogleShopping在饲料中排除severals产品。然后,添加与PHP脚本安装
<?php
$installer = $this;
$installer->startSetup();
$installer->addAttribute('catalog_product', 'in_googleshopping_feed', array(
'group' => 'General',
'type' => 'int',
'input' => 'select',
'label' => 'In GoogleShoppint feed',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => 1,
'required' => 0,
'default' => 1,
'visible_on_front' => 0,
'is_html_allowed_on_front' => 0,
'sort_order' => 32,
'is_configurable' => 0,
'source' => 'eav/entity_attribute_source_boolean',
'searchable' => 0,
'filterable' => 0,
'comparable' => 0,
'unique' => false,
'user_defined' => false,
'is_user_defined' => false,
'used_in_product_listing' => true
)
);
$installer->endSetup();
接下来,在观察我试图找回这与值这个属性:
$products = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*')
//->addAttributeToSelect('in_googleshopping_feed');
->addAttributeToFilter('in_googleshopping_feed',0);
这是我的疑问,为什么haven't收集这个属性?
不过,我可以检索Product_Model的价值丝毫的下一个片段:
$products = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*');
$prodIds=$products->getAllIds();
foreach($prodIds as $productId):
$product = Mage::getModel('catalog/product')->setStoreId('1');
$product->load($productId);
var_dump($product->getData('in_googleshopping_feed'));
endforeach;
然后,我的巨大的疑问是:为什么我不能用我的新属性过滤收集? 我认为与方法addAttributeToSelect(“*”)的所有字段添加到集合。
谁能帮我? 谢谢
非常感谢,我认为这是一个frecueltly错误与收集工作。但在核心/社区的许多地方我看到addAttributeToFilter无阵列。例如,在Find_Feed_Model_Import在该行的Magento 105 1.5.1.0可以看到$ productCollection-> addAttributeToFilter( 'is_imported',1);你知道如果在某些情况下工作,无数组? – davidselo 2012-07-05 14:47:27