<?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>Christopher Shennan&#039;s Blog &#187; Magento</title>
	<atom:link href="http://www.chrisshennan.com/category/magento/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chrisshennan.com</link>
	<description>A day in the life of...</description>
	<lastBuildDate>Thu, 15 Sep 2011 15:13:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Import Product Attributes into Magento</title>
		<link>http://www.chrisshennan.com/2011/04/23/import-product-attributes-into-magento/</link>
		<comments>http://www.chrisshennan.com/2011/04/23/import-product-attributes-into-magento/#comments</comments>
		<pubDate>Sat, 23 Apr 2011 14:41:04 +0000</pubDate>
		<dc:creator>Christopher Shennan</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[import product attribute]]></category>
		<category><![CDATA[magento import]]></category>

		<guid isPermaLink="false">http://www.chrisshennan.com/?p=618</guid>
		<description><![CDATA[I have recently taken on a new web project which is to move an e-commerce website from a custom 3rd party solution over to Magento and before I even got started I hit a road block (you have got to love Magento for that!).  I found that I had to import around 200 product attributes [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently taken on a new web project which is to move an e-commerce website from a custom 3rd party solution over to Magento and before I even got started I hit a road block (you have got to love Magento for that!).  I found that I had to import around 200 product attributes (colours, sizes, etc) from the old online shop to the magento installation and obviously I did not want to enter all these by hand, but where to begin?!</p>
<p>Luckily I came across a post on the Magento forums which details a method for bulk importing product attributes into Magento and although it did not allow me to automate the whole process, it was sufficient for my purposes.<br />
<span id="more-618"></span></p>
<p>The sample code provided in the post allows you to import multiple attributes into Magento but you have to create the attribute in Magento manually before you can import the values as the import does not create non-existing attibutes.  The other problem for me was that the sample code only allowed you to import one attribute at a time and then you had to edit files and id&#8217;s to do the next one.</p>
<p>As I had multiple attributes to import I tweaked the example code (you can <a href="/wp-content/uploads/2011/04/magento-attribute-import-sample.zip">download the tweaked code</a> here) to allow me to import values for multiple attributes at one time.  I still had to create the attributes manually within Magento first but the tweaked code allowed me to import all my attributes values for multiple attributes at once.</p>
<p>In order to import the product attribute values you need to create files in your magento installation within the folder</p>
<blockquote><p>/var/import/attributes/</p></blockquote>
<p>The files need to be in the format of [attribute_id]_[attribute_name].csv i.e. 80_color.csv, 122_size.csv,  techically the _[attribute_name] is not necessary but it helps to make identifying which attribute the file is for a whole lot easier.</p>
<p>Each value for the product attribute need to be in a separate line and the first line needs to contain the word &#8220;admin&#8221;.  For example, 80_color.csv contains:-</p>
<pre>admin
Red
Blue
Green
Purple
Black</pre>
<p>Once you have created the attribute files and copied to other files to their relevant locations you can then open ImpAttributes.php for your Magento installation in your browser i.e. http://www.mysite.com/ImpAttributes.php and all being good, your product attributes should be imported.</p>
<p>I have made the adapted product attributes import for Magento sample code available for download via the link below:-</p>
<h3>Sample Code</h3>
<p>This also contains a sample colours and sizes file</p>
<p><a href="/wp-content/uploads/2011/04/magento-attribute-import-sample.zip">Importing Product Attributes into Magento &#8211; Sample Code</a></p>
<h3>References</h3>
<p><a title="Bulk Import Attributes" href="http://www.magentocommerce.com/boards/viewthread/9391/#t34066" target="_blank">Bulk Import Attributes</a> &#8211; Original solution provided by Srinigenie</p>
<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.chrisshennan.com/2011/04/23/import-product-attributes-into-magento/' addthis:title='Import Product Attributes into Magento ' ><a href="//addthis.com/bookmark.php?v=250&amp;username=xa-4d2b47597ad291fb" class="addthis_button_compact">Share</a><span class="addthis_separator">|</span><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.chrisshennan.com/2011/04/23/import-product-attributes-into-magento/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Magento API &#8211; Update Product Stock Levels</title>
		<link>http://www.chrisshennan.com/2009/11/15/magento-api-update-product-stock-levels/</link>
		<comments>http://www.chrisshennan.com/2009/11/15/magento-api-update-product-stock-levels/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 18:23:00 +0000</pubDate>
		<dc:creator>Christopher Shennan</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[magento api]]></category>
		<category><![CDATA[magento stock levels]]></category>
		<category><![CDATA[product.update]]></category>
		<category><![CDATA[product_stock.update]]></category>

		<guid isPermaLink="false">http://www.chrisshennan.com/?p=162</guid>
		<description><![CDATA[Another day&#8230; another magento problem! I was asked to look into a problem with an automated stock level update script not updating the stock levels.  This update script was using the Magento API and on the face of things everything looked ok as the script ran without any errors, the product prices got updated but [...]]]></description>
			<content:encoded><![CDATA[<p>Another day&#8230; another magento problem!</p>
<p>I was asked to look into a problem with an automated stock level update script not updating the stock levels.  This update script was using the Magento API and on the face of things everything looked ok as the script ran without any errors, the product prices got updated but the stock levels never changed.</p>
<p>After a bit of investigating I found the problem was caused by an incorrect usage of the Magento API and the original update statement was similar to:-</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$proxy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">call</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sessionId</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'product.update'</span><span style="color: #339933;">,</span>
	<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'PRD0001'</span><span style="color: #339933;">,</span> 
		<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'price'</span><span style="color: #339933;">=&gt;</span><span style="color:#800080;">12.50</span><span style="color: #339933;">,</span> 
			<span style="color: #0000ff;">'qty'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">12</span><span style="color: #339933;">,</span> 
			<span style="color: #0000ff;">'is_in_stock'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> 
			<span style="color: #0000ff;">'discontinued'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">0</span>
		<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>However, the update of the is_in_stock and qty fields is not done against the product (via <a href="http://www.magentocommerce.com/wiki/doc/webservices-api/api/catalog_product" target="_blank">product.update</a>) but against the product inventory (via <a href="http://www.magentocommerce.com/wiki/doc/webservices-api/api/cataloginventory_stock_item" target="_blank">product_stock.update</a>) so this code had to be updated to the following:-<br />
<span id="more-162"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// UPDATE THE PRODUCT</span>
<span style="color: #000088;">$proxy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">call</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sessionId</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'product.update'</span><span style="color: #339933;">,</span>
	<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'PRD0001'</span><span style="color: #339933;">,</span> 
		<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'price'</span><span style="color: #339933;">=&gt;</span><span style="color:#800080;">12.50</span><span style="color: #339933;">,</span> 
			<span style="color: #0000ff;">'discontinued'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">0</span>
		<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// UPDATE THE PRODUCT INVENTORY</span>
<span style="color: #000088;">$proxy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">call</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sessionId</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'product_stock.update'</span><span style="color: #339933;">,</span>
	<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'PRD0001'</span><span style="color: #339933;">,</span> 
		<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'qty'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">12</span><span style="color: #339933;">,</span> 
			<span style="color: #0000ff;">'is_in_stock'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> 
		<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>After the stock level update script had been adapted to this 2 step approach everything seemed to run ok and the stock level figures were then being updated with the appropriate quantities.</p>
<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.chrisshennan.com/2009/11/15/magento-api-update-product-stock-levels/' addthis:title='Magento API &#8211; Update Product Stock Levels ' ><a href="//addthis.com/bookmark.php?v=250&amp;username=xa-4d2b47597ad291fb" class="addthis_button_compact">Share</a><span class="addthis_separator">|</span><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.chrisshennan.com/2009/11/15/magento-api-update-product-stock-levels/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

