Answer the question
In order to leave comments, you need to log in
How to replace the choice of the maximum number of goods in Bitrix?
Hello, Aspro-Maximum Solution, such a question.
The bottom line is that there is one database in which goods go by the piece (I can’t change them), let’s say 5000 goods and there is a property how many pieces are in 1 package, let’s say 50 pieces
and I need to limit to a maximum of 100 goods so that they can buy this particular product, and t .to. the quantity hits 5000 at once, then people can issue 5000 packages, but in fact there are only 50 pieces of packages
On the detailed page of the product, I decided to do this))) works
<? $tovar1 = $arResult["PROPERTIES"]["KOMPLEKTATSIYA_PERVICHNAYA_UPAKOVKA"]["VALUE"];
$str = preg_replace("/[^0-9]/", '', $tovar1);
$delenie = $arResult['CATALOG_QUANTITY'];
$finish = (int)($delenie / $str);
?>
<script>
var username = "<?php echo $finish ?>";
$('.plus').attr('data-max', '<?php echo $finish ?>');
</script>
<td class="basket-items-list-item-amount">
<div class="basket-item-block-amount{{#NOT_AVAILABLE}} disabled{{/NOT_AVAILABLE}}"
data-entity="basket-item-quantity-block">
<span class="basket-item-amount-btn-minus" data-entity="basket-item-quantity-minus"></span>
<div class="basket-item-amount-filed-block">
<input style="display:none" type="text" class="basket-item-amount-filed" value="{{QUANTITY}}"
{{#NOT_AVAILABLE}} disabled="disabled"{{/NOT_AVAILABLE}}
data-value="{{QUANTITY}}" data-entity="basket-item-quantity-field"
id="basket-item-quantity-{{ID}}">
</div>
<span class="basket-item-amount-btn-plus" data-entity="basket-item-quantity-plus"></span>
{{#SHOW_LOADING}}
<div class="basket-items-list-item-overlay"></div>
{{/SHOW_LOADING}}
</div>
</td>
<?
AddEventHandler("iblock", "OnAfterIBlockElementUpdate", "OnAfterIBlockElementUpdateHandler");
function OnAfterIBlockElementUpdateHandler(&$arFields)
{
Cmodule::IncludeModule('iblock');
Cmodule::IncludeModule('catalog');
$iblockId = 18;
$updateElements = CIBlockElement::GetList(
Array("ID" => "ASC"),
Array("IBLOCK_ID" => $iblockId),
false,
false,
Array(
'ID',
'KOMPLEKTATSIYA_PERVICHNAYA_UPAKOVKA'
)
);
while ($arFields = $updateElements->GetNext()) {
$coeff = $arFields['KOMPLEKTATSIYA_PERVICHNAYA_UPAKOVKA'];
$newcoef = preg_replace("/[^0-9]/", '', $coeff);
$curElementRatio = CCatalogMeasureRatio::getList(
Array(),
array('IBLOCK_ID' => $iblockId, 'PRODUCT_ID' => $arFields['ID']),
false, false);
while ($arRatio = $curElementRatio->GetNext()) {
$ratioId = $arRatio['ID'];
}
CCatalogMeasureRatio::update($ratioId, Array(
'PRODUCT_ID' => $arFields['ID'],
'RATIO' => $newcoef)
);
}
}
?>
[TypeError]
Argument 1 passed to Bitrix\Catalog\Config\State::handlerAfterIblockElementUpdate() must be of the type array, bool given, called in /var/www/html/bitrix/modules/main/classes/general/module.php on line 480 (0)
/var/www/html/bitrix/modules/catalog/lib/config/state.php:243
#0: Bitrix\Catalog\Config\State::handlerAfterIblockElementUpdate
/var/www/html/bitrix/modules/main/classes/general/module.php:480
#1: ExecuteModuleEventEx
/var/www/html/bitrix/modules/iblock/classes/mysql/iblockelement.php:1757
#2: CIBlockElement->Update
/var/www/html/bitrix/modules/iblock/admin/iblock_element_edit.php:1047
#3: require(string)
/var/www/html/bitrix/admin/iblock_element_edit.php:1
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question