If I manually add the SKU that already exists, then get the error: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'sm_nat_med_0002' for key 'PRIMARY': INSERT INTO {uc_product_stock} (sku, nid, active, stock, threshold) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array ( [:db_insert_placeholder_0] => sm_nat_med_0002 [:db_insert_placeholder_1] => 639 [:db_insert_placeholder_2] => 1 [:db_insert_placeholder_3] => 0 [:db_insert_placeholder_4] => 0 ) in uc_product_power_tools_node_insert() (line 296 of /home/thirdeye/public_html/sites/all/modules/uc_product_power_tools/uc_product_power_tools.module).

I think it's better to check it out and display a warning. If nobody is fixed, then I'll write a patch.

Comments

ibit’s picture

So if I disable Ubercart Product Power Tools module - I can create new products with exist SKU.

stefan.r’s picture

Issue summary: View changes

uc_stock supposes unique SKU's as per #737790: Products SKU update did not transfer correctly to Stock (uc_stock) module but regular Ubercart allows for duplicates.

Throwing an error on a duplicate doesn't seem like the right solution since regular Ubercart doesn't do this either at the moment.

If you create new products with existing SKUs without "Ubercart Product Power Tools", the new node and the old node will use the same stock-keeping (so the new node will inherit the old stock level and the stock will go down when someone buys either of the nodes.

We could stick to this behaviour and leave the stock level alone if the SKU already exists, but as this may be unexpected we could output a warning saying that the SKU already exists so the stock level hasn't been updated and is still X (old stock level) instead do of Y (default stock level for new products).

  • stefan.r committed 9de6764 on 7.x-1.x
    Issue #2000652: PDOException: SQLSTATE[23000]: Integrity constraint...
stefan.r’s picture

Status: Active » Fixed
stefan.r’s picture

Status: Fixed » Closed (fixed)