<?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>My Silly Point of View &#187; Techie Daw</title>
	<atom:link href="http://mysillypointofview.richardferaro.com/category/techie-daw/feed/" rel="self" type="application/rss+xml" />
	<link>http://mysillypointofview.richardferaro.com</link>
	<description>it&#039;s my blog anyway</description>
	<lastBuildDate>Sun, 06 Nov 2011 05:36:22 +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>How to fix the &#8220;Illegal scheme supplied, only alphanumeric characters are permitted&#8221; Magento error on Localhost using HTTP (fresh install)</title>
		<link>http://mysillypointofview.richardferaro.com/2011/11/01/how-to-fix-the-illegal-scheme-supplied-error-on-localhost-fresh-install/</link>
		<comments>http://mysillypointofview.richardferaro.com/2011/11/01/how-to-fix-the-illegal-scheme-supplied-error-on-localhost-fresh-install/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 20:56:01 +0000</pubDate>
		<dc:creator>Richard Feraro</dc:creator>
				<category><![CDATA[Feeling guru]]></category>
		<category><![CDATA[Techie Daw]]></category>

		<guid isPermaLink="false">http://mysillypointofview.richardferaro.com/?p=729</guid>
		<description><![CDATA[I want to setup a development environment for the Mage Enabler for WordPress plugin in my new desktop so I downloaded the latest copy of Magento Community Edition which is version 1.6.1.0 at the time of this writing. I used the sample data provided from the Magento download page and used all the default values. [...]]]></description>
			<content:encoded><![CDATA[<p>I want to setup a development environment for the <a href="http://wordpress.org/extend/plugins/mage-enabler/" title="Mage Enabler" target="_blank">Mage Enabler</a> for WordPress plugin in my new desktop so I downloaded the latest copy of Magento Community Edition which is version 1.6.1.0 at the time of this writing. I used the sample data provided from the Magento download page and used all the default values.</p>
<p><span id="more-729"></span></p>
<p style="text-align: center;"><a href="http://mysillypointofview.richardferaro.com/wp-content/uploads/2011/11/Magento-Installation-Wizard.png"><img class="size-medium wp-image-736" title="Magento Installation Wizard" src="http://mysillypointofview.richardferaro.com/wp-content/uploads/2011/11/Magento-Installation-Wizard-300x300.png" alt="Magento Installation Wizard" width="300" height="300" /></a></p>
<p>Everything went well during the installation except when I access the frontend (http://localhost/magento) and admin (http://localhost/magento/admin), I was greeted with the default error page like the one below:</p>
<p style="text-align: center;"><a href="http://mysillypointofview.richardferaro.com/wp-content/uploads/2011/11/There-has-been-an-error-processing-your-request.png"><img class="size-full wp-image-733 aligncenter" title="There has been an error processing your request" src="http://mysillypointofview.richardferaro.com/wp-content/uploads/2011/11/There-has-been-an-error-processing-your-request.png" alt="" width="532" height="205" /></a></p>
<p>The page itself is not helpful so I decided to check the content of the error log (htdocs\magento\var\report) record number <strong>1742231029</strong> which contains the following information:</p>
<p><code>a:5:{i:0;s:67:"Illegal scheme supplied, only alphanumeric characters are permitted";i:1;s:681:"#0 C:\xampp\htdocs\magento\app\code\core\Mage\Core\Model\Store.php(712): Zend_Uri::factory('{{base_url}}')<br />
#1 C:\xampp\htdocs\magento\app\code\core\Mage\Core\Controller\Varien\Front.php(313): Mage_Core_Model_Store-&gt;isCurrentlySecure()<br />
#2 C:\xampp\htdocs\magento\app\code\core\Mage\Core\Controller\Varien\Front.php(161): Mage_Core_Controller_Varien_Front-&gt;_checkBaseUrl(Object(Mage_Core_Controller_Request_Http))<br />
#3 C:\xampp\htdocs\magento\app\code\core\Mage\Core\Model\App.php(349): Mage_Core_Controller_Varien_Front-&gt;dispatch()<br />
#4 C:\xampp\htdocs\magento\app\Mage.php(640): Mage_Core_Model_App-&gt;run(Array)<br />
#5 C:\xampp\htdocs\magento\index.php(80): Mage::run('', 'store')<br />
#6 {main}";s:3:"url";s:19:"/magento/index.php/";s:11:"script_name";s:18:"/magento/index.php";s:4:"skin";s:7:"default";}</code></p>
<p>As you can see, the cause of the error is the invalid config data format being passed during the start of a session. To fix this, we need to accomplish these tasks:
<ol type="1">
<li>Allow the admin panel to run on localhost by disabling the domain check.</li>
<li>Fix the config data value.</li>
</ol>
<h3>Allow the admin panel to run on localhost.</h3>
<p>You will need to follow the <a href="http://mysillypointofview.richardferaro.com/2010/03/24/how-to-fix-magentos-admin-login-failing-no-error-message-on-localhost/" title="How to Fix Magento’s Admin Login Failing (no error message) on Localhost">instructions in my previous post</a> but instead of using HTTP, <span style="text-decoration: underline">you must access the admin page via HTTPS</span> after you applied the code changes.</p>
<h3>Fixing the config data value.</h3>
<p>Once you are able to access the admin panel using HTTPS, go to <em>System > Configuration > General > Web</em>. Make sure that you supply the proper value for the Base URL on both Unsecure and Secure tabs then <strong>save the changes</strong>. See my example below:</p>
<p style="text-align: center;"><a href="http://mysillypointofview.richardferaro.com/wp-content/uploads/2011/11/Configuration-System-Magento-Admin.png"><img src="http://mysillypointofview.richardferaro.com/wp-content/uploads/2011/11/Configuration-System-Magento-Admin-300x157.png" alt="" title="Configuration - System - Magento Admin" width="300" height="157" class="aligncenter size-medium wp-image-758" /></a></p>
<p>Clear your browser&#8217;s cache and also Magento&#8217;s cache by deleting all the contents (not the folder itself) of the cache directory (htdocs\magento\var\cache). At this point, you should be able to access the frontend and admin panel using HTTP protocol.</p>
]]></content:encoded>
			<wfw:commentRss>http://mysillypointofview.richardferaro.com/2011/11/01/how-to-fix-the-illegal-scheme-supplied-error-on-localhost-fresh-install/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Auto-select all &lt;option&gt; items from multiple select dropdown using jQuery</title>
		<link>http://mysillypointofview.richardferaro.com/2011/04/12/auto-select-all-option-items-from-multiple-select-dropdown-using-jquery/</link>
		<comments>http://mysillypointofview.richardferaro.com/2011/04/12/auto-select-all-option-items-from-multiple-select-dropdown-using-jquery/#comments</comments>
		<pubDate>Mon, 11 Apr 2011 16:00:00 +0000</pubDate>
		<dc:creator>Richard Feraro</dc:creator>
				<category><![CDATA[Feeling guru]]></category>
		<category><![CDATA[Techie Daw]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://mysillypointofview.richardferaro.com/2011/04/12/auto-select-all-option-items-from-multiple-select-dropdown-using-jquery/</guid>
		<description><![CDATA[I’ve been working for the past few days with jQuery and one of the task was to manipulate HTML forms before submitting it for processing. What I needed to do is to process a form having multiple submit buttons and select tags. These set of select tags requires all values to be selected on submit. [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been working for the past few days with jQuery and one of the task was to manipulate HTML forms before submitting it for processing. What I needed to do is to process a form having multiple submit buttons and select tags. These set of select tags requires all values to be selected on submit.</p>
<p><span id="more-717"></span></p>
<p>Let’s start with creating the markup of the form. Save the HTML below and name it as <code>index.htm</code> (we won’t be needing PHP stuff for now in this exercise.)</p>
<p>
<pre class="brush: xml; title: ; notranslate">&lt;!doctype html&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; /&gt;
&lt;title&gt;Sample Form&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;//ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
	&lt;form id=&quot;myForm&quot; action=&quot;index.html&quot; method=&quot;post&quot; onSubmit=&quot;return false;&quot;&gt;
		&lt;select id=&quot;do-not-select&quot; name=&quot;do-not-select[]&quot; multiple=&quot;multiple&quot; size=&quot;3&quot;&gt;
			&lt;option&gt;Do&lt;/option&gt;
			&lt;option&gt;not&lt;/option&gt;
			&lt;option&gt;select&lt;/option&gt;
		&lt;/select&gt;
		&lt;select id=&quot;color&quot; name=&quot;color[]&quot; multiple=&quot;multiple&quot; size=&quot;3&quot;&gt;
			&lt;option&gt;Red&lt;/option&gt;
			&lt;option&gt;Green&lt;/option&gt;
			&lt;option&gt;Blue&lt;/option&gt;
		&lt;/select&gt;
		&lt;select id=&quot;size&quot; name=&quot;size[]&quot; multiple=&quot;multiple&quot; size=&quot;3&quot;&gt;
			&lt;option&gt;Small&lt;/option&gt;
			&lt;option&gt;Medium&lt;/option&gt;
			&lt;option&gt;Large&lt;/option&gt;
		&lt;/select&gt;
		&lt;select id=&quot;category&quot; name=&quot;category[]&quot; multiple=&quot;multiple&quot; size=&quot;3&quot;&gt;
			&lt;option&gt;Children&lt;/option&gt;
			&lt;option&gt;Ladies&lt;/option&gt;
			&lt;option&gt;Men&lt;/option&gt;
		&lt;/select&gt;
		&lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;
	&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
</p>
<p>The markup above will create a single form with an id of <strong>myForm</strong> having four (4) multi-select field with the following ids: </p>
<ul>
<li>do-not-select</li>
<li>color</li>
<li>size</li>
<li>category</li>
</ul>
<p>At line 6, we added the jQuery file (latest version 1.5.2 as of this writing) to use it&#8217;s functionality in manipulating <a href="http://en.wikipedia.org/wiki/Document_Object_Model">DOM objects</a>. Now for the real action, copy the code below and insert it between line 6 and 7:</p>
<p>
<pre class="brush: xml; title: ; notranslate">&lt;script&gt;
$(document).ready(function() {
	$('#myForm').submit(function() {
		$('#color, #size, #category').find('option').each(function() {
			$(this).attr('selected', 'selected');
		});
	});
});
&lt;/script&gt;</pre>
</p>
<p>The script above will do the following task: </p>
<ol type="1">
<li>Instruct the browser to execute the script within <code>$(document).ready(...);</code> when the page has loaded. </li>
<li>Trigger the script within <code>$('#myForm').submit(...)</code> once the form with an id of <strong>myForm</strong> is submitted. </li>
<li>With the given <code>SELECT</code> element ids (color, size, category), find all <code>OPTION</code> tags in each of them and add the attribute and value <code>selected=&quot;selected&quot;</code> </li>
</ol>
<p>We also added at line 10 the event handler <code>onSubmit</code> with <code>return false;</code> to prevent the page on submitting while we are testing the script.</p>
<p>That&#8217;s it! Load the file on your browser and click Submit button. It should highlight all the options under color, size and category while ignoring the <strong>do-not-select</strong> option since we didn&#8217;t add them in the affected elements. See the full markup below. Remember to remove the <code>onSubmit="return false;"</code> in the <code>FORM</code> tag to enable redirection of your form on submit.</p>
<p>
<pre class="brush: xml; title: ; notranslate">&lt;!doctype html&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; /&gt;
&lt;title&gt;Sample Form&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;//ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script&gt;
$(document).ready(function() {
	$('#myForm').submit(function() {
		$('#color, #size, #category').find('option').each(function() {
			$(this).attr('selected', 'selected');
		});
	});
});
&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
	&lt;form id=&quot;myForm&quot; action=&quot;index.html&quot; method=&quot;post&quot; onSubmit=&quot;return false;&quot;&gt;
		&lt;select id=&quot;do-not-select&quot; name=&quot;do-not-select[]&quot; multiple=&quot;multiple&quot; size=&quot;3&quot;&gt;
			&lt;option&gt;Do&lt;/option&gt;
			&lt;option&gt;not&lt;/option&gt;
			&lt;option&gt;select&lt;/option&gt;
		&lt;/select&gt;
		&lt;select id=&quot;color&quot; name=&quot;color[]&quot; multiple=&quot;multiple&quot; size=&quot;3&quot;&gt;
			&lt;option&gt;Red&lt;/option&gt;
			&lt;option&gt;Green&lt;/option&gt;
			&lt;option&gt;Blue&lt;/option&gt;
		&lt;/select&gt;
		&lt;select id=&quot;size&quot; name=&quot;size[]&quot; multiple=&quot;multiple&quot; size=&quot;3&quot;&gt;
			&lt;option&gt;Small&lt;/option&gt;
			&lt;option&gt;Medium&lt;/option&gt;
			&lt;option&gt;Large&lt;/option&gt;
		&lt;/select&gt;
		&lt;select id=&quot;category&quot; name=&quot;category[]&quot; multiple=&quot;multiple&quot; size=&quot;3&quot;&gt;
			&lt;option&gt;Children&lt;/option&gt;
			&lt;option&gt;Ladies&lt;/option&gt;
			&lt;option&gt;Men&lt;/option&gt;
		&lt;/select&gt;
		&lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;
	&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://mysillypointofview.richardferaro.com/2011/04/12/auto-select-all-option-items-from-multiple-select-dropdown-using-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to create a new Magento customer account from an external site?</title>
		<link>http://mysillypointofview.richardferaro.com/2011/02/22/create-new-magento-customer-from-external-site/</link>
		<comments>http://mysillypointofview.richardferaro.com/2011/02/22/create-new-magento-customer-from-external-site/#comments</comments>
		<pubDate>Mon, 21 Feb 2011 16:00:08 +0000</pubDate>
		<dc:creator>Richard Feraro</dc:creator>
				<category><![CDATA[Feeling guru]]></category>
		<category><![CDATA[Techie Daw]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://mysillypointofview.richardferaro.com/?p=655</guid>
		<description><![CDATA[I&#8217;ve been receiving a lot of inquiries on how to create a new customer record on the fly using Mage.php or using the plugin Mage Enabler for WordPress. So, to save you time and also to provide a thread for this specific topic, here&#8217;s how to accomplish it. First, include the file Mage.php from your [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been receiving a lot of inquiries on how to create a new customer record on the fly using <code>Mage.php</code> or using the plugin <a href="http://wordpress.org/extend/plugins/mage-enabler/">Mage Enabler</a> for WordPress. So, to save you time and also to provide a thread for this specific topic, here&#8217;s how to accomplish it.</p>
<p><span id="more-655"></span>First, include the file <code>Mage.php</code> from your Magento installation to your PHP file. Doing this will enable you to connect to your shop using the Mage object.</p>
<p><strong>If you&#8217;re using Mage Enabler for WordPress, you may skip this part:</strong></p>
<pre class="brush: php; title: ; notranslate">&lt;?php
require_once (&quot;/your/magento/app/Mage.php&quot;);
umask(0);</pre>
<p>and here&#8217;s the rest of the code&#8230;</p>
<pre class="brush: php; first-line: 4; title: ; notranslate">// Customer Information
$firstname = &quot;John&quot;;
$lastname = &quot;Smith&quot;;
$email = &quot;johnsmith@localhost.local&quot;;
$password = &quot;myverysecretpassword&quot;;

// Website and Store details
$websiteId = Mage::app()-&gt;getWebsite()-&gt;getId();
$store = Mage::app()-&gt;getStore();

$customer = Mage::getModel(&quot;customer/customer&quot;);
$customer-&gt;website_id = $websiteId;
$customer-&gt;setStore($store);

try {
	// If new, save customer information
	$customer-&gt;firstname = $firstname;
	$customer-&gt;lastname = $lastname;
	$customer-&gt;email = $email;
	$customer-&gt;password_hash = md5($password);
	if($customer-&gt;save()){
		echo $customer-&gt;firstname.&quot; &quot;.$customer-&gt;lastname.&quot; information is saved!&quot;;
	}else{
		echo &quot;An error occured while saving customer&quot;;
	}
}catch(Exception $e){
	// If customer already exists, initiate login
	if(preg_match('/Customer email already exists/', $e)){
		$customer-&gt;loadByEmail($email);

		$session = Mage::getSingleton('customer/session');
		$session-&gt;login($email, $password);

		echo $session-&gt;isLoggedIn() ? $session-&gt;getCustomer()-&gt;getName().' is online!' : 'not logged in';
	}
}</pre>
<p>The above code tries to create a Magento customer account using the given parameters such as <code>$firstname</code>, <code>$lastname</code>, <code>$email</code> and <code>$password</code>. If the email doesn&#8217;t have a match in the database, the request proceeds. But if a match is found, it logs in the customer using the parameters <code>$email</code> and <code>$password</code> then checks if the customer is online or not logged in. There are actually more parameters that you can pass such as if you want to send confirmation message or not but these are the basic fields to help you get started.</p>
<p>I hope this will help you integrate the Magento registration to your external site <img src='http://mysillypointofview.richardferaro.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://mysillypointofview.richardferaro.com/2011/02/22/create-new-magento-customer-from-external-site/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Separating message and author in &#8216;Stray Random Quotes&#8217; WordPress plugin</title>
		<link>http://mysillypointofview.richardferaro.com/2011/01/30/separate-message-author-in-stray-random-plugin/</link>
		<comments>http://mysillypointofview.richardferaro.com/2011/01/30/separate-message-author-in-stray-random-plugin/#comments</comments>
		<pubDate>Sat, 29 Jan 2011 20:05:22 +0000</pubDate>
		<dc:creator>Richard Feraro</dc:creator>
				<category><![CDATA[Feeling guru]]></category>
		<category><![CDATA[Techie Daw]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://mysillypointofview.richardferaro.com/?p=639</guid>
		<description><![CDATA[I needed a plugin that can show random quotes with author options as well and I found Stray Random Quotes WordPress plugin could do the trick. The only problem is, the function to display the random quote directly outputs the text onscreen together with the author. What I need to do is to suppress the [...]]]></description>
			<content:encoded><![CDATA[<p>I needed a plugin that can show random quotes with author options as well and I found <a href="http://wordpress.org/extend/plugins/stray-quotes/">Stray Random Quotes</a> WordPress plugin could do the trick. The only problem is, the function to display the random quote directly outputs the text onscreen together with the author.</p>
<p><span id="more-639"></span>What I need to do is to suppress the display of the function output onscreen, pass it to a variable then do a split of the variable to separate the message and author in an array. See the code below on how I did it <img src='http://mysillypointofview.richardferaro.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre class="brush: php; title: ; notranslate">&lt;?php
if (function_exists('stray_random_quote'))
// turn on output buffer
ob_start();
// run the function of the plugin
stray_random_quote('feedback',false,'',true,1,0,'Category','ASC',false,'');
// get the content from the buffer
$string = ob_get_contents();
ob_end_clean();
// split the output and remove unnecessary HTML tags
$feedback = split('by',strip_tags($string));
// access the message
echo trim($feedback[0]);
// access the author
echo trim($feedback[1]);</pre>
<p>Pretty easy!</p>
]]></content:encoded>
			<wfw:commentRss>http://mysillypointofview.richardferaro.com/2011/01/30/separate-message-author-in-stray-random-plugin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>My Silly Point of View is nominated for Best Technology Blog!</title>
		<link>http://mysillypointofview.richardferaro.com/2010/11/22/my-silly-point-of-view-is-nominated-for-best-technology-blog/</link>
		<comments>http://mysillypointofview.richardferaro.com/2010/11/22/my-silly-point-of-view-is-nominated-for-best-technology-blog/#comments</comments>
		<pubDate>Mon, 22 Nov 2010 08:04:12 +0000</pubDate>
		<dc:creator>Richard Feraro</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[Techie Daw]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://mysillypointofview.richardferaro.com/?p=603</guid>
		<description><![CDATA[The event will be held on 12th of December 2010 at Carlos P. Romulo Auditorium, RCBC Plaza. Hopefully, I&#8217;ll be able to win the award but nevertheless, the ultimate goal is to be with the best Filipino bloggers in the country.]]></description>
			<content:encoded><![CDATA[<p>The event will be held on 12th of December 2010 at Carlos P. Romulo Auditorium, RCBC Plaza. Hopefully, I&#8217;ll be able to win the award but nevertheless, the ultimate goal is to be with the best Filipino bloggers in the country.</p>
]]></content:encoded>
			<wfw:commentRss>http://mysillypointofview.richardferaro.com/2010/11/22/my-silly-point-of-view-is-nominated-for-best-technology-blog/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>How to pull the list of customers from Magento to an external site?</title>
		<link>http://mysillypointofview.richardferaro.com/2010/09/07/how-to-pull-the-list-of-customers-from-magento-to-an-external-site/</link>
		<comments>http://mysillypointofview.richardferaro.com/2010/09/07/how-to-pull-the-list-of-customers-from-magento-to-an-external-site/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 09:09:16 +0000</pubDate>
		<dc:creator>Richard Feraro</dc:creator>
				<category><![CDATA[Feeling guru]]></category>
		<category><![CDATA[Techie Daw]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://mysillypointofview.richardferaro.com/?p=565</guid>
		<description><![CDATA[If you&#8217;re thinking of creating a page that will display your customer list from Magento to a different PHP-based application, you can use the script below to do so. First, let&#8217;s create a file called index.php and inside it, create function (I named it getCustomers()) that will extract an array of customer list and their [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re thinking of creating a page that will display your customer list from Magento to a different PHP-based application, you can use the script below to do so.</p>
<p>First, let&#8217;s create a file called <code>index.php</code> and inside it, create function (I named it <strong>getCustomers()</strong>) that will extract an array of customer list and their information. The function should be able to access the <code>Mage.php</code> file of your Magento instance.</p>
<p><span id="more-565"></span>
<pre class="brush: php; title: ; notranslate">&lt;?php
function getCustomers() {
	/* Magento's Mage.php path
	 * Mage Enabler users may skip these lines
	 */
	require_once (&quot;../magento/app/Mage.php&quot;);
	umask(0);
	Mage::app(&quot;default&quot;);
	/* Magento's Mage.php path */

	/* Get customer model, run a query */
	$collection = Mage::getModel('customer/customer')
				  -&gt;getCollection()
				  -&gt;addAttributeToSelect('*');

	$result = array();
	foreach ($collection as $customer) {
		$result[] = $customer-&gt;toArray();
	}

	return $result;
}
?&gt;</pre>
<p>Once you&#8217;re done with the function, add the HTML tags needed to create the a page with a table for the customer information.</p>
<pre class="brush: xml; first-line: 24; title: ; notranslate">&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Customers&lt;/title&gt;
&lt;style&gt;
table {
	border-collapse: collapse;
}
td {
	padding: 5px;
	border: 1px solid #000000;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;table&gt;
&lt;tr&gt;
	&lt;td&gt;ID&lt;/td&gt;
	&lt;td&gt;Lastname&lt;/td&gt;
	&lt;td&gt;Firstname&lt;/td&gt;
	&lt;td&gt;Email&lt;/td&gt;
	&lt;td&gt;Is Active?&lt;/td&gt;
	&lt;td&gt;Date Created&lt;/td&gt;
	&lt;td&gt;Date Updated&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>After line 47, press return/enter key and add the following script to loop through the array result of our <code>getCustomer()</code> function:</p>
<pre class="brush: php; first-line: 48; title: ; notranslate">&lt;?php
$result = getcustomers();
if(count($result) &gt; 0){
	foreach($result as $key =&gt; $value){
		echo &quot;&lt;tr&gt;&quot;;
			echo &quot;&lt;td&gt;&quot;.$value['entity_id'].&quot;&lt;/td&gt;&quot;;
			echo &quot;&lt;td&gt;&quot;.$value['lastname'].&quot;&lt;/td&gt;&quot;;
			echo &quot;&lt;td&gt;&quot;.$value['firstname'].&quot;&lt;/td&gt;&quot;;
			echo &quot;&lt;td&gt;&quot;.$value['email'].&quot;&lt;/td&gt;&quot;;
			echo &quot;&lt;td&gt;&quot;;
			echo $value['is_active'] == 1 ? &quot;Yes&quot; : &quot;No&quot;;
			echo &quot;&lt;/td&gt;&quot;;
			echo &quot;&lt;td&gt;&quot;.$value['created_at'].&quot;&lt;/td&gt;&quot;;
			echo &quot;&lt;td&gt;&quot;.$value['updated_at'].&quot;&lt;/td&gt;&quot;;
		echo &quot;&lt;/tr&gt;&quot;;
	}
}else{
	echo &quot;&lt;tr&gt;&lt;td colspan=\&quot;7\&quot;&gt;No records found&lt;/td&gt;&lt;/tr&gt;&quot;;
}
?&gt;</pre>
<p>There are several available information within the array that you can also use. Here&#8217;s an example of a record result from our function:</p>
<pre class="brush: php; title: ; notranslate">[0] =&gt; Array
	(
		[entity_id] =&gt; 1
		[entity_type_id] =&gt; 1
		[attribute_set_id] =&gt; 0
		[website_id] =&gt; 1
		[email] =&gt; john.doe@example.com
		[group_id] =&gt; 1
		[increment_id] =&gt; 000000001
		[store_id] =&gt; 1
		[created_at] =&gt; 2007-08-30 23:23:13
		[updated_at] =&gt; 2008-08-08 12:28:24
		[is_active] =&gt; 1
		[firstname] =&gt; John
		[lastname] =&gt; Doe
		[password_hash] =&gt; 2049484a4020ed15d0e4238db22977d5:eg
		[prefix] =&gt;
		[middlename] =&gt;
		[suffix] =&gt;
		[taxvat] =&gt;
		[default_billing] =&gt; 274
		[default_shipping] =&gt; 274
	)</pre>
<p>Save the file as <code>index.php</code> and access it through your browser. It should display a table similar to the one below:</p>
<div id="attachment_574" class="wp-caption aligncenter" style="width: 501px"><a href="http://mysillypointofview.richardferaro.com/wp-content/uploads/2010/09/Customers_list.png"><img class="size-full wp-image-574   " title="Customers_list" src="http://mysillypointofview.richardferaro.com/wp-content/uploads/2010/09/Customers_list.png" alt="Sample table of customers from Magento" width="491" height="266" /></a><p class="wp-caption-text">Sample table of customers from Magento</p></div>
<p>Here&#8217;s the <code>index.php</code> for your reference:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php
function getcustomers() {
	/* Magento's Mage.php path
	 * Mage Enabler users may skip these lines
	 */
	require_once (&quot;../magento/app/Mage.php&quot;);
	umask(0);
	Mage::app(&quot;default&quot;);
	/* Magento's Mage.php path */

	/* Get customer model, run a query */
	$collection = Mage::getModel('customer/customer')
				  -&gt;getCollection()
				  -&gt;addAttributeToSelect('*');

	$result = array();
	foreach ($collection as $customer) {
		$result[] = $customer-&gt;toArray();
	}

	return $result;
}
?&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Customers&lt;/title&gt;
&lt;style&gt;
table {
	border-collapse: collapse;
}
td {
	padding: 5px;
	border: 1px solid #000000;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;table&gt;
&lt;tr&gt;
	&lt;td&gt;ID&lt;/td&gt;
	&lt;td&gt;Lastname&lt;/td&gt;
	&lt;td&gt;Firstname&lt;/td&gt;
	&lt;td&gt;Email&lt;/td&gt;
	&lt;td&gt;Is Active?&lt;/td&gt;
	&lt;td&gt;Date Created&lt;/td&gt;
	&lt;td&gt;Date Updated&lt;/td&gt;
&lt;/tr&gt;
&lt;?php
$result = getcustomers();
if(count($result) &gt; 0){
	foreach($result as $key =&gt; $value){
		echo &quot;&lt;tr&gt;&quot;;
			echo &quot;&lt;td&gt;&quot;.$value['entity_id'].&quot;&lt;/td&gt;&quot;;
			echo &quot;&lt;td&gt;&quot;.$value['lastname'].&quot;&lt;/td&gt;&quot;;
			echo &quot;&lt;td&gt;&quot;.$value['firstname'].&quot;&lt;/td&gt;&quot;;
			echo &quot;&lt;td&gt;&quot;.$value['email'].&quot;&lt;/td&gt;&quot;;
			echo &quot;&lt;td&gt;&quot;;
			echo $value['is_active'] == 1 ? &quot;Yes&quot; : &quot;No&quot;;
			echo &quot;&lt;/td&gt;&quot;;
			echo &quot;&lt;td&gt;&quot;.$value['created_at'].&quot;&lt;/td&gt;&quot;;
			echo &quot;&lt;td&gt;&quot;.$value['updated_at'].&quot;&lt;/td&gt;&quot;;
		echo &quot;&lt;/tr&gt;&quot;;
	}
}else{
	echo &quot;&lt;tr&gt;&lt;td colspan=\&quot;7\&quot;&gt;No records found&lt;/td&gt;&lt;/tr&gt;&quot;;
}
?&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://mysillypointofview.richardferaro.com/2010/09/07/how-to-pull-the-list-of-customers-from-magento-to-an-external-site/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Mage Enabler is now available for download in the Official WordPress Plugin repository!</title>
		<link>http://mysillypointofview.richardferaro.com/2010/05/12/mage-enabler-is-now-available-for-download/</link>
		<comments>http://mysillypointofview.richardferaro.com/2010/05/12/mage-enabler-is-now-available-for-download/#comments</comments>
		<pubDate>Wed, 12 May 2010 06:48:03 +0000</pubDate>
		<dc:creator>Richard Feraro</dc:creator>
				<category><![CDATA[Techie Daw]]></category>
		<category><![CDATA[e-commerce]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://mysillypointofview.wordpress.com/?p=378</guid>
		<description><![CDATA[I&#8217;m soooo happy to see my very first plugin to be released for everyone to use. I hope it will help a lot of Magento and WordPress users! Click! click! click!]]></description>
			<content:encoded><![CDATA[<p><a href="http://mysillypointofview.files.wordpress.com/2010/05/wordpress-e280ba-newest-c2ab-wordpress-plugins_1273645824215.png"><img src="http://mysillypointofview.files.wordpress.com/2010/05/wordpress-e280ba-newest-c2ab-wordpress-plugins_1273645824215.png" alt="" title="Mage Enabler plugin" width="497" height="207" class="alignnone size-full wp-image-379" /></a></p>
<p>I&#8217;m soooo happy to see my very first plugin to be released for everyone to use. I hope it will help a lot of Magento and WordPress users!</p>
<p><a href="http://wordpress.org/extend/plugins/mage-enabler/">Click! click! click!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mysillypointofview.richardferaro.com/2010/05/12/mage-enabler-is-now-available-for-download/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Mage Enabler: A plugin to run Magento&#039;s session within WordPress</title>
		<link>http://mysillypointofview.richardferaro.com/2010/05/11/mage-enabler/</link>
		<comments>http://mysillypointofview.richardferaro.com/2010/05/11/mage-enabler/#comments</comments>
		<pubDate>Tue, 11 May 2010 10:56:30 +0000</pubDate>
		<dc:creator>Richard Feraro</dc:creator>
				<category><![CDATA[Feeling guru]]></category>
		<category><![CDATA[Techie Daw]]></category>
		<category><![CDATA[e-commerce]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://mysillypointofview.wordpress.com/?p=350</guid>
		<description><![CDATA[Update (May 12, 2010): Mage Enabler is now available in the Official WordPress Plugin repository. Get it here! It&#8217;s been a while since I posted my tweak that allows Mage object to be utilized within any WordPress installation. The tweak requires the blog owner to modify functions.php as stated in my post. I&#8217;m inspired by [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-365" title="mage_enabler" src="http://mysillypointofview.files.wordpress.com/2010/05/mage_enabler.png" alt="Mage Enabler" width="497" height="167" /></p>
<p><strong>Update (May 12, 2010):</strong> Mage Enabler is now available in the Official WordPress Plugin repository. <a href="http://wordpress.org/extend/plugins/mage-enabler/">Get it here!</a></p>
<p>It&#8217;s been a while since I posted my tweak that allows Mage object to be utilized within any WordPress installation. The tweak requires the blog owner to modify <strong>functions.php</strong> as stated in my <a href="http://mysillypointofview.wordpress.com/2010/04/08/how-to-use-magentos-session-within-wordpress/">post</a>. I&#8217;m inspired by the feedback of the readers who used the tweak so I decided that a plugin that does the same thing should be made to prevent modifying the WordPress core files thus preventing the tweak to cause inconsistencies when an upgrade is necessary.</p>
<p><span id="more-350"></span>It is my pleasure to introduce to you, <strong>Mage Enabler</strong> plugin. <del datetime="2010-05-12T06:31:45+00:00">Just copy the whole code snippet below and save it as <em>mage-enabler.php</em>. Place it inside a folder named <strong>mage-enabler</strong> together with the <em>readme.txt</em> available right after the code block.</del> Please take time to read and follow the readme.txt instruction on how to install the plugin in your WordPress setup.</p>
<h2>How to use the plugin?</h2>
<p>To show you how the plugin works, I&#8217;ve decided to convert my example in my previous <a href="http://mysillypointofview.wordpress.com/2010/04/08/how-to-use-magentos-session-within-wordpress/">post</a> by providing a single login page for both WordPress (subscriber) and Magento (customer). This setup assumes that the account credentials (subcriber/customer) in both database are the same and that the function collision problem between WordPress and Magento has been <a href="http://mysillypointofview.wordpress.com/2010/04/08/how-to-use-magentos-session-within-wordpress/">fixed</a>. If you followed the <strong>functions.php</strong> update in that post, <strong>remove the block of code added at line 4123 to 4138</strong>.</p>
<p>Location of functions.php</p>
<pre>path-to-your-root-htdocs/wordpress/wp-includes/functions.php</pre>
<p>Let&#8217;s start by opening the <strong>index.php</strong> file of the WordPress theme Twenty Ten. I&#8217;m using version 3.0-beta1 of WordPress in this article. You can replicate the same code update to any WordPress version and theme you have.</p>
<pre>wordpress_root\wp-content\themes\twentyten\index.php</pre>
<p>Copy the necessary codes (lines 16-18 and 22-40) to make it similar below:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php

/**
 * The main template file
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage Twenty Ten
 * @since 3.0.0
 */
 if(class_exists('Mage')){
 	Mage::getSingleton('core/session', array('name' =&gt; 'frontend'));
 }
?&gt;

&lt;?php get_header(); ?&gt;
&lt;!-- Magento's custom greeting --&gt;
&lt;div style=&quot;font-size: 15px; margin-bottom: 15px; border-bottom: 1px solid #000; padding-bottom: 10px;&quot;&gt;
&lt;?php
if(class_exists('Mage')){
	$session = Mage::getSingleton(&quot;customer/session&quot;);
	$magento_message = &quot;Welcome &quot;;
	// Generate a personalize greeting
	if($session-&gt;isLoggedIn()){
		$magento_message .= $session-&gt;getCustomer()-&gt;getData('firstname').' ';
		$magento_message .= $session-&gt;getCustomer()-&gt;getData('lastname').'!';
	}else{
		$magento_message .= &quot;Guest!&quot;;
	}

	echo $magento_message;
}
?&gt;
&lt;/div&gt;
&lt;!-- End of Magento's custom greeting --&gt;</pre>
<p>The purpose of the code change above is to display a ?Welcome [customer name here]? when a customer is logged in, and show ?Welcome Guest? when they are not. <strong>Make sure that if you&#8217;re going to use any Magento related script in your code, always write it within the following if condition:</strong></p>
<pre class="brush: php; title: ; notranslate">if(class_exists('Mage')){
	// Write your Magento codes here
}</pre>
<p>This will prevent your page or theme files from breaking up if in case the plugin is deactivated, not working or if Mage.php can&#8217;t be found.</p>
<p>Open user.php file found at following address below:</p>
<pre>path-to-your-root-htdocs/wordpress/wp-includes/user.php</pre>
<p>Locate the function wp_authenticate_username_password()  and find the similar code below. I found mine at line 108.</p>
<pre class="brush: php; first-line: 108; title: ; notranslate">	if ( !wp_check_password($password, $userdata-&gt;user_pass, $userdata-&gt;ID) )
		return new WP_Error('incorrect_password', sprintf(__('&lt;strong&gt;ERROR&lt;/strong&gt;: Incorrect password. &lt;a href=&quot;%s&quot; title=&quot;Password Lost and Found&quot;&gt;Lost your password&lt;/a&gt;?'), site_url('wp-login.php?action=lostpassword', 'login')));</pre>
<p>Right after the code above, add the following code starting at line 111 to make it similar to the code below. This update allows us to run the login request of Magento within WordPress:</p>
<pre class="brush: php; first-line: 108; title: ; notranslate">	if ( !wp_check_password($password, $userdata-&gt;user_pass, $userdata-&gt;ID) )
		return new WP_Error('incorrect_password', sprintf(__('&lt;strong&gt;ERROR&lt;/strong&gt;: Incorrect password. &lt;a href=&quot;%s&quot; title=&quot;Password Lost and Found&quot;&gt;Lost your password&lt;/a&gt;?'), site_url('wp-login.php?action=lostpassword', 'login')));
	// Start Magento
	if(class_exists('Mage')){
		Mage::getSingleton('core/session', array('name' =&gt; 'frontend'));
		$session = Mage::getSingleton(&quot;customer/session&quot;);
		try{
			$login = $session-&gt;login($username, $password);
		}catch(Exception $e){
			// Do nothing
		}
	}</pre>
<p>Finally, to call the Magento&#8217;s logout function, locate the file below and open it:</p>
<pre>path-to-your-root-htdocs/wordpress/wp-login.php</pre>
<p>Find the switch case statement at line 352. Add the necessary code to make it similar to the code below and save it:</p>
<pre class="brush: plain; first-line: 352; title: ; notranslate">switch ($action) {

case 'logout' :
	check_admin_referer('log-out');
	// Start Magento
	if(class_exists('Mage')){
		Mage::getSingleton('core/session', array('name' =&gt; 'frontend'));
		Mage::getSingleton(&quot;customer/session&quot;)-&gt;logout();
	}
	wp_logout();</pre>
<p>Now test your WordPress by accessing the homepage at http://localhost/wordpress/. It should display the &#8216;Welcome Guest&#8217; similar to the image below with a cookie named as &#8216;frontend&#8217; in your Firebug cookie tab. That is your Magento cookie.</p>
<div id="attachment_304" class="wp-caption aligncenter" style="width: 499px"><a href="http://mysillypointofview.files.wordpress.com/2010/04/test_wordpress_home.png"><img class="size-full wp-image-304 " title="A Test WordPress homepage showing the default welcome message for Magento" src="http://mysillypointofview.files.wordpress.com/2010/04/test_wordpress_home.png" alt="A Test WordPress homepage showing the default welcome message for Magento" width="489" height="516" /></a><p class="wp-caption-text">A Test WordPress homepage showing the default welcome message for Magento</p></div>
<p>Clicking the login for WordPress redirects us to the login form like the one below while still showing the &#8216;frontend&#8217; cookie. Since I have a customer with same credentials on both Magento (Customer) and WordPress (set as Subscriber), all I have to do is to use the username and password to login in the form below.</p>
<div id="attachment_306" class="wp-caption aligncenter" style="width: 496px"><a href="http://mysillypointofview.files.wordpress.com/2010/04/test_wordpress_login.png"><img class="size-full wp-image-306 " title="A Test WordPress login page with a generated Magento cookie" src="http://mysillypointofview.files.wordpress.com/2010/04/test_wordpress_login.png" alt="A Test WordPress login page with a generated Magento cookie" width="486" height="455" /></a><p class="wp-caption-text">A Test WordPress login page with a generated Magento cookie</p></div>
<p>At this point, your Magento session should be running with an active customer session. To check if it does, go back to your homepage by clicking the top header text or going to http://localhost/wordpress/. It should display now the welcome message with your customer&#8217;s name.</p>
<div id="attachment_308" class="wp-caption aligncenter" style="width: 496px"><a href="http://mysillypointofview.files.wordpress.com/2010/04/test_wordpress_with_active_customer.png"><img class="size-full wp-image-308 " title="A Test WordPress homepage showing the customer's name in the welcome message" src="http://mysillypointofview.files.wordpress.com/2010/04/test_wordpress_with_active_customer.png" alt="A Test WordPress homepage showing the customer's name in the welcome message" width="486" height="500" /></a><p class="wp-caption-text">A Test WordPress homepage showing the customer&#039;s name in the welcome message</p></div>
<p>For those who will use this plugin, let me know the version of WordPress and Magento you&#8217;re using so I can keep track of the list of versions in which this plugin is compatible. <del datetime="2010-05-12T06:31:45+00:00">Until such time that the plugin is moved to the Official WordPress Plugin repository, I&#8217;ll accept and answer inquiries here thru comment/feedback form below.</del> Mage Enabler is now available in the Official WordPress Plugin repository. <a href="http://wordpress.org/extend/plugins/mage-enabler/">Get it here!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mysillypointofview.richardferaro.com/2010/05/11/mage-enabler/feed/</wfw:commentRss>
		<slash:comments>182</slash:comments>
		</item>
		<item>
		<title>How to use Magento&#8217;s session within WordPress</title>
		<link>http://mysillypointofview.richardferaro.com/2010/04/08/how-to-use-magentos-session-within-wordpress/</link>
		<comments>http://mysillypointofview.richardferaro.com/2010/04/08/how-to-use-magentos-session-within-wordpress/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 13:38:31 +0000</pubDate>
		<dc:creator>Richard Feraro</dc:creator>
				<category><![CDATA[Feeling guru]]></category>
		<category><![CDATA[Techie Daw]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://mysillypointofview.wordpress.com/?p=283</guid>
		<description><![CDATA[Update (May 11, 2010): I created a WordPress plugin for this one. Check it out here. You have a free WordPress blog that has been online for sometime. You love its simple yet powerful way of managing your content so you&#8217;ve decided to have it hosted to a different provider in order to have a [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update (May 11, 2010):</strong> I created a WordPress plugin for this one. Check it out <a href="http://mysillypointofview.wordpress.com/2010/05/11/mage-enabler/">here</a>.</p>
<p>You have a free WordPress blog that has been online for sometime. You love its simple yet powerful way of managing your content so you&#8217;ve decided to have it hosted to a different provider in order to have a more granular control to its code and functionality. Eventually, you needed cash to support the hosting expenses so you decided to utilize your blog for e-commerce use. That&#8217;s when Magento comes in to the scene. You want to find a way to use Magento as your backend while pulling your catalog and customer information to be posted to WordPress site. This is what my article is for.</p>
<p><span id="more-283"></span>Since your WordPress will serve as the frontend, you don&#8217;t have to worry about where the database for Magento will be located as long as you have a local access to the Mage.php file in order to extend all Magento&#8217;s functionality to your WordPress pages. My current setup is still the same with the rest of my post here having &#8216;htdocs&#8217; as my root directory, magento has its own subdirectory &#8216;htdocs/magento&#8217; as well as wordpress in &#8216;htdocs/wordpress&#8217;. The goal here is to able to use Magento as if it is a native function within our WordPress installation.</p>
<p>Since there is an existing function collision between Magento and WordPress because both application has an existing translator function named <strong>__()</strong>, our first task is to automatically detect if the function already exists and disable it in Magento and run as usual if it doesn&#8217;t.</p>
<p><del datetime="2010-05-11T14:41:01+00:00">To do that, locate the file below in your Magento installation:</del><br />
Copy the file <strong>functions.php</strong> below from your Magento core folder</p>
<pre>path:to-your-htdocs/magento/app/code/core/Mage/Core/functions.php</pre>
<p>and paste it in the Magento local folder which can be found below and open it for editing (create needed folders if it doesn&#8217;t exists):</p>
<pre>path:to-your-htdocs/magento/app/code/local/Mage/Core/functions.php</pre>
<p>Locate the function <strong>__()</strong> or go to line 93:</p>
<pre class="brush: php; first-line: 93; title: ; notranslate">function __()
{
    return Mage::app()-&gt;getTranslator()-&gt;translate(func_get_args());
}</pre>
<p>replace it with this:</p>
<pre class="brush: php; first-line: 93; title: ; notranslate">if (!function_exists('__')) {
	function __()
	{
		return Mage::app()-&gt;getTranslator()-&gt;translate(func_get_args());
	}
}</pre>
<p>Why did I choose to disable Magento&#8217;s translator function instead of WordPress&#8217;? It is because in Magento, it has already been marked as deprecated in version 1.3 and searching throughout the installation I didn&#8217;t see any file that uses that function.</p>
<p>Now that the function collision has been solved, let&#8217;s proceed in modifying WordPress to include our Mage.php file. Locate and open the WordPress file below:</p>
<pre>path-to-your-root-htdocs/wordpress/wp-includes/functions.php</pre>
<p>Scroll down to the end of the file. Add the codes below right after the last function statement which is after line 4122</p>
<p><ins datetime="2010-07-15T15:11:08+00:00"><strong>Note: Mage Enabler plugin users don&#8217;t need to do this anymore.</strong></ins></p>
<pre class="brush: php; first-line: 4123; title: ; notranslate">/**
 * Run Magento's Mage.php within WordPress
 *
 * @author Richard Feraro &lt;richardferaro@gmail.com&gt;
 * @link http://mysillypointofview.richardferaro.com
 *
 * @return object
 */
function magento($name = &quot;frontend&quot;) {
	// Include Magento application
	require_once ( &quot;../magento/app/Mage.php&quot; );
	umask(0);
	// Initialize Magento
	Mage::app(&quot;default&quot;);
	return Mage::getSingleton(&quot;core/session&quot;, array(&quot;name&quot; =&gt; $name));
}</pre>
<p>That&#8217;s it! I know it&#8217;s weird that it isn&#8217;t like the solution given by others that require modifying a lot of files. Nevertheless, I tested it and it does work. You just have to make sure that whenever you use the <strong>magento()</strong> function to any file within WordPress, <strong>always place it at the top most part of the code where there&#8217;s no header request</strong> or else you will get a similar error below:</p>
<pre>Fatal error: Uncaught exception 'Exception' with message 'Warning: session_start() [<a href="function.session-start">function.session-start</a>]: Cannot send session cookie - headers already sent by (output started at path:to-your-htdocs\wordpress\wp-content\themes\twentyten\index.php:19) in path:to-your-htdocs\magento\app\code\core\Mage\Core\Model\Session\Abstract\Varien.php on line 115' in path:to-your-htdocs\magento\app\code\core\Mage\Core\functions.php:245 Stack trace: #0 [internal function]: mageCoreErrorHandler(2, 'session_start()...', 'path:to-your-htdocs...', 115, Array) #1 path:to-your-htdocs\magento\app\code\core\Mage\Core\Model\Session\Abstract\Varien.php(115): session_start() #2 path:to-your-htdocs\magento\app\code\core\Mage\Core\Model\Session\Abstract\Varien.php(155): Mage_Core_Model_Session_Abstract_Varien-&gt;start('frontend') #3 path:to-your-htdocs\magento\app\code\core\Mage\Core\Model\Session\Abstract.php(84): Mage_Core_Model_Session_Abstract_Varien-&gt;init('core', 'frontend') #4 path:to-your-htdocs\magento\app\code\core\Mage\Core\Model\Ses in path:to-your-htdocs\magento\app\code\core\Mage\Core\functions.php  on line 245</pre>
<p>An example of how to use this is to check whether a customer is logged in or not. To do this, open the <strong>index.php</strong> of WordPress&#8217; default theme which is Twenty Ten 0.7:</p>
<pre>path-to-your-root-htdocs/wordpress/wp-content/themes/twentyten/index.php</pre>
<p>Just below line 15, add the <strong>magento()</strong> function. It should look like the codes below:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php

/**
 * The main template file
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage Twenty Ten
 * @since 3.0.0
 */
 magento(); // Don't add this anymore if you're already using Mage Enabler

?&gt;

&lt;?php get_header(); ?&gt;</pre>
<p>Add the code below marked as <em>Magento&#8217;s custom greeting</em> right after the <strong>get_header()</strong> function of WordPress in the same file:</p>
<pre class="brush: php; first-line: 20; title: ; notranslate">&lt;?php get_header(); ?&gt;
&lt;!-- Magento's custom greeting --&gt;
&lt;div style=&quot;font-size: 15px; margin-bottom: 15px; border-bottom: 1px solid #000; padding-bottom: 10px;&quot;&gt;
&lt;?php
	$session = Mage::getSingleton(&quot;customer/session&quot;);
	$magento_message = &quot;Welcome &quot;;
	// Generate a personalize greeting
	if($session-&gt;isLoggedIn()){
		$magento_message .= $session-&gt;getCustomer()-&gt;getData('firstname').' ';
		$magento_message .= $session-&gt;getCustomer()-&gt;getData('lastname').'!';
	}else{
		$magento_message .= &quot;Guest!&quot;;
	}

	echo $magento_message;
	//echo &quot;&lt;br&gt;&quot;;
	//print_r($session);
?&gt;
&lt;/div&gt;
&lt;!-- End of Magento's custom greeting --&gt;</pre>
<p>The purpose of the code change above is to display a &#8216;Welcome [customer name here]&#8216; when a customer is logged in, and show &#8216;Welcome Guest&#8217; when they are not.</p>
<p>Next we have to edit the file below to allow us to use the default login page of WordPress as entry point for Magento also. <strong>We assumed here that both Magento and WordPress has the same list of user credentials.</strong> Your setup maybe different as to which user&#8217;s database to use so it&#8217;s up to you how to implement it.</p>
<pre>path-to-your-root-htdocs/wordpress/wp-includes/user.php</pre>
<p>Locate the function <strong>wp_authenticate_username_password()</strong> and find the similar code below. I found mine at line 108.</p>
<pre class="brush: php; first-line: 108; title: ; notranslate">	if ( !wp_check_password($password, $userdata-&gt;user_pass, $userdata-&gt;ID) )
		return new WP_Error('incorrect_password', sprintf(__('&lt;strong&gt;ERROR&lt;/strong&gt;: Incorrect password. &lt;a href=&quot;%s&quot; title=&quot;Password Lost and Found&quot;&gt;Lost your password&lt;/a&gt;?'), site_url('wp-login.php?action=lostpassword', 'login')));</pre>
<p>Right after the code above, add the following code starting at line 111 to make it similar to the code below. This update allows us to run the login request of Magento within WordPress:</p>
<pre class="brush: php; first-line: 108; title: ; notranslate">	if ( !wp_check_password($password, $userdata-&gt;user_pass, $userdata-&gt;ID) )
		return new WP_Error('incorrect_password', sprintf(__('&lt;strong&gt;ERROR&lt;/strong&gt;: Incorrect password. &lt;a href=&quot;%s&quot; title=&quot;Password Lost and Found&quot;&gt;Lost your password&lt;/a&gt;?'), site_url('wp-login.php?action=lostpassword', 'login')));
	// Start Magento
	magento(); // Don't add this anymore if you're already using Mage Enabler
	$session = Mage::getSingleton(&quot;customer/session&quot;);
	try{
		$login = $session-&gt;login($username, $password);
	}catch(Exception $e){
		// Do nothing
	}</pre>
<p>Finally, to call the Magento&#8217;s logout function, locate the file below and open it:</p>
<pre>path-to-your-root-htdocs/wordpress/wp-login.php</pre>
<p>Find the switch case statement at line 352. Add the necessary code to make it similar to the code below and save it:</p>
<pre class="brush: php; first-line: 352; title: ; notranslate">switch ($action) {

case 'logout' :
	check_admin_referer('log-out');
	// Start Magento
	magento(); // Don't add this anymore if you're already using Mage Enabler
	Mage::getSingleton(&quot;customer/session&quot;)-&gt;logout();
	wp_logout();</pre>
<p>Now test your WordPress by accessing the homepage at http://localhost/wordpress/. It should display the &#8216;Welcome Guest&#8217; similar to the image below with a cookie named as &#8216;frontend&#8217; in your Firebug cookie tab. That is your Magento cookie.</p>
<div id="attachment_304" class="wp-caption aligncenter" style="width: 499px"><a href="http://mysillypointofview.files.wordpress.com/2010/04/test_wordpress_home.png"><img class="size-full wp-image-304 " title="A Test WordPress homepage showing the default welcome message for Magento" src="http://mysillypointofview.files.wordpress.com/2010/04/test_wordpress_home.png" alt="A Test WordPress homepage showing the default welcome message for Magento" width="489" height="516" /></a><p class="wp-caption-text">A Test WordPress homepage showing the default welcome message for Magento</p></div>
<p>Clicking the login for WordPress redirects us to the login form like the one below while still showing the &#8216;frontend&#8217; cookie. Since I have a customer with same credentials on both Magento (Customer) and WordPress (set as Subscriber), all I have to do is to use the username and password to login in the form below.</p>
<div id="attachment_306" class="wp-caption aligncenter" style="width: 496px"><a href="http://mysillypointofview.files.wordpress.com/2010/04/test_wordpress_login.png"><img class="size-full wp-image-306 " title="A Test WordPress login page with a generated Magento cookie" src="http://mysillypointofview.files.wordpress.com/2010/04/test_wordpress_login.png" alt="A Test WordPress login page with a generated Magento cookie" width="486" height="455" /></a><p class="wp-caption-text">A Test WordPress login page with a generated Magento cookie</p></div>
<p>At this point, your Magento session should be running with an active customer session. To check if it does, go back to your homepage by clicking the top header text or going to http://localhost/wordpress/. It should display now the welcome message with your customer&#8217;s name.</p>
<div id="attachment_308" class="wp-caption aligncenter" style="width: 496px"><a href="http://mysillypointofview.files.wordpress.com/2010/04/test_wordpress_with_active_customer.png"><img class="size-full wp-image-308 " title="A Test WordPress homepage showing the customer's name in the welcome message" src="http://mysillypointofview.files.wordpress.com/2010/04/test_wordpress_with_active_customer.png" alt="A Test WordPress homepage showing the customer's name in the welcome message" width="486" height="500" /></a><p class="wp-caption-text">A Test WordPress homepage showing the customer&#039;s name in the welcome message</p></div>
<p>I hope this article will help you get started in using Magento&#8217;s functionality within WordPress.</p>
]]></content:encoded>
			<wfw:commentRss>http://mysillypointofview.richardferaro.com/2010/04/08/how-to-use-magentos-session-within-wordpress/feed/</wfw:commentRss>
		<slash:comments>168</slash:comments>
		</item>
		<item>
		<title>How to run Magento (version 1.4.0.1) session into an external site?</title>
		<link>http://mysillypointofview.richardferaro.com/2010/03/25/how-to-run-magento-version-1-4-0-1-session-to-external-site/</link>
		<comments>http://mysillypointofview.richardferaro.com/2010/03/25/how-to-run-magento-version-1-4-0-1-session-to-external-site/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 14:20:00 +0000</pubDate>
		<dc:creator>Richard Feraro</dc:creator>
				<category><![CDATA[Feeling guru]]></category>
		<category><![CDATA[Techie Daw]]></category>
		<category><![CDATA[e-commerce]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://mysillypointofview.wordpress.com/?p=269</guid>
		<description><![CDATA[This post is an update for my blog entry on how to extend the Magento session to an external site but instead of using the version 1.2.1.2, I used the the latest stable version as of this writing which is version 1.4.0.1. The script below also implements the login() and logout() method the Magento way [...]]]></description>
			<content:encoded><![CDATA[<p>This post is an update for my blog entry on <a href="http://mysillypointofview.richardferaro.com/2009/04/13/how-to-run-magento-session-to-an-external-site/">how to extend the Magento session to an external site</a> but instead of using the version 1.2.1.2, I used the the latest stable version as of this writing which is version 1.4.0.1. The script below also implements the <strong>login()</strong> and <strong>logout()</strong> method the Magento way as well as extracting the customer data (firstname and lastname) using <strong>getCustomer()</strong> method.</p>
<p><span id="more-269"></span>
<pre class="brush: php; title: ; notranslate">&lt;?php
// Include Magento application
require_once ( &quot;/var/www/your-magento-directory/app/Mage.php&quot; );
umask(0);

// Initialize Magento
Mage::app(&quot;default&quot;);

// You have two options here,
// &quot;frontend&quot; for frontend session or &quot;adminhtml&quot; for admin session
Mage::getSingleton(&quot;core/session&quot;, array(&quot;name&quot; =&gt; &quot;frontend&quot;));
$session = Mage::getSingleton(&quot;customer/session&quot;);

if(!isset($_REQUEST['action'])) {
	$_REQUEST['action'] = '';
}

switch($_REQUEST['action']){
	case &quot;login&quot;:
		try{
			// Do login request.
			// I know, there are ways to sanitize the form.
			// But for simplicity's sake, let's assume we already
			// did our homework regarding the matter.
			$login = $session-&gt;login($_POST['username'],$_POST['password']);
		}catch(Exception $e){
			// Do something for the error message
			$message = $e-&gt;getMessage();
		}

		header(&quot;location: index.php&quot;);

		break;
	case &quot;logout&quot;:
		// Execute the logout request
		$session-&gt;logout();
		header(&quot;location: index.php&quot;);

		break;
	default:
		// If the customer is not logged in, show login form
		// else, show logout link
		if(!$session-&gt;isLoggedIn()){
		?&gt;
			&lt;html&gt;
			&lt;head&gt;
			&lt;title&gt;External Page for Magento&lt;/title&gt;
			&lt;/head&gt;
			&lt;body&gt;
			&lt;h3&gt;Login here&lt;/h3&gt;
			&lt;form method=&quot;POST&quot; action=&quot;index.php&quot;&gt;
			Username &lt;input type=&quot;text&quot; name=&quot;username&quot; size=&quot;10&quot; /&gt;
			Password &lt;input type=&quot;password&quot; name=&quot;password&quot; size=&quot;10&quot; /&gt;
			&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;login&quot; /&gt;
			&lt;input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;login&quot; /&gt;
			&lt;/form&gt;
			&lt;/body&gt;
			&lt;/html&gt;
&lt;?php
		}else{
			$firstname = $session-&gt;getCustomer()-&gt;getData('firstname');
			$lastname = $session-&gt;getCustomer()-&gt;getData('lastname');
			echo &quot;Welcome &quot;.$firstname.&quot; &quot;.$lastname.&quot;!&lt;br&gt;&quot;;
			echo &quot;You're currently logged in &quot;;
			echo &quot;[ &lt;a href=\&quot;index.php?action=logout\&quot;&gt;click here to logout&lt;/a&gt; ]&quot;;
		}
}
?&gt;
</pre>
<p>Just copy the whole script and save it as <strong>index.php</strong> and run the script.</p>
]]></content:encoded>
			<wfw:commentRss>http://mysillypointofview.richardferaro.com/2010/03/25/how-to-run-magento-version-1-4-0-1-session-to-external-site/feed/</wfw:commentRss>
		<slash:comments>88</slash:comments>
		</item>
		<item>
		<title>How to Fix Magento&#8217;s Admin Login Failing (no error message) on Localhost</title>
		<link>http://mysillypointofview.richardferaro.com/2010/03/24/how-to-fix-magentos-admin-login-failing-no-error-message-on-localhost/</link>
		<comments>http://mysillypointofview.richardferaro.com/2010/03/24/how-to-fix-magentos-admin-login-failing-no-error-message-on-localhost/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 12:28:23 +0000</pubDate>
		<dc:creator>Richard Feraro</dc:creator>
				<category><![CDATA[Feeling guru]]></category>
		<category><![CDATA[Techie Daw]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://mysillypointofview.wordpress.com/?p=225</guid>
		<description><![CDATA[You want to install a new Magento instance (version 1.4.0.1 at the time of this writing) in your machine. You followed every steps from downloading up to the setting up of your admin account. Everything went fine so you assumed you&#8217;re good to go. You tried to login using your admin account&#8230; nothing happened. You [...]]]></description>
			<content:encoded><![CDATA[<p>You want to install a new Magento instance (version 1.4.0.1 at the time of this writing) in your machine. You followed every steps from downloading up to the setting up of your admin account. Everything went fine so you assumed you&#8217;re good to go. You tried to login using your admin account&#8230; nothing happened. You tried again&#8230; Same login screen with no error whatsoever. You wonder what went wrong. You checked the files and the database as well as clearing the cache. You even tried resetting your account&#8217;s password found in the Magento&#8217;s <em>admin_user</em> table using the MD5 function thru phpMyAdmin but to no avail. You gave up and tried to reinstall everything only to be greeted by the very same login screen after clicking the Login button.</p>
<p><span id="more-225"></span>The real problem lies when a Magento instance is running through a localhost and tries to create a cookie, but fails to do so because it requires a domain and localhost is not a true domain (thanks to <a href="http://www.blogger.com/profile/14751715706838377391">Mohammad Abdul Momin Arju</a> for pointing this out in his <a href="http://arjudba.blogspot.com/2009/04/after-installing-magento-cant-log-in-to.html">blog</a>). You can do a simple check to validate this by using Firefox and Firebug to check if a cookie is being generated by the Magento&#8217;s Admin Panel login page.</p>
<div id="attachment_245" class="wp-caption alignnone" style="width: 476px"><a href="http://mysillypointofview.files.wordpress.com/2010/03/magento-admin-login-no-cookie1.png"><img class="size-full wp-image-245    " title="magento-admin-login-no-cookie" src="http://mysillypointofview.files.wordpress.com/2010/03/magento-admin-login-no-cookie1.png" alt="Magento's Admin Panel Login without cookie being generated upon loading" width="466" height="284" /></a><p class="wp-caption-text">Magento&#039;s Admin Panel Login without a cookie being generated upon loading</p></div>
<p>At this point, we have to edit the core files without breaking the functionality behind this domain checking feature of Magento. <del datetime="2010-05-11T14:49:18+00:00">To do this, open the following file:</del></p>
<p>Copy the <strong>Varien.php</strong> core file which can be found below:</p>
<pre>app\code\core\Mage\Core\Model\Session\Abstract\Varien.php</pre>
<p>where we assumed that your root directory is <strong>htdocs</strong> and inside it is your <strong>magento</strong> folder.</p>
<p>Paste it in the Magento &#8216;local&#8217; folder which can be found below (create needed folders if it doesn&#8217;t exists) and open the file for editing:</p>
<pre>app\code\local\Mage\Core\Model\Session\Abstract\Varien.php</pre>
<p>Go to line 96 or locate the code similar below:</p>
<pre class="brush: php; first-line: 96; title: ; notranslate">if (isset($cookieParams['domain'])) {
    $cookieParams['domain'] = $cookie-&gt;getDomain();
}</pre>
<p>Replace the code found in line 96 with this one:</p>
<pre class="brush: php; first-line: 96; title: ; notranslate">if (isset($cookieParams['domain']) &amp;&amp; !in_array(&quot;127.0.0.1&quot;, self::getValidatorData())) {</pre>
<p><strong>For Apple machines or other operating system, try what Nirav did found in his <a href="#commententry-676">comment</a>.</strong></p>
<p>The purpose of this code change is to disable the Magento&#8217;s domain checking only if it is accessed via localhost and run as usual if it is being accessed thru a valid domain.</p>
<p>Clear your browser&#8217;s cookies to start with a clean slate then clear the Magento cache by deleting all the contents of the following folder:</p>
<pre>var\cache</pre>
<p>Access the Magento Admin Panel login again thru localhost while your firebug&#8217;s cookie tab being on (http://localhost:8080/magento/index.php/admin/). It should display something similar to the image below indicating that a cookie with an adminhtml name has been generated.</p>
<div id="attachment_254" class="wp-caption alignnone" style="width: 476px"><a href="http://mysillypointofview.files.wordpress.com/2010/03/magento-admin-login-with-cookie.png"><img class="size-full wp-image-254     " title="magento-admin-login-with-cookie" src="http://mysillypointofview.files.wordpress.com/2010/03/magento-admin-login-with-cookie.png" alt="Magento's Admin Panel Login with a cookie being generated upon loading" width="466" height="282" /></a><p class="wp-caption-text">Magento&#039;s Admin Panel Login showing a cookie &#039;adminhtml&#039; generated after loading</p></div>
<p>At this point you should be able to login now with your admin username and password using localhost as your domain.</p>
]]></content:encoded>
			<wfw:commentRss>http://mysillypointofview.richardferaro.com/2010/03/24/how-to-fix-magentos-admin-login-failing-no-error-message-on-localhost/feed/</wfw:commentRss>
		<slash:comments>265</slash:comments>
		</item>
	</channel>
</rss>

