Try the Demo

Magento Forum

   
New Products in Homepage! 
 
patriciamg
Jr. Member
 
Total Posts:  13
Joined:  2008-03-14
 

Please HELP!!!!
I still haven´t fix this issue here:

I´ve set my homepage to display new products and it´s working fine, except when it comes to present the products in more than one line/row. I currently have 8 new products so, the ideal situation would be showing those 8 products in two rows 4+4. But if I adjust the product limit to 8, the products will be displayed in the same row!!!!!
Isn´t there a way to either display one row and have a “next page” button to show the rest? or at least have more than one row displayed???
I don´t understand why nowone else is getting this same problem....

(pic in attachment)

thanks

Image Attachments
1.jpg
 
Magento Community Magento Community
Magento Community
Magento Community
 
patriciamg
Jr. Member
 
Total Posts:  13
Joined:  2008-03-14
 

hello ohminu!

I´ve used the code people posted in the forum, like:
in CMS>Homepage>Contens
“{{block type="catalog/product_new" template="catalog/product/new.phtml" “}}

and used the new.php and new.phtml provided with the package.

new.phtml

<?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
<div class="box recently">
<h3><?php echo $this->__('New Products') ?></h3>
<table cellspacing="0" class="recently-list" id="recently-compared-list-table">
<tr>
<?php $i=0; foreach ($_products->getItems() as $_product): ?>
<?php if ($i>10): continue; endif; ?>

<td>
<div>
<a href="<?php echo $_product->getProductUrl() ?>” title="<?php echo $this->htmlEscape($_product->getName()) ?>">
<img class="product-image" src="<?php echo $_product->getSmallImageUrl() ?>” width="100" height="75" alt="<?php echo $this->htmlEscape($_product->getName()) ?>"/>
</a>
</div>
<p><a class="product-name" href="<?php echo $_product->getProductUrl() ?>” title="<?php echo $this->htmlEscape($_product->getName()) ?>)"><?php echo $this->htmlEscape($_product->getName()) ?></a></p>
<?php echo $this->helper('review/product')->getSummaryHtml($_product, 'short') ?>
<?php echo $this->helper('catalog/product')->getPriceHtml($_product) ?>
<?php if($_product->isSaleable()): ?>
<button class="form-button" onclick="setLocation(’<?php echo $this->getAddToCartUrl($_product) ?>’)"><span><?php echo $this->__('Add to Cart') ?></span></button>
<?php else: ?>
<div class="out-of-stock"><?php echo $this->__('Out of stock') ?></div>
<?php endif; ?>
<div class="clear"></div>
<p class="add-to">
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<a href="<?php echo $this->getAddToWishlistUrl($_product) ?>” class="link-cart"><?php echo $this->__('Add to Wishlist') ?></a>
<?php endif; ?>
<?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?><br/>
<a href="<?php echo $_compareUrl ?>"><?php echo $this->__('Add to Compare') ?></a>
<?php endif; ?>
</p>
</td>

<?php $i++; endforeach; ?>
<?php for($i;$i%4!=0;$i++): ?>
<td> </td>
<?php endfor ?>
</tr>
</table></div>
<?php endif; ?>

and new.php

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’), ‘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(4)->setCurPage(1);

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

thanks:)

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

hi patriciamg,
you should change the code at new.phtml and its css

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

Hello

which data where I can change the new products number at the homepage?

thanks

 Signature 

sokkal szerényebben

 
Magento Community Magento Community
Magento Community
Magento Community
 
chiaraweb
Guru
 
Avatar
Total Posts:  721
Joined:  2008-03-21
Aviano ~ Italy
 

try to change the width of your layout (maybe 3-columns) and set the same width of the main content, I think that now is set to “auto”
I don’t know how you can do to add the 2nd page link, maybe in this way the products will be show under (2 rows)

 Signature 

Believe Yourself

My Magento Shop http://www.ecobaby.it

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

thank you, but I found it :

@ patriciamg - Have you tried changing this line in \app\code\core\Mage\Catalog\Block\Product\New.php
$products->setOrder(’news_from_date’)->setPageSize(5)->setCurPage(1);
Change 5 to whatever you want.
I’m just guessing as I haven’t tested this.

another qouestion: have you got a filter to this new.php, what’s doing this:

you can’t see the out of box products at the homepage

aother problem:

if I put this to the catalog xml:

<block type="customer/form_login" name="mini_login" template="customer/form/mini.login.phtml" />

the original code is this :

<reference name="left.menu">
            <
block type="catalog/navigation" name="catalog.leftnav" template="catalog/navigation/leftnav.phtml"/>
            <
block type="catalog/product_homepage" name="home.catalog.product.homepage" alias="product_homepage" template="catalog/product/homepage.phtml"/>
            <
block type="checkout/cart_sidebar" name="cart_sidebar" before="-" template="checkout/cart/sidebar.phtml"/>
        </
reference>
the login box not being invisible when you logged in :s

but if i put it to the costumer xml, it’ in the left.navs bottom

<customer_logged_out>
        <
reference name="top.links">
            <
action method="addLink" translate="label title" module="customer"><label>Log In</label><url helper="customer/getLoginUrl"/><title>Log In</title><prepare/><urlParams/><position>100</position></action>
        </
reference>
        <
remove name="wishlist_sidebar"></remove>
        <
remove name="reorder"></remove>
        <
reference name="left.menu">
            <
block type="customer/form_login" name="mini_login" template="customer/form/mini.login.phtml" />
        </
reference>
    </
customer_logged_out>

have you got any idea, how to put it to the left.menu-s top?

 Signature 

sokkal szerényebben

 
Magento Community Magento Community
Magento Community
Magento Community
 
patriciamg
Jr. Member
 
Total Posts:  13
Joined:  2008-03-14
 

Thanks for the suggestions, Chiaraweb an Alkarim!
Do you happen to know which file should I edit to change the width of the central/content column?
I have a 3 column layout, as you already notice:)

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

at the boxes.css:

.col-3-layout .col-main { width:550px; margin-left:17px; }

 Signature 

sokkal szerényebben

 
Magento Community Magento Community
Magento Community
Magento Community
 
patriciamg
Jr. Member
 
Total Posts:  13
Joined:  2008-03-14
 

thanks Kimura:)

 
Magento Community Magento Community
Magento Community
Magento Community
 
chiaraweb
Guru
 
Avatar
Total Posts:  721
Joined:  2008-03-21
Aviano ~ Italy
 

have you resolved Patricia?

 Signature 

Believe Yourself

My Magento Shop http://www.ecobaby.it

 
Magento Community Magento Community
Magento Community
Magento Community
 
patriciamg
Jr. Member
 
Total Posts:  13
Joined:  2008-03-14
 

not really… the size of that column isn´t “auto” after all...it´s already set to:
.col-3-layout .col-main { width:475px; margin-left:17px; }

:(

 
Magento Community Magento Community
Magento Community
Magento Community
 
patriciamg
Jr. Member
 
Total Posts:  13
Joined:  2008-03-14
 

I´ve already tried to force a spcecific size to the table in the new.phtml, but nothing....
I just don´t get it how many people got this solution right for themselves. It seem nobady´s complaining about this…
Maybe I´ll try another alternative...I´ll put a specific category (news category) displayed at the home. It already comes with the category grid formating, so it´ll be easier.

Does anyone know where to change (file) the grid elements?

Thanks

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

Here is my new.phtml:

<div <?php

?> 
                                        <?php 
if (($_products $this->getProductCollection()) && $_products->getSize()): ?>
<div class="box recently">
                                        <
h3><?php echo $this->__('New Products'?></h3>
<
div>

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

<
div class="newbox"><div class="newboxh" valign="center"><p><class="product-name" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>)"><?php echo $this->htmlEscape($_product->getName()) ?></a></p></div
        <
div>
            <
a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>">
            <
div align="center"
         <
div class="corner_box" >
    <
class="corner_top_open">
        <
class="c_b"><class="c1_f"></b></b>
        <
class="c_b"><class="c2_f"></b></b>

        <
class="c_b"><class="c3_f"></b></b>
        <
class="c_b"><class="c4_f"></b></b>
        <
class="c_b"><class="c5_f"></b></b>

        <
class="c_b"><class="c6_f"></b></b>
        <
class="c_b"><class="c7_f"></b></b>
        <
class="c_b"><class="c8_f"></b></b>    
        <
class="c_b"><class="c9_f"></b></b>    
        <
class="c_b"><class="c10_f"></b></b>    
    </
b>
               
        <
div class="corners">         <img class="product-image" src="<?php echo $_product->getSmallImageUrl() ?>" width="80" height="77" alt="<?php echo $this->htmlEscape($_product->getName()) ?>"/>
            </
a>
                     </
div
            
             <
class="corner_bottom">
        <
class="c_b"><class="c10_f"></b></b>    
        <
class="c_b"><class="c9_f"></b></b>    
        <
class="c_b"><class="c8_f"></b></b>    
        <
class="c_b"><class="c7_f"></b></b>

        <
class="c_b"><class="c6_f"></b></b>
        <
class="c_b"><class="c5_f"></b></b>
        <
class="c_b"><class="c4_f"></b></b>

        <
class="c_b"><class="c3_f"></b></b>
        <
class="c_b"><class="c2_f"></b></b>
        <
class="c_b"><class="c1_f"></b></b>

    </
b>
</
div
            
        </
div>
        </
div
   
        
<?php echo $this->helper('review/product')->getSummaryHtml($_product'short'?>

               <?php 
echo $this->helper('catalog/product')->getPriceHtml($_product?>
            <?php 
if($_product->isSaleable()): ?>
            
<button class="form-button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('Add to Cart'?></span></button>
            
<?php else: ?>
            
<div class="out-of-stock"><?php echo $this->__('Out of stock'?></div>
            
<?php endif; ?>
            
<div class="clear"></div>
            <
class="add-to">
                
<?php if ($this->helper('wishlist')->isAllow()) : ?>
                
<a href="<?php echo $this->getAddToWishlistUrl($_product) ?>" class="link-cart"><?php echo $this->__('Add to Wishlist'?></a>
                
<?php endif; ?>
                <?php 
if($_compareUrl=$this->getAddToCompareUrl($_product)): ?><br/>
                <
a href="<?php echo $_compareUrl ?>"><?php echo $this->__('Add to Compare'?></a>
                
<?php endif; ?>
            
</p>

<?php $i++; endforeach; ?>
<?php 
for($i;$i%6!=0;$i++): ?>
        
<td>&nbsp;</td>
    
<?php endfor ?>


<?php 
endif; ?> </div>     </div></div>

and the css codes:

.newbox { float: left; height: 273px; width: 180px; background:  #fff; /*background-image: url(../images/newboxbg.gif) ;*/border-bottom: 1px dashed #c5c5c5; border: 1px dashed #c5c5c5;border-left: 1px dashed #c5c5c5;margin-right: 5px; margin-left: 5px; margin-bottom: 20px;}
.newboxh { width:170px; height: 45px; background-image: url(../images/newboxh.gif) ; margin: 5px; }
.corner_box { width: 100px; }
.corners { border-left: 1px solid #c5c5c5; border-right: 1px solid #c5c5c5; }
.corner_top_open *{
display: block;
height: 1px;
overflow: hidden;
background-image: url(gr.gif);
}
.corner_bottom *{
display: block;
height: 1px;
overflow: hidden;
background: #fff;
}
.c_b {
margin-left: 0px;
margin-right: 0px;
background: #fff;
z-index: 0;
}
.c1_f {
margin-left: 7px;
margin-right: 7px;
background: #c5c5c5;
}
.c2_f {
margin-left: 5px;
margin-right: 5px;
border-left: 3px solid #c5c5c5;
border-right: 3px solid #c5c5c5;
}
.c3_f {
margin-left: 4px;
margin-right: 4px;
border-left: 2px solid #c5c5c5;
border-right: 2px solid #c5c5c5;
}
.c4_f {
margin-left: 3px;
margin-right: 3px;
border-left: 2px solid #c5c5c5;
border-right: 2px solid #c5c5c5;
}
.c5_f {
margin-left: 2px;
margin-right: 2px;
border-left: 2px solid #c5c5c5;
border-right: 2px solid #c5c5c5;
}
.c6_f {
margin-left: 1px;
margin-right: 1px;
border-left: 2px solid #c5c5c5;
b

Image Attachments
Untitled-1.gif
 Signature 

sokkal szerényebben

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

table.recently-list td {width:120px; margin-right: 20px;padding: 5px; border-right: 1px solid #48a9d6; }

another in boxes.cc what you should see

 Signature 

sokkal szerényebben

 
Magento Community Magento Community
Magento Community
Magento Community
 
patriciamg
Jr. Member
 
Total Posts:  13
Joined:  2008-03-14
 

Kimura, I´ve tried out your code but now I get only one column and one row per product:

prod
+
prod
+
prod

...

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

you can play with widths and float left-s in the css.

use firebug with outline block level elements, and you will see what’s wrong
http://www.getfirebug.com/

 Signature 

sokkal szerényebben

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