JND*_*PNT 11 collections product magento
我试图获得整个magento产品系列,没有任何过滤器或限制,但我没有得到所有产品.
我已经尝试了各种方法,但它们都给我一个非常有限的产品选择.假设商店包含5000个产品,但它只显示500个.当我检查目录时 - >产品确实显示了整个列表.
Mage::getModel('catalog/product')->getCollection();
Mage::getResourceModel('catalog/product_collection')->addAttributeToSelect('*');
Mage::getModel("catalog/product")->getResourceCollection()->load();
Run Code Online (Sandbox Code Playgroud)
所有这些都返回相同的数量(500),而我希望它给我5000个产品.我宁愿不使用Zend或PHP,只是坚持使用Magento方式来获取它们.
有谁知道如何真正获得所有产品或可以指出我正确的方向为什么这不起作用?
返回的select-string是:
SELECT 1 AS `status`, `e`.`entity_id`, `e`.`type_id`, `e`.`attribute_set_id` FROM `catalog_product_flat_4` AS `e`
Run Code Online (Sandbox Code Playgroud)
ash*_*med 13
//to overwrite limit but you need first to increase your memory limit
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*') // select all attributes
->setPageSize(5000) // limit number of results returned
->setCurPage(1); // set the offset (useful for pagination)
// we iterate through the list of products to get attribute values
foreach ($collection as $product) {
echo $product->getName(); //get name
echo (float) $product->getPrice(); //get price as cast to float
echo $product->getDescription(); //get description
echo $product->getShortDescription(); //get short description
echo $product->getTypeId(); //get product type
echo $product->getStatus(); //get product status
// getCategoryIds(); returns an array of category IDs associated with the product
foreach ($product->getCategoryIds() as $category_id) {
$category = Mage::getModel('catalog/category')->load($category_id);
echo $category->getName();
echo $category->getParentCategory()->getName(); // get parent of category
}
//gets the image url of the product
echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).
'catalog/product'.$product->getImage();
echo $product->getSpecialPrice();
echo $product->getProductUrl(); //gets the product url
echo '<br />';
}
Run Code Online (Sandbox Code Playgroud)
Ale*_*dre 10
这样的事情:
$products = Mage::getModel('catalog/product')->getCollection();
foreach($products as $prod) {
$product = Mage::getModel('catalog/product')->load($prod->getId());
}
Run Code Online (Sandbox Code Playgroud)
通过这种方法,我获得了超过500但我的所有产品......
| 归档时间: |
|
| 查看次数: |
66669 次 |
| 最近记录: |