Skip to main content

Posts

Fixing a Compiler Error in Magento

Fortunately the compiler is quite easy to manually disable. This will resolve the compiler issue and allow you to access your Magento Admin so that you can re-compile before enabling the compiler again. Access your Magento website using FTP and open the file /includes/config.php . You should see the following code: ------------------------------------------------------------------------------------------------------- define ( 'COMPILER_INCLUDE_PATH' , dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . 'src' ) ; define ( 'COMPILER_COLLECT_PATH' , dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . 'stat' ) ; ------------------------------------------------------------------------------ This code tells Magento where to look for the compiled files. To disable the compiler, simply comment out these lines (add a '#' character to the start of each line). The result should look like the following: ------------------------------------------------...

Output more than one image per product on list (category page) of Magento.

//get images for product $product = Mage::getModel('catalog/product')->load($_product->getId()); $helper = Mage::Helper('catalog/image'); foreach ($product->getMediaGalleryImages() as $image) {     echo "<img src='" . $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $image->getFile())->resize(243) . "' />"; } ?>

Magento - Ajax add to cart and quantity box in list.phtml

 To add quantity box with increment + and - and also using ajax add to cart, you should first take the quantity increment box with CSS styling and also need to include a dynamic form (multiple forms per product) as shown in the below code : <ul class="products-grid products-grid--max-<?php echo $_columnCount; ?>-col">   <?php $i=0; foreach ($_productCollection as $_product): ?>   <?php if ($i++%$_columnCount==0): ?>   <?php endif ?>   <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">     <form action="<?php echo $this->getAddToCartUrl($_product) ?>" method="post" id="product_addtocart_form_<?php echo $_product->getId()?>"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>       <script type="text/javascript">   ...

Smooth Page Scroll Script

< script > $(function() { $('a[href*=#]:not([href=#])').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')  && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); if (target.length) { $('html,body').animate({ scrollTop: target.offset().top }, 1000); return false; } } }); }); </ script >

Magento-local.xml-Template

<?xml version="1.0"?> <layout>         <!-- Add/Remove Items From Head -->     <default translate="label" module="page">     <reference name="head">         <!-- Add Javascript File -->                 <action method="addItem">         <type>skin_js</type>         <name>js/jquery.js</name>         <params/>         </action>         <!-- Add CSS File -->         <action method="addCss">         <stylesheet>css/local.css</stylesheet>         </act...

Remove Category option from Layered Navigation options list in magnto

This is about how to remove the category from the layered navgation Please open to app/design/frontend/default/default/template/catalog/layer and open up view.phtml for edit.  < dl id = "narrow-by-list" > <?php $_filters  =  $this -> getFilters ()  ?> <?php  foreach ( $_filters  as  $_filter ):  ?>  <?php  if( $_filter -> getItemsCount ()):  ?> <?php  if( $_filter -> getName () !=  "Category" ) { ?> < dt > <?php  echo  $this -> __ ( $_filter -> getName ())  ?> </ dt > < dd > <?php  echo  $_filter -> getHtml ()  ?> </ dd > <?php }  endif;  ?> <?php  endforeach;  ?> </ dl >

Magento: get skin url, get media url, get base url, get store url

To Retrieve URL path in STATIC BLOCK To get SKIN URL {{skin url='images/sampleimage.jpg'}} To get Media URL {{media url='/sampleimage.jpg'}} To get Store URL {{store url='mypage.html'}} To get Base URL {{base url='yourstore/mypage.html'}} TO Retrieve URL path in PHTML Note: In editing PHTML don't forget to enclode the following code with PHP tag Not secure Skin URL: <?php echo $this->getSkinUrl('images/sampleimage.jpg') ?> Secure Skin URL <?php echo $this->getSkinUrl('images/ sampleimage.gif', array('_secure'=>true)) ?> Get  Current URL $current_url = Mage::helper('core/url')->getCurrentUrl(); Get Home URL $home_url = Mage::helper('core/url')->getHomeUrl(); Get Magento Media Url Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); Get Magento Media Url Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); Get Magento Skin Url Mage::getBaseUrl(Mage_Co...

SMTP settings for Magento / Magento Send Email using smtp

If you want to send emails with Magento you need to configure it to use an SMTP server – that is, the outgoing server that takes care of delivering your messages. magento to use SMTP instead of the usual mail function, you need to take the below steps. - Login to magento admin and go to. System->Configuration->Advanced->System->Mail Sending Settings - Now here set the host value to your smtp host name like mail.domain.com - And then the default port is 25. - Now you need to change magento file. Do not edit the core file as you will loose your change in an upgrade. - So copy this file app/code/core/Mage/core/Model/Email/Template.php in to your local, by creating the same folder structure. - Enable that module. - Then in Template.php you will have to change the getMail() function as below. public function getMail()     {         if (is_null($this->_mail)) {             /* changes begin */ ...

Need Mini Shopping Cart in Header

<div id="cartsummary">               Now in your cart :<br />        <a href="<?php echo $this->getUrl('checkout/cart/')?>">             <?php      $count = $this->helper('checkout/cart')->getSummaryCount();  //get total items in cart        $total = $this->helper('checkout/cart')->getQuote()->getGrandTotal(); //get total price        if($count==0)        {        echo "0 item";       }        if($count==1)        {          echo $this->__(' %s items',$count);        }        i...

How to Call Newsletter in footer in Magento

To show Newsletter in footer go to app/design/frontend/default/YourTheme/layout/newsletter.xml and add the following lines in default < reference name = "footer" > < block type = "newsletter/subscribe" name = "footer.newsletter"   template = "newsletter/subscribe.phtml" /> </ reference > and add the following line in app/design/frontend/default/YourTheme/template/page/html/footer.phtml <?php echo $this -> getChildHtml ( 'footer.newsletter' ) ; ?>

How to get products from a particular category in magento ecommerce

Save it in your cms page where you want to show your products.. {{block type="catalog/product_list" category_id="3" template="catalog/product/home-product.phtml"}} and save it in your catalog/product/home-product.phtml <?php /**  * Magento  *  * NOTICE OF LICENSE  *  * This source file is subject to the Academic Free License (AFL 3.0)  * that is bundled with this package in the file LICENSE_AFL.txt.  * It is also available through the world-wide-web at this URL:  * http://opensource.org/licenses/afl-3.0.php  * If you did not receive a copy of the license and are unable to  * obtain it through the world-wide-web, please send an email  * to license@magentocommerce.com so we can send you a copy immediately.  *  * DISCLAIMER  *  * Do not edit or add to this file if you wish to upgrade Magento to newer  * versions in the future. If you wish to customize Magento for your  * need...

Display Top Level Categories and Current Categories SubCategories

<?php $_helper = Mage::helper( 'catalog/category' ) ?> <?php $_categories = $_helper ->getStoreCategories() ?> <?php $currentCategory = Mage::registry( 'current_category' ) ?> <?php if ( count ( $_categories ) > 0): ?>      <ul>          <?php foreach ( $_categories as $_category ): ?>              <li>                  <a href= "<?php echo $_helper->getCategoryUrl($_category) ?>" >                      <?php echo $_category ->getName() ?>                  </a>         ...

Display Top Level Categories and ALL Subcategories

<?php $_helper = Mage::helper( 'catalog/category' ) ?> <?php $_categories = $_helper ->getStoreCategories() ?> <?php $currentCategory = Mage::registry( 'current_category' ) ?> <?php if ( count ( $_categories ) > 0): ?>      <ul>          <?php foreach ( $_categories as $_category ): ?>              <li>                  <a href= "<?php echo $_helper->getCategoryUrl($_category) ?>" >                      <?php echo $_category ->getName() ?>                  </a>         ...

Display Top Level Categories Only

<?php $_helper = Mage::helper( 'catalog/category' ) ?> <?php $_categories = $_helper ->getStoreCategories() ?> <?php if ( count ( $_categories ) > 0): ?>      <ul>          <?php foreach ( $_categories as $_category ): ?>              <li>                  <a href= "<?php echo $_helper->getCategoryUrl($_category) ?>" >                      <?php echo $_category ->getName() ?>                  </a>              </li>      ...