Help for integrating the Laravel package
Forum rules: Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
#5117 by aimeos
27 Nov 2017, 12:36
You can use the searchItem() method of the product manager to get all products:
https://aimeos.org/docs/Developers/Library/Managing_items#Search_items

To retrieve associated items like texts, prices, attributes, etc. pass the list of domain names you need as second parameter. This does also work for getItem():
Code: Select all$manager->searchItems( $criteria, ['text', 'price', 'media', 'attribute', 'product'] );


You can limit the returned products by conditions:
https://aimeos.org/docs/Developers/Conditions_for_searching

And you need to do that efficiently and not thousands of products at once:
https://aimeos.org/docs/Developers/Fetch_records_in_bunches
#5121 by MirkoPinna
27 Nov 2017, 14:07
Thank you, i did try the following code but returns me an empty array.
Code: Select all//First get the context
      $context = App::make('\Aimeos\Shop\Base\Context')->get(TRUE);

      //Obtain the manager for products
      $this->orderManager = \Aimeos\MShop\Factory::createManager($context, 'product');

      //Create the search for retrieve the orders
      $search = $this->orderManager->createSearch();
      $search->setConditions( $search->compare('==', 'product.siteid', $siteID));
      $products = $this->orderManager->searchItems($search, ['text', 'price', 'media', 'attribute', 'product'] );
#5131 by aimeos
27 Nov 2017, 22:04
You must not use the "siteid" key for searching because it's already added from the locale object!
In your example, this leads to SQL queries like "siteid=1 AND siteid=2" if your siteid value is different from the locale site ID and therefore to empty results.

If you implement a Laravel command, you have to add a locale item yourself using the bootstrap() method of the locale manager: https://aimeos.org/docs/Laravel/Extend_Aimeos
#5140 by MirkoPinna
28 Nov 2017, 09:33
Thank you now it works, but i cannot get media and price anyway.
this is what i get:
Code: Select all[13] =>
 Aimeos\MShop\Product\Item\Standard Object (
    [values:Aimeos\MShop\Product\Item\Standard:private] => Array (
       [product.id] => 13
       [product.siteid] => 8
       [product.typeid] => 1
       [product.code] => test1
       [product.label] => Product VENDOR 1
       [product.config] => Array ( )
       [product.datestart] =>
       [product.dateend] =>
       [product.status] => 1
       [product.ctime] => 2017-10-20 07:56:33
       [product.mtime] => 2017-11-24 10:01:24
       [product.editor] => super@botteega.com
       [product.target] =>
       [product.type] => default
       [product.typename] => Article )
    [propItems:Aimeos\MShop\Product\Item\Standard:private] => Array ( )
    [refItems:Aimeos\MShop\Common\Item\ListRef\Base:private] => Array ( )
    [listItems:Aimeos\MShop\Common\Item\ListRef\Base:private] => Array ( )
    [sortedLists:Aimeos\MShop\Common\Item\ListRef\Base:private] =>
    [bdata:Aimeos\MShop\Common\Item\Base:private] => Array (
       [product.id] => 13
       [product.siteid] => 8
       [product.typeid] => 1
       [product.code] => test1
       [product.label] => Product VENDOR 1
       [product.config] => Array ( )
       [product.datestart] =>
       [product.dateend] =>
       [product.status] => 1
       [product.ctime] => 2017-10-20 07:56:33
       [product.mtime] => 2017-11-24 10:01:24
       [product.editor] => super@botteega.com
       [product.target] =>
       [product.type] => default
       [product.typename] => Article )
    [prefix:Aimeos\MShop\Common\Item\Base:private] => product.
    [modified:Aimeos\MShop\Common\Item\Base:private] => )
#5151 by aimeos
28 Nov 2017, 22:26
Does the items have media and prices in the site you are using in the locale item?