get an array of products with it's ID and LABEL
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!
- ahmed31916
- Advanced
- Posts: 148
- Joined: 14 Apr 2022, 12:15
get an array of products with it's ID and LABEL
Hello,
How to get an array of products (or any domain) with it's ID and LABEL?
This get the Label, but how to get it's id?
something like this:
array:3 [
5 => "product1"
7 => "product2"
11 => "product3"
]
How to get an array of products (or any domain) with it's ID and LABEL?
This get the Label, but how to get it's id?
Code: Select all
->getLabel()->toArray()
array:3 [
5 => "product1"
7 => "product2"
11 => "product3"
]
Re: get an array of products with it's ID and LABEL
The product IDs are already used as keys in the array.
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
- ahmed31916
- Advanced
- Posts: 148
- Joined: 14 Apr 2022, 12:15
Re: get an array of products with it's ID and LABEL
Thanks for your reply, but maybe you didn't understand my point.
Anyway, is there a function in Aimeos similar to the "where" eloquent function that we use in Laravel?
Anyway, is there a function in Aimeos similar to the "where" eloquent function that we use in Laravel?
Re: get an array of products with it's ID and LABEL
According to your question, you requested something like:ahmed31916 wrote: ↑02 Jun 2022, 11:22 Thanks for your reply, but maybe you didn't understand my point.
Code: Select all
array(
<product ID> => '<product label>',
)
The Map object implemented where() to filter the collection:ahmed31916 wrote: ↑02 Jun 2022, 11:22 Anyway, is there a function in Aimeos similar to the "where" eloquent function that we use in Laravel?
https://php-map.org/#where
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
- ahmed31916
- Advanced
- Posts: 148
- Joined: 14 Apr 2022, 12:15
Re: get an array of products with it's ID and LABEL
I wanted array with id and label for sub categories to use it in ajax for main category.
Using getLabel function: " ->getLabel()->toArray()", it get an array with sub categories without id.
When things get tough I used query builder, and it meet the purpose. Thanks.
Using getLabel function: " ->getLabel()->toArray()", it get an array with sub categories without id.
When things get tough I used query builder, and it meet the purpose. Thanks.
Re: get an array of products with it's ID and LABEL
The IDs of the objects are always the keys of the arrays when you get back the collection from the storage.
If you transform data and it's not the case any more, you can always use the "col()" method to rekey the collection, e.g. for a collection of categories:
If you transform data and it's not the case any more, you can always use the "col()" method to rekey the collection, e.g. for a collection of categories:
Code: Select all
$collection->col( null, 'catalog.id' )
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