Add custom sortation to catalog/lists with ElasticSearch
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: Add custom sortation to catalog/lists with ElasticSearch
Of course, I have a file in my extension here: config/mshop/product.php
This is the content of the file:
Code: Select all
return [
'manager' => [
'name' => 'StandardCustom',
],
];
Code: Select all
protected function createItemBase( array $values = [], array $listItems = [],
array $refItems = [], array $propertyItems = [] ) : \Aimeos\MShop\Common\Item\Iface
{
$values['.date'] = $this->date;
return new \Aimeos\MShop\Product\Item\StandardCustom( $values, $listItems, $refItems, $propertyItems );
}
When ElasticIndex is being used and I try to go into a product details page, my custom product class is not used.
Then it throws errors that I have undefined methods in my custom product item class.
Thank you for this, I will try it. If it works, I won't need to create custom product item classes.
I think that the documentation wasn't clear enough and I ended up adding it in the wrong location.
The "Item properties" section should have a note that that config should be added to the boot() method.
I can also add the details about this as a pull request on github.
Re: Add custom sortation to catalog/lists with ElasticSearch
I added this to App\Providers\AppServiceProvider::boot():
I got this error: Called unknown macro "method" on class "Aimeos\MShop\Product\Item\Standard"
I think my code is up to date (~2023.04), not sure what the problem is.
Code: Select all
\Aimeos\MShop\Product\Item\Standard::method( 'getMycolumn', function() {
return $this->get( 'mycolumn' );
} );
I think my code is up to date (~2023.04), not sure what the problem is.
Re: Add custom sortation to catalog/lists with ElasticSearch
The method name changed from "method" to "macro" two years ago:
Is there still an old reference somewhere?
Code: Select all
\Aimeos\MShop\Product\Item\Standard::macro( 'getMycolumn', function() {
return $this->get( 'mycolumn' );
} );
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: Add custom sortation to catalog/lists with ElasticSearch
Docs need to be updated with the "macro" method here:
https://aimeos.org/docs/2023.x/models/extend-managers/
https://aimeos.org/docs/2023.x/models/extend-managers/
Re: Add custom sortation to catalog/lists with ElasticSearch
Thanks, has been fixed now
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