PDA

View Full Version : MM4 module question


RayYates
05-20-08, 06:11 PM
When is Module_Upgrade_Store() called?

aGorilla
05-20-08, 06:19 PM
When you have a module in a store, and you upload a new copy, with a higher version number.

RayYates
05-20-08, 06:34 PM
OK next question. It seems that Import modules do not require or call Module_Install_Store() since it is never explicitly "assigned".

Soooo, what function should I be using when the module is installed to initialize its data files. Module_Install() perhaps?

aGorilla
05-20-08, 06:40 PM
That should work. Just remember that's a 'mall level' function, so you'll probably want to install for all stores, since the import is done on a store level.

Kent Multer
05-20-08, 06:40 PM
This could be considered a bug, or at least a design flaw, in Merchant. Module_Install is called when you first put the module in your Merchant domain, so it's not appropriate to use it for individual store setup in a multi-store domain.

The work-around that some of us use is to create a function equivalent to Module_Install_Store, and have the module call it at the beginning of the ImportModule_Screen function. Of course, there has to be conditional code to make sure it only runs the first time it's called, e.g. by checking whether the databases already exist.

Uninstalling can also be a bit complex; you can probably figure out that part for yourself :^) .

MichaelBrock
05-20-08, 08:25 PM
Along the lines of what Kent said, I personally think that the way the import and export modules were implemented was not well thought out. They assumed that any particular import or export module should be available to all stores and did not need the module_install_store() and module_upgrade_store() functions. I have a few modules which are officially of type "import" or "export" but I try to make them utility modules. Taking the approach Kent mentioned of calling your own upgrade and install functions works, but it's more consistent to stick to the "usual" way to go about it.

RayYates
05-22-08, 06:23 AM
Thanks gentlemen. At first I attempted to make this and dual utility import module and realized this was just more complex than it needed to be so I ended up using module_install() and module_uninstall() making it available to all stores. Since this is a one of kind custom program, it's fine.

My initial confustion was in not realizing that import modules install on the domain level