本文整理汇总了PHP中MG::priceCourse方法的典型用法代码示例。如果您正苦于以下问题:PHP MG::priceCourse方法的具体用法?PHP MG::priceCourse怎么用?PHP MG::priceCourse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MG
的用法示例。
在下文中一共展示了MG::priceCourse方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInfoRecentProduct
static function getInfoRecentProduct($args)
{
$model = new Models_Product();
$stringRelated = ' null';
$sortRelated = array();
foreach ($args as $item) {
$stringRelated .= ',' . DB::quote($item);
$sortRelated[$item] = $item;
}
$stringRelated = substr($stringRelated, 1);
$data['products'] = $model->getProductByUserFilter(' p.code IN (' . $stringRelated . ') and p.activity = 1 ');
if (!empty($data['products'])) {
$data['currency'] = MG::getSetting('currency');
foreach ($data['products'] as $item) {
$img = explode('|', $item['image_url']);
$item['img'] = $img[0];
$item['url'] = SITE . '/' . (isset($item["category_url"]) ? $item["category_url"] : 'catalog') . '/' . $item["product_url"];
$item['price'] = MG::priceCourse($item['price_course']);
$sortRelated[$item['code']] = $item;
}
$data['products'] = array();
//сортируем связанные товары в том порядке, в котором они идут в строке артикулов
foreach ($sortRelated as $item) {
if (!empty($item['id']) && is_array($item)) {
$data['products'][$item['id']] = $item;
}
}
}
return self::htmlRecentlyProducts($data);
}
示例2: __construct
function __construct()
{
$model = new Models_Product();
// Требуется только пересчет цены товара.
if (!empty($_REQUEST['calcPrice'])) {
$model->calcPrice();
exit;
}
$product = Storage::get(md5('ControllersProduct' . URL::getUrl()));
if ($product == null) {
$settings = MG::get('settings');
$product = $model->getProduct(URL::getQueryParametr('id'));
if (empty($product)) {
MG::redirect('/404');
exit;
}
$product['meta_title'] = $product['meta_title'] ? $product['meta_title'] : $product['title'];
$product['currency'] = $settings['currency'];
$blockVariants = $model->getBlockVariants($product['id']);
$blockedProp = $model->noPrintProperty();
$propertyFormData = $model->createPropertyForm($param = array('id' => $product['id'], 'maxCount' => $product['count'], 'productUserFields' => $product['thisUserFields'], 'action' => "/catalog", 'method' => "POST", 'ajax' => true, 'blockedProp' => $blockedProp, 'noneAmount' => false, 'noneButton' => $product['count'] ? false : true, 'titleBtn' => MG::getSetting('buttonBuyName'), 'blockVariants' => $blockVariants, 'currency_iso' => $product['currency_iso']));
// Легкая форма без характеристик.
$liteFormData = $model->createPropertyForm($param = array('id' => $product['id'], 'maxCount' => $product['count'], 'productUserFields' => null, 'action' => "/catalog", 'method' => "POST", 'ajax' => true, 'blockedProp' => $blockedProp, 'noneAmount' => false, 'noneButton' => $product['count'] ? false : true, 'titleBtn' => MG::getSetting('buttonBuyName'), 'blockVariants' => $blockVariants));
//echo viewData($propertyFormData['defaultSet']);
$product['price_course'] += $propertyFormData['marginPrice'];
$currencyRate = MG::getSetting('currencyRate');
$currencyShopIso = MG::getSetting('currencyShopIso');
$product['currency_iso'] = $product['currency_iso'] ? $product['currency_iso'] : $currencyShopIso;
$product['old_price'] = $product['old_price'] * $currencyRate[$product['currency_iso']];
$product['old_price'] = $product['old_price'] ? $product['old_price'] : 0;
$product['price'] = MG::priceCourse($product['price_course']);
$product['propertyForm'] = $propertyFormData['html'];
$product['propertyNodummy'] = $propertyFormData['propertyNodummy'];
$product['stringsProperties'] = $propertyFormData['stringsProperties'];
$product['liteFormData'] = $liteFormData['html'];
$product['description'] = MG::inlineEditor(PREFIX . 'product', "description", $product['id'], $product['description']);
$product['title'] = MG::modalEditor('catalog', $product['title'], 'edit', $product["id"]);
// Информация об отсутствии товара на складе.
if (MG::getSetting('printRemInfo') == "true") {
$message = 'Здравствуйте, меня интересует товар "' . str_replace("'", """, $product['title']) . '" с артикулом "' . $product['code'] . '", но его нет в наличии.
Сообщите, пожалуйста, о поступлении этого товара на склад. ';
if ($product['count'] != 0) {
$style = 'style="display:none;"';
}
$product['remInfo'] = "<span class='rem-info' " . $style . ">Товара временно нет на складе!<br/><a href='" . SITE . "/feedback?message=" . $message . "'>Сообщить когда будет в наличии.</a></span>";
}
if ($product['count'] < 0) {
$product['count'] = "много";
}
$product['related'] = $model->createRelatedForm($product['related']);
Storage::save(md5('ControllersProduct' . URL::getUrl()), $product);
}
// MG::set('propertyNodummy',$product['propertyNodummy']);
// $_SESSION['propertyNodummy'] = $product['propertyNodummy'];
$this->data = $product;
}
示例3:
<div class="filter-container" <?php
if ($displayFilter) {
echo "style='display:block'";
}
?>
>
<?php
echo $filter;
?>
<div class="block-stat-info-order">
<span>Найдено заказов: <strong><?php
echo $itemsCount;
?>
шт.</strong></span>
<span>Общая сумма заказов: <strong><?php
echo MG::priceCourse($totalSumm) . ' ' . MG::getSetting('currency');
?>
</strong></span>
</div>
<div class="clear"></div>
</div>
<div class="property-order-container">
<h2><?php
echo $lang['OREDER_LOCALE_24'];
?>
:</h2>
<form name="requisites" method="POST">
<ul class="requisites-list">
<li><span><?php
echo $lang['OREDER_LOCALE_9'];
示例4: getItemsCart
/**
* Возвращает данные о всех продуктах в корзине.
* @return array
*/
public function getItemsCart()
{
$productPositions = array();
// Создает модель для работы с продуктами.
$itemPosition = new Models_Product();
$totalSumm = 0;
if (!empty($_SESSION['cart'])) {
$currencyRate = MG::getSetting('currencyRate');
$currencyShopIso = MG::getSetting('currencyShopIso');
$variantsId = array();
$productsId = array();
foreach ($_SESSION['cart'] as $key => $item) {
if (!empty($item['variantId'])) {
$variantsId[] = $item['variantId'];
}
$productsId[] = $item['id'];
}
$products_all = array();
$variants_all = array();
if (!empty($variantsId)) {
$ids = implode(',', $variantsId);
$variants_res = DB::query('SELECT pv.*, c.rate,(pv.price_course + pv.price_course *(IFNULL(c.rate,0))) as `price_course`,
p.currency_iso
FROM `' . PREFIX . 'product_variant` pv
LEFT JOIN `' . PREFIX . 'product` as p ON
p.id = pv.product_id
LEFT JOIN `' . PREFIX . 'category` as c ON
c.id = p.cat_id
WHERE pv.id IN (' . trim(DB::quote($ids, true)) . ')');
while ($variant_row = DB::fetchAssoc($variants_res)) {
$variants_all[$variant_row['id']] = $variant_row;
}
}
if (!empty($productsId)) {
$ids = implode(',', array_unique($productsId));
$product_res = DB::query('
SELECT CONCAT(c.parent_url,c.url) as category_url,
p.url as product_url, p.*, rate, (p.price_course + p.price_course * (IFNULL(rate,0))) as `price_course`,
p.`currency_iso`
FROM `' . PREFIX . 'product` p
LEFT JOIN `' . PREFIX . 'category` c
ON c.id = p.cat_id
WHERE p.id IN (' . DB::quote($ids, true) . ')');
if (!empty($product_res)) {
while ($result = DB::fetchAssoc($product_res)) {
$products_all[$result['id']] = $result;
}
}
}
foreach ($_SESSION['cart'] as $key => $item) {
$variant = '';
if (!empty($item['variantId'])) {
// $variants = $itemPosition->getVariants($item['id']);
$variant = $variants_all[$item['variantId']];
}
// Заполняет массив информацией о каждом продукте по id из куков.
// Если куки не актуальны, пропускает товар.
$product = $products_all[$item['id']];
if (!empty($product)) {
$product['property'] = $_SESSION['cart'][$key]['propertySetId'];
$product['property_html'] = htmlspecialchars_decode(str_replace('&', '&', $_SESSION['cart'][$key]['property']));
$product['propertySetId'] = $_SESSION['cart'][$key]['propertySetId'];
if (!empty($variant)) {
$product['price'] = $variant['price'];
$product['code'] = $variant['code'];
$product['count'] = $variant['count'];
$product['weight'] = $variant['weight'];
$product['image_url'] = $variant['image'] ? $variant['image'] : $product['image_url'];
$product['title'] .= " " . $variant['title_variant'];
$product['variantId'] = $variant['id'];
$product['price_course'] = $variant['price_course'];
}
// если установлен формат без копеек то округлим стоимость.
$priceFormat = MG::getSetting('priceFormat');
if (in_array($priceFormat, array('1234.56', '1234', '1 234', '1,234', ''))) {
$price = round($product['price_course']);
} else {
$price = $product['price_course'];
}
if ($item['id'] == $product['id']) {
$count = $item['count'];
$price = SmalCart::plusPropertyMargin($price, $item['propertyReal'], $currencyRate[$product['currency_iso']]);
// $product['currency_iso'] = $product['currency_iso']?$product['currency_iso']:$currencyShopIso;
// $price *= $currencyRate[$product['currency_iso']];
$product['price'] = $price;
// применение скидки по купону
$priceWithCoupon = $this->applyCoupon($_SESSION['couponCode'], $product['price'], $product);
$priceWithDiscoutn = $this->applyDiscountSystem($product['price']);
$product['price'] = $priceWithCoupon < $priceWithDiscoutn['price'] ? $priceWithCoupon : $priceWithDiscoutn['price'];
$product['priceInCart'] = MG::priceCourse($product['price'] * $count) . " " . MG::getSetting('currency');
$arrayImages = explode("|", $product['image_url']);
if (!empty($arrayImages)) {
$product['image_url'] = $arrayImages[0];
}
}
$product['category_url'] = SHORT_LINK == '1' ? '' : $product['category_url'] . '/';
//.........这里部分代码省略.........
示例5: getGroupsData
public function getGroupsData()
{
$model = new Models_Catalog();
$currencyRate = MG::getSetting('currencyRate');
$currencyShopIso = MG::getSetting('currencyShopIso');
// Формируем список товаров для блока рекомендуемой продукции.
$recommendProducts = $model->getListByUserFilter(MG::getSetting('countRecomProduct'), ' p.recommend = 1 and p.activity=1 ORDER BY sort ASC');
foreach ($recommendProducts['catalogItems'] as &$item) {
$imagesUrl = explode("|", $item['image_url']);
$item["image_url"] = "";
if (!empty($imagesUrl[0])) {
$item["image_url"] = $imagesUrl[0];
}
$item['currency_iso'] = $item['currency_iso'] ? $item['currency_iso'] : $currencyShopIso;
// $item['price'] *= $currencyRate[$item['currency_iso']];
$item['old_price'] = $item['old_price'] * $currencyRate[$item['currency_iso']];
$item['old_price'] = $item['old_price'] ? MG::priceCourse($item['old_price']) : 0;
$item['price'] = MG::priceCourse($item['price_course']);
}
// Формируем список товаров для блока новинок.
$newProducts = $model->getListByUserFilter(MG::getSetting('countNewProduct'), ' p.new = 1 and p.activity=1 ORDER BY sort ASC');
foreach ($newProducts['catalogItems'] as &$item) {
$imagesUrl = explode("|", $item['image_url']);
$item["image_url"] = "";
if (!empty($imagesUrl[0])) {
$item["image_url"] = $imagesUrl[0];
}
$item['currency_iso'] = $item['currency_iso'] ? $item['currency_iso'] : $currencyShopIso;
// $item['price'] *= $currencyRate[$item['currency_iso']];
$item['old_price'] = $item['old_price'] * $currencyRate[$item['currency_iso']];
$item['old_price'] = $item['old_price'] ? MG::priceCourse($item['old_price']) : 0;
$item['price'] = MG::priceCourse($item['price_course']);
}
// Формируем список товаров со старой ценой.
$saleProducts = $model->getListByUserFilter(MG::getSetting('countSaleProduct'), ' p.old_price>0 and p.activity=1 ORDER BY sort ASC');
foreach ($saleProducts['catalogItems'] as &$item) {
$imagesUrl = explode("|", $item['image_url']);
$item["image_url"] = "";
if (!empty($imagesUrl[0])) {
$item["image_url"] = $imagesUrl[0];
}
$item['currency_iso'] = $item['currency_iso'] ? $item['currency_iso'] : $currencyShopIso;
//$item['price'] *= $currencyRate[$item['currency_iso']];
$item['old_price'] = $item['old_price'] * $currencyRate[$item['currency_iso']];
$item['old_price'] = $item['old_price'] ? MG::priceCourse($item['old_price']) : 0;
$item['price'] = MG::priceCourse($item['price_course']);
}
$html = MG::get('pages')->getPageByUrl('index');
$html['html_content'] = MG::inlineEditor(PREFIX . 'page', "html_content", $html['id'], $html['html_content']);
$data = array('recommendProducts' => $recommendProducts, 'newProducts' => $newProducts, 'saleProducts' => $saleProducts);
return $data;
}
示例6: getCartData
/**
* Вычисляет общую стоимость содержимого, а также количество.
* @return array массив с данными о количестве и цене.
*/
public static function getCartData()
{
$modelCart = new Models_Cart();
// Количество вещей в корзине.
$res['cart_count'] = 0;
// Общая стоимость.
$res['cart_price'] = 0;
// Если удалось получить данные из куков и они успешно десериализованы в $_SESSION['cart'].
//self::getCokieCart() &&
if (!empty($_SESSION['cart'])) {
$settings = MG::get('settings');
$totalPrice = 0;
$totalCount = 0;
if (!empty($_SESSION['cart'])) {
$itemIds = array();
$variantsId = array();
foreach ($_SESSION['cart'] as $key => $item) {
if (!empty($item['id'])) {
if (!empty($item['variantId'])) {
$variantsId[] = $item['variantId'];
}
$itemIds[] = $item['id'];
}
}
if (!empty($itemIds)) {
// Пробегаем по содержимому.
$idsPr = implode(',', array_unique($itemIds));
$where = ' IN (' . trim(DB::quote($idsPr), "'") . ')';
}
} else {
$where = ' IN (0)';
}
// Пробегаем по содержимому.
// $where = ' IN ('.trim(DB::quote(implode(',',$itemIds)),"'").')';
$result = DB::query('
SELECT CONCAT(c.parent_url,c.url) AS category_url, p.url AS product_url, p.*, rate,
(p.price_course + p.price_course * (IFNULL(rate,0))) as `price_course`, p.currency_iso
FROM `' . PREFIX . 'product` AS p
LEFT JOIN `' . PREFIX . 'category` AS c ON c.id = p.cat_id
WHERE p.id ' . $where);
$array_variants = array();
if (!empty($variantsId)) {
$ids = implode(',', $variantsId);
$variants_res = DB::query('SELECT pv.*, c.rate,(pv.price_course + pv.price_course *(IFNULL(c.rate,0))) as `price_course`,
p.currency_iso
FROM `' . PREFIX . 'product_variant` pv
LEFT JOIN `' . PREFIX . 'product` as p ON
p.id = pv.product_id
LEFT JOIN `' . PREFIX . 'category` as c ON
c.id = p.cat_id
WHERE pv.id IN (' . trim(DB::quote($ids, true)) . ')');
while ($variant_row = DB::fetchAssoc($variants_res)) {
$array_variants[$variant_row['id']] = $variant_row;
}
}
$currencyRate = MG::getSetting('currencyRate');
$currencyShopIso = MG::getSetting('currencyShopIso');
$products_row = array();
while ($prod = DB::fetchAssoc($result)) {
$products_row[$prod['id']] = $prod;
}
foreach ($_SESSION['cart'] as $key => $item) {
$variant = null;
$row = $products_row[$item['id']];
$arrayImages = explode("|", $row['image_url']);
if (!empty($item['variantId'])) {
$variant = $array_variants[$item['variantId']];
$image = $variant['image'] ? $variant['image'] : $arrayImages[0];
$row['price'] = $variant['price'];
$row['code'] = $variant['code'];
$row['count'] = $variant['count'];
$row['image_url'] = $variant['image'] ? $variant['image'] : $row['image_url'];
$row['image_url_new'] = mgImageProductPath($image, $item['id'], 'small');
$row['weight'] = $variant['weight'];
$row['title'] = $row['title'] . " " . $variant['title_variant'];
$row['variantId'] = $variant['id'];
$row['price_course'] = $variant['price_course'];
}
$price = $row['price_course'];
if ($item['id'] == $row['id']) {
$count = $item['count'];
$row['countInCart'] = $count;
$row['property_html'] = htmlspecialchars_decode(str_replace('&', '&', $item['property']));
$price = self::plusPropertyMargin($price, $item['propertyReal'], $currencyRate[$row['currency_iso']]);
$row['property'] = $item['propertySetId'];
$priceWithCoupon = $modelCart->applyCoupon($_SESSION['couponCode'], $price, $row);
//$row['currency_iso'] = $row['currency_iso']?$row['currency_iso']:$currencyShopIso;
//$price *= $currencyRate[$row['currency_iso']];
$priceWithDiscount = $modelCart->applyDiscountSystem($price);
//$price = $priceWithCoupon < $priceWithDiscount['price'] ? $priceWithCoupon : $priceWithDiscount['price'];
$price = $modelCart->customPrice(array('product' => $row, 'priceWithCoupon' => $priceWithCoupon, 'priceWithDiscount' => $priceWithDiscount['price']));
// если выбран формат без копеек, то округляем стоимость до ворматирования.
if (in_array(MG::getSetting('priceFormat'), array('1234', '1 234', '1,234'))) {
$price = round($price);
}
$row['priceInCart'] = MG::priceCourse($price * $count) . " " . $settings['currency'];
//.........这里部分代码省略.........
示例7: createRelatedForm
/**
* Возвращает HTML блок связанных товаров
* @param type $args
* @return type
*/
public function createRelatedForm($args, $title = 'С этим товаром покупают', $layout = 'layout_related')
{
if ($args) {
$data['title'] = $title;
$stringRelated = ' null';
$sortRelated = array();
foreach (explode(',', $args) as $item) {
$stringRelated .= ',' . DB::quote($item);
$sortRelated[$item] = $item;
}
$stringRelated = substr($stringRelated, 1);
$data['products'] = $this->getProductByUserFilter(' p.code IN (' . $stringRelated . ') and p.activity = 1 ');
if (!empty($data['products'])) {
$data['currency'] = MG::getSetting('currency');
foreach ($data['products'] as $item) {
$img = explode('|', $item['image_url']);
$item['img'] = $img[0];
$item['category_url'] = SHORT_LINK == '1' ? '' : $item['category_url'] . '/';
$item['url'] = SITE . '/' . (isset($item["category_url"]) ? $item["category_url"] : 'catalog/') . $item["product_url"];
$item['price'] = MG::priceCourse($item['price_course']);
$sortRelated[$item['code']] = $item;
}
$data['products'] = array();
//сортируем связанные товары в том порядке, в котором они идут в строке артикулов
foreach ($sortRelated as $item) {
if (!empty($item['id']) && is_array($item)) {
$data['products'][$item['id']] = $item;
}
}
$result = MG::layoutManager($layout, $data);
}
}
$args = func_get_args();
return MG::createHook(__CLASS__ . "_" . __FUNCTION__, $result, $args);
}
示例8: foreach
foreach ($data['variants'] as $item) {
$cItem++;
?>
<?php
if ($item['price'] != $item['price_course']) {
?>
<tr>
<td colspan="3">
<span class="view-price tool-tip-bottom" data-productId="<?php
echo $item['id'];
?>
" style="color: <?php
echo $item['price'] < $item['price_course'] ? '#1C9221' : '#B42020';
?>
;" title="с учетом скидки/наценки"><?php
echo MG::priceCourse($item['price_course']) . ' ' . $currency;
?>
</span>
<div class="clear"></div>
</td>
</tr>
<?php
} else {
?>
<?php
if ($cItem > 1) {
?>
<tr><td colspan="3" height="15"></td></tr>
<?php
}
?>
示例9: fastSaveProduct
/**
* Обновляет параметры товара (быстрый вариант).
* @return type
*/
public function fastSaveProduct()
{
$this->messageSucces = $this->lang['ACT_SAVE_PROD'];
$this->messageError = $this->lang['ACT_NOT_SAVE_PROD'];
$model = new Models_Product();
$variant = $_POST['variant'];
unset($_POST['variant']);
$arr = array($_POST['field'] => $_POST['value']);
// Обновление.
if ($variant) {
$model->fastUpdateProductVariant($_POST['id'], $arr, $_POST['product_id']);
$arrVar = $model->getVariants($_POST['product_id']);
foreach ($arrVar as $key => $variant) {
if ($variant['id'] == $_POST['id']) {
$this->data = MG::priceCourse($variant['price_course']);
}
}
} else {
$model->fastUpdateProduct($_POST['id'], $arr);
$tempProd = $model->getProduct($_POST['id']);
$this->data = MG::priceCourse($tempProd['price_course']);
}
return true;
}
示例10: __construct
function __construct()
{
$settings = MG::get('settings');
// Если нажата кнопка купить.
$_REQUEST['category_id'] = URL::getQueryParametr('category_id');
if (!empty($_REQUEST['inCartProductId'])) {
$cart = new Models_Cart();
$property = $cart->createProperty($_POST);
$cart->addToCart($_REQUEST['inCartProductId'], $_REQUEST['amount_input'], $property);
SmalCart::setCartData();
MG::redirect('/cart');
}
$countСatalogProduct = $settings['countСatalogProduct'];
// Показать первую страницу выбранного раздела.
$page = 1;
// Запрашиваемая страница.
if (isset($_REQUEST['p'])) {
$page = $_REQUEST['p'];
}
$model = new Models_Catalog();
// Получаем список вложенных категорий, для вывода всех продуктов, на страницах текущей категории.
$model->categoryId = MG::get('category')->getCategoryList($_REQUEST['category_id']);
// В конец списка, добавляем корневую текущую категорию.
$model->categoryId[] = $_REQUEST['category_id'];
// Передаем номер требуемой страницы, и количество выводимых объектов.
$countСatalogProduct = 100;
$actionButton = MG::getSetting('actionInCatalog') === "true" ? 'actionBuy' : 'actionView';
$dataGroupProducts = Storage::get(md5('dataGroupProductsIndexConroller'));
$currencyRate = MG::getSetting('currencyRate');
$currencyShopIso = MG::getSetting('currencyShopIso');
$randomProdBlock = MG::getSetting('randomProdBlock') == "true" ? true : false;
if ($dataGroupProducts == null) {
// Формируем список товаров со старой ценой.
$sort = $randomProdBlock ? "RAND()" : "sort";
$saleProducts = $model->getListByUserFilter(MG::getSetting('countSaleProduct'), ' (p.old_price>0 || pv.old_price>0) and p.activity=1 ORDER BY ' . $sort . ' ASC');
$recommendProducts = $model->getListByUserFilter(MG::getSetting('countRecomProduct'), ' p.recommend=1 ORDER BY ' . $sort . ' ASC');
$newProducts = $model->getListByUserFilter(MG::getSetting('countNewProduct'), ' p.new=1 ORDER BY ' . $sort . ' ASC');
foreach ($saleProducts['catalogItems'] as &$item) {
$imagesUrl = explode("|", $item['image_url']);
$item["image_url"] = "";
if (!empty($imagesUrl[0])) {
$item["image_url"] = $imagesUrl[0];
}
$item['currency_iso'] = $item['currency_iso'] ? $item['currency_iso'] : $currencyShopIso;
//$item['price'] *= $currencyRate[$item['currency_iso']];
$item['old_price'] = $item['old_price'] ? MG::priceCourse($item['old_price']) : 0;
$item['price'] = MG::priceCourse($item['price_course']);
if ($printCompareButton != 'true') {
$item['actionCompare'] = '';
}
if ($actionButton == 'actionBuy' && $item['count'] == 0) {
$item['actionBuy'] = $item['actionView'];
}
}
$dataGroupProducts['recommendProducts'] = $recommendProducts;
$dataGroupProducts['newProducts'] = $newProducts;
$dataGroupProducts['saleProducts'] = $saleProducts;
Storage::save(md5('dataGroupProductsIndexConroller'), $dataGroupProducts);
}
$recommendProducts = $dataGroupProducts['recommendProducts'];
$newProducts = $dataGroupProducts['newProducts'];
$saleProducts = $dataGroupProducts['saleProducts'];
$html = MG::get('pages')->getPageByUrl('index');
if (!empty($html)) {
$html['html_content'] = MG::inlineEditor(PREFIX . 'page', "html_content", $html['id'], $html['html_content']);
} else {
$html['html_content'] = '';
}
$this->data = array('newProducts' => !empty($newProducts['catalogItems']) ? $newProducts['catalogItems'] : array(), 'recommendProducts' => !empty($recommendProducts['catalogItems']) ? $recommendProducts['catalogItems'] : array(), 'saleProducts' => !empty($saleProducts['catalogItems']) ? $saleProducts['catalogItems'] : array(), 'titeCategory' => $html['meta_title'], 'cat_desc' => $html['html_content'], 'meta_title' => $html['meta_title'], 'meta_keywords' => $html['meta_keywords'], 'meta_desc' => $html['meta_desc'], 'currency' => $settings['currency'], 'actionButton' => $actionButton);
}
示例11: addPropertyToProduct
/**
* Метод добавляет к массиву продуктов информацию о характеристиках
* для каждого продукта
* @param $arrayProducts - массив с продуктами
* @return float.
*/
public function addPropertyToProduct($arrayProducts)
{
$categoryIds = array();
$whereCat = '';
$idsProduct = array();
$currency = MG::getSetting("currency");
$currencyRate = MG::getSetting('currencyRate');
$currencyShopIso = MG::getSetting('currencyShopIso');
$prod = new Models_Product();
$idsVariantProduct = array();
foreach ($arrayProducts as $key => $product) {
$arrayProducts[$key]['category_url'] = SHORT_LINK == '1' && !URL::isSection('mg-admin') ? '' : $arrayProducts[$key]['category_url'] . '/';
$product['category_url'] = SHORT_LINK == '1' ? '' : $product['category_url'] . '/';
if ($product['variant_exist'] && $product['variant_id']) {
$variants = $prod->getVariants($product['id']);
$variantsKey = array_keys($variants);
$product['variant_id'] = $variantsKey[0];
$idsVariantProduct[$product['id']][] = $key;
$variant = $variants[$product['variant_id']];
$arrayProducts[$key]['price_course'] = $variant['price_course'];
$arrayProducts[$key]['price'] = $variant['price'];
$arrayProducts[$key]['image_url'] = $variant['image'] ? $variant['image'] : $arrayProducts[$key]['image_url'];
}
$idsProduct[$product['id']] = $key;
$categoryIds[] = $product['cat_id'];
// Назначаем для продукта позьзовательские
// характеристики по умолчанию, заданные категорией.
$arrayProducts[$key]['thisUserFields'] = MG::get('category')->getUserPropertyCategoryById($product['cat_id']);
$arrayProducts[$key]['propertyIdsForCat'] = MG::get('category')->getPropertyForCategoryById($product['cat_id']);
$arrayProducts[$key]['currency'] = $currency;
// Формируем ссылки подробнее и в корзину.
$arrayProducts[$key]['actionBuy'] = '<a href="' . SITE . '/catalog?inCartProductId=' . $product["id"] . '" class="addToCart product-buy" data-item-id="' . $product["id"] . '">' . MG::getSetting('buttonBuyName') . '</a>';
$arrayProducts[$key]['actionCompare'] = '<a href="' . SITE . '/compare?inCompareProductId=' . $product["id"] . '" class="addToCompare" data-item-id="' . $product["id"] . '">' . MG::getSetting('buttonCompareName') . '</a>';
$arrayProducts[$key]['actionView'] = '<a href="' . SITE . '/' . (isset($product["category_url"]) ? $product["category_url"] : 'catalog') . '/' . $product["product_url"] . '" class="product-info">' . MG::getSetting('buttonMoreName') . '</a>';
$arrayProducts[$key]['link'] = SITE . '/' . (isset($product["category_url"]) ? $product["category_url"] : 'catalog/') . $product["product_url"];
if (empty($arrayProducts[$key]['currency_iso'])) {
$arrayProducts[$key]['currency_iso'] = $currencyShopIso;
}
$arrayProducts[$key]['real_old_price'] = $arrayProducts[$key]['old_price'];
$arrayProducts[$key]['old_price'] *= $currencyRate[$arrayProducts[$key]['currency_iso']];
$arrayProducts[$key]['real_price'] = $arrayProducts[$key]['price'];
$arrayProducts[$key]['price'] = MG::priceCourse($arrayProducts[$key]['price_course']);
$imagesConctructions = $prod->imagesConctruction($arrayProducts[$key]['image_url'], $arrayProducts[$key]['image_title'], $arrayProducts[$key]['image_alt']);
$arrayProducts[$key]['images_product'] = $imagesConctructions['images_product'];
$arrayProducts[$key]['images_title'] = $imagesConctructions['images_title'];
$arrayProducts[$key]['images_alt'] = $imagesConctructions['images_alt'];
$arrayProducts[$key]['image_url'] = $imagesConctructions['image_url'];
$arrayProducts[$key]['image_title'] = $imagesConctructions['image_title'];
$arrayProducts[$key]['image_alt'] = $imagesConctructions['image_alt'];
$imagesUrl = explode("|", $arrayProducts[$key]['image_url']);
$arrayProducts[$key]["image_url"] = "";
if (!empty($imagesUrl[0])) {
$arrayProducts[$key]["image_url"] = $imagesUrl[0];
}
}
$model = new Models_Product();
$arrayVariants = $model->getBlocksVariantsToCatalog(array_keys($idsProduct), true);
foreach (array_keys($idsProduct) as $id) {
$arrayProducts[$idsProduct[$id]]['variants'] = $arrayVariants[$id];
}
// Собираем все ID продуктов в один запрос.
if ($prodSet = trim(DB::quote(implode(',', array_keys($idsProduct))), "'")) {
// Формируем список id продуктов, к которым нужно найти пользовательские характеристики.
$where = ' IN (' . $prodSet . ') ';
} else {
$where = ' IN (0) ';
}
//Определяем id категории, в которой находимся
$catCode = URL::getLastSection();
$sql = '
SELECT pup.property_id, pup.value, pup.product_id, prop.*, pup.type_view, pup.product_margin
FROM `' . PREFIX . 'product_user_property` as pup
LEFT JOIN `' . PREFIX . 'property` as prop
ON pup.property_id = prop.id ';
if ($catSet = trim(DB::quote(implode(',', $categoryIds)), "'")) {
$categoryIds = array_unique($categoryIds);
$sql .= '
LEFT JOIN `' . PREFIX . 'category_user_property` as cup
ON cup.property_id = prop.id ';
$whereCat = ' AND cup.category_id IN (' . $catSet . ') ';
}
$sql .= 'WHERE pup.`product_id` ' . $where . $whereCat;
$sql .= 'ORDER BY `sort` DESC';
$res = DB::query($sql);
while ($userFields = DB::fetchAssoc($res)) {
// viewDAta($userFields['property_id']);
// viewDAta($arrayProducts[$key]['propertyIdsForCat']);
// Обновляет данные позначениям характеристик, только для тех хар. которые назначены для категории текущего товара.
// Это не работает в фильтрах и сравнениях.
// if(in_array($userFields['property_id'],$arrayProducts[$key]['propertyIdsForCat'])){
// дописываем в массив пользовательских характеристик,
// все переопределенные для каждого тоавара, оставляя при
// этом не измененные характеристики по умолчанию
$arrayProducts[$idsProduct[$userFields['product_id']]]['thisUserFields'][$userFields['property_id']] = $userFields;
//.........这里部分代码省略.........
示例12:
?>
</a>
</div>
<div class="product-description">
<?php
echo MG::textMore($item["description"], 240);
?>
</div>
<div class="product-footer">
<div class="product-price">
<span class="product-old-price" <?php
echo !$item['old_price'] ? 'style="display:none"' : 'style="display:block"';
?>
>
<?php
echo MG::priceCourse($item['old_price']);
?>
<?php
echo $data['currency'];
?>
</span>
<?php
echo $item["price"];
?>
<?php
echo $data['currency'];
?>
</div>
<div class="product-buttons">
<!--Кнопка, кототорая меняет свое значение с "В корзину" на "Подробнее"-->
示例13: getInfoProducts
/**
* Получает информацию о каждом товаре.
* @param array $viewCategoryId - массив id категорий.
*/
public function getInfoProducts($viewCategoryId)
{
if (empty($viewCategoryId)) {
return false;
}
$listProductsArray = array();
$countProduct = 0;
foreach ($viewCategoryId as $k => $id) {
$listProductsIdTemp = $_SESSION['compareList'][$id];
$countProduct += count($_SESSION['compareList'][$id]);
$listProductsArray = array_merge($listProductsArray, $listProductsIdTemp);
}
$listProductsId = implode(',', $listProductsArray);
$catalogModel = new Models_Catalog();
$productModel = new Models_Product();
if (!empty($listProductsId)) {
$arrProduct = $catalogModel->getListByUserFilter($countProduct, ' p.id IN (' . DB::quote($listProductsId, true) . ')');
}
$currencyRate = MG::getSetting('currencyRate');
$currencyShopIso = MG::getSetting('currencyShopIso');
$currencyShopIso = MG::getSetting('currencyShopIso');
foreach ($arrProduct['catalogItems'] as &$product) {
$blockVariants = $productModel->getBlockVariants($product['id']);
$blockedProp = $productModel->noPrintProperty();
$propertyFormData = $productModel->createPropertyForm($param = array('id' => $product['id'], 'maxCount' => $product['count'], 'productUserFields' => $product['thisUserFields'], 'action' => "/catalog", 'method' => "POST", 'ajax' => true, 'blockedProp' => $blockedProp, 'noneAmount' => false, 'titleBtn' => MG::getSetting('buttonBuyName'), 'blockVariants' => $blockVariants, 'printStrProp' => 'false', 'printCompareButton' => 'false', 'currency_iso' => $product['currency_iso']));
if ($product['count'] < 0) {
$product['count'] = "много";
}
$product['price'] += $propertyFormData['marginPrice'];
$product['currency_iso'] = $product['currency_iso'] ? $product['currency_iso'] : $currencyShopIso;
$product['currency'] = MG::getSetting('currency');
$product['old_price'] = $product['old_price'] * $currencyRate[$product['currency_iso']];
$product['old_price'] = $product['old_price'] ? MG::priceCourse($product['old_price']) : 0;
$product['price'] = MG::priceCourse($product['price_course'], true, true);
$product['propertyForm'] = $propertyFormData['html'];
$product['propertyNodummy'] = $propertyFormData['propertyNodummy'];
$product['stringsProperties'] = $propertyFormData['stringsProperties'];
$product['image_url'] = explode('|', $product['image_url']);
$product['image_url'] = $product['image_url'][0];
}
return array('catalogItems' => $arrProduct['catalogItems']);
}