简体   繁体   English

如何获取给定主要类别ID的产品集合?

[英]How to get product collection of given main category id?

In my website I have several stores available. 在我的网站上,我有几家商店。 One particular store contains both the simple and configurable products. 一个特定的商店同时包含简单和可配置的产品。 This is a huge collection of products. 这是大量产品。 What is the fastest way to get all enabled products (including child products of configurable products) collection of this store by store id? 通过商店ID获取此商店的所有已启用产品(包括可配置产品的子产品)的最快方法是什么?

Note: I tried this lot of different ways. 注意:我尝试了很多不同的方法。 But it takes loo much time. 但是这花费了很多时间。 Sometimes cause to crash the server even. 有时甚至导致服务器崩溃。

Note : I'm using Magento CE 1.3 注意:我使用的是Magento CE 1.3

Any suggestions will be appreciated. 任何建议将不胜感激。

$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect(array('name', 'url_key','price','lowest_price','service_id','description','short_description'));

$collection->addStoreFilter();

instead of use addAttributeToSelect('*') use only specific attributes which you needed because it effect performance of site 而不使用addAttributeToSelect('*'),仅使用所需的特定属性,因为这会影响网站的性能

hope this will help you 希望这个能对您有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM