Mini Tutorial: Automatic Store Setup Wizard (Cont.)

In my last blog post, I wrote about the brainstorming process of an automatic store setup wizard.   After a few days of head scratching,  the beta version was up.

Related: Automatic Store Setup Wizard (Prototype Stage)

There isn’t much to enter on Step 1.  All I need is store and admin information.  When the user clicks submit, the following steps will be performed:

1. Create a website, store and storeview based on the store name and admin username.
2. Link the above items together.
3. Create an admin user based on admin info fields and customer data.
4. Create an user role and assign predefined access control information.
5. Config the website by using Mage::getModel(‘core/config’)->saveConfig($path,$value,$scope_type,$scope_id);
6. Set up URL, template and etc.
7. Config customer attributes to allow website information to be display on customer dashboard.
8. Create a subdirectory based on the admin username.
9. Copy the index.php and .htaccess template to corresponding subdirectory.
10. Modify the index.php to replace Mage::run($mageRunCode, $mageRunType); with Mage::run($username, ‘website’);
11. Refresh the config cache.

That’s it… a new website is created!

The next step is setting up the CMS contents.  I only have to create a location page and a homepage.

The homepage includes an “about-me” block, which use the logo picture from Step 1 and the “Store description” field.  It also includes a feature product block, which will be set up in the product selecting step.

The location page has a google map that is based on the store address and a timetable for operation hours.

The last step is product selection.  The user will select the product he/she wants to sell.   The user will also select the feature product on homepage in this column. Finally, the user may specify a mark up for the products he/she sells. When the user submits the form,  the products are updated with Mage::getSingleton(‘catalog/product_action’)->updateWebsites().  The price with a calculated mark up and “featured” attribute are updated with $product->save();

When the user completes the wizard, they can visit the site right the way.   However there is one drawback.  The product/category pages will not be available.  The reason for this is that they require Magento to be re-indexed and we can’t index on saving because there is a performance penalty.   The product shows up once the site is re-indexed.

Here are some images from the site using the wizard: