Magento: Show Visitor's Recently Viewed Product - magento

This question is somehow related to my previous question. I want the "recently viewed" section to show the products which are recently viewed by my (as a visitor). So in that way, every visitor will see their recently viewed products in that section.
Does magento provide any default functionality for this feature or do I have to do it the way I referred in my previous question.

Yes magento has its default functionality
Goto app/design/frontend/default/(yourtheme)/tempalte/reports folder
If you cant see that folder in your theme, just copy it and save it to your theme folder
you can use the below code to display in layout files
<block type="reports/product_viewed" name="left.reports.product.viewed" template="reports/product_viewed.phtml" />
To call in CMS pages (homepage)
{{block type="reports/product_viewed" name="left.reports.product.viewed" template="reports/product_viewed.phtml"}}
To call in phtml file
<?php echo $this->getLayout()->createBlock('reports/product_viewed')->setTemplate('reports/product_viewed.phtml')->tohtml(); ?>

yes , you can by simply use this
<cms_index_index>
<reference name="content">
<block type="reports/product_viewed" name="home.reports.product.viewed" alias="product_viewed" template="reports/home_product_viewed.phtml" after="product_new">
<action method="addPriceBlockType">
<type>bundle</type>
<block>bundle/catalog_product_price</block>
<template>bundle/catalog/product/price.phtml</template>
</action>
</block>
</reference>
</cms_index_index>

Related

Hide discount code section in cart

I am writing a Magento Extension that is trying to hide the Discount Code section on the checkout cart page. I wrote the following code to replace the current cart.phtml with my custom template.
<layout version="0.1.0">
<checkout_cart_index>
<reference name="checkout.cart">
<action method="setTemplate">
<template>company/module/cart.phtml</template>
</action>
</reference>
</checkout_cart_index>
</layout>
Everything looked good until I realized it even overwrote the template the cart page uses for an empty cart. I have tried many combinations for switch the "checkout_cart_index"
name to the reference name but I cannot get it to just replace that template. I further investigated and found in the default layout it sets the cart values here:
<reference name="content">
<block type="checkout/cart" name="checkout.cart">
<action method="setCartTemplate"><value>checkout/cart.phtml</value></action>
<action method="setEmptyTemplate"><value>checkout/cart/noItems.phtml</value></action>
I tried again using "SetCartTemplate" but I cannot get it to display yet alone behave as I am intending. Any ideas?
In your layout update
<checkout_cart_index>
<reference name="checkout.cart">
<action method="setCartTemplate"><value>path/to/your/cart.phtml</value></action>
<action method="setEmptyTemplate"><value>path/to/your/noItems.phtml</value></action>
<action method="chooseTemplate"/>
</reference>
</checkout_cart_index>
chooseTemplate will choose the right template
Try to Rewrite this core class to hide the discount code section in your cart page
Mage_Sales_Model_Quote_Address_Total_Discount

Remove "my cart" from side bar in blog page only in magento

I am trying to remove the "my cart" block from the blog page in magento, but i am not being able to remove only from the blog page. Whenever i try to remove it, it removes it from the whole website.
Is there a way to remove it from only the blog page?
The code that i used:
<reference name="right">
<remove name="cart_sidebar"/>
<block type="blog/menu_sidebar" name="right.blog.menu" >
<action method="setTemplate" ifconfig="blog/menu/right" ifvalue="1">
<template>aw_blog/menu.phtml</template>
</action>
<block type="blog/tags" name="blog_tags" />
</block>
</reference>
Any help will be appreciated, thank you

Add a static block to one page checkout in Magento via local.xml

I would like to add a CMS static block (basket_shipping_message) just above the available shipping methods in my Magento checkout. I can edit the phtml file but would rather do it via my local.xml file.
The following code doesen't seem to be working, any ideas?
<checkout_onepage_index>
<reference name="content">
<reference name="shipping_method">
<block type="cms/block" name="basket_shipping_message" before="available">
<action method="setBlockId"><block_id>basket_shipping_message</block_id></action>
</block>
</reference>
</reference>
</checkout_onepage_index>
Did you call in your phtml template getChildHtml('basket_shipping_message');? That should do it. Without that magento does not render the block

How do I add the recently viewed products box to the homepage?

It is a totally easy problem, but Im not able to solve it.
I tried the following:
add layout xml to the update layout field in the backend for this cms page:
<reference name="right">
<block type="reports/product_viewed" before="right.permanent.callout" name="right.reports.product.viewed" template="reports/product_viewed.phtml" />
</reference>
or the same in the local.xml
<cms_index_index>
<reference name="right">
<block type="reports/product_viewed" before="right.permanent.callout" name="right.reports.product.viewed" template="reports/product_viewed.phtml" />
</reference>
</cms_index_index>
Thanks a lot, I know its not complicated, but I cant get it.
Here is some checks:
Check if your page is using two-column-right or three-column layout.
Clearing cache
Add your layout update to cms.xml directly and clearing cache.
Hope this help
You might have missed to echo the block in the custom home page template file?
echo $this->getChildHtml('right.reports.product.viewed');
Or may be your home page is using 2-template left or other templates where there is no 'right' content block.

Add "My Cart" to top.links magento in local.xml or checkout.xml?

Two parts to this question:
How can I add My Cart to either local.xml or checkout.xml? I have a custom template, that never had it called. Looking for where it is being removed, but not sure I am looking in the right place.
I have tried adding to local.xml
<reference name="root">
<reference name="top.links">
<action method="addCartLink"></action>
</reference>
</reference>
But it breaks magento. Basically I have a soft add to cart and want to pull the default magento "My Cart" to the header, so the ajax updates on page like it does in the default magento template.
2nd par - Where does the code for "My Cart" live to tweak it?
<reference name="top.links">
<block type="checkout/links" name="checkout_cart_link">
<action method="addCartLink"></action>
</block>
</reference>
You may have to clear your cache.

Resources