Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#6 | stockdb.png | 41.48 KB | JSCSJSCS |
#1 | 1011068-update-nid-on-stck-update.patch | 1.06 KB | hanoii |
Comments
Comment #1
hanoiipatch applied to the latest dev
Comment #2
TimelessDomain CreditAttribution: TimelessDomain commentedduplicatecomplimentary issue #745912: Stock values lost when SKU is alteredComment #3
hanoiiI don't think #745912: Stock values lost when SKU is altered it's a duplicate, but rather a complementary issue.
Comment #4
hanoiiIn any way, all uc_stock tagged issues should be probably be reviewed as a whole as there are quite a few related.
Comment #5
TR CreditAttribution: TR commentedAgain, 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.
Comment #6
JSCSJSCS CreditAttribution: JSCSJSCS commentedI 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.
Comment #7
hanoii@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.
Comment #9
hanoiiare tests working for modules? how do we make the testbot ignore patches?
Comment #10
JSCSJSCS CreditAttribution: JSCSJSCS commentedIs this the patch I need for my issue? I can enter manually.
Comment #11
TR CreditAttribution: TR commentedComment #12
TR CreditAttribution: TR commented#1: 1011068-update-nid-on-stck-update.patch queued for re-testing.