May 17, 2012

pricing II

Filed under: ZenMagick — DerManoMann @ 10:01 am

I am very close to having the new pricing code pass all shopping cart tests. In fact, one benefit of this change is that for the first time it is possible to run a complete cart test over all products in one go.

The stats for that look something like this:
Client IP: 127.0.0.1;   PHP: 5.3.10;   ZenMagick: ${zenmagick.version};   environment: prod;   total page execution: 31.5726 secconds;
databases: zmdev(ZMDatabase): SQL queries: 23325, duration: 19.6571 seconds;
includes: 526;   memory: 63176704

Right now I do have one test randomly failing. The attributes are randomly populated (select, radio and text), so it takes a bit to log what is actually breaking things.
Still, this is a major improvement and means that ZenMagick contains all relevant pricing code – and all of that only once!
Since the checkout order instance is already populated from the shopping cart, all data is derived from a single set of business logic – yay!

Another bonus is that the shopping cart now is populated just from a simple array containing product id, quantity and attribute details of the products in the cart. In fact, this is the same data zen-cart uses.
This also means that we now can start tracking cart actions separate from zen-cart (and verify that they match). The ultimate consequence of that is native cart actions that just use ZenMagick code rather than the zen-cart cart instance internally.

Still some way to go, but a big step, nevertheless.

May 15, 2012

pricing

Filed under: ZenMagick — DerManoMann @ 5:17 am

This week I have taken another stab at improving the ZenMagick pricing code. The main reason right now is to further reduce the number of SQL queries per request. As part of the process to encapsulate zen-cart logic as much as possible there is a class ZenCartCheckoutOrder that is compatible with zen-cart. However, it is populated entirely from the ZenMagick shopping cart class.

Unfortunately, the shopping cart class itself still relies on zen-cart, so the more logic is in ZenMagick, the better, because with the internal caching in the ZenMagick service classes, all relevant data will only be loaded once and once only!

Of course, pricing is not the most trivial part of zen-cart, so getting that right is a mission and tracking down pieces of code one by one to see what is actually going on.

The good news is, that so far all common cases like discounts, attribute pricing, quantity discounts, sales and one time costs are already working. The remaining differences are all around word count issues, etc. Hopefully one more improvement to come with the next version.

To make things work reliably, there is an option to assert that calculated values are in sync with zen-cart, which makes life a lot easier…

May 3, 2012

not so weekly update

Tags: , , ,
Filed under: PHP,ZenMagick — DerManoMann @ 10:59 am

After having published a first snapshot of the upcoming ZenMagick 0.9.14 it seems time to write about what is new and shiny in the next release.

Perhaps the biggest change is that zen-cart is now loaded on demand and ZenMagick is the main request handler.

What does that mean?

It means that for example, ZenMagick is responsible for session handling. It also means that no zen-cart code is loaded unless ZenMagick allows it.

Right now that *is* still happening, as there are still some missing bits in the ZenMagick request handling. However, we are nearing the point where this is no longer the case. At that point, zen-cart will only be loaded on demand, and only the bits relevant for checking out and ordering.

As a side effect of these refactorings, we have added a number of modified zen-cart core files into a bundle (the symfony plugin system), so file patches can be obsoleted. On the other hand it means that relying on zen-cart core file patches will not be that easily possible any more.

A second major milestone is the integration of yet more symfon2 components, as can be seen in the list below.

Other, biggish changes include:

  • Full localisation support using gettext – po/mo files throughout all of ZenMagick; admin, storefront, themes and plugins
  • Support for symfony2 routing; this task is not yet complete, but I expect to have almost full coverage of storefront urls via routing
  • Simplified MVC components; again this is mostly compatible with symfony2, with the exception that controller classes always need to be declared using the full namespace (rather than a bundle name)
  • The ZenMagick template system is now implemented as a symfony2 template engine. This was a precursor for allowing Twig as alternative template engine.
  • Support for ZenMagick WISYWIG editor plugins in zen-cart admin pages
  • Skelton for a separate ZenMagick installer application
  • Separate main configuration file, independent of zen-cart’s configure.php

For a more complete list of all changes please check the roadmap for 0.9.14.