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

Manufacturer on Homepage in New Products list [almost solved]
 
vicek
Jr. Member
 
Total Posts:  12
Joined:  2008-06-16
 

Hello i have small problem. I want to show a manufacturer of product in New Products list on Homepage.
Code php for this:

class Mage_Catalog_Block_Product_New extends Mage_Catalog_Block_Product_Abstract
{
    
public function __construct()
    
{
        parent
::__construct();

        
$storeId    Mage::app()->getStore()->getId();

        
$product    Mage::getModel('catalog/product');
        
/* @var $product Mage_Catalog_Model_Product */
        
$todayDate  $product->getResource()->formatDate(time());
        
$products   $product->setStoreId($storeId)->getCollection()
            ->
addAttributeToFilter('news_from_date', array('date'=>true'to'=> $todayDate))
            ->
addAttributeToFilter(array(array('attribute'=>'news_to_date''date'=>true'from'=>$todayDate), array('attribute'=>'news_to_date''is' => new Zend_Db_Expr('null'))),'','left')
            ->
addAttributeToSort('news_from_date','desc')
            ->
addAttributeToSelect(array('name''price''small_image','description'), 'inner')
            ->
addAttributeToSelect(array('special_price''special_from_date''special_to_date'), 'left')
        ;
        
/* @var $products Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection */

        
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
        
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);

        
$products->setOrder('news_from_date')->setPageSize(3)->setCurPage(1);

        
$this->setProductCollection($products);
    
}
}
i wont show the phtml file coz i will display manufacturer with:
$_product->getManufacturer()
i was trying to add manufacturer (tag/field) to that line:
->addAttributeToSelect(array('name''price''small_image','description'), 'inner')
but then products w/o selected manufacturer dont show , and if product have the manufacturer in manufacturer field i can see numbers (ex. 1,2,3,4,5,6 )
can someone help me ? i need it badly, hope everything can be understand. my english is poor
 
Magento Community Magento Community
Magento Community
Magento Community
 
vicek
Jr. Member
 
Total Posts:  12
Joined:  2008-06-16
 

anyone know ? i need it badly

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

The number returned by the function getManufacturer is certainly the manufacturer id in the database.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Gabriel Queiroz
Sr. Member
 
Total Posts:  135
Joined:  2008-05-28
Brasília, Brazil
 

Take a look on this thread: http://www.magentocommerce.com/boards/viewthread/1610/
It’s done using the layout xml. I got it working on the category listing, but not in the home page, though.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Joachim
Sr. Member
 
Avatar
Total Posts:  133
Joined:  2008-01-23
Netherlands
 

You should use <?=$_product->getAttributeText('manufacturer')?> to display the dropdown option instead of a number.

 
Magento Community Magento Community
Magento Community
Magento Community
 
alkarim
Guru
 
Total Posts:  368
Joined:  2008-04-10
 

hi @vicek, try this

$products   $product->setStoreId($storeId)->getCollection()
                ->
addAttributeToSelect(array('name''price''image','short_description','manufacturer','description','upc'), 'inner');

make sure you have done to add some field at manufacturer attribute

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