Admin rebuild : getting/creating/updating data
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Re: Admin rebuild : getting/creating/updating data
Yes, it is. The code base has been rewritten to PSR-4 compliance (namespaces) and all former class names are now prefixed by "\Aimeos\" and underscores (_) have been replaced by backslashes (\). A full list of breaking changes is available in the developer section: https://aimeos.org/docs/Developers/ChangelogChaeril wrote: I keep getting error 'Class 'MShop_Factory' not found' is it changed in ~2016 or i missed something?
is it \Aimeos\MShop\Factory::createManager ?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Admin rebuild : getting/creating/updating data
1. if i want to find stock and / or media for product, do i need to set up another manager and submanager search?
or there is another preferred way?.
2. When do i need to use getResourceType() and getSearchAttributes();
ResourceType seems to return an array which i can loop inside createManager () although it seems to be a bad way.
still not sure with SearchAttributes.
Regards
Code: Select all
$manager = \Aimeos\MShop\Factory::createManager($context, 'product');
$search = $manager->createSearch();
$getSubManager = $manager->getSubManager('stock');
$sub_search = $getSubManager->createSearch();
...
$media = \Aimeos\MShop\Factory::createManager($context, 'media');
$s_media = $media->createSearch();
2. When do i need to use getResourceType() and getSearchAttributes();
ResourceType seems to return an array which i can loop inside createManager () although it seems to be a bad way.
still not sure with SearchAttributes.
Regards
Re: Admin rebuild : getting/creating/updating data
Media items (as well as attributes, texts, prices, etc.) are associated via the list tables. The easiest way to fetch them is along with the product item:
Afterwards, they are available via getRefItems():
More information about this methods is available in the API docs:
https://aimeos.org/api/2016/class-Aimeo ... Iface.html
https://aimeos.org/api/2016/class-Aimeo ... Iface.html
You can create the submanager for retrieving stock levels with the factory too:
getSearchAttributes() and getResourceType() are available to determine the search keys and resources automatically. Normally, you don't need to call them.
Code: Select all
$item = $manager->getItem( '<id>', array( 'media', ...) );
$items = $manager->searchItems( $search, array( 'media', 'text', 'attribute', 'price', ... ) );
Code: Select all
$mediaItems = $item->getRefItems( 'media' [, '<media type>'] [, '<list type>'] );
https://aimeos.org/api/2016/class-Aimeo ... Iface.html
https://aimeos.org/api/2016/class-Aimeo ... Iface.html
You can create the submanager for retrieving stock levels with the factory too:
Code: Select all
$manager = \Aimeos\MShop\Factory::createManager($context, 'product/stock');
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Admin rebuild : getting/creating/updating data
There's now full documentation available for how to manage items and content:
https://aimeos.org/docs/Developers/Libr ... ging_items
https://aimeos.org/docs/Developers/Libr ... ging_items
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Admin rebuild : getting/creating/updating data
Code: Select all
$json = null;
$items = $manager->searchItems($search, array('media', 'text', 'attribute', 'price'));
foreach ($items as $id => $item) {
$item = $manager->getItem($id, array('media', 'text', 'attribute', 'price'));
$temp = $item->toArray();
$temp['text'] = $item->getRefItems('text');
$temp['media'] = $item->getRefItems('media');
$temp['attribute'] = $item->getRefItems('attribute');
$temp['price'] = $item->getRefItems('price');
$json[] = $temp;
}
[0] -> ... -> [media] -> [29] -> position -> 0
i found that 29 is the id of media attached to item, should i use another manager to find preview url, or file url.
Re: Admin rebuild : getting/creating/updating data
No, but you should use the toArray() method for each item to get the key/value pairs suitable for json_encode:
More information about getRefItems() and toArray():
https://aimeos.org/api/latest/class-Aim ... Iface.html
https://aimeos.org/api/latest/class-Aim ... l#_toArray
Code: Select all
$json = array();
$items = $manager->searchItems($search, array('media', 'text', 'attribute', 'price'));
foreach ($item as $id => $item) {
$temp = $item->toArray();
foreach ($item->getRefItems() as $domain => $list) {
foreach ($list as $refId => $refItem) {
$temp[$domain][$refId] = $refItem->toArray();
}
}
$json[] = $temp;
}
https://aimeos.org/api/latest/class-Aim ... Iface.html
https://aimeos.org/api/latest/class-Aim ... l#_toArray
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Admin rebuild : getting/creating/updating data
Hi,
i am stuck with creating order, from what i understand i need to create 3 manager for each of order, order/base, and order/base/product. then save order/base, get last id and save the rest of data using .baseid
is there a transactional way to do this?
i am stuck with creating order, from what i understand i need to create 3 manager for each of order, order/base, and order/base/product. then save order/base, get last id and save the rest of data using .baseid
is there a transactional way to do this?
Re: Admin rebuild : getting/creating/updating data
You only need the order and order/base manager. The item created by an order/base manager is exactly the basket of a customer and you can save it by calling the store() method:Chaeril wrote: i am stuck with creating order, from what i understand i need to create 3 manager for each of order, order/base, and order/base/product. then save order/base, get last id and save the rest of data using .baseid
is there a transactional way to do this?
Code: Select all
$manager = \Aimeos\MShop\Factory::createManager( $context, 'order' );
$baseManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' );
$order = $manager->createItem();
$basket = $baseManager->createItem();
// ... add something to the basket ...
$manager->begin();
$baseManager->store( $basket );
$order->setBaseId( $basket->getId() );
$manager->saveItem( $order );
$manager->commit(); // or rollback()
https://aimeos.org/api/latest/namespace ... nager.html
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star