<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>unexpected[it] &#187; Magento</title>
	<atom:link href="http://www.unexpectedit.com/category/magento/feed" rel="self" type="application/rss+xml" />
	<link>http://www.unexpectedit.com</link>
	<description>Professional IT Blog</description>
	<lastBuildDate>Tue, 31 Jan 2012 21:55:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Create a new layout to Magento, using at CMS design tab</title>
		<link>http://www.unexpectedit.com/magento/howto/create-a-new-layout-to-magento-using-at-cms-design-tab</link>
		<comments>http://www.unexpectedit.com/magento/howto/create-a-new-layout-to-magento-using-at-cms-design-tab#comments</comments>
		<pubDate>Thu, 29 Sep 2011 18:28:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[How To]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=671</guid>
		<description><![CDATA[Just edit your /app/etc/local.xml as follows]]></description>
			<content:encoded><![CDATA[<h2>Just edit your <strong>/app/etc/local.xml</strong> as follows </h2>
<pre class="brush: xml; highlight: [66,67,68,69]; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;!--
/**
 * 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
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   Mage
 * @package    Mage_Core
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
--&gt;
&lt;config&gt;
    &lt;global&gt;
        &lt;install&gt;
            &lt;date&gt;&lt;![CDATA[Fri, 23 Sep 2011 21:21:44 +0000]]&gt;&lt;/date&gt;
        &lt;/install&gt;
        &lt;crypt&gt;
            &lt;key&gt;&lt;![CDATA[ba07d498e63a98eb6e31be0720000000]]&gt;&lt;/key&gt;
        &lt;/crypt&gt;
        &lt;disable_local_modules&gt;false&lt;/disable_local_modules&gt;
        &lt;resources&gt;
            &lt;db&gt;
                &lt;table_prefix&gt;&lt;![CDATA[]]&gt;&lt;/table_prefix&gt;
            &lt;/db&gt;
            &lt;default_setup&gt;
                &lt;connection&gt;
                    &lt;host&gt;&lt;![CDATA[localhost]]&gt;&lt;/host&gt;
                    &lt;username&gt;&lt;![CDATA[root]]&gt;&lt;/username&gt;
                    &lt;password&gt;&lt;![CDATA[root]]&gt;&lt;/password&gt;
                    &lt;dbname&gt;&lt;![CDATA[magento]]&gt;&lt;/dbname&gt;
                    &lt;initStatements&gt;&lt;![CDATA[SET NAMES utf8]]&gt;&lt;/initStatements&gt;
                    &lt;model&gt;&lt;![CDATA[mysql4]]&gt;&lt;/model&gt;
                    &lt;type&gt;&lt;![CDATA[pdo_mysql]]&gt;&lt;/type&gt;
                    &lt;pdoType&gt;&lt;![CDATA[]]&gt;&lt;/pdoType&gt;
                    &lt;active&gt;1&lt;/active&gt;
                &lt;/connection&gt;
            &lt;/default_setup&gt;
        &lt;/resources&gt;
        &lt;session_save&gt;&lt;![CDATA[files]]&gt;&lt;/session_save&gt;
		&lt;cms&gt;
            &lt;layouts&gt;
                &lt;empty&gt;
                    &lt;label&gt;Empty&lt;/label&gt;
                    &lt;template&gt;page/one-column.phtml&lt;/template&gt;
                &lt;/empty&gt;
                &lt;one_column&gt;
                    &lt;label&gt;1 column&lt;/label&gt;
                    &lt;template&gt;page/1column.phtml&lt;/template&gt;
                &lt;/one_column&gt;
                &lt;one_column_home&gt;
                    &lt;label&gt;1 column home&lt;/label&gt;
                    &lt;template&gt;page/1column-home.phtml&lt;/template&gt;
                &lt;/one_column_home&gt;
                &lt;two_columns_left&gt;
                    &lt;label&gt;2 columns with left bar&lt;/label&gt;
                    &lt;template&gt;page/2columns-left.phtml&lt;/template&gt;
                &lt;/two_columns_left&gt;
                &lt;two_columns_right&gt;
                    &lt;label&gt;2 columns with right bar&lt;/label&gt;
                    &lt;template&gt;page/2columns-right.phtml&lt;/template&gt;
                &lt;/two_columns_right&gt;
                &lt;three_columns&gt;
                    &lt;label&gt;3 columns&lt;/label&gt;
                    &lt;template&gt;page/3columns.phtml&lt;/template&gt;
                &lt;/three_columns&gt;
            &lt;/layouts&gt;
        &lt;/cms&gt;
    &lt;/global&gt;
    &lt;admin&gt;
        &lt;routers&gt;
            &lt;adminhtml&gt;
                &lt;args&gt;
                    &lt;frontName&gt;&lt;![CDATA[admin]]&gt;&lt;/frontName&gt;
                &lt;/args&gt;
            &lt;/adminhtml&gt;
        &lt;/routers&gt;
    &lt;/admin&gt;
&lt;/config&gt;
</pre>
<div id="wpcr_respond_1"></div>]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/magento/howto/create-a-new-layout-to-magento-using-at-cms-design-tab/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magento, how to create new frontend type attribute for category</title>
		<link>http://www.unexpectedit.com/magento/howto/magento-how-to-create-new-frontend-type-attribute-for-category</link>
		<comments>http://www.unexpectedit.com/magento/howto/magento-how-to-create-new-frontend-type-attribute-for-category#comments</comments>
		<pubDate>Wed, 07 Sep 2011 23:58:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[How To]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=663</guid>
		<description><![CDATA[In this How To, I&#8217;m going to explain how to create a new category attribute to handle PDF files. a) Create a new category attribute a1) Check your entity types catalog_category is ID 9 a2) Insert attribute. Table: eav_attribute note the new row ID is 950 a3) Define attribute set and group. Make the relation [...]]]></description>
			<content:encoded><![CDATA[<p><strong>In this How To, I&#8217;m going to explain how to create a new category attribute to handle PDF files.</strong><br />
<img src="http://www.unexpectedit.com/wp-content/uploads/2011/09/Screen-shot-2011-09-07-at-18.57.22.png" alt="Magento category with new PDF attribute" title="Magento category PDF attribute" width="784" height="580" class="alignnone size-full wp-image-664" /></p>
<h2>a) Create a new category attribute</h2>
<p><strong>a1) Check your entity types</strong></p>
<pre class="brush: sql; title: ; notranslate">
SELECT * FROM `eav_entity_type`
</pre>
<p>catalog_category is ID 9</p>
<p><strong>a2) Insert attribute. Table: eav_attribute</strong></p>
<pre class="brush: bash; title: ; notranslate">
entity_type_id = 9
attribute_code = category_pdf
attribute_model = NULL
backend_model = catalog/category_attribute_backend_file
backend_type = varchar
backend_table =
frontend_model =
frontend_input = file
frontend_label = Category PDF
frontend_class =
source_model =
is_required = 0
is_user_defined = 0
default_value =
is_unique = 0
note =
</pre>
<p>note the new row ID is 950</p>
<p><strong>a3) Define attribute set and group. Make the relation between attribute and entity. Table: eav_entity_attribute</strong></p>
<pre class="brush: bash; title: ; notranslate">
entity_type_id = 9 (Category)
attribute_set_id = 12 (&quot;Default&quot;, attribute set - eav_attribute_set)
attribute_group_id = 7 (&quot;General Information&quot;, first tab - eav_attribute_group)
attribute_id = 950 (&quot;category_pdf&quot;, link with attribute)
sort_order = 0 (order position)
</pre>
<p><strong>a4) Define attribute properties. Table: catalog_eav_attribute</strong></p>
<pre class="brush: bash; title: ; notranslate">
frontend_input_renderer =
is_global = 1
is_visible = 1
is_searchable = 0
is_filterable = 0
is_comparable = 0
is_visible_on_front = 0
is_html_allowed_on_front = 0
is_used_for_price_rules = 1
is_filterable_in_search = 0
used_in_product_listing = 0
used_for_sort_by = 0
is_configurable = 1
apply_to
is_visible_in_advanced_search = 0
position = 0 (order position)
is_wysiwyg_enabled = 0
is_used_for_promo_rules = 1
</pre>
<p><strong>a5) Remember to reindex Category Flat Data</strong></p>
<h2>b) Create a new frontend attribute type.</h2>
<p><strong>We will call it File to handle PDF files.</strong></p>
<p><strong>b1) Create the file /app/code/local/Mage/Catalog/Model/Category/Attribute/Backend/File.php</strong></p>
<pre class="brush: php; title: ; notranslate">

&lt;?php
/**
 * Catalog category file attribute backend model
 *
 */
class Mage_Catalog_Model_Category_Attribute_Backend_File extends Mage_Eav_Model_Entity_Attribute_Backend_Abstract
{

    /**
     * Save uploaded file and set its name to category
     *
     * @param Varien_Object $object
     */
    public function afterSave($object)
    {
        $value = $object-&gt;getData($this-&gt;getAttribute()-&gt;getName());

        if (is_array($value) &amp;&amp; !empty($value['delete'])) {
            $object-&gt;setData($this-&gt;getAttribute()-&gt;getName(), '');
            $this-&gt;getAttribute()-&gt;getEntity()
                -&gt;saveAttribute($object, $this-&gt;getAttribute()-&gt;getName());
            return;
        }

        $path = Mage::getBaseDir('media') . DS . 'files' . DS;

        try {
            $uploader = new Mage_Core_Model_File_Uploader($this-&gt;getAttribute()-&gt;getName());
            $uploader-&gt;setAllowedExtensions(array('pdf'));
            $uploader-&gt;setAllowRenameFiles(true);
            $result = $uploader-&gt;save($path);

            $object-&gt;setData($this-&gt;getAttribute()-&gt;getName(), $result['file']);
            $this-&gt;getAttribute()-&gt;getEntity()-&gt;saveAttribute($object, $this-&gt;getAttribute()-&gt;getName());
        } catch (Exception $e) {
            if ($e-&gt;getCode() != Mage_Core_Model_File_Uploader::TMP_NAME_EMPTY) {
                Mage::logException($e);
            }
            /** @TODO ??? */
            return;
        }
    }
}
</pre>
<p><strong>b2) Create the file /app/code/local/Varien/Data/Form/Element/File.php</strong></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
/**
 * Category form input file element
 *
 */
class Varien_Data_Form_Element_File extends Varien_Data_Form_Element_Abstract
{

    /**
     * Enter description here...
     *
     * @param array $data
     */
    public function __construct($data)
    {
        parent::__construct($data);
        $this-&gt;setType('file');
    }

    /**
     * Enter description here...
     *
     * @return string
     */
    public function getElementHtml()
    {
        $html = '';

        if ($this-&gt;getValue()) {
            $url = $this-&gt;_getUrl();

            if( !preg_match(&quot;/^http\:\/\/|https\:\/\//&quot;, $url) ) {
                $url = Mage::getBaseUrl('media') . 'files' . DS . $url;
            }

            $html = '&lt;a href=&quot;'.$url.'&quot; target=&quot;_blank&quot;&gt;';
            $html.= 'View file';
            $html.='&lt;/a&gt; ';
        }
        $this-&gt;setClass('input-file');
        $html.= parent::getElementHtml();
        $html.= $this-&gt;_getDeleteCheckbox();

        return $html;
    }

    /**
     * Enter description here...
     *
     * @return string
     */
    protected function _getDeleteCheckbox()
    {
        $html = '';
        if ($this-&gt;getValue()) {
            $label = Mage::helper('core')-&gt;__('Delete File');
            $html .= '&lt;span class=&quot;delete-image&quot;&gt;';
            $html .= '&lt;input type=&quot;checkbox&quot; name=&quot;'.parent::getName().'[delete]&quot; value=&quot;1&quot; class=&quot;checkbox&quot; id=&quot;'.$this-&gt;getHtmlId().'_delete&quot;'.($this-&gt;getDisabled() ? ' disabled=&quot;disabled&quot;': '').'/&gt;';
            $html .= '&lt;label for=&quot;'.$this-&gt;getHtmlId().'_delete&quot;'.($this-&gt;getDisabled() ? ' class=&quot;disabled&quot;' : '').'&gt; '.$label.'&lt;/label&gt;';
            $html .= $this-&gt;_getHiddenInput();
            $html .= '&lt;/span&gt;';
        }

        return $html;
    }

    /**
     * Enter description here...
     *
     * @return string
     */
    protected function _getHiddenInput()
    {
        return '&lt;input type=&quot;hidden&quot; name=&quot;'.parent::getName().'[value]&quot; value=&quot;'.$this-&gt;getValue().'&quot; /&gt;';
    }

    /**
     * Get image preview url
     *
     * @return string
     */
    protected function _getUrl()
    {
        return $this-&gt;getValue();
    }

    /**
     * Enter description here...
     *
     * @return string
     */
    public function getName()
    {
        return  $this-&gt;getData('name');
    }

}
</pre>
<div class="note" style="text-align:left">
<div>Tested on Magento 1.5.1.0</div>
</div>
<div id="wpcr_respond_1"></div>]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/magento/howto/magento-how-to-create-new-frontend-type-attribute-for-category/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Magento Schedule Export Google Base products with Cron</title>
		<link>http://www.unexpectedit.com/magento/magento-schedule-export-google-base-products-with-cron</link>
		<comments>http://www.unexpectedit.com/magento/magento-schedule-export-google-base-products-with-cron#comments</comments>
		<pubDate>Sat, 28 May 2011 14:43:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[cron job]]></category>
		<category><![CDATA[export]]></category>
		<category><![CDATA[google base]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=612</guid>
		<description><![CDATA[Schedule the script bellow every day with cron in your system like 01 00 * * * php -f /srv/www/htdocs/Magento/exportGoogleBase.php Then set up your Google Base merchant account like the pic bellow]]></description>
			<content:encoded><![CDATA[<p>Schedule the script bellow every day with cron in your system like<br />
01 00 * * * php -f /srv/www/htdocs/Magento/exportGoogleBase.php</p>
<pre class="brush: php; title: ; notranslate">
define('SAVE_FEED_LOCATION','/srv/www/htdocs/Magento/var/export/google_base_feed.txt'); //you can set a new folder and file if you want, don't forget to chmod the folder to 777

function cleanString($text) {
	// 1) convert á ô =&gt; a o
	$text = preg_replace(&quot;/[áàâãªä]/u&quot;,&quot;a&quot;,$text);
	$text = preg_replace(&quot;/[ÁÀÂÃÄ]/u&quot;,&quot;A&quot;,$text);
	$text = preg_replace(&quot;/[ÍÌÎÏ]/u&quot;,&quot;I&quot;,$text);
	$text = preg_replace(&quot;/[íìîï]/u&quot;,&quot;i&quot;,$text);
	$text = preg_replace(&quot;/[éèêë]/u&quot;,&quot;e&quot;,$text);
	$text = preg_replace(&quot;/[ÉÈÊË]/u&quot;,&quot;E&quot;,$text);
	$text = preg_replace(&quot;/[óòôõºö]/u&quot;,&quot;o&quot;,$text);
	$text = preg_replace(&quot;/[ÓÒÔÕÖ]/u&quot;,&quot;O&quot;,$text);
	$text = preg_replace(&quot;/[úùûü]/u&quot;,&quot;u&quot;,$text);
	$text = preg_replace(&quot;/[ÚÙÛÜ]/u&quot;,&quot;U&quot;,$text);
	$text = preg_replace(&quot;/[’‘‹›‚]/u&quot;,&quot;'&quot;,$text);
	$text = preg_replace(&quot;/[“”«»„]/u&quot;,'&quot;',$text);
	$text = str_replace(&quot;–&quot;,&quot;-&quot;,$text);
	$text = str_replace(&quot; &quot;,&quot; &quot;,$text);
	$text = str_replace(&quot;ç&quot;,&quot;c&quot;,$text);
	$text = str_replace(&quot;Ç&quot;,&quot;C&quot;,$text);
	$text = str_replace(&quot;ñ&quot;,&quot;n&quot;,$text);
	$text = str_replace(&quot;Ñ&quot;,&quot;N&quot;,$text);

	//2) Translation CP1252. &amp;ndash; =&gt; -
	$trans = get_html_translation_table(HTML_ENTITIES);
	$trans[chr(130)] = '&amp;sbquo;';    // Single Low-9 Quotation Mark
	$trans[chr(131)] = '&amp;fnof;';    // Latin Small Letter F With Hook
	$trans[chr(132)] = '&amp;bdquo;';    // Double Low-9 Quotation Mark
	$trans[chr(133)] = '&amp;hellip;';    // Horizontal Ellipsis
	$trans[chr(134)] = '&amp;dagger;';    // Dagger
	$trans[chr(135)] = '&amp;Dagger;';    // Double Dagger
	$trans[chr(136)] = '&amp;circ;';    // Modifier Letter Circumflex Accent
	$trans[chr(137)] = '&amp;permil;';    // Per Mille Sign
	$trans[chr(138)] = '&amp;Scaron;';    // Latin Capital Letter S With Caron
	$trans[chr(139)] = '&amp;lsaquo;';    // Single Left-Pointing Angle Quotation Mark
	$trans[chr(140)] = '&amp;OElig;';    // Latin Capital Ligature OE
	$trans[chr(145)] = '&amp;lsquo;';    // Left Single Quotation Mark
	$trans[chr(146)] = '&amp;rsquo;';    // Right Single Quotation Mark
	$trans[chr(147)] = '&amp;ldquo;';    // Left Double Quotation Mark
	$trans[chr(148)] = '&amp;rdquo;';    // Right Double Quotation Mark
	$trans[chr(149)] = '&amp;bull;';    // Bullet
	$trans[chr(150)] = '&amp;ndash;';    // En Dash
	$trans[chr(151)] = '&amp;mdash;';    // Em Dash
	$trans[chr(152)] = '&amp;tilde;';    // Small Tilde
	$trans[chr(153)] = '&amp;trade;';    // Trade Mark Sign
	$trans[chr(154)] = '&amp;scaron;';    // Latin Small Letter S With Caron
	$trans[chr(155)] = '&amp;rsaquo;';    // Single Right-Pointing Angle Quotation Mark
	$trans[chr(156)] = '&amp;oelig;';    // Latin Small Ligature OE
	$trans[chr(159)] = '&amp;Yuml;';    // Latin Capital Letter Y With Diaeresis
	$trans['euro'] = '&amp;euro;';    // euro currency symbol
	ksort($trans); 

	foreach ($trans as $k =&gt; $v) {
		$text = str_replace($v, $k, $text);
	}

	// 3) remove &lt;p&gt;, &lt;br/&gt; ...
	$text = strip_tags($text); 

	// 4) &amp;amp; =&gt; &amp; &amp;quot; =&gt; '
	$text = html_entity_decode($text);

	// 5) remove Windows-1252 symbols like &quot;TradeMark&quot;, &quot;Euro&quot;...
	$text = preg_replace('/[^(\x20-\x7F)]*/','', $text); 

	return ($text);
} 

// make sure we don't time out
set_time_limit(0);

require_once '/srv/www/htdocs/Magento/app/Mage.php';
Mage::app('default');

try{
	$handle = fopen(SAVE_FEED_LOCATION, 'w');

	$heading = array('id','title','description','link','image_link','price','condition','c:product_code');
	$feed_line=implode(&quot;\t&quot;, $heading).&quot;\r\n&quot;;
	fwrite($handle, $feed_line);

	$products = Mage::getModel('catalog/product')-&gt;getCollection();
	$products-&gt;addAttributeToFilter('status', 1);//enabled
	$products-&gt;addAttributeToFilter('visibility', 4);//catalog, search
	$products-&gt;addAttributeToSelect('*');
	$prodIds=$products-&gt;getAllIds();

	$i = 0;
	foreach($prodIds as $productId) {
		$product = Mage::getModel('catalog/product');
		$product-&gt;load($productId);
			$i++;
			$product_data = array();
			$product_data['id']=$product-&gt;getId();
			$product_data['title']=$product-&gt;getName();
			$product_data['description']=$product-&gt;getDescription();
			$product_data['link']=$product-&gt;getProductUrl();
			$product_data['image_link']=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product'.$product-&gt;getImage();
			if($product-&gt;getSpecialPrice())
			$product_data['price']=round($product-&gt;getSpecialPrice(),2);
			else
			$product_data['price']=round($product-&gt;getPrice(),2);
			$product_data['condition']='new';
			$product_data['c:product_code']=$product-&gt;getSku();

			//sanitize data
			foreach($product_data as $k=&gt;$val){
				$bad=array('&quot;',&quot;\r\n&quot;,&quot;\n&quot;,&quot;\r&quot;,&quot;\t&quot;);
				$good=array(&quot;&quot;,&quot; &quot;,&quot; &quot;,&quot; &quot;,&quot;&quot;);
				$val = str_replace($bad,$good,$val);
				$val = cleanString($val); // convert á ô ... =&gt; a o
				$product_data[$k] = $val;
			}

			$feed_line = implode(&quot;\t&quot;, $product_data).&quot;\r\n&quot;;
			fwrite($handle, $feed_line);
			fflush($handle);

			unset($product);
	}
	fclose($handle);
}
catch(Exception $e){
	die($e-&gt;getMessage());
}
</pre>
<p>Then set up your Google Base merchant account like the pic bellow<br/><br />
<a href="http://www.unexpectedit.com/wp-content/uploads/2011/05/Screen-shot-2011-05-28-at-09.41.08.png"><img src="http://www.unexpectedit.com/wp-content/uploads/2011/05/Screen-shot-2011-05-28-at-09.41.08.png" alt="Google Base Magento settings" title="Google Base Magento setup" width="581" height="573" class="aligncenter size-full wp-image-613" /></a></p>
<div id="wpcr_respond_1"></div>]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/magento/magento-schedule-export-google-base-products-with-cron/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Magento &#8211; Setting up Robots Meta tag in your theme</title>
		<link>http://www.unexpectedit.com/magento/config/magento-setting-up-robots-meta-tag-in-your-theme</link>
		<comments>http://www.unexpectedit.com/magento/config/magento-setting-up-robots-meta-tag-in-your-theme#comments</comments>
		<pubDate>Tue, 24 May 2011 18:00:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Config]]></category>
		<category><![CDATA[googlebots]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[metatag]]></category>
		<category><![CDATA[nofollow]]></category>
		<category><![CDATA[noindex]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=606</guid>
		<description><![CDATA[1) Set the meta tag in /app/design/frontend/your_theme/default/template/page/html/head.phtml 2) Set the Robot content from Layout in /app/design/frontend/your_theme/default/layout/page.xml Every page layout should look like this &#160; Magento 1.4.0.1]]></description>
			<content:encoded><![CDATA[<div class="leftColumn">
<p>
<strong>1) Set the meta tag in /app/design/frontend/your_theme/default/template/page/html/head.phtml</strong></p>
<pre class="brush: xml; title: ; notranslate">
...
&lt;meta name=&quot;robots&quot; content=&quot;&lt;?php echo htmlspecialchars($this-&gt;getRobots()) ?&gt;&quot; /&gt;
...
</pre>
<p><strong>2) Set the Robot content from Layout in /app/design/frontend/your_theme/default/layout/page.xml</strong></p>
<p> Every page layout should look like this </p>
<pre class="brush: xml; highlight: [8,9,10]; title: ; notranslate">
    &lt;page_two_columns_right translate=&quot;label&quot;&gt;
        &lt;label&gt;All Two-Column Layout Pages (Right Column)&lt;/label&gt;
        &lt;reference name=&quot;root&quot;&gt;
            &lt;action method=&quot;setTemplate&quot;&gt;&lt;template&gt;page/2columns-right.phtml&lt;/template&gt;&lt;/action&gt;
            &lt;!-- Mark root page block that template is applied --&gt;
            &lt;action method=&quot;setIsHandle&quot;&gt;&lt;applied&gt;1&lt;/applied&gt;&lt;/action&gt;
        &lt;/reference&gt;
		&lt;reference name=&quot;head&quot;&gt;
			&lt;action method=&quot;setRobots&quot;&gt;&lt;value&gt;NOINDEX,FOLLOW&lt;/value&gt;&lt;/action&gt;
		&lt;/reference&gt;
    &lt;/page_two_columns_right&gt;
</pre>
<div class="clr">&nbsp;</div>
</p>
</div>
<div class="rightColumnSpec">
<ul>
<li>Magento 1.4.0.1</li>
</ul>
</div>
<div id="wpcr_respond_1"></div>]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/magento/config/magento-setting-up-robots-meta-tag-in-your-theme/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add new customer attribute onepage Magento checkout</title>
		<link>http://www.unexpectedit.com/magento/add-new-customer-attribute-onepage-magento-checkout</link>
		<comments>http://www.unexpectedit.com/magento/add-new-customer-attribute-onepage-magento-checkout#comments</comments>
		<pubDate>Fri, 15 Apr 2011 03:51:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Magento]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=507</guid>
		<description><![CDATA[In this example I&#8217;m going to explain how to add a new customer attribute and collect the data from the checkout attribute or register form. Remember to activate the Vat/Tax attribute for the checkout, check right image The new attribute will be a TaxVat Document Type Info, so using the TaxVat attribute of Magento you [...]]]></description>
			<content:encoded><![CDATA[<div class="leftColumn">
<p>In this example I&#8217;m going to explain how to add a new customer attribute and collect the data from the checkout attribute or register form.<br />
<strong>Remember to activate the Vat/Tax attribute for the checkout, check right image</strong><br />
The new attribute will be a TaxVat Document Type Info, so using the TaxVat attribute of Magento you could collect the kind of document: Passport, NIT, NIF, Cedula, DNI&#8230;</p>
<div class="note">
<div>All the files should be overriting with a module to keep the changes when you update Magento.</div>
</div>
<p><strong>1. Add the new customer attribute to the database. Also create a new column to save the attribute when in the quote. (This allows you to keep the value through the onepage checkout page steps).<br />
Execute this code in any .phtml file or any file that you could run under Magento classes.</strong></p>
<pre class="brush: php; title: ; notranslate">
//Attribute to add
$newAttributeName = &quot;taxvattype&quot;; //modify this with the name of your attribute

//a) Add EAV Attributes (modify as you needed)
$attribute  = array(
	'type'			=&gt; 'varchar',
	'label'			=&gt; 'Tax/VAT Type',
	'visible'		=&gt; true,
	'required'		=&gt; false,
	'user_defined'	=&gt; false,
	'searchable'	=&gt; false,
	'filterable'	=&gt; false,
	'comparable'	=&gt; false,
);

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
//Add to customer
$setup-&gt;addAttribute('customer', $newAttributeName, $attribute);

//b) Add Quote attributes (one page step to step save field)
$setup = new Mage_Sales_Model_Mysql4_Setup('sales_setup');
$setup-&gt;getConnection()-&gt;addColumn(
        $setup-&gt;getTable('sales_flat_quote'),
        $newAttributeName,
        'text NULL DEFAULT NULL'
    );
$setup-&gt;addAttribute('quote', &quot;customer_&quot;.$newAttributeName, array('type' =&gt; 'static', 'visible' =&gt; false));
</pre>
<p><strong>2. Add a new line to the file<br />
/app/code/core/Mage/Customer/etc/config.xml </strong></p>
<pre class="brush: xml; highlight: [14]; title: ; notranslate">
    &lt;global&gt;
        &lt;fieldsets&gt;
            &lt;customer_account&gt;
                &lt;prefix&gt;&lt;create&gt;1&lt;/create&gt;&lt;update&gt;1&lt;/update&gt;&lt;name&gt;1&lt;/name&gt;&lt;/prefix&gt;
                &lt;firstname&gt;&lt;create&gt;1&lt;/create&gt;&lt;update&gt;1&lt;/update&gt;&lt;name&gt;1&lt;/name&gt;&lt;/firstname&gt;
                &lt;middlename&gt;&lt;create&gt;1&lt;/create&gt;&lt;update&gt;1&lt;/update&gt;&lt;name&gt;1&lt;/name&gt;&lt;/middlename&gt;
                &lt;lastname&gt;&lt;create&gt;1&lt;/create&gt;&lt;update&gt;1&lt;/update&gt;&lt;name&gt;1&lt;/name&gt;&lt;/lastname&gt;
                &lt;suffix&gt;&lt;create&gt;1&lt;/create&gt;&lt;update&gt;1&lt;/update&gt;&lt;name&gt;1&lt;/name&gt;&lt;/suffix&gt;
                &lt;email&gt;&lt;create&gt;1&lt;/create&gt;&lt;update&gt;1&lt;/update&gt;&lt;/email&gt;
                &lt;password&gt;&lt;create&gt;1&lt;/create&gt;&lt;/password&gt;
                &lt;confirmation&gt;&lt;create&gt;1&lt;/create&gt;&lt;/confirmation&gt;
                &lt;dob&gt;&lt;create&gt;1&lt;/create&gt;&lt;update&gt;1&lt;/update&gt;&lt;/dob&gt;
                &lt;taxvat&gt;&lt;create&gt;1&lt;/create&gt;&lt;update&gt;1&lt;/update&gt;&lt;/taxvat&gt;
                &lt;taxvattype&gt;&lt;create&gt;1&lt;/create&gt;&lt;update&gt;1&lt;/update&gt;&lt;/taxvattype&gt;
                &lt;gender&gt;&lt;create&gt;1&lt;/create&gt;&lt;update&gt;1&lt;/update&gt;&lt;/gender&gt;
</pre>
<p><strong>3. Modify your checkout template<br />
/app/design/frontend/your_template/default/template/checkout/onepage/billing.phtml</strong></p>
<pre class="brush: php; highlight: [3,4,5,6,7,8,9,10]; title: ; notranslate">
        &lt;?php $_taxvat = $this-&gt;getLayout()-&gt;createBlock('customer/widget_taxvat') ?&gt;
        &lt;?php if ($_taxvat-&gt;isEnabled()): ?&gt;
        		&lt;li&gt;
                    &lt;div class=&quot;field&quot;&gt;
                        &lt;label for=&quot;billing:taxvattype&quot;&gt;&lt;?php echo $this-&gt;__('Tax/VAT Document Type') ?&gt;&lt;/label&gt;
                        &lt;div class=&quot;input-box&quot;&gt;
                            &lt;input type=&quot;text&quot; title=&quot;&lt;?php echo $this-&gt;__('Tax/VAT Document Type') ?&gt;&quot; name=&quot;billing[taxvattype]&quot; id=&quot;billing:taxvattype&quot; value=&quot;&lt;?php echo $this-&gt;htmlEscape($this-&gt;getData(&quot;taxvattype&quot;)); ?&gt;&quot; class=&quot;input-text&quot; /&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                &lt;/li&gt;
                &lt;li&gt;
                    &lt;?php echo $_taxvat-&gt;setTaxvat($this-&gt;getQuote()-&gt;getCustomerTaxvat())-&gt;setFieldIdFormat('billing:%s')-&gt;setFieldNameFormat('billing[%s]')-&gt;toHtml() ?&gt;
                &lt;/li&gt;
        &lt;?php endif ?&gt;
</pre>
<p>&nbsp;</p>
<p><strong>4. Modify the register form template<br />
/app/design/frontend/your_template/default/template/customer/form/register.phtml</strong></p>
<pre class="brush: php; highlight: [2,3,4,5]; title: ; notranslate">
            &lt;?php if ($_taxvat-&gt;isEnabled()): ?&gt;
				    &lt;div class=&quot;input-box&quot;&gt;
				        &lt;label for=&quot;taxvat_type&quot;&gt;&lt;?php echo $this-&gt;__('Tax/VAT Document Type') ?&gt;&lt;/label&gt;&lt;br/&gt;
				        &lt;input type=&quot;text&quot; name=&quot;taxvattype&quot; id=&quot;taxvattype&quot; value=&quot;&lt;?php echo $this-&gt;htmlEscape($this-&gt;getData(&quot;taxvattype&quot;)); ?&gt;&quot; title=&quot;&lt;?php echo $this-&gt;__('Tax/VAT Document Type') ?&gt;&quot; class=&quot;input-text&quot; /&gt;
				    &lt;/div&gt;
                &lt;li&gt;&lt;?php echo $_taxvat-&gt;setTaxvat($this-&gt;getFormData()-&gt;getTaxvat())-&gt;toHtml() ?&gt;&lt;/li&gt;
            &lt;?php endif ?&gt;
</pre>
<p><strong>5. Modify the file<br />
/app/code/core/Mage/Checkout/Model/Type/Onepage.php (Please remember to overrite with a module instead).</strong><br />
a) Function saveBilling($data, $customerAddressId)</p>
<pre class="brush: php; highlight: [7]; title: ; notranslate">
        if (empty($data)) {
            return array('error' =&gt; -1, 'message' =&gt; $this-&gt;_helper-&gt;__('Invalid data.'));
        }

        $address = $this-&gt;getQuote()-&gt;getBillingAddress();

$this-&gt;getQuote()-&gt;setData(&quot;customer_taxvattype&quot;,$data['taxvattype']);

        if (!empty($customerAddressId)) {
            $customerAddress = Mage::getModel('customer/address')-&gt;load($customerAddressId);
            if ($customerAddress-&gt;getId()) {
                if ($customerAddress-&gt;getCustomerId() != $this-&gt;getQuote()-&gt;getCustomerId()) {
</pre>
<p>b) Function saveOrder()</p>
<pre class="brush: php; highlight: [6,7,8,9,10]; title: ; notranslate">
            default:
                $this-&gt;_prepareCustomerQuote();
                break;
        }

	    $billing = $this-&gt;getQuote()-&gt;getBillingAddress();
	    if ($this-&gt;getQuote()-&gt;getData(&quot;customer_taxvattype&quot;) &amp;&amp; !$billing-&gt;getData(&quot;taxvattype&quot;)) {
	    	//Save in the customer
	    	$this-&gt;getQuote()-&gt;getCustomer()-&gt;setData(&quot;taxvattype&quot;, $this-&gt;getQuote()-&gt;getData(&quot;customer_taxvattype&quot;));
		}

        $service = Mage::getModel('sales/service_quote', $this-&gt;getQuote());
        $service-&gt;submitAll();
</pre>
</div>
<div class="rightColumnSpec">
<ul>
<li> <strong>To use the example you have to activate the VatTax attribute for the onepage checkout. Check the image bellow.</strong></li>
</ul>
<div><a href="http://www.unexpectedit.com/wp-content/uploads/2011/04/checkoutattribute1.png"><img class="alignleft size-thumbnail wp-image-519" title="checkoutattribute1" src="http://www.unexpectedit.com/wp-content/uploads/2011/04/checkoutattribute1-150x150.png" alt="Magento add VAT/Tax attribute to the checkout" width="150" height="150" /></a></div>
<p>&nbsp;</p>
<ul>
<li>Tested on Magento 1.4.1.1</li>
<li></li>
</ul>
</div>
<div class="rightColumnImages">
<div><a href="http://www.unexpectedit.com/wp-content/uploads/2011/04/checkoutattribute2.png"><img class="alignleft size-thumbnail wp-image-526" title="checkoutattribute2" src="http://www.unexpectedit.com/wp-content/uploads/2011/04/checkoutattribute2-150x150.png" alt="Checkout Attribute 2" width="150" height="150" /></a></p>
<p><a href="http://www.unexpectedit.com/wp-content/uploads/2011/04/checkoutattribute3.png"><img class="alignleft size-thumbnail wp-image-527" title="checkoutattribute3" src="http://www.unexpectedit.com/wp-content/uploads/2011/04/checkoutattribute3-150x150.png" alt="Checkout Attribute3" width="150" height="150" /></a></div>
</div>
<div id="wpcr_respond_1"></div>]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/magento/add-new-customer-attribute-onepage-magento-checkout/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Aptana Eclipse svn: chunked stream ended unexpectedly</title>
		<link>http://www.unexpectedit.com/magento/aptana-eclipse-svn-chunked-stream-ended-unexpectedly</link>
		<comments>http://www.unexpectedit.com/magento/aptana-eclipse-svn-chunked-stream-ended-unexpectedly#comments</comments>
		<pubDate>Wed, 08 Dec 2010 12:39:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[aptana]]></category>
		<category><![CDATA[chuncked]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[timeout]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=391</guid>
		<description><![CDATA[After creating a Magento SVN repository, we realised that the whole trunk folder needs 586Mb. Due to this huge volume we had issues doing the first checkout process in Aptana Eclipse. These steps will show how to checkout the first version of the project and import to Aptana / Eclipse as a project. 1) Checkout [...]]]></description>
			<content:encoded><![CDATA[<p>After creating a Magento SVN repository, we realised that the whole trunk folder needs 586Mb.<br />
Due to this huge volume we had issues doing the first checkout process in Aptana Eclipse. </p>
<p>These steps will show how to checkout the first version of the project and import to Aptana / Eclipse as a project.<br />
<a href="http://www.unexpectedit.com/wp-content/uploads/2010/12/a.png"><img src="http://www.unexpectedit.com/wp-content/uploads/2010/12/a.png" alt="eclipse svn chunked stream ended error" title="eclipse svn chunked stream ended error" width="720" height="663" class="aligncenter size-full wp-image-392" /></a></p>
<p>1) Checkout through console the whole project.</p>
<pre class="brush: bash; title: ; notranslate">
$ cd /Applications/MAMP/htdocs
$ mkdir MyProject
$ svn checkout http://www.yoursite.com/svn/MyProject/ MyProject
# [..]
# A    src/errors/404.php
# A    src/errors/503.php
# A    src/.settings
# A    src/.settings/org.eclipse.php.core.prefs
# Checked out revision 2.
</pre>
<p><strong>Note: If it fails execute svn checkout any time until you see the &#8220;Check out&#8221; message.</strong></p>
<p>2) File >>> Import<br />
<a href="http://www.unexpectedit.com/wp-content/uploads/2010/12/b.jpg"><img src="http://www.unexpectedit.com/wp-content/uploads/2010/12/b-300x239.jpg" alt="Eclipse - File - Import" title="Eclipse - File - Import" width="300" height="239" class="aligncenter size-medium wp-image-393" /></a></p>
<p>3) Choose &#8220;Existing Folder As New Project&#8221;<br />
<div id="attachment_394" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.unexpectedit.com/wp-content/uploads/2010/12/c.jpg"><img src="http://www.unexpectedit.com/wp-content/uploads/2010/12/c-300x249.jpg" alt="Eclipse - Choose Project" title="Eclipse - Choose Project" width="300" height="249" class="size-medium wp-image-394" /></a><p class="wp-caption-text">Eclipse - Choose Project</p></div></p>
<p>4) Choose the folder of the project you have checked out and a name for it<br />
<div id="attachment_395" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.unexpectedit.com/wp-content/uploads/2010/12/d.jpg"><img src="http://www.unexpectedit.com/wp-content/uploads/2010/12/d-300x248.jpg" alt="Eclipse - Choose folder" title="Eclipse - Choose folder" width="300" height="248" class="size-medium wp-image-395" /></a><p class="wp-caption-text">Eclipse - Choose folder</p></div></p>
<p>At this point Eclipse / Aptana will refresh you project synchronising SVN cache. When it finish you will be able to work on your project with SVN feature in Aptana / Eclipse.</p>
<p>It takes a while to update SVN cache&#8230;<br />
<div id="attachment_396" class="wp-caption aligncenter" style="width: 1025px"><a href="http://www.unexpectedit.com/wp-content/uploads/2010/12/e.jpg"><img src="http://www.unexpectedit.com/wp-content/uploads/2010/12/e.jpg" alt="Aptana Update SVN Cache" title="Aptana Update SVN Cache" width="1015" height="242" class="size-full wp-image-396" /></a><p class="wp-caption-text">Aptana Update SVN Cache</p></div></p>
<p>But finally you&#8217;ll have your SVN commands under Team menu!<br />
<a href="http://www.unexpectedit.com/wp-content/uploads/2010/12/final.jpg"><img src="http://www.unexpectedit.com/wp-content/uploads/2010/12/final.jpg" alt="Aptana Team SVN commands" title="Aptana Team SVN commands" width="885" height="960" class="aligncenter size-full wp-image-397" /></a></p>
<div id="wpcr_respond_1"></div>]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/magento/aptana-eclipse-svn-chunked-stream-ended-unexpectedly/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magento Statistics System</title>
		<link>http://www.unexpectedit.com/magento/howto/magento-statistics-system</link>
		<comments>http://www.unexpectedit.com/magento/howto/magento-statistics-system#comments</comments>
		<pubDate>Tue, 26 Oct 2010 12:47:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[profit]]></category>
		<category><![CDATA[sales_order_aggregated_created]]></category>
		<category><![CDATA[zero]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=352</guid>
		<description><![CDATA[Total Ordered Report from version 1.4 is generated from a table called: sales_order_aggregated_created This table is filled up using this query: NOTES: - Profit is zero if you don&#8217;t generate invoices.]]></description>
			<content:encoded><![CDATA[<p><strong>Total Ordered Report</strong> from version 1.4 is generated from a table called: sales_order_aggregated_created<br />
<a href="http://www.unexpectedit.com/wp-content/uploads/2010/10/sales_report.jpg"><img src="http://www.unexpectedit.com/wp-content/uploads/2010/10/sales_report.jpg" alt="" title="sales_report" width="946" height="433" class="alignnone size-full wp-image-353" /></a></p>
<p>This table is filled up using this query:</p>
<pre class="brush: sql; title: ; notranslate">
SELECT
	DATE(e.created_at) AS 'period',
	e.store_id AS 'store_id',
	e.status AS 'order_status',
	COUNT(e.entity_id) AS 'orders_count',
	SUM(e.total_qty_ordered) AS 'total_qty_ordered',
	SUM(IFNULL(e.base_subtotal_invoiced, 0) * e.base_to_global_rate) + SUM(IFNULL(e.base_discount_refunded, 0) * e.base_to_global_rate) - SUM(IFNULL(e.base_subtotal_refunded, 0) * e.base_to_global_rate) - SUM(IFNULL(e.base_discount_invoiced, 0) * e.base_to_global_rate) - SUM(IFNULL(e.base_total_invoiced_cost, 0) * e.base_to_global_rate) AS 'base_profit_amount',
	SUM(e.base_subtotal * e.base_to_global_rate) AS 'base_subtotal_amount',
	SUM(e.base_tax_amount * e.base_to_global_rate) AS 'base_tax_amount',
	SUM(e.base_shipping_amount * e.base_to_global_rate) AS 'base_shipping_amount',
	SUM(e.base_discount_amount * e.base_to_global_rate) AS 'base_discount_amount',
	SUM(e.base_grand_total * e.base_to_global_rate) AS 'base_grand_total_amount',
	SUM(e.base_total_paid * e.base_to_global_rate) AS 'base_invoiced_amount',
	SUM(e.base_total_refunded * e.base_to_global_rate) AS 'base_refunded_amount',
	SUM(IFNULL(e.subtotal_canceled, 0) * e.base_to_global_rate) AS 'base_canceled_amount'
FROM  `sales_order` as e
WHERE
	e.state NOT IN ('pending_payment', 'new') AND
	e.created_at LIKE '2010-10-22%';
</pre>
<p>NOTES:<br />
- Profit is zero if you don&#8217;t generate invoices.</p>
<div id="wpcr_respond_1"></div>]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/magento/howto/magento-statistics-system/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Magento Sharing baskets between multiple stores</title>
		<link>http://www.unexpectedit.com/magento/magento-sharing-baskets-between-multiple-stores</link>
		<comments>http://www.unexpectedit.com/magento/magento-sharing-baskets-between-multiple-stores#comments</comments>
		<pubDate>Tue, 12 Oct 2010 11:01:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[basket]]></category>
		<category><![CDATA[domain]]></category>
		<category><![CDATA[multiple]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[share]]></category>
		<category><![CDATA[store]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=344</guid>
		<description><![CDATA[Finally, I found the solution after digging in the code and spending hours trying to figure out. Check this good explained tutorial first: http://webdevster.com/ecommerce/magento/magento-multiple-store-setup-instructions Environment 1 &#8211; Dedicated Server in Amazon EC2, Suse 11 SP1 1 &#8211; Apache 2.2.16 + PHP 5.3 + MySQL 5.0 1 &#8211; IP address 1 &#8211; magento-main.com &#8211; virtual host [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Finally, I found the solution after digging in the code and spending hours trying to figure out.</strong></p>
<p>Check this good explained tutorial first:<br />
<a target="_blank" href="http://webdevster.com/ecommerce/magento/magento-multiple-store-setup-instructions">http://webdevster.com/ecommerce/magento/magento-multiple-store-setup-instructions</a></p>
<h2>Environment</h2>
<p>1 &#8211; Dedicated Server in Amazon EC2, Suse 11 SP1<br />
1 &#8211; Apache 2.2.16 + PHP 5.3 + MySQL 5.0<br />
1 &#8211; IP address<br />
1 &#8211; magento-main.com &#8211; virtual host www root directory for main store<br />
1 &#8211; magento-2nd.com &#8211; virtual host www root directory for 2nd store<br />
1 &#8211; Magento Admin Control Panel which is your main store.</p>
<h2>Solution</h2>
<p>After following all the steps from webdevster.com I was still not able to share the basket. What I added to that tutorial is links sharing the SID (Session Id) to the other domain.</p>
<p><strong>magento-main.com and magento-2nd.com</strong><br />
If you add in the basket (/app/design/frontend/yourtheme/default/template/checkout/cart.phtml) this code in both stores:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;?php
	//Get Link to the main Website id=1
	$switcher = new Mage_Page_Block_Switch;
	if(count($switcher-&gt;getGroups())&gt;1) {
		foreach ($switcher-&gt;getGroups() as $_group) {
			if($_group-&gt;getId() == 1) { //Default
	        	$link_other_store = $_group-&gt;getHomeUrl();
			}
		}
	}
?&gt;

&lt;a href=&quot;&lt;?php echo $link_other_store; ?&gt;&quot;&gt;
Go to the sister website
&lt;/a&gt;
</pre>
<p>Now, you have a link to switch to the other store. This link will transfer your session so Magento can identify you and shows you all the basket and settings as you have in the other website.</p>
<div id="wpcr_respond_1"></div>]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/magento/magento-sharing-baskets-between-multiple-stores/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Magento Weird Numbers at the end of Product Url</title>
		<link>http://www.unexpectedit.com/magento/magento-weird-numbers-at-the-end-of-product-url</link>
		<comments>http://www.unexpectedit.com/magento/magento-weird-numbers-at-the-end-of-product-url#comments</comments>
		<pubDate>Wed, 08 Sep 2010 16:06:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[Mage_Catalog_Model_Product_Status]]></category>
		<category><![CDATA[product_url]]></category>
		<category><![CDATA[STATUS_ENABLED]]></category>
		<category><![CDATA[TYPE_CONFIGURABLE]]></category>
		<category><![CDATA[type_id]]></category>
		<category><![CDATA[url_key]]></category>
		<category><![CDATA[visibility]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=307</guid>
		<description><![CDATA[All configurable products wich all simple products have the same product url. When you try the Product Url in the frontend it shows some numbers at the end. http://www.yourshop.com/beach-ball-422.html Case http://www.yourshop.com/rechargeable-electric-corkscrew-1912.html instead of http://www.yourshop.com/rechargeable-electric-corkscrew.html Why have the products a number at the end? Magento fixes the duplicate product urls adding the product_id or the position [...]]]></description>
			<content:encoded><![CDATA[<p>All configurable products wich all simple products have the same product url.<br />
<strong>When you try the Product Url in the frontend it shows some numbers at the end.</p>
<p>http://www.yourshop.com/beach-ball-422.html</strong></p>
<p><strong>Case</strong></p>
<p>http://www.yourshop.com/rechargeable-electric-corkscrew-1912.html</p>
<p>instead of</p>
<p>http://www.yourshop.com/rechargeable-electric-corkscrew.html</p>
<p><strong>Why have the products a number at the end?</strong><br />
Magento fixes the duplicate product urls adding the product_id or the position number.<br />
This is due to multi store from version 1.4.0.1 and multi store.<br />
If you look at any configurable product in the sample data, and at each of the standard products that make up that configurable product &#8211; they all have the same URL key set. It appears that the products with a lower-numbered product id (Which I presume this means they were added earlier.) are claiming the URL, and the ones with higher numbers are getting stuck with URL + -1, -2, etc&#8230;</p>
<p><strong>How could I fix it?</strong><br />
Right now, that&#8217;s Magento default behaviour. If you need to modify the path of a product just go to:<br />
1) Catalog >>> Manage Products<br />
2) Open every single product no visible and add the SKU Option to the end of the &#8220;Url Key&#8221; (Handpicked tab)<br />
	837 &#8211; Rechargeable Electric Corkscrew (Black)<br />
	URL Key: rechargeable-electric-corkscrew-black<br />
	1911 &#8211; Rechargeable Electric Corkscrew (Black)<br />
	URL Key: rechargeable-electric-corkscrew-silver<br />
	1912 &#8211; Rechargeable Electric Corkscrew !important: This is the product that you want to have the URL like rechargeable-electric-corkscrew.html<br />
	URL Key: rechargeable-electric-corkscrew</p>
<p>3) System >>> Index management<br />
Reindex Catalog Url Rewrites</p>
<p>Note: after doing this, the product still keeps the old wrong URL. Please send us a message to force a reindex from database.</p>
<p><strong>Alternatively, I used to use this script before&#8230; but it&#8217;s not 100% effective</strong></p>
<pre class="brush: php; title: ; notranslate">
$visibility = array(
	Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE
);
$status = array(
	Mage_Catalog_Model_Product_Status::STATUS_ENABLED
);

echo &quot;Simple Products Not Visible but Enabled - delete product_url...&lt;br/&gt;&quot;;
	$products = Mage::getModel('catalog/product')-&gt;getCollection()
	-&gt;addAttributeToSelect(&quot;url_key&quot;)
	-&gt;joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner', null)
	-&gt;addAttributeToFilter('visibility', $visibility)
	-&gt;addAttributeToFilter('status', $status);
	$i=0;
	foreach ($products as $product) {
		$product-&gt;setData(&quot;url_key&quot;, &quot;&quot;);//$product-&gt;getData(&quot;url_key&quot;).&quot;-&quot;.$product-&gt;getData(&quot;product_id&quot;));
		$product-&gt;setData(&quot;url_key&quot;, $product-&gt;getData(&quot;url_key&quot;).&quot;-&quot;.$product-&gt;getData(&quot;product_id&quot;));
		$product-&gt;save();
		//echo $product-&gt;getData(&quot;url_key&quot;);
		echo &quot;&lt;br/&gt;&quot;;
		$i++;
	}
	echo &quot;Total:$i&quot;.&quot;&lt;br/&gt;&quot;;

echo &quot;Configurable Products&lt;br/&gt;&quot;;
	$products = Mage::getModel('catalog/product')-&gt;getCollection()
	-&gt;addAttributeToSelect(&quot;url_key&quot;)
    -&gt;addAttributeToSelect('type_id')
	-&gt;addAttributeToFilter('status', $status)
	-&gt;addAttributeToFilter('type_id', Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE);

	$i=0;
	foreach ($products as $product) {
		$product-&gt;setData(&quot;url_key&quot;, &quot;&quot;);//$product-&gt;getData(&quot;url_key&quot;).&quot;-&quot;.$product-&gt;getData(&quot;product_id&quot;));
		$product-&gt;setData(&quot;url_key&quot;, $product-&gt;getData(&quot;url_key&quot;).&quot;-&quot;.$product-&gt;getData(&quot;product_id&quot;));
		$product-&gt;save();
		//echo $product-&gt;getData(&quot;url_key&quot;);
		echo &quot;&lt;br/&gt;&quot;;
		$i++;
	}
	echo &quot;Total:$i&quot;.&quot;&lt;br/&gt;&quot;;
</pre>
<div id="wpcr_respond_1"></div>]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/magento/magento-weird-numbers-at-the-end-of-product-url/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Magento Useful Methods</title>
		<link>http://www.unexpectedit.com/magento/magento-useful-methods</link>
		<comments>http://www.unexpectedit.com/magento/magento-useful-methods#comments</comments>
		<pubDate>Sat, 24 Jul 2010 08:53:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[Config]]></category>
		<category><![CDATA[currency]]></category>
		<category><![CDATA[getCurrentCurrencyCode]]></category>
		<category><![CDATA[getStoreConfig]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=197</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: php; title: ; notranslate">
//Get Store Configuration Setting
echo Mage::getStoreConfig(&quot;carriers/freeshipping/free_shipping_subtotal&quot;);

//Get Currency Symbol
echo Mage::app()-&gt;getLocale()-&gt;currency(Mage::app()-&gt;getStore()-&gt;getCurrentCurrencyCode())-&gt;getSymbol();

//Print Amount Proper Currency (e.g. $102.36)
echo Mage::helper('core')-&gt;currency($subtotal, true, true)
</pre>
<div id="wpcr_respond_1"></div>]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/magento/magento-useful-methods/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

