A
A
Anumik2016-08-18 16:15:01
1C-Bitrix
Anumik, 2016-08-18 16:15:01

How to automatically change the price when changing / loading a product in 1s-Bitrix?

Good day
, When importing goods from 1C to 1C-Bitrix, it is necessary to rewrite the price something like this: $arFields['PRICE']=$arFields['PRICE']/100*110;in init.php I threw an event (I found a similar one on the forum),

<?
AddEventHandler("catalog", "OnBeforePriceUpdate", array("MyClass", "OnBeforePriceUpdateHandler"));

class MyClass
{
   function OnBeforePriceUpdateHandler($PRICE_ID, $arFields)
   {
      $db_price = CPrice::GetList(
         array(),
         array(
            "ID" => $PRICE_ID
         )
      );

      if($ar_price = $db_price->Fetch())
      {
         if($ar_price['PRICE'] != $arFields['PRICE'])
         {
            $arFields['PRICE']=$arFields['PRICE']/100*110;
         }
      }
   }
}

but the price does not change. I just started programming, can anyone help a newbie?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Zakharov, 2016-08-18
@konratnox

Read the documentation, you are using
AddEventHandler("iblock", "OnBeforeIBlockElementUpdate", Array("MyClass", "OnBeforeIBlockElementUpdateHandler"));
First you use OnBeforeIBlockElementUpdate, in this event there is no PRICE field, secondly
you pass Array("MyClass", "OnBeforeIBlockElementUpdateHandler"));
You don't have such function in your class, you have OnBeforePriceUpdateHandler Related
link
dev.1c-bitrix.ru/support/forum/forum6/topic47042

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question