Magento Forum

ways to show products at the home page
 
Essaouera
Member
 
Total Posts:  45
Joined:  2008-01-22
 

Could you display the short_description on your home page? I can not do this on my project....

I had in New.php :
->addAttributeToSelect(array(’name’, ‘price’, ‘small_image’, ‘short_description’), ‘inner’)
and I keep in new.phtml:
<?php echo $this->helper('review/product')->getSummaryHtml($_product, 'short') ?>

[EDIT] Sorry, I just found the answer: replace in new.phtml
<?php echo $this->helper('review/product')->getSummaryHtml($_product, 'short') ?>
by
<?php echo $_product->getShortDescription() ?>

 
Magento Community Magento Community
Magento Community
Magento Community
 
buddhi
Jr. Member
 
Total Posts:  4
Joined:  2008-05-26
 

Is there a way to get the standard list and grid view for viewing the products in home page.. with pagination and switching grid/list view. so far i’ve been able to get the product list view yet, i cannot get the toolbar

adding the block

{{block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml"}}
doesn’t help and gives load of errors. has anyone been successful with similar task?
 
Magento Community Magento Community
Magento Community
Magento Community
 
VosSavant
Jr. Member
 
Avatar
Total Posts:  21
Joined:  2008-05-29
Colorado
 

@ Essaouera,

I am having trouble showing a short description via the homepage.phtml file supplied by dan. Currently, the relevant portion of the file looks like this:

// show a link to the product
<p><class="product-name" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>)"><?php echo $_product->getName() ?></a></p>
// (supposedly) show a short description of the product -- this is the line I'm interested in getting to work
<?php echo $this->helper('review/product')->getSummaryHtml($_product'short'?>
// show the price
<?php echo $this->helper('catalog/product')->getPriceHtml($_product?>

You were referring to a change in the new.phtml file in the template\category\product directory, but I tried it in the homepage.phtml file without luck.

Does anyone know how to get a short description to show on the homepage under featured products?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Kimura
Member
 
Avatar
Total Posts:  48
Joined:  2008-04-21
Hungary
 

Hello Guys, I’ve got a little problem with the new products

http://magento.viala.hu/

It works correctly the two different ways to show new products (the new product (selected by date)and the homepage choosen )

my problem with the new products, (what’s selected by date,) becouse not the newest products on the homepage, and

“Set Product as New from Date
Set Product as New to Date”

not works correctly

has anybody got a problem like this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Kimura
Member
 
Avatar
Total Posts:  48
Joined:  2008-04-21
Hungary
 

i wan’t to add somethint like this to homepage.php:

->addAttributeToFilter('qty', array('0'=>false))

to filter the products what’s out of box, but this code not works :S
what’s the variable name of the qty, or what’s the ggod code?

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
Essaouera
Member
 
Total Posts:  45
Joined:  2008-01-22
 
VosSavant - 30 May 2008 06:55 PM

@ Essaouera,

I am having trouble showing a short description via the homepage.phtml file supplied by dan. Currently, the relevant portion of the file looks like this:

// show a link to the product
<p><class="product-name" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>)"><?php echo $_product->getName() ?></a></p>
// (supposedly) show a short description of the product -- this is the line I'm interested in getting to work
<?php echo $this->helper('review/product')->getSummaryHtml($_product'short'?>
// show the price
<?php echo $this->helper('catalog/product')->getPriceHtml($_product?>

You were referring to a change in the new.phtml file in the template\category\product directory, but I tried it in the homepage.phtml file without luck.

Does anyone know how to get a short description to show on the homepage under featured products?

Did you modified the line

->addAttributeToSelect(array('name''price''small_image'), 'inner')
by
->addAttributeToSelect(array('name''price''small_image''short_description'), 'inner')
in homepage.php?
 
Magento Community Magento Community
Magento Community
Magento Community
 
Essaouera
Member
 
Total Posts:  45
Joined:  2008-01-22
 
Kimura - 03 June 2008 03:49 AM

Hello Guys, I’ve got a little problem with the new products

http://magento.viala.hu/

It works correctly the two different ways to show new products (the new product (selected by date)and the homepage choosen )

my problem with the new products, (what’s selected by date,) becouse not the newest products on the homepage, and

“Set Product as New from Date
Set Product as New to Date”

not works correctly

has anybody got a problem like this?

Do you have this in your new.php file:

->addAttributeToSort('news_from_date','desc')
?
 
Magento Community Magento Community
Magento Community
Magento Community
 
Essaouera
Member
 
Total Posts:  45
Joined:  2008-01-22
 

I have another question. I tried to show my special price products on my home page. I used the same code than for new product, I just modified new_from_date by special_from_date etc… but it selects every product....

class Mage_Catalog_Block_Product_Specials 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('special_from_date', array('date'=>true'to'=> $todayDate))
            ->
addAttributeToFilter(array(array('attribute'=>'special_to_date''date'=>true'from'=>$todayDate), array('attribute'=>'special_to_date''is' => new Zend_Db_Expr('null'))),'','left')
            ->
addAttributeToSelect(array('name''price''small_image''short_description'), 'inner')
            ->
addAttributeToSelect(array('special_price''special_from_date''special_to_date'), 'left')
        ;
        
$products->getSelect()->order('rand()');

        
/* @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->setPageSize(3)->setCurPage(1);

        
$this->setProductCollection($products);
    
}
}

Do you have an idea why every products are selected instead of those which have a special price?

 
Magento Community Magento Community
Magento Community
Magento Community
 
shopi
Member
 
Total Posts:  46
Joined:  2008-02-16
 

anyone know how to show the latest products of one category?

show all new products is no problem
but now i want to show all new products of category 7

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

hi there,

before the homepage is created, we make new attribute named “home_page_featured” as

$products   $product->setStoreId($storeId)->getCollection()

        ->
addAttributeToFilter('home_page_featured', array('yes'=>true))

        ->
addAttributeToSelect(array('name''price''small_image'), 'inner')

        ->
addAttributeToSelect(array('special_price''special_from_date''special_to_date'), 'left');

where we set our “home_page_featured” attribute with “Catalog Input Type for” to “YES/NO”,

Now, I change with “Catalog Input Type for” for “DropDown”, what will the addAttributeToFilter’s param should change to what ??

what should I replace this, “array(’yes’=>true” into ???

thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
castus
Member
 
Total Posts:  64
Joined:  2008-06-04
 

@shopi

To get products that are only in category 7 add this to you Homepage.php file line 40

->addAttributeToFilter('category_ids'7)

Although, I don’t think it works for products that are in more than 1 category, as the category IDs are shown as comma separated, like this 7,8,9 and I don’t know how to test for values within the commas.

 
Magento Community Magento Community
Magento Community
Magento Community
 
hansoloz
Jr. Member
 
Total Posts:  22
Joined:  2008-02-26
Minneapolis, MN
 
Jono - 13 May 2008 07:43 PM

You need to modify the php file

$products->setOrder('hot_deals')->setPageSize(5)->setCurPage(1);

change to

$products->setOrder('hot_deals')->setPageSize("YOURSIZE")->setCurPage(1);

Cheers

i’ve set the setPageSize to “15” and it is only displaying 6 products for some reason… any thoughts?

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

hi @hansoloz,

you set to 15 products, but only 6 products display,

check your homepage.phtml

<?php if ($i>5): continue; endif; ?>

change to

<?php if ($i>15): continue; endif; ?>

and make sure that you already select ‘YES’ at your products....

 
Magento Community Magento Community
Magento Community
Magento Community
 
thetoine
Jr. Member
 
Avatar
Total Posts:  21
Joined:  2008-06-04
Montreal, Canada
 
dan_w - 27 March 2008 05:53 AM

Ok, in order to put products on the homepage based on a custom attribute, you need a block, a template file, and a little bit of css markup. I have attached two files, Homepage.php and homepage.phtml. Homepage.php should be placed in app/code/core/Mage/Catalog/Block/Product/ and homepage.phtml should be placed in app/design/frontend/[your package]/[your theme]/template/catalog/product/. Homepage.php is based off of the new product block but instead of looking for a date period it looks for a custom attribute called ‘home_page_featured’, which leads me to the next step: creating the custom attribute. Create an attribute called ‘home_page_featured’ of the yes/no variety and add this to your default attribute group. You may choose whatever attribute label you wish. Now when you edit a product there will be a yes/no option for this attribute. Set the products that you want to appear on the homepage as yes.

First, thank you for this wonderful trick. Although, I think we should never put any new code into Mage’s core files. Make good usage of local.xml config file instead.

Move Homepage.php in code/local/[StoreName]/Catalog/Block/Product/Homepage.php

Then edit etc/local.xml and add this in the main <global> tag :

<blocks>
  <
catalog>
     <
rewrite>
        <
product_homepage>StoreName_Catalog_Block_Product_Homepage</product_homepage>
     </
rewrite>             
  </
catalog>
</
blocks>

Also, make sure your Homepage class is extending Mage correctly :

class StoreName_Catalog_Block_Product_Homepage extends Mage_Catalog_Block_Product_Abstract
 
Magento Community Magento Community
Magento Community
Magento Community
 
hansoloz
Jr. Member
 
Total Posts:  22
Joined:  2008-02-26
Minneapolis, MN
 
alkarim - 30 June 2008 11:40 PM

hi @hansoloz,

you set to 15 products, but only 6 products display,

check your homepage.phtml

<?php if ($i>5): continue; endif; ?>

change to
<?php if ($i>15): continue; endif; ?>

and make sure that you already select ‘YES’ at your products....

thanks alkarim!

missed that in the homepage.phtml… it’s working perfectly now.

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