Open daphilli224 opened 2 months ago
Versions of EO prior to 4.7.0 did drop the products 'prid' from the orders-products table (see #216). I'm afraid I can't be of help with the SBA integration (or lack thereof). None of my clients use that product-variant handler.
The products_prid of a product with attributes in an order is changed in table orders_products_attributes_stock when the quantity of the product is changed in edit_orders. The product must be tracked by Products With Attributes Stock (SBA) plugin. Procedure to see problem:
At least one effect from the change in products_prid is that if the order is now deleted with the restock option chosen, the products quantity in stock in table products_with_attributes_stock is incorrect. There may be other effects that I have not noticed.
I have traced the issue to a call to zen_get_uprid around line 736 in admin/includes/classes/observers/class.products_with_attributes_stock.php where $new_attrs[$key] is structured differently than other calls to zen_get_uprid. The code segment is:
foreach ($order_product_attribute_id as $key=>$opai) { $sql_data_array = array('orders_products_attributes_id' =>$opai, 'orders_id' =>$order_id, 'orders_products_id' =>$orders_products_id, 'stock_id' => $_stock_info['stock_id'], 'stock_attribute' => $_stock_info['stock_attribute'], 'customid' => $product['customid'], 'products_prid' =>zen_get_uprid($product['id'], $new_attrs[$key])); zen_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES_STOCK, $sql_data_array); //inserts data into the TABLE_ORDERS_PRODUCTS_ATTRIBUTES_STOCK table. }
I found the structure of the second argument to zen_get_uprid, $new_attrs[$key], after edit_orders was array('option_id'=>'3', 'value_id'=>'255') where '3' is the option_id for the test product, and '255' is the option_value_id. Normally and before edit_orders, the second argument to zen_get_uprid is array(3=>255) for my test case. I fixed the problem by changing $new_attrs[$key] to the normal structure.Disclaimer: I did not trace back further to see where edit_orders set or passed the data that gets into $new_attrs[$key] and whether the problem is really an edit_orders problem or an SBA problem. My apologies if this should be reported to SBA.
Dave zc158a, edit_orders 4.7.1, SBA downloaded from GitHub on 11/15/2023. Same problem exists in zc157c, edit_orders 4.6.2.