Exemplo n.º 1
0
 function onIBlockElementDelete($id)
 {
     $modifier_id = intval(Option::get('modifier_id'));
     $params = array(
         'select' => array('IBLOCK_ID'),
         'filter' => array(
             '=ID' => $id
         )
     );
     $arElement = ElementTable::getRow($params);
     if (intval($arElement['IBLOCK_ID']) !== $modifier_id)
     {
         return ElementModifiers::delete($id);
     }
     return Modifiers::delete($id);
 }
Exemplo n.º 2
0
    private function importOffers($arOffers = array())
    {
        // в эту переменную будем кэшировать выборку из инфоблока модификаторов
        $arCache = array();
        foreach ($arOffers as $arElement)
        {
            foreach ($arElement['OFFERS'] as $arModifier)
            {
                $sectionKey = $arModifier['XML_ID'];
                $elementKey = $arModifier['VALUE_XML_ID'];

                $boolCached = isset($arCache[$sectionKey]);
                if (strlen($elementKey) > 0)
                {
                    $boolCached = isset($arCache[$sectionKey][$elementKey]);
                }
                if (!$boolCached)
                {
                    $params = array(
                        'select' => array('ID', 'XML_ID'),
                        'filter' => array(
                            '=IBLOCK_ID'      => $this->OFFERS_ID,
                            '=SECTION.XML_ID' => $sectionKey
                        ),
                        'runtime' => array(
                            new ReferenceField(
                                'SECTION',
                                '\Bitrix\Iblock\SectionTable',
                                array('=this.IBLOCK_SECTION_ID' => 'ref.ID'),
                                array('join_type' => 'LEFT')
                            )
                        )
                    );
                    if (strlen($elementKey) > 0)
                    {
                        $params['filter']['=XML_ID'] = $elementKey;
                    }

                    $result = ElementTable::getList($params);
                    while ($row = $result->fetch())
                    {
                        $arCache[$sectionKey][$row['XML_ID']] = $row['ID'];
                    }
                }

                foreach ($arCache[$sectionKey] as $modifierID)
                {
                    ElementModifiers::add($arElement['ID'], $modifierID, $arModifier['REQUIRED']);
                }
            }
        }
    }
Exemplo n.º 3
0
        try
        {
            Loader::includeModule("sale");
            Loader::includeModule("catalog");
            Loader::includeModule("ugraweb.iiko");

            $intProductIBlockID = (int) CIBlockElement::GetIBlockByID($productID);
            if ($intProductIBlockID > 0)
            {
                if (
                    isset($_REQUEST[$arParams["PRODUCT_PROPS_VARIABLE"]])
                    && is_array($_REQUEST[$arParams["PRODUCT_PROPS_VARIABLE"]])
                )
                {
                    $product_properties = \Iiko\ElementModifiers::checkElementModifiers(
                        $productID,
                        $_REQUEST[$arParams["PRODUCT_PROPS_VARIABLE"]]
                    );
                    if (empty($product_properties))
                    {
                        $strError = "Не все модификаторы товара, добавляемые в корзину, заполнены";
                        $successfulAdd = false;
                    }
                }

                if (isset($_REQUEST[$arParams["PRODUCT_QUANTITY_VARIABLE"]]))
                {
                    $QUANTITY = doubleval($_REQUEST[$arParams["PRODUCT_QUANTITY_VARIABLE"]]);
                }

                if (!$QUANTITY)
                {
Exemplo n.º 4
0
    function getBasketItems($orderID)
    {
        // выбираем товар из заказа
        $params = array(
            'select' => array("ID", "QUANTITY", "PRICE", "NAME", "PRODUCT_ID", "DISCOUNT_PRICE", "XML_ID" => "ELEMENT.XML_ID"),
            'filter' => array(
                '=ORDER_ID' => $orderID
            ),
            'runtime' => array(
                new ReferenceField(
                    'ELEMENT',
                    '\Bitrix\Iblock\ElementTable',
                    array('=this.PRODUCT_ID' => 'ref.ID'),
                    array('join_type' => 'LEFT')
                )
            )
        );
        $arBasketItems = BasketTable::getList($params)->fetchAll();

        // выбираем свойства товара
        foreach ($arBasketItems as &$arBasketItem)
        {
            $rsBasketProp = \CSaleBasket::GetPropsList(
                array("SORT" => "ASC"),
                array(
                    "BASKET_ID" => $arBasketItem["ID"],
                    "!CODE" => array("CATALOG.XML_ID", "PRODUCT.XML_ID")
                )
            );
            while ($arBasketProp = $rsBasketProp->Fetch())
            {

                $arElemMod = ElementModifiers::getByPropCode($arBasketProp['CODE']);
                $arBasketItem["PROPS"][] = array_merge($arBasketProp, $arElemMod);
            }
        }

        return $arBasketItems;
    }