Overriding \Aimeos\MShop\Price\Item\Standard::setValue( )

How to configure and adapt Aimeos based shops as developer
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!
EvE
Posts: 2
Joined: 22 Feb 2019, 22:48

Overriding \Aimeos\MShop\Price\Item\Standard::setValue( )

Post by EvE » 23 Feb 2019, 13:18

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:

Code: Select all

'mshop' => [
    'price' => [
        'item' => [
            'name' => 'MShopPriceItemStandardCustom'
        ],
    ]
],
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:

Code: Select all

'madmin' => [
    'cache' => [
        'manager' => [
            'name' => 'MAdminCacheManagerRedisCustom',
        ],
    ],
],
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.

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Overriding \Aimeos\MShop\Price\Item\Standard::setValue(

Post by aimeos » 23 Feb 2019, 17:34

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?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

EvE
Posts: 2
Joined: 22 Feb 2019, 22:48

Re: Overriding \Aimeos\MShop\Price\Item\Standard::setValue(

Post by EvE » 23 Feb 2019, 21:03

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.

Post Reply