Answer the question
In order to leave comments, you need to log in
Why do events not work when updating the quantity OnProductUpdate, OnBeforeProductUpdate?
AddEventHandler('catalog', 'OnProductUpdate', ['MyClass', 'OnProductUpdateHandler']);
class MyClass
{
function OnProductUpdateHandler($id, &$arFields)
{
$arLoadProductArray = $arFields['QUANTITY'] > 0 ? Array("IN_STOCK" => "Y") : Array("IN_STOCK" => "N");
}
}
AddEventHandler("catalog", "OnBeforeProductUpdate", "notInStore");
function notInStore($ID,&$arFields){
if (($arFields['QUANTITY'] != $arFields['OLD_QUANTITY']) || (!is_null($arFields['QUANTITY']) && is_null($arFields['OLD_QUANTITY']))) {
if (intval($arFields["QUANTITY"]) > 100) {
$arFields["QUANTITY"] = 100;
}
}
}
$eventManager->addEventHandler('catalog','OnStoreProductAdd', 'UpdateAvailableQuantity');
$eventManager->addEventHandler('catalog','OnStoreProductUpdate', 'UpdateAvailableQuantity');
$eventManager->addEventHandler('catalog','OnStoreProductDelete', 'DeletesAvailableQuantity');
use \Bitrix\Main\Loader;
Loader::includeModule('catalog');
function UpdateAvailableQuantity($id, $arFields){
$obProduct = new CCatalogProduct();
if (intval($arFields["AMOUNT"])>=100){
$obProduct->Update($arFields["PRODUCT_ID"], ['QUANTITY' => 100, 'SUBSCRIBE' => 'D']);
}else{
if ($arFields["AMOUNT"]==0)
$obProduct->Update($arFields["PRODUCT_ID"], ['QUANTITY' => 0, 'SUBSCRIBE' => 'D']);
else
$obProduct->Update($arFields["PRODUCT_ID"], ['QUANTITY' => $arFields["AMOUNT"], 'SUBSCRIBE' => 'D']);
}
}
Answer the question
In order to leave comments, you need to log in
See the documentation for the following WinAPI calls: OpenProcess, ReadProcessMemory, WriteProcessMemory, CloseHandle. In addition, there is such a thing as restrictions on reading and writing to the memory of other processes, and you may need to set these additional flags or request rights.
You probably need to see the address of the object in memory, and not "... the object whose value in memory I need to find" or is it still the address of the object's property? But anyway - create a pointer to an object or property and initialize it with whatever you want, then print that pointer to stdout ("%p") and see the address of what you want. Moreover, regardless of Win or Lin .. :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question