How To Setup Multiple Magento Stores

Crucial Web Hosting has a very well put together blog posting detailing how one can utilize Magento’s MultiStore ability and different approachs to take for whatever reason they maybe.  Like subdomains, subfolders or even completely different domains.  They also go into how to setup SSL for each of the stores if you are needing to keep Site A’s identity hidden from Site B’s.  It’s defiantly worth checking out or atleast bookmarking for a later read.

arrow Crucial Web Hosting » Blog » How To Setup Multiple Magento Stores.

arrow A GUIDE TO SETTING UP MULTIPLE STORES IN MAGENTO

Export X-Cart Products for Magento

xcart-to-mag

Something I have been wanting to do for awhile is attempt at writing a Magento X-Cart import module. Since I’m no where near getting such completed, and was needing to get a clients old X-Cart version 3.5.X product data imported into Magento 1.2.x, I decided to do it the old fashioned way. Export the X-Cart data into an Excel document and map the exported data. Since I had no idea what fields Magento would require for the import. I simply exported my existing Magento products I had added manually. If you don’t have any simply create a single test product and then proceed to export from Magento.

Please keep in mind this is a very basic import, as Product Options and Categories from X-Cart are ignored. I’m open to any ideas and/or thoughts to achieve this, so please feel free to add any comments.

Here is the SQL Query that I have used to grab the basic essential data out of X-Cart:

SELECT
xcart_products.productid,
xcart_products.productcode,
xcart_products.product,
xcart_products.brand,
xcart_products.model,
xcart_products.weight,
xcart_products.categoryid,
xcart_products.list_price,
xcart_products.descr,
xcart_products.fulldescr,
xcart_products.param00,
xcart_products.param01,
xcart_products.param02,
xcart_products.param03,
xcart_products.`type`,
xcart_pricing.productid,
xcart_pricing.quantity,
xcart_pricing.price,
xcart_thumbnails.image_path,
xcart_images.image_path,
xcart_images.image_x,
xcart_images.image_y,
xcart_images.image_size,
xcart_images.alt,
xcart_pricing.membership,
xcart_categories.category
FROM
xcart_products
Left Join xcart_pricing ON xcart_products.productid = xcart_pricing.productid
Left Join xcart_thumbnails ON xcart_products.productid = xcart_thumbnails.productid
Left Join xcart_images ON xcart_products.productid = xcart_images.productid
Left Join xcart_categories ON xcart_categories.categoryid = xcart_products.categoryid
GROUP BY xcart_products.productid

xcart-import-diagram-schema   

One Remote MySQL Manager I found very useful for alot of this was “NaviCat“, the free version doesn’t support export/importing however they do offer a 30 day trial with all the bells and whistles.

As you can tell I am only exporting xcart_products, xcart_pricing, xcart_thumbnails, xcart_images and xcart_categories. However I did not use xcart_categories when mapping my data in Excel, I merely wanted to export it so it was easier to determine products while in Excel.

When exporting with NaviCat I noticed two Excel options, both seem to yield the same results, however I noticed with one of the options long descriptions over 255 characters were being truncated, here is the option to use for best results I’ve found:
export option

A few things to take note while mapping and/or copying your X-Cart exported data to your Magento exported data is:

  • You will need to remove the full path that X-Cart uses in its image tables, i.e. /home/mysite/public_html/
  • Keep a front slash ‘/’ in front of your image filename’s.
  • Copy all of your X-Cart product’s Images via FTP or however you choose. And upload them to /media/import/
  • Keep existing data in the fields of the Magento products export the same. The most note-able are: store, attribute_set and type.
  • You may have some custom data from X-Cart that can be utilized, per say if you were using param00 for a cost field, you can easily map this field into Magento’s custom attributes you can create to be able to port this information over. You can find custom attributes under “Catalog”->”Attributes”->”Manage Attributes” within the Admin.
  • Export as a “Comma Separated Values” (CSV) file. I opened this file up in notepad after exporting and re-saved just to ensure line-breaks and odd characters aren’t miss-interrupted.

All of Magento’s export and import functionality can be found under “System”->”Import/Export”->”Profiles”.

I created a new profile entitled “X-Cart Import” and used the following settings:
xcart-import-magento-profile-settings

Here is the XML profile for my X-Cart import profile as well:

    
    
    true
    
    1
    
    catalog/convert_adapter_product
    parse

One Idea I didn’t realize during my first initial import was the import process at least on a low-end server can take hours to complete, so you may want to take a small portion of your spreadsheet, export to CSV and do a small amount of data to ensure you have all of your data properly laid out. I made this mistake and am now in the process of re-importing all 2000+ products after doing a small amount to ensure things are in order.

If at anytime you want to wipe all of your products and start from no products, run this query in NaviCat or PHPMyAdmin:

TRUNCATE TABLE `catalog_product_bundle_option`;
TRUNCATE TABLE `catalog_product_bundle_option_value`;
TRUNCATE TABLE `catalog_product_bundle_selection`;
TRUNCATE TABLE `catalog_product_entity_datetime`;
TRUNCATE TABLE `catalog_product_entity_decimal`;
TRUNCATE TABLE `catalog_product_entity_gallery`;
TRUNCATE TABLE `catalog_product_entity_int`;
TRUNCATE TABLE `catalog_product_entity_media_gallery`;
TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;
TRUNCATE TABLE `catalog_product_entity_text`;
TRUNCATE TABLE `catalog_product_entity_tier_price`;
TRUNCATE TABLE `catalog_product_entity_varchar`;
TRUNCATE TABLE `catalog_product_link`;
TRUNCATE TABLE `catalog_product_link_attribute`;
TRUNCATE TABLE `catalog_product_link_attribute_decimal`;
TRUNCATE TABLE `catalog_product_link_attribute_int`;
TRUNCATE TABLE `catalog_product_link_attribute_varchar`;
TRUNCATE TABLE `catalog_product_link_type`;
TRUNCATE TABLE `catalog_product_option`;
TRUNCATE TABLE `catalog_product_option_price`;
TRUNCATE TABLE `catalog_product_option_title`;
TRUNCATE TABLE `catalog_product_option_type_price`;
TRUNCATE TABLE `catalog_product_option_type_title`;
TRUNCATE TABLE `catalog_product_option_type_value`;
TRUNCATE TABLE `catalog_product_super_attribute`;
TRUNCATE TABLE `catalog_product_super_attribute_label`;
TRUNCATE TABLE `catalog_product_super_attribute_pricing`;
TRUNCATE TABLE `catalog_product_super_link`;
TRUNCATE TABLE `catalog_product_enabled_index`;
TRUNCATE TABLE `catalog_product_website`;
TRUNCATE TABLE `catalog_product_entity`;
TRUNCATE TABLE `cataloginventory_stock`;
TRUNCATE TABLE `cataloginventory_stock_item`;
TRUNCATE TABLE `cataloginventory_stock_status`;
insert  into `catalog_product_link_type`(`link_type_id`,`code`) values (1,'relation'),(2,'bundle'),(3,'super'),(4,'up_sell'),(5,'cross_sell');
insert  into `catalog_product_link_attribute`(`product_link_attribute_id`,`link_type_id`,`product_link_attribute_code`,`data_type`) values (1,2,'qty','decimal'),(2,1,'position','int'),(3,4,'position','int'),(4,5,'position','int'),(6,1,'qty','decimal'),(7,3,'position','int'),(8,3,'qty','decimal');
insert  into `cataloginventory_stock`(`stock_id`,`stock_name`) values (1,'Default');

(thanks to Mike Smullin on the Magento Forums for this query!)

Whats planned? I am also going to be attempting to apply the same method for importing X-Cart customer data into Magento. As well as making product options and categories importable as well.

There is a good thread on importing product’s in Magento’s community discussing this topic as well.

Magento Commerce Tips

Magento Commerce Logo

Since I’ve started customizing MagentoCommerce about a year ago, here’s a few tricks I’ve learned to help further development and general operations.  I don’t claim to be a Magento Expert by any means but some of this information I had to dig long and hard before finally finding a resolution to the issues I was having.
  1. Can’t find where to edit email templates that are generated by Magento? There is a great article posted up on Magentos Wikipedia on how to Edit the E-mail templates.
  2. Wouldn’t it be nice if you could actually display what template files are making up the current Magento page you are viewing? Well you can!  Under the Admin area -> System -> Configuration.  Select the “Current Configuration Scope:” to the left.  <- This is an important step to get to this feature.  After you have selected the Store of your choice proceed to the “Developer” Subsection to the left you’ll notice a “Template Path Hints” field with a drop down to enable/disable it.  Enabling this will cause Magento to display what .phtml or template files make up any particular page.  This really helps speed up time when it comes to customizing Magento’s theme or adding functionality.
  3. When using MagentoConnect ALWAYS do a full site backup, including all files and database dumps, I know the docs mention this quite a bit but I have completely toasted Magento before by simply trying to update Magento to its latest release.  The biggest issue I have seen with using MagentoConnect is sometimes files and/or directories are not writable by the web server.  The best approach I have found for this is to download the latest version via Magento’s site and copying the files manually.  Particularly /app/code/core/Mage/
  4. Innon-db-fix.sql can be your best friend.  From some reason, I’m not sure why but Magento will have issues with tables in the database not being the proper type, Normally MyISAM instead of InnonDB.  Using this simple SQL file can help fix “some” issues that may not seem related to it.  I’m still hunting for a definitive list of what tables should be which, but it appears the majority are InnonDB.
  5. One error that plagued me for days after an upgrade was “SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails”, The innon-db-fix.sql did NOT fix this issue for me.  After reading over Magento’s community forums there was one posting in regards to residual products and or categories, ghosts basically.  Any attempt to save new products or categories yielded this error, Thankfully this was on a development site and I was able to simple clear out the table: “catalog_category_product_index“, which resolved the issue and I re-imported the products I had entered in before this error appeared.

Hopefully this has helped someone if so, leave a comment.