查看内容

Magento1.x 首页调用产品数量并进行数量控制

2017-8-18 15:45| 发布者: lutish| 查看: 599| 评论: 0

 $category = Mage::getModel('catalog/category')->load($this->getCategoryId());
$products = Mage::getModel('catalog/product')->getCollection();
Mage::getSingleton('cataloginventory/stock')
->addInStockFilterToCollection($products);
$products->addCategoryFilter($category);
$products->addAttributeToSelect(array('name', 'thumbnail', 'price','special_price')); //feel free to add any other attribues
$products->addAttributeToSort("entity_id","DESC");
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
//$products->getSelect()->order('RAND()');
$products->addAttributeToSort("entity_id","DESC");
//$products ->setOrder('ordered_qty', 'desc') ;
$products->getSelect()->limit(12);
$_columnCount = 4;
$i=0;
?>









  • getName(); ?>









    getSpecialPrice()) {
    ?>








    currency($_product->getPrice(),true,false); ?>





    currency($_product->getSpecialPrice(),true,false); ?>


    }else{

    echo Mage::helper('core')->currency($_product->getPrice(),true,false);


    }
    ?>









    canConfigure() && $_product->isSaleable()): ?>

    getStockItem() && $_product->getStockItem()->getIsInStock()): ?>
    __('View Details') ?>

    __('Out of stock') ?>








后台控制调用代码

{{block type="core/template" category_id="3" template="catalog/product/list_home.phtml"}}

适合于1.9.3.4及后续1.X版本。

返回顶部