Magento : sort by category problems? - magento

When I have products in categories ( I have sub-categories in this category) I don't have sort by category just sort by price. I want to add sort by category with sort by price.
For example :
if i have computer category and i have laptop and Desktop sub-categories. I have many products also in computer category. When i am in computer catalog i wish to show also in navigation layer :
Sort by
Category :
Laptop(1)
Desktop(2)
What is the problem ?

Magento base theme provides this feature by default
using these 2 files
base/default/layout/catalog.xml
<catalog_category_default translate="label">
<reference name="left">
<block type="catalog/navigation" name="catalog.leftnav" after="currency" template="catalog/navigation/left.phtml"/>
</reference>
....
</catalog_category_default>
And base/default/template/catalog/navigation/let.phtml and of course there is Block class to provide data.
To use this feature your product should belong to child as well parent category or your parent category's display setting Is Anchor should be set "Yes", then it will display all products including products in children categories as well with category filter.

Related

List 8 latest products on homepage - Magento 1.9.2.1

I know this question gets asked quite a bit and seems straight forward but I can't seem to find a post which states an answer that works.
There a few with solutions on how to list products marked with a 'new from' date in the backend and there are solutions which list the latest products from a specific category but I just need the 8 most recently added products to the catalog full stop.
Currently I am manually adding the products to a 'latest products' category with an ID of 116
and have this in the content of my home page CMS page:
{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="116" template="catalog/product/list-latest.phtml"}}
Then in the list-latest.phtml template file, I have some code to get the collection:
<?php
$_productCollection=$this->getLoadedProductCollection()->setPageSize(10);
$_productCollection->clear(); //this will unset the loaded items.
$_productCollection->getSelect()->limit(10); //set a new limit
$_productCollection->getSelect()->reset(Zend_Db_Select::ORDER); //reset the order
$_productCollection->getSelect()->order('cat_index_position asc');//force order by position in category
$_productCollection->load();
$_helper = $this->helper('catalog/output');
?>
And then it loops through the collection and works fine but I need a way to get the latest products from ALL categories and automatically put the latest 8 products on the homepage.
Is there a way to alter this code to do this?
Please try the following code
Place below code in you home page via admin login cms->select your home page->
design->Layout Update XML
<block type="catalog/product_new" name="home.catalog.product.new" alias="product_new" template="catalog/product/new.phtml" after="cms_page">
<action method="addPriceBlockType">
<type>bundle</type>
<block>bundle/catalog_product_price</block>
<template>bundle/catalog/product/price.phtml</template>
</action>
<action method="setColumnCount"><columns>4</columns></action>
<action method="setProductsCount"><count>8</count></action>
</block>
The above code will show you new product with four columns per row and total 8 product limit.
Let me know if you have any query
I did this using a widget. Create a widget with:
type:Catalog new products list
Display On: where you want it
In the Widget Options tab: Display Type: all products (you can select New Products but then you have to mark products as new rather than the latest you added)
There are other options that are self-explanatory.
You will probably have to theme your widget but it shouldn't be too different to a normal product displays.

Show filter attribute (size) in category listing page above product listings section

I want to show size filter attributes near sort by drop-down section in category listing page,above product listing. By default its coming in left sidebar (layered navigation). Please provide me some solution which will show size filter attributes (Example: XL,L,XXL etc) in list page.
change in catalog.xml of your theme
<reference name="content">
<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
</reference>
change reference name to "content" instead of "left" as per above then changes in css and template as per your need

magento - products in 2col_with_right_col and category lists in 3col layout

I a little confused at the moment.
I'd like to show the category lists in 3cols layout. That works.
But the products I'd like to show in 2cols with right col. I can change the layout for every single product - but I'd like to set this layout generally for all products.
How can I do this?
use file catalog.xml in your template, for example:
magentofolder/app/design/frontend/default/default/layout/catalog.xml (default/default should be your layout pages)
for anchod and non-nachor categories update:
<catalog_category_default translate="label"> (non-anchor)
<catalog_category_layered translate="label"> (anchor)
<catalog_product_view translate="label"> Catalog Product View (Any)
edit row <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
to
<action method="setTemplate"><template>page/3columns.phtml</template></action>

Selective HTML Blocks on Product Pages in Magento?

I want to display specific HTML blocks on all product pages of a specific category in Magento.
For example:
Categories - dress, phone, gps
HTML blocks for these categories: dress.phtml, phone.phtml, gps.phtml
On all the pages of products in dress, dress.phtml is displayed - dress size charts, color charts, how to wash, etc.
On all the pages of products in phone, phone.phtml is displayed - battery care, how we package the phones, etc.
On all the pages of products in gps, gps.phtml is displayed - GPS usage, installation, etc.
You get the idea. How can I do this in Magento? How can I call different PHTML files (dress.phtml, phone.phtml or gps.phtml) in catalog/product/view.phtml by product category?
Thanks!
This is easily achieved by making a few modificaitions to your catalog/product/view.phtml file and your custom theme's layout/local.xml file.
Let's begin by modifying local.xml. Open it up and type / copy & paste the following code:
<catalog_product_view>
<reference name="content">
<reference name="product.info">
<block type="catalog/product_view" name="product.dress" as="productDress" template="wherever/you/keep/dress.phtml" />
<block type="catalog/product_view" name="product.phone" as="productPhone" template="wherever/you/keep/phone.phtml" />
<block type="catalog/product_view" name="product.gps" as="productGps" template="wherever/you/keep/gps.phtml" />
</reference>
</reference>
</catalog_product_view>
What we're essentially doing by modifying local.xml is making your new templates available to the catalog/product/view.phtml file within the product.info block. The block type is *catalog/product_view* so we have access to all the same information and methods available within catalog/product/view.phtml. We can then write a bit of code in view.phtml to decide what block to output
$_currentCategory = Mage::registry('current_category');
if ($_currentCategory->getId() == id of dress category) {
echo $this->getChildHtml('productDress');
} elseif ($_currentCategory->getId() == id of phone category) {
echo $this->getChildHtml('productPhone');
} elseif ($_currentCategory->getId() == id of gps category) {
echo $this->getChildHtml('productGps');
}
All we're doing here is checking the current category of the product and outputting the associated block. Of course you'll need to replace "id of ___ category" with the appropriate category ID value. This won't work if you're in a child category of one of the categories you'd like to find. For example, if your structure is as follows Phone > Accessories > Phone Charger Product we'll only find the latest category (Accessories) in the Phone Charger Product. There's other ways of finding a parent category which are scattered across Google and StackOverflow.
Hope that helps. I don't have means to test this code unfortunately but it should work. Good luck!
$product->getCategoryIds() can give you the category ids to which the product belong.

How to display all products for one perticular category?

I am facing a problem that I am having 3 categories like... 1)A, 2)B and 3)C. Now as per the settings in admin, each category's product listing having pagination but I don't want pagination dependent listing in category B. Instead I want to display all it's products on one single page.
What should be done for this?
Any Help?
Edit the category in the Magento Admin UI. Find the 'Custom Design' tab and the 'Custom Layout' text area in that tab. Add the following:
<reference name="product_list_toolbar_pager">
<action method="addPagerLimit" translate="label">
<mode>list</mode>
<limit>all</limit>
<label>All</label>
</action>
<action method="setDefaultListPerPage">
<limit>all</limit>
</action>
</reference>
NB: This still leaves the pager toolbar for the customer to limit the display and/or sort the results.

Resources