<?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>Prattski &#124; Magento &#38; Web Development &#187; Magento</title>
	<atom:link href="http://prattski.com/category/magento/feed/" rel="self" type="application/rss+xml" />
	<link>http://prattski.com</link>
	<description></description>
	<lastBuildDate>Mon, 30 Jan 2012 21:40:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Magento: Database Updater Module</title>
		<link>http://prattski.com/2012/01/30/magento-database-updater-module/</link>
		<comments>http://prattski.com/2012/01/30/magento-database-updater-module/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 21:40:29 +0000</pubDate>
		<dc:creator>Josh Pratt</dc:creator>
				<category><![CDATA[Magento]]></category>

		<guid isPermaLink="false">http://prattski.com/?p=819</guid>
		<description><![CDATA[I am currently working on a project that has one Magento code base, but will be deployed to multiple instances on different servers, all having their own database. Because we&#8217;ll have one set of code and multiple databases, what happens &#8230; <a href="http://prattski.com/2012/01/30/magento-database-updater-module/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I am currently working on a project that has one Magento code base, but will be deployed to multiple instances on different servers, all having their own database.  Because we&#8217;ll have one set of code and multiple databases, what happens when we need to make a database change (system config change, adding a product attribute, etc.) to some or all of the websites?  I can tell you that having to go into the admin of 20+ Magento installs to make the change in each isn&#8217;t an option.</p>
<p>A better option that we have come up with is to create a module that allows us to do the updates.  If done well, it should allow us to have all the control we need when a database update is necessary.</p>
<p>Here are some of the ideas we are working on:</p>
<ul>
<li>A system config option that allows us to specify a website identifier code used for this module.</li>
<li>Additional methods added to our resource file which allow us to specify if we want an update to apply to all websites, only to specified websites, or to all excluding specified websites.</li>
<li>A mysql4-update template file with lots of documentation and examples of how to add/update some of the most common changes to make updates easier.</li>
</ul>
<p>I have no plans to release this module (I can&#8217;t imagine much of a need for it for the majority of Magento users), but I wanted to share our plans in case there&#8217;s someone out there in the same place as we found ourselves.</p>
]]></content:encoded>
			<wfw:commentRss>http://prattski.com/2012/01/30/magento-database-updater-module/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Magento Module:  Hide Empty Categories</title>
		<link>http://prattski.com/2011/10/06/magento-module-hide-empty-categories/</link>
		<comments>http://prattski.com/2011/10/06/magento-module-hide-empty-categories/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 20:58:41 +0000</pubDate>
		<dc:creator>Josh Pratt</dc:creator>
				<category><![CDATA[Magento]]></category>

		<guid isPermaLink="false">http://prattski.com/?p=809</guid>
		<description><![CDATA[There are a number of ways that you can hide empty categories: You can disable them manually, you can modify the template output to check the product count and if zero don&#8217;t display it, etc. Another way is to write &#8230; <a href="http://prattski.com/2011/10/06/magento-module-hide-empty-categories/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>There are a number of ways that you can hide empty categories:  You can disable them manually, you can modify the template output to check the product count and if zero don&#8217;t display it, etc.  Another way is to write a module and intercept the catalog collection output before it&#8217;s sent to the templates.</p>
<p>I could easily package this up and put it up on Magento Connect, but I&#8217;m more into trying to help people understand Magento modules, so below is a walkthrough of how to create a module that will provide this functionality.</p>
<p><em>Note:</em> Update &#8211; Fixed for Flat Categories too. This has only been tested on 1.6.x.</p>
<h2>Step 1</h2>
<p>Create the file &#8216;/app/etc/modules/Prattski_HideEmptyCategories.xml&#8217;. This file tells Magento that your module exists, if it&#8217;s enabled or not, and where to find it.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">/**</span>
<span style="color: #808080; font-style: italic;"> * Hide Empty Categories</span>
<span style="color: #808080; font-style: italic;"> *</span>
<span style="color: #808080; font-style: italic;"> * @category    Prattski</span>
<span style="color: #808080; font-style: italic;"> * @package     Prattski_HideEmptyCategories</span>
<span style="color: #808080; font-style: italic;"> * @copyright   Copyright (c) 2011 Prattski (http://prattski.com/)</span>
<span style="color: #808080; font-style: italic;"> * @author      Josh Pratt (Prattski)</span>
<span style="color: #808080; font-style: italic;"> */</span>
<span style="color: #808080; font-style: italic;">--&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;modules<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Prattski_HideEmptyCategories<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;active<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/active<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;codePool<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>local<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/codePool<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Prattski_HideEmptyCategories<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/modules<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h2>Step 2</h2>
<p>Now we create our module directory.  Create &#8216;/app/code/local/Prattski/HideEmptyCategories/&#8217;.  This is where our module will reside.  Inside that directory, create this file:  &#8216;etc/config.xml&#8217;.  This file does a number of things:  It tells Magento which version your module is, defines your model namespace and directory, and creates and event observer to observe every time a category collection is loaded.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">/**</span>
<span style="color: #808080; font-style: italic;"> * Hide Empty Categories</span>
<span style="color: #808080; font-style: italic;"> *</span>
<span style="color: #808080; font-style: italic;"> * @category    Prattski</span>
<span style="color: #808080; font-style: italic;"> * @package     Prattski_HideEmptyCategories</span>
<span style="color: #808080; font-style: italic;"> * @copyright   Copyright (c) 2011 Prattski (http://prattski.com/)</span>
<span style="color: #808080; font-style: italic;"> * @author      Josh Pratt (Prattski)</span>
<span style="color: #808080; font-style: italic;"> */</span>
<span style="color: #808080; font-style: italic;">--&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;modules<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Prattski_HideEmptyCategories<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.0.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Prattski_HideEmptyCategories<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/modules<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;global<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;models<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;hideemptycategories<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Prattski_HideEmptyCategories_Model<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/hideemptycategories<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;catalog_resource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rewrite<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;category_flat<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Prattski_HideEmptyCategories_Model_Catalog_Resource_Category_Flat<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/category_flat<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/rewrite<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/catalog_resource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/models<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/global<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;frontend<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;events<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;catalog_category_collection_load_after<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;observers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;hideemptycategories<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>singleton<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>hideemptycategories/observer<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;method<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>catalogCategoryCollectionLoadAfter<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/method<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/hideemptycategories<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/observers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/catalog_category_collection_load_after<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/events<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/frontend<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h2>Step 3</h2>
<p>Let&#8217;s create our observer model. As you can see in the file above, we are going to have the &#8216;catalogCategoryCollectionLoadAfter&#8217; method run in this file when it observes the &#8216;catalog_category_collection_load_after&#8217; event. Create this file: Model/Observer.php</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Hide Empty Categories
 *
 * @category    Prattski
 * @package     Prattski_HideEmptyCategories
 * @copyright   Copyright (c) 2011 Prattski (http://prattski.com/)
 * @author      Josh Pratt (Prattski)
 */</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Event Observer
 *
 * @category    Prattski
 * @package     Prattski_HideEmptyCategories
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> Prattski_HideEmptyCategories_Model_Observer <span style="color: #000000; font-weight: bold;">extends</span> Mage_Core_Model_Abstract
<span style="color: #009900;">&#123;</span>
    <span style="color: #009933; font-style: italic;">/**
     * Remove hidden caegories from the collection
     *
     * @param Varien_Event_Observer $observer
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> catalogCategoryCollectionLoadAfter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$observer</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_isApiRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$collection</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$observer</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getEvent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getCategoryCollection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_removeHiddenCollectionItems<span style="color: #009900;">&#40;</span><span style="color: #000088;">$collection</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Remove hidden items from a product or category collection
     * 
     * @param Mage_Eav_Model_Entity_Collection_Abstract|Mage_Core_Model_Mysql4_Collection_Abstract $collection
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> _removeHiddenCollectionItems<span style="color: #009900;">&#40;</span><span style="color: #000088;">$collection</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// Loop through each category or product</span>
        <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$collection</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// If it is a category</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getEntityTypeId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getProductCount</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$collection</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">removeItemByKey</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Return true if the reqest is made via the api
     *
     * @return boolean
     */</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _isApiRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">app</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getModuleName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #0000ff;">'api'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2>Step 4</h2>
<p>Magento has the ability to turn on Flat Categories to speed up the performance whenever categories are loaded.  The event that we are observing above does not work when Flat Categories are enabled.  So, thanks to <a href="http://netzarbeiter.com/">Vinai&#8217;s</a> help, we need to rewrite a method in a core file to make this work. Create this file: Model/Catalog/Resource/Category/Flat.php</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Hide Empty Categories
 *
 * @category    Prattski
 * @package     Prattski_HideEmptyCategories
 * @copyright   Copyright (c) 2011 Prattski (http://prattski.com/)
 * @author      Josh Pratt (Prattski)
 */</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Event Observer
 *
 * @category    Prattski
 * @package     Prattski_HideEmptyCategories
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> Prattski_HideEmptyCategories_Model_Catalog_Resource_Category_Flat
    <span style="color: #000000; font-weight: bold;">extends</span> Mage_Catalog_Model_Resource_Category_Flat
<span style="color: #009900;">&#123;</span>
    <span style="color: #009933; font-style: italic;">/**
     * Load nodes by parent id
     *
     * @param unknown_type $parentNode
     * @param integer $recursionLevel
     * @param integer $storeId
     * @return Mage_Catalog_Model_Resource_Category_Flat
     */</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _loadNodes<span style="color: #009900;">&#40;</span><span style="color: #000088;">$parentNode</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$recursionLevel</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$storeId</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$nodes</span> <span style="color: #339933;">=</span> parent<span style="color: #339933;">::</span>_loadNodes<span style="color: #009900;">&#40;</span><span style="color: #000088;">$parentNode</span><span style="color: #339933;">,</span> <span style="color: #000088;">$recursionLevel</span><span style="color: #339933;">,</span> <span style="color: #000088;">$storeId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$nodes</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$node</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getProductCount</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$nodes</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$nodes</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2>Step 5</h2>
<p>To recap all the files we have made:</p>
<ul>
<li>/app/etc/modules/Prattski_HideEmptyCategories.xml</li>
<li>/app/code/local/Prattski/HideEmptyCategories/etc/config.xml</li>
<li>/app/code/local/Prattski/HideEmptyCategories/Model/Observer.php</li>
<li>/app/code/local/Prattski/HideEmptyCategories/Model/Catalog/Resource/Category/Flat.php</li>
</ul>
<p>Test it out!  You&#8217;ll be able to see if Magento recognizes your module by going to System > Configuration > Advanced.  If you see the module in the list, Magento knows it&#8217;s there.  You&#8217;ll have to have some categories in your system, some with products in them, some without, to see if it&#8217;s working properly on the frontend.</p>
<p>I hope you enjoyed learning how to build this module.  If you find any issues or bugs, please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://prattski.com/2011/10/06/magento-module-hide-empty-categories/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Looking For Small/Medium Magento Module Jobs</title>
		<link>http://prattski.com/2011/10/05/looking-for-smallmedium-magento-module-jobs/</link>
		<comments>http://prattski.com/2011/10/05/looking-for-smallmedium-magento-module-jobs/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 01:49:20 +0000</pubDate>
		<dc:creator>Josh Pratt</dc:creator>
				<category><![CDATA[Magento]]></category>

		<guid isPermaLink="false">http://prattski.com/?p=803</guid>
		<description><![CDATA[I am coming back to the freelance market for a bit, and I am looking for small/medium Magento module jobs. If you or anyone you know needs any work done in this area, please let me know!]]></description>
			<content:encoded><![CDATA[<p>I am coming back to the freelance market for a bit, and I am looking for small/medium Magento module jobs.  If you or anyone you know needs any work done in this area, please <a href="http://prattski.com/magento-development/">let me know</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://prattski.com/2011/10/05/looking-for-smallmedium-magento-module-jobs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Magento: Modify Collection To Include Comma Separated Values From Another Table</title>
		<link>http://prattski.com/2011/09/22/magento-modify-collection-to-include-comma-separated-values-from-another-table/</link>
		<comments>http://prattski.com/2011/09/22/magento-modify-collection-to-include-comma-separated-values-from-another-table/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 19:52:19 +0000</pubDate>
		<dc:creator>Josh Pratt</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://prattski.com/?p=796</guid>
		<description><![CDATA[It was rather difficult to come up with a title for this post, so I&#8217;m not sure that it is completely accurate. But, I have been working on a module, and I needed to modify the catalog/product collection to add &#8230; <a href="http://prattski.com/2011/09/22/magento-modify-collection-to-include-comma-separated-values-from-another-table/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It was rather difficult to come up with a title for this post, so I&#8217;m not sure that it is completely accurate.  But, I have been working on a module, and I needed to modify the catalog/product collection to add a column that contains comma separated skus of the related products associated to each product.</p>
<p>First step is to get the product collection,</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$collection</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'catalog/product'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getCollection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now we need to modify the collection to add a new select column.  The mysql is also important here.  You&#8217;ll see that I&#8217;m using <a href="http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat">GROUP_CONCAT</a> and <a href="http://dev.mysql.com/doc/refman/5.0/en/distinct-optimization.html">DISTINCT</a>, and towards the bottom specifying to group by &#8216;e.entity_id&#8217;.  I&#8217;m not going to dive into why this is necessary or how it all works. You&#8217;ll be better off visiting the mysql documentation on those.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$collection</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'catalog/product'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getCollection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$collection</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getSelect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">-&gt;</span><span style="color: #004000;">columns</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'GROUP_CONCAT(DISTINCT (SELECT sku FROM catalog_product_entity WHERE entity_id = r.linked_product_id) SEPARATOR \', \') AS related_skus'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">-&gt;</span><span style="color: #004000;">joinLeft</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'r'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'catalog_product_link'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'r.product_id = e.entity_id AND r.link_type_id = 1'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">-&gt;</span><span style="color: #004000;">group</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'e.entity_id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The result of this is an additional field in the collection called &#8216;related_skus&#8217; that is a comma-space separated list of skus that are related products for each product in the collection.</p>
<p>If you want to log the actual query that is generated by this, simply add this line below the code above:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">Mage<span style="color: #339933;">::</span><span style="color: #990000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$collection</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getSelect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__toString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Hopefully this helps you in some way!</p>
]]></content:encoded>
			<wfw:commentRss>http://prattski.com/2011/09/22/magento-modify-collection-to-include-comma-separated-values-from-another-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magento: Adding/Updating Products with V2 API</title>
		<link>http://prattski.com/2011/09/08/magento-addingupdating-products-with-v2-api/</link>
		<comments>http://prattski.com/2011/09/08/magento-addingupdating-products-with-v2-api/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 15:25:54 +0000</pubDate>
		<dc:creator>Josh Pratt</dc:creator>
				<category><![CDATA[Magento]]></category>

		<guid isPermaLink="false">http://prattski.com/?p=789</guid>
		<description><![CDATA[Magento unfortunately has virtually no documentation on the V2 API. I needed to prove to someone today that using the V2 API, you can indeed create a product, assign it to 2 or more websites, and set the product price &#8230; <a href="http://prattski.com/2011/09/08/magento-addingupdating-products-with-v2-api/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Magento unfortunately has virtually no documentation on the V2 API.  I needed to prove to someone today that using the V2 API, you can indeed create a product, assign it to 2 or more websites, and set the product price to different values for each website (as long as you&#8217;ve set the price scope to &#8220;Website&#8221; instead of the default &#8220;Global&#8221; which is in System > Configuration > Catalog > Price).</p>
<p>In this example, I set the initial product data to create, and run the API method &#8216;catalogProductCreate&#8217;. After the product has been created, I then set the product price for the wholesale website, and then run the &#8216;catalogProductUpdate&#8217; method.  The key here is passing in the correct store view code.  Ultimately, the product is created with the price of $45.  Then the wholesale website is updated to set a price of $20.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//error_reporting(E_ALL);</span>
<span style="color: #666666; font-style: italic;">//ini_set('display_errors', '1');</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Get API Session
 */</span>
<span style="color: #000088;">$client</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SoapClient<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://core.local/api/v2_soap?wsdl=1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$session</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$client</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">login</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'augustash'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Set Product Data
 */</span>
<span style="color: #000088;">$newProductData</span>                     <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> stdClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$newProductData</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span>               <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Product Name'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$newProductData</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">description</span>        <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Description'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$newProductData</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">short_description</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Short Description'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$newProductData</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">websites</span>	    <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$newProductData</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">categories</span>         <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">7</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$newProductData</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">status</span>             <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$newProductData</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">price</span>              <span style="color: #339933;">=</span> <span style="color: #cc66cc;">45</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$newProductData</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tax_class_id</span>       <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$newProductData</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">weight</span>             <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Create Product Using V2 API
 */</span>
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$client</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">catalogProductCreate</span><span style="color: #009900;">&#40;</span>
    <span style="color: #000088;">$session</span><span style="color: #339933;">,</span>           <span style="color: #666666; font-style: italic;">// Soap Session</span>
    <span style="color: #0000ff;">'simple'</span><span style="color: #339933;">,</span>           <span style="color: #666666; font-style: italic;">// Product Type</span>
    <span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span>                  <span style="color: #666666; font-style: italic;">// Attribute Set Id (Default)</span>
    <span style="color: #0000ff;">'product-sku'</span><span style="color: #339933;">,</span>      <span style="color: #666666; font-style: italic;">// Product Sku</span>
    <span style="color: #000088;">$newProductData</span>     <span style="color: #666666; font-style: italic;">// Product Data</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Set Price for Wholesale Website
 */</span>
<span style="color: #000088;">$newProductData</span>         <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> stdClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$newProductData</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">price</span>  <span style="color: #339933;">=</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Update Product with Wholesale Price using V2 API
 */</span>
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$client</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">catalogProductUpdate</span><span style="color: #009900;">&#40;</span>
    <span style="color: #000088;">$session</span><span style="color: #339933;">,</span>           <span style="color: #666666; font-style: italic;">// Soap Session</span>
    <span style="color: #0000ff;">'product-sku'</span><span style="color: #339933;">,</span>      <span style="color: #666666; font-style: italic;">// Product Sku</span>
    <span style="color: #000088;">$newProductData</span><span style="color: #339933;">,</span>    <span style="color: #666666; font-style: italic;">// Product Data</span>
    <span style="color: #0000ff;">'wholesale'</span>         <span style="color: #666666; font-style: italic;">// Store View Code</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * End Session
 */</span>
<span style="color: #000088;">$client</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">endSession</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$session</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>If you are wondering where to look to find out what values you can pass in, and what parameters are needed when making V2 API calls, you&#8217;ll need to look at the wsdl.  In app/code/core/Mage/Catalog/etc/wsdl.xml, you&#8217;ll find the product API info.  I&#8217;ve extracted the product data fields that you can pass in when creating a product:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;complexType</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;catalogProductCreateEntity&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;all<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;categories&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;typens:ArrayOfString&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;websites&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;typens:ArrayOfString&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;name&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;description&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;short_description&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;weight&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;status&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;url_key&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;url_path&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;visibility&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;category_ids&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;typens:ArrayOfString&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;website_ids&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;typens:ArrayOfString&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;has_options&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;gift_message_available&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;price&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;special_price&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;special_from_date&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;special_to_date&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;tax_class_id&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;tier_price&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;typens:catalogProductTierPriceEntityArray&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;meta_title&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;meta_keyword&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;meta_description&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;custom_design&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;custom_layout_update&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;options_container&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;additional_attributes&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;typens:associativeArray&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/all<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/complexType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Here are the parameters that can be passed in when using the create and update methods:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;message</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;catalogProductCreateRequest&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;part</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;sessionId&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;part</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;type&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;part</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;set&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;part</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;sku&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;part</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;productData&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;typens:catalogProductCreateEntity&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/message<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;message</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;catalogProductUpdateRequest&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;part</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;sessionId&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;part</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;product&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;part</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;productData&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;typens:catalogProductCreateEntity&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;part</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;storeView&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;part</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;productIdentifierType&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xsd:string&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/message<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://prattski.com/2011/09/08/magento-addingupdating-products-with-v2-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magento: Bug With Editing Date &amp; Time, Time Custom Options</title>
		<link>http://prattski.com/2011/09/01/magento-bug-with-editing-date-time-time-custom-options/</link>
		<comments>http://prattski.com/2011/09/01/magento-bug-with-editing-date-time-time-custom-options/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 15:24:35 +0000</pubDate>
		<dc:creator>Josh Pratt</dc:creator>
				<category><![CDATA[Magento]]></category>

		<guid isPermaLink="false">http://prattski.com/?p=784</guid>
		<description><![CDATA[Using Magento 1.5.0.1, I noticed an interesting bug this afternoon. If you have setup any Date &#038; Time or Time custom attributes, and have made them NOT required, here&#8217;s something you may notice: When initially adding the product to the &#8230; <a href="http://prattski.com/2011/09/01/magento-bug-with-editing-date-time-time-custom-options/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Using Magento 1.5.0.1, I noticed an interesting bug this afternoon.  If you have setup any Date &#038; Time or Time custom attributes, and have made them NOT required, here&#8217;s something you may notice:</p>
<p>When initially adding the product to the cart, and you leave the Date &#038; Time or Time custom options NOT filled out, your product will be added to the cart just as you would expect.  The untouched custom options are not applied to the product in your cart.  However, in the rare case where a user is clicking the &#8220;Edit&#8221; link in the cart to edit it, and you still leave those custom options untouched, the validation will bark at you saying &#8220;Field is not complete&#8221; on those custom options.  The only way to edit that product then is to put values in for those fields.  Magento updates the product as it should, but you now have those other custom options in play, which could screw things up.</p>
<p>I have submitted the bug to Magento:  http://www.magentocommerce.com/bug-tracking/issue?issue=12183</p>
]]></content:encoded>
			<wfw:commentRss>http://prattski.com/2011/09/01/magento-bug-with-editing-date-time-time-custom-options/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disappointed with Magento Module Sales/Distribution</title>
		<link>http://prattski.com/2011/07/25/disappointed-with-magento-module-salesdistribution/</link>
		<comments>http://prattski.com/2011/07/25/disappointed-with-magento-module-salesdistribution/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 16:46:45 +0000</pubDate>
		<dc:creator>Josh Pratt</dc:creator>
				<category><![CDATA[Magento]]></category>

		<guid isPermaLink="false">http://prattski.com/?p=777</guid>
		<description><![CDATA[Magento, from the beginning, has offered a system of packaging extensions, and installing those packages. It was a smart move, and one that I really appreciated. There are a lot of developers out there who properly package their extensions (everything &#8230; <a href="http://prattski.com/2011/07/25/disappointed-with-magento-module-salesdistribution/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Magento, from the beginning, has offered a system of packaging extensions, and installing those packages.  It was a smart move, and one that I really appreciated.  There are a lot of developers out there who properly package their extensions (everything that you can get directly off Magento Connect is packaged).  However, there are still loads of developers who do not package their extensions.  This is especially true with developers who sell their extensions.</p>
<p>One particular developer that I&#8217;d like to point out my frustration with is <a href="http://www.aitoc.com/">AITOC</a>.  Before I get started though, they ARE talented developers, and they make good functioning modules.  However, I can&#8217;t stand their pricing and distributing philosophies.</p>
<p>Most of their modules are based off of how many enabled products you have in your catalog, how many stores/websites you have setup in Magento, or how many admin accounts you have setup.  Let&#8217;s say you want to use one of their modules for 50 of your products, but you have 10,000 products in your catalog.  Or, you want to use one of their modules for one of your websites, but you have 10 websites setup in Magento.  With both of these scenarios, prepare to spend big bucks.  You can easily go from a $99 module, to a $599 module.  I hate that.</p>
<p>Also, let&#8217;s say you have 950 products in your catalog, and you buy a module from them and you get the license that allows up to 1000 products.  When you hit 1001, the functionality of that module will disable itself.</p>
<p>Now to their distribution.  When you buy one of their modules, prepare for a headache!  They are loaded and bloated full of files.  It&#8217;s a mess.  You cannot install their module with a simple command line.  Instead, you need to upload a ton of files, set special permissions, and then walk through a somewhat complicated installation process.  There&#8217;s even a module in there just to install/manage the module you want to install, loading up your Magento install with over 100 additional files.  They override a few Core Magento files and send out a web service request, checking your license to make sure it&#8217;s valid before it will fully install your module.  Almost every single file in their module is wrapped in a PHP call that checks to make sure you have properly installed it, and that you are not exceeding the license rule (# of products, stores, admin accounts, etc.).</p>
<p>They make it a headache to install, a headache to maintain, and a nightmare to fully uninstall and remove all the files.  If they properly packaged their extension, it would be cakewalk to install, update, and uninstall.</p>
<p>Why do they do it?  It&#8217;s simple.  As for their pricing, they want to make more money off you.  They tease you with a price, but many people will not pay the base price for their modules.  Why do they not package their extension?  They want more control over you and your store, and more control ensuring people aren&#8217;t abusing their license (because of the dumb limitations they enforce) or re-using it over and over, or passing it along to other people to use.</p>
<p>They are smart in that regard, but when it become a total pain for the end-user, you should re-think the process.  I think they need to ditch the limitations.  And, when it comes to the modules, properly package them up so that they can be installed with one command or using Magneto Connect.  There are other ways of protecting a module from being re-used or re-distributed like <a href="http://www.ioncube.com/">IonCube</a> that are far less of a headache to deal with.</p>
<p>So, if you are a Magento developer distributing or selling modules, please, make them into a proper Magento extension.  It doesn&#8217;t take long, it&#8217;s not hard, and it works way, way better.  And, don&#8217;t put annoying limitations on them like AITOC does.</p>
]]></content:encoded>
			<wfw:commentRss>http://prattski.com/2011/07/25/disappointed-with-magento-module-salesdistribution/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>Magento: Revised Multiple Image Import Module (1.5 +)</title>
		<link>http://prattski.com/2011/07/15/magento-revised-multiple-image-import-module-1-5/</link>
		<comments>http://prattski.com/2011/07/15/magento-revised-multiple-image-import-module-1-5/#comments</comments>
		<pubDate>Fri, 15 Jul 2011 15:18:15 +0000</pubDate>
		<dc:creator>Josh Pratt</dc:creator>
				<category><![CDATA[Magento]]></category>

		<guid isPermaLink="false">http://prattski.com/?p=763</guid>
		<description><![CDATA[Back in 2009, I made this post about my first multiple image import module. It was quite popular, and worked all the way up through Magento 1.4.x. With the release of 1.5, it no longer worked due to core changes &#8230; <a href="http://prattski.com/2011/07/15/magento-revised-multiple-image-import-module-1-5/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Back in 2009, I made <a href="http://prattski.com/2009/10/09/magento-import-multiple-images-for-products-module/">this post</a> about my first multiple image import module.  It was quite popular, and worked all the way up through Magento 1.4.x.  With the release of 1.5, it no longer worked due to core changes Magento made.</p>
<p>We finally ran into a client who needed this functionality on 1.5, so I have re-factored the module, and added a couple new features.  Instead of just packaging up the module though, like last time, I will walk you through how to create it yourself (so that hopefully some of you will learn a little more about how to create modules).</p>
<p><em>Note:</em> This will not work on Magento 1.4.x and lower.  For a version that works on 1.4.x and lower (which is a little more basic too), please see <a href="http://prattski.com/2009/10/09/magento-import-multiple-images-for-products-module/">this post</a>.</p>
<p><strong>What does this module do?</strong></p>
<ul>
<li>Imports multiple images (of course) in addition to the 3 main product images (image, small_image, thumbnail)</li>
<li>Allows you to enable or disable (in the system config) excluding any main product images (image, small_image, thumbnail) from showing up in the gallery (the exclude checkbox)</li>
<li>Allows you to specify the column name for your multiple images in the system config</li>
</ul>
<p><strong>How it works:</strong> When you do a product import, all you have to do is add a new column to your CSV with the header of your choice (which you can change in the system config under Catalog > Catalog > Import Image Options &#8211; By default it&#8217;s &#8216;additional_images&#8217;).  In that column, you can have as many images as you&#8217;d like.  Simply separate the image names with a semi-colon: &#8216;image1.jpg;image2.jpg;image3.jpg&#8217;.  Just be sure you&#8217;ve put the images in /media/import/ like you would normally do.</p>
<p>Enough talk, let&#8217;s get to building the module.  In my example, I&#8217;m using the &#8216;Prattski&#8217; namespace for my module.  You can certainly change that if you would like, just make sure to change it in ever place you see it.</p>
<h2>Step 1</h2>
<p>Create the file &#8216;/app/etc/modules/Prattski_ImageImport.xml&#8217;. This file tells Magento that your module exists, if it&#8217;s enabled or not, and where to find it.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;modules<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Prattski_ImageImport<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;active<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/active<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;codePool<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>local<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/codePool<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Prattski_ImageImport<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/modules<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h2>Step 2</h2>
<p>Now we create our module directory.  Create &#8216;/app/code/local/Prattski/ImageImport/&#8217;.  This is where our module will reside.  Inside that directory, create this file:  &#8216;etc/config.xml&#8217;.  This file does a number of things:  It tells Magento which version your module is, defines your model namespace and directory, rewrites a core model with your own, defines your helper namespace and directory, and sets default values in the system config.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;modules<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Prattski_ImageImport<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0.1.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Prattski_ImageImport<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/modules<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;global<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;models<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;imageimport<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Prattski_ImageImport_Model<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/imageimport<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;catalog<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rewrite<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;convert_adapter_product<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Prattski_ImageImport_Model_Catalog_Convert_Adapter_Product<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/convert_adapter_product<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/rewrite<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/catalog<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/models<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;helpers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;imageimport<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Prattski_ImageImport_Helper<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/imageimport<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/helpers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/global<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;catalog<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;catalog<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image_exclude_enabled<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/image_exclude_enabled<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;multiple_image_column_name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>additional_images<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/multiple_image_column_name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/catalog<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/catalog<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h2>Step 3</h2>
<p>Let&#8217;s create our module&#8217;s helper.  This isn&#8217;t necessary, but always a good practice to include it, as it is required for locale stuff, and it&#8217;s a ready utility if ever needed.  In our case, we&#8217;ll just create a blank helper.  Create this file in your module directory &#8216;Helper/Data.php&#8217;:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Prattski Import Images Module
 *
 * @category    Prattski
 * @package     Prattski_ImageImport
 * @copyright   Copyright (c) 2011 Prattski (http://prattski.com)
 * @author      Prattski (Josh Pratt)
 */</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Helper
 *
 * @category    Prattski
 * @package     Prattski_ImageImport
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> Prattski_ImageImport_Helper_Data <span style="color: #000000; font-weight: bold;">extends</span> Mage_Core_Helper_Abstract
<span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2>Step 4</h2>
<p>Now we will create our system config.  This will give us the ability to turn on or off excluding the main product images, and specify the column in our CSV for the additional images.  Note:  In our config.xml file that we created, you&#8217;ll see the &#8216;default&#8217; tag near the bottom.  There we pre-populate our system config fields that we are creating here with data so that they aren&#8217;t blank upon module installation.  Create this file in your module directory: &#8216;etc/system.xml&#8217;:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sections<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;catalog<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groups<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;catalog<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Import Image Options<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;frontend_type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>text<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/frontend_type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sort_order<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>999<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sort_order<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;show_in_default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/show_in_default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;show_in_website<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/show_in_website<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;show_in_store<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/show_in_store<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fields<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image_exclude_enabled</span> <span style="color: #000066;">translate</span>=<span style="color: #ff0000;">&quot;label&quot;</span> <span style="color: #000066;">module</span>=<span style="color: #ff0000;">&quot;imageimport&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Enable Excluded Images<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;frontend_type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>select<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/frontend_type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;source_model<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>adminhtml/system_config_source_yesno<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/source_model<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sort_order<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>10<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sort_order<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;show_in_default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/show_in_default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;show_in_website<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/show_in_website<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;show_in_store<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/show_in_store<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>If the product image is a main product image (image, small_image, or thumbnail), automatically check the exlcude checkbox.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/image_exclude_enabled<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;multiple_image_column_name</span> <span style="color: #000066;">translate</span>=<span style="color: #ff0000;">&quot;label&quot;</span> <span style="color: #000066;">module</span>=<span style="color: #ff0000;">&quot;imageimport&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Multiple Image Column Name<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;frontend_type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>text<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/frontend_type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sort_order<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>20<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sort_order<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;show_in_default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/show_in_default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;show_in_website<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/show_in_website<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;show_in_store<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/show_in_store<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>The header in your CSV where you will put your additional images to import. When importing multiple images, separate with a semi-colon: 'image1.jpg;image2.jpg;image3.jpg'<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/multiple_image_column_name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fields<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/catalog<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groups<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/catalog<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sections<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h2>Step 5</h2>
<p>Finally, we&#8217;ll create the model that will rewrite the core module to add in our new functionality. You&#8217;ll see towards the bottom (at line 230) that I&#8217;ve added two code blocks.  The first block will exclude (or not) based on the system configuration setting we setup.  The second is what imports all the additional images.  Create this file in your module directory &#8216;Model/Catalog/Convert/Adapter/Product.php&#8217;:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Prattski Import Images Module
 *
 * @category    Prattski
 * @package     Prattski_ImageImport
 * @copyright   Copyright (c) 2011 Prattski (http://prattski.com)
 * @author      Prattski (Josh Pratt)
 */</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Product Import Adapter
 *
 * @category    Prattski
 * @package     Prattski_ImageImport
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> Prattski_ImageImport_Model_Catalog_Convert_Adapter_Product <span style="color: #000000; font-weight: bold;">extends</span> Mage_Catalog_Model_Convert_Adapter_Product
<span style="color: #009900;">&#123;</span>
    <span style="color: #009933; font-style: italic;">/**
     * Save product (import)
     *
     * @param array $importData
     * @throws Mage_Core_Exception
     * @return bool
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> saveRow<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span> <span style="color: #000088;">$importData</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$product</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getProductModel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #339933;">-&gt;</span><span style="color: #004000;">reset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'store'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_null</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getBatchParams</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'store'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$store</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getStoreById</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getBatchParams</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'store'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$message</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'catalog'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span>
                    <span style="color: #0000ff;">'Skipping import row, required field &quot;%s&quot; is not defined.'</span><span style="color: #339933;">,</span>
                    <span style="color: #0000ff;">'store'</span>
                <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                Mage<span style="color: #339933;">::</span><span style="color: #004000;">throwException</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$store</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getStoreByCode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'store'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$store</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$message</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'catalog'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span>
                <span style="color: #0000ff;">'Skipping import row, store &quot;%s&quot; field does not exist.'</span><span style="color: #339933;">,</span>
                <span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'store'</span><span style="color: #009900;">&#93;</span>
            <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            Mage<span style="color: #339933;">::</span><span style="color: #004000;">throwException</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sku'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$message</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'catalog'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Skipping import row, required field &quot;%s&quot; is not defined.'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'sku'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            Mage<span style="color: #339933;">::</span><span style="color: #004000;">throwException</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setStoreId</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$store</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$productId</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getIdBySku</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sku'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$productId</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$productId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$productTypes</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getProductTypes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$productAttributeSets</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getProductAttributeSets</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #009933; font-style: italic;">/**
             * Check product define type
             */</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$productTypes</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$message</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'catalog'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span>
                    <span style="color: #0000ff;">'Skip import row, is not valid value &quot;%s&quot; for field &quot;%s&quot;'</span><span style="color: #339933;">,</span>
                    <span style="color: #000088;">$value</span><span style="color: #339933;">,</span>
                    <span style="color: #0000ff;">'type'</span>
                <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                Mage<span style="color: #339933;">::</span><span style="color: #004000;">throwException</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setTypeId</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$productTypes</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009933; font-style: italic;">/**
             * Check product define attribute set
             */</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attribute_set'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$productAttributeSets</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attribute_set'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attribute_set'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attribute_set'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$message</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'catalog'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span>
                    <span style="color: #0000ff;">'Skip import row, the value &quot;%s&quot; is invalid for field &quot;%s&quot;'</span><span style="color: #339933;">,</span>
                    <span style="color: #000088;">$value</span><span style="color: #339933;">,</span>
                    <span style="color: #0000ff;">'attribute_set'</span>
                <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                Mage<span style="color: #339933;">::</span><span style="color: #004000;">throwException</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttributeSetId</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$productAttributeSets</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attribute_set'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_requiredFields <span style="color: #b1b100;">as</span> <span style="color: #000088;">$field</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$attribute</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$field</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$field</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$attribute</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getIsRequired</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$message</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'catalog'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span>
                        <span style="color: #0000ff;">'Skipping import row, required field &quot;%s&quot; for new products is not defined.'</span><span style="color: #339933;">,</span>
                        <span style="color: #000088;">$field</span>
                    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    Mage<span style="color: #339933;">::</span><span style="color: #004000;">throwException</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setProductTypeInstance</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$product</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'category_ids'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setCategoryIds</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'category_ids'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_ignoreFields <span style="color: #b1b100;">as</span> <span style="color: #000088;">$field</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$field</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$field</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$store</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$websiteIds</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getWebsiteIds</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$websiteIds</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$websiteIds</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$store</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getWebsiteId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$websiteIds</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$websiteIds</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$store</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getWebsiteId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setWebsiteIds</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$websiteIds</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'websites'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$websiteIds</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getWebsiteIds</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$websiteIds</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span><span style="color: #000088;">$store</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$websiteIds</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000088;">$websiteCodes</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span> <span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'websites'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$websiteCodes</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$websiteCode</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                try <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$website</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">app</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getWebsite</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$websiteCode</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$website</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$websiteIds</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #000088;">$websiteIds</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$website</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
                catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setWebsiteIds</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$websiteIds</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$websiteIds</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$field</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$field</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_inventoryFields<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_null</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #000088;">$attribute</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$field</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$attribute</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #000088;">$isArray</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$setValue</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getFrontendInput</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'multiselect'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">MULTI_DELIMITER</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$isArray</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$setValue</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getBackendType</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'decimal'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$setValue</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getNumber</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">usesSource</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getSource</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAllOptions</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$isArray</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'label'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                            <span style="color: #000088;">$setValue</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'value'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                        <span style="color: #009900;">&#125;</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$setValue</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
                    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'label'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                            <span style="color: #000088;">$setValue</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'value'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                        <span style="color: #009900;">&#125;</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setData</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$field</span><span style="color: #339933;">,</span> <span style="color: #000088;">$setValue</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getVisibility</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setVisibility</span><span style="color: #009900;">&#40;</span>Mage_Catalog_Model_Product_Visibility<span style="color: #339933;">::</span><span style="color: #004000;">VISIBILITY_NOT_VISIBLE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000088;">$stockData</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$inventoryFields</span> <span style="color: #339933;">=</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_inventoryFieldsProductTypes<span style="color: #009900;">&#91;</span><span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getTypeId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
            ? <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_inventoryFieldsProductTypes<span style="color: #009900;">&#91;</span><span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getTypeId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span>
            <span style="color: #339933;">:</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$inventoryFields</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$field</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$field</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$field</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_toNumber<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$stockData</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$field</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getNumber</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$field</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$stockData</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$field</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$field</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setStockData</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$stockData</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$mediaGalleryBackendModel</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'media_gallery'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getBackend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$arrayToMassAdd</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMediaAttributes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$mediaAttributeCode</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$mediaAttribute</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$mediaAttributeCode</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$mediaAttributeCode</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$mediaGalleryBackendModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getImage</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$product</span><span style="color: #339933;">,</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$arrayToMassAdd</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'file'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mediaAttribute'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$mediaAttributeCode</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #009933; font-style: italic;">/**
         * Added code to enable/disable the exclude checkbox for main product images
         */</span>
&nbsp;
        <span style="color: #000088;">$_exclude</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Mage<span style="color: #339933;">::</span><span style="color: #004000;">getStoreConfig</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'catalog/catalog/image_exclude_enabled'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$addedFilesCorrespondence</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$mediaGalleryBackendModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addImagesWithDifferentMediaAttributes</span><span style="color: #009900;">&#40;</span>
            <span style="color: #000088;">$product</span><span style="color: #339933;">,</span>
            <span style="color: #000088;">$arrayToMassAdd</span><span style="color: #339933;">,</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getBaseDir</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'media'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> DS <span style="color: #339933;">.</span> <span style="color: #0000ff;">'import'</span><span style="color: #339933;">,</span>
            <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span>
            <span style="color: #000088;">$_exclude</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #009933; font-style: italic;">/**
         * End new code
         */</span>
&nbsp;
        <span style="color: #009933; font-style: italic;">/**
         * Added code to allow the import of additional product images
         */</span>
        <span style="color: #000088;">$_column</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getStoreConfig</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'catalog/catalog/multiple_image_column_name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$_column</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$additionalImages</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">';'</span><span style="color: #339933;">,</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$_column</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$additionalImages</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$image</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$mediaGalleryBackendModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getImage</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$product</span><span style="color: #339933;">,</span> <span style="color: #000088;">$image</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$arrayToMassAdd2</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'file'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000088;">$addedFilesCorrespondence</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$mediaGalleryBackendModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addImagesWithDifferentMediaAttributes</span><span style="color: #009900;">&#40;</span>
            <span style="color: #000088;">$product</span><span style="color: #339933;">,</span>
            <span style="color: #000088;">$arrayToMassAdd2</span><span style="color: #339933;">,</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getBaseDir</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'media'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> DS <span style="color: #339933;">.</span> <span style="color: #0000ff;">'import'</span><span style="color: #339933;">,</span>
            <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span>
            <span style="color: #009900; font-weight: bold;">false</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009933; font-style: italic;">/**
         * End new code
         */</span>
&nbsp;
        <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMediaAttributes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$mediaAttributeCode</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$mediaAttribute</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$addedFile</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$mediaAttributeCode</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'_label'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$fileLabel</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$mediaAttributeCode</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'_label'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$mediaAttributeCode</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$keyInAddedFile</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_search</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$mediaAttributeCode</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
                        <span style="color: #000088;">$addedFilesCorrespondence</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'alreadyAddedFiles'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$keyInAddedFile</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #000088;">$addedFile</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$addedFilesCorrespondence</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'alreadyAddedFilesNames'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$keyInAddedFile</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$addedFile</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$addedFile</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mediaAttributeCode</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$fileLabel</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$addedFile</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$mediaGalleryBackendModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">updateImage</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$product</span><span style="color: #339933;">,</span> <span style="color: #000088;">$addedFile</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$fileLabel</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setIsMassupdate</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setExcludeUrlRewrite</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2>Step 6</h2>
<p>To recap all the files we have made:</p>
<ul>
<li>/app/etc/modules/Prattski_ImageImport.xml</li>
<li>/app/code/local/Prattski/ImageImport/etc/config.xml</li>
<li>/app/code/local/Prattski/ImageImport/etc/system.xml</li>
<li>/app/code/local/Prattski/ImageImport/Helper/Data.php</li>
<li>/app/code/local/Prattski/ImageImport/Model/Catalog/Convert/Adapter/Product.php</li>
</ul>
<p>Test it out!  You&#8217;ll be able to see if Magento recognizes your module by going to System > Configuration > Advanced.  If you see the module in the list, Magento knows it&#8217;s there.  You can also go to System > Configuration > Catalog > Catalog > Import Image Options to see the configuration options we setup there.</p>
<p>If all looks good, then you are ready for a test.  Setup your CSV import file, including a new column called &#8216;additional_images&#8217; (or whatever you changed it to in the system config) and populate it with images to import.  When ready, go to System > Import/Export > Dataflow &#8211; Profiles and select the Import All Products and give it a go!</p>
<p>I hope you enjoyed learning how to build this module.  If you find any issues or bugs, please let me know.  Remember, this is for Magento 1.5.x and probably will not work on 1.4.x and lower.</p>
]]></content:encoded>
			<wfw:commentRss>http://prattski.com/2011/07/15/magento-revised-multiple-image-import-module-1-5/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Magento API: V2 API Does Not Return Custom Order Attributes</title>
		<link>http://prattski.com/2011/07/13/magento-api-v2-api-does-not-return-custom-order-attributes/</link>
		<comments>http://prattski.com/2011/07/13/magento-api-v2-api-does-not-return-custom-order-attributes/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 19:03:32 +0000</pubDate>
		<dc:creator>Josh Pratt</dc:creator>
				<category><![CDATA[Magento]]></category>

		<guid isPermaLink="false">http://prattski.com/?p=755</guid>
		<description><![CDATA[I am working with a 3rd party integrator to make an integration between Magento and Sage AccPac. We planned from the beginning to pass them custom order attributes and custom order-item attributes, which I verified come through the API, seeing &#8230; <a href="http://prattski.com/2011/07/13/magento-api-v2-api-does-not-return-custom-order-attributes/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I am working with a 3rd party integrator to make an integration between Magento and Sage AccPac. We planned from the beginning to pass them custom order attributes and custom order-item attributes, which I verified come through the API, seeing both custom order attributes, and custom order-item attributes returned.</p>
<p>Now that they&#8217;ve got their stuff up and running, I just got an email telling me that they do not see any of these custom attributes coming through.  At first I thought maybe they were just blind, but through investigating further, I found that they are using .NET and therefore have chosen to use the V2 API.</p>
<p>I then experimented with the same sales_order.info method with the V2 and discovered that they are right. No custom order or custom order-item attributes are returned!</p>
<p>If I figure out why, I will update this post.  If you know anything about this, please comment!</p>
<h3>Update:</h3>
<p>Actually, I found out that the V2 returns WAY less information than the standard soap API.  Why is this!?</p>
<h3>Update 2:</h3>
<p>I believe I&#8217;ve found out the &#8216;why&#8217; as to why there are so many fewer attributes, and why no custom attributes come through the V2 methods:  According to a .NET developer I talked with, languages like .NET and Java need to know the number of properties that are going to be returned.  For example, if .NET expects to get 5 attributes, but because of a custom attribute we added it gets 6, bad things happen.  So, the V2 of the api will always only ever return a very specific set of attributes that does not change.</p>
<p>As for where in the code it is doing this limitation, I am not quite sure yet.  When/if I figure it out, and how to modify it, I will make a post on that.</p>
]]></content:encoded>
			<wfw:commentRss>http://prattski.com/2011/07/13/magento-api-v2-api-does-not-return-custom-order-attributes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Magento API: v2_soap Does Not Use Call()</title>
		<link>http://prattski.com/2011/07/13/magento-api-v2_soap-does-not-use-call/</link>
		<comments>http://prattski.com/2011/07/13/magento-api-v2_soap-does-not-use-call/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 18:40:18 +0000</pubDate>
		<dc:creator>Josh Pratt</dc:creator>
				<category><![CDATA[Magento]]></category>

		<guid isPermaLink="false">http://prattski.com/?p=752</guid>
		<description><![CDATA[If you are utilizing Magento&#8217;s API and have checked out the documentation, you&#8217;ll see that they have included a V2 of their soap API saying: As of v1.3 you may also use http://yourmagentohost/api/v2_soap?wsdl=1 which has been added to improve compatbility &#8230; <a href="http://prattski.com/2011/07/13/magento-api-v2_soap-does-not-use-call/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you are utilizing Magento&#8217;s API and have checked out the documentation, you&#8217;ll see that they have included a V2 of their soap API saying:</p>
<blockquote><p>As of v1.3 you may also use http://yourmagentohost/api/v2_soap?wsdl=1 which has been added to improve compatbility with Java and .NET.</p></blockquote>
<p>If you find the need to utilize the v2_soap API, take note that you will need to call your methods differently than the documentation explains.</p>
<p>For example, if you would like to use the sales_order.info method, using the standard soap API, you would do the following to get all the order info for order number 1000000142:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$client</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SoapClient<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://yourwebsite.com/api/soap/?wsdl'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$session</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$client</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">login</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'username'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$client</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">call</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$session</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'sales_order.info'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'1000000142'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>If you need to use the V2 API, you need to so it slightly different.  Instead of using the call() method, you call the specific API method instead:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$client</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SoapClient<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://yourwebsite.com/api/soap/?wsdl'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$session</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$client</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">login</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'username'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$client</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">salesOrderInfo</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$session</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'1000000142'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>So, for V2, you must convert the method names in the Magento documentation to a camel-case method name.</p>
]]></content:encoded>
			<wfw:commentRss>http://prattski.com/2011/07/13/magento-api-v2_soap-does-not-use-call/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

