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

[Solved] Problem with loading products
 
altansar
Member
 
Total Posts:  51
Joined:  2008-07-08
 

Hello !

I have a problem with a custom code since I upgraded Magento to 1.2.0 .

this code loads products from a specific category :

protected function _getFeaturedProducts(){
        
        $store_id 
Mage::app()->getStore()->getId();
        
$product Mage::getModel('catalog/product');
        
$category Mage::getModel('catalog/category')->load(13);
        
        
$visibility = array(  
             
Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,  
             
Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG  
        
);
        
$products $product->setStoreId($store_id)
            ->
getCollection()
            ->
addAttributeToFilter('visibility'$visibility)
            ->
addCategoryFilter($category)
            ->
addAttributeToSelect(array('name','small_image','price','url_key'), 'inner')
        ;
        
$this->_featuredProducts $products;
    
}

Since I’ve upgraded Magento, this code does not load any product whereas I could have correct datas before.
Thanks for your help.

 
Magento Community Magento Community
Magento Community
Magento Community
 
altansar
Member
 
Total Posts:  51
Joined:  2008-07-08
 

Ok I’ve solved this problem.

I use this code to load products from a category, featured products, where I put products I want to be displayed on the home page.
I don’t want this category to appear in the store menu so I did not putted it under the root category but at the same level.

It seems that with Magento 1.2 you can’t load a category that is not under the root category with my code.....
So I moved my featured products category under the root category and set Is active to no.

 
Magento Community Magento Community
Magento Community
Magento Community
 
andreladocruz
Guru
 
Total Posts:  322
Joined:  2008-05-07
Brazil
 

where do you use this code?

This code may help me with one category issue.

regards

 
Magento Community Magento Community
Magento Community
Magento Community
 
altansar
Member
 
Total Posts:  51
Joined:  2008-07-08
 

I use this code to pick products from a category with additional parameters.

You can find a useful article to deal with this kind of feature here :

http://www.exploremagento.com/magento/some-custom-blocks-to-help-you-show-products.php

 
Magento Community Magento Community
Magento Community
Magento Community
 
andreladocruz
Guru
 
Total Posts:  322
Joined:  2008-05-07
Brazil
 

have you seen this topic

http://www.magentocommerce.com/boards/viewthread/27238/?

there were a easier way to do that…

but with this rudge problems in categories, it´s not working by now.

regards,

 
Magento Community Magento Community
Magento Community
Magento Community
 
altansar
Member
 
Total Posts:  51
Joined:  2008-07-08
 

Yes I know how to load a category with smarty tags, the code I posted here is just a sample of a class I’ve written for a custom module.

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