Jump to content


Photo

Multiple Storefronts Off The Same Database


  • Please log in to reply
12 replies to this topic

#1 David Frost

David Frost

    Avactis Support Engineer

  • Administrators
  • PipPipPipPip
  • 144 posts

Posted 15 December 2009 - 10:54 AM

Hello dear webmasters! This may be a somewhat hidden feature (and it's not in much use) but Avactis actually does support multiple storefronts. In this post I'll do my best to show you how it works.

First off, here's the process of a store page generation:

When your browser opens one of Avactis store pages, the first thing that's happening is that your web server includes (reads and executes) init.php. That's of course because <?include("init.php")?> is (and should be) the first line of every Avactis storefront file.

Now, if you look into init.php, you will see that it does just two things:

1. Sets the name of the layout file that will be used during generation of this page;

2. Includes (loads and executes) avactis-system/store.php which starts system initialization.

Then the system initializes itself. It reads configuration files, cookies (if any), connects to the database, reads settings, all the necessary data, creates core system objects, looks for available modules, and stuff like that.

Somewhere in the middle of this process it reads the specified layout file. From the settings in this file, the system learns where it should look for all the necessary files and folders: templates, categories, product pages, cart, checkout pages, customer login/password/orders pages, etc. This information is used throughout the whole system to answer 2 main questions:

a. Where to read templates to generate storefront blocks from?

b. Which pages link to from the storefront (what to put in the hrefs)?

It's also used to generate .htaccess rewrite rules for SEO URLs feature.

Then the system processes all necessary actions. For example, if you added a product to cart, the system actually updates the cart, sets variables in user session, decreases the product's stock level, adds data to reports, etc.

Note that all this stuff takes place at the very first line of the page: <?include("init.php")?>.

When all the necessary work is done, PHP continues processing the page after init.php. Most often it starts to output page header: DOCTYPE, html, head, etc.

Then it encounters an Avactis tag like <?Breadcrumb()?>. So what does it do? Not much: just calls the function Breadcrumb. This function already exists in memory, because it has been created somewhere in the process of system initialization. This function reads various variables to determine what is the current path, reads its templates from avactis-templates/catalog/breadcrumb/default/, composes the corresponding HTML code, and outputs it. Of course it generates its links according to layout file settings.

That's basically it.

So, the whole process is ruled by two files: init.php and storefront-layout.ini. They determine what is used and what is not.

To create a new storefront for the same product catalog (database), you need to do the following:

* Make a copy of the old storefront and template directory in a different location;
* Make a copy of the old storefront-layout.ini file in the same directory (avactis-layouts), under a new name;
* Edit it to specify the correct location of the new storefront files and templates;
* Edit init.php in the new storefront to specify the new layout file name.

Example:

We have a storefront at www.oldstore.com. Layout:

SiteURL = "http://www.oldstore.com/"
SitePath = "/var/www/vhosts/oldstore.com/httpdocs/"

TemplateDirectory = avactis-templates

init.php:

$layout_file_path = 'storefront-layout.ini';
include('/var/www/vhosts/oldstore.com/httpdocs/avactis-system/store.php');

I want to make a new store at www.newstore.com with a different design.

I create a new domain newstore.com.

I copy all .php files, storefront-files and avactis-templates directories from /var/www/vhosts/oldstore.com/httpdocs/ to /var/www/vhosts/newstore.com/httpdocs/

I copy storefront-layout.ini to newstore-layout.ini
(it is done in oldstore.com/httpdocs/avactis-layouts/)

I edit newstore-layout.ini:

SiteURL = "http://www.newstore.com/"
SitePath = "/var/www/vhosts/newstore.com/httpdocs/"

I edit newstore.com/httpdocs/init.php:

$layout_file_path = 'newstore-layout.ini';
include('/var/www/vhosts/oldstore.com/httpdocs/avactis-system/store.php');

That's it.

When your browser opens www.newstore.com, the first line of index.php includes init.php, which sets layout to newstore-layout.ini, which sets templates and other files to newstore.com, and uses the system from oldstore.com.

You should always access Admin Area from oldstore.com.

You may also rename avactis-templates to just templates and reflect this change in layout.ini. Or rename any file listed there as well.

Having several .ini files in avactis-layouts will make your admin area display several "Storefront" links and several sections of settings (for each storefront) in several places.

I would like to emphasize: this feature is experimental and you may encounter bugs. Please don't hesitate to contact us to resolve any.
David
Avactis Support Team

#2 wbd

wbd

    Expert

  • Members
  • PipPipPipPipPip
  • 235 posts

Posted 28 May 2010 - 08:27 AM

Hello David, thank you for taking the time to share this information. I see that this document is based on v1.8.x of the Avactis Shopping Cart. Is it possible to update (or publish a new post) so that it reflects the current v1.9.1 Avactis Shopping Cart? Alternatively, is there documentation already available which describes how to achieve this functionality for the current version?

#3 David Frost

David Frost

    Avactis Support Engineer

  • Administrators
  • PipPipPipPip
  • 144 posts

Posted 28 May 2010 - 09:37 AM

Now that the root .php files do not contain that dirty HTML anymore :) the process is still the same: system initialization, then processing all tags on a page. The tags just aren't taken from the page itself but rather from the corresponding section of map.ini. So the process isn't much different.
David
Avactis Support Team

#4 brewster

brewster

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 21 June 2010 - 07:37 PM

Hi David, Is this possible if stores are on 2 different servers? ie one in Australia and the other in the US

#5 Ilya Vassilevsky

Ilya Vassilevsky

    Avactis Support

  • Administrators
  • PipPipPipPip
  • 198 posts

Posted 26 July 2010 - 11:23 AM

No, no way to do this remotely, only on the same server.

#6 Lavern

Lavern

    Expert

  • Members
  • PipPipPipPipPip
  • 306 posts

Posted 11 August 2010 - 04:44 PM

Does this require more than one license? And when I use one installation for two storefronts, they share the same customer list and settings under Store Settings > Customer Account Settings, right? I have two installations of Avactis on the same domain (one is on a subdomain) because we want to have a retail and a wholesale site. The wholesale storefront requires that an admin verifies customer accounts before they can purchase. I don't think I can do this with one installation of Avactis, but I am wondering if it's possible to use one Avactis license for these two installations since they both sit on one domain. That is probably a silly question, but I just wanted to check.
Lavern Gingerich
New Creation Designs
Website and Graphic Design Services

#7 Ilya Vassilevsky

Ilya Vassilevsky

    Avactis Support

  • Administrators
  • PipPipPipPip
  • 198 posts

Posted 11 August 2010 - 06:43 PM

Dear Lavern, You can't use a single license for both stores because technically they are 2 separate installations, with 2 different databases. The method described by David allows creation of different "faces" of the same installation - single database, product catalog, customer list. Equal prices. So far, Avactis does not support customer groups with different pricing for each group, so your setup is not possible with a single installation of Avactis. Please ask more questions and don't be afraid of their nature. It is always better to over-explain :)

#8 Lavern

Lavern

    Expert

  • Members
  • PipPipPipPipPip
  • 306 posts

Posted 12 August 2010 - 07:18 AM

Thanks for your kind help, Ilya.
Lavern Gingerich
New Creation Designs
Website and Graphic Design Services

#9 Tom S

Tom S

    Novice

  • Members
  • PipPip
  • 12 posts

Posted 20 September 2010 - 12:49 AM

did not know this till now. thanks!

#10 peteVA

peteVA

    Devotee

  • Members
  • PipPipPipPip
  • 102 posts

Posted 22 September 2010 - 05:52 PM

Would this work for setting up affiliates each with their own "home" page? They could have their own "welcome to Marys shop", welcome to Janes shop, etc. while in reality it's all one deal. They would simply direct traffic to "their" cart which would also have their affiliate code embedded.

#11 BoL

BoL

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 09 November 2010 - 01:28 AM

Dear Lavern,

You can't use a single license for both stores because technically they are 2 separate installations, with 2 different databases.

The method described by David allows creation of different "faces" of the same installation - single database, product catalog, customer list. Equal prices.

So far, Avactis does not support customer groups with different pricing for each group, so your setup is not possible with a single installation of Avactis.

Please ask more questions and don't be afraid of their nature. It is always better to over-explain :)


Any update on this question of multistore functionality?

Here is our situation: We are looking to have multiple storefronts at different domains that offer different selections of products from the same database (e.g., one master store would have all products, but then there may be a separate domain (or subdirectory) that is specialized and only offers some of the products. As far as I can tell from the initial post in this thread, this should be possible, but I don't see any clear confirmation of this. I understand that each may need its own license, but I am not sure as they will share a database - can you clarify this?

Thanks for your input.

#12 Ilya Vassilevsky

Ilya Vassilevsky

    Avactis Support

  • Administrators
  • PipPipPipPip
  • 198 posts

Posted 09 November 2010 - 10:33 AM

Unfortunately, we cannot guarantee stable operation of Avactis with multi-domain setup. You can try it out, and there's a high chance that it'll work, but there is no guarantee. We plan to do a major rewrite of URL-mapping subsystem, with multi-domain in mind, in Avactis 3.0 only. Avactis 2.0 due to be released very soon, has native support for multiple customer groups. You will be able to set different prices for each group and hide any products from any groups. Update from 1.x to 2.0 will be ready ASAP - somewhere in December.

#13 zorgster

zorgster

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 27 February 2012 - 12:13 PM

Hi

I have successfully created a multistore - a second front running off the same backend database - using Avactis 2.1.1

I copied the main root php files, and the themes folder. I had trouble with the page not loading... and I ended up copying a lot of the admin folder over, admin/modules, admin/core, admin/conf, created a new cache and backup folder under admin.. ajax_actions_maps... basically almost a reproduction of the avactis-system folder.

I copied and renamed the layouts.ini ... and edited the Store Path within that... as was suggested above.

I was still having trouble with the site not loading past a few lines - part of the header etc - and tried so much to fix - looking at the templates and so on.. I couldn't figure it out... until I simply deleted the new store's cache folder and then everything came online... so if you are having trouble setting up the store and you've tried everything, maybe just delete the contents of the cache folder - just in case...

Once the new store was up and running, I can see Storefront 1 and Storefront 2 buttons in Admin. On some pages I can see a few more doubled entries for the two layouts.

I cannot edit pages in Page Manager ... for that I had to load up admin from the other domain... and edit the layouts from that admin interface... I also had to be careful that I didn't edit our 'Welcome Text' on one, because it is global content.... I had to create a new set of content and menus for the new storefront... then work through all the pages in page manager (from admin in the new domain) and set the menus to the copied version... and set the content to the copied content.

Once that is done, there is no daily need to enter Admin from the new domain. You can alter the Products and Categories using the main admin interface and the content is pulled from one single database...

Another requirement I have was that users registering on the new website, were added into a new Customer Group.

This requires a modification at code level...

<pre><code>
function addAccount($account, $password, $aff_id="", $group_id=2)
{
global $application;
$tables = $this->getTables();
$customers_table = $tables['ca_customers']['columns'];

$query = new DB_Insert('ca_customers');
$query->addInsertValue($account, $customers_table['customer_account']);
$query->addInsertValue(md5($password), $customers_table['customer_password']);
$query->addInsertValue($aff_id, $customers_table['affiliate_id']);
$query->addInsertValue(modApiFunc('MultiLang', 'getLanguage'), $customers_table['customer_lng']);
$query->addInsertValue(modApiFunc('MultiLang', 'getLanguage'), $customers_table['notification_lng']);
$query->addInsertValue($group_id, $customers_table['group_id']);
$application->db->PrepareSQL($query);
return $application->db->DB_Exec();
}
</code></pre>

On one storefront I have set the default value of $group_id to 1 and on the other to 2... Ideally I could then add $group_id to the RegisterCustomer code... and then to the HTML_Form ... etc... and perhaps add it in as a hidden field to a template...

I have edited Product List on both stores to point to a SubCategory below Home. So products assigned to one store can be kept separate from Products in the second store. Visitors in either store could be directed to the other store and the purchases would all use the same Cart... my client packs all Products from the same location anyway... All Product Types can also be assigned to a specific Customer Group. Ideally I would like to remove 'Home' from the Breadcrumbs... but I've set the Home category to only show items in the Home category, which should prevent users from seeing products they shouldn't see.

So for now I appear to have two storefronts, running off the same backend product/category/user database.

I have yet to test making an order, and paying through WorldPay - because the callback for WorldPay will be sent to the primary domain... ? I presume the orders will all be managed from the primary admin interface still... Or does the callback that I send, take precedence over the callback set for the WorldPay installation...

If anyone has a difficulty setting it up, I'll try to give a clearer answer regarding how I achieved it.

Oliver