Magento, custom product list - php

I made my own product list page based on Mage_Catalog_Block_Product_List:
app/code/local/Mage/Catalog/Block/Product/Special.php:
class Mage_Catalog_Block_Product_Special extends Mage_Catalog_Block_Product_List
{
/* Original contents */
/* Here I call addAttributeToFilter on product collection, and then... */
return $this->_productCollection;
}
I include this in a CMS page on the center column:
<reference name="content">
<block type="catalog/product_special" template="catalog/product/list.phtml" />
</reference>
The problem is: The product list shows up just fine, but I get no layered navigation in my left column.
This is quite strange, since I am using exactly the same template as normal listings.
A couple of things I have checked:
Mage_Catalog_Block_Product_Special just being a proxy class. This doesn't work. Even if I use block type "catalog/product_list" on my CMS page I will not get a layered navigation.
There are no extensions that are overriding crucial core classes.
I have also tried to create my own module and list it under for example 'mycatalog'. This results in exactly the same problem.
I have a feeling this has to do with trying to include a product listing on a CMS page but I have not been able to track down the exact problem.
Any help on this would be very much appreciated.

You need to add the Block that renders the Layers into the left column.
If you look in catalog.xml, you will see that the catalog_category_layered node includes the following:
<reference name="left">
<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
...
</reference>
So, add that into your CMS xml layout update and that should display the Layer block on your CMS page.
If you have issues with the product list not being filtered when you click one of the filterable attributes, that is probably because the links rendered by the Layer_View Block assume that they are going to post back to a CategoryController, not a CmsController which will be rendering your CMS page. That may or may not be an issue, so report back here if it doesn't work and we can try to work through it.

Personally I would have a hidden category with all products in it and use a script to keep that updated to be all products. The script can be done with the API, slow yes, but it will work in a timely fashion for a certain level of SKU count.

layer navigation is include in category view.
You should include the part of navigation used by category, so try to insert
<reference name="left">
<block type="catalog/navigation" name="catalog.leftnav" after="currency" template="catalog/navigation/left.phtml"/>
</reference>
before
<reference name="content">
I'm not sure but if it's doesn't works it should help you to understand the problem anyway

check the following pages ( they came across the same problem )
http://www.exploremagento.com/magento/some-custom-blocks-to-help-you-show-products.php
http://www.chilipepperdesign.com/2009/03/23/magento-how-to-list-all-the-products-in-a-single-category-in-a-sidebar-block

Related

Left sidebar appearing on grouped product page

I have a minor bug/issue with my Magento site.
I've started to make a few group products, and all of the grouped product pages are broken.
It looks like 1 or both of the sidebars appear on the product page and "squeeze" the product info into the middle of the page.
I am using the "ultimo" theme.
Can anyone suggest how I can try and fix this myself?
I can probably fix it myself, if someone is able to point me to the correct file and suggest a code to fix.
Here is the example:
To me this page looks like it is set to the base template 3-columns rather than 2-columns-right.
Since you say it only happens with grouped products have a look in your layout xml files for the handle PRODUCT_TYPE_grouped then with this handle you will probably see something as follows.
<reference name="root">
<action method="setTemplate"><template>page/3columns</template></action>
</reference>
I guess it should be:
<reference name="root">
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
</reference>

Display table with data in it after product detail

Magento 1.9.1.0
I am new to magento. i want to display data in table after product detail. I have created table in database. I can add data from backend/admin panel side. now i want to display this data in product detail page after product. Below is attached image with data that i want to display.
if you are working with user defined module, then in frontend layout xml, you can write code like ...
<catalog_product_view>
<update handle="content"/>
<reference name="content">
<block type="tabledata/tabledata" after="-" name="tabledata" template="tabledata/tabledata.phtml" />
</reference>
</catalog_product_view>
If not using module, then go to catalog layout and override the layout file, and add the above content's section code.
you will need to create a phtml file for template, that 'll show the data. and xml used where to show the data.

Custom Content on Sidebar of Magento

Sup Stackers!
I need your help dearly. I'm pretty much a beginner when it comes to Magento. I would like to display a custom set of links on my page sidebar, the sidebar that holds blocks such as Categories, Compare Products etc. I've tried the following:
<reference name="right">
<block type="cms/block" name="right.permanent.callout">
<action method="setBlockId"><block_id>favourites</block_id></action>
</block>
</reference>
No result. The above references a cms static block I've created that just contains a UL of links. The indentifier for the block is favourites. Whenever I try to get the unordered list to show on the page by including the above in the CMS page Layout XML via the Admin panel, I get nothing happening at all. One thing to note is that, as a test, I deleted all the content that was currently in my home pages Layout XML and it changed nothing, all the sidebar content still remained.
After trying about 10 different alternatives, I'm still no closer to getting the to work. Anyone got any ideas on how to get this to work?
Your code looks like what it should be to get this working. A few things to check is the "name" attribute and caching. Give the block a unique name, such a "favourites." You can also add a "before" or "after" to position this block exactly where you want to on the sidebar, just reference the block name that you want it to appear before or after.
<reference name="right">
<block type="cms/block" name="favourites" before="-">
<action method="setBlockId"><block_id>favourites</block_id></action>
</block>
</reference>
This should get it working. You mentioned that you removed all the code from the Layout Update XML without any changes taking effect. I don't think caching is your problem but I just want to mention it since it's still a possibility. It may have to do with how the default code is commented out, so all you're doing is removing code that isn't being applied to the layout. Hopefully this helps because I think you're right there, good luck!

Magento List Layout XML

I am trying to get my module to replace the 'media' section on list and grid view on category list pages with my own new one, if there is a hole in Mage knowledge its the layout xml so if someone could help :-) I am using,
<layout>
<catalog_category_view>
<reference name="head">
<action method="addItem"><type>skin_js</type><name>js/imageover.js</name></action>
</reference>
<reference name="product_list">
<block type="catalog/product_view_media" name="product.info.media" as="media" template="lewis/imageover/media.phtml"/>
</reference>
</catalog_category_view>
</layout>
but it's not working? :s debug toolbar shows my layout is being called but the changed aren't being made.
Edit: Ok with some help from the post below I got it to read my layout, but turns out on the category_list page Magento doesn't use media template the image call is made in the list.phtml file, so the only way to change it appears to be to replace that whole template file. (which seems very extreme!) is there another way to replace the image on the category list page?
What you've done here is effectively reinstantiate the media block with your template. If your changes are solely template-based, you can just <reference name="product.info.media"> the existing block instance from the layout and call <action method="setTemplate"><template>lewis/imageover/media.phtml</...>. If you have your module has a custom block class, you'll need to use your module's block class group. For more on class group notation, the factory method, etc, see Alan Storm's article on the Magento config.

how can i add a new price template to magento

how can i add a new price template to the category view (template/catalog/product/list.phtml) without changing the price template that is used in (template/catalog/product/view.phtml)?
both files uses the template/catalog/product/price.phtml, but i need a separate price template in template/catalog/product/list.phtml that don't show the text "special price".
thank you very much for your help.
nafex
after a long search time on the internet i found a nice way:
in the file catalog.xml i just added the actions:
<action method="addPriceBlockType"><type>simple</type><block>catalog/product_price</block><template>catalog/product/new_price.phtml</template></action>
<action method="addPriceBlockType"><type>grouped</type><block>catalog/product_price</block><template>catalog/product/new_price.phtml</template></action>
<action method="addPriceBlockType"><type>configurable</type><block>catalog/product_price</block><template>catalog/product/new_price.phtml</template></action>
to the block:
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
You could always override the Mage_Catalog_Block_Product_List block with a block in your own module and then reimplement the _getPriceBlockTemplate method which is used by the call to getPriceHtml for the product list. This should allow you to specify your own price templates for this block specifically, giving you control over not only the catalog page lists, but the ones for related and upsell products as well.
Hope that helps!
Thanks,
Joe

Categories