Bug in Magento 1.4.1.1: Pagination links missing in tagged product list

August 5, 2012  |  1 Comments  |  by Raj (MagePsycho)  |  Latest, Magento

Today, I noticed one bug in Magento 1.4.1.1: Pagination links (Page: 1, 2, 3 …) were missing in tagged product list.

Pagination bug in tagged product list


After looking into later version of Magento 1.5.x, it was found that issue was due to following missing blocks in ‘tag_product_list’ handle of layout file: app/design/frontend/[interface]/[theme]/layout/tag.xml:

<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"/>
</block>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>

Existing XML code in Magento 1.4.1.1

<tag_product_list translate="label">
	<label>Tagged Products List</label>
	<!-- Mage_Tag -->
	<reference name="content">
		<block type="tag/product_result" name="tag_products" template="catalogsearch/result.phtml">
			<block type="catalog/product_list" name="search_result_list" template="catalog/product/list.phtml"></block>
			<action method="setListOrders"/>
			<action method="setListModes"/>
			<action method="setListCollection"/>
		</block>
	</reference>
</tag_product_list>

Fixed XML code

<tag_product_list translate="label">
	<label>Tagged Products List</label>
	<!-- Mage_Tag -->
	<reference name="content">
		<block type="tag/product_result" name="tag_products" template="catalogsearch/result.phtml">
			<block type="catalog/product_list" name="search_result_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"/>
				</block>
				<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
			</block>
			<action method="setListOrders"/>
			<action method="setListModes"/>
			<action method="setListCollection"/>
		</block>
	</reference>
</tag_product_list>

Using above xml code instead, will fix the issue of missing pagination links in tagged product list.

Fixed Pagination

Hope this helps somebody.

How to change default sort order / dir in Magento search results?

March 4, 2012  |  6 Comments  |  by Raj (MagePsycho)  |  Latest, Magento

Introduction

Today we will be discussing about how to change the defualt sort order / dir in magento search results (simple & advanced).

Regarding solution, some says you need to change the /app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php file in order to change the default sort order field and dir. But you don’t need to do so as there is an extremely easy way to do so.

Suppose say we are changing the default sort order field to ‘name’ and default sort direction to ‘asc’. Here goes the solution:

Changing default sort order / dir in simple search results:

1> Copy the following file to your custom theme folder
app/design/frontend/*/*/template/catalogsearch/form.mini.phtml
2> and insert the following two lines of code in between the

<form></form>

element of form.mini.phtml:

<input type="hidden" name="order" value="name" />
<input type="hidden" name="dir" value="asc" />

3> You’re done

Changing default sort order / dir in advanced search results:

1> Copy the following file to your custom theme folder
app/design/frontend/*/*/template/catalogsearch/advanced/form.phtml
2> and insert the following two lines of code in between the

<form></form>

element of form.phtml:

<input type="hidden" name="order" value="name" />
<input type="hidden" name="dir" value="asc" />

3> You’re done

Sort By Field: 'name', Dir: 'asc'

Hopefully this artice was useful.
Thanks for reading guys.