Adding attribute to the new order notification email in magento.

Today for purpose of one my freelancing project I have added attribute to new order Email . So i am going to share this.

Just you have to work on two file only 1. app->design->fronend->themname->default->template->email->order->items.phtml

in here you have add column heading

then you have to go 2. app->design->fronend->themname->default->template->email->order->items->order->default.phtml

here to add attribute you should have write code like


<?php $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $_item->getSku(), array('Attribute_code')); ?>
 <?php echo $product->getData('Attribute_code'); ?>

&nbsp;

hope it will help you.

for more magento tutorial visit: http://blog.free-extension.com/

Advertisements

Reindexing Problem-Stock Status Index process is working now.Try again later

As my Title of post this common problem in magento.. This is caused by sever execution time or file access permission problem. Today I have solved this problem by a simple task

here I have rename the locks folder———-var/locks

then tried again reindexing problem is solved.

for more magento tutorial visit: http://blog.free-extension.com/

Some Common Fixes of Magento

  1. I need to change the url that my site is defaulted to
    1. in phpmyadmin go to table core_config_data and edit base url fields to what you want
  2. A variety of Magento issues can be resolved by deleting cache
    1. to easily delete cache go to the /var folder and delete the /cache folder
  3. How to setup a Contact Us Page
    1. Paste this into a CMS page
      1. <!– CONTACT FORM CODE BEGIN–>
      2. {{block type=’core/template’ name=’contactForm’ template=’contacts/form.phtml’}}
      3. <!– CONTACT FORM CODE END–>
  4. How to Change the database a Magento Install is pointing to
    1. go to app/etc/local.xml
    2. edit the information on this page, save and upload

for more magento tutorial visit: http://blog.free-extension.com/

How To Setup Google Adwords Conversion Tracking in magento

Today One of  my  project i have added google  adwords. So i want to share this to everyone. this is very simple only two steps

One Step-01:

open this file

/app/design/frontend/default/yourskinname/template/checkout/success.phtml

then paste this code in the bottom of success.phtml file


<?php
 $order_details =  Mage::getModel(‘sales/order’)->loadByIncrementId(Mage::getSingleton(‘checkout/session’)->getLastRealOrderId());
 $adwords_saleamt = $order_details->subtotal;
 ?>

then login into google account

Under the “Reporting’ tab, click on “Conversions” and follow the steps to get the code that you’ll also need to add to the success.phtml page. It will look something like this:


<!– Google Code for Sale Conversion Page –>
 <script type=”text/javascript”>
 <!–
 var google_conversion_id = 0987654321;
 var google_conversion_language = “en”;
 var google_conversion_format = “3″;
 var google_conversion_color = “ffffff”;
 var google_conversion_label = “KFKFKFKFKFKF”;
 var google_conversion_value = 0;
 if (<?php echo $adwords_saleamt; ?>) {
 google_conversion_value = <?php echo $adwords_saleamt; ?>;
 }
 //–>
 </script>
 <script type=”text/javascript” src=”https://www.googleadservices.com/pagead/conversion.js”>
 </script>
 <noscript>
 <div style=”display:inline;”>
 <img height=”1″ width=”1″ style=”border-style:none;” alt=”"  src=”https://www.googleadservices.com/pagead/conversion/0987654321/?value=150&amp;label=KFKFKFKFKFKF&amp;guid=ON&amp;script=0″/>
 </div>
 </noscript>

now paste this getting code in the bottom of success.phtml page.

that okay and it is finished

 

for more magento tutorial visit: http://blog.free-extension.com/

Selecting data from database using Magento

<div>
<div>
<pre>// display all regions defined for the United States
$sql = "SELECT * FROM directory_country_region WHERE country_id='US'";
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
foreach ($connection->fetchAll($sql) as $arr_row) {
	echo $arr_row['default_name'];
}</pre>
</div>
</div>

for more magento tutorial visit: http://blog.free-extension.com/

Inserting Data in magento using raw PHP

<div>
<div>
<pre>// insert a new US State into the region table
$sql = "INSERT INTO `directory_country_region` (`region_id`,`country_id`,`code`,`default_name`) VALUES (NULL,'US','XX','New US State')";
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
$connection->query($sql);</pre>
</div>
</div>

for more magento tutorial visit: http://blog.free-extension.com/

How to display Random Product in magento


<?php	

	$collection = Mage::getResourceModel('catalog/product_collection');
        Mage::getModel('catalog/layer')->prepareProductCollection($collection);
        $collection->getSelect()->order('rand()');
        $collection->addStoreFilter();
        $this->setProductCollection($collection);
        return parent::_beforeToHtml();

        //below code to written in template file

        if (($_products = $this->getProductCollection())):
        	echo $_product->getSku();
        endif;

?>


for more info visit mage-people