problem appears in following situation

create product
set stock values
update product with new SKU
visit stock
values have been lost

some other issues that a proposed patch might solve
#737790: Products SKU update did not transfer correctly to Stock (uc_stock) module
#423262: Stock information not deleted with node

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

GiorgosK’s picture

Status: Active » Needs review
FileSize
818 bytes

The patch updates stock table when product is updated
at the end of "uc_product_update" function

function uc_product_update($node) {
...
  if (module_exists('uc_stock')){
    db_query("UPDATE {uc_product_stock} SET sku = '%s' WHERE nid=%d", $node->model, $node->nid, $node->nid);
  }
}
GiorgosK’s picture

Title: uc_product_stock not updated when SKU is altered » Stock values lost when SKU is altered

this might be a better title

Exploratus’s picture

I tried it and it ubercart still resets the stock.... Doesnt work...

GiorgosK’s picture

you tried it with what version

the patch was for 2.2

please make your report as helpful as possible

Exploratus’s picture

Your right, I tried it with 2.3. I didnt realize the version just changed, I used to have 2.2. Is there a port to 2.3?

GiorgosK’s picture

Version: 6.x-2.2 » 6.x-2.4

the patch still applies without change

if you can't make it apply, apply it by hand
after line 661 uc_product.module paste

  db_query("UPDATE {uc_product_stock} SET sku = '%s' WHERE nid=%d", $node->model, $node->nid, $node->nid);

and test

TR’s picture

Priority: Critical » Normal
Status: Needs review » Needs work

Your patch has the same problem with database integrity that I mentioned in http://drupal.org/node/737790#comment-3345606 in response to a similar issue. You're fixing one thing at the expense of breaking other things. IMO the only proper way to handle this is to modify Ubercart so SKUs are not only unique but immutable.

casey_2000’s picture

Title: Stock values lost when SKU is altered » I had a issue that
Component: Code » Stock

Sorry for my English, I'm from Russia.

I had the problem:
Changing SKU in some product makes Stock create new record with new SKU and it doesn't delete the old one.

The patch published by GiorgosK helped me a lot. It updates SKU in stock when changing in product.
Big thanks.

GiorgosK’s picture

Title: I had a issue that » Stock values lost when SKU is altered

Please keep the title to something descriptive of the problem

TimelessDomain’s picture

hanoii’s picture

I don't think #1011068: Changing SKU on a node to a previously used SKU on a different node leads to bogus stock information (wrong reports) it's a duplicate, but rather a complementary issue, they address different things and the patch here won't fix what I have mentioned on that issue.

jlporter’s picture

puttin my sub skates on

mirocow’s picture

subscribe

GiorgosK’s picture

I know this is not going to be included in ubercart
but just for the people that want a quick fix I updated the patch for 2.4

ratinakage’s picture

Anyone know why this patch got ignored?

GiorgosK’s picture

because its just a quick work around which might work in your use case
but its not something that would be of general use

make thorough testing before putting in your live site

longwave’s picture

Status: Needs work » Closed (duplicate)