Moving the “Recently Viewed Products” Widget in Magento
In this guide, we’ll walk you through the process of moving the “Recently Viewed Products” widget to a specific location below the main product section in your one-column layout Magento store.
Your Current Layout Configuration
The XML code you’ve shared currently places the catalog.compare.sidebar block before the cart_sidebar block, and then positions it within the left sidebar. This is why you’re seeing the “Recently Viewed Products” widget appearing below the menu and above the product listing in your one-column layout.
Here’s a breakdown of your current configuration:
<reference name="left">
<block type="catalog/product_compare_sidebar"
before="cart_sidebar" ...
/>
</reference>
Moving the Widget to the Main Content Area
To move the widget below the main product section, we need to target the content reference instead of the left reference.
-
Open your one-column layout XML file (usually located in
app/design/frontend/{package}/{theme}/layout/catalog.xml). -
Locate the
<catalog_product_view>block and add the following code inside it:
<reference name="content">
<block type="catalog/product_compare_sidebar"
before="-" ...
/>
</reference>
The before attribute set to - ensures that the widget is placed at the end of the main content area, below all other blocks.
- Save your changes and refresh the cache by running this command in your terminal:
php bin/magento cache:clean
Fine-tuning the Position
If you want to place the “Recently Viewed Products” widget specifically below the “You may also like” section, we need to target the catalog.product.related block instead of the main content area.
- In your layout XML file, find the
<catalog_product_view>block and add this code inside it:
<reference name="catalog.product.related">
<block type="catalog/product_compare_sidebar"
after="-" ...
/>
</reference>
The after attribute set to - ensures that the widget is placed immediately below the “You may also like” section.
Remember, you should place this code block above any existing content blocks in your layout XML file to ensure it’s rendered before those blocks.
Conclusion
By following these steps, you’ve successfully moved the “Recently Viewed Products” widget to a new location in your one-column Magento store:
- To place the widget below the main product listing but above the “You may also like” section, use
before="-"within thecontentreference. - To position it immediately below the “You may also like” section, use
after="-"within thecatalog.product.relatedreference.
Always remember to refresh your Magento cache after making layout updates to see the changes reflected on your storefront.
For more advanced customizations and best practices in Magento layout management, visit our dedicated page at LaravelCompany.com.