<?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>b.wilhelm &#187; Development</title>
	<atom:link href="http://www.bwilhelm.com/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bwilhelm.com</link>
	<description>E-commerce, Internet Marketing, Design and Everything Else</description>
	<lastBuildDate>Thu, 06 Oct 2011 12:44:16 +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>Introducing the New Jewelry Television Mobile App</title>
		<link>http://www.bwilhelm.com/2010/12/03/introducing-the-new-jewelry-television-mobile-app/</link>
		<comments>http://www.bwilhelm.com/2010/12/03/introducing-the-new-jewelry-television-mobile-app/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 19:48:56 +0000</pubDate>
		<dc:creator>Brian Wilhelm</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Home Shopping Network]]></category>
		<category><![CDATA[IPhone]]></category>
		<category><![CDATA[Jewelry Television]]></category>
		<category><![CDATA[Streaming media]]></category>

		<guid isPermaLink="false">http://www.bwilhelm.com/?p=231</guid>
		<description><![CDATA[Our team recently finished the new Jewelry Television iPhone app, and I wanted to show off some of the features. Take a look! The Jewelry Television iPhone and Android apps are now available in their respective app marketplaces. Feel free to go download them and have a look while you read through my brief overview. [...]]]></description>
			<content:encoded><![CDATA[<p>Our team recently finished the new Jewelry Television iPhone app, and I wanted to show off some of the features. Take a look!<br />
<span id="more-231"></span></p>
<div style="margin:20px auto; text-align:center"><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/dJZS75pH_yo?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/dJZS75pH_yo?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></div>
<p>The <a href="itms://itunes.apple.com/us/app/jtv/id402114612?mt=8">Jewelry Television iPhone</a> and Android apps are now available in their respective app marketplaces. Feel free to go download them and have a look while you read through my brief overview.</p>
<p>Take a look at the home screen below. It features some banner space, a live refreshing current item on air, links to recent items shown on TV, and a featured item category.</p>
<p><div id="attachment_233" class="wp-caption aligncenter" style="width: 210px"><a href="http://www.bwilhelm.com/wordpress/wp-content/uploads/2010/12/home.png"><img class="size-medium wp-image-233" title="JTV App Home Screen" src="http://www.bwilhelm.com/wordpress/wp-content/uploads/2010/12/home-200x300.png" alt="JTV App Home Screen" width="200" height="300" /></a><p class="wp-caption-text">JTV App Home Screen</p></div></p>
<p>We also included the ability to watch JTV live through the app, as long as you are connected to 3G or wi-fi. This section features the current item which refreshes below the video, so you can tap the item and buy it if you so desire.</p>
<p><div id="attachment_236" class="wp-caption aligncenter" style="width: 210px"><a href="http://www.bwilhelm.com/wordpress/wp-content/uploads/2010/12/liveshow.png"><img class="size-medium wp-image-236" title="JTV Live Show" src="http://www.bwilhelm.com/wordpress/wp-content/uploads/2010/12/liveshow-200x300.png" alt="JTV Live Show" width="200" height="300" /></a><p class="wp-caption-text">The live broadcast streaming within the app.</p></div></p>
<p>Let me say that writing an app for a home shopping network provides unique challenges that most app developers don&#8217;t have to contend with, namely, streaming video of your live broadcast. Getting this right and working has been a fairly complex challenge filled with consideration for all sorts of devices, connection speed, and bit rate scenarios to make sure that its available to as many devices as possible and looks good at the same time.</p>
<p>We also included some non-live video in our video library section. Here we have pre-defined categories of video that we can update on the fly for app users.</p>
<p><div id="attachment_239" class="wp-caption aligncenter" style="width: 210px"><a href="http://www.bwilhelm.com/wordpress/wp-content/uploads/2010/12/videolibrary.png"><img class="size-medium wp-image-239" title="Video Library" src="http://www.bwilhelm.com/wordpress/wp-content/uploads/2010/12/videolibrary-200x300.png" alt="Video Library" width="200" height="300" /></a><p class="wp-caption-text">The video library section of the JTV app.</p></div></p>
<p>Education is a big part of what Jewelry Television stands for, and the Gemopedia section features information about gemstones, including pictures and video, and is a convenient little gemstone guide you can keep in your pocket.</p>
<p><div id="attachment_242" class="wp-caption aligncenter" style="width: 210px"><a href="http://www.bwilhelm.com/wordpress/wp-content/uploads/2010/12/gemopediahome.png"><img class="size-medium wp-image-242" title="Gemopedia" src="http://www.bwilhelm.com/wordpress/wp-content/uploads/2010/12/gemopediahome-200x300.png" alt="Gemopedia" width="200" height="300" /></a><p class="wp-caption-text">The Gemopedia, a mobile gemstone guide.</p></div></p>
<p>We also provide some tools in the app, such as a ring sizer, program guide, and channel finder that uses your GPS to tell you what channel Jewelry Television is on in your immediate area.</p>
<p><div id="attachment_243" class="wp-caption aligncenter" style="width: 210px"><a href="http://www.bwilhelm.com/wordpress/wp-content/uploads/2010/12/channelfinder.png"><img class="size-medium wp-image-243" title="Channel Finder" src="http://www.bwilhelm.com/wordpress/wp-content/uploads/2010/12/channelfinder-200x300.png" alt="" width="200" height="300" /></a><p class="wp-caption-text">The JTV Channel Finder</p></div></p>
<p><div id="attachment_244" class="wp-caption aligncenter" style="width: 210px"><a href="http://www.bwilhelm.com/wordpress/wp-content/uploads/2010/12/ringsizer.png"><img class="size-medium wp-image-244" title="Ring Sizer" src="http://www.bwilhelm.com/wordpress/wp-content/uploads/2010/12/ringsizer-200x300.png" alt="Ring Sizer" width="200" height="300" /></a><p class="wp-caption-text">The JTV Ring Sizer</p></div></p>
<p>Of course the app wouldn&#8217;t be complete without the ability to shop. We have a full shopping experience built in to the app, where you can browse the roughly 30,000 jewelry and gemstone items on JTV.com and purchase, right from your mobile device.</p>
<p><div id="attachment_245" class="wp-caption aligncenter" style="width: 210px"><a href="http://www.bwilhelm.com/wordpress/wp-content/uploads/2010/12/shopping.png"><img class="size-medium wp-image-245" title="App Shopping" src="http://www.bwilhelm.com/wordpress/wp-content/uploads/2010/12/shopping-200x300.png" alt="App Shopping" width="200" height="300" /></a><p class="wp-caption-text">Shopping inside the JTV app.</p></div></p>
<p>All in all the app is a solid version 1.0. Keep an eye out for more features rolling out soon.</p>
<p>Download the apps: <a href="itms://itunes.apple.com/us/app/jtv/id402114612?mt=8">JTV iPhone App</a></p>
<p>QR Code for the Android App<br />
<div id="attachment_248" class="wp-caption alignleft" style="width: 160px"><a href="http://www.bwilhelm.com/wordpress/wp-content/uploads/2010/12/qrcode_android.gif"><img src="http://www.bwilhelm.com/wordpress/wp-content/uploads/2010/12/qrcode_android.gif" alt="QR Code for Android App" title="QR Code for Android App" width="150" height="150" class="size-full wp-image-248" /></a><p class="wp-caption-text">QR Code for Android App</p></div></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bwilhelm.com/2010/12/03/introducing-the-new-jewelry-television-mobile-app/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Creating Timed Events in Your iPhone App with Titanium</title>
		<link>http://www.bwilhelm.com/2010/11/20/creating-timed-events-in-your-iphone-app-with-titanium/</link>
		<comments>http://www.bwilhelm.com/2010/11/20/creating-timed-events-in-your-iphone-app-with-titanium/#comments</comments>
		<pubDate>Sun, 21 Nov 2010 03:54:35 +0000</pubDate>
		<dc:creator>Brian Wilhelm</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Appcelerator]]></category>
		<category><![CDATA[Appcelerator Titanium]]></category>
		<category><![CDATA[IPhone]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Titanium]]></category>

		<guid isPermaLink="false">http://www.bwilhelm.com/?p=212</guid>
		<description><![CDATA[Timers are core elements of games. I&#8217;ll show you how to write a basic timer function that will let you trigger an event on an interval for your iphone app, using Appcelerator&#8217;s Titanium. Since Titanium allows you to write code in Javascript, you can write functions to do a bunch of stuff for you and [...]]]></description>
			<content:encoded><![CDATA[<p>Timers are core elements of games. I&#8217;ll show you how to write a basic timer function that will let you trigger an event on an interval for your iphone app, using Appcelerator&#8217;s <a class="zem_slink" title="Appcelerator Titanium" rel="homepage" href="http://www.appcelerator.com">Titanium</a>.<br />
<span id="more-212"></span></p>
<p>Since Titanium allows you to write code in Javascript, you can write functions to do a bunch of stuff for you and make writing your app much easier.  I wrote a simple timer function that can be used to fire other events within your app. This might be useful for games, cooking apps, etc.</p>
<p>So here&#8217;s the code:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> setTimer<span style="color: #009900;">&#40;</span>timetowait<span style="color: #339933;">,</span>context<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
mt<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
mtimer <span style="color: #339933;">=</span> setInterval<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    	mt<span style="color: #339933;">++;</span>
	Ti.<span style="color: #660066;">API</span>.<span style="color: #660066;">info</span><span style="color: #009900;">&#40;</span>mt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>mt<span style="color: #339933;">==</span>timetowait<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// do something;</span>
	clearInterval<span style="color: #009900;">&#40;</span>mtimer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 	Ti.<span style="color: #660066;">App</span>.<span style="color: #660066;">fireEvent</span><span style="color: #009900;">&#40;</span>context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>So let&#8217;s break it down to understand what it does. First let&#8217;s look at the variable we pass into the function: <em><strong>timetowait</strong></em> and <em><strong>context</strong></em></p>
<p><em><strong>timetowait</strong></em> simply represents the number of seconds the timer should count to until you want your event to fire.</p>
<p><em><strong>context</strong></em> is the name of the event that you want to fire when the timer reaches timetowait</p>
<p><em><strong>Ti.API.info(mt)</strong></em> simply writes out the Titanium debug window the value of <em>mt</em>, which is our variable that increments every second. This is optional, but helpful in the development process to see exactly when the timer stops.</p>
<p><em><strong>clearInterval(mtimer)</strong></em> tells the setInterval function in Titanium to essentially stop/reset.</p>
<p><em><strong>Ti.App.fireEvent(context)</strong></em> fires the name of the event we passed in as the variable <strong><em>context</em></strong>.</p>
<p>Let&#8217;s look at a couple of examples of how this could be used. Let&#8217;s say we have a basic game where the player has to do something in a specific amount of time. We could use our setTimer function to time the game, and then show a game over alert message in the app:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//set the timer for 30 seconds, and after that show the game over message</span>
setTimer<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">30</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'showGameOver'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//create an event listener for our Game Over alert</span>
Ti.<span style="color: #660066;">App</span>.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;showGameOver&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Game Over!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>That&#8217;s a pretty simple example. Let&#8217;s say we wanted to continuously loop the timer:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//set the timer for 30 seconds, and then call the timer function again</span>
setTimer<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">30</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'loopTimer'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
Ti.<span style="color: #660066;">App</span>.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;loopTimer&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">//call the timer function again</span>
	setTimer<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">30</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'loopTimer'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In both of these cases we can add as much complexity to our event listeners (the event that is fired when the timer ends) as we want…we could update the on-screen display, fire off multiple events, write data to the local database, load a remote file, check network connectivity, etc.</p>
<p>Timers can be used for all sorts of things in iPhone apps. Hope this helps someone get started using them.</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><img class="zemanta-pixie-img" style="border: none; float: right;" src="http://img.zemanta.com/pixy.gif?x-id=6cdf010d-c626-4348-8654-12c1a0452ac7" alt="" /></div>
]]></content:encoded>
			<wfw:commentRss>http://www.bwilhelm.com/2010/11/20/creating-timed-events-in-your-iphone-app-with-titanium/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Get XML Data into Magento via the Magento API</title>
		<link>http://www.bwilhelm.com/2010/01/05/get-xml-data-into-magento-via-magento-api/</link>
		<comments>http://www.bwilhelm.com/2010/01/05/get-xml-data-into-magento-via-magento-api/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 19:13:59 +0000</pubDate>
		<dc:creator>Brian Wilhelm</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[E-Commerce]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[magento]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.bwilhelm.com/?p=63</guid>
		<description><![CDATA[Recently I needed to write some code to get a dropshipper&#8217;s xml product data into Magento to update my products price, quantity available, and stock status. This is how I went about it. NOTE: Before you get started, you need to make sure you have created an API user in Magento. Here is a good [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I needed to write some code to get a dropshipper&#8217;s xml product data into Magento to update my products price, quantity available, and stock status. This is how I went about it.<br />
<span id="more-63"></span><br />
NOTE: Before you get started, you need to make sure you have created an API user in Magento. <a href="http://www.yireo.com/tutorials/magebridge/administration/119-step-by-step-create-a-magento-api-user">Here is a good step-by-step tutorial for doing that.</a></p>
<p>I decided that because of the potentially massive amount of data in my dropshipper&#8217;s XML feed file, that I should save the file to my server before attempting to process any data. I set up a cron job to use CURL to fetch the file. First I created a file called &#8216;importproducts.php&#8217; and added the following code:</p>
<p><strong>importproducts.php</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//my dropshipper's feed URL - replace with your dropshipper's feed</span>
<span style="color: #000088;">$myFeed</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://www.mydropshipperssite.com/feedurl.xml'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// specify the name of the file you want to save</span>
<span style="color: #000088;">$myFilename</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'product_feed.xml'</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$myFeed</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//  Initialize the cURL session</span>
	<span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$myFeed</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//Create a new file</span>
	<span style="color: #000088;">$fp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$myFilename</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'w'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// Save to file</span>
	<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_FILE<span style="color: #339933;">,</span> <span style="color: #000088;">$fp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// Execute the cURL session</span>
	<span style="color: #990000;">curl_exec</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//Close cURL session and file</span>
	<span style="color: #990000;">curl_close</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Feed Imported Successfully!&quot;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
		<span style="color: #666666; font-style: italic;">//check the file size - if its 0 then my dropshipper didn't provide any updates, so don't let me know</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">filesize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$myFilename</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">// send email to me when executed</span>
			<span style="color: #000088;">$to</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;youremail@yourdomain.com&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$subject</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Feed Imported&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$body</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Hi,<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>The latest product data for YOURSITE has been downloaded on &quot;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$body</span> <span style="color: #339933;">.=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'l jS \of F Y h:i:s A'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span> File Size: &quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">filesize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$myFilename</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; bytes&quot;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">mail</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$to</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subject</span><span style="color: #339933;">,</span> <span style="color: #000088;">$body</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				  <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;p&gt;Message successfully sent!&lt;/p&gt;&quot;</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: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;p&gt;Message delivery failed...&lt;/p&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Now that we have this script written, we need to process the data. Before that, let me show you an example of the xml data I am working with in the xml file we just saved with the import script. Here is sample xml:</p>
<p><strong>product_feed.xml</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td 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;products<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;product</span> <span style="color: #000066;">sku</span>=<span style="color: #ff0000;">&quot;15569&quot;</span> <span style="color: #000066;">mfg_part_number</span>=<span style="color: #ff0000;">&quot;405970-1&quot;</span> <span style="color: #000066;">upc</span>=<span style="color: #ff0000;">&quot;082324027055&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;inventory</span> <span style="color: #000066;">quantity</span>=<span style="color: #ff0000;">&quot;13&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;price</span> <span style="color: #000066;">your_price</span>=<span style="color: #ff0000;">&quot;143.18&quot;</span> <span style="color: #000066;">list</span>=<span style="color: #ff0000;">&quot;159.99&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description</span> <span style="color: #000066;">short</span>=<span style="color: #ff0000;">&quot;A product description&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/product<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;product</span> <span style="color: #000066;">sku</span>=<span style="color: #ff0000;">&quot;16128&quot;</span> <span style="color: #000066;">mfg_part_number</span>=<span style="color: #ff0000;">&quot;406350-1&quot;</span> <span style="color: #000066;">upc</span>=<span style="color: #ff0000;">&quot;082324029301&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;inventory</span> <span style="color: #000066;">quantity</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;price</span> <span style="color: #000066;">your_price</span>=<span style="color: #ff0000;">&quot;128.18&quot;</span> <span style="color: #000066;">list</span>=<span style="color: #ff0000;">&quot;149.99&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description</span> <span style="color: #000066;">short</span>=<span style="color: #ff0000;">&quot;Another product description&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/product<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/products<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Now we can talk about the next file, the one that takes the XML data and uses it to update products in Magento via the API. We&#8217;ll name this file &#8216;processupdates.php&#8217;.</p>
<p><strong>processupdates.php</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//include the Magento API file - replace with your server path to the file</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/some/path/to/public_html/app/Mage.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// ***** Configuration ******</span>
<span style="color: #000088;">$myDomain</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://www.yourdomain.com'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$myAPILogin</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'username'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$myAPIKey</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'password'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//calculate the price markup - useful if you have a standard markup you apply</span>
<span style="color: #000088;">$myMarkUp</span> <span style="color: #339933;">=</span> <span style="color:#800080;">.30</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$defaultMarkup</span> <span style="color: #339933;">=</span> <span style="color:#800080;">.30</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// get my saved file name</span>
<span style="color: #000088;">$myFilename</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'product_feed.xml'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//load up local xml file for processing</span>
<span style="color: #000088;">$feed_xml</span> <span style="color: #339933;">=</span> <span style="color: #990000;">simplexml_load_file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$myFilename</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Begin SOAP Requests</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: #000088;">$myDomain</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/api/?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: #000088;">$myAPILogin</span><span style="color: #339933;">,</span> <span style="color: #000088;">$myAPIKey</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$updatedProducts</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//some counters - counting loops this way lets me see and set where the count increments</span>
<span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//some filter date to pass to the API - add more to filter your results further - see Magento API docs</span>
<span style="color: #000088;">$filterData</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'type'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'simple'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//get all my database products into an array</span>
<span style="color: #000088;">$products</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;">'catalog_product.list'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filterData</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">//loop through my product array</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$products</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$product</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Starting product loop...&lt;br/&gt;&lt;br/&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">//get my database product sku - for cleaner reference in the code</span>
<span style="color: #000088;">$mysku</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$product</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sku'</span><span style="color: #009900;">&#93;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//search directly in the product sku attribute in the xml for my sku</span>
<span style="color: #000088;">$res</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$feed_xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;//product[@sku='<span style="color: #006699; font-weight: bold;">$mysku</span>']&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">// if we find one, lets process it</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;">$res</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//matched - make updates</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Matched: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$mysku</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//price updates</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$res</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">price</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'list'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$newprice</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$res</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">price</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'your_price'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$res</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">price</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'list'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$res</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">price</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'your_price'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #000088;">$myMarkUp</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;">$newprice</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$res</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">price</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'your_price'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$res</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">price</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'your_price'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">*</span><span style="color: #000088;">$defaultMarkup</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//build my array to pass to the magento API</span>
	<span style="color: #000088;">$fieldPriceData</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cost'</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$res</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">price</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'your_price'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'price'</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$newprice</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'upc'</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$res</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">product</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'upc'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//update magento with price data</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;">'catalog_product.update'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$product</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sku'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$fieldPriceData</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;">//qty and stock updates</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$res</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">inventory</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'quantity'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">1</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;">$fieldQtyData</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: #000088;">$res</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">inventory</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'quantity'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">1</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: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;In Stock&lt;br/&gt;&quot;</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;">$fieldQtyData</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: #000088;">$res</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">inventory</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'quantity'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'is_in_stock'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Out of Stock&lt;br/&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//update magento with quantity and stock data</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;">'product_stock.update'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$product</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sku'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$fieldQtyData</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;">//record the updated product for emailing later</span>
	<span style="color: #000088;">$updatedProducts</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;SKU: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$mysku</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; - &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$res</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">description</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'short'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Price: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$newprice</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Cost: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$res</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">price</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'your_price'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Qty: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$res</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">inventory</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'quantity'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//increment my counter</span>
	<span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$x</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;no match&lt;br/&gt;&lt;br/&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">// send mail to me</span>
<span style="color: #000088;">$to</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;you@yourdomain.com&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$subject</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Feed Processed&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$body</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Hi,<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>The latest data for &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$myDomain</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; has been processed on &quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'l jS \of F Y h:i:s A'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$body</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;Products Updated: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$x</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$updatedProducts</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">mail</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$to</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subject</span><span style="color: #339933;">,</span> <span style="color: #000088;">$body</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;p&gt;Message successfully sent!&lt;/p&gt;&quot;</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: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;p&gt;Message delivery failed...&lt;/p&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Now all you need to do is set up the cron jobs to call your import file at one interval, and your process file at another interval. Note that this works for me because I have a limited number of database products. If you have thousands of products you might want to have your site updating products by category, for example. If anyone has any better ideas on how to do any of this, please let me know. I always like to learn new stuff!</p>
<p>Download Files: <a href="http://www.bwilhelm.com/downloads/Magento_API_XML_Import.zip" title="Downloaded 651 times">Magento API XML Import</a> - 15.82 KB - 651 Downloads<br />
<br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bwilhelm.com/2010/01/05/get-xml-data-into-magento-via-magento-api/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
	</channel>
</rss>

