magento db select on limit
piaoling 2011-07-29 10:25:29
$collection = $this->getProductCollection($storeId);
$select = $collection->getSelect();
$select->join(array('cat_index'=>'catalog_category_product_index'),"cat_index.product_id=e.entity_id and cat_index.store_id='$storeId' AND cat_index.category_id in ('10','17')",array('*'));
$select->where("cat_index.product_id>35")
->orWhere("cat_index.product_id<135");
$select->limit(7,2);//first param is the rows number needed to return ,the second param is the offset
$collection = $collection->getItems();
foreach ($collection as $product){
//var_dump($product->getData('category_ids'));
$prodCats =$product->getData();
echo $product->getId();
var_dump($prodCats);
}
发表评论(评论将通过邮件发给作者):