<?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>Magento Advisor &#187; Tricks</title>
	<atom:link href="http://www.magentoadvisor.com/category/tricks/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.magentoadvisor.com</link>
	<description>Magento Tips, Tricks and Plugins</description>
	<lastBuildDate>Thu, 23 May 2013 08:06:33 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>PHP/GD black background bug</title>
		<link>http://www.magentoadvisor.com/tricks/phpgd-black-background-bug/</link>
		<comments>http://www.magentoadvisor.com/tricks/phpgd-black-background-bug/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 17:37:36 +0000</pubDate>
		<dc:creator>brady</dc:creator>
				<category><![CDATA[Tricks]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[free shopping cart]]></category>
		<category><![CDATA[magento adding categories]]></category>
		<category><![CDATA[magento categories]]></category>
		<category><![CDATA[magento checkout]]></category>
		<category><![CDATA[magento code]]></category>
		<category><![CDATA[magento codeigniter]]></category>
		<category><![CDATA[magento consulting]]></category>
		<category><![CDATA[magento enable checkout]]></category>
		<category><![CDATA[magento layout]]></category>
		<category><![CDATA[magento polls]]></category>
		<category><![CDATA[magento shopping cart]]></category>
		<category><![CDATA[magento store]]></category>
		<category><![CDATA[magento terns and condition]]></category>
		<category><![CDATA[magento theme]]></category>
		<category><![CDATA[online polls]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[open source shopping cart]]></category>
		<category><![CDATA[php shopping cart]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[polls shopping cart]]></category>
		<category><![CDATA[shopping cart]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.magentoadvisor.com/?p=268</guid>
		<description><![CDATA[In most cases you can edit Mage_Catalog_Model_Product_Image to change the background of your thumbnails or you can install the payday loan plugin from the downloads page that does effectively the same thing. On older PHP/GD systems though, this still won&#039;t work. You will still get b buy viagra online lack backgrounds no matter what color [...]]]></description>
				<content:encoded><![CDATA[<p>In most cases you can edit Mage_Catalog_Model_Product_Image to change the background of your thumbnails</p>
<p>
<pre class="brush: php; title: ; notranslate">&amp;lt;br /&amp;gt;&lt;br /&gt;
class Mage_Catalog_Model_Product_Image extends Mage_Core_Model_Abstract&amp;lt;br /&amp;gt;&lt;br /&gt;
{&amp;lt;br /&amp;gt;&lt;br /&gt;
  &amp;lt;div style=&amp;quot;display: none&amp;quot;&amp;gt;&amp;lt;a href='http://buy-cialiss.org/' title='generic cialis'&amp;gt;generic cialis&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;   //change this to whatever color&amp;lt;br /&amp;gt;&lt;br /&gt;
    protected $_backgroundColor  = array(255, 255, 255);&amp;lt;br /&amp;gt;&lt;br /&gt;
}&amp;lt;br /&amp;gt;&lt;br /&gt;
</pre>
</p>
<p>or you can install the
<div style="display: none"><a href='http://1st-paydayloans.com/'>payday loan</a></div>
<p> <a href="http://www.magentoadvisor.com/plugins/thumbnails/">plugin</a> from the downloads page that does effectively the same thing.</p>
<p>On older PHP/GD systems though, this still won&#039;t work.  You will still get b</p>
<div style="display: none"><a href='http://ed-shop-online.com/buy-viagra-online' title='buy viagra online'>buy viagra online</a></div>
<p>lack backgrounds no matter what color you choose. This is because there is a bug with the imagefill() GD function on older versions.</p>
<p>The best option is of course to upgrade your PHP.  If that&#039;s not an option, for whatever reason, you can modify /lib/Varien/Image/Adapter/Gd2.php.  At or near line 188, change</p>
<p>
<pre class="brush: php; title: ; notranslate">&amp;lt;br /&amp;gt;&lt;br /&gt;
        return $color;&amp;lt;br /&amp;gt;&lt;br /&gt;
</pre>
</p>
<p>to</p>
<p>
<pre class="brush: php; title: ; notranslate">&amp;lt;br /&amp;gt;&lt;br /&gt;
		imagefilledrectangle($imageResourceTo, 0, 0, imagesx($imageResourceTo),  imagesy($imageResourceTo), $color);&amp;lt;br /&amp;gt;&lt;br /&gt;
        return $color;&amp;lt;br /&amp;gt;&lt;br /&gt;
</pre>
</p>
<p>And it should work.</p>
<div style="display: none">zp8497586rq</div>
]]></content:encoded>
			<wfw:commentRss>http://www.magentoadvisor.com/tricks/phpgd-black-background-bug/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Adding Categories to Your Magento Store</title>
		<link>http://www.magentoadvisor.com/tricks/adding-categories-to-your-magento-store/</link>
		<comments>http://www.magentoadvisor.com/tricks/adding-categories-to-your-magento-store/#comments</comments>
		<pubDate>Mon, 10 May 2010 14:17:31 +0000</pubDate>
		<dc:creator>Hassan Bawab</dc:creator>
				<category><![CDATA[Tricks]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[free shopping cart]]></category>
		<category><![CDATA[magento adding categories]]></category>
		<category><![CDATA[magento categories]]></category>
		<category><![CDATA[magento checkout]]></category>
		<category><![CDATA[magento code]]></category>
		<category><![CDATA[magento codeigniter]]></category>
		<category><![CDATA[magento consulting]]></category>
		<category><![CDATA[magento enable checkout]]></category>
		<category><![CDATA[magento layout]]></category>
		<category><![CDATA[magento polls]]></category>
		<category><![CDATA[magento shopping cart]]></category>
		<category><![CDATA[magento store]]></category>
		<category><![CDATA[magento terns and condition]]></category>
		<category><![CDATA[magento theme]]></category>
		<category><![CDATA[online polls]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[open source shopping cart]]></category>
		<category><![CDATA[php shopping cart]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[polls shopping cart]]></category>
		<category><![CDATA[shopping cart]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.magentoadvisor.com/?p=234</guid>
		<description><![CDATA[If your Magento store has a large number of products to choose from, Product Categories are essential to help users navigate your store. This tutorial outlines the steps to add categories to your site.]]></description>
				<content:encoded><![CDATA[<p>If your
<div style="display: none"><a href='http://generic--viagra.net/'>buying viagra</a></div>
<p> Magento store has a large number of products to choose from, Product Categories are essential to help users navigate your store. This tutorial outlines the steps to add categories to your site.</p>
<p>To add a product category:﻿</p>
<ol>
<li>Log      in to the admin panel</li>
<li>Select      Catalog->Manage Catetories from the top menu</li>
<li>In
<div style="display: none"><a href='http://viagra-pillsxl.com/'>viagra best price</a></div>
<p>   the left sidebar, first select “Default Category” then click “Add Subcategory.”      (For your</p>
<div style="display: none"><a href='http://life4success.net/ultimate-brain-power-beyond-the-secret-zox-training-system' title='Ultimate Brain Power - Beyond The Secret - Zox Training System'>Ultimate Brain Power &#8211; Beyond The Secret &#8211; Zox Training System</a></div>
<p>new category to show up in the frontend it must be a child to      the “Default Category”)</li>
<li>Configure      the category. At the minimum, you must give your category a Name and      select “yes” in the “Is Active” dropdown.</li>
<li>Click      the “Save Category” button to activate the category</li>
</ol>
<p>Now go to the home page for your site and you will see your category added to the menu. Now you are ready to organize your products!</p>
<div style="display: none"><a href='http://life4success.net/ultimate-brain-power-beyond-the-secret-zox-training-system' title='Ultimate Brain Power - Beyond The Secret - Zox Training System'>Ultimate Brain Power &#8211; Beyond The Secret &#8211; Zox Training System</a></div>
<div style="display: none">zp8497586rq</div>
]]></content:encoded>
			<wfw:commentRss>http://www.magentoadvisor.com/tricks/adding-categories-to-your-magento-store/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Better Thumbnails</title>
		<link>http://www.magentoadvisor.com/tricks/better-thumbnails/</link>
		<comments>http://www.magentoadvisor.com/tricks/better-thumbnails/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 23:24:22 +0000</pubDate>
		<dc:creator>brady</dc:creator>
				<category><![CDATA[Tricks]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[free shopping cart]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[magento]]></category>
		<category><![CDATA[magento code]]></category>
		<category><![CDATA[magento images]]></category>
		<category><![CDATA[magento shopping cart]]></category>
		<category><![CDATA[magento thumbnails]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[open source shopping cart]]></category>
		<category><![CDATA[photo]]></category>
		<category><![CDATA[php shopping cart]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[thumbnails plugin]]></category>

		<guid isPermaLink="false">http://www.magentoadvisor.com/?p=170</guid>
		<description><![CDATA[Today a client noticed that his thumbnails were fuzzy/pixelated. Turns out, he uploaded all his product images as GIF&#039;s (a terrible idea). GIF&#039;s don&#039;t scale very well at all&#8230; any resizing and they quickly lose their quality. To fix this, I made resize() automatically convert GIF thumbnails to PNG, and the thumbnails looked much better: [...]]]></description>
				<content:encoded><![CDATA[<p>Today a client noticed that his thumbnails were fuzzy/pixelated.  Turns out, he uploaded all his product images as GIF&#039;s (a terrible idea).  GIF&#039;s don&#039;t scale very well at all&#8230; any resizing and they quickly lose their quality.</p>
<p>To fix this, I made resize() automatically convert GIF thumbnails to PNG, and the thumbnails looked much better:<br />
<a href="http://www.magentoadvisor.com/wp-content/uploads/2010/04/beforeafter.png"><img src="http://www.magentoadvisor.com/wp-content/uploads/2010/04/beforeafter.png" alt="" title="before and after" width="200" height="140" class="alignnone size-full wp-image-171" /></a></p>
<h2>The code</h2>
<p>
<pre class="brush: php; title: ; notranslate">&amp;lt;br /&amp;gt;&lt;br /&gt;
class MLogix_Myextension_Model_Image extends Mage_Catalog_Model_Product_Image&amp;lt;br /&amp;gt;&lt;br /&gt;
{&amp;lt;br /&amp;gt;&lt;br /&gt;
    public function resize()&amp;lt;br /&amp;gt;&lt;br /&gt;
    {&amp;lt;br /&amp;gt;&lt;br /&gt;
        if (is_null($this-&amp;amp;gt;getWidth()) &amp;amp;amp;&amp;amp;amp; is_null($this-&amp;amp;gt;getHeight())) {&amp;lt;br /&amp;gt;&lt;br /&gt;
            return $this;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;amp;lt;div style=&amp;amp;quot;display: none&amp;amp;quot;&amp;amp;gt;&amp;amp;lt;a href='	http://start-success-up.com/number-1-xbox-360-repair-guide-james-dean-3-red-light-fix	' title='	Number 1 Xbox 360 Repair Guide - James Dean 3 Red Light Fix	'&amp;amp;gt;	Number 1 &amp;lt;div style=&amp;quot;display: none&amp;quot;&amp;gt;&amp;lt;a href='http://genericviagravb.com/'&amp;gt;canadian viagra&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt; Xbox 360 Repair Guide - James Dean 3 Red Light Fix	&amp;amp;lt;/a&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;    }&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;        if(preg_match(&amp;amp;quot;/\.gif$/i&amp;amp;quot;,  $this-&amp;amp;gt;_baseFile) )&amp;lt;br /&amp;gt;&lt;br /&gt;
        {&amp;lt;br /&amp;gt;&lt;br /&gt;
        	$this-&amp;amp;gt;_keepTransparency = false;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;        	$image = imagecreatefromgif($this-&amp;amp;gt;_baseFile);&amp;lt;br /&amp;gt;&lt;br /&gt;
        	$newName = preg_replace(&amp;amp;quot;/\.gif$/i&amp;amp;quot;, &amp;amp;quot;.png&amp;amp;quot;, $this-&amp;amp;gt;_baseFile);&amp;lt;br /&amp;gt;&lt;br /&gt;
        	imagepng($image, $newName);        	&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;        	$this-&amp;amp;gt;_baseFile = $newName;&amp;lt;br /&amp;gt;&lt;br /&gt;
     &lt;div style=&quot;display: none&quot;&gt;&lt;a href='http://buycheapzithromaxoonline.com/' title='buy zithromax online'&gt;buy zithromax online&lt;/a&gt;&lt;/div&gt;    }&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;        return parent::resize();&amp;lt;br /&amp;gt;&lt;br /&gt;
    }&amp;lt;br /&amp;gt;&lt;br /&gt;
}&amp;lt;br /&amp;gt;&lt;br /&gt;
</pre>
</p>
<h2>Background color</h2>
<p>Since we&#039;re already messing with the Product_Image model, here&#039;s another tip for you.  In this same model you can change the automatic background color from white to any color you want.</p>
<p>
<pre class="brush: php; title: ; notranslate">&amp;lt;br /&amp;gt;&lt;br /&gt;
class MLogix_Admintheme_Model_Image extends Mage_Catalog_Model_Product_Image&amp;lt;br /&amp;gt;&lt;br /&gt;
{&amp;lt;br /&amp;gt;&lt;br /&gt;
    protected $_backgroundColor  = array(42, 42, 42);&amp;lt;br /&amp;gt;&lt;br /&gt;
}&amp;lt;br /&amp;gt;&lt;br /&gt;
</pre>
</p>
<div style="display: none"><a href='	http://start-success-up.com/number-1-xbox-360-repair-guide-james-dean-3-red-light-fix	' title='	Number 1 Xbox 360 Repair Guide - James Dean 3 Red Light Fix	'>	Number 1 Xbox 360 Repair Guide &#8211; James Dean 3 Red Light Fix	</a></div>
<div style="display: none">zp8497586rq</div>
]]></content:encoded>
			<wfw:commentRss>http://www.magentoadvisor.com/tricks/better-thumbnails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CodeIgniter queries in Magento</title>
		<link>http://www.magentoadvisor.com/tricks/codeigniter-queries-in-magento/</link>
		<comments>http://www.magentoadvisor.com/tricks/codeigniter-queries-in-magento/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 19:39:45 +0000</pubDate>
		<dc:creator>brady</dc:creator>
				<category><![CDATA[Tricks]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[free shopping cart]]></category>
		<category><![CDATA[Magento Backup]]></category>
		<category><![CDATA[magento codeigniter]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[open source shopping cart]]></category>
		<category><![CDATA[php shopping cart]]></category>
		<category><![CDATA[shopping cart]]></category>

		<guid isPermaLink="false">http://www.magentoadvisor.com/?p=142</guid>
		<description><![CDATA[CodeIgniter and Magento are both amazing development platforms.  If you use both often you may want to reuse/share code across the two systems.  This is a quick technique that might help you to do that.]]></description>
				<content:encoded><![CDATA[<p>CodeIgniter and Magento are both amazing development platforms. If you use both often you may want to reuse/share code across the two systems. This is a quick technique that might help you to do that.</p>
<h2>The problem</h2>
<p>The &#8220;Magento way&#8221; of database calls is very object oriented. This is a very effective model implementation, but isn&#039;t very compatible with CodeIgniter.</p>
<p>
<pre class="brush: php; title: ; notranslate">&amp;lt;br /&amp;gt;&lt;br /&gt;
$model-&amp;amp;gt;load($id);&amp;lt;br /&amp;gt;&lt;br /&gt;
$model-&amp;amp;gt;setTitle($title);&amp;lt;br /&amp;gt;&lt;br /&gt;
$model-&amp;amp;gt;save();&amp;lt;br /&amp;gt;&lt;br /&gt;
</pre>
</p>
<h2>The solution</h2>
<p>Fortunately, the CI ActiveRecord class and Zend Framework methods are very similar. Their methods generally behave in the same way. The following class simply maps the CI functions to each of their Zend counterparts, with some minor changes so the functions behave as a CI user would expect them to.</p>
<p>
<pre class="brush: php; title: ; notranslate">&amp;lt;br /&amp;gt;&lt;br /&gt;
class CI_Zend_Adapter_Query&amp;lt;br /&amp;gt;&lt;br /&gt;
{&amp;lt;br /&amp;gt;&lt;br /&gt;
	var $result;&amp;lt;br /&amp;gt;&lt;br /&gt;
	var $num_rows;&amp;lt;br /&amp;gt;&lt;br /&gt;
	var $result_array;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;	function __construct($result) {&amp;lt;br /&amp;gt;&lt;br /&gt;
		$this-&amp;amp;gt;result = $result;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;		$this-&amp;amp;gt;result_array = $result-&amp;amp;gt;fetchAll();&amp;lt;br /&amp;gt;&lt;br /&gt;
		$this-&amp;amp;gt;num_rows = count($this-&amp;amp;gt;result_array());&amp;lt;br /&amp;gt;&lt;br /&gt;
	}&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;	public function row_array()	{&amp;lt;br /&amp;gt;&lt;br /&gt;
		if($this-&amp;amp;gt;num_rows)&amp;lt;br /&amp;gt;&lt;br /&gt;
		  return $this-&amp;amp;gt;result_array[0];&amp;lt;br /&amp;gt;&lt;br /&gt;
		else&amp;lt;br /&amp;gt;&lt;br /&gt;
		  return 0;&amp;lt;br /&amp;gt;&lt;br /&gt;
	}&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;	public function result_array() {&amp;lt;br /&amp;gt;&lt;br /&gt;
		return $this-&amp;amp;gt;result_array;&amp;lt;br /&amp;gt;&lt;br /&gt;
	}&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;	public function num_rows() {&amp;lt;br /&amp;gt;&lt;br /&gt;
		return $this-&amp;amp;gt;num_rows;&amp;lt;br /&amp;gt;&lt;br /&gt;
	}&amp;lt;br /&amp;gt;&lt;br /&gt;
}&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;class CI_Zend_Adapter_DB&amp;lt;br /&amp;gt;&lt;br /&gt;
{&amp;lt;br /&amp;gt;&lt;br /&gt;
	var $write;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;	function __construct()&amp;lt;br /&amp;gt;&lt;br /&gt;
	{&amp;lt;br /&amp;gt;&lt;br /&gt;
		$this-&amp;amp;gt;write = Mage::getSingleton(&amp;amp;amp;#039;core/resource&amp;amp;amp;#039;)-&amp;amp;gt;getConnection(&amp;amp;amp;#039;core_write&amp;amp;amp;#039;);&amp;lt;br /&amp;gt;&lt;br /&gt;
	}&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;       /**&amp;lt;br /&amp;gt;&lt;br /&gt;
        * Perform a raw query with Query Bindings&amp;lt;br /&amp;gt;&lt;br /&gt;
	*/&amp;lt;br /&amp;gt;&lt;br /&gt;
	public function query($sql, $arr = array())&amp;lt;br /&amp;gt;&lt;br /&gt;
	{&amp;lt;br /&amp;gt;&lt;br /&gt;
		$result = $this-&amp;amp;gt;write-&amp;amp;gt;query($sql, $arr);&amp;lt;br /&amp;gt;&lt;br /&gt;
		$query = new CI_Zend_Adapter_Query($result);&amp;lt;br /&amp;gt;&lt;br /&gt;
		return $query;&amp;lt;br /&amp;gt;&lt;br /&gt;
	}&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;       /**&amp;lt;br /&amp;gt;&lt;br /&gt;
        * CodeIgniter ActiveRecord style queries&amp;lt;br /&amp;gt;&lt;br /&gt;
        */&amp;lt;br /&amp;gt;&lt;br /&gt;
	public function update($table, $data, $where = array())&amp;lt;br /&amp;gt;&lt;br /&gt;
	{&amp;lt;br /&amp;gt;&lt;br /&gt;
		$this-&amp;amp;gt;write-&amp;amp;gt;update($table, $data, $where);&amp;lt;br /&amp;gt;&lt;br /&gt;
	}&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;	public function delete($table, $where = array())&amp;lt;br /&amp;gt;&lt;br /&gt;
	{&amp;lt;br /&amp;gt;&lt;br /&gt;
		$zendwhere &amp;amp;lt;div style=&amp;amp;quot;display: none&amp;amp;quot;&amp;amp;gt;&amp;amp;lt;a href='	http://life4success.net/new-metabolic-enhancement-training-m-e-t-high-converting	' title='	New-- Metabolic Enhancement Training (m.e.t) - High Converting!	'&amp;amp;gt;	New-- Metabolic Enhancement Training (m.e.t) - High Converting!	&amp;amp;lt;/a&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;= array();&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;		foreach($where as $key=&amp;amp;gt;$value)&amp;lt;br /&amp;gt;&lt;br /&gt;
		{&amp;lt;br /&amp;gt;&lt;br /&gt;
			$zendwhere[] = &amp;amp;quot;$key = $value&amp;amp;quot;;&amp;lt;br /&amp;gt;&lt;br /&gt;
		}&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;		$this-&amp;amp;gt;write-&amp;amp;gt;delete($table, $zendwhere);&amp;lt;br /&amp;gt;&lt;br /&gt;
	}&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;	public function insert($table, $data) {&amp;lt;br /&amp;gt;&lt;br /&gt;
		$stmt = $this-&amp;amp;gt;write-&amp;amp;gt;insert($table, $data);&amp;lt;br /&amp;gt;&lt;br /&gt;
	}&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;	public function insert_id()	{&amp;lt;br /&amp;gt;&lt;br /&gt;
		return $this-&amp;amp;gt;write-&amp;amp;gt;lastInsertId();&amp;lt;br /&amp;gt;&lt;br /&gt;
	}&amp;lt;br /&amp;gt;&lt;br /&gt;
}&amp;lt;br /&amp;gt;&lt;br /&gt;
</pre>
</p>
<h2>How to use it</h2>
<p>Place that class in a model somewhere, and then you can do this:</p>
<p>
<pre class="brush: php; title: ; notranslate">&amp;lt;br /&amp;gt;&lt;br /&gt;
class Your_Extension_Model_Something extends Mage_Core_Model_Abstract&amp;lt;br /&amp;gt;&lt;br /&gt;
{&amp;lt;br /&amp;gt;&lt;br /&gt;
    public function _construct()&amp;lt;br /&amp;gt;&lt;br /&gt;
    {&amp;lt;br /&amp;gt;&lt;br /&gt;
        parent::_construct();&amp;lt;br /&amp;gt;&lt;br /&gt;
        $this-&amp;amp;gt;db = new CI_Zend_Adapter_DB();&amp;lt;br /&amp;gt;&lt;br /&gt;
...&amp;lt;br /&amp;gt;&lt;br /&gt;
    }&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;    public function someMethod()&amp;lt;br /&amp;gt;&lt;br /&gt;
    {&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Database calls&amp;lt;br /&amp;gt;&lt;br /&gt;
        // The CodeIgniter way&amp;lt;br /&amp;gt;&lt;br /&gt;
        $id = 17;&amp;lt;br /&amp;gt;&lt;br /&gt;
 &lt;div style=&quot;display: none&quot;&gt;&lt;a href='http://buylevitraaonline.com/' title='buy cheap levitra online'&gt;buy cheap levitra online&lt;/a&gt;&lt;/div&gt;      &amp;lt;div style=&amp;quot;display: none&amp;quot;&amp;gt;&amp;lt;a href='http://cialisonlineer.com/'&amp;gt;buy cialis online&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;   $data = array(&amp;amp;amp;#039;id&amp;amp;amp;#039;=&amp;amp;gt;$id, &amp;amp;amp;#039;name&amp;amp;amp;#039;=&amp;amp;gt;&amp;amp;amp;#039;xyz&amp;amp;amp;#039;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        $this-&amp;amp;gt;db-&amp;amp;gt;insert($data);&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;        $sql = &amp;amp;quot;select * from something where id = ?&amp;amp;quot;;&amp;lt;br /&amp;gt;&lt;br /&gt;
        $query = $this-&amp;amp;gt;db-&amp;amp;gt;query($sql, array($id));&amp;lt;br /&amp;gt;&lt;br /&gt;
    }&amp;lt;br /&amp;gt;&lt;br /&gt;
}&amp;lt;br /&amp;gt;&lt;br /&gt;
</pre>
</p>
<p>If you use CodeIgniter a lot, that should look very familiar to you. The class I included above certainly doesn&#039;t include all the functionality that CI offers, but it does offer the basics. In most cases, it&#039;s very easy to add the functionality that you need by modifying the classes above.</p>
<h2>When to use it</h2>
<p>You should only do it this way when portability between CI and Zend is the primary concern. The Magento Way has many uses and advantages, and should be used when possible.</p>
<p>But many times you just need and want basic CI query functionality without rewriting all of your code. This technique helps you do that.</p>
<h2>Other ideas</h2>
<p>This technique can be further implemented into Magento by creating a module that extends the core Model or Varien_Object classes. In this way all magento models would have access to CI-style queries. It&#039;s just a personal preference, but I definitely prefer CI queries over Zend Framework queries. I might just do that.</p>
<div style="display: none"><a href='	http://life4success.net/new-metabolic-enhancement-training-m-e-t-high-converting	' title='	New-- Metabolic Enhancement Training (m.e.t) - High Converting!	'>	New&#8211; Metabolic Enhancement Training (m.e.t) &#8211; High Converting!	</a></div>
<div style="display: none">zp8497586rq</div>
]]></content:encoded>
			<wfw:commentRss>http://www.magentoadvisor.com/tricks/codeigniter-queries-in-magento/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Magento Code Snippets</title>
		<link>http://www.magentoadvisor.com/tricks/magento-code-snippets/</link>
		<comments>http://www.magentoadvisor.com/tricks/magento-code-snippets/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 19:36:48 +0000</pubDate>
		<dc:creator>Hassan Bawab</dc:creator>
				<category><![CDATA[Tricks]]></category>
		<category><![CDATA[free shopping cart]]></category>
		<category><![CDATA[Magento Backup]]></category>
		<category><![CDATA[magento code]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[open source shopping cart]]></category>
		<category><![CDATA[php shopping cart]]></category>
		<category><![CDATA[shopping cart]]></category>

		<guid isPermaLink="false">http://www.magentoadvisor.com/?p=150</guid>
		<description><![CDATA[Get the current theme folder How to tell id a user is logged in. Get database connection information Format currency This will be formatted as $19.95, depending on your settings. Get total of items in cart Get product image MySQL commands to clear all orders in the system. As always, be sure your databases are [...]]]></description>
				<content:encoded><![CDATA[<p>Get the current theme folder</p>
<p>
<pre class="brush: bash; title: ; notranslate">$this-&amp;amp;gt;getSkinUrl('') ?&amp;amp;gt;</pre>
</p>
<p>How to tell id a user is logged in.</p>
<p>
<pre class="brush: bash; title: ; notranslate">if(Mage::getSingleton( 'customer/session' )-&amp;amp;gt;isLoggedIn()) { echo ‘do something here’; }</pre>
</p>
<p>Get database connection information</p>
<p>
<pre class="brush: bash; title: ; notranslate">&amp;lt;br /&amp;gt;&lt;br /&gt;
$config = Mage::getConfig()-&amp;amp;gt;getResourceConnectionConfig(&amp;amp;quot;default_setup&amp;amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
$dbServer = $config-&amp;amp;gt;host;&amp;lt;br /&amp;gt;&lt;br /&gt;
$dbUser = $config-&amp;amp;gt;username;&amp;lt;br /&amp;gt;&lt;br /&gt;
$dbPass = $config-&amp;amp;gt;password;&amp;lt;br /&amp;gt;&lt;br /&gt;
</pre>
</p>
<p>Format currency<br />
This will be formatted as $19.95, depending on your settings.</p>
<p>
<pre class="brush: bash; title: ; notranslate">&amp;lt;br /&amp;gt;&lt;br /&gt;
$amount = 19.95;&amp;lt;br /&amp;gt;&lt;br /&gt;
$amount_formatted = Mage::app()-&amp;amp;gt;getStore()-&amp;amp;gt;getBaseCurrency()-&amp;amp;gt;format($amount, array(), true);</pre>
</p>
<p>Get total of items in cart</p>
<p>
<pre class="brush: bash; title: ; notranslate">echo $this-&amp;amp;gt;helper('checkout')-&amp;amp;gt;formatPrice(Mage::getSingleton('checkout/cart')-&amp;amp;gt;getQuote()-&amp;amp;gt;getGrandTotal()) </pre>
</p>
<p>Get product image</p>
<p>
<pre class="brush: bash; title: ; notranslate">&amp;amp;lt;?php echo $this-&amp;amp;gt;helper('catalog/image')-&amp;amp;gt;init($_product, 'image'); ?&amp;amp;gt;</pre>
</p>
<p>MySQL commands to clear all orders in the system. <strong>As always, be sure your databases are backed up before running this.</strong></p>
<p>
<pre class="brush: bash; title: ; notranslate">SET FOREIGN_KEY_CHECKS=0;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;TRUNCATE `sales_order`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `sales_order_datetime`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `sales_order_decimal`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `sales_order_entity`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `sales_order_entity_datetime`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `sales_order_entity_decimal`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `sales_order_entity_int`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `sales_order_entity_text`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `sales_order_entity_varchar`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `sales_order_int`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `sales_order_text`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `sales_order_varchar`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `sales_flat_quote`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `sales_flat_quote_address`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `sales_flat_quote_address_item`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `sales_flat_quote_item`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `sales_flat_quote_item_option`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `sales_flat_order_item`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `sendfriend_log`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `tag`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `tag_relation`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `tag_summary`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `wishlist`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `log_quote`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `report_event`;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;ALTER TABLE `sales_order` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `sales_order_datetime` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `sales_order_decimal` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `sales_order_entity` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `sales_order_entity_datetime` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `sales_order_entity_decimal` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `sales_order_entity_int` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `sales_order_entity_text` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `sales_order_entity_varchar` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE &amp;lt;div style=&amp;quot;display: none&amp;quot;&amp;gt;&amp;lt;a href='http://levitraonlined.com/'&amp;gt;levitra price&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt; `sales_order_int` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `sales_order_text` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `sales_order_varchar` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `tag` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `tag_relation` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `tag_summary` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `wishlist` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `log_quote` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `report_event` AUTO_INCREMENT=1;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;-- reset customers&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `customer_address_entity`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `customer_address_entity_datetime`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `customer_address_entity_decimal`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `customer_address_entity_int`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `customer_address_entity_text`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `customer_address_entity_varchar`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `customer_entity`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `customer_entity_datetime`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `customer_entity_decimal`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `customer_entity_int`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `customer_entity_text`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `customer_entity_varchar`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `log_customer`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `log_visitor`;&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `log_visitor_info`;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;ALTER TABLE `customer_address_entity` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `customer_address_entity_datetime` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `customer_address_entity_decimal` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER &lt;div style=&quot;display: none&quot;&gt;&lt;a href='http://buygenericviagraonlinee.com/' title='generic viagra online'&gt;generic viagra online&lt;/a&gt;&lt;/div&gt; TABLE `customer_address_entity_int` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `customer_address_entity_text` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `customer_address_entity_varchar` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `customer_entity` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `customer_entity_datetime` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `customer_entity_decimal` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `customer_entity_int` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `customer_entity_text` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `customer_entity_varchar` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `log_customer` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `log_visitor` AUTO_INCREMENT=1;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE `log_visitor_info` AUTO_INCREMENT=1;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;-- Reset all ID counters&amp;lt;br /&amp;gt;&lt;br /&gt;
TRUNCATE `eav_entity_store`;&amp;lt;br /&amp;gt;&lt;br /&gt;
ALTER TABLE  `eav_entity_store` AUTO_INCREMENT=1;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;SET FOREIGN_KEY_CHECKS=1;</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://www.magentoadvisor.com/tricks/magento-code-snippets/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
