3

Im trying to show a few products on my homepage

I got pretty far using this code:

{{block type="catalog/product_list" name="product_list" category_id="74" column_count="5" num_products="24" mode="grid" template="catalog/product/list.phtml"}}

I also added a display: none; to the css to remove the option and filter thing from the product vieuw block. to let it look more natrual on the homepage

<style><!--
.cms-home .pager, .cms-home .sorter, .toolbar, .pager {
    display: none;
}
--></style>

But my problem is: i can't get more products on it as my average 12.

I already tried:

1>> I tried to let the catolog page use an diffrent "show amount" so instead of 12 i changed it to use 36 with the custom xml bellow. this worked on the catolog path (wich is now offline) but does not work with my block on the homepage (also tried to add this custom xml to the homepage)

<reference name="product_list_toolbar">
 <action method="setDefaultGridPerPage">
<limit>36</limit></action></reference>

2>> I tried alot of extra block options but none of them seems to take effect. few of them are bellow: (there are a few more as this but i cant find them anymore, aslo tried it on amount 36)

products_per_page="50" products_count="50" count="9" limit="9" num_products="24"

3>> edit also tried the following blocks

<p>{{block type="catalog/product_list" name="product_list" category_id="74" column_count="5" count="24" limit="24" mode="grid" template="catalog/product/list.phtml"}}</p>
<p>{{block type="catalog/product_list" name="product_list" category_id="74" column_count="6" count="6" limit="4" mode="grid" template="catalog/product/list.phtml"}}</p>
<p>{{block type="catalog/product_list" name="product_list" alias="products_homepage" category_id="74" template="catalog/product/list.phtml"}}</p>
<p>{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="74" column_count="6" products_per_page="50" products_count="50" count="9" limit="9" num_products="24" template="catalog/product/list.phtml"}}</p>
<p>{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="9" template="catalog/product/list.phtml"}}</p>

4>> edit Tried the following custom xml code:

<reference name="content">
    <!-- Overwrite the view template -->
    <block type="catalog/product_list" template="catalog/product/list.phtml">
      <action method="setLimit">36</action>
 </block>

5>> edit Products per page on grid allowed values. I got 12,24,36 because i need column=3 on my product page with 4 bellow each other.

question: Does anyone knows how to get more as 12 products with this block? or get around it on a different way.

Fabian Schmengler
  • 65,791
  • 25
  • 187
  • 421
Marco de Wit
  • 41
  • 1
  • 4
  • try this

    {{block type="catalog/product_list" name="product_list" category_id="3" column_count="6" count="6" limit="4" mode="grid" template="catalog/product/list.phtml"}}

    – seb May 06 '16 at 08:19
  • hello klettseb, i tried your block and it shows 2 rows of 6 (so still 12 in total and not the 19 as are in the category_id at this moment). I also tried to change some of it in this: column_count="5" count="24" limit="24" but still only showing 12 in total. – Marco de Wit May 06 '16 at 08:32
  • What if you dont use a number in there? like this

    {{block type="catalog/product_list" name="product_list" alias="products_homepage" category_id="9" template="catalog/product/list.phtml"}}

    – seb May 06 '16 at 08:35
  • hello Klettseb, just tried your last block and it shows my normal catogory page (without the top part ofcorse becasue of my custom css on the homepage) so it shows 3 X 4 so still 12 total. – Marco de Wit May 06 '16 at 08:39
  • in System > configuration > catalogue > Front End > Products per Page on Grid Allowed Values what values do you have? – Ahmed Elawadi May 06 '16 at 10:58
  • hello Ahmed Elawadi, these values are 12,24,36 (this is because i need 3 x 4 on each catogory page) but on the homepage i smallered the text / prices to optimalize it for column_count 5 and i probitly want to show 20 - 25 products – Marco de Wit May 06 '16 at 11:08
  • Hi. Have a look at this article : http://www.proxiblue.com.au/blog/smarter-cms-category-product-limits/ Although the example is different i think you are having the same issue where the collection limit is forced to be the toolbar page size. In you case 12. The article describes how to override this limit value with your own. Although not exactly what you wsnt ( if i understand your question correctly ) the idea may help. You could manipulate the collection in a similar manner to achieve your results. – ProxiBlue Dec 18 '16 at 13:32

2 Answers2

0

Go to the homepage in the CMS -> Manage pages and add the following code snippet into the editor there

You could also use the same code to drill down into a specific category, by adding the category variable, e.g. be aware that here you have list_custom.phtml so you need to copy this there and just copy the list.phtml.

{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="9" template="catalog/product/list_custom.phtml"}}

1) app\design\frontend\default\<your theme>\template\catalog\product copy list.phtml and save as list_custom.phtml

2) Now open list_custom.phtml and search for the following snippet. I have edited the $_columnCount = 4 as I want 4 products in one row and I have 4 products to show in the line if($i == 4) break;. So for you you will need the columntcount you want and then 36 as a break.

<?php // Grid Mode ?>
<?php $_collectionSize = $_productCollection->count() ?>
<?php //$_columnCount = $this->getColumnCount(); ?>
<?php $_columnCount = 4; ?>
<?php $i=0; foreach ($_productCollection as $_product): ?>
<?php 
$_productId = $_product->getId();?>
<?php if($i == 4) break; ?>
<?php if ($i++%$_columnCount==0): ?>
<ul class="products-grid row">
seb
  • 3,572
  • 3
  • 25
  • 57
  • Hello @Klettseb, thankyou for your answer. I tried both the layout update and the block. The block showed 3 x 4 products (as is defauld) and the layout update showed 3 x 4 with an bigger layout, this was also with random products. After that i tried your block with all the extra options as I got on ""2>>"" but still only 12 products and not 19 as are curently in catogory 74. Do you have an other solution? – Marco de Wit May 11 '16 at 12:02
  • My last known option, the other ones used to work for me – seb May 11 '16 at 12:09
  • http://magento.stackexchange.com/questions/62678/show-products-with-specific-attribute-on-cms-page – seb May 12 '16 at 07:42
  • hello @klettseb, i like to try out your code but i am not that good in php can you please let me on what line nr. i have to put the code? i tried to find if endings but there are atleast 6 of them on the php. (already tried some but only got synax errors on my homepage) i quickly uploaded my list.phtml to: http://verwarmland.nl/media/wysiwyg/list.phtml for you to see how mine looks – Marco de Wit May 12 '16 at 10:58
  • where you have this line right now – seb May 12 '16 at 11:00
  • hello @klettseb, the last 20 min i tried to put it somewhere around that line but i have realy no clue where to put the lines, i keep getting syntax errors. Can you tell me exactly where to put the code? (as i read your descition i tougth code 1 code 2 – Marco de Wit May 12 '16 at 11:48
  • Replace that line – seb May 12 '16 at 11:48
  • hello klettseb, i did this (replace the code with your code): http://verwarmland.nl/media/wysiwyg/list_new.phtml to the code but i got a syntax error im sorry if im doing something stupid – Marco de Wit May 12 '16 at 11:54
  • I have updated it, just did it now, works like a charm – seb Jun 01 '16 at 07:32
0

Follow the below steps:

Step 1: Call below code on cms homepage

{{block type="catalog/product_list" category_id="74" column_count="5" template="catalog/product/list.phtml"}}

Step 2: Goto system >> permission >> Blocks >> add block name >> allowed to Yes >> save.

Step 3: Goto System >> Configuration >> Catalog >> Frontend >> add products per page on grid default value "24"(by default 24 products will be display in grid rather than 12 products).

step 4: add limit in your phtml to display fix number of products. Add below code before start

  • tag.

    add below code after end

  • tag
    <?php endif // for 24 product?>
    
    Abhinav Singh
    • 2,592
    • 15
    • 14