Prestashop - PHP - обновление количества комбинаций вызывает ошибку - PullRequest
1 голос
/ 12 июля 2020

Я пытаюсь создать сценарий PHP, который обновляет количество комбинаций в PrestaShop 1.6.1.11

Я думал, что могу получить комбинацию по их коду:

$product = new Product("COMB CODE");

$product->quantity = 5;  // your quantity
$product->save();

Но PHP повышает:

PHP Deprecated:  array_key_exists(): Using array_key_exists() on objects is deprecated. Use isset() or property_exists() instead in /home/w.sk/web/Adapter/Adapter_EntityMapper.php on line 84
PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /home/w.sk/web/classes/ObjectModel.php on line 478
PHP Fatal error:  Uncaught Out of range value for column 'id_product' at row 1<br /><br /><pre>INSERT INTO `ps_product` (`id_shop_default`, `id_manufacturer`, `id_supplier`, `reference`, `supplier_reference`, `location`, `width`, `height`, `depth`, `weight`, `quantity_discount`, `ean13`, `upc`, `cache_is_pack`, `cache_has_attachments`, `is_virtual`, `id_category_default`, `id_tax_rules_group`, `on_sale`, `online_only`, `ecotax`, `minimal_quantity`, `price`, `wholesale_price`, `unity`, `unit_price_ratio`, `additional_shipping_cost`, `customizable`, `text_fields`, `uploadable_files`, `active`, `redirect_type`, `id_product_redirected`, `available_for_order`, `available_date`, `condition`, `show_price`, `indexed`, `visibility`, `cache_default_attribute`, `advanced_stock_management`, `date_add`, `date_upd`, `pack_stock_type`) VALUES ('1', '0', '0', '', '', '', '0', '0', '0', '0', '0', '', '', '0', '0', '0', '0', '1', '0', '0', '0', '1', '0', '0', '', '0', '0', '0', '0', '0', '1', '', '0', '1', '0000-00-00', 'new', '1', '0', 'both', in /home/w.sk/web/classes/db/Db.php on line 791

Вы знаете, как получить существующую комбинацию и обновить ее количество?

1 Ответ

0 голосов
/ 15 июля 2020

Вы можете использовать этот код для обновления количества комбинаций:

$id_product = your product id
$id_product_attribute = your combination id
$quantity = your quantity
 
StockAvailable::setQuantity($id_product,$id_product_attribute, $quantity);
...