Magento加载产品集合,包括禁用产品 [英] Magento load product collection including disabled products

查看:51
本文介绍了Magento加载产品集合,包括禁用产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要按禁用状态过滤magento产品集合. Magento似乎默认情况下在加载收藏集时会忽略禁用的产品.

I need to filter a magento product collection by disabled status. Magento seems to by default ignore disabled products when loading the collection.

所以我的问题分为两部分:

So there are two parts to my question:

1-如何在仅包含禁用产品的magento中加载收藏集? 2-为什么magento首先不将禁用产品加载到集合中?

1 - How can i load a collection in magento containing only disabled products? 2 - Why is magento not loading disabled products in the collection to begin with?

我正在使用标准代码加载集合:

I am using standard code to load the collection:

$collction = Mage::getModel('catalog/product')->getCollection()

这永远不会加载禁用的产品.

this never loads disabled products.

推荐答案

如果使用产品平面结构,则

If you use the product flat structure, then

$col = Mage::getModel('catalog/product')->getCollection();

将使用平面表(例如catalog_product_flat_1),并且disabled产品不属于该表.

will use the flat table (eg. catalog_product_flat_1), and disabled products are not part of that table.

将配置Use Flat Catalog Product更改为"NO",您将拥有该集合中的所有产品:

Change the config Use Flat Catalog Product to "NO" and you will have all products in the collection:

它将以这种方式加载所有产品.

It will load all products this way.

这篇关于Magento加载产品集合,包括禁用产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆