Monday, 27 August 2018

How to show category image full width on catalog page.

Go any phmtl page like 2columns-left.phtml pur after breadcrumbs below code.

$_category  = Mage::registry('current_category');
        if($_category){
        $_helper    = Mage::helper('catalog/output');
         $_imgHtml   = '';
           if ($_imgUrl = $_category->getImageUrl()) {
           echo   $_imgHtml = '<div class="category-image-container1"><div class="category-image-container-inner"><p class="category-image"><img src="'.$_imgUrl.'" alt="'.$this->htmlEscape($_category->getName()).'" title="'.$this->htmlEscape($_category->getName()).'" /></p></div></div>';
                $_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
               
            }

Monday, 7 March 2016

How to change a product dropdown attribute to a multiselect in Magento

First, update the attribute input type to multiselect:
UPDATE eav_attribute SET
entity_type_id = '4',
attribute_model = NULL,
backend_model = 'eav/entity_attribute_backend_array',
backend_type = 'varchar',
backend_table = NULL,
frontend_model = NULL,
frontend_input = 'multiselect',
frontend_class = NULL
WHERE attribute_id = 'YOUR_ATTRIBUTE_ID_HERE';
 
Next, copy the attribute values from the old table to the new:
INSERT INTO catalog_product_entity_varchar ( entity_type_id, attribute_id, store_id, entity_id, value)
SELECT entity_type_id, attribute_id, store_id, entity_id, value
FROM catalog_product_entity_int
WHERE attribute_id = YOUR_ATTRIBUTE_ID_HERE;
 
Finally,  remove the old values or they will conflict with the new setup (the old values will load, but Magento will save new values to the varchar table):
DELETE FROM catalog_product_entity_int
WHERE entity_type_id = 4 and attribute_id = YOUR_ATTRIBUTE_ID_HERE;

Monday, 8 June 2015

How to start with a different Customer ID in Magento?

But it will done by MySql query. Run the below query manually and
 you will get the user id starts from 200001.
 
 
ALTER TABLE customer_entity AUTO_INCREMENT = 200001;

Thursday, 7 May 2015

Defer parsing of JavaScript in Magento

Copy /app/code/core/Mage/Page/Block/Html/Head.php
to
/app/code/local/Mage/Page/Block/Html/Head.php
Go to line 204 and add an defer in line 205
// static and skin javascripts

 $html .= $this->_prepareStaticAndSkinElements('<script type="text/javascript" defer src="%s"%s></script>' . "\n",
            empty($items['js']) ? array() : $items['js'],
            empty($items['skin_js']) ? array() : $items['skin_js'],
            $shouldMergeJs ? array(Mage::getDesign(), 'getMergedJsUrl') : null
        );

Friday, 24 April 2015

Magento Paypal Express bug: Guest user name not save

If user name not show in admin when place an order with paypal express as guest.


Please find below file and replace code:
app/code/core/Mage/Paypal/Model/Express/Checkout.php


protected function _prepareGuestQuote()
    {
        $quote = $this->_quote;
        $quote->setCustomerId(null)
            ->setCustomerFirstname($quote->getBillingAddress()->getFirstname())
            ->setCustomerLastname($quote->getBillingAddress()->getLastname())

            ->setCustomerEmail($quote->getBillingAddress()->getEmail())
            ->setCustomerIsGuest(true)
            ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
        return $this;
    }

Friday, 16 January 2015

Magento: Display currency symbol after price

Open file: /lib/Zend/Currency.php

position'  => self::STANDARD,

with:

'position'  => self::RIGHT, 

Wednesday, 3 December 2014

Non WWW to WWW in magento direct and Remove index.php and of the domain

#non www to www
RewriteCond %{HTTP_HOST} ^(?!www\.)(.+) [NC]
RewriteRule ^(.*) http://www.%1/$1 [R=301,NE,L]

#remove index.php after domain name
DirectoryIndex index.php\
RewriteEngine On
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php$ /$1 [L,R=302,NC,NE]

Thursday, 25 September 2014

Magento Custom Options – Change the Option to show total price.

Sol : You need to modify Abstact.PHP file.. It is located at app/code/core/Mage/Catalog/Block/Product/View/Options/Abstract.php
        $_priceInclTax = $this->getPrice($value['pricing_value'], true);
        $_priceExclTax = $this->getPrice($value['pricing_value']);

 Replace above code below code

        $_priceInclTax = $this->getPrice($value['pricing_value'], true)+$this->getProduct()->getFinalPrice();
        $_priceExclTax = $this->getPrice($value['pricing_value'])+$this->getProduct()->getFinalPrice();

Wednesday, 17 September 2014

Show third level catgories in Magento

<?php $_helper = Mage::helper('catalog/category') ?>
                <?php $_categories = $_helper->getStoreCategories() ?>
                <?php $currentCategory = Mage::registry('current_category') ?>
                <?php if (count($_categories) > 0): ?>
                 <?php foreach($_categories as $_category): ?>
              <li>
                <a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
                    <span class="guitar"><?php echo $_category->getName() ?></span>
                </a>
                <?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
                <?php $_subcategories = $_category->getChildrenCategories() ?>
                <?php if (count($_subcategories) > 0): ?>
                  <ul>
                        <?php foreach($_subcategories as $_subcategory): ?>
                            <li>
                                <a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>">
                                    <?php echo $_subcategory->getName() ?>
                                </a>
                                <?php // third level /// ?>
                                    <?php $_sub_subcategory = Mage::getModel('catalog/category')->load($_subcategory->getId()) ?>
                                    <?php $_sub_subcategories = $_sub_subcategory->getChildrenCategories() ?>
                                    <?php if (count($_sub_subcategories) > 0): ?>
                                        <ul>
                                            <?php foreach($_sub_subcategories as $_subsubcategory): ?>
                                                <li>
                                                    <a href="<?php echo $_helper->getCategoryUrl($_subsubcategory) ?>">
                                                        <?php echo $_subsubcategory->getName() ?>
                                                    </a>
                                                </li>
                                            <?php endforeach; ?>
                                        </ul>
                                    <?php endif; ?>
                                   
                                <?php /// third level //// ?>
                               
                            </li>
                        <?php endforeach; ?>
                    </ul>
                <?php endif; ?>
            </li>
        <?php endforeach; ?>
         <?php endif; ?>

Tuesday, 16 September 2014

Category image resize in Magento

<?php
$_file_name = $cat->getThumbnail();             
$_media_dir = Mage::getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS;
$cache_dir = $_media_dir . 'resize' . DS;

if (file_exists($cache_dir . $_file_name)) {
$catImg =Mage::getBaseUrl('media') .  'catalog' . DS . 'category' . DS . 'resize' . DS . $_file_name;
 } elseif (file_exists($_media_dir . $_file_name)) {
if (!is_dir($cache_dir)) {
mkdir($cache_dir);
}

$_image = new Varien_Image($_media_dir . $_file_name);
$_image->constrainOnly(true);
$_image->keepAspectRatio(false);
$_image->keepFrame(false);
$_image->keepTransparency(true);
$_image->resize(224, 174); // change image height, width
$_image->save($cache_dir . $_file_name);
$catImg = Mage::getBaseUrl('media') . 'catalog' . DS . 'category' . DS . 'resize' . DS . $_file_name;
                         }
 echo  $catImg ; // display resize category thumbnail imagename
 ?>

<img src="<?php echo $catImg;  ?>"  />

Magento Add Payment Method to Admin invoice Grid

 protected function _prepareCollection()
    {
        $collection = Mage::getResourceModel($this->_getCollectionClass());
      
        $collection->join(array('payment'=>'sales/order_payment'),'main_table.order_id=parent_id',array('method','po_number'));
      
        $collection->getSelect()->joinLeft('sales_flat_order_address', 'main_table.order_id = sales_flat_order_address.parent_id',array('full_name'=>'CONCAT(sales_flat_order_address.firstname, " " , sales_flat_order_address.lastname)','full_address'=>'CONCAT(sales_flat_order_address.street, " ", sales_flat_order_address.city, sales_flat_order_address.postcode)','telephone','city','firstname','postcode','company','street','email' ) )->where("sales_flat_order_address.address_type =  'billing'");
      
      
          $collection->getSelect()->joinLeft('sales_flat_order', 'main_table.order_id=sales_flat_order.entity_id', array("shipping_desc"=>"shipping_description","weight"=>"weight","subtotal_incl_tax"=>"subtotal_incl_tax","base_subtotal_invoiced"=>"base_subtotal_invoiced","base_shipping_invoiced"=>"base_shipping_invoiced","base_tax_amount"=>"base_tax_amount"));
        
     
         $this->setCollection($collection);
         return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
        
    }
$payments = Mage::getModel('payment/config')->getAllMethods();
        $methods = array();
            foreach ($payments as $paymentCode=>$paymentModel)
            {
                $paymentTitle = Mage::getStoreConfig('payment/'.$paymentCode.'/title');
                $methods[$paymentCode] = $paymentTitle;
            }
            $this->addColumnAfter('method', array(
                'header' => Mage::helper('sales')->__('Payment Method'),
                'index' => 'method',
                'filter_index' => 'method',
                'type'  => 'options',
                'width' => '1050px',
                'options' => $methods,
            ));

Sunday, 6 April 2014

Remove all Customers with Reset Id in Magento.

Run Below Query in your database.please  make a backup your db 
SET FOREIGN_KEY_CHECKS=0;
-- reset customers
TRUNCATE customer_address_entity;
TRUNCATE customer_address_entity_datetime;
TRUNCATE customer_address_entity_decimal;
TRUNCATE customer_address_entity_int;
TRUNCATE customer_address_entity_text;
TRUNCATE customer_address_entity_varchar;
TRUNCATE customer_entity;
TRUNCATE customer_entity_datetime;
TRUNCATE customer_entity_decimal;
TRUNCATE customer_entity_int;
TRUNCATE customer_entity_text;
TRUNCATE customer_entity_varchar;
TRUNCATE log_customer;
TRUNCATE log_visitor;
TRUNCATE log_visitor_info;

ALTER TABLE customer_address_entity AUTO_INCREMENT=1;
ALTER TABLE customer_address_entity_datetime AUTO_INCREMENT=1;
ALTER TABLE customer_address_entity_decimal AUTO_INCREMENT=1;
ALTER TABLE customer_address_entity_int AUTO_INCREMENT=1;
ALTER TABLE customer_address_entity_text AUTO_INCREMENT=1;
ALTER TABLE customer_address_entity_varchar AUTO_INCREMENT=1;
ALTER TABLE customer_entity AUTO_INCREMENT=1;
ALTER TABLE customer_entity_datetime AUTO_INCREMENT=1;
ALTER TABLE customer_entity_decimal AUTO_INCREMENT=1;
ALTER TABLE customer_entity_int AUTO_INCREMENT=1;
ALTER TABLE customer_entity_text AUTO_INCREMENT=1;
ALTER TABLE customer_entity_varchar AUTO_INCREMENT=1;
ALTER TABLE log_customer AUTO_INCREMENT=1;
ALTER TABLE log_visitor AUTO_INCREMENT=1;
ALTER TABLE log_visitor_info AUTO_INCREMENT=1;
SET FOREIGN_KEY_CHECKS=1;

Wednesday, 26 March 2014

How to add custom field in Magento newsletter module.

Step 1 : Open file: root/app/design/frontend/your-package-name/your-theme/template/newsletter/subscribe.phtml

Add input field for ‘Name’ before ‘Email’ Field :
<input type="text" name="subscriber_name" id="subscriber_name" title="<?php echo $this->__('Name') ?>" />
 
Step 2 : Open file:  root/app/code/core/Mage/Newsletter/controllers/SubscriberController.php
A. Search:
$status = Mage::getModel('newsletter/subscriber')->subscribe($email);
Replace with:
if ($this->getRequest()->getPost('subscriber_name'))
{
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
$subscriber_name     = (string) $this->getRequest()->getPost('subscriber_name');
$subscriber->setsubscriber_name($subscriber_name);
}
$status = Mage::getModel('newsletter/subscriber')->subscribe($email,$subscriber_name);
 
Step 3 : Open file : root/app/code/core/Mage/Newsletter/Model/Subscriber.php
A. Search:
public function subscribe($email)
Replace with:
public function subscribe($email,$subscriber_name=null)
B. Search:
$this->setSubscriberEmail($email);
Add after it:
$this->setsubscriber_name($subscriber_name);
C. Search:
public function setEmail($value)
{
return $this->setSubscriberEmail($value);
}
Add after it:
public function setsubscriber_name($value)
{
return $this->setSubscriberName($value);
}
Step 4 : Open file : root/app/code/core/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid.php
A. Search:
$this->addColumn('email', array(
'header'    => Mage::helper('newsletter')->__('Email'),
'index'     => 'subscriber_email'
));
Add before it:
$this->addColumn('subscriber_name', array(
'header'    => Mage::helper('newsletter')->__('Subscriber Name'),
'index'     => 'subscriber_name',
'default'   =>    '----'
));
Step 5 : Open your database.
Create a field ‘subscriber_name’ in table “Newsletter Subscriber”.
Step 6 : Clear the caches ................
 
  
 
 
 
 
 
  
 
  

Monday, 13 January 2014

After upgrade 1.7 to 1.8, ‘Place Order’ button does not work

Replace the base file the following path
app/design/frontend/default/your_theme/template/checkout/onepage/review/info.phtml
(or)
Replace the line number 81 in info.phtml
review = new Review(’<?php echo $this->getUrl('checkout/onepage/saveOrder', array('form_key' => Mage::getSingleton('core/session')->getFormKey())) ?>’, ‘<?php echo $this->getUrl('checkout/onepage/success') ?>’, $(’checkout-agreements’));

Friday, 26 July 2013

How to remove index.php from Any URLs in Magento

find below line in .htaccess
  # These lines rewrite /index.php/admin to /admin.
     RewriteCond %{REQUEST_URI} ^/index.php/admin.*$
     RewriteRule ^index.php/admin(.*) /admin$1 [R]
  
follow below code for remove index.php
 example1= www.domain.com/index.php/affiliate/
   # These lines rewrite /index.php/affiliate to /affiliate.
     RewriteCond %{REQUEST_URI} ^/index.php/affiliate.*$
     RewriteRule ^index.php/affiliate(.*) /affiliate$1 [R]

      example2
    # These lines rewrite /index.php/articles to /admin.
     RewriteCond %{REQUEST_URI} ^/index.php/articles.*$
     RewriteRule ^index.php/articles(.*) /articles$1 [R]
   

Thursday, 27 June 2013

How to display the product price with tax in product list/view page.

Follow the steps to achieve this.
1. Sign in to Magento Admin Panel
2. Go to System > Configuration
3. Click on ‘Tax’ listed under Sales
4. Go to ‘Calculation’ and set ‘tax based on’ to ‘Shipping Origin’
5. Go to ‘Display’ and set ‘Display Cart/Order Prices’ to ‘including and excluding tax’
6. Go to ‘Display’ and set ‘Display Product Prices’ to ‘including and excluding tax’
7. Save the Configuration

Wednesday, 5 June 2013

Magento - remove trailing slash from urls

Open app\code\core\Mage\Core\Block/Abstract.php and find the getUrl() method, it should just be one line of code that returns the requested URL:


return $this->_getUrlModel()->getUrl($route, $params);
Replace that line with the following:


$return_url = $this->_getUrlModel()->getUrl($route, $params);
if ($return_url != $this->getBaseUrl() && substr($return_url, -1) == '/' && !Mage::getSingleton('admin/session')->isLoggedIn()):
    return substr($return_url, 0, -1);
else:
    return $return_url;
endif;

Monday, 25 February 2013

Magento - Editing phtml Files in Dreamweaver

Its only recently that we came across a post which has now brought me a lot of joy to our lives and made it a lot easier on the eyes. Natively dreamweaver does not recognise phtml files and so you end up living in a black and white world, which is ok except you feel like you've been living in a 1950's sid com for the last few years. However help is finally at hand and now you can finally see phtml files for what they really are and we're going to show you how to achieve the same.
First of all since we're all on PC's, the fix described is only for windows based computers. But if you do need a fix for windows you can find the fix here.
  • Step One
Documents and Settings > [user] > Application Data > Adobe Dreamweaver > Configuration > extensions.txt
Change the top line and add the PHTML
HTM,HTML,SHTM,SHTML, ... ,TXT,PHP,PHP3,PHP4,PHP5,PHTML,JSP,WML,TPL, ... ,MASTER:All Documents
And then change the third line down to look like
PHP,PHP3,PHP4,PHP5,TPL,PHTML:PHP Files
  • Step Two
Program Files > Adobe > Dreamweaver [Your Version] > configuration > Extensions.txt
Change the top line and add the PHTML
HTM,HTML,SHTM,SHTML, ... ,TXT,PHP,PHP3,PHP4,PHP5,PHTML,JSP,WML,TPL, ... ,MASTER:All Documents
And then change the third line down to look like
PHP,PHP3,PHP4,PHP5,TPL,PHTML:PHP Files
  • Step Three
Program Files > Adobe > Dreamweaver [Your Version] > configuration > DocumentTypes > MMDocumentTypes.xml
Go to line 75 and change it so it looks like below
<documenttype id="PHP_MySQL" servermodel="PHP MySQL" internaltype="Dynamic" winfileextension="php,php3,php4,phtml,php5,<strong>phtml</strong>"<br />macfileextension="php,php3,php4,phtml,php5,<strong>phtml</strong>" file="Default.php" writebyteordermark="false">; </documenttype>

Wednesday, 13 February 2013

Add increment decrement Qty in Cart Magento


app\design\frontend\default\your theme\template\catalog\product\view\addtocart.phtm
<?php $_product = $this->getProduct(); ?>
<?php $buttonTitle = $this->__('Add to Cart'); ?>
<?php if($_product->isSaleable()): ?>

<?php if(!$_product->isGrouped()): ?>

<ul>
<li> <a href="javascript:void(0)" onclick="decrementQty('qty');"><img src="<?php echo $this->getSkinUrl('images')?>/plus-icon-1.jpg" alt="" border="0" /></a></li>
<li class="back"><input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" /></li>
<li><a href="javascript:void(0);" onclick="incrementQty('qty');"><img src="<?php echo $this->getSkinUrl('images')?>/plus-icon-2.jpg" alt="" border="0"/></a></li>
</ul>

<?php endif; ?>
<button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>
<?php echo $this->getChildHtml('', true, true) ?>

<?php endif; ?>
<script type="text/javascript">
//<![CDATA[
function decrementQty(id) {
var val = parseInt($(id).getValue());
if(val != 1)
document.getElementById(id).value = val - 1;
}
function incrementQty(id) {
var val = parseInt($(id).getValue());
document.getElementById(id).value = val + 1;
}
//]]>
</script>

Add Order Status to Last 5 Orders on Magento Admin Dashboard

Standard Grid
Modified Grid
First of all, and this is a must when modifying any core files, create a local copy of the following file:
Copy app/code/core/Mage/Adminhtml/Block/Dashboard/Orders/Grid.php
To app/code/local/Mage/Adminhtml/Block/Dashboard/Orders/Grid.php
Open your local copy of Grid.php and around line 114 add the following:
$this->addColumn('status', array(
'header' => Mage::helper('sales')->__('Status'),
'index' => 'status',
'type'  => 'options',
'width' => '70px',
'sortable'  => false,
'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
));
Save and upload the local copy and you should now have a column called Status in your Last 5 Orders.