【发布时间】:2013-10-08 09:09:31
【问题描述】:
起初我是 magento 的新手..
我只想显示使用属性过滤的产品值
我想运行类似www.somesite.com/something.php 的东西,我应该能够看到产品详细信息..
我已经找到了一些我怀疑的代码,但我不明白如何以www.somesite.com/something.php 运行该代码
请给我建议
【问题讨论】:
标签: magento attributes magento-1.7
起初我是 magento 的新手..
我只想显示使用属性过滤的产品值
我想运行类似www.somesite.com/something.php 的东西,我应该能够看到产品详细信息..
我已经找到了一些我怀疑的代码,但我不明白如何以www.somesite.com/something.php 运行该代码
请给我建议
【问题讨论】:
标签: magento attributes magento-1.7
您必须使用属性过滤器在您的收藏中执行以下操作:
$collection->addAttributeToFilter('status',1); //only enabled product
或
$collection->addAttributeToFilter('created_at', array('date' => true, 'to' => $fromDate)); //product created
等
例如
$collection = Mage::getResourceModel('catalog/product_collection');
$collection->addAttributeToFilter('status',1); //only enabled product
$collection->setOrder('created_at', 'desc');
$collection->addAttributeToSelect('*'); //add product attribute to be fetched
$collection->addStoreFilter();
【讨论】: