5

I create a category with some product. Also create a custom layout for my page that I add new cms page with this layout that I created. I need to have this page with my layout because I want to add some php code just for this page. I redirect category to this page but my problem is here that products that I added to this category doesn't show in page.

Now I want to know how can I show products in this page?

Steps that I created my custom layout:

1.) I create a phtml file with 2columns-left.phtml layout and it's name is renewpage.phtml and it's address is: app/design/frontend/default/celebrity/template/page.

2.) I added it's config.xml in app/code/local/Renew/Page/etc/config.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <Renew_page>
            <version>0.1.0</version>
        </Renew_page>
    </modules>
    <global>
        <page>
            <layouts>
                <renewpage translate="label">
                    <label>Renew_page</label>
                    <template>page/renewpage.phtml</template>
                    <layout_handle>Renew_page</layout_handle>
                </renewpage>
                <!-- add more layouts here -->
            </layouts>
        </page>
    </global>
</config>

3.) And add Renew_page.xml in app/etc/modules/Renew_page.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <Renew_page>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Page />
            </depends>
        </Renew_page>
    </modules>
</config>
  • You want a particular category product – Magento 2 Aug 25 '15 at 11:07
  • @Manojkothari: Can you explain me more please? – Elham Gdz Aug 25 '15 at 11:12
  • You Want a particular category in custom page – Magento 2 Aug 25 '15 at 11:53
  • @Manojkothari: I am new in magento, can you guide me how can I do this? thanks. – Elham Gdz Aug 25 '15 at 11:54
  • you create 1 category and assign what and all product you want in custom page – Magento 2 Aug 25 '15 at 11:57
0

You copy app/design/frontend/default/Customtheme/template/catalog/product/list.phtml and paste it same folder app/design/frontend/default/Customtheme/template/catalog/product/rename.phtml

Then call this code in your custom page

{{block type="catalog/product_list" category_id="Your Category ID Here" template="catalog/product/rename.phtml"}}
  • 1
    Its the same as i say before but without the upgrade of the grid. – ntzz Aug 25 '15 at 14:51
0

You could show a list of product using app/design/frontend/default/URDESIGN/template/catalog/product/list.phtml

If want to get a individual category and display with a simple config, you could do this on the list.phtml line 110 on else, to display a grid mode:

<?php else: ?>
    <?php // Grid Mode ?>
    <?php $_collectionSize = $_productCollection->count() ?>
    <table class="products-grid" id="products-grid-table">
    <?php
        $_columnCount = 1; // $this->getColumnCount()
        $_items = $_productCollection->getItems();
        shuffle($_items);
        $max_items = 6; // Show 6 items
        $personal_count = 1;
        $i = 0;
        foreach ($_items as $_product):
    ?>

EDIT:

If you want to call it, just call like:

{{block type="catalog/product_list" category_id="###CAT_ID###" template="catalog/product/new-list-example.phtml"}}

And switch ###CAT_ID### for the category that you want to display.

If have any problem, comment it.

  • Why I should add this code in list.phtml? I don't want to change in files and I create my custom layout for my page that I want to show products in this page, I don't understand why you said change list.phtml. – Elham Gdz Aug 25 '15 at 11:25
  • Its correct, i write quickly but i say you could. Instead of this, you could create a new file called new-list-example.phtml and copy list.phtml and add this changes. – ntzz Aug 25 '15 at 11:30
  • I use your code but nothing happen. – Elham Gdz Aug 25 '15 at 11:41
  • Did you insert the code that i put at the end to insert the list? – ntzz Aug 25 '15 at 11:50
  • Yes I insert block in my page in admin panel. – Elham Gdz Aug 25 '15 at 11:53
0

In summary then, you need to do the following things:

  • Create a new category
  • Create a new module
  • Create a new layout XML file in the module
  • Create a new template in the module
  • Create a new Block Class in the module
  • Add the logic to pull out the products from your new category in there
  • Call the method from your template

All these individual steps are documented elsewhere on the web, I won't repeat that information here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.