<?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; open source</title>
	<atom:link href="http://mysillypointofview.richardferaro.com/tag/open-source/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 &#8216;The plugin does not have a valid header&#8217; error when activating a WordPress plugin</title>
		<link>http://mysillypointofview.richardferaro.com/2010/05/27/fix-the-plugin-does-not-have-a-valid-header-error/</link>
		<comments>http://mysillypointofview.richardferaro.com/2010/05/27/fix-the-plugin-does-not-have-a-valid-header-error/#comments</comments>
		<pubDate>Wed, 26 May 2010 16:03:27 +0000</pubDate>
		<dc:creator>Richard Feraro</dc:creator>
				<category><![CDATA[Feeling guru]]></category>
		<category><![CDATA[open source]]></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=420</guid>
		<description><![CDATA[You want to extend WordPress&#8217; functionality and decided to download some plugins found in the Official WordPress Plugin repository. After searching the repo, you&#8217;ve found two plugins that accomplishes the tasks you needed to implement in your blog. Downloading the plugins gives you two ZIP files that when double-clicked, shows you the contents in the [...]]]></description>
			<content:encoded><![CDATA[<p>You want to extend WordPress&#8217; functionality and decided to download some plugins found in the <a href="http://wordpress.org/extend/plugins/">Official WordPress Plugin</a> repository. After searching the repo, you&#8217;ve found two plugins that accomplishes the tasks you needed to implement in your blog. Downloading the plugins gives you two ZIP files that when double-clicked, shows you the contents in the following format:</p>
<blockquote><p><strong>plugin-a.zip</strong></p>
<pre style="white-space: pre">plugin-a-folder
---- plugin-a-main-file.php
---- plugin-a-readme.txt</pre>
</blockquote>
<p></p>
<blockquote><p>
<strong>plugin-b.zip</strong></p>
<pre style="white-space: pre">plugin-b-folder
---- plugin-b-subfolder
-------- plugin-b-main-file.php
-------- plugin-b-readme.txt</pre>
</blockquote>
<p></p>
<p><span id="more-420"></span>There are two ways to install a plugin. <strong>Option 1</strong> is to unzip the file and upload the contents to <code>wordpress_root/wp-content/plugins/</code> directory. <strong>Option 2</strong> is to use the <code>Add New -&gt; Upload</code> option found in the left panel bar of the administrative page of WordPress. Let&#8217;s assume the two plugins went through the two installation options.</p>
<h4>Installing &#8216;plugin-a.zip&#8217; using Option 1</h4>
<ol>
<li>Unzip the file</li>
<li>Upload the contents to <code>wordpress_root/wp-content/plugins/</code></li>
<li>Login as admin and go to <code>Plugins -&gt; Installed</code>.</li>
<li>Locate plugin and click <span style="text-decoration:underline;">Activate</span> link.</li>
<li><strong>Result:</strong>
<div style="display:inline;border:1px solid #E6DB55;background:#FFFFE0;-moz-border-radius:3px 3px 3px 3px;padding:3px 10px;">Plugin <strong>activated.</strong></div>
</li>
</ol>
<h4>Installing &#8216;plugin-a.zip&#8217; using Option 2</h4>
<ol>
<li>Login as admin and go to <code>Plugins -&gt; Add New -&gt; Upload</code></li>
<li>Locate the file <code>plugin-a.zip</code> by clicking the <em>Browse</em> button.</li>
<li>Click <em>Install Now</em> button.</li>
<li><strong>Result:</strong><br />
	Unpacking the package?<br />
Installing the plugin?<br />
Plugin installed successfully.
	</li>
<li>Click <span style="text-decoration:underline;">Activate Plugin</span> link.</li>
<li><strong>Result:</strong>
<div style="display:inline;border:1px solid #E6DB55;background:#FFFFE0;-moz-border-radius:3px 3px 3px 3px;padding:3px 10px;">Plugin <strong>activated.</strong></div>
</ol>
<h4>Installing &#8216;plugin-b.zip&#8217; using Option 1</h4>
<ol>
<li>Unzip the file</li>
<li>Upload the contents to <code>wordpress_root/wp-content/plugins/</code></li>
<li>Login as admin and go to <code>Plugins -&gt; Installed</code>.</li>
<li>Locate plugin and click <span style="text-decoration:underline;">Activate</span> link.</li>
<li><span style="color:#FF0000;"><strong>Error:</strong> Plugin does not exists in the list.</span></li>
</ol>
<h4>Installing &#8216;plugin-b.zip&#8217; using Option 2</h4>
<ol>
<li>Login as admin and go to <code>Plugins -&gt; Add New -&gt; Upload</code></li>
<li>Locate the file <code>plugin-b.zip</code> by clicking the <em>Browse</em> button.</li>
<li>Click <em>Install Now</em> button.</li>
<li><strong>Result:</strong><br />
	Unpacking the package?<br />
Installing the plugin?<br />
Plugin installed successfully.
	</li>
<li>Click <span style="text-decoration:underline;">Activate Plugin</span> link.</li>
<li><span style="color:#FF0000;"><strong>WordPress ? Error</strong></span>
<div style="color:#333333;display:block;border:1px solid #DFDFDF;background:#FFFFFF;-moz-border-radius:11px 11px 11px 11px;font-family:'Lucida Grande',Verdana,Arial,'Bitstream Vera Sans',sans-serif;padding:1em 2em;">The plugin does not have a valid header.</div>
</ol>
<p>Based on our testing, <code>plugin-b.zip</code> seems to fail on both methods of installation. To find out what is causing the error, we have to understand how the plugin installation works. Upon checking the core files I found this excerpt in <strong>get_plugins()</strong> function:</p>
<blockquote><p>* WordPress only supports plugin files in the base plugins directory<br />
 * (wp-content/plugins) and in one directory above the plugins directory<br />
 * (wp-content/plugins/my-plugin). The file it looks for has the plugin data and<br />
 * must be found in those two locations. It is recommended that do keep your<br />
 * plugin files in directories.</p></blockquote>
<p>The plugin data that the function is looking for can be found below:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php
/*
Plugin Name: Name Of The Plugin
Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
Description: A brief description of the Plugin.
Version: The Plugin's Version Number, e.g.: 1.0
Author: Name Of The Plugin Author
Author URI: http://URI_Of_The_Plugin_Author
License: A &quot;Slug&quot; license name e.g. GPL2
*/
?&gt;</pre>
<p>So in order to properly install and activate a plugin, the following two conditions must be satisfied:</p>
<ul>
<li>that a plugin main file (.php) must be placed in <code>plugins</code> root folder or in <strong>first-level subdirectory within plugins folder</strong></li>
<li>and it should contain the necessary plugin data for identification/validation purposes</li>
</ul>
<p>In the case of <code>plugin-b.zip</code>, although the main PHP file contains the needed plugin data, the <strong>validate_plugin()</strong> function returned an error since neither the file can be found or check if it contains the plugin data because it is placed in the <strong>second level subdirectory</strong>, <span style="text-decoration:underline;">a directory location in which the function is not designed to scan the content.</span></p>
<p>To fix the <code>plugin-b.zip</code> file, it needs to have the following content structure:</p>
<blockquote><p><strong>plugin-b.zip</strong></p>
<pre style="white-space: pre">plugin-b-folder
---- plugin-b-main-file.php
---- plugin-b-readme.txt</pre>
</blockquote>
<p></p>
<p>I hope this post will enlighten WordPress users who wants to maximize their blog&#8217;s potential <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/2010/05/27/fix-the-plugin-does-not-have-a-valid-header-error/feed/</wfw:commentRss>
		<slash:comments>31</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>WordCamp Philippines on October 2010!</title>
		<link>http://mysillypointofview.richardferaro.com/2010/04/28/wordcamp-philippines-on-october-2010/</link>
		<comments>http://mysillypointofview.richardferaro.com/2010/04/28/wordcamp-philippines-on-october-2010/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 16:00:50 +0000</pubDate>
		<dc:creator>Richard Feraro</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[WordCamp]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://mysillypointofview.wordpress.com/?p=339</guid>
		<description><![CDATA[I&#8217;m sooo excited about this! For those who don&#8217;t know what WordCamp is, here is an excerpt from their site: WordCamp is a conference that focuses on everything WordPress. WordCamps are informal, community-organized events that are put together by WordPress users like you. Everyone from casual users to core developers participate, share ideas, and get [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m sooo excited about this! For those who don&#8217;t know what WordCamp is, here is an excerpt from their <a href="http://philippines.wordcamp.org/what-is-wordcamp/">site</a>:</p>
<blockquote><p>WordCamp is a conference that focuses on everything WordPress.</p>
<p>WordCamps are informal, community-organized events that are put together by WordPress users like you. Everyone from casual users to core developers participate, share ideas, and get to know each other.  WordCamps are open to WordPress.com and WordPress.org users alike.</p></blockquote>
<p>It is scheduled on October 2 this year and they haven&#8217;t publish any details yet, but what the heck! I&#8217;m still going! So fellow WordPress bloggers, hop on to our mothership!</p>
]]></content:encoded>
			<wfw:commentRss>http://mysillypointofview.richardferaro.com/2010/04/28/wordcamp-philippines-on-october-2010/feed/</wfw:commentRss>
		<slash:comments>3</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 add a product into Magento shopping cart from an external site?</title>
		<link>http://mysillypointofview.richardferaro.com/2009/04/27/how-to-add-a-product-into-magento-from-an-external-site/</link>
		<comments>http://mysillypointofview.richardferaro.com/2009/04/27/how-to-add-a-product-into-magento-from-an-external-site/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 06:28:17 +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[open source]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://mysillypointofview.wordpress.com/?p=128</guid>
		<description><![CDATA[Yes, I know. This topic has already been discussed here. But it seems the article isn&#8217;t really helpful for those people who would integrate Magento into a custom website because it will redirect the page to Magento&#8217;s default web store provided in the installation. The technique I&#8217;ll discuss here assumes that you know HTML and [...]]]></description>
			<content:encoded><![CDATA[<p>Yes, I know. This topic has already been discussed <a title="Adding a Product to the Cart via Querystring" href="http://www.magentocommerce.com/wiki/adding_a_product_to_the_cart_via_querystring" target="_blank">here</a>. But it seems the article isn&#8217;t really helpful for those people who would integrate Magento into a custom website because it will redirect the page to Magento&#8217;s default web store provided in the installation. The technique I&#8217;ll discuss here assumes that you know HTML and ofcourse familiar with Object Oriented Programming (OOP) in PHP.</p>
<p><span id="more-128"></span>Let&#8217;s start.</p>
<p>We begin our <strong>index.php</strong> page with a HTML form having one (1) textbox for quantity and a submit button.</p>
<pre class="brush: xml; title: ; notranslate">&lt;form action=&quot;process.php&quot;&gt;
Product name: T-shirt &lt;br&gt;
Quantity: &lt;input type=&quot;text&quot; name=&quot;qty[&lt;?=$productID?&gt;]&quot;&gt;
&lt;input type=&quot;submit&quot; value=&quot;Add to Cart&quot;&gt;
&lt;/form&gt;</pre>
<p>where <strong>$productID</strong> is the ID of the product that you want to add into your shopping cart and <strong>process.php</strong> is the file that will do the processing of the form. Also upon submission of the form, the qty field will pass the value into an array format similar to one below:</p>
<pre class="brush: xml; title: ; notranslate">&quot;qty&quot; = array(12345 =&gt; 1)</pre>
<p>where</p>
<blockquote><p><strong>qty</strong> is the field name<br />
<strong>12345</strong> is the product ID and<br />
<strong>1</strong> is the qty value</p></blockquote>
<p>This will be the content of <strong>process.php</strong> file:</p>
<p>Include the Mage.php file on top of the process.php. <a href="http://mysillypointofview.richardferaro.com/2009/04/13/how-to-run-magento-session-to-an-external-site/" target="_blank">Click here to see how.</a><br />
Then proceed with the php script below:</p>
<pre class="brush: php; title: ; notranslate">// continuation of process.php
$items = $_POST[&quot;qty&quot;];

// get the current Magento cart
$cart = Mage::getSingleton('checkout/cart');

foreach($items as $key =&gt; $value)
{
   // call the Magento catalog/product model
   $product = Mage::getModel('catalog/product')
                     // set the current store ID
                     -&gt;setStoreId(Mage::app()-&gt;getStore()-&gt;getId())
                     // load the product object
                     -&gt;load($key);

   // start adding the product
   $cart-&gt;addProduct($product, array('qty' =&gt; $value));
   // save the cart
   $cart-&gt;save();

   // very straightforward, set the cart as updated
   Mage::getSingleton('checkout/session')-&gt;setCartWasUpdated(true);
}

// redirect to index.php
header(&quot;Location: index.php&quot;);
</pre>
<p>That&#8217;s it! I didn&#8217;t add the end tag for php since <a href="http://framework.zend.com/manual/en/coding-standard.php-file-formatting.html#coding-standard.php-file-formatting.general" target="_blank">it isn&#8217;t required for pure php file</a>. I included alot of comments within the code to explain how each line works. If it causes you some problems, just remove the comments <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/2009/04/27/how-to-add-a-product-into-magento-from-an-external-site/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>How to delete a quote in Magento?</title>
		<link>http://mysillypointofview.richardferaro.com/2009/04/13/how-to-delete-a-quote-in-magento/</link>
		<comments>http://mysillypointofview.richardferaro.com/2009/04/13/how-to-delete-a-quote-in-magento/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 08:59:33 +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[open source]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://mysillypointofview.wordpress.com/?p=50</guid>
		<description><![CDATA[If you&#8217;re using an external site with Magento as a backend for e-commerce functionality, you will notice that the shopping cart items doesn&#8217;t get deleted after you checkout. Actually in Magento, a shopping cart is a quote. So to remove everything in the shopping cart, you must delete the quote currently used by the user. [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re using an external site with Magento as a backend for e-commerce functionality, you will notice that the shopping cart items doesn&#8217;t get deleted after you checkout. Actually in Magento, a shopping cart is a quote. So to remove everything in the shopping cart, you must delete the quote currently used by the user. To do this, follow the code below:</p>
<p><span id="more-50"></span>First, insert the Magento app snippets which can be found <a href="2009/04/13/how-to-run-magento-session-to-an-external-site/">here</a></p>
<p>then use the code below to delete a quote:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php
$quoteID = Mage::getSingleton(&quot;checkout/session&quot;)-&gt;getQuote()-&gt;getId();

if($quoteID)
{
    try {
        $quote = Mage::getModel(&quot;sales/quote&quot;)-&gt;load($quoteID);
        $quote-&gt;setIsActive(false);
        $quote-&gt;delete();

        return &quot;cart deleted&quot;;
    } catch(Exception $e) {
        return $e-&gt;getMessage();
    }
}else{
    return &quot;no quote found&quot;;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://mysillypointofview.richardferaro.com/2009/04/13/how-to-delete-a-quote-in-magento/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>How to run Magento session into an external site?</title>
		<link>http://mysillypointofview.richardferaro.com/2009/04/13/how-to-run-magento-session-to-an-external-site/</link>
		<comments>http://mysillypointofview.richardferaro.com/2009/04/13/how-to-run-magento-session-to-an-external-site/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 08:02:27 +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[open source]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://mysillypointofview.wordpress.com/?p=52</guid>
		<description><![CDATA[Recently I received a programming task requiring to use Magento as backend system while implementing its e-commerce functionality to a website created using CodeIgniter framework. After reading a book related to the software mentioned, I found this piece of code that will enable me to use all Magento&#8217;s power into my custom website: That&#8217;s it! [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I received a programming task requiring to use Magento as backend system while implementing its e-commerce functionality to a website created using CodeIgniter framework. After reading a book related to the software mentioned, I found this piece of code that will enable me to use all Magento&#8217;s power into my custom website:</p>
<p><span id="more-52"></span></p>
<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;));</pre>
<p>That&#8217;s it! You can now use the internal classes and functions of Magento into your site. For example, the code below validates whether a customer is logged in or not by checking the Magento session:</p>
<pre class="brush: php; title: ; notranslate">$session = Mage::getSingleton(&quot;customer/session&quot;);

if($session-&gt;isLoggedIn())
{
    echo &quot;Logged in&quot;;
}else{
    echo &quot;Not logged in&quot;;
}</pre>
<p><strong>** Updated **</strong><br />
For users of Magento version 1.4.0.1, <a href="http://mysillypointofview.wordpress.com/2010/03/25/how-to-run-magento-version-1-4-0-1-session-to-external-site/">click here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mysillypointofview.richardferaro.com/2009/04/13/how-to-run-magento-session-to-an-external-site/feed/</wfw:commentRss>
		<slash:comments>59</slash:comments>
		</item>
	</channel>
</rss>

