Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Nur Artikel mit Bestand >0
 
Jonnysol
Member
 
Total Posts:  40
Joined:  2008-06-15
 

Hallo,

wie kann ich folgenden code erweitern, dass nur Artikel mit einem Bestand größer NULL ausgegeben werden?

public function getListLatestProducts($fieldorder 'entity_id'$order 'rand()')
    
{
        $storeId    
Mage::app()->getStore()->getId();
        
$cateids $this->getConfig('catsid');
        
$productids = array();
        if(
$cateids != null)
        
{
            
foreach($this->getListCategory() as $cat){
                $arr_productids 
$this->getProductByCategory($cat->getId());
                
$productids array_merge($productids$arr_productids);
            
}
            $products 
Mage::getResourceModel('reports/product_collection')
            ->
addAttributeToSelect('*')
            ->
addAttributeToSelect(array('name''price''small_image')) //edit to suit tastes
            
->addIdFilter($productids)// id product
            
->setStoreId($storeId)
            ->
addStoreFilter($storeId)
            ->
setOrder ($fieldorder,$order//latest product
            
;
        
}
        
else
        
{
            $products 
Mage::getResourceModel('reports/product_collection')
            ->
addAttributeToSelect('*')
            ->
addAttributeToSelect(array('name''price''small_image')) //edit to suit tastes
            
->setStoreId($storeId)
            ->
addStoreFilter($storeId)
            ->
setOrder ($fieldorder,$order//latest product
            
;
        
}
        Mage
::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
        
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
        
$this->setProductCollection($products);
        
$products->getSelect()->order('rand()'); //random
        
$products->addStoreFilter();
        
$numProducts $this->getNumProducts() ? $this->getNumProducts() : 12//Artikel begrenzen
        
$products->setPage(1$numProducts)->load();

    
}
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top