本文整理汇总了PHP中CCatalogProduct::Add方法的典型用法代码示例。如果您正苦于以下问题:PHP CCatalogProduct::Add方法的具体用法?PHP CCatalogProduct::Add怎么用?PHP CCatalogProduct::Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCatalogProduct
的用法示例。
在下文中一共展示了CCatalogProduct::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addCatalogProducts
protected function addCatalogProducts($arParams){
if (!CModule::IncludeModule("iblock") && !CModule::IncludeModule("catalog") && !CModule::IncludeModule("sale")):
return false;
endif;
$arFields = array(
"ID" => $arParams["PRODUCT_ID"],
"QUANTITY" => $arParams["BALANCE"],
"CAN_BUY_ZERO" => "Y",
"NEGATIVE_AMOUNT_TRACE" => "Y",
"QUANTITY_TRACE" => "Y"
);
$db_res = CCatalogProduct::GetList(
array(),
array("ID" => $arParams["PRODUCT_ID"]),
false,
array()
);
if ($ar_res = $db_res->Fetch()):
if (!CCatalogProduct::Update($ar_res["ID"], $arFields)):
return false;
endif;
else:
if(!CCatalogProduct::Add($arFields)):
return false;
endif;
endif;
return true;
}
示例2: On1CExchAfterIBlockElementAdd
function On1CExchAfterIBlockElementAdd(&$arFields)
{
// Create catalog records for all iblock elements
$iblockElementId = intval($arFields['RESULT']);
if ($iblockElementId > 0) {
$catalogProduct = new CCatalogProduct();
$catalogProduct->Add(array('ID' => $iblockElementId, 'QUANTITY' => 0));
}
return true;
}
示例3: add_element
function add_element($iblock_id, $section_id, $NAME, $PRICE_EUR, $P, $DETAIL_PICTURE)
{
$el = new CIBlockElement();
//test_dump($P);
$arFields = array("IBLOCK_ID" => $iblock_id, "NAME" => $NAME, "CODE" => $P["ARTNUMBER"], "ACTIVE" => "Y", "IBLOCK_SECTION_ID" => $section_id, "DETAIL_TEXT" => $P["DESCRIPTION_TEXT"], "DETAIL_TEXT_TYPE" => "html", "PROPERTY_VALUES" => $P, "DETAIL_PICTURE" => $DETAIL_PICTURE);
if ($last_el_id = $el->Add($arFields)) {
echo "New ID: " . $last_el_id . "<br>";
$arFields = array("ID" => $last_el_id, "VAT_INCLUDED" => "Y");
if (CCatalogProduct::Add($arFields)) {
echo "Добавили параметры товара к элементу каталога " . $last_el_id . "<br>";
$arFields = array("PRODUCT_ID" => $last_el_id, "CATALOG_GROUP_ID" => 1, "PRICE" => $PRICE_EUR, "CURRENCY" => "EUR");
CPrice::Add($arFields);
} else {
echo "Ошибка добавления параметров товаров";
}
} else {
echo "Error: " . $el->LAST_ERROR . "<br>";
}
}
示例4: array
}
if ('' == $strErrorR && $bIBlockIsCatalog) {
$arLoadOfferArray = array("ID" => $PRODUCT_ID);
foreach ($arAvailPriceFields_names as $key => $value) {
$ind = -1;
for ($i_tmp = 0; $i_tmp < $NUM_FIELDS; $i_tmp++) {
if (${"field_" . $i_tmp} == $key) {
$ind = $i_tmp;
break;
}
}
if ($ind > -1) {
$arLoadOfferArray[$value["field"]] = trim($arRes[$ind]);
}
}
CCatalogProduct::Add($arLoadOfferArray);
$quantityFrom = 0;
$quantityTo = 0;
for ($j = 0; $j < $NUM_FIELDS; $j++) {
if (${"field_" . $j} == "CV_QUANTITY_FROM") {
$quantityFrom = intval($arRes[$j]);
} elseif (${"field_" . $j} == "CV_QUANTITY_TO") {
$quantityTo = intval($arRes[$j]);
}
}
if (0 >= $quantityFrom) {
$quantityFrom = false;
}
if (0 >= $quantityTo) {
$quantityTo = false;
}
示例5:
if (isset($arFields['CATALOG_WEIGHT']) && '' != $arFields['CATALOG_WEIGHT'])
$arCatalogProduct['WEIGHT'] = $arFields['CATALOG_WEIGHT'];
if (isset($arFields['CATALOG_VAT_INCLUDED']) && !empty($arFields['CATALOG_VAT_INCLUDED']))
$arCatalogProduct['VAT_INCLUDED'] = $arFields['CATALOG_VAT_INCLUDED'];
if (isset($arFields['CATALOG_QUANTITY_TRACE']) && !empty($arFields['CATALOG_QUANTITY_TRACE']))
$arCatalogProduct['QUANTITY_TRACE'] = $arFields['CATALOG_QUANTITY_TRACE'];
if ('Y' != $strUseStoreControl)
{
if (isset($arFields['CATALOG_QUANTITY']) && '' != $arFields['CATALOG_QUANTITY'])
$arCatalogProduct['QUANTITY'] = $arFields['CATALOG_QUANTITY'];
}
if (!CCatalogProduct::IsExistProduct($ID))
{
$arCatalogProduct['ID'] = $ID;
CCatalogProduct::Add($arCatalogProduct, false);
}
else
{
if (!empty($arCatalogProduct))
CCatalogProduct::Update($ID, $arCatalogProduct);
}
if (isset($arFields['CATALOG_MEASURE_RATIO']) && '' != trim($arFields['CATALOG_MEASURE_RATIO']))
{
$intRatioID = 0;
$rsRatios = CCatalogMeasureRatio::getList(
array(),
array('PRODUCT_ID' => $ID),
false,
false,
示例6: array
}
if ('' == $strErrorR && $bIBlockIsCatalog) {
$arLoadOfferArray = array("ID" => $PRODUCT_ID);
foreach ($arAvailPriceFields_names as $key => $value) {
$ind = -1;
for ($i_tmp = 0; $i_tmp < $NUM_FIELDS; $i_tmp++) {
if (${"field_" . $i_tmp} == $key) {
$ind = $i_tmp;
break;
}
}
if ($ind > -1) {
$arLoadOfferArray[$value["field"]] = trim($arRes[$ind]);
}
}
$productAddRes = CCatalogProduct::Add($arLoadOfferArray);
if (!$productAddRes) {
$strErrorR .= GetMessage('CATI_LINE_NO') . ' ' . $line_num . '. ';
if ($ex = $APPLICATION->GetException()) {
$strErrorR .= GetMessage('CATI_ERR_PRODUCT_UPDATE') . $ex->GetString();
} else {
$strErrorR .= GetMessage('CATI_ERR_PRODUCT_UPDATE_UNKNOWN');
}
unset($ex);
} else {
$quantityFrom = 0;
$quantityTo = 0;
for ($j = 0; $j < $NUM_FIELDS; $j++) {
if (${"field_" . $j} == "CV_QUANTITY_FROM") {
$quantityFrom = intval($arRes[$j]);
} elseif (${"field_" . $j} == "CV_QUANTITY_TO") {
示例7: ImportElementPrices
function ImportElementPrices($arXMLElement, &$counter, $arParent = false)
{
/** @global CMain $APPLICATION */
global $APPLICATION;
static $catalogs = array();
$arElement = array("ID" => 0, "XML_ID" => $arXMLElement[$this->mess["IBLOCK_XML2_ID"]]);
$hashPosition = strrpos($arElement["XML_ID"], "#");
if ($this->use_offers && $hashPosition === false && !$this->force_offers && isset($this->PROPERTY_MAP["CML2_LINK"]) && isset($this->arProperties[$this->PROPERTY_MAP["CML2_LINK"]])) {
$IBLOCK_ID = $this->arProperties[$this->PROPERTY_MAP["CML2_LINK"]]["LINK_IBLOCK_ID"];
if (!isset($catalogs[$IBLOCK_ID])) {
$catalogs[$IBLOCK_ID] = true;
$rs = CCatalog::GetList(array(), array("IBLOCK_ID" => $IBLOCK_ID));
if (!$rs->Fetch()) {
$obCatalog = new CCatalog();
$boolFlag = $obCatalog->Add(array("IBLOCK_ID" => $IBLOCK_ID, "YANDEX_EXPORT" => "N", "SUBSCRIPTION" => "N"));
if (!$boolFlag) {
if ($ex = $APPLICATION->GetException()) {
$this->LAST_ERROR = $ex->GetString();
}
return 0;
}
}
}
} else {
$IBLOCK_ID = $this->next_step["IBLOCK_ID"];
}
$obElement = new CIBlockElement();
$rsElement = $obElement->GetList(array("ID" => "asc"), array("=XML_ID" => $arElement["XML_ID"], "IBLOCK_ID" => $IBLOCK_ID), false, false, array("ID", "TMP_ID", "ACTIVE"));
$arDBElement = $rsElement->Fetch();
if ($arDBElement) {
$arElement["ID"] = $arDBElement["ID"];
}
if (isset($arXMLElement[$this->mess["IBLOCK_XML2_STORE_AMOUNT_LIST"]])) {
$arElement["STORE_AMOUNT"] = array();
foreach ($arXMLElement[$this->mess["IBLOCK_XML2_STORE_AMOUNT_LIST"]] as $storeAmount) {
if (isset($storeAmount[$this->mess["IBLOCK_XML2_STORE_ID"]])) {
$storeXMLID = $storeAmount[$this->mess["IBLOCK_XML2_STORE_ID"]];
$amount = $this->ToFloat($storeAmount[$this->mess["IBLOCK_XML2_AMOUNT"]]);
$arElement["STORE_AMOUNT"][$storeXMLID] = $amount;
}
}
} elseif (isset($arXMLElement[$this->mess["IBLOCK_XML2_RESTS"]])) {
$arElement["STORE_AMOUNT"] = array();
foreach ($arXMLElement[$this->mess["IBLOCK_XML2_RESTS"]] as $xmlRest) {
foreach ($xmlRest as $storeAmount) {
if (is_array($storeAmount)) {
if (isset($storeAmount[$this->mess["IBLOCK_XML2_ID"]])) {
$storeXMLID = $storeAmount[$this->mess["IBLOCK_XML2_ID"]];
$amount = $this->ToFloat($storeAmount[$this->mess["IBLOCK_XML2_AMOUNT"]]);
$arElement["STORE_AMOUNT"][$storeXMLID] = $amount;
}
} else {
if (strlen($storeAmount) > 0) {
$amount = $this->ToFloat($storeAmount);
$arElement["QUANTITY"] = $amount;
}
}
}
}
} elseif ($arParent && (array_key_exists($this->mess["IBLOCK_XML2_STORES"], $arXMLElement) || array_key_exists($this->mess["IBLOCK_XML2_STORE"], $arXMLElement))) {
$arElement["STORE_AMOUNT"] = array();
$rsStores = $this->_xml_file->GetList(array("ID" => "asc"), array("><LEFT_MARGIN" => array($arParent["LEFT_MARGIN"], $arParent["RIGHT_MARGIN"]), "NAME" => $this->mess["IBLOCK_XML2_STORE"]), array("ID", "ATTRIBUTES"));
while ($arStore = $rsStores->Fetch()) {
if (strlen($arStore["ATTRIBUTES"]) > 0) {
$info = unserialize($arStore["ATTRIBUTES"]);
if (is_array($info) && array_key_exists($this->mess["IBLOCK_XML2_STORE_ID"], $info) && array_key_exists($this->mess["IBLOCK_XML2_STORE_AMOUNT"], $info)) {
$arElement["STORE_AMOUNT"][$info[$this->mess["IBLOCK_XML2_STORE_ID"]]] = $this->ToFloat($info[$this->mess["IBLOCK_XML2_STORE_AMOUNT"]]);
}
}
}
}
if (isset($arElement["STORE_AMOUNT"])) {
$this->ImportStoresAmount($arElement["STORE_AMOUNT"], $arElement["ID"], $counter);
}
if ($arDBElement) {
$arProduct = array("ID" => $arElement["ID"]);
if (isset($arXMLElement[$this->mess["IBLOCK_XML2_PRICES"]])) {
$arElement["PRICES"] = array();
foreach ($arXMLElement[$this->mess["IBLOCK_XML2_PRICES"]] as $price) {
if (isset($price[$this->mess["IBLOCK_XML2_PRICE_TYPE_ID"]]) && array_key_exists($price[$this->mess["IBLOCK_XML2_PRICE_TYPE_ID"]], $this->PRICES_MAP)) {
$price["PRICE"] = $this->PRICES_MAP[$price[$this->mess["IBLOCK_XML2_PRICE_TYPE_ID"]]];
$arElement["PRICES"][] = $price;
if (array_key_exists($this->mess["IBLOCK_XML2_MEASURE"], $price) && !isset($arProduct["MEASURE"])) {
$tmp = $this->convertBaseUnitFromXmlToPropertyValue($price[$this->mess["IBLOCK_XML2_MEASURE"]]);
if ($tmp["DESCRIPTION"] > 0) {
$arProduct["MEASURE"] = $tmp["DESCRIPTION"];
}
}
}
}
$arElement["DISCOUNTS"] = array();
if (isset($arXMLElement[$this->mess["IBLOCK_XML2_DISCOUNTS"]])) {
foreach ($arXMLElement[$this->mess["IBLOCK_XML2_DISCOUNTS"]] as $discount) {
if (isset($discount[$this->mess["IBLOCK_XML2_DISCOUNT_CONDITION"]]) && $discount[$this->mess["IBLOCK_XML2_DISCOUNT_CONDITION"]] === $this->mess["IBLOCK_XML2_DISCOUNT_COND_VOLUME"]) {
$discount_value = $this->ToInt($discount[$this->mess["IBLOCK_XML2_DISCOUNT_COND_VALUE"]]);
$discount_percent = $this->ToFloat($discount[$this->mess["IBLOCK_XML2_DISCOUNT_COND_PERCENT"]]);
if ($discount_value > 0 && $discount_percent > 0) {
$arElement["DISCOUNTS"][$discount_value] = $discount_percent;
}
}
//.........这里部分代码省略.........
示例8: AuthtorizeAfterAds
/**
* функция после добавлением элемента в инфоблока
* @param $arFields поля элемента ифоблока
* для страницы Объявления
* eсли VIP объявление то добавляет корзину
* привязывает по ID созданное объявления к товару в корзине
* редирект на необходимы url
*/
function AuthtorizeAfterAds(&$arFields){
unset($_SESSION['user777999authorize']);
if($arFields['PROPERTY_VALUES']['114']){
foreach($arFields['PROPERTY_VALUES']['114'] as $key114 => $item114){
if($item114['VALUE']){
foreach($arFields['PROPERTY_VALUES']['113'] as $key113 => $item113){
if($item113['VALUE']){
$arFields['PROPERTY_VALUES']['113'][$key113]=ConvertDateTime($item114['VALUE'], "YYYY-MM-DD HH:MI:SS");
}else{
$arFields['PROPERTY_VALUES']['113'][n0]=ConvertDateTime($item114['VALUE'], "YYYY-MM-DD HH:MI:SS");
}
}
}
}
}
if(($arFields["IBLOCK_ID"] == 16)&&(!CUser::IsAuthorized())){
global $USER;
$rsUser = CUser::GetByID($_SESSION['NEW_USER_ID']);
$arUser = $rsUser->Fetch();
$_SESSION['$arUser']=$arUser;
$USER = new CUser;
$arAuthResult = $USER->Login($arUser['LOGIN'], $arUser['PASSWORD'], "Y","N");
}
//$_SESSION['user777authorize']=$arFields;
if(($arFields["IBLOCK_ID"] == 16)&&(CModule::IncludeModule("catalog"))&&(CModule::IncludeModule("sale"))){
$price_product=floatval($arFields["PROPERTY_VALUES"][86]);
$quantity_product=floatval($arFields["PROPERTY_VALUES"][87]);
if($price_product){
$PRODUCT_ID = $arFields['ID'];
$PRICE_TYPE_ID = 1;
$arFieldsprice = Array(
"PRODUCT_ID" => $PRODUCT_ID,
"CATALOG_GROUP_ID" => $PRICE_TYPE_ID,
"PRICE" =>$price_product,
"CURRENCY" => "RUB",
"QUANTITY_FROM" => 1,
);
$res = CPrice::GetList(
array(),
array(
"PRODUCT_ID" => $PRODUCT_ID,
"CATALOG_GROUP_ID" => $PRICE_TYPE_ID
)
);
if ($arr = $res->Fetch())
{
CPrice::Update($arr["ID"], $arFieldsprice);
}
else
{
CPrice::Add($arFieldsprice,true);
}
}
}
if (
(
(($arFields["IBLOCK_ID"] == 2)&& (is_numeric($arFields["PROPERTY_VALUES"][73])))
||
(($arFields["IBLOCK_ID"] == 15)&& (is_numeric($arFields["PROPERTY_VALUES"][76])))
||
(($arFields["IBLOCK_ID"] == 14)&& (is_numeric($arFields["PROPERTY_VALUES"][78])))
)
&&
CModule::IncludeModule("catalog")
&&
CModule::IncludeModule("sale")
&&
((strstr($_SERVER['REQUEST_URI'],'/personal/moy-magazin/'))||(strstr($_SERVER['REQUEST_URI'],'/obyavleniya/add-ads/')))
)
{
switch($arFields["IBLOCK_ID"]){
case 2:
$price_product=floatval($arFields["PROPERTY_VALUES"][73]);
$quantity_product=floatval($arFields["PROPERTY_VALUES"][75]);
break;
case 14:
$price_product=floatval($arFields["PROPERTY_VALUES"][78]);
$quantity_product=floatval($arFields["PROPERTY_VALUES"][79]);
//.........这里部分代码省略.........
示例9: strval
$arFields['SUBSCRIBE'] = strval($_POST['SUBSCRIBE']);
}
if (!$bUseStoreControl) {
$arFields["QUANTITY"] = $CAT_BASE_QUANTITY;
if ($bEnableReservation && isset($CAT_BASE_QUANTITY_RESERVED)) {
$arFields["QUANTITY_RESERVED"] = $CAT_BASE_QUANTITY_RESERVED;
}
}
if ($arCatalog["SUBSCRIPTION"] == "Y") {
$arFields["PRICE_TYPE"] = $CAT_PRICE_TYPE;
$arFields["RECUR_SCHEME_TYPE"] = $CAT_RECUR_SCHEME_TYPE;
$arFields["RECUR_SCHEME_LENGTH"] = $CAT_RECUR_SCHEME_LENGTH;
$arFields["TRIAL_PRICE_ID"] = $CAT_TRIAL_PRICE_ID;
$arFields["WITHOUT_ORDER"] = $CAT_WITHOUT_ORDER;
}
CCatalogProduct::Add($arFields);
$arMeasureRatio = array('PRODUCT_ID' => $PRODUCT_ID, 'RATIO' => $CAT_MEASURE_RATIO);
$newRatio = true;
$currentRatioID = 0;
if (isset($_POST['CAT_MEASURE_RATIO_ID'])) {
$currentRatioID = (int) $_POST['CAT_MEASURE_RATIO_ID'];
if ($currentRatioID > 0) {
$ratioIterator = CCatalogMeasureRatio::getList(array(), array('ID' => $currentRatioID, 'PRODUCT_ID' => $PRODUCT_ID), false, false, array('ID', 'PRODUCT_ID'));
if ($currentRatio = $ratioIterator->Fetch()) {
$newRatio = false;
}
unset($currentRatio, $ratioIterator);
}
}
if ($newRatio) {
CCatalogMeasureRatio::add($arMeasureRatio);
示例10: while
while ($enum_fields = $property_enums->GetNext()) {
$arEnumIds[] = $enum_fields["ID"];
}
$dbElement = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $arIBlockFur["ID"], "XML_ID" => 56), false);
$arElement = $dbElement->Fetch();
$arOfferElements[] = array("PRODUCT" => array("IBLOCK_ID" => $IBLOCK_OFFERS_ID, "NAME" => GetMessage("CAT_OFFER_NAME_1"), "ACTIVE" => "Y", "PROPERTY_VALUES" => array($arProps["CML2_LINK"] => $arElement["ID"], $arProps["327"] => $arEnumIds[0], $arProps["329"] => GetMessage("CAT_OFFER_COLOR_1"))), "PRICE" => GetMessage("CAT_OFFER_PRICE_11"));
$arOfferElements[] = array("PRODUCT" => array("IBLOCK_ID" => $IBLOCK_OFFERS_ID, "NAME" => GetMessage("CAT_OFFER_NAME_1"), "ACTIVE" => "Y", "PROPERTY_VALUES" => array($arProps["CML2_LINK"] => $arElement["ID"], $arProps["327"] => $arEnumIds[1], $arProps["329"] => GetMessage("CAT_OFFER_COLOR_1"))), "PRICE" => GetMessage("CAT_OFFER_PRICE_12"));
$dbElement = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $arIBlockFur["ID"], "XML_ID" => 55), false);
$arElement = $dbElement->Fetch();
$arOfferElements[] = array("PRODUCT" => array("IBLOCK_ID" => $IBLOCK_OFFERS_ID, "NAME" => GetMessage("CAT_OFFER_NAME_2"), "ACTIVE" => "Y", "PROPERTY_VALUES" => array($arProps["CML2_LINK"] => $arElement["ID"], $arProps["327"] => $arEnumIds[2], $arProps["329"] => GetMessage("CAT_OFFER_COLOR_1"))), "PRICE" => GetMessage("CAT_OFFER_PRICE_21"));
$arOfferElements[] = array("PRODUCT" => array("IBLOCK_ID" => $IBLOCK_OFFERS_ID, "NAME" => GetMessage("CAT_OFFER_NAME_2"), "ACTIVE" => "Y", "PROPERTY_VALUES" => array($arProps["CML2_LINK"] => $arElement["ID"], $arProps["327"] => $arEnumIds[1], $arProps["329"] => GetMessage("CAT_OFFER_COLOR_3"))), "PRICE" => GetMessage("CAT_OFFER_PRICE_22"));
$arOfferElements[] = array("PRODUCT" => array("IBLOCK_ID" => $IBLOCK_OFFERS_ID, "NAME" => GetMessage("CAT_OFFER_NAME_2"), "ACTIVE" => "Y", "PROPERTY_VALUES" => array($arProps["CML2_LINK"] => $arElement["ID"], $arProps["327"] => $arEnumIds[1], $arProps["329"] => GetMessage("CAT_OFFER_COLOR_1"))), "PRICE" => GetMessage("CAT_OFFER_PRICE_23"));
foreach ($arOfferElements as $key => $arOffer) {
$el = new CIBlockElement();
$elementID = $el->Add($arOffer["PRODUCT"]);
$elementProduct = CCatalogProduct::Add(array("ID" => $elementID, "QUANTITY" => "0", "QUANTITY_TRACE" => "D", "WEIGHT" => "0"));
$dbSite = CSite::GetByID(WIZARD_SITE_ID);
if ($arSite = $dbSite->Fetch()) {
$lang = $arSite["LANGUAGE_ID"];
}
if (strlen($lang) <= 0) {
$lang = "ru";
}
$defCurrency = "EUR";
if ($lang == "ru") {
$shopLocalization = $wizard->GetVar("shopLocalization");
if ($shopLocalization == "ua") {
$defCurrency = "UAH";
} else {
$defCurrency = "RUB";
}
示例11: orderHistory
//.........这里部分代码省略.........
$optionsOrderTypes[$order['orderType']] = $orderType;
} else {
$optionsOrderTypes[$order['orderType']] = $defaultOrderType;
}
}
// we dont need new orders without any customers (can check only for externalId)
if (!isset($order['customer']['externalId'])) {
if (!isset($order['customer']['id'])) {
continue;
}
$registerNewUser = true;
if (!isset($order['customer']['email']) || $order['customer']['email'] == '') {
$login = $order['customer']['email'] = uniqid('user_' . time()) . '@crm.com';
} else {
$dbUser = CUser::GetList($by = 'ID', $sort = 'ASC', array('=EMAIL' => $order['email']));
switch ($dbUser->SelectedRowsCount()) {
case 0:
$login = $order['customer']['email'];
break;
case 1:
$arUser = $dbUser->Fetch();
$registeredUserID = $arUser['ID'];
$registerNewUser = false;
break;
default:
$login = uniqid('user_' . time()) . '@crm.com';
break;
}
}
if ($registerNewUser === true) {
$userPassword = uniqid();
$newUser = new CUser();
$arFields = array("NAME" => self::fromJSON($order['customer']['firstName']), "LAST_NAME" => self::fromJSON($order['customer']['lastName']), "EMAIL" => $order['customer']['email'], "LOGIN" => $login, "LID" => "ru", "ACTIVE" => "Y", "PASSWORD" => $userPassword, "CONFIRM_PASSWORD" => $userPassword);
$registeredUserID = $newUser->Add($arFields);
if ($registeredUserID === false) {
self::eventLog('ICrmOrderActions::orderHistory', 'CUser::Register', 'Error register user');
continue;
}
try {
$api->customerFixExternalIds(array(array('id' => $order['customer']['id'], 'externalId' => $registeredUserID)));
} catch (\RetailCrm\Exception\CurlException $e) {
self::eventLog('ICrmOrderActions::orderHistory', 'RetailCrm\\RestApi::customerFixExternalIds::CurlException', $e->getCode() . ': ' . $e->getMessage());
continue;
}
}
$order['customer']['externalId'] = $registeredUserID;
}
// new order
$newOrderFields = array('LID' => CSite::GetDefSite(), 'PERSON_TYPE_ID' => isset($optionsOrderTypes[$order['orderType']]) ? $optionsOrderTypes[$order['orderType']] : $defaultOrderType, 'PAYED' => 'N', 'CANCELED' => 'N', 'STATUS_ID' => 'N', 'PRICE' => 0, 'CURRENCY' => CCurrency::GetBaseCurrency(), 'USER_ID' => $order['customer']['externalId'], 'PAY_SYSTEM_ID' => 0, 'PRICE_DELIVERY' => 0, 'DELIVERY_ID' => 0, 'DISCOUNT_VALUE' => 0, 'USER_DESCRIPTION' => '');
if (count($optionsSitesList) > 1 && ($lid = array_search($order['site'], $optionsSitesList))) {
$newOrderFields['LID'] = $lid;
}
$externalId = CSaleOrder::Add($newOrderFields);
if (!isset($order['externalId'])) {
try {
$api->orderFixExternalIds(array(array('id' => $order['id'], 'externalId' => $externalId)));
} catch (\RetailCrm\Exception\CurlException $e) {
self::eventLog('ICrmOrderActions::orderHistory', 'RetailCrm\\RestApi::orderFixExternalIds::CurlException', $e->getCode() . ': ' . $e->getMessage());
continue;
}
}
$order['externalId'] = $externalId;
}
if (isset($order['externalId']) && $order['externalId']) {
// custom orderType function
if (function_exists('intarocrm_set_order_type')) {
示例12: htmlspecialcharsback
$arPropertySaveValues[$srcKey] = CIBlock::makeFilePropArray($srcValue, false);
}
break;
}
}
}
$arPropertySaveValues["CML2_LINK"] = $parentElement;
$arIBlockElementAdd['PROPERTY_VALUES'] = $arPropertySaveValues;
$sku = new \Bitrix\Iblock\Template\Entity\Element(0);
$sku->setFields($arIBlockElementAdd);
$arIBlockElementAdd["NAME"] = htmlspecialcharsback(\Bitrix\Iblock\Template\Engine::process($sku, $title));
unset($arIBlockElementAdd['PROPERTY_VALUES']["CML2_LINK"]);
$idNewElement = $obIBlockElement->Add($arIBlockElementAdd, false, true, true);
if ($idNewElement) {
$productData['ID'] = $idNewElement;
CCatalogProduct::Add($productData, false);
foreach ($arPriceGroup as $price) {
CPrice::Add(array("PRODUCT_ID" => $idNewElement, "CURRENCY" => $price["CURRENCY"], "PRICE" => $price["PRICE"], "CATALOG_GROUP_ID" => $price["TYPE"]));
}
$element = new \Bitrix\Iblock\InheritedProperty\ElementValues($subIBlockId, $idNewElement);
$template = new \Bitrix\Iblock\InheritedProperty\BaseTemplate($element);
$template->set(array("MY_TEMPLATE" => $title));
} else {
$errorMessage .= $obIBlockElement->LAST_ERROR;
break;
}
}
unset($productData);
if ($idNewElement) {
?>
<script type="text/javascript">
示例13: OnBeforePrologHandler
//.........这里部分代码省略.........
$strValueName = $arOldNamePropListCache[$arProp['CODE']][$arProp['VALUE_ENUM_ID']];
$intValueKey = array_search($strValueName, $arNamePropListCache[$arProp['CODE']]);
if ($intValueKey !== false) {
$arSrc['PROPERTY_VALUES'][$arProp['CODE']] = $intValueKey;
}
}
}
}
}
}
} elseif ($arProp['PROPERTY_TYPE'] == 'S' || $arProp['PROPERTY_TYPE'] == 'N') {
if ($arProp['MULTIPLE'] == 'Y') {
if (is_array($arProp['~VALUE'])) {
if ($arProp['WITH_DESCRIPTION'] == 'Y') {
$arSrc['PROPERTY_VALUES'][$arProp['CODE']] = array();
foreach ($arProp['~VALUE'] as $propValueKey => $propValue) {
$arSrc['PROPERTY_VALUES'][$arProp['CODE']][] = array('VALUE' => $propValue, 'DESCRIPTION' => $arProp['~DESCRIPTION'][$propValueKey]);
}
unset($propValue, $propValueKey);
} else {
$arSrc['PROPERTY_VALUES'][$arProp['CODE']] = $arProp['~VALUE'];
}
}
} else {
$arSrc['PROPERTY_VALUES'][$arProp['CODE']] = $arProp['WITH_DESCRIPTION'] == 'Y' ? array('VALUE' => $arProp['~VALUE'], 'DESCRIPTION' => $arProp['~DESCRIPTION']) : $arProp['~VALUE'];
}
} else {
$arSrc['PROPERTY_VALUES'][$arProp['CODE']] = $arProp['~VALUE'];
}
}
if (isset($arProp)) {
unset($arProp);
}
AddMessage2Log($arSrc['PROPERTY_VALUES']);
$intNewID = $el->Add($arSrc, true, true, true);
if ($intNewID) {
if ($boolCatalog && $boolCopyCatalog) {
$priceRes = CPrice::GetListEx(array(), array('PRODUCT_ID' => $ID), false, false, array('PRODUCT_ID', 'EXTRA_ID', 'CATALOG_GROUP_ID', 'PRICE', 'CURRENCY', 'QUANTITY_FROM', 'QUANTITY_TO'));
while ($arPrice = $priceRes->Fetch()) {
$arPrice['PRODUCT_ID'] = $intNewID;
CPrice::Add($arPrice);
}
}
if ($boolCatalog && $boolNewCatalog) {
$arProduct = array('ID' => $intNewID);
if ($boolCopyCatalog) {
$productRes = CCatalogProduct::GetList(array(), array('ID' => $ID), false, false, array('QUANTITY', 'QUANTITY_TRACE_ORIG', 'CAN_BUY_ZERO_ORIG', 'NEGATIVE_AMOUNT_TRACE_ORIG', 'SUBSCRIBE_ORIG', 'WEIGHT', 'PRICE_TYPE', 'RECUR_SCHEME_TYPE', 'RECUR_SCHEME_LENGTH', 'TRIAL_PRICE_ID', 'WITHOUT_ORDER', 'SELECT_BEST_PRICE', 'VAT_ID', 'VAT_INCLUDED', 'WIDTH', 'LENGTH', 'HEIGHT', 'PURCHASING_PRICE', 'PURCHASING_CURRENCY', 'MEASURE'));
if ($arCurProduct = $productRes->Fetch()) {
$arProduct = $arCurProduct;
$arProduct['ID'] = $intNewID;
$arProduct['QUANTITY_TRACE'] = $arProduct['QUANTITY_TRACE_ORIG'];
$arProduct['CAN_BUY_ZERO'] = $arProduct['CAN_BUY_ZERO_ORIG'];
$arProduct['NEGATIVE_AMOUNT_TRACE'] = $arProduct['NEGATIVE_AMOUNT_TRACE_ORIG'];
if (isset($arProduct['SUBSCRIBE_ORIG'])) {
$arProduct['SUBSCRIBE'] = $arProduct['SUBSCRIBE_ORIG'];
}
foreach ($arProduct as $productKey => $productValue) {
if ($productValue === null) {
unset($arProduct[$productKey]);
}
}
}
}
CCatalogProduct::Add($arProduct, false);
}
if ($_REQUEST['action'] == 'asd_move') {
示例14: ImportElementPrices
function ImportElementPrices($arXMLElement, &$counter)
{
/** @global CMain $APPLICATION */
global $APPLICATION;
static $catalogs = array();
$arElement = array(
"ID" => 0,
"XML_ID" => $arXMLElement[GetMessage("IBLOCK_XML2_ID")],
);
$hashPosition = strrpos($arElement["XML_ID"], "#");
if (
$this->use_offers
&& $hashPosition === false
&& isset($this->PROPERTY_MAP["CML2_LINK"])
&& isset($this->arProperties[$this->PROPERTY_MAP["CML2_LINK"]])
)
{
$IBLOCK_ID = $this->arProperties[$this->PROPERTY_MAP["CML2_LINK"]]["LINK_IBLOCK_ID"];
if (!isset($catalogs[$IBLOCK_ID]))
{
$catalogs[$IBLOCK_ID] = true;
$rs = CCatalog::GetList(array(),array("IBLOCK_ID" => $IBLOCK_ID));
if (!$rs->Fetch())
{
$obCatalog = new CCatalog();
$boolFlag = $obCatalog->Add(array(
"IBLOCK_ID" => $IBLOCK_ID,
"YANDEX_EXPORT" => "N",
"SUBSCRIPTION" => "N",
));
if (!$boolFlag)
{
if ($ex = $APPLICATION->GetException())
$this->LAST_ERROR = $ex->GetString();
return 0;
}
}
}
}
else
{
$IBLOCK_ID = $this->next_step["IBLOCK_ID"];
}
$obElement = new CIBlockElement;
$rsElement = $obElement->GetList(
Array("ID"=>"asc"),
Array("=XML_ID" => $arElement["XML_ID"], "IBLOCK_ID" => $IBLOCK_ID),
false, false,
Array("ID", "TMP_ID", "ACTIVE")
);
if($arDBElement = $rsElement->Fetch())
{
$arElement["ID"] = $arDBElement["ID"];
if(isset($arXMLElement[GetMessage("IBLOCK_XML2_PRICES")]))
{//Collect price information for future use
$arElement["PRICES"] = array();
foreach($arXMLElement[GetMessage("IBLOCK_XML2_PRICES")] as $price)
{
if(
isset($price[GetMessage("IBLOCK_XML2_PRICE_TYPE_ID")])
&& array_key_exists($price[GetMessage("IBLOCK_XML2_PRICE_TYPE_ID")], $this->PRICES_MAP)
)
{
$price["PRICE"] = $this->PRICES_MAP[$price[GetMessage("IBLOCK_XML2_PRICE_TYPE_ID")]];
$arElement["PRICES"][] = $price;
}
}
$arElement["DISCOUNTS"] = array();
if(isset($arXMLElement[GetMessage("IBLOCK_XML2_DISCOUNTS")]))
{
foreach($arXMLElement[GetMessage("IBLOCK_XML2_DISCOUNTS")] as $discount)
{
if(
isset($discount[GetMessage("IBLOCK_XML2_DISCOUNT_CONDITION")])
&& $discount[GetMessage("IBLOCK_XML2_DISCOUNT_CONDITION")] === GetMessage("IBLOCK_XML2_DISCOUNT_COND_VOLUME")
)
{
$discount_value = $this->ToInt($discount[GetMessage("IBLOCK_XML2_DISCOUNT_COND_VALUE")]);
$discount_percent = $this->ToFloat($discount[GetMessage("IBLOCK_XML2_DISCOUNT_COND_PERCENT")]);
if($discount_value > 0 && $discount_percent > 0)
$arElement["DISCOUNTS"][$discount_value] = $discount_percent;
}
}
}
}
if(isset($arXMLElement[GetMessage("IBLOCK_XML2_AMOUNT")]))
{
$arElementTmp = array();
$arElement["QUANTITY_RESERVED"] = 0;
if($arElement["ID"])
$arElementTmp = CCatalogProduct::GetById($arElement["ID"]);
if(is_array($arElementTmp) && !empty($arElementTmp) && isset($arElementTmp["QUANTITY_RESERVED"]))
$arElement["QUANTITY_RESERVED"] = $arElementTmp["QUANTITY_RESERVED"];
//.........这里部分代码省略.........
示例15: Add
public static function Add($arFields)
{
if (!CModule::IncludeModule('catalog')) {
return false;
}
global $DB;
$element = new CIBlockElement();
$ID = isset($arFields['ID']) ? $arFields['ID'] : null;
if ($ID === null) {
//Try to create a CIBlockElement
$arElement = array();
if (isset($arFields['NAME'])) {
$arElement['NAME'] = $arFields['NAME'];
}
if (isset($arFields['SORT'])) {
$arElement['SORT'] = $arFields['SORT'];
}
if (isset($arFields['ACTIVE'])) {
$arElement['ACTIVE'] = $arFields['ACTIVE'];
}
if (isset($arFields['DETAIL_PICTURE'])) {
$arElement['DETAIL_PICTURE'] = $arFields['DETAIL_PICTURE'];
}
if (isset($arFields['DESCRIPTION'])) {
$arElement['DETAIL_TEXT'] = $arFields['DESCRIPTION'];
$arElement['DETAIL_TEXT_TYPE'] = 'text';
}
if (isset($arFields['DESCRIPTION_TYPE'])) {
$arElement['DETAIL_TEXT_TYPE'] = $arFields['DESCRIPTION_TYPE'];
}
if (isset($arFields['PREVIEW_PICTURE'])) {
$arElement['PREVIEW_PICTURE'] = $arFields['PREVIEW_PICTURE'];
}
if (isset($arFields['PREVIEW_TEXT'])) {
$arElement['PREVIEW_TEXT'] = $arFields['PREVIEW_TEXT'];
$arElement['PREVIEW_TEXT_TYPE'] = 'text';
}
if (isset($arFields['PREVIEW_TEXT_TYPE'])) {
$arElement['PREVIEW_TEXT_TYPE'] = $arFields['PREVIEW_TEXT_TYPE'];
}
if (isset($arFields['CATALOG_ID'])) {
$arElement['IBLOCK_ID'] = intval($arFields['CATALOG_ID']);
} else {
$arElement['IBLOCK_ID'] = $arFields['CATALOG_ID'] = CCrmCatalog::EnsureDefaultExists();
}
if (isset($arFields['SECTION_ID'])) {
$arElement['IBLOCK_SECTION_ID'] = $arFields['SECTION_ID'];
$arElement['IBLOCK_SECTION'] = array($arElement['IBLOCK_SECTION_ID']);
}
if (isset($arFields['XML_ID'])) {
$arElement['XML_ID'] = $arFields['XML_ID'];
} else {
if (isset($arFields['ORIGINATOR_ID']) || isset($arFields['ORIGIN_ID'])) {
if (isset($arFields['ORIGINATOR_ID']) && isset($arFields['ORIGIN_ID'])) {
$arElement['XML_ID'] = $arFields['ORIGINATOR_ID'] . '#' . $arFields['ORIGIN_ID'];
} else {
if (isset($arFields['ORIGINATOR_ID'])) {
$arElement['XML_ID'] = $arFields['ORIGINATOR_ID'] . '#';
} else {
$arElement['XML_ID'] = '#' . $arFields['ORIGIN_ID'];
}
}
} else {
if ($arElement['IBLOCK_ID'] != self::getDefaultCatalogId()) {
$arElement['XML_ID'] = '#';
}
}
}
if (!$element->CheckFields($arElement)) {
self::RegisterError($element->LAST_ERROR);
return false;
}
if (isset($arFields['PROPERTY_VALUES'])) {
$arElement['PROPERTY_VALUES'] = $arFields['PROPERTY_VALUES'];
}
$ID = intval($element->Add($arElement));
if ($ID <= 0) {
self::$LAST_ERROR = $element->LAST_ERROR;
return false;
}
$arFields['ID'] = $ID;
}
if (!self::CheckFields('ADD', $arFields, 0)) {
$element->Delete($ID);
return false;
}
$CCatalogProduct = new CCatalogProduct();
$arCatalogProductFields = array('ID' => $ID, 'QUANTITY' => 0);
if (isset($arFields['VAT_INCLUDED'])) {
$arCatalogProductFields['VAT_INCLUDED'] = $arFields['VAT_INCLUDED'];
}
if (isset($arFields['VAT_ID']) && !empty($arFields['VAT_ID'])) {
$arCatalogProductFields['VAT_ID'] = $arFields['VAT_ID'];
}
if (isset($arFields['MEASURE']) && !empty($arFields['MEASURE'])) {
$arCatalogProductFields['MEASURE'] = $arFields['MEASURE'];
}
if ($CCatalogProduct->Add($arCatalogProductFields)) {
if (isset($arFields['PRICE']) && isset($arFields['CURRENCY_ID'])) {
self::setPrice($ID, $arFields['PRICE'], $arFields['CURRENCY_ID']);
//.........这里部分代码省略.........