예제 #1
0
 $element = $elementIterator->fetch();
 unset($elementIterator);
 if (!empty($element)) {
     $sku = CCatalogSKU::GetInfoByOfferIBlock($element['IBLOCK_ID']);
     if (!empty($sku)) {
         $propertyIterator = CIBlockElement::GetProperty($element['IBLOCK_ID'], $element['ID'], array(), array('ID' => $sku['SKU_PROPERTY_ID']));
         if ($property = $propertyIterator->Fetch()) {
             $parentId = (int) $property['VALUE'];
         }
         unset($property, $propertyIterator);
     }
 }
 if (!empty($element) && $parentId > 0) {
     $bBasketUpdate = false;
     $arPropsValues["CML2_LINK"] = $parentId;
     $newProductId = getProductByProps($element['IBLOCK_ID'], $arPropsValues, true);
     if (!empty($newProductId)) {
         if ($productProvider = CSaleBasket::GetProductProvider($arItem)) {
             $arFieldsTmp = $productProvider::GetProductData(array("PRODUCT_ID" => $newProductId['ID'], "QUANTITY" => $arItem['QUANTITY'], "RENEWAL" => "N", "USER_ID" => $USER->GetID(), "SITE_ID" => SITE_ID, "BASKET_ID" => $arItem['ID'], "CHECK_QUANTITY" => "Y", "CHECK_PRICE" => "Y", "NOTES" => $arItem["NOTES"]));
         } elseif (isset($arItem["CALLBACK_FUNC"]) && !empty($arItem["CALLBACK_FUNC"])) {
             $arFieldsTmp = CSaleBasket::ExecuteCallbackFunction($arItem["CALLBACK_FUNC"], $arItem["MODULE"], $newProductId['ID'], $arItem['QUANTITY'], "N", $USER->GetID(), SITE_ID);
         }
         if (!empty($arFieldsTmp) && is_array($arFieldsTmp)) {
             $arFields = array('PRODUCT_ID' => $newProductId['ID'], 'PRODUCT_PRICE_ID' => $arFieldsTmp["PRODUCT_PRICE_ID"], 'PRICE' => $arFieldsTmp["PRICE"], 'CURRENCY' => $arFieldsTmp["CURRENCY"], 'QUANTITY' => $arFieldsTmp['QUANTITY'], 'WEIGHT' => $arFieldsTmp['WEIGHT']);
             $arProps = array();
             if (strpos($newProductId['XML_ID'], '#') === false) {
                 $parentIterator = \Bitrix\Iblock\ElementTable::getList(array('select' => array('ID', 'XML_ID'), 'filter' => array('ID' => $parentId)));
                 if ($parentProduct = $parentIterator->fetch()) {
                     $newProductId['XML_ID'] = $parentProduct['XML_ID'] . '#' . $newProductId['XML_ID'];
                 }
                 unset($parentProduct, $parentIterator);
예제 #2
0
			}

			$dbRes = CIBlockElement::GetList(
				array("SORT" => "ASC", "ID" => "ASC"),
				array("ID" => $arItem["PRODUCT_ID"]),
				false,
				false,
				$arSelect
			);

			if ($arElement = $dbRes->Fetch())
			{
				$bBasketUpdate = false;
				$arPropsValues["CML2_LINK"] = $arElement["PROPERTY_CML2_LINK_VALUE"];

				$newProductId = getProductByProps($arElement["IBLOCK_ID"], $arPropsValues);

				if ($newProductId > 0)
				{
					if ($productProvider = CSaleBasket::GetProductProvider($arItem))
					{
						$arFieldsTmp = $productProvider::GetProductData(array(
							"PRODUCT_ID" => $newProductId,
							"QUANTITY"   => $arItem['QUANTITY'],
							"RENEWAL"    => "N",
							"USER_ID"    => $USER->GetID(),
							"SITE_ID"    => SITE_ID,
							"BASKET_ID" => $arItem['ID'],
							"CHECK_QUANTITY" => "Y",
							"CHECK_PRICE" => "Y",
							"NOTES" => $arItem["NOTES"]