Magento Forum

   
How do i add NEW products to Homepage? 
 
EdY888
Jr. Member
 
Total Posts:  7
Joined:  2008-10-21
 
brendan. - 05 September 2008 01:40 AM

Hey,

Yep been in your position and it can be frustrating!

In Administration
1. Goto the CMS\Manage Pages
2. Open the Homepage
3. Select the Custom Design Option
4. Add the following

Between the section <reference name="content"> and </reference> add in the code for New Products as shown below

<reference name="content">

<!-- New 
Products -->
 <
block type="catalog/product_new" name="home.catalog.product.new" alias="product_new" template="catalog/product/new.phtml"
after="product_featured"/>

</
reference>

Now, Just make sure you have some products which have the date parameters set for the new products.

You should be good

cheers
Brendan

Thank so much for the post.  I followed the directions and got new products to appear on the homepage, However, the products are not centered and are aligned to the far left--flush with the left most border of the left column.

How do I center the New products grid on my home page?

Thanks so much

Ed

 
Magento Community Magento Community
Magento Community
Magento Community
 
EdY888
Jr. Member
 
Total Posts:  7
Joined:  2008-10-21
 

Hello,
When I follow the directions above, I am getting New Products but they are aligning with the Left border fo the site?

Can anyone tell me what I have done incorrectly?

Also, I was able to edit the /app/design/frontend/default/default/template/catalog/product/new.phtml FILE

Around line 32, the code below is the relvant part wherein the “2” of line <?php if ($i>2): continue; endif; ?> configures the number of products to display per row.

<?php $i=0; foreach ($_products->getItems() as $_product): ?>
        <?php 
if ($i>2): continue; endif; ?>

How do I get the homepage to display a specified number of rows.  Let’s say I want 4 rows with 3 products on each row.

Thanks so much

Ed

Image Attachments
store snapshot.jpg
 
Magento Community Magento Community
Magento Community
Magento Community
 
screege
Sr. Member
 
Total Posts:  107
Joined:  2008-05-08
 

Edy did you manage to find a solution, I have a problem with new products it displays 5 products only invading my right column blocks and getting behind the fifth product, how can I tell magento to display 4 products and then create a new row to display the other products, this is driving me mad and I can’t believe the store just doesn’t does this like others does natively.

thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
rudack
Jr. Member
 
Total Posts:  10
Joined:  2008-07-09
 

Same problem as above mentioned.  I can not find the proper solution.  Is anyone able to help?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Leo27
Sr. Member
 
Total Posts:  127
Joined:  2008-10-08
 
screege - 16 November 2008 05:39 AM

Edy did you manage to find a solution, I have a problem with new products it displays 5 products only invading my right column blocks and getting behind the fifth product, how can I tell magento to display 4 products and then create a new row to display the other products, this is driving me mad and I can’t believe the store just doesn’t does this like others does natively.

thanks

Hi, well to change it to display only 4 products just check your new file located “/app/design/frontend/default/default/template/catalog/product/new.phtml” now change this <?php if ($i>5): continue; endif; ?> to <?php if ($i>3): continue; endif; ?>. now it will display only 4 products. Now, about ading a new row, I don’t know how yet, but I’m checking it now.

Best Regards
L. Nunes

 
Magento Community Magento Community
Magento Community
Magento Community
 
SelfSuicide
Jr. Member
 
Total Posts:  9
Joined:  2008-11-16
 

Thanks a lot Brendan. I really appreciate your help. I was struggling to display the products, now i am am able to manage well. Thanks again.

 
Magento Community Magento Community
Magento Community
Magento Community
 
cntbill
Sr. Member
 
Total Posts:  107
Joined:  2008-11-29
PA
 
Leo27 - 17 November 2008 01:22 PM

screege - 16 November 2008 05:39 AM
Edy did you manage to find a solution, I have a problem with new products it displays 5 products only invading my right column blocks and getting behind the fifth product, how can I tell magento to display 4 products and then create a new row to display the other products, this is driving me mad and I can’t believe the store just doesn’t does this like others does natively.

thanks

Hi, well to change it to display only 4 products just check your new file located “/app/design/frontend/default/default/template/catalog/product/new.phtml” now change this <?php if ($i>5): continue; endif; ?> to <?php if ($i>3): continue; endif; ?>. now it will display only 4 products. Now, about ading a new row, I don’t know how yet, but I’m checking it now.

Best Regards
L. Nunes

I know this is an older thread, but I am having I believe a similar problem. The problem only shows in IE6 (don’t use IE7 so don’t know) while FireFox and Safari display just fine.

I tried the suggestion above, but other than less items showing up, new products are still listed on the bottom left instead in the center. 

Has someone found a solution? As I am spending way too much time in layout/design and am not getting products listed.

Thanks,

Bill…

 
Magento Community Magento Community
Magento Community
Magento Community
 
cristache
Member
 
Total Posts:  72
Joined:  2008-12-06
Bucuresti - Romania
 

This is a quote from this thread http://www.magentocommerce.com/boards/viewthread/16287/

If someone want to show more than 5 new product in home page.
Try This…
This example to show 10 items in 2 rows 5 products each.

You need to change the line in \app\code\core\Mage\Catalog\Block\Product\New.php
$products->setOrder(’news_from_date’)->setPageSize(5)->setCurPage(1);
change to
$products->setOrder(’news_from_date’)->setPageSize(10)->setCurPage(1);

Andneed to change new.phtml
<?php if ($i>5): continue; endif; ?>
change to
<?php if ($i==5):  echo "</tr><tr>"; endif; ?>
<?php if ($i>9): continue; endif; ?>

If someone wants let’s say 4 rows, simply do this:

<?php if ($i==3):  echo "</tr><tr>"; endif; ?>
<?php 
if ($i==6):  echo "</tr><tr>"; endif; ?>
<?php 
if ($i==9):  echo "</tr><tr>"; endif; ?>
<?php 
if ($i==12):  echo "</tr><tr>"; endif; ?>
<?php 
if ($i>12): continue; endif; ?>
This ($i==3) shows the products on the first row. If you want let’s say 4, than you have to chage also the other numbers (6,9,12) to 8,12,16

Hope this helps. It worked for me.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Rick Bradford
Jr. Member
 
Total Posts:  9
Joined:  2009-02-04
 

I made the change in new.php to reduce the number of items to 4 from the default of 5 and it worked perfectly—although the code looks a bit different than above. This is the line I changed:

const DEFAULT_PRODUCTS_COUNT 4;

I also made the changes above to new.phtml like so:

<?php $i=0; foreach ($_products->getItems() as $_product): ?>
        <?php 
if ($i==4): echo "</tr><tr>"; endif; ?>
        <?php 
if ($i==8): echo "</tr><tr>"; endif; ?>
        <?php 
if ($i==12): echo "</tr><tr>"; endif; ?>
        <?php 
if ($i==16): echo "</tr><tr>"; endif; ?>
        <?php 
if ($i>15): continue; endif; ?>

But I have two problems:

1. It’s not adding the other three rows. (I wasn’t sure if the number in the final line should be 16 or 15 but either gets the same result so far.)

2. It’s not showing the most recent products. The products themselves should be okay as they are showing under “Your Recently Viewed”.

I’m a novice (to say the least) so I hope I’m communicating the info okay. Any suggestions would be greatly appreciated!

 
Magento Community Magento Community
Magento Community
Magento Community
 
cristache
Member
 
Total Posts:  72
Joined:  2008-12-06
Bucuresti - Romania
 

in this line

const DEFAULT_PRODUCTS_COUNT 4;
you should place 16 instead of 4. If you leave 4, homepage will show only 4 products, that’s why you didn’t see he rest of the rows.

Hope that helps.
Cheers!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Rick Bradford
Jr. Member
 
Total Posts:  9
Joined:  2009-02-04
 

Hi, thanks very much for your reply. I made those two changes and the results were that I’m now back to seeing five new products with only one row (as if no changes had been made).

What have I missed?

I’ve opened both files back up to double-check my edits and this is what those lines look like. These are the only edits I’ve made to these files and I’m editing and saving through cPanel.

const DEFAULT_PRODUCTS_COUNT 16;

<?php $i=0; foreach ($_products->getItems() as $_product): ?>
        <?php 
if ($i==4): echo "</tr><tr>"; endif; ?>
        <?php 
if ($i==8): echo "</tr><tr>"; endif; ?>
        <?php 
if ($i==12): echo "</tr><tr>"; endif; ?>
        <?php 
if ($i==16): echo "</tr><tr>"; endif; ?>
        <?php 
if ($i>16): continue; endif; ?>

Thanks again!

 
Magento Community Magento Community
Magento Community
Magento Community
 
cristache
Member
 
Total Posts:  72
Joined:  2008-12-06
Bucuresti - Romania
 

First of all, I apologize for the mistake here

<?php if ($i>15): continue; endif; ?>
The corect number is 15, not 16. I will edit the above code to correct that.

Secondly, did you check your System/Configuration/Catalog/Frontend settings? Maybe you have the default 5 instead of 16.

Hope that helps! Keep in touch!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Rick Bradford
Jr. Member
 
Total Posts:  9
Joined:  2009-02-04
 

Ah, I didn’t think about System/Configuration/Catalog/Frontend—unfortunately, however, that doesn’t seem to be the problem. I even changed the Grid allowed values (4,8,12,16) and the Grid default value (tried both 16 and 4) and it didn’t impact the front page.

I changed ($>16) to 15 as well.

I appreciate your time; if you’ve got any other suggestions I’m listening!

 
Magento Community Magento Community
Magento Community
Magento Community
 
cristache
Member
 
Total Posts:  72
Joined:  2008-12-06
Bucuresti - Romania
 

Sorry Rick, I have no other suggestions for the moment.
I am not a programmer, all I’ve changed in my custom theme I’ve learned here, on the forum. And everything I’ve posted here were parts of code from other threads that helped me.

Hope you can make it somehow.
Cheers!

EDIT: However, on a second thought, I might have the solution. Please tell me, what is the script in your homepage? Please check CMS/Manage pages and then select homepage and look for the script in General information/Content or Custom design/Layout update XML.

Waiting for your answer.
Good day!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Rick Bradford
Jr. Member
 
Total Posts:  9
Joined:  2009-02-04
 

Hi, sorry for not responding sooner, here’s what I’ve got in:

General Information > Content:

<div class="col-left side-col">
<
class="home-callout">
</
p>
</
div>

and Custom Design > Layout Update XML:

<reference name="content">
<
block type="catalog/product_new" name="home.catalog.product.new" alias="product_new" template="catalog/product/new.phtml" after="cms_page">
<
action method="addPriceBlockType">
<
type>bundle</type><block>bundle/catalog_product_price</block><template>bundle/catalog/product/price.phtml</template></action></block>
<
block type="reports/product_viewed" name="home.reports.product.viewed" alias="product_viewed" template="reports/home_product_viewed.phtml" after="product_new"><action method="addPriceBlockType"><type>bundle</type><block>bundle/catalog_product_price</block><template>bundle/catalog/product/price.phtml</template></action></block>
<
block type="reports/product_compared" name="home.reports.product.compared" template="reports/home_product_compared.phtml" after="product_viewed"><action method="addPriceBlockType"><type>bundle</type><block>bundle/catalog_product_price</block><template>bundle/catalog/product/price.phtml</template></action></block>
</
reference><reference name="right">
<
action method="unsetChild"><alias>right.reports.product.viewed</alias></action>
<
action method="unsetChild"><alias>right.reports.product.compared</alias></action>


<!-- New 
Products -->
 <
block type="catalog/product_new" name="home.catalog.product.new" alias="product_new" template="catalog/product/new.phtml"
after="product_featured"/>

</
reference>

Thanks again!

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