I found this because a client of mine did the following (values are just examples):

- had a node (nid: 1) with sku: MODEL-X
- saved some stock information for that node
- changed that ndoe sku to: MODEL-Y
- create a new node (nid: 2) with an sku: MODEL-X
- save stock information

now, because a stock information was saved for MODEL-X as nid: 1, when the new stock information for MODEL-X, which is now nid:2 is properly updated but the nid on the stock table doesn't change.

Because the key is the SKU, node ID should also be updated in the stock table.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hanoii’s picture

Version: 6.x-2.4 » 6.x-2.x-dev
FileSize
1.06 KB

patch applied to the latest dev

TimelessDomain’s picture

Component: Stock » Code
Status: Needs work » Needs review
hanoii’s picture

I don't think #745912: Stock values lost when SKU is altered it's a duplicate, but rather a complementary issue.

hanoii’s picture

In any way, all uc_stock tagged issues should be probably be reviewed as a whole as there are quite a few related.

TR’s picture

Component: Code » Stock
Status: Needs review » Needs work

Again, this patch has a problem with database integrity. By renaming the SKUs like this you're breaking all the historical order data. This is way too simplistic a "fix". Please read my comments in #745912: Stock values lost when SKU is altered and in the other issues referenced there.

JSCSJSCS’s picture

Version: 6.x-2.x-dev » 6.x-2.4
Component: Code » Stock
Status: Needs review » Needs work
FileSize
41.48 KB

I am using v 6.x-2.4 and have seen this issue, or similar one. I simply changed the SKU of products and the stock report is now empty. I have attached a screen capture of the database table. I want to ask how to fix it now and for future reference, should I change the SKU again.

hanoii’s picture

Status: Needs work » Needs review

@TR: Sorry to take a while to address your comment, the recent one brought my attention to this issue again.

In this particular case, I don't think you lose integrity. You are indeed renaming SKU, but that's a possibility within Ubercart, if you can do it, then it has to be considered a feature and not an unwanted use case, otherwise it should have means to prevent that from happening. The problem here is that both model and nid are used as relationships but not every time (as in stock information where only sku is used to update data, but not the nid.

So there is still an integrity problem as it is, this patch tries to overcome cope with this use case in which, once you renamed the SKU (because you can), the other bits of ubercart works in the same way and cope with it. Yes, you may lose historical information (the one linked by nid and model, not the one linked only by model assuming you create the same model on a different node), but ubercart will still working as you expect "from now on", otherwise it doesn't.

Status: Needs review » Needs work

The last submitted patch, 1011068-update-nid-on-stck-update.patch, failed testing.

hanoii’s picture

Status: Needs work » Needs review

are tests working for modules? how do we make the testbot ignore patches?

JSCSJSCS’s picture

Is this the patch I need for my issue? I can enter manually.

TR’s picture

Version: 6.x-2.4 » 6.x-2.x-dev
TR’s picture

Issue tags: -uc_stock

Status: Needs review » Needs work

The last submitted patch, 1011068-update-nid-on-stck-update.patch, failed testing.