We wanted to add the “Recently Viewed” box in the left column to one of our Magento sites. Magento by default has the recently viewed box in the right.
Here’s what we did:
In page.xml we added this line under the “left” reference:
<block type=”reports/product_viewed” name=”product.recently.viewed” as=”product_recently_viewed” template=”reports/product_viewed.phtml”/>
Next, in template/page/2columns-left.phtml we added:
<?php echo $this->getChildHtml(’product_recently_viewed’) ?>
Where we wanted it to appear in the left column.
There you go, that’s how to add the “Recently Viewed” box in the left column of your Magento site
If you’re trying to figure out how to call an image up in one of your design template files in Magento, here’s the correct code to make it happen:
echo $this->getSkinUrl(’images/your-image.jpg’);
So for instance, if you’re creating a new left column phtml file for your Magento store and need to call an image from your skin images directory, that command will do it. If you want to do the same thing but calling it from elsewhere, use this command:
echo Mage::getDesign()->getSkinUrl(’images/your-image.jpg’);
That’s it. Hope it helps.
Here was another toughy. We wanted to add the text “Regular Price:” in front of the priceĀ on one of our sites running Magento, and after a bit of searching, found the correct file and line to add it to.
Go to /app/design/frontend/default/yourtheme/template/catalog/product/price.phtml and find this line:
<span class=”regular-price” id=”product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>”><?php echo Mage::helper(’core’)->currency($_price,true,true) ?></span>
And change it to read:
<span class=”regular-price” id=”product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>”><?php echo $this->__(’Regular Price: ‘), Mage::helper(’core’)->currency($_price,true,true) ?></span>
Save your file and have a look at your results.
You should now have “Regular Price: in front of your price in Magento
We wanted to add a “Close Window” button to a Magento store for one of our clients. Turns out, it’s one of the easiest things to do with Magento!
Open /app/design/frontend/default/yourtheme/template/catalog/product/gallery.phtml.
Just under the first line of code: <?php $_width=$this->getImageWidth() ?>
Add this line of code and save the file.
<div-left”><a href=”javascript:window.close()”><img border=”0″ src=”/images/btn-close.png”></a></div>
Make sure you create an image for the close button, name it btn-close.png and put it in your images directory.
If you wanted to just do a link instead, use this code: <a href=”javascript:window.close()”>Close Window</a>
You should be done. That’s how we added a “Close Button” to our Magento product images.