...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/webform/manager.php
- Класс: Bitrix\Crm\WebForm\Manager
- Вызов: Manager::updateProductFormsWithNewPrice
static function updateProductFormsWithNewPrice(int $productId, float $oldPrice, float $newPrice, string $oldCurrency, string $newCurrency) { static $formFields; // cache fields if (is_null($formFields)) { // get all product form fields $formFields = \Bitrix\Crm\WebForm\Internals\FieldTable::getList([ 'select' => ['ID', 'FORM_ID', 'ITEMS'], 'filter' => [ '=TYPE' => 'product', ], ]); } static $forms = []; // cache forms $updatedForms = []; // update only fields related to updated price foreach ($formFields as $field) { $formId = $field['FORM_ID']; if (!array_key_exists($formId, $forms)) { $forms[$formId] = new \Bitrix\Crm\WebForm\Form($formId); } $form = $forms[$formId]; $formCurrency = $form->getCurrencyId(); if ($formCurrency !== $oldCurrency || $formCurrency !== $newCurrency) { continue; } $items = $field['ITEMS'] ?? []; $isUpdated = false; foreach ($items as &$item) { // update if price in form matches catalog price if ($productId === (int)$item['ID'] && $oldPrice === (float)$item['PRICE']) // && $item['CUSTOM_PRICE'] === 'N' { $item['PRICE'] = $newPrice; $isUpdated = true; } } if ($isUpdated) { \Bitrix\Crm\WebForm\Internals\FieldTable::update($field['ID'], ['ITEMS' => $items]); $updatedForms[] = $formId; } } // rebuild form cache foreach ($updatedForms as $formId) { \Bitrix\Crm\WebForm\Manager::updateScriptCache($formId, 1); } }