overbags Posted March 22, 2022 Share Posted March 22, 2022 (edited) hello everyone I have a problem to expose you I am trying to manipulate the StockAvailable.php file in class / stock / to register two custom fields of ps_product_attribute in ps_stock_available "reference_uni" and "reference_uni_conf" I cannot retrieve these two fields and have them recorded in the ps_stock_available table when updating the stock I found the lines that record the quantities and I thought I would act on these lines (I attach image) if (!$depends_on_stock) { $id_stock_available = (int)StockAvailable::getStockAvailableIdByProductId($id_product, $id_product_attribute, $id_shop); if ($id_stock_available) { $stock_available = new StockAvailable($id_stock_available); $stock_available->quantity = (int)$quantity; $stock_available->reference_uni = "test1"; $stock_available->reference_uni_conf = "test2"; $stock_available->update(); } else { $out_of_stock = StockAvailable::outOfStock($id_product, $id_shop); $stock_available = new StockAvailable(); $stock_available->out_of_stock = (int)$out_of_stock; $stock_available->id_product = (int)$id_product; $stock_available->id_product_attribute = (int)$id_product_attribute; $stock_available->quantity = (int)$quantity; $stock_available->reference_uni = "test3"; $stock_available->reference_uni_conf = "test4"; Edited March 29, 2022 by overbags forgotten script (see edit history) Link to comment Share on other sites More sharing options...
overbags Posted March 29, 2022 Author Share Posted March 29, 2022 I solved it with an adapted script found online -------------------------------------- // REFERENCE_UNI REFERENCE_UNI_CONF $query_ebay = 'SELECT reference_uni, reference_uni_conf FROM `' . _DB_PREFIX_ . 'product_attribute` WHERE `id_product` = '.(int)$id_product.' AND `id_product_attribute` = '.(int)$id_product_attribute; $ebaym = Db::getInstance()->executeS($query_ebay); $ebayKeys = array_keys($ebaym); $lastebayKey = array_pop($ebayKeys); $reference_uni = ''; $reference_uni_conf = ''; foreach ($ebaym as $eba_k => $ebay) { $reference_uni .= $ebay['reference_uni']; $reference_uni_conf .= $ebay['reference_uni_conf']; if ($eba_k != $lastebayKey) { $reference_uni .= ' | '; $reference_uni_conf .= ' | '; } } if (!$depends_on_stock) { $id_stock_available = (int)StockAvailable::getStockAvailableIdByProductId($id_product, $id_product_attribute, $id_shop); if ($id_stock_available) { $stock_available = new StockAvailable($id_stock_available); $stock_available->quantity = (int)$quantity; $stock_available->reference_uni = $reference_uni; $stock_available->reference_uni_conf = $reference_uni_conf; $stock_available->update(); } else { $out_of_stock = StockAvailable::outOfStock($id_product, $id_shop); $stock_available = new StockAvailable(); $stock_available->out_of_stock = (int)$out_of_stock; $stock_available->id_product = (int)$id_product; $stock_available->id_product_attribute = (int)$id_product_attribute; $stock_available->quantity = (int)$quantity; $stock_available->reference_uni = $reference_uni; $stock_available->reference_uni_conf = $reference_uni_conf; 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now