<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>My Science Is Better &#187; ecommerce</title>
	<atom:link href="http://www.myscienceisbetter.info/tag/ecommerce/feed" rel="self" type="application/rss+xml" />
	<link>http://www.myscienceisbetter.info</link>
	<description></description>
	<lastBuildDate>Sat, 20 Mar 2010 16:16:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Magento export categories with id</title>
		<link>http://www.myscienceisbetter.info/magento-export-categories-with-id.html</link>
		<comments>http://www.myscienceisbetter.info/magento-export-categories-with-id.html#comments</comments>
		<pubDate>Mon, 07 Sep 2009 09:07:58 +0000</pubDate>
		<dc:creator>Romeo Adrian Cioaba</dc:creator>
				<category><![CDATA[ecommerce]]></category>
		<category><![CDATA[magento]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.myscienceisbetter.info/?p=81</guid>
		<description><![CDATA[A friend asked me to help out import some products and categories from an old database to a brand new magento install. What I first did was to construct a CSV file with all the categories from the old store (that was the easy part...) and import them to magento. I followed this thread and [...]]]></description>
			<content:encoded><![CDATA[<p>A friend asked me to help out import some products and categories from an old database to a brand new magento install. What I first did was to construct a CSV file with all the categories from the old store (that was the easy part...) and import them to magento. I followed <a href="http://www.magentocommerce.com/boards/viewthread/26022/P0/">this</a> thread and the import when smooth. Now I needed to get the ids that magento addigned to my categories so that I could import a product inside the categories so that my friend won't have to do it in backend.</p>
<p>First thing I did was to look on magento forums how to get all store categories. After finding <a href="http://www.magentocommerce.com/boards/viewthread/24947/">this</a> great thread, i came up with this little script which I put into my template folder in /catalog/allcategories.phtml:</p>
<pre class="brush: php;">
$category = Mage::getModel ( 'catalog/category' );
$tree = $category-&gt;getTreeModel ();
$tree-&gt;load ();

$ids = $tree-&gt;getCollection ()-&gt;getAllIds ();

if ($ids) {
$fp = fopen('var/import/catwithid.csv', 'a');
fwrite($fp,  'catId, catName\n');
foreach ( $ids as $id ) {
                $string = $id . ', ' .$category-&gt;load($id)-&gt;getName() . '\n';
fwrite($fp,  $string);
}
fclose($fp);
}
</pre>
<p>As a note, you need to make sure that /var/import/catwithid.csv exists and it's writeable by your web server. You can make sure it is by chmod-ing it to 777</p>
<pre class="brush: bash;">
touch var/import/catwithid.csv # we create the file
chmod 777 var/import/catwithid.csv #make sure it's writeable
</pre>
<p>Since this was a dev install, I then just loaded that script into a block element by editing the Home Page inside the CMS section:</p>
<pre class="brush: xml;">
{{block type=&quot;core/template&quot; template=&quot;catalog/allcategories.phtml&quot;}}
</pre>
<p>Hope this helps someone <img src='http://www.myscienceisbetter.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.myscienceisbetter.info/magento-export-categories-with-id.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
