本文整理汇总了PHP中CSaleUser::getList方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleUser::getList方法的具体用法?PHP CSaleUser::getList怎么用?PHP CSaleUser::getList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSaleUser
的用法示例。
在下文中一共展示了CSaleUser::getList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: catchCatalogBasket
public static function catchCatalogBasket($id, $arFields)
{
global $APPLICATION;
// alter b_sale_basket - add recommendation, update it here
if (!static::isOn()) {
return;
}
// get product id by offer id
$productInfo = \CCatalogSKU::GetProductInfo($arFields['PRODUCT_ID']);
if (!empty($productInfo['ID'])) {
$realProductId = $productInfo['ID'];
} else {
$realProductId = $arFields['PRODUCT_ID'];
}
// select site user id & recommendation id
$siteUserId = 0;
$recommendationId = '';
// first, try to find in cookies
$recommendationCookie = $APPLICATION->get_cookie(static::getCookieLogName());
if (!empty($recommendationCookie)) {
$recommendations = static::decodeProductLog($recommendationCookie);
if (is_array($recommendations) && isset($recommendations[$realProductId])) {
$recommendationId = $recommendations[$realProductId][0];
}
}
if (empty($recommendationId)) {
// ok then, lets see in views history
//if(\COption::GetOptionString("sale", "encode_fuser_id", "N") == "Y")
if (!is_numeric($arFields['FUSER_ID'])) {
$filter = array('CODE' => $arFields['FUSER_ID']);
} else {
$filter = array('ID' => $arFields['FUSER_ID']);
}
$result = \CSaleUser::getList($filter);
if (!empty($result)) {
$siteUserId = $result['USER_ID'];
// select recommendation id
$fuser = $result['ID'];
$viewResult = CatalogViewedProductTable::getList(array('select' => array('RECOMMENDATION'), 'filter' => array('=FUSER_ID' => $fuser, '=PRODUCT_ID' => $arFields['PRODUCT_ID']), 'order' => array('DATE_VISIT' => 'DESC')))->fetch();
if (!empty($viewResult['RECOMMENDATION'])) {
$recommendationId = $viewResult['RECOMMENDATION'];
}
}
}
// prepare data
$data = array('product_id' => $realProductId, 'user_id' => $siteUserId, 'bx_user_id' => static::getBxUserId(), 'domain' => Context::getCurrent()->getServer()->getHttpHost(), 'recommendation' => $recommendationId, 'date' => date(DATE_ISO8601));
CounterDataTable::add(array('TYPE' => 'basket', 'DATA' => $data));
// update basket with recommendation id
if (!empty($recommendationId)) {
$conn = Application::getConnection();
$helper = $conn->getSqlHelper();
$conn->query("UPDATE " . $helper->quote('b_sale_basket') . " SET RECOMMENDATION='" . $helper->forSql($recommendationId) . "' WHERE ID=" . (int) $id);
}
}
示例2: catchCatalogBasket
public static function catchCatalogBasket($id, $arFields)
{
if (!static::isOn()) {
return;
}
// select site user id
$siteUserId = 0;
if (\COption::GetOptionString("sale", "encode_fuser_id", "N") == "Y") {
$filter = array('CODE' => $arFields['FUSER_ID']);
} else {
$filter = array('ID' => $arFields['FUSER_ID']);
}
$result = \CSaleUser::getList($filter);
if (!empty($result)) {
$siteUserId = $result['USER_ID'];
}
// prepare data
$data = array('product_id' => $arFields['PRODUCT_ID'], 'user_id' => $siteUserId, 'bx_user_id' => static::getBxUserId(), 'domain' => Context::getCurrent()->getServer()->getHttpHost(), 'recommendation' => '0', 'date' => date(DATE_ISO8601));
CounterDataTable::add(array('TYPE' => 'basket', 'DATA' => $data));
}
示例3: catchCatalogBasket
public static function catchCatalogBasket($id, $arFields)
{
// exclude empty cookie
if (!static::getBxUserId()) {
return;
}
if (!isset($arFields['MODULE']) || $arFields['MODULE'] != 'catalog') {
// catalog items only
return;
}
global $APPLICATION;
// alter b_sale_basket - add recommendation, update it here
if (!static::isOn()) {
return;
}
// get product id by offer id
$productInfo = \CCatalogSKU::GetProductInfo($arFields['PRODUCT_ID']);
$iblockId = 0;
if (!empty($productInfo['ID'])) {
$realProductId = $productInfo['ID'];
$iblockId = $productInfo['IBLOCK_ID'];
} else {
$realProductId = $arFields['PRODUCT_ID'];
// get iblock id
$element = \Bitrix\Iblock\ElementTable::getRow(array('select' => array('IBLOCK_ID'), 'filter' => array('=ID' => $realProductId)));
if (!empty($element)) {
$iblockId = $element['IBLOCK_ID'];
}
}
// select site user id & recommendation id
$siteUserId = 0;
$recommendationId = '';
// first, try to find in cookies
$recommendationCookie = $APPLICATION->get_cookie(static::getCookieLogName());
if (!empty($recommendationCookie)) {
$recommendations = static::decodeProductLog($recommendationCookie);
if (is_array($recommendations) && isset($recommendations[$realProductId])) {
$recommendationId = $recommendations[$realProductId][0];
}
}
if (empty($recommendationId)) {
// ok then, lets see in views history
//if(\COption::GetOptionString("sale", "encode_fuser_id", "N") == "Y")
if (!is_numeric($arFields['FUSER_ID'])) {
$filter = array('CODE' => $arFields['FUSER_ID']);
} else {
$filter = array('ID' => $arFields['FUSER_ID']);
}
$result = \CSaleUser::getList($filter);
if (!empty($result)) {
$siteUserId = $result['USER_ID'];
// select recommendation id
$fuser = $result['ID'];
$viewResult = CatalogViewedProductTable::getList(array('select' => array('RECOMMENDATION'), 'filter' => array('=FUSER_ID' => $fuser, '=PRODUCT_ID' => $arFields['PRODUCT_ID']), 'order' => array('DATE_VISIT' => 'DESC')))->fetch();
if (!empty($viewResult['RECOMMENDATION'])) {
$recommendationId = $viewResult['RECOMMENDATION'];
}
}
}
// prepare data
$data = array('product_id' => $realProductId, 'iblock_id' => $iblockId, 'user_id' => $siteUserId, 'bx_user_id' => static::getBxUserId(), 'domain' => Context::getCurrent()->getServer()->getHttpHost(), 'recommendation' => $recommendationId, 'date' => date(DATE_ISO8601));
// debug info
global $USER;
$data['real_user_id'] = $USER->getId() ?: 0;
$data['is_admin'] = (int) $USER->IsAdmin();
$data['admin_section'] = (int) (defined('ADMIN_SECTION') && ADMIN_SECTION);
$data['admin_panel'] = (int) \CTopPanel::shouldShowPanel();
// try to guess unnatural baskets
$data['artificial_basket'] = (int) ($data['user_id'] > 0 && $data['user_id'] != $data['real_user_id'] || $data['is_admin'] || $data['admin_section'] || $data['admin_panel']);
// save
CounterDataTable::add(array('TYPE' => 'basket', 'DATA' => $data));
// update basket with recommendation id
if (!empty($recommendationId)) {
$conn = Application::getConnection();
$helper = $conn->getSqlHelper();
$conn->query("UPDATE " . $helper->quote('b_sale_basket') . " SET RECOMMENDATION='" . $helper->forSql($recommendationId) . "' WHERE ID=" . (int) $id);
}
}