Date: Fri, 29 Mar 2024 14:28:54 +0000 (UTC) Message-ID: <558818392.19.1711722534188@fb411f308f12> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_18_13134736.1711722534187" ------=_Part_18_13134736.1711722534187 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Here you will find explanation for the architecture of AbanteCart= a> open source eCommerce, directory structure and how all subsystems intera= ct and used.
The main category you will see after opening AbanteCart distribution arc= hive is public_html. Below are the files/directories inside public_html tha= t represent AbanteCart public site directory structure. Most important dire= ctories and files are shown and linked to GitHub repository for convenience= .
NOTE, not all directories/files are covered here.
MVC AbanteC= art is built based on MVC concept. MVC stands for Model View Controller. In= AbanteCart we also introduce dispatcher to concept of MVC. Dispatcher is i= n charge of running controllers in a set order and manages parent children = processing between controllers. Fist controller in AbanteCart runs as a pag= e or response controller. Others controllers can only be included and run a= s children of above two main controllers. This is done to prevent unauthori= zed execution of controllers.
Page controller = span>- this a main parent controller that is building page content. Layout = class is loaded for this controller to build page elements based on set lay= out. See layout section
Response controller&nbs= p;- This is any first (main parent) controller that do not have a sp= ecial layout and just provide data response. Example of this controllers ca= n be AJAX response, XML Response, RSS feed, JSON, etc.
Below is the diagram to illustrate MVC process= in AbanteCart.
Children Controller:&nb=
sp;These are children controllers that can only be loaded from any o=
ther controller and can not be accessed directly from the browser. These co=
ntrollers can perform any operation, load other children controllers and pr=
ocess any template.
On start (construct), any controller loads corresponding model and language=
set that are with the same route (name) as the controller.
Model: Thes= e are the modules that handle data load and management that corresponds to = the given controller. Each controller auto-loads the corresponding model . = For instance, for controller catalog/product there will be catalog/product = model loaded automatically once the controller is loaded (initialized).
Languages and translations: A= banteCart language system is based on language translation saved in the dat= abase. Translations are grouped to sections that can represent a given cont= roller, page or section in the code. Each group needs to have unique identi= fier, for instance, product/category Initial translation entries for the la= nguages are stored in XML files that are provided at installation. After in= stallation, all translation values are transferred to the database for furt= her use in the system. XML Files are only used for initial load and resetti= ng translations to default values.
The below diagram explains the process flow fo= r the Language text depending on the action.
Database: A= banteCart is primarily set up to use the Mysql database. You can see the da= tabase structure below that can give you an idea of the types of data, tabl= es and relationships used in the application.
Below diagram shows the Database Relationship = AbanteCart 1.2:
Below diagram shows the Database Relationship = AbanteCart 2.0:
Layout: In = layout, we set a combination of elements or blocks on the given page. Block= s and elements are represented by controllers, models and views or template= s (MVC) for each instance of the block or element. Any storefront page in A= banteCart needs to have a layout. The specific layout can be set to any pag= e. If no specific layout is set the default layout will be used. The layout= can be stored in the database or set in the code. Layouts are set per temp= late and will be reloaded if a different template is selected.
Template: A= banteCart supports multiple templates for storefront and control panel. Tem= plates can be set in the settings section of the control panel. Template fi= les are loaded and processed by view class with the data loaded from model = and controller management.
Blocks: The= se are smaller scope MVC sets with separate controller, template, and/or mo= del. Blocks are elements that can appear in the template in a special locat= ion (top, bottom, left, right, center, etc). AbanteCart can have 2 types of= blocks: Static and Dynamic. Static Blocks - added in the particular part o= f the main controller code as children. Dynamic Blocks - Blocks that are li= nked to the particular placeholder and parent controller with database sett= ing of layout class. See Layout ...
Forms: In A= banteCart we introduce concept of FlexyForms, flexible way to set up forms = in the application. Using FlexyForms you can configure any type of form wit= h any type of fields quickly and hassle-free. This is very handy for creati= ng extensions and quick forms management in the admin. FlexyForms are compl= etely based on the settings loaded in the database and do not require code = adjustment. In addition to FlexyForms AbanteCart offers blend of AForm and = AHtml classes to provide unified interface to build regular forms in the co= de.
Dataset: Da= taset offer quick and worry free methods to handle data without dealing wit= h SQL and creating specific database tables. Data can be handled via easy d= ataset class methods. Dataset can be used in extensions to store relatively= small data sets that do not require extensive relationships and transactio= nal data records.
Resource Library: = AbanteCart is equipped with a flexible and convenient way to store, = manage and map media resources. The system can handle media files or any ot= her files or HTML codes that needs too have association to product, categor= y, brand or any other data resource in the application. Simple example of a= media file is image that can be mapped to one or many products or categori= es.
Extensions: AbanteCart is build based on flexibility and expandability in design. To a= llow expandability, there is an extension concept built into the core of Ab= anteCart application. This allows to add virtually any feature or service t= o AbanteCart and this is very important in current dynamically changing tec= hnology environment. Extension is a set of files and configurations that bu= ilds a plugin module. Extensions are located in one directory and all exten= sion related file are located under one directory with corresponding extens= ion name.
Caching: Ab= anteCart is set up to be fast performing eCommerce solution with optimized = resources use and execution time. To achieve great performance AbanteCart u= tilize caching of commonly used database queries and requests. Upon changes= in this areas in the control panel the cache for this section is automatic= ally reset.
Messages: A= banteCart equipped with the notification system, that enables merchants to = get notifications about their AbanteCart eCommerce activity. These messages= are available in the control panel of AbanteCart upon login or in the mess= ages section. Messages give you dynamic information about AbanteCart update= s and upgrades, critical errors happened on your site, low stock notificati= ons and other information. To communicate the error, warning and notices to= administrator and users, AbanteCart utilise a message concept with help of= AMessage class. Primarily purpose of this class is to pass the massage to = the control panel users and make them aware of the activity and updates in = the system. This system is configurable to the user desire and easily asses= sable in the code.
Debugging: = To help and improve development process for core and extensions where is AD= ebug class available that can provide comprehensive details about the page = load and execution process. This system is configurable to the user desire = and easily assessable in the code. In addition, visual debug is available t= o help debug blocks and controllers loaded on the pages for the template.= p>
Dynamic Menus: To offer more flexibility to navigation management a number of methods = offered to control the menu item for the AbanteCart. Both Storefront and Co= ntrol Panel (admin) utilize dynamic menu system that is stored in the Datas= et. Menus can be edited at extension installation stage if particular exten= sion requires to add new page to navigation menu.
User Friendly Control Panel:&nbs= p;In the control panel (admin) of AbanteCart uses unique ap= proach to display, list and edit of the data. To list data in Control Panel= pages, AbanteCart utilise jqGrid (developed by Tony Tomov, [1] ) based on = jQuery. This approach is unified and applied on all pages that use data lis= ting. See below how grid controller can be used to manage any data in the c= art. On the edit pages of AbanterCart control panel there is a unified appr= oach to saving data. Most of the data elements can be saved individually to= bring best customer UI experience. To improve UI experience even more, all= the fields that are eddied are highlighted for convenience. User can see w= hat is edited and avoid mistakes before saving.
Data Migration: = span>AbanteCart helps existing eCommerce store owners to take advantage of = the platform and migrate to it very quick and efficient. With offered migra= tion tools, data can be transferred from third party eCommerce applications= into AbanteCart in a matter of minutes.
There is a core directory with engine and libr= ary sections in the AbanteCart architecture. These are the main components = of the AbanteCart. Engine files represent the primary functional classes th= at organize execution flow and rendering of the result. Engine processes th= e controllers, in set order with help of dispatcher and connect it together= with models and views . Libraries contain set of methods (routines) to hel= p and support control over the engine and data management. In the libraries= you can find classes that deal with processing translation (localization) = exceptions and error handling, sessions, debugs, database and much more. We= intend to keep AbanteCart with unified, clean and easy to use interface to= all the engine classes and libraries. Functions are named base on their in= tention and produced result. In addition to standards, we also focus on pro= viding flexibility and robustness to the interface. Data can be managed wit= h direct access or via interface methods or with batch XML Load.
How controllers interact. There is always a ma= in controller present in AbanteCart on every page load or request. Only 2 t= ypes of controllers can be loaded. These are page and response controllers.=
Page controller - this a main parent controlle= r that is building page content. Layout class is loaded for this controller= to build page elements based on set layout. See layout section
Response controller - This is any first (main = parent) controller that do not have a special layout and just provide data = response. Example of this controllers can be AJAX response, XML Response, R= SS feed, JSON, etc.
Other controllers are children for the above t= wo main controllers. Children can be included statically in the code or wit= h use of dynamic layout system loaded from the database. Dynamic layout sys= tem is only available for page controllers and organize elements to be disp= layed on the page and controllers to be loaded for that. Children controlle= rs are processed in the order they assigned and return display result the t= he parent controller. This can be imagined as building Lego, where each pea= ce is a controller that is processed individually and put together by dispa= tcher class into final Lego puzzle.
$this->addChi= ld('common/menu', 'menu', 'common/menu.tpl');
Dynamic controllers can be added with appropri= ate addition to the layout_block database that is explained later in extens= ion section.
In addition to children controllers you can re= quest dispatcher to run a new controller that can be executed separately. M= ain difference from child controller is in the way it is ran. Newly dispatc= hed controller can accept arguments and most important it can be run with c= aller controller terminated. This can be done as redirect to different cont= roller or page. You can dispatch new controller and capture the output pass= ing it back to prior caller or just use the output internally. See examples= :
public function = main() { =E2=80=A6. //Instantiate new dispatch $new_dispatched_controller =3D $this->dispatch('common/template_debug', = array()); return $new_dispatched_controller; //After return new controller will be run and we exit the current one. }
public function = main() { =E2=80=A6. //Instantiate new dispatch $new_dispatched_controller =3D $this->dispatch('common/template_debug', array( =09=E2=80=98arg1=E2=80=99 =3D> =E2=80=98value=E2=80=99, =09=E2=80=98arg2=E2=80=99 =3D> =E2=80=98value=E2=80=99 )); $output =3D $new_dispatched_controller->dispatchGetOutput(); }
Global structures (classes, fun= ctions) and how and where to use them. AbanteCart utiliz= e one central location (registry) for all global structure and class instan= ces. Registry is automatically available in controllers (set in based contr= oller class) and can be accessed with $this->registry . If you use some = other non-controller file you can get local instance of the registry with l= ine below:
$this->registry =3D Registry::getInstance();
To= have shorter access (from $this->registry->document to $this->doc= ument ) you can add below =E2=80=9Cmagic=E2=80=9D functions.<= /span>
public function = __get($key) { return $this->registry->get($key); } public function __set($key, $value) { $this->registry->set($key, $value); }
Other global classes that are part of the regi= stry:
This class stores data for head of the current= page. Using this class methods you can manage meta tags and breadcrumbs. C= heck ADocument class for available methods. All data set in the ADocument c= lass is store throughout execution and set to display at the end. Thus, thi= s data can be effected in any controller.
$this->document, $this->registry->do= cument
This is the class that provides access and con= trol to the session data Example:
$this->se=
ssion or $this->registry->session $this->s=
ession->data['stored_data']
This is the class that provides access to the = request data and contains sanitized $_GET, $_POST, $_COOKIE, $_FILES and $_= SERVER
$this->request or $this->registry->r= equest
Class containing extensions details on running= AbanteCart
$this->extensions or $this->registry-&g= t;extensions
ALoader class provides interface to load model= s, language modules, configurations, etc. Once loaded data made available a= nd accessible in global structures.
$this->load or $this->registry->load=
Global access to HTML interface is provided to= build and display HTML elements.
$this->html or $this->registry->html=
Global access to configuration values. These a= re settings loaded for selected store id (0 store by default)
$this->config or $this->registry->co= nfig
Global access to database interface. Connectio= n is already established in class constructor
$this->db or $this->registry->dbGlobal ALog class with interface to write to A= banteCart log file
$this->log or $this->registry->log= pre>Global ALayout class with interface and data a= ccess to current page layout. This is used for storefront pages layout cons= truction.
$this->layout or $this->registry->la= youtIn controller=E2=80=99s local data and structu= res, there is an automatic access to all registry global objects listed abo= ve. In addition, there are local objects that can be automatically accessed= once base controller class is extended.
AView class that is in control of building the= final output of current controller.
$this->viewThis is a unique instance ID for a given contr= oller. Since there is a possibility of same controllers be loaded and run i= n the same page multiple times, we need to identify each controller unique = instance. This instance ID is set on controller class creation with ->ne= w() method.
$this->instance_idThis is aa access to route string that identif= ies the name (rt) for the given controller. The route (rt) is also a partia= l directory path to the controller. It looks like this: pages/catalog/produ= ct
$this->controllerIn case of nested controllers, we need to iden= tify child to parent relationship. Most controllers are children to some ma= in controller (page or response). This variable contains reference to paren= t controller object. This way children can have access to some interface an= d data of parent controller. This can be used to pass common parent control= ler data to all children . If you have data set up in parent controller wit= h public scope, it will be available for children.
$this->pa= rent_controller$variable=3D $this->parent_contr= oller->data[=E2=80=98variable_name=E2=80=99];
This is an array with all children references = for given controller. Last child controller will not have any children cont= rollers.
$this->children
See values in arrays or classes<= /span>To se= e detailed of any variable, array or class instance, you can use built-in e= cho_array(); function. Careful to echo full registry or nested structure as= it can stole your browser. You can use debug methods to save output to fil= e.
AbanteCart offers a sophisticated mechanism to handle errors and debug c= ode. Error handling controlled in admin -> system -> settings . Click= System tab - here you have controls for error logging, debug info and debu= g level Following settings is available:
Display Errors:
Log Errors
Show Debug Info
Level 0 - no logs , only exception errors
Level 1 - errors and warnings
Level 2 - #1 + mysql site load, php file execution time and page element=
s load time
Level 3 - #2 + basic logs =
and stack of execution
Level 4 - #3 + du=
mp mysql statements
Level 5 - #4 + inter=
mediate variable
Depending on these settings you are able to= track program flow If you want to debug some piece of code, you should sur= round it with checkpoint functions.
AC_Debug::checkp= oint('dev_checkpoint start'); . . some code . . AC_Debug::checkpoint('dev_checkpoint end');
On dev_checkpoint end you could see somethi= ng like this:
Example of debug level 4 checkpoint:= strong> - Memory: 7,872 (1,752,352) - Files: 0 (44) - Que= ries: 2 (9) - Time: 0.0032 (0.0111) Time File Line SQL 0.00076 Z:\home\proj= ects\www\ac\core\lib\language.php 98 SELECT * FROM language where code=3D'e= n' 0.00058 Z:\home\projects\www\ac\core\lib\currency.php 13 SELECT * FROM c= urrency These means that - program allocate 7,872 bytes of memory since pre= vious checkpoint ( total 1,752,352 bytes ) - included 0 files since previou= s checkpoint (total 44 included) - run 2 sql queries - spent 0.0032 sec on = execution and below you see sql queries with info file, line etc.
There are 3 classes to work with errors&=
nbsp;
AException - use it in case of fatal error. execution is terminated in this=
case AError - use it in case you want to let user know that there is an er=
ror, but it is not fatal AWarning - use it to warn user
throw new AC_Exc= eption(AC_ERR_LOAD, 'Error: Could not load library ' . $library . '!');
AC_ERR_LOAD - an error code, mean problem with loading some resources Yo= u could find all error codes in core/lib/exceptions/exception_code.php = ;
Exception message will be either logged or saved for display. User will = be redirect to /error/index.php - separate section with minimal class inclu= des.
AError class has methods - toDebug - add msg to deb= ug log - toLog - write to log - toMessages - add to AbanteCart messages sys= tem - toMail - mail error message to store owner
$err =3D new AEr= ror( $msg, $code ); $err->toDebug()->toLog(); // or just $err->toD= ebug();
Code is an optional parameter and needed to= describe message title You could find all error codes in core/lib/exceptio= ns/exception_code.php In extension we could add new code error and add erro= r description like
define('AC_ERR_A= DDON', 9900 ); $error_descriptions[AC_ERR_ADDON] =3D 'some addon error';
AbanteCart offers message class that can handl= e information (massages) passed to the next page (result page) or stored to= the database to be recorded and passed to control panel users and store ad= mins. Admins can see messages and manage them in the control panel of Abant= eCart. Messages can be of 3 types, Critical, Warning and just informative o= r notice Message class can be instantiated at any part of application code = and extensions.
$registry->set('messages', $messages);later on you can access it via registry object= Message class has following methods - saveNotice($title, $message) - saveW= arning($title, $message) - saveError($title, $message) these methods add me= ssage to db for further display
- saveForDisplay($title, $message, $status) - add message to session to dis= play on page reload
you can use it as following:// if you do not= have access to registry - get it // in controllers you can access messages like - $this->messages $registry =3D Registry::getInstance(); $messages =3D $registry->get(=E2=80=98messages=E2=80=99); $message->saveNotice(=E2=80=98Some notice=E2=80=99, =E2=80=98message tex= t=E2=80=99);Suggestions to use: Say you need to notify sto= re admin of critical errors happened during checkout. Below is the example = what you do:
//for us= e in controller $this->messages->saveError(=E2=80=98Checkout error=E2= =80=99, =E2=80=98message text=E2=80=99);If the form submit encounter and error you can pass the message to the n= ext leading page.
example/** * save notice * * @param $title - string - message title * @param $message - string - message body * @param $status - message status ( N - notice, W - warning, E - error= ) * @return void */ // in this case message will be added to session message pool and shown on = page reload $this->messages->saveForDisplay($title, $message, $status)
Below diagram show error, warning and message relation and flow:
Related pages
There are no items with the selected labels at this time.