function __construct($component = null) { parent::__construct($component); CModule::IncludeModule('iblock'); CModule::IncludeModule('aqw.shop'); CBitrixComponent::includeComponentClass('aqw:store.product'); }
<?php use Bitrix\Main\Localization\Loc; use Bitrix\Main\SystemException; use Bitrix\Main\Loader; if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } CBitrixComponent::includeComponentClass("bitrix:catalog.viewed.products"); class CSaleBestsellersComponent extends CCatalogViewedProductsComponent { /** * @param $params * @override * @return array */ public function onPrepareComponentParams($params) { $params = parent::onPrepareComponentParams($params); if (!isset($params["CACHE_TIME"])) { $params["CACHE_TIME"] = 86400; } $params["DETAIL_URL"] = trim($params["DETAIL_URL"]); if (isset($params["BY"]) && is_array($params["BY"])) { if (count($params["BY"])) { $params["BY"] = array_values($params["BY"]); $params["BY"] = $params["BY"][0]; } else { $params["BY"] = "AMOUNT"; } }
<?php namespace Notagency\Components; \CBitrixComponent::includeComponentClass('notagency:materials.list'); class MaterialsDetail extends MaterialsList { protected $checkParams = ['IBLOCK_CODE' => ['type' => 'string']]; public function onPrepareComponentParams($arParams) { $arParams = parent::onPrepareComponentParams($arParams); $arParams['SELECT_SECTIONS'] = 'N'; $arParams['ELEMENTS_COUNT'] = 1; $arParams['PAGING'] = 'N'; if (array_key_exists($arParams['REQUEST_ELEMENT_CODE'], $_REQUEST) && !empty($_REQUEST[$arParams['REQUEST_ELEMENT_CODE']])) { $arParams['ELEMENT_CODE'] = htmlspecialchars(trim($_REQUEST[$arParams['REQUEST_ELEMENT_CODE']])); } if (array_key_exists($arParams['REQUEST_ELEMENT_ID'], $_REQUEST) && intval($_REQUEST[$arParams['REQUEST_ELEMENT_ID']])) { $arParams['ELEMENT_ID'] = intval($_REQUEST[$arParams['REQUEST_ELEMENT_ID']]); } return $arParams; } protected function executeMain() { $filterInitialized = false; if ($this->arParams['ELEMENT_ID']) { $this->elementsFilter['ID'] = $this->arParams['ELEMENT_ID']; $filterInitialized = true; } if ($this->arParams['ELEMENT_CODE']) { $this->elementsFilter['CODE'] = $this->arParams['ELEMENT_CODE'];
/** * Bitrix Framework * @package bitrix * @subpackage sale * @copyright 2001-2014 Bitrix */ use Bitrix\Main; use Bitrix\Main\DB; use Bitrix\Main\Config; use Bitrix\Main\Localization\Loc; use Bitrix\Sale\Location; use Bitrix\Main\Data; CBitrixComponent::includeComponentClass("bitrix:sale.location.selector.search"); Loc::loadMessages(__FILE__); class CBitrixLocationSelectorSystemComponent extends CBitrixLocationSelectorSearchComponent { const ID_BLOCK_LEN = 90; const HUGE_TAIL_LEN = 30; const PAGE_SIZE = 10; const LOCATION_ENTITY_NAME = '\Bitrix\Sale\Location\LocationTable'; protected $entityClass = false; protected $useGroups = true; protected $useCodes = false; protected $dbResult = array();
<?php require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"; CModule::IncludeModule('sale'); CBitrixComponent::includeComponentClass("component.model:xml"); $xml = '<?xml version="1.0" encoding="UTF-8"?> <customerOrder vatIncluded="true" applicable="true" sourceStoreUuid="existing-store-uuid" payerVat="true" sourceAgentUuid="existing-counterparty-uuid" targetAgentUuid="existing-organization-uuid" moment="2011-06-27T06:27:00+04:00" name="0001"> <customerOrderPosition vat="18" goodUuid="existing-good-uuid" quantity="4.0" discount="0.0"> <basePrice sumInCurrency="555000.0" sum="555000.0"/> <reserve>0.0</reserve> </customerOrderPosition> </customerOrder>'; $data = new XML($xml); var_dump($data->customerOrder->customerOrderPosition->getData());
$arRes["BASKET_DATA"]["GRID"]["HEADERS"] = $columnsData; $arRes["COLUMNS"] = $strColumns; $arRes["BASKET_ID"] = $arItem['ID']; } $arRes["CODE"] = $bBasketUpdate === true ? "SUCCESS" : "ERROR"; if ($bBasketUpdate === false && is_array($arErrors) && !empty($arErrors)) { foreach ($arErrors as $error) { $arRes["MESSAGE"] .= (strlen($arRes["MESSAGE"]) > 0 ? "<br/>" : "") . $error; } } } } } else { if ($_POST[$action_var] == "recalculate") { // todo: extract duplicated code to function CBitrixComponent::includeComponentClass("redvent:sale.basket.basket"); $basket = new CRedventBasketComponent(); $basket->onIncludeComponentLang(); $basket->weightKoef = htmlspecialcharsbx(COption::GetOptionString('sale', 'weight_koef', 1, SITE_ID)); $basket->weightUnit = htmlspecialcharsbx(COption::GetOptionString('sale', 'weight_unit', "", SITE_ID)); $basket->columns = $arColumns; $basket->offersProps = $strOffersProps; $basket->quantityFloat = isset($_POST["quantity_float"]) && $_POST["quantity_float"] == "Y" ? "Y" : "N"; $basket->countDiscount4AllQuantity = isset($_POST["count_discount_4_all_quantity"]) && $_POST["count_discount_4_all_quantity"] == "Y" ? "Y" : "N"; $basket->priceVatShowValue = isset($_POST["price_vat_show_value"]) && $_POST["price_vat_show_value"] == "Y" ? "Y" : "N"; $basket->hideCoupon = isset($_POST["hide_coupon"]) && $_POST["hide_coupon"] == "Y" ? "Y" : "N"; $basket->usePrepayment = isset($_POST["use_prepayment"]) && $_POST["use_prepayment"] == "Y" ? "Y" : "N"; $res = $basket->recalculateBasket($_POST); foreach ($res as $key => $value) { $arRes[$key] = $value; }
<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die(); CBitrixComponent::includeComponentClass('aqw:store.catalog'); $catalog = new AqwCatalog(); $catalog->setOrder(array("RAND"=>"RAND")); $catalog->setLimit(8); $catalog->setFilter(array(">PROPERTY_VENDOR.ID"=>0, ">PROPERTY_MATERIAL.ID"=>0)); $arResult['ITEMS'] = $catalog->getItems(); $this->IncludeComponentTemplate(); ?>
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } /** * Bitrix Framework * @package bitrix * @subpackage sale * @copyright 2001-2014 Bitrix */ use Bitrix\Main; use Bitrix\Main\Localization\Loc; use Bitrix\Main\Loader; use Bitrix\Sale\Location\Admin\LocationHelper; CBitrixComponent::includeComponentClass("bitrix:sale.location.import"); Loc::loadMessages(__FILE__); class CBitrixCrmConfigLocationImport2Component extends CBitrixSaleLocationImportComponent { protected function checkRequiredModules() { $result = true; if (!Loader::includeModule('sale')) { $this->errors['FATAL'][] = Loc::getMessage("SALE_SLI_SALE_MODULE_NOT_INSTALL"); $result = false; } if (!Loader::includeModule('crm')) { $this->errors['FATAL'][] = Loc::getMessage("SALE_CCLI2_CRM_MODULE_NOT_INSTALL"); $result = false; } return $result;
<? if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die(); CBitrixComponent::includeComponentClass("component.model:item"); /** * News list * * @author Roman Morozov <*****@*****.**> * @version 1.0 */ class FilterCatalog extends CBitrixComponent { const IBLOCK_ID = 6; /** * Изначальное значение сортировки * @var array */ private $sort = array( 'NAME' => 'ASC' ); /** * Поля для выбора основных элементов * @var array */ private $select = array( 'ID',
* Базовый компонент для списков * version 1.0.1 * Created by PhpStorm. * User: Abai Adelshin * www.orendev.ru * Date: 01.02.2016 * Time: 11:15 * Базовый класс компонента для формирования списков (news.list) * По умолчанию формирует независимый блок новостной карусели * Необходимо подключить фреймворк bootstrap и jquery * * Доработать - Сформировать таблицу стилей * Доработать Проверка условия подключения фреймворка bootstrap * */ CBitrixComponent::includeComponentClass("itmanagement:base.component"); class newsClass extends TBaseComponent { const COUNT_ITEM_PAGE_DEFAULT = 4; //количество элементов в одном блоке по умолчанию protected $showError; protected $countPage = 4; protected $elementArSelect = array('IBLOCK_ID', 'ID', 'NAME', 'ACTIVE_FROM', 'PREVIEW_PICTURE', 'DETAIL_PICTURE', 'CODE', 'DETAIL_PAGE_URL', 'LIST_PAGE_URL'); /** * @param $arParams * @return mixed * @throws Exception * Обработка массива $arParams */ public function onPrepareComponentParams($arParams) {
<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die(); CBitrixComponent::includeComponentClass('aqw:store.system'); $arResult['SYSTEM'] = new AqwSystem(); /** * @var AqwCatalogMenu $this * @var $arResult */ $this->setSectionID($_REQUEST['SECTION_ID']); $arResult['MENU'] = $this->getTreeMenu(); if(count($arResult['MENU'])>0) { $arResult['ACTIVE_ID'] = $this->getSectionID(); $this->IncludeComponentTemplate(); } ?>
$arRes["BASKET_DATA"]["GRID"]["HEADERS"] = $columnsData; $arRes["COLUMNS"] = $strColumns; $arRes["BASKET_ID"] = $arItem['ID']; } $arRes["CODE"] = $bBasketUpdate === true ? "SUCCESS" : "ERROR"; if ($bBasketUpdate === false && is_array($arErrors) && !empty($arErrors)) { foreach ($arErrors as $error) { $arRes["MESSAGE"] .= (strlen($arRes["MESSAGE"]) > 0 ? "<br/>" : "") . $error; } } } } } else { if ($_POST[$action_var] == "recalculate") { // todo: extract duplicated code to function CBitrixComponent::includeComponentClass("bitrix:sale.basket.basket"); $basket = new CBitrixBasketComponent(); $basket->onIncludeComponentLang(); $basket->weightKoef = htmlspecialcharsbx(COption::GetOptionString('sale', 'weight_koef', 1, SITE_ID)); $basket->weightUnit = htmlspecialcharsbx(COption::GetOptionString('sale', 'weight_unit', "", SITE_ID)); $basket->columns = $arColumns; $basket->offersProps = $strOffersProps; $basket->quantityFloat = isset($_POST["quantity_float"]) && $_POST["quantity_float"] == "Y" ? "Y" : "N"; $basket->countDiscount4AllQuantity = isset($_POST["count_discount_4_all_quantity"]) && $_POST["count_discount_4_all_quantity"] == "Y" ? "Y" : "N"; $basket->priceVatShowValue = isset($_POST["price_vat_show_value"]) && $_POST["price_vat_show_value"] == "Y" ? "Y" : "N"; $basket->hideCoupon = isset($_POST["hide_coupon"]) && $_POST["hide_coupon"] == "Y" ? "Y" : "N"; $basket->usePrepayment = isset($_POST["use_prepayment"]) && $_POST["use_prepayment"] == "Y" ? "Y" : "N"; $res = $basket->recalculateBasket($_POST); foreach ($res as $key => $value) { $arRes[$key] = $value; }
<?php CBitrixComponent::includeComponentClass("component.model:abstractItem"); /** * Сущность элемента */ class Item extends AbstractItem { public function __construct($item) { if (!$item) { return false; } $this->item = $item; } /** * Обрезка текста последним пробелом с добавлнием троеточия * @param strign $text Большой текст для обрезки * @param integer $size Максимальный размер обрезанного текста * @return strging Обрезанный текст */ public function cutText($text, $size = 150) { if (strlen($text) > $size) { $text = substr(\HTMLToTxt($text), 0, strripos(substr(\HTMLToTxt($text), 0, $size), " ")) . "..."; } return $text; } /** * {@inheritdoc} */
{ CIBlockPriceTools::setRatioMinPrice($arResult, true); } if (!empty($arResult['DISPLAY_PROPERTIES'])) { foreach ($arResult['DISPLAY_PROPERTIES'] as $propKey => $arDispProp) { if ('F' == $arDispProp['PROPERTY_TYPE']) unset($arResult['DISPLAY_PROPERTIES'][$propKey]); } } $arResult['SKU_PROPS'] = $arSKUPropList; $arResult['DEFAULT_PICTURE'] = $arEmptyPreview; $arResult['wish']['isWished'] = CIBlockElement::GetList(false, array( 'IBLOCK_ID' => 23, 'ACTIVE' => 'Y', 'PROPERTY_OBJECT' => $arResult['ID'] ), false, false, array('ID'))->SelectedRowsCount(); CBitrixComponent::includeComponentClass("component.model:likes"); $objElement = new CIBlockElement; $likes = new Likes(1); $arResult['likes']['already_liked'] = $likes->isLikedByCurrent($arResult['ID']); $arResult['likes']['value'] = $likes->count($arResult['ID']); ?>
<?php namespace Notagency\Components; \CBitrixComponent::includeComponentClass('notagency:materials.detail'); class CatalogDetail extends MaterialsDetail { protected $needModules = ['iblock', 'catalog']; protected function processElement($element) { $element = parent::processElement($element); $element = $this->processAmount($element); $element = $this->processPrice($element); return $element; } protected function processAmount($element) { $product = \CCatalogProduct::GetByID($element['ID']); $element['QUANTITY'] = $product['QUANTITY']; return $element; } protected function processPrice($element) { $element['CATALOG_DETAILS'] = \CCatalogProduct::GetOptimalPrice($element['ID']); $element['PRICE_FORMATTED'] = $this->formatPrice($element['CATALOG_DETAILS']['PRICE']['PRICE']); return $element; } protected function formatPrice($price) { $price = \CCurrencyLang::CurrencyFormat($price, 'RUB', false); return $price;
<?php use Bitrix\Main; use Bitrix\Catalog\CatalogViewedProductTable; use Bitrix\Main\Text\String; use Bitrix\Main\Localization\Loc; use Bitrix\Main\SystemException; if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } CBitrixComponent::includeComponentClass("bitrix:sale.bestsellers"); class CatalogBigdataProductsComponent extends CSaleBestsellersComponent { protected $rcmParams; protected $ajaxItemsIds; /** * Prepare Component Params */ public function onPrepareComponentParams($params) { global $APPLICATION; // remember src params for further ajax query if (!isset($params['RCM_CUR_BASE_PAGE'])) { $params['RCM_CUR_BASE_PAGE'] = $APPLICATION->GetCurPage(); } $this->arResult['_ORIGINAL_PARAMS'] = $params; // bestselling $params['FILTER'] = array('PAYED'); $params['PERIOD'] = 30; return parent::onPrepareComponentParams($params); }
<?php /** * Created by PhpStorm. * User: adeveloper aka Худяков Кирилл * Date: 23.10.2015 * Time: 10:49 */ namespace Portal\Components; use Bitrix\Main; if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) { die; } \CBitrixComponent::includeComponentClass(basename(dirname(__DIR__)) . ':base'); /** * Class BaseRouter - класс комплексной компоненты * @package Portal\Components */ abstract class BaseRouter extends \CBitrixComponent { use General; /** * @var страница шаблона по умолчанию */ protected $defaultSefPage = 'index'; // template.php если пустая /** * @var array Paths of templates default */ public $defaultUrlTemplates = array("list" => "index.php", "detail" => "#ELEMENT_ID#/", "detail_code" => "code/#ELEMENT_CODE#/", "blog" => "blog/#BLOG_URL#/");