aimeos / aimeos-core

Aimeos PHP e-commerce framework for ultra fast online shops, scalable marketplaces, complex B2B applications and #gigacommerce
https://aimeos.org
Other
3.4k stars 118 forks source link

ProductPrice plugin an modified prices #183

Closed nvindice closed 4 years ago

nvindice commented 4 years ago

Hi @aimeos, we introduced a configuration option for the ProductPrice plugin in march, see #141 .

However, I'm not so sure about this anymore. At least in my setup, the setModified() method of every price object in every product gets called multiple times at every action. This would render the ProductPrice plugin absolutely useless with activated ignore-modified setting, as ultimately every price object would be "modified".

Can you please clarify my understanding of the modified flag? When does it get set without manual action?

aimeos commented 4 years ago

The "modified" flag should be set whenever a value of an object changes. You may check why the setModified() method is called, for which key and to what value. In 2019.10 and dev-master, this is rather easy because the set() method is used by all set*() methods internally: https://github.com/aimeos/aimeos-core/blob/master/lib/mshoplib/src/MShop/Common/Item/Base.php#L127-L140

nvindice commented 4 years ago

Well, IIUC even the standard implementation of loading a basket from the DB will trigger the modified flag multiple times, as it uses the set*() methods for setting up the price object: https://github.com/aimeos/aimeos-core/blob/6c3e2d3ba34b85fa49100febaa86862b0e039ebb/lib/mshoplib/src/MShop/Order/Manager/Base/Standard.php#L966-L972

What sense does the modified flag have when it is always true? Or am I missing something?

aimeos commented 4 years ago

There have been some cleanups recently to avoid setting the "modified" flag in those cases: https://github.com/aimeos/aimeos-core/commit/f4b2b009132ebca2918668dcc8beeeb1a86eb6c1

nvindice commented 4 years ago

I see. Is it okay when I refactor 2018.x alike? Or is this too much change for a LTS?

aimeos commented 4 years ago

It's too much and may have unpredictable results

nvindice commented 4 years ago

Any other ideas on how to fix the ignore-modified setting in the ProductPrice plugin for 2018.x?

nvindice commented 4 years ago

I developed a solution fitting only my current scenario using custom hidden attributes. So I'll close this issue, although it still might be an existig problem in 2018.x.