本文整理汇总了PHP中CCatalogSKU::getInfoByOfferIBlock方法的典型用法代码示例。如果您正苦于以下问题:PHP CCatalogSKU::getInfoByOfferIBlock方法的具体用法?PHP CCatalogSKU::getInfoByOfferIBlock怎么用?PHP CCatalogSKU::getInfoByOfferIBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCatalogSKU
的用法示例。
在下文中一共展示了CCatalogSKU::getInfoByOfferIBlock方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: refresh
/**
* Common function, used to update/insert any product.
*
* @param int $productId Id of product.
* @param int $fuserId User basket id.
* @param string $siteId Site id.
* @param int $elementId Parent id.
* @param string $recommendationId Bigdata recommendation id.
*
* @return int Id of row.
*/
public static function refresh($productId, $fuserId, $siteId = SITE_ID, $elementId = 0, $recommendationId = '')
{
$connection = Application::getConnection();
$productId = (int) $productId;
if ($productId <= 0) {
return -1;
}
$fuserId = (int) $fuserId;
if ($fuserId <= 0) {
return -1;
}
if (!is_string($siteId) || strlen($siteId) <= 0) {
return -1;
}
$filter = array("FUSER_ID" => $fuserId, "SITE_ID" => $siteId);
if ($elementId > 0) {
$filter["ELEMENT_ID"] = $elementId;
// Delete parent product id (for capability)
if ($elementId != $productId) {
$connection->query("DELETE FROM\n\t\t\t\t\t\t\t\t\t\tb_catalog_viewed_product\n\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\tPRODUCT_ID = " . intval($elementId) . "\n\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\tFUSER_ID = " . intval($fuserId) . "\n\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\tSITE_ID = '" . $connection->getSqlHelper()->forSql($siteId) . "'");
}
} else {
$iblockId = (int) \CIBlockElement::getIBlockByID($productId);
if ($iblockId <= 0) {
return -1;
}
$productInfo = \CCatalogSKU::getProductInfo($productId, $iblockId);
// Concrete SKU ID
if (!empty($productInfo)) {
$filter['PRODUCT_ID'] = array();
$siblings = array();
// Delete parent product id (for capability)
$connection->query("DELETE FROM\n\t\t\t\t\t\t\t\t\t\tb_catalog_viewed_product\n\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\tPRODUCT_ID = " . intval($productInfo['ID']) . "\n\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\tFUSER_ID = " . intval($fuserId) . "\n\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\tSITE_ID = '" . $connection->getSqlHelper()->forSql($siteId) . "'");
$skuInfo = \CCatalogSKU::getInfoByOfferIBlock($iblockId);
$skus = \CIBlockElement::getList(array(), array('IBLOCK_ID' => $iblockId, 'PROPERTY_' . $skuInfo['SKU_PROPERTY_ID'] => $productInfo['ID']), false, false, array('ID', 'IBLOCK_ID'));
while ($oneSku = $skus->fetch()) {
$siblings[] = $oneSku['ID'];
}
$filter["PRODUCT_ID"] = $siblings;
} else {
$filter["PRODUCT_ID"] = $productId;
}
}
$iterator = static::getList(array("filter" => $filter, "select" => array("ID", "FUSER_ID", "DATE_VISIT", "PRODUCT_ID", "SITE_ID", "VIEW_COUNT")));
if ($row = $iterator->fetch()) {
static::update($row["ID"], array("PRODUCT_ID" => $productId, "DATE_VISIT" => new \Bitrix\Main\Type\DateTime(), 'VIEW_COUNT' => $row['VIEW_COUNT'] + 1, "ELEMENT_ID" => $elementId, "RECOMMENDATION" => $recommendationId));
return $row['ID'];
} else {
$result = static::add(array("FUSER_ID" => $fuserId, "DATE_VISIT" => new \Bitrix\Main\Type\DateTime(), "PRODUCT_ID" => $productId, "ELEMENT_ID" => $elementId, "SITE_ID" => $siteId, "VIEW_COUNT" => 1, "RECOMMENDATION" => $recommendationId));
return $result->getId();
}
}
示例2: resolveIblock
/**
* For offers iblock identifier returns it's products iblock.
* Otherwise $iblockId returned.
*
* @param integer $iblockId Information block identifier.
*
* @return integer
*/
public static function resolveIblock($iblockId)
{
if (self::$catalog === null) {
self::$catalog = \Bitrix\Main\Loader::includeModule("catalog");
}
if (self::$catalog) {
$catalog = \CCatalogSKU::getInfoByOfferIBlock($iblockId);
if (!empty($catalog) && is_array($catalog)) {
return $catalog["PRODUCT_IBLOCK_ID"];
}
}
return $iblockId;
}
示例3: refresh
/**
* Common function, used to update/insert any product.
*
* @param int $productId Id of product.
* @param int $fuserId User basket id.
* @param string $siteId Site id.
*
* @return int Id of row.
*/
public static function refresh($productId, $fuserId, $siteId = SITE_ID)
{
$connection = Application::getConnection();
$productId = (int) $productId;
if ($productId <= 0) {
return -1;
}
$iblockID = (int) \CIBlockElement::getIBlockByID($productId);
if ($iblockID <= 0) {
return -1;
}
$productInfo = \CCatalogSKU::getProductInfo($productId, $iblockID);
$fuserId = (int) $fuserId;
if ($fuserId <= 0) {
return -1;
}
if (!is_string($siteId) || strlen($siteId) <= 0) {
return -1;
}
$filter = array("FUSER_ID" => $fuserId, "SITE_ID" => $siteId);
// Concrete SKU ID
if (!empty($productInfo)) {
$filter['PRODUCT_ID'] = array();
$siblings = array();
// Delete parent product id (for capability)
$connection->query("DELETE FROM b_catalog_viewed_product WHERE PRODUCT_ID = {$productInfo['ID']} AND FUSER_ID = {$fuserId} AND SITE_ID = '{$siteId}'");
$skuInfo = \CCatalogSKU::getInfoByOfferIBlock($iblockID);
$skus = \CIBlockElement::getList(array(), array('IBLOCK_ID' => $iblockID, 'PROPERTY_' . $skuInfo['SKU_PROPERTY_ID'] => $productInfo['ID']), false, false, array('ID', 'IBLOCK_ID'));
while ($oneSku = $skus->fetch()) {
$siblings[] = $oneSku['ID'];
}
$filter["PRODUCT_ID"] = $siblings;
} else {
$filter["PRODUCT_ID"] = $productId;
}
$iterator = static::getList(array("filter" => $filter, "select" => array("ID", "FUSER_ID", "DATE_VISIT", "PRODUCT_ID", "SITE_ID", "VIEW_COUNT")));
if ($row = $iterator->fetch()) {
static::update($row["ID"], array("PRODUCT_ID" => $productId, "DATE_VISIT" => new \Bitrix\Main\Type\DateTime(), 'VIEW_COUNT' => $row['VIEW_COUNT'] + 1));
return $row['ID'];
} else {
$result = static::add(array("FUSER_ID" => $fuserId, "DATE_VISIT" => new \Bitrix\Main\Type\DateTime(), "PRODUCT_ID" => $productId, "SITE_ID" => $siteId, "VIEW_COUNT" => 1));
return $result->getId();
}
}
示例4: ExportProperties
function ExportProperties(&$PROPERTY_MAP)
{
$PROPERTY_MAP = array();
fwrite($this->fp, "\t\t<" . GetMessage("IBLOCK_XML2_PROPERTIES") . ">\n");
if ($this->bExtended) {
$arElementFields = array("CML2_ACTIVE" => GetMessage("IBLOCK_XML2_BX_ACTIVE"), "CML2_CODE" => GetMessage("IBLOCK_XML2_SYMBOL_CODE"), "CML2_SORT" => GetMessage("IBLOCK_XML2_SORT"), "CML2_ACTIVE_FROM" => GetMessage("IBLOCK_XML2_START_TIME"), "CML2_ACTIVE_TO" => GetMessage("IBLOCK_XML2_END_TIME"), "CML2_PREVIEW_TEXT" => GetMessage("IBLOCK_XML2_ANONS"), "CML2_DETAIL_TEXT" => GetMessage("IBLOCK_XML2_DETAIL"), "CML2_PREVIEW_PICTURE" => GetMessage("IBLOCK_XML2_PREVIEW_PICTURE"));
foreach ($arElementFields as $key => $value) {
fwrite($this->fp, $this->formatXMLNode(3, GetMessage("IBLOCK_XML2_PROPERTY"), array(GetMessage("IBLOCK_XML2_ID") => $key, GetMessage("IBLOCK_XML2_NAME") => $value, GetMessage("IBLOCK_XML2_MULTIPLE") => "false")));
}
}
$arFilter = array("IBLOCK_ID" => $this->arIBlock["ID"], "ACTIVE" => "Y");
$arSort = array("sort" => "asc");
$obProp = new CIBlockProperty();
$rsProp = $obProp->GetList($arSort, $arFilter);
while ($arProp = $rsProp->Fetch()) {
fwrite($this->fp, "\t\t\t<" . GetMessage("IBLOCK_XML2_PROPERTY") . ">\n");
$xml_id = $this->GetPropertyXML_ID($this->arIBlock["ID"], $arProp["NAME"], $arProp["ID"], $arProp["XML_ID"]);
$PROPERTY_MAP[$arProp["ID"]] = $xml_id;
$PROPERTY_MAP["~" . $arProp["ID"]] = $arProp["NAME"];
fwrite($this->fp, $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_ID"), $xml_id));
fwrite($this->fp, $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_NAME"), $arProp["NAME"]));
fwrite($this->fp, $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_MULTIPLE"), $arProp["MULTIPLE"] == "Y" ? "true" : "false"));
if ($arProp["PROPERTY_TYPE"] == "L") {
fwrite($this->fp, "\t\t\t\t<" . GetMessage("IBLOCK_XML2_CHOICE_VALUES") . ">\n");
$rsEnum = CIBlockProperty::GetPropertyEnum($arProp["ID"]);
while ($arEnum = $rsEnum->Fetch()) {
fwrite($this->fp, $this->formatXMLNode(5, GetMessage("IBLOCK_XML2_VALUE"), $arEnum["VALUE"]));
if ($this->bExtended) {
fwrite($this->fp, "\t\t\t\t\t<" . GetMessage("IBLOCK_XML2_CHOICE") . ">\n" . $this->formatXMLNode(6, GetMessage("IBLOCK_XML2_ID"), $arEnum["XML_ID"]) . $this->formatXMLNode(6, GetMessage("IBLOCK_XML2_VALUE"), $arEnum["VALUE"]) . $this->formatXMLNode(6, GetMessage("IBLOCK_XML2_BY_DEFAULT"), $arEnum["DEF"] == "Y" ? "true" : "false") . $this->formatXMLNode(6, GetMessage("IBLOCK_XML2_SORT"), intval($arEnum["SORT"])) . "\t\t\t\t\t</" . GetMessage("IBLOCK_XML2_CHOICE") . ">\n");
}
}
fwrite($this->fp, "\t\t\t\t</" . GetMessage("IBLOCK_XML2_CHOICE_VALUES") . ">\n");
}
if ($this->bExtended) {
$strUserSettings = '';
if ('' != $arProp["USER_TYPE"]) {
if (!empty($arProp['USER_TYPE_SETTINGS']) && is_array($arProp['USER_TYPE_SETTINGS'])) {
$strUserSettings = $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_USER_TYPE_SETTINGS"), serialize($arProp['USER_TYPE_SETTINGS']));
}
}
fwrite($this->fp, $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_SORT"), intval($arProp["SORT"])) . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_CODE"), $arProp["CODE"]) . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_PROPERTY_TYPE"), $arProp["PROPERTY_TYPE"]) . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_ROWS"), $arProp["ROW_COUNT"]) . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_COLUMNS"), $arProp["COL_COUNT"]) . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_LIST_TYPE"), $arProp["LIST_TYPE"]) . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_FILE_EXT"), $arProp["FILE_TYPE"]) . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_FIELDS_COUNT"), $arProp["MULTIPLE_CNT"]) . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_LINKED_IBLOCK"), $this->GetIBlockXML_ID($arProp["LINK_IBLOCK_ID"])) . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_WITH_DESCRIPTION"), $arProp["WITH_DESCRIPTION"] == "Y" ? "true" : "false") . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_SEARCH"), $arProp["SEARCHABLE"] == "Y" ? "true" : "false") . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_FILTER"), $arProp["FILTRABLE"] == "Y" ? "true" : "false") . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_USER_TYPE"), $arProp["USER_TYPE"]) . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_IS_REQUIRED"), $arProp["IS_REQUIRED"] == "Y" ? "true" : "false") . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_DEFAULT_VALUE"), serialize($arProp["DEFAULT_VALUE"])) . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_SERIALIZED"), 1) . $strUserSettings);
}
fwrite($this->fp, "\t\t\t</" . GetMessage("IBLOCK_XML2_PROPERTY") . ">\n");
}
fwrite($this->fp, "\t\t</" . GetMessage("IBLOCK_XML2_PROPERTIES") . ">\n");
if ($this->bExtended) {
$catalog = false;
if (CModule::IncludeModule("catalog")) {
$catalog = CCatalogSKU::getInfoByOfferIBlock($this->arIBlock["ID"]);
}
if (!empty($catalog) && is_array($catalog)) {
$this->ExportSmartFilter(2, $this->arIBlock["ID"], false, $PROPERTY_MAP, $catalog["PRODUCT_IBLOCK_ID"]);
} else {
$this->ExportSmartFilter(2, $this->arIBlock["ID"], 0, $PROPERTY_MAP);
}
}
}