Search produc by codes
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!
- AmzoooJibal
- Posts: 35
- Joined: 12 Mar 2021, 20:09
Search produc by codes
Hello,
i dont understand why this method not working as expected:
The result is one product (demo-article) :
i dont understand why this method not working as expected:
Code: Select all
$codes = [
0 => "demo-article",
1 => "demo-selection-article-2",
2 => "demo-selection-article-1",
];
$context = $this->getContext();
$config = $context->getConfig();
$domains = [
'attribute', 'media', 'media/property', 'price', 'product', 'text', 'stock', 'supplier'
];
$domains = $config->get('client/html/catalog/domains', $domains);
$domains = $config->get('client/html/catalog/detail/domains', $domains);
$products = \Aimeos\Controller\Frontend::create($context, 'product')
->compare('==', 'product.code', $codes)
->slice(0, count($codes))
->uses($domains)->search();
dd($products);
Code: Select all
Aimeos\Map {#2844 ▼
#list: array:1 [▼
1 => Aimeos\MShop\Product\Item\Standard {#2644 ▼
-date: "2021-07-19 13:52:00"
-prefix: "product."
-available: true
-modified: false
#bdata: array:21 [▼
"product.id" => "1"
"product.siteid" => "1."
"product.type" => "default"
"product.code" => "demo-article"
"product.label" => "Demo article"
"product.url" => "Demo-article"
"product.datestart" => null
"product.dateend" => null
"product.status" => "1"
"product.ctime" => "2021-06-17 11:10:00"
"product.mtime" => "2021-06-30 15:02:05"
"product.editor" => "127.0.0.1"
"product.target" => ""
"product.dataset" => ""
"product.scale" => "1"
"product.config" => []
"product.rating" => "0.00"
"product.ratings" => "0"
".supplier" => array:1 [▶]
".stock" => array:1 [▶]
".date" => "2021-07-19 13:52:00"
]
-listItems: array:4 [▶]
-listRefItems: array:4 [▶]
-listRmItems: []
-listPrepared: false
-listRmMap: []
-listMap: []
-listMax: 19
-propItems: []
-propRmItems: []
-propMax: 0
}
]
#sep: "/"
}
Re: Search produc by codes
"demo-selection-article-1" and "demo-selection-article-2" are variant articles of a selection product and haven't been added to any category. Thus, the frontend controller don't return them as products.
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
- AmzoooJibal
- Posts: 35
- Joined: 12 Mar 2021, 20:09
Re: Search produc by codes
Ah ok thank you, in the json admin api how i can get the same rules ? when i try with this url:
How i can get like the front result ? where i can get all rules ?
Code: Select all
http://www.test.com/admin/default/jsonadm/product?filter%5B%7C%7C%5D%5B0%5D%5B%3D%3D%5D%5Bproduct.id%5D=&filter%5B%7C%7C%5D%5B1%5D%5B%3D~%5D%5Bproduct.code%5D=&filter%5B%7C%7C%5D%5B2%5D%5B%3D~%5D%5Bproduct.label%5D=&fields%5Bproduct%5D=product.id%2Cproduct.code%2Cproduct.label&page%5Boffset%5D=0&page%5Blimit%5D=25&sort=product.label&include=product
Re: Search produc by codes
To get several products by code including the domains, you need a filter like this:
Code: Select all
filter[||][0][==][product.code]=prodcode1&filter[||][1][==][product.code]=prodcode2&filter[||][2][==][product.code]=prodcode3&include=attribute,media,price,...
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
- AmzoooJibal
- Posts: 35
- Joined: 12 Mar 2021, 20:09
Re: Search produc by codes
thank you for your response.
the search is well documented in the documentation except how to filter in relation in my case how i can filter product that is attached to a category ?
as you said in frontend only the product that is attached to a category is searched, so in admin json api i need to do the same filter in product endpoint to get only the product that is attached to a category
the search is well documented in the documentation except how to filter in relation in my case how i can filter product that is attached to a category ?
as you said in frontend only the product that is attached to a category is searched, so in admin json api i need to do the same filter in product endpoint to get only the product that is attached to a category
Re: Search produc by codes
Retrieving products by category is descriped here:
https://aimeos.org/docs/latest/frontend ... y-category
https://aimeos.org/docs/latest/frontend ... y-category
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