View Issue Details

IDProjectCategoryView StatusLast Update
0005888OXID eShop (all versions)4.01. Database handlingpublic2015-03-09 12:01
Reporterd.bloessl Assigned To 
PriorityhighSeveritymajorReproducibilityunable to reproduce
Status closedResolutionreopened 
Product Version4.8.6 / 5.1.6 
Summary0005888: oxvarstock is not updated, when article is offline
DescriptionWe have a inactive parent and variant article and update the stock on the variant article, the oxvarstock property of the parent article is not updated.

This happens, because _onChangeUpdateStock in oxarticles.php takes the SqlActiveSnippet into account (line 4856).

When activating the article later, the oxvarstock is not updated as well and is wrong.
Steps To ReproduceSee the attached demo controller, to reproduce the problem.
TagsNo tags attached.
Attached Files
fakecontroller.php (893 bytes)   
<?php

class FakeController extends oxUBase
{

    public function render()
    {
        $oParent = oxNew('oxarticle');
        $oParent->setId('fakeparent');
        $oParent->oxarticles__oxtitle = new oxField('Fake Parent');
        $oParent->oxarticles__oxactive = new oxField(0);
        $oParent->save();

        $oChild = oxNew('oxarticle');
        $oChild->setId('fakechild');
        $oChild->oxarticles__oxparentid = new oxField('fakeparent');
        $oPrice = new oxPrice(20);
        $oChild->setPrice($oPrice);
        $oChild->oxarticles__oxstock = new oxField(0);
        $oChild->oxarticles__oxactive = new oxField(0);
        $oChild->oxarticles__oxstock = new oxField(25);
        $oChild->save();

        $oChild->oxarticles__oxactive = new oxField(1);
        $oChild->save();

        $oParent->oxarticles__oxactive = new oxField(1);
        $oParent->save();

    }
}
fakecontroller.php (893 bytes)   
ThemeAzure
BrowserAll
PHP Version5.4
Database Versionany

Activities

jurate.baseviciene

2014-09-30 16:04

reporter   ~0010203

Reminder sent to: d.bloessl

Hi,

Thanks a lot for submitting this issue, but unfortunately we can not reproduce this case. Could you please provide test case how we could reproduce on our shop without fakecontroller.php execution. We try reproduce it and with demo controller fakecontroller.php and everything seems to work like expected.

Best regards,
Jurate

d.bloessl

2014-10-13 17:33

reporter   ~0010231

Nope, it does not ;-)

1) Copy fakecontroller.php to application/controllers/
2) Run with index.php?cl=fakecontroller
3) Check the database with "SELECT * FROM oxarticles WHERE oxid = 'fakeparent' OR oxparentid = 'fakeparent';"
4) The article with OXID 'fakechild' has oxprice = 20 and oxstock = 25
5) The article with OXID 'fakeparent' has oxvarminprice = 0, oxvarmaxprice = 0, oxvarstock = 0

tadas

2014-10-30 16:47

reporter   ~0010293

this is not a bug, that's intended behaviour how shop handled article variants. To explain:
It doesn't matter if parent is active or not;
If a variant is innactive, it won't be included in oxvarstock calculation, neither in oxvarminprice, oxvarmaxprice;
If variant is active, it will be included in all those calculations;

d.bloessl

2014-10-31 15:45

reporter   ~0010298

Sure, but the values should be corrected, if the parent article gets activated.

I'm missing a recalculation of oxvarminprice, oxvarmaxprice and oxvarstock after changing the status of a parent article.

tadas

2014-10-31 15:55

reporter   ~0010299

Reminder sent to: d.bloessl

Hi,

As I tried to explain previously, if a variant is innactive, it won't be taken into oxvarstock, oxvarminprice, oxvarmaxprice calculations, and it does not matter whether the parent article is active or not. This is intended shop functionality. I hope it is a bit more clear now.

Regards,
Tadas

d.bloessl

2014-10-31 15:58

reporter   ~0010300

If you take a deeper look into that code:
The parent article is inactive.
The variant article is inactive.
The variant article gets activated.
The parent article gets activated.

Parent and variant article are active, but the information of the variant article is not stored into the parents oxvarstock, oxvarminprice and oxvarmaxprice.
That cannot be the intended functionality.

tadas

2014-10-31 18:44

reporter   ~0010302

Reminder sent to: d.bloessl

Hi,

I have looked at the fakecontroller previously and something was not quite right for me. I was wondering why stock is being set to 0, then to 25 with a single save call. Another issue was that price wasn't actually saved when used like that. I tried with oxarticles__oxprice when setting the price, and it worked, price was updated after the script execution. Since previously it was not set at all, it seemed like it isn't working like intended. Hope this helps a bit.

Regards,
Tadas

QA

2015-03-09 12:01

administrator   ~0010769

Last edited: 2015-03-18 09:26

no more feedback from reporter -> closed.