Yvler wrote:As I told in another post, we're trying to rewrite the admin panel.
Offering an admin interface suited for the specific needs is always a good thing. Our plan is still to offer a REST interface to ease that task.
Yvler wrote:Is there an easy way (à la Laravel way) to receive a list (for example of products, categories, ...) of items?
Is there another way to save and update them, or create them? Or do we just do the standard Laravel stuff and write to the database?
The principles are more or less similar but Aimeos provides a much better suited interface tailored for e-commerce applications to the data than just accessing the records. Unfortunately, tutorials for this are still missing but the methods are fully documented in the source code.
In Aimeos managers are responsible for creating, saving, deleting and searching items. The items are more or less containers for the records with a bit intelligence while the managers know how to create and handle them. Each domain (e.g. catalog, product, text, attribute, etc.) has its own manager (maybe with sub-managers) and items. As a rule of thumb, each table in the database is governed by a manager or sub-manager.
All managers share a common interface:
searchItems() is the most powerful method and I have to explain it a bit more. You can add condition and sorting rules for each search as well as the domains associated items should be fetched too. For example:
Code: Select all
$context = app( '\Aimeos\Shop\Base\Context' )->get(); // necessary context with required depencencies
$manager = MShop_Factory::createManager( $context, 'product' ); // 'product/list' would return the product list sub-manager
$search = $manager->createSearch(true);
$expr = array(
$search->compare( '=~', 'product.code', 'demo-' );
$search->compare( '==', 'product.list.domain', 'text' );
$search->compare( '>=', 'product.list.datestart', '2000-01-01 00:00:00' );
$search->setConditions( $search->combine( '&&', $expr ); // AND operator, || -> OR operator
$search->setSortations( array( $search->sort( '+', 'product.id' ); // + -> ascending, - -> descending
$search->setSlice( 10, 50 ); // start at position 10, 50 entries
$total = 0;
$result = $manager->searchItems( $search, array( 'text' ), $total ); // last two parameters are optional
This would fetch the product items whose code starts with "demo-" and which have at least one text item associated that is available after year 2000. The are ordered by product ID and the items at position 10 to 60 are returned which the associated text items available via "$item->getRefItem( 'text', ... );". The $total parameter contains the number of total items that are available for that search.
The list of conditions is described in the Wiki: http://aimeos.org/docs/Developers/Conditions_for_searching
How to fetch bunches of items efficiently is also described there: http://aimeos.org/docs/Developers/Fetch_records_in_bunches
The available search keys for each manager are described in the managers, e.g. for the product manager: https://github.com/aimeos/arcavias-core/blob/master/lib/mshoplib/src/MShop/Product/Manager/Default.php
For the categories, the same principles apply but the catalog is a tree so it contains an addition method getTree() that returns a tree of nodes independent of how the tree is stored in the database.
What else do you need to know?