One product, two paths, two templates in magento. Why? - magento

I have a product with full path like domain.com/category/product.html and the same product with canonical path domain.com/product.html.
I use 3 columns to display this page.
<catalog_product_view translate="label">
<label>Catalog Product View (Any)</label>
<!-- Mage_Catalog -->
<reference name="root">
<action method="setTemplate"><template>page/3columns-2.phtml</template></action>
</reference>
<reference name="content">
....
</reference>
<reference name="right">
<block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"/>
</reference>
<reference name="left">
<block type="catalog/navigation" name="catalog.leftmenu" before="-" template="catalog/navigation/menu.phtml"/>
</reference>
</catalog_product_view>
This settings works for both path (I can see in view-source), BUT left column is empty for canonical path. Why??

Having different URL's for the same product like domain.com/category/product.html and domain.com/product.html is because of the settings you've made in Catalog configuration. If you would like to use URL's like domain.com/product.html only, you can set it in Settings menu, under the Catalog, open the Search Engine Optimizations tab and set Use Categories Path for Product URLs value to No.
About your question; first read my answer about having multiple categories for a product here
Your product view page must have a category related data in left block, therefore if you click on a URL like domain.com/category/product.html your session has a category id and your left block is rendered normally. If you click on a URL like domain.com/product.html, your session doesn't have a category id, so your left block looks empty.

Related

How to get Product item count in layered navigation on advanced search result page?

Actually I want display product attributes item count on product list page but when I call
<block type="catalog/layer_view" name="catalog.leftnav" template="catalog/layer/view.phtml">
XML block in advanced search result page in catalogsearch.xml I got wrong item count on left side. Please suggest me how to get proper count of attributes?
I think you can load category model using categoryId and then call getProductCount function like this:
$categoryData = Mage::getModel('catelog/category')->load($categoryId)->getProductCount();
echo $categoryData;
This shall print your product count in this particular category. You can use block or your template to run your code, or in run-time you may also use your controller using an AJAX call.
Follow this steps:
Open catalogsearch.xml from your theme's layout directory.
Search the keyword catalogsearch_advanced_result
Set below code between opening and closing tag of catalogsearch_advanced_result
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
</reference>
<reference name="left">
<block type="catalog/layer_view" name="catalog.leftnav" before="-" template="catalog/layer/view.phtml"/>
</reference>

Magento: how to add a static block AFTER product list

In a web site my boss wants me to insert a static block AFTER the product list of that category. Up to now, using the Magento front end application, the one you can see here, I have seen that I can add a static block only before the product list. How can I do to put the block after the product list for each category?
For example this is a page of the site I am working on and I would like to display the block at the bottom of the page, after the product list but before the footer links.
I think I should change some files (like page.xml or local.xml) ma I don't know how and I haven't found anything useful in the net. Can you help?
In your local.xml add the following, replacing cms_extra with the identifier of your CMS block.
<!-- Catalog Category (Anchor) -->
<catalog_category_layered>
<reference name="content">
<block type="cms/block" name="cms_extra" after="category.products">
<action method="setBlockId"><block_id>cms_extra</block_id></action>
</block>
</reference>
</catalog_category_layered>
<!-- Catalog Category (Non-Anchor) -->
<catalog_category_default>
<reference name="content">
<block type="cms/block" name="cms_extra" after="category.products">
<action method="setBlockId"><block_id>cms_extra</block_id></action>
</block>
</reference>
</catalog_category_default>
Alternatively if it needs to be a different CMS block on each category, add the following near the bottom of your catalog/product/list.phtml..
<?php
$catcode = Mage::registry('current_category')->getId();
echo $this->getLayout()->createBlock('cms/block')->setBlockId('category_block_' . $catcode .'')->toHtml();
?>
Create each category's CMS block with identifier of category_block_categoryid

how to change the category block right to left in magento?

i use the magento 1.9 and install the MA2 theme.
how to category block change right to left column?
plz check this image below=" http://postimg.org/image/jcs8mssct/"
You can change the category layout via the backend :
catalog > Manage categories > select your category > Custom design tab > page layout and change it to 2columns with left bar, but I don't think this will work with your template, it will change the page layout but it will not show the category list, it may show Magento layer nav if your category is anchor
or you can use your local.xml to add this :
<catalog_category_default translate="label">
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
</reference>
<reference name="right">
<remove name="category.list"/>
</reference>
<reference name="left">
<block type="catalog/navigation" name="category.list" before="-" template="catalog/navigation/category_list.phtml"/>
</reference>
</catalog_category_default>
On MA2 template you can use the same code above on ma2\default\layout\local.xml

Magento: Show two products on the product page

I would like to show two different products on the product view page. Basically, after displaying the first product like it normally would, the page should then show another product with all it's details, images and of course the "Add to Cart" button.
Both products should be fully displayed on the product view page, so I can't use any of the existing blocks like catalog/product_list_related or catalog/product_list_upsell.
My idea was to simply add another catalog/product_view block to the catalog_product_view layout definition, like so:
catalog.xml:
<layout version="0.1.0">
...
<catalog_product_view translate="label">
...
<reference name="content">
<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
...
</block>
</reference>
...
<!-- Changes start here -->
<reference name="content">
<block type="catalog/product_view" name="product.info2" template="catalog/product/view.phtml">
<action method="setProductId"><product_id>123</product_id></action>
</block>
</reference>
</catalog_product_view>
However, this does not seem to work. Various elements of the block don't seem to load correctly, as you can see on this screenshot:
All the product images are missing as well as the price and the buttons. Also, my call to setProductId() doesn't seem to have any effect.
You can delete this catalog.xml, then magento usa base catalog.xml

How to I show a category list on inner pages in Magento?

In the Magento theme I am using there is a left sidebar, on the homepage the sidebar contains a category list but on inner pages (category page, product page, etc) the list isn't there. How can I replicate this block onto the product and category page so that users can choose a category from anywhere?
You can include the block in the layout(catalog.xml) under the section
Product view
<catalog_product_view translate="label">
<reference name="left">
Your block comes here
</reference>
</catalog_product_view></li>
Category Page
<catalog_category_default translate="label">
<reference name="left">
Your block comes here
</reference>
</catalog_category_default></li>
Otherwise just put in the deafult section of the catalog.xml, I am thinking that should also work.
<default>
<reference name="left">
Your block comes here
</reference>
</default>
I think the block that ususally displays the left navigation of category is
<reference name="left">
<block type="catalog/navigation" name="catalog.leftnav" after="currency" template="catalog/navigation/left.phtml"/>
</reference>
Hope this helps you to some extent.
Cheers

Resources