Overriding \Aimeos\MShop\Price\Item\Standard::setValue( )
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Overriding \Aimeos\MShop\Price\Item\Standard::setValue( )
Hello,
I want to override \Aimeos\MShop\Price\Item\Standard::setValue( $price ), because I need more than 2 decimals for importing prices.
I'm using Aimeos 2018.10.* with Laravel 5.5.* on Linux with PHP 7.3.1 (Homestead).
I've added the following custom class:
/ext/myextension/lib/custom/src/MShop/Price/Item/MShopPriceItemStandardCustom.php
And registered it in shop.php with:
This however does NOT work.
The same procedure however DOES work when I override the cache manager with:
/ext/myextension/lib/custom/src/MAdmin/Cache/Manager/MAdminCacheManagerRedisCustom.php
And registered it in shop.php:
My questions are:
* Why does overriding \Aimeos\MShop\Price\Item\Standard does not work?
* Is there another way to achieve my goal to override \Aimeos\MShop\Price\Item\Standard::setValue( $price ) ?
Thanks in advance.
I want to override \Aimeos\MShop\Price\Item\Standard::setValue( $price ), because I need more than 2 decimals for importing prices.
I'm using Aimeos 2018.10.* with Laravel 5.5.* on Linux with PHP 7.3.1 (Homestead).
I've added the following custom class:
/ext/myextension/lib/custom/src/MShop/Price/Item/MShopPriceItemStandardCustom.php
And registered it in shop.php with:
Code: Select all
'mshop' => [
'price' => [
'item' => [
'name' => 'MShopPriceItemStandardCustom'
],
]
],
The same procedure however DOES work when I override the cache manager with:
/ext/myextension/lib/custom/src/MAdmin/Cache/Manager/MAdminCacheManagerRedisCustom.php
And registered it in shop.php:
Code: Select all
'madmin' => [
'cache' => [
'manager' => [
'name' => 'MAdminCacheManagerRedisCustom',
],
],
],
* Why does overriding \Aimeos\MShop\Price\Item\Standard does not work?
* Is there another way to achieve my goal to override \Aimeos\MShop\Price\Item\Standard::setValue( $price ) ?
Thanks in advance.
Re: Overriding \Aimeos\MShop\Price\Item\Standard::setValue(
You can only configure alternative manager names, not item names. To use another item implementation, extend from the standard price manager, overwrite createItemBase() method and use your new item class there.
BTW: For which currency do you need more decimals? Bitcoin?
BTW: For which currency do you need more decimals? Bitcoin?
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: Overriding \Aimeos\MShop\Price\Item\Standard::setValue(
Thank you so much for your quick reply! This works.
The reason I need more decimals is because we have some very cheap products that can only be ordered in multiples of let's say 1000.
So the item price would be 0.008 (0.8 cents), but you can only order 1000, 2000, 5000, etc. of them.
The reason I need more decimals is because we have some very cheap products that can only be ordered in multiples of let's say 1000.
So the item price would be 0.008 (0.8 cents), but you can only order 1000, 2000, 5000, etc. of them.