Monday, September 17, 2012

Magento : Change page layout from controller

 Change page layout from controller in Magento



Just you need to replace one line of code in your controller
where you want to change the layout of the page if you are not
able to do from xml through setlayout.

Replace
$this->loadLayout();

with
$this->loadLayout()->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');

Monday, September 10, 2012

Magento : Category Flat Data index error


 When reindexing "Category Flat Data " gives error
Cannot initialize the indexer process.

 I run the below query and the issue resolved.

ALTER TABLE catalog_category_entity ENGINE=INNODB;
ALTER TABLE core_store ENGINE=INNODB;

:)

Sunday, September 2, 2012

Magento Installation Linux/Ubuntu : Enable curl


Magento Installation Linux/Ubuntu : Enable curl

If you get error "curl cannot be loaded"  just run the below command in your linux terminal and the error will disappear.



sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

Monday, August 27, 2012

Magento : Get all options of a dropdown or multiselect attribute

Magento : Get all options of a dropdown or multiselect attribute

$arg_attribute = "manufacturer";//this may be any attribute code

//Object of attribute model

$attribute_model = Mage::getModel('eav/entity_attribute');

//Object of attribute options model

$attribute_options_model= Mage::getModel('eav/entity_attribute_source_table') ;

//

$attribute_code = $attribute_model->getIdByCode('catalog_product', $arg_attribute);

$attribute = $attribute_model->load($attribute_code);

$attribute_table =$attribute_options_model->setAttribute($attribute);

//Getting all options

$options = $attribute_options_model->getAllOptions(false);

//Printing all options of particular attribute

echo "<pre />";

print_r($options);

Tuesday, August 21, 2012

Magento : Product list page wrong sorting by price

Magento : Product list page wrong sorting by price

When we install webtex_customergroupprice it has a bug when it sorts products

on product list page it is not correct. For this we need to change collections orderby.

We add

$collection->getSelect()->reset(Zend_Db_Select::ORDER)->order('(min_price)'.$orderDir);

at the end of the function public function sortByPrice() in file "app/code/local/Webtex/Customer

GroupsPrice/Model/Observer.php".

Refresh Cache and the sorting is perfect.

Enjoy!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Thursday, August 9, 2012

Magento : Ecommerce Tracking google analytics

Ecommerce Tracking google analytics magento

Code for sales conversion tracking in magento.

Add below code to the end of the success.phtml file in Magento

<?php
$order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
$subtotal = $order->getSubtotal();
$order_id = $order->getId(); //the id of the order
//$order->getIncrementId();//the increment id of the order
$gtotal = $order->getGrandTotal();//grand total of the order
$address = $order->getBillingAddress()->getData();
$city = $address['city'];
$state = $address['region'];
$country = $address['country_id'];
?>
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-17916440-1']);
  _gaq.push(['_trackPageview']);
  _gaq.push(['_addTrans',
    '<?php echo $order_id; ?>',           // order ID - required
    'steigerhoutstunter.nl',  // affiliation or store name
    '<?php echo $gtotal;?>',          // total - required
    '0',           // tax
    '0',              // shipping
    '<?php echo $city;?>',       // city
    '<?php echo $state;?>',     // state or province
    '<?php echo $country;?>'             // country
  ]);

<?php
$items = $order->getAllItems();
$itemcount=count($items);
$name=array();
$unitPrice=array();
$sku=array();
$ids=array();
$qty=array();
foreach ($items as $itemId => $item)
{?>

 _gaq.push(['_addItem',
    '<?php echo $order_id; ?>',                // order ID - required
    '<?php echo $item->getSku(); ?>',          // SKU/code - required
    '<?php echo $item->getName(); ?>',         // product name
    'category name',                           // category or variation
    '<?php echo $item->getPrice(); ?>',        // unit price - required
    '<?php echo $item->getQtyToInvoice(); ?>'  // quantity - required
  ]);
<?php
}
?>
  _gaq.push(['_trackTrans']); //submits transaction to the Analytics servers
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>

Sunday, August 5, 2012

Magento : Show guest name in last 5 orders magento admin dashboard


Show guest name in last 5 orders magento admin dashboard

On the magento community admin dashboard, Under "Last 5 orders" if there is an order by guest it doesnot show the name of guest customer. There were many instances when my clients wanted to show the names of guest too.
For this i have some suggestions. We can show the name from billing address there instead of the customer name. If you think my suggestion is feasible, i request to add this modification to the coming release of magento.
I have coded for this
In Mage/Adminhtml/Block/Dashboard/Orders/Grid.php about line '51' replace "->joinCustomerName('customer')"  with ->joinCustomerBName('customer')
and  in Mage/Reports/Model/Resource/Order/Collection.php

 add a function
 public function joinCustomerBName($alias = 'name')
    {
        $fields      = array('t2.firstname', 't2.lastname');
        $fieldConcat = $this->getConnection()->getConcatSql($fields, ' ');
        $this->getSelect()
        ->join(array('t2' => 'sales_flat_order_address'),'main_table.billing_address_id = t2.entity_id')->columns(array($alias => $fieldConcat));
       

        return $this;
    }

Thursday, July 5, 2012

Magento 1.6.1.0 : Custom option values not displaying at Orders in the Admin Page

In Magento 1.6.1.0 , when a product with custom option is ordered, the custom option values which are selected by customer do not display in  Orders in the Admin Page.( Sales >> Orders ). Also it is not displayed in the Invoice too.
But the values are visible at the order mails . Also when we will try to edit the order at Admin Orders itself, we will be able to see the values which are chosen by custome.

A simple solution to fix this bug:

Comment this line
<?php //$_option = $this->getFormattedOption($_option['value']); ?>

at line 44
in file "/app/design/adminhtml/default/default/template/sales/items/column/name.phtml"


ENJOY!!!!!!!!!

Wednesday, July 4, 2012

Magento : Inject custom module block to other modules

Magento inject custom module block to any module code sample



<firecheckout_index_index>

       <reference name="checkout.onepage.review.info.items.after">

           <block type="sendfriend/send" after="media"  name="sendfriend.send" template="sendfriend/send.phtml" />

       </reference>

   </firecheckout_index_index>

Wednesday, May 30, 2012

Magento : Back order report

This link helps to display a list of all magento backorders.
Click Here  to get the module.

Tuesday, May 29, 2012

Magento : Speed up magento

Below are tips and tricks to speed up any magento site.
Click Here  to see details

Magento : Import products with external url for images

In magento sometimes we need to import products and we don't have access to images.
We need to use image urls from external sites.
Click Here to know more how to achieve this.

Monday, May 28, 2012

Magento : Resolve Extension Conflicts

In magento we install many extensions and sometimes it so happens that more than one extension extends same class from core and conflict occurs.
Click Here to fix this issue.
Here you will find three methods to resolve thje extension conflicts. In my view the third method is the easiest and the best.

Thursday, May 24, 2012

Magento : Bundle product inclusive tax and including tax price

Sometimes the price including tax and price excluding tax for bundle products appears same on product view page.This issue is mostly faced on Magento 1.5.0.1.  Click Here After struggling for 2-3 days i found this solution Click Here.

Monday, April 23, 2012

Magento : Remove index.php from url

If you want to access your magento URL without index.php
for example:
http://domain.com/index.php/category
to
http://domain.com/category
then use the following steps
1) Login to admin section by using the URL
http://domain.com/index.php/admin
2) then go to “System >>  Configuration >>Web >> Search Engines Optimization”
Use Web Server Rewrites : YES
3) Go to “System >>  Configuration >>Web >>Secure”
Use secure URL Frontend: YES
4)Then create the .htaccess file under your the magento installed folder.
If the magento installed under document root ( /home/username/public_html) then add follogig rules into .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

and If the magento installed under /shop or directory then add the following rules into ” /home/username/public_html/shop/.htaccess ” file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /shop/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /shop/index.php [L]
</IfModule>

Done

Saturday, April 21, 2012

Magento : Prevent guest from seeing Catalog and other pages and allow only logged in user to access website pages

Magento : Prevent guest from seeing Catalog and other pages and allow only logged in user to access website pages

Click HERE to see Detail.

Friday, April 20, 2012

Magento : Delete test data from magento store by SQL Query

 Magento : Delete test data from magento store by SQL Query

Run following SQL Query in Database to remove all test data from magento store:

SET FOREIGN_KEY_CHECKS=0;

##############################
# SALES RELATED TABLES
##############################
TRUNCATE `sales_flat_creditmemo`;
TRUNCATE `sales_flat_creditmemo_comment`;
TRUNCATE `sales_flat_creditmemo_grid`;
TRUNCATE `sales_flat_creditmemo_item`;
TRUNCATE `sales_flat_invoice`;
TRUNCATE `sales_flat_invoice_comment`;
TRUNCATE `sales_flat_invoice_grid`;
TRUNCATE `sales_flat_invoice_item`;
TRUNCATE `sales_flat_order`;
TRUNCATE `sales_flat_order_address`;
TRUNCATE `sales_flat_order_grid`;
TRUNCATE `sales_flat_order_item`;
TRUNCATE `sales_flat_order_payment`;
TRUNCATE `sales_flat_order_status_history`;
TRUNCATE `sales_flat_quote`;
TRUNCATE `sales_flat_quote_address`;
TRUNCATE `sales_flat_quote_address_item`;
TRUNCATE `sales_flat_quote_item`;
TRUNCATE `sales_flat_quote_item_option`;
TRUNCATE `sales_flat_quote_payment`;
TRUNCATE `sales_flat_quote_shipping_rate`;
TRUNCATE `sales_flat_shipment`;
TRUNCATE `sales_flat_shipment_comment`;
TRUNCATE `sales_flat_shipment_grid`;
TRUNCATE `sales_flat_shipment_item`;
TRUNCATE `sales_flat_shipment_track`;
TRUNCATE `sales_invoiced_aggregated`;            # ??
TRUNCATE `sales_invoiced_aggregated_order`;        # ??
TRUNCATE `log_quote`;

ALTER TABLE `sales_flat_creditmemo_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_payment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_status_history` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_payment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_shipping_rate` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_track` AUTO_INCREMENT=1;
ALTER TABLE `sales_invoiced_aggregated` AUTO_INCREMENT=1;
ALTER TABLE `sales_invoiced_aggregated_order` AUTO_INCREMENT=1;
ALTER TABLE `log_quote` AUTO_INCREMENT=1;

#########################################
# DOWNLOADABLE PURCHASED
#########################################
TRUNCATE `downloadable_link_purchased`;
TRUNCATE `downloadable_link_purchased_item`;

ALTER TABLE `downloadable_link_purchased` AUTO_INCREMENT=1;
ALTER TABLE `downloadable_link_purchased_item` AUTO_INCREMENT=1;

#########################################
# RESET ID COUNTERS
#########################################
TRUNCATE `eav_entity_store`;
ALTER TABLE  `eav_entity_store` AUTO_INCREMENT=1;

##############################
# CUSTOMER RELATED TABLES
##############################
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 `tag`;
TRUNCATE `tag_relation`;
TRUNCATE `tag_summary`;
TRUNCATE `tag_properties`;            ## CHECK ME
TRUNCATE `wishlist`;
TRUNCATE `log_customer`;

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 `tag` AUTO_INCREMENT=1;
ALTER TABLE `tag_relation` AUTO_INCREMENT=1;
ALTER TABLE `tag_summary` AUTO_INCREMENT=1;
ALTER TABLE `tag_properties` AUTO_INCREMENT=1;
ALTER TABLE `wishlist` AUTO_INCREMENT=1;
ALTER TABLE `log_customer` AUTO_INCREMENT=1;


##############################
# ADDITIONAL LOGS
##############################
TRUNCATE `log_url`;
TRUNCATE `log_url_info`;
TRUNCATE `log_visitor`;
TRUNCATE `log_visitor_info`;
TRUNCATE `report_event`;
TRUNCATE `report_viewed_product_index`;
TRUNCATE `sendfriend_log`;
### ??? TRUNCATE `log_summary`

ALTER TABLE `log_url` AUTO_INCREMENT=1;
ALTER TABLE `log_url_info` AUTO_INCREMENT=1;
ALTER TABLE `log_visitor` AUTO_INCREMENT=1;
ALTER TABLE `log_visitor_info` AUTO_INCREMENT=1;
ALTER TABLE `report_event` AUTO_INCREMENT=1;
ALTER TABLE `report_viewed_product_index` AUTO_INCREMENT=1;
ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1;
### ??? ALTER TABLE `log_summary` AUTO_INCREMENT=1;

SET FOREIGN_KEY_CHECKS=1;




If the above doesnot work try the below sql

SET FOREIGN_KEY_CHECKS=0;
TRUNCATE `sales_order`;TRUNCATE `sales_order_datetime`;TRUNCATE `sales_order_decimal`;TRUNCATE `sales_order_entity`;TRUNCATE `sales_order_entity_datetime`;TRUNCATE `sales_order_entity_decimal`;TRUNCATE `sales_order_entity_int`;TRUNCATE `sales_order_entity_text`;TRUNCATE `sales_order_entity_varchar`;TRUNCATE `sales_order_int`;TRUNCATE `sales_order_text`;TRUNCATE `sales_order_varchar`;TRUNCATE `sales_flat_quote`;TRUNCATE `sales_flat_quote_address`;TRUNCATE `sales_flat_quote_address_item`;TRUNCATE `sales_flat_quote_item`;TRUNCATE `sales_flat_quote_item_option`;TRUNCATE `sales_flat_order_item`;TRUNCATE `sendfriend_log`;TRUNCATE `tag`;TRUNCATE `tag_relation`;TRUNCATE `tag_summary`;TRUNCATE `wishlist`;TRUNCATE `log_quote`;TRUNCATE `report_event`;
ALTER TABLE `sales_orderAUTO_INCREMENT=1;ALTER TABLE `sales_order_datetimeAUTO_INCREMENT=1;ALTER TABLE `sales_order_decimalAUTO_INCREMENT=1;ALTER TABLE `sales_order_entityAUTO_INCREMENT=1;ALTER TABLE `sales_order_entity_datetimeAUTO_INCREMENT=1;ALTER TABLE `sales_order_entity_decimalAUTO_INCREMENT=1;ALTER TABLE `sales_order_entity_intAUTO_INCREMENT=1;ALTER TABLE `sales_order_entity_textAUTO_INCREMENT=1;ALTER TABLE `sales_order_entity_varcharAUTO_INCREMENT=1;ALTER TABLE `sales_order_intAUTO_INCREMENT=1;ALTER TABLE `sales_order_textAUTO_INCREMENT=1;ALTER TABLE `sales_order_varcharAUTO_INCREMENT=1;ALTER TABLE `sales_flat_quoteAUTO_INCREMENT=1;ALTER TABLE `sales_flat_quote_addressAUTO_INCREMENT=1;ALTER TABLE `sales_flat_quote_address_itemAUTO_INCREMENT=1;ALTER TABLE `sales_flat_quote_itemAUTO_INCREMENT=1;ALTER TABLE `sales_flat_quote_item_optionAUTO_INCREMENT=1;ALTER TABLE `sales_flat_order_itemAUTO_INCREMENT=1;ALTER TABLE `sendfriend_logAUTO_INCREMENT=1;ALTER TABLE `tagAUTO_INCREMENT=1;ALTER TABLE `tag_relationAUTO_INCREMENT=1;ALTER TABLE `tag_summaryAUTO_INCREMENT=1;ALTER TABLE `wishlistAUTO_INCREMENT=1;ALTER TABLE `log_quoteAUTO_INCREMENT=1;ALTER TABLE `report_eventAUTO_INCREMENT=1;

-- 
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_entityAUTO_INCREMENT=1;ALTER TABLE `customer_address_entity_datetimeAUTO_INCREMENT=1;ALTER TABLE `customer_address_entity_decimalAUTO_INCREMENT=1;ALTER TABLE `customer_address_entity_intAUTO_INCREMENT=1;ALTER TABLE `customer_address_entity_textAUTO_INCREMENT=1;ALTER TABLE `customer_address_entity_varcharAUTO_INCREMENT=1;ALTER TABLE `customer_entityAUTO_INCREMENT=1;ALTER TABLE `customer_entity_datetimeAUTO_INCREMENT=1;ALTER TABLE `customer_entity_decimalAUTO_INCREMENT=1;ALTER TABLE `customer_entity_intAUTO_INCREMENT=1;ALTER TABLE `customer_entity_textAUTO_INCREMENT=1;ALTER TABLE `customer_entity_varcharAUTO_INCREMENT=1;ALTER TABLE `log_customerAUTO_INCREMENT=1;ALTER TABLE `log_visitorAUTO_INCREMENT=1;ALTER TABLE `log_visitor_infoAUTO_INCREMENT=1;

-- 
Reset all ID counters
TRUNCATE 
`eav_entity_store`;ALTER TABLE  `eav_entity_storeAUTO_INCREMENT=1;
SET FOREIGN_KEY_CHECKS=1;

Wednesday, April 11, 2012

Tuesday, March 27, 2012

Magento : Admin XML Structue

Magento : Admin XML Structue

Often we want to add some common configuration for our modules under "System->Configuration->General->Custom Tab"

Admin XML TO CREATE NEW TAB IN GENERAL

Saturday, March 24, 2012

Magento Tutorial

Click Here to go to Treasure of magento
Magento Tutorial

Magento : Get store Admin Email Address and Name

 Magento : Get store Admin Email Address and Name

$from_email = Mage::getStoreConfig('trans_email/ident_general/email'); //fetch sender email Admin
$from_name = Mage::getStoreConfig('trans_email/ident_general/name'); //fetch sender name Admin

Magento : Set Custom Theme in Controller for a particular Page

  Magento : Set Custom Theme in Controller
Open the corresponding controller and the action in that controller from where the layout is loaded.
Put the below code and you shall see your custom theme applied on that particular page.
public function indexAction() //It can be any action from where your layout is called
   {
          ..
          ..
              Mage::getDesign()->setTheme('Your theme name');   /* This is the code you need to put */               
               $this->loadLayout();                        
               $this->renderLayout();

       }

Saturday, March 3, 2012

Magento : Get Current Currency Symbol

 Magento : Get Current Currency Symbol

Code is useful for get currency symbol
  
     Mage::app()->getLocale()->currency(Mage::app()->getStore()->

     getCurrentCurrencyCode())->getSymbol()

or if you want to pass a certain currency code simply specify it:

     Mage::app()->getLocale()->currency('EUR')->getSymbol()



Understanding Magento XML Structure

 Understanding Magento XML Structure

http://magebase.com/magento-tutorials/5-useful-tricks-for-your-magento-local-xml/

Friday, March 2, 2012

Social media buttons images

 Social media buttons images

http://www.wpzoom.com/wpzoom/500-free-icons-wpzoom-social-networking-icon-set/

magento : sql create new admin

magento :  sql create new admin
 
/* This is an example SQL script.
You should replace all the UPPERCASED variables.
The <USERNAME> variable can only be alphanumeric characters, 
and probably underscores (haven't tested)
 
You can either generate a password hash using the PHP code below,
or you can grab a password hash from the admin_user table from an
existing Magento install for which you know the admin password.
*/
 
/* Use the following PHP script to generate a salted password hash. 
You can also use a straight md5 hash, but it's much more easily brute-forced
<?php $password = 'PASSWORD'; $salt = 'GF'; echo $hash = md5($salt.$password).
':'.$salt; ?>
*/
 
insert into admin_user
select
(select max(user_id) + 1 from admin_user) user_id,
'FIRST NAME' first_name,
'LAST NAME' last_name,
'EMAIL' email,
'USERNAME' username,
'HASH EXAMPLE: 178f29c8e4c6c801db90cd171e3b2b53:in' password,  
/* You can replace this value with an md5 hash */
now() created,
NULL modified,
NULL logdate,
0 lognum,
0 reload_acl_flag,
1 is_active,
(select max(extra) from admin_user where extra is not null) extra;
 
insert into admin_role
select
(select max(role_id) + 1 from admin_role) role_id,
(select role_id from admin_role where role_name = 'Administrators') parent_id,
2 tree_level,
0 sort_order,
'U' role_type,
(select user_id from admin_user where username = 'USERNAME') user_id,
'USERNAME' role_name

Thursday, March 1, 2012

Magento : colour swatches

Magento : colour swatches

http://www.google.co.in/search?q=magento+%2B+list+page+image+zoom&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a#hl=en&client=firefox-a&hs=jTo&rls=org.mozilla:en-US%3Aofficial&sclient=psy-ab&q=magento+%2B+colour+swatches+%2B+free&pbx=1&oq=magento+%2B+colour+swatches+%2B+free&aq=f&aqi=&aql=&gs_sm=3&gs_upl=1281876l1289233l0l1289730l22l20l0l0l0l0l2304l2304l9-1l1l0&gs_l=serp.3...1281876l1289233l0l1289730l22l20l0l0l0l0l2304l2304l9-1l1l0&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.,cf.osb&fp=e01d7cdb16f4b8e&biw=1024&bih=625

Magento : RSS (Category, New Products etc)

Magento : RSS (Category, New Products etc)

http://www.e-commercewebdesign.co.uk/blog/magento-tips/enable-magento-rss-feeds.php

Friday, February 24, 2012

Magento : Show Best Selling and Most Viewed Products

Magento : Show Best Selling and Most Viewed Products 

http://blog.magikcommerce.com/how-to-show-most-viewed-best-selling-products-in-magento-store/

Magento : Onepage Checkout – Add File Upload Field to any step

Magento : Onepage Checkout – Add File Upload Field to any step

http://www.excellencemagentoblog.com/onepage-checkout-add-file-upload-field-to-any-step

Magento : Reviews and ratings with stars

 Magento : Reviews and ratings with stars

Getting collection of all reviews for a product.
http://mandagreen.com/showing-all-reviews-and-ratings-on-a-page-in-magento/

Wednesday, February 22, 2012

Magento : Remove white space from top and bottom of Image

Magento : Remove white space from top and bottom of Image
Use keepFrame(false) just before resize and the images will show without white spaces at top and bottom.

Example:

<img id="image" src="'.$this->helper('catalog/image')->init($_product, 'image')->keepFrame(false)->resize(690).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />

Before:



After:

Saturday, February 18, 2012

Magento : Add extra links to top links in header


We always need to add links apart from default top links in magento.
Here are the steps to add extra links to top links without touching the core files.

1)   Find   "<block type="page/template_links" name="top.links" as="topLinks"/>" in
page.xml    and paste just below this

<!--Added for showing extra links below top links start("/Clients/slendersbeauty/index.php" should be removed in below three links when go live)-->
                <block type="page/template_links" name="header_links" as="header_links" template="page/template/header_links.phtml">
                    <action method="addLink" translate="label title" ><label>AANBIEDINGEN</label><url>/aanbiedingen</url><title>AANBIEDINGEN</title><prepare/><urlParams/><position>10</position></action>
                    <action method="addLink" translate="label title" ><label>OVER ONS</label><url>/about-magento-demo-store</url><title>OVER ONS</title><prepare/><urlParams/><position>10</position></action>
                    <action method="addLink" translate="label title" ><label>CONTACT</label><url>/contacts</url><title>CONTACT</title><prepare/><urlParams/><position>10</position></action>
                </block>
            <!--Added for showing extra links below top links end-->


2)  Copy    /app/design/frontend/base/default/template/page/template/links.phtml
to  a file /app/design/frontend/base/default/template/page/template/header_links.phtml

3)  In /app/design/frontend/base/default/template/page/html/header.phtml
paste     <?php echo $this->getChildHtml('header_links') ?>
where you want to appear the above links.

and now you can see the extra links apart from top links in header .

Magento : Special product Page

Magento : Special product Page

For showing special products(products which have special price) in a cms page ,
follow the below steps:

1) Create a file   "/app/code/local/Mage/Catalog/Block/Product/Special.php "
     with following contents:




     <?php
if(version_compare(Mage::getVersion(), '1.4.0.0', '>=') || version_compare(Mage::getVersion(), '1.6.0.0', '<=')){
//Code
class Mage_Catalog_Block_Product_Special extends Mage_Catalog_Block_Product_List
{
   function get_prod_count()
   {
      //unset any saved limits
      Mage::getSingleton('catalog/session')->unsLimitPage();
      return (isset($_REQUEST['limit'])) ? intval($_REQUEST['limit']) : 12;
   }// get_prod_count

   function get_cur_page()
   {
      return (isset($_REQUEST['p'])) ? intval($_REQUEST['p']) : 1;
   }// get_cur_page

   /**
    * Retrieve loaded category collection
    *
    * @return Mage_Eav_Model_Entity_Collection_Abstract
   **/
   protected function _getProductCollection()
   {
      $todayDate = date('m/d/y');
      $tomorrow = mktime(0, 0, 0, date('m'), date('d')+1, date('y'));
      $tomorrowDate = date('m/d/y', $tomorrow);


            
        $collection = Mage::getResourceModel('catalogsearch/advanced_collection')
            ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
            ->addMinimalPrice()
            ->addStoreFilter();
       
        Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
        Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
       
        $collection->addAttributeToFilter('special_from_date', array('date' => true, 'to' => $todayDate))
            ->addAttributeToFilter('special_to_date', array('or'=> array(
            0 => array('date' => true, 'from' => $tomorrowDate),
            1 => array('is' => new Zend_Db_Expr('null')))
            ), 'left');


      $this->setProductCollection($collection);

      return $collection;
   }// _getProductCollection
}// Mage_Catalog_Block_Product_Special
}


2)  Create a CMS page "SPECIAL" by going to
Magento -> Admin ->CMS -> Pages

3)  In the above CMS page
Go to Design-> Layout Update XML
and
Paste



<reference name="content">
   <block type="catalog/product_special" name="product_new" template="catalog/product/list.phtml">
      <action method="setCategoryId"><category_id>10</category_id></action>
      <action method="setColumnCount"><column_count>6</column_count></action>
      <action method="setProductsCount"><count>0</count></action>
      <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
         <block type="page/html_pager" name="product_list_toolbar_pager" />
         <action method="setDefaultGridPerPage"><limit>12</limit></action>
         <action method="addPagerLimit"><mode>grid</mode><limit>12</limit></action>
         <action method="addPagerLimit"><mode>grid</mode><limit>24</limit></action>
         <action method="addPagerLimit"><mode>grid</mode><limit>36</limit></action>
         <action method="addPagerLimit"><mode>grid</mode><limit>48</limit></action>
         <action method="addPagerLimit" translate="label"><mode>grid</mode><limit>all</limit><label>All</label></action>
      </block>
      <action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>6</count></action>
      <action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
   </block>
</reference>


 


Your CMS Page is created .
You can see your page at
www.yoursite.com/SPECIAL

---------------------------------------------------------------------------------------------------

If you want special product on homepage

Paste
<reference name="content">
<block type="catalog/product_special" name="catalog_product_special" as="product_homepage"  template="catalog/product/lists.phtml"/>
</reference>

in Layout Update XML of "Home Page" CMS

A useful link also is available at:
http://www.dnawebagency.com/displaying-new-products-in-magento-with-pagination