Magento Forum

Cannot add 4 columns to front page product list. 
 
marcus32
Jr. Member
 
Total Posts:  18
Joined:  2012-09-16
 

Hello,

I’m trying to put a product grid on the front page of my store, which I’ve managed to do, but unfortunately, it doesn’t seem tor respond to my changes from 3 column to 4...The standard product view is 4 items (if I were to browse a category), but the front block doesn’t respond.

I’ve put this on my content:
{{block type="catalog/product_list" category_id="3" template="catalog/product/list.phtml" column_count="4"}}

as well as

{{block type="catalog/product_list" category_id="3" template="catalog/product/list.phtml" columnCount="4"}}

I’ve also even updated the catalog.xml to have a count of 4...yet the front page doesn’t comply...Please help!

 
Magento Community Magento Community
Magento Community
Magento Community
 
quicksand14
Sr. Member
 
Total Posts:  150
Joined:  2010-09-30
 

Is it listening to the rest of the code in this XML that you have? You could try to specify it a little differently:

<reference name="product_list">
    <
action method="setColumnCount"><count>4</count></action>
</
reference>
 
Magento Community Magento Community
Magento Community
Magento Community
 
marcus32
Jr. Member
 
Total Posts:  18
Joined:  2012-09-16
 

this is what i have in the catalog.xml

<block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
                <
block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
                    <
block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
                        <
block type="page/html_pager" name="product_list_toolbar_pager"/>
                        <!-- 
The following code shows how to set your own pager increments -->
                        <!--
                            <
action method="setDefaultListPerPage"><limit>10</limit></action>
                            <
action method="setDefaultGridPerPage"><limit>8</limit></action>
                            <
action method="addPagerLimit"><mode>list</mode><limit>10</limit></action>
                            <
action method="addPagerLimit"><mode>list</mode><limit>20</limit></action>
                            <
action method="addPagerLimit"><mode>list</mode><limit>30</limit></action>
                            <
action method="addPagerLimit" translate="label"><mode>list</mode><limit>all</limit><label>All</label></action>
                            <
action method="addPagerLimit"><mode>grid</mode><limit>8</limit></action>
                            <
action method="addPagerLimit"><mode>grid</mode><limit>16</limit></action>
                            <
action method="addPagerLimit"><mode>grid</mode><limit>24</limit></action>
                            <
action method="addPagerLimit" translate="label"><mode>grid</mode><limit>all</limit><label>All</label></action>
                        -->
                    </
block>
                    <!--
action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
                    <
action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
                    <
action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
                    <
action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
                    <
action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action-->
                    <
action method="setColumnCount"><count>4</count></action>
                    <
action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
                </
block>
            </
block>

I don’t know where else it would be, but it only affects the front page, and not the actual category view

 
Magento Community Magento Community
Magento Community
Magento Community
 
quicksand14
Sr. Member
 
Total Posts:  150
Joined:  2010-09-30
 

What code are you using to generate the products on the homepage? You may be talking to the wrong reference. I wouldn\’t be making changes in catalog.xml to change the homepage layout.

 
Magento Community Magento Community
Magento Community
Magento Community
 
marcus32
Jr. Member
 
Total Posts:  18
Joined:  2012-09-16
 

i’m not sure what you mean when you say generate code

I just placed this in my content for the page

{{block type="catalog/product_list" category_id="3" template="catalog/product/list.phtml" columnCount="4"}}

it is the correct category. 

and when I look at the list.phtml file, I don’t see anywhere where it limits the columns to 3

Here’s the code for the grid mode in list.phtml

<?php $_collectionSize $_productCollection->count() ?>
    <?php $_columnCount 
$this->getColumnCount(); ?>
    <?php $i
=0; foreach ($_productCollection as $_product): ?>
        <?php 
if ($i++%$_columnCount==0): ?>
        
<ul class="products-grid">
        
<?php endif ?>
            
<li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
                <
a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(140); ?>" width="140" height="140" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
                <
h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product$_product->getName(), 'name'?></a></h2>
                
<?php if($_product->getRatingSummary()): ?>
                <?php 
echo $this->getReviewsSummaryHtml($_product'short'?>
                <?php 
endif; ?>
                <?php 
echo $this->getPriceHtml($_producttrue?>
                
<div class="actions">
                    
<?php if($_product->isSaleable()): ?>
                        
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart'?></span></span></button>
                    
<?php else: ?>
                        
<class="availability out-of-stock"><span><?php echo $this->__('Out of stock'?></span></p>
                    
<?php endif; ?>
                    
<ul class="add-to-links">
                        
<?php if ($this->helper('wishlist')->isAllow()) : ?>
                            
<li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist'?></a></li>
                        
<?php endif; ?>
                        <?php 
if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
                            
<li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare'?></a></li>
                        
<?php endif; ?>
                    
</ul>
                </
div>
            </
li>
        
<?php if ($i%$_columnCount==|| $i==$_collectionSize): ?>
        
</ul>
        
<?php endif ?>
        <?php 
endforeach ?>
        
<script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
    <?php 
endif; ?>
 
Magento Community Magento Community
Magento Community
Magento Community
 
quicksand14
Sr. Member
 
Total Posts:  150
Joined:  2010-09-30
 

To clarify - you are using this code to display products on the homepage? Where are you putting this code?

{{block type="catalog/product_list" category_id="3" template="catalog/product/list.phtml" columnCount="4"}}

And it is doing everything you want except it is not displaying 4 products in the column? If so, how many is it displaying?

 
Magento Community Magento Community
Magento Community
Magento Community
 
marcus32
Jr. Member
 
Total Posts:  18
Joined:  2012-09-16
 

that is correct.  It’s working, but not showing properly....it’s showing 3, when I want 4.

 
Magento Community Magento Community
Magento Community
Magento Community
 
quicksand14
Sr. Member
 
Total Posts:  150
Joined:  2010-09-30
 

In your grid code

<?php $_columnCount $this->getColumnCount(); ?>
is looking for that column count.

You could try a few things (if you don\’t want to hardcode that) there but I think it is not seeing the proper page handle there. I think you should write it in the form of a <reference> in local.xml instead.

Here this user experience similar problem: http://www.magentocommerce.com/boards/viewthread/185889/

 
Magento Community Magento Community
Magento Community
Magento Community
 
marcus32
Jr. Member
 
Total Posts:  18
Joined:  2012-09-16
 

got it!

change that line to <?php $_columnCount = 4; ?>

and it works!  Thanks!

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