【问题标题】:Magento - how to Retrieve products with a specific attribute valueMagento - 如何检索具有特定属性值的产品
【发布时间】:2013-10-08 09:09:31
【问题描述】:

起初我是 magento 的新手..

我只想显示使用属性过滤的产品值

我想运行类似www.somesite.com/something.php 的东西,我应该能够看到产品详细信息..

我已经找到了一些我怀疑的代码,但我不明白如何以www.somesite.com/something.php 运行该代码

请给我建议

【问题讨论】:

    标签: magento attributes magento-1.7


    【解决方案1】:

    您必须使用属性过滤器在您的收藏中执行以下操作:

    $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();
    

    【讨论】:

    • 我可以知道如何在某个 php 文件中运行您的代码吗?我只需要输入一些属性值,我应该得到具有该属性值的产品......
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多