当前位置: 首页>>代码示例>>PHP>>正文


PHP ProductSale类代码示例

本文整理汇总了PHP中ProductSale的典型用法代码示例。如果您正苦于以下问题:PHP ProductSale类的具体用法?PHP ProductSale怎么用?PHP ProductSale使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ProductSale类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: hookRightColumn

 function hookRightColumn($params)
 {
     global $smarty, $category_path;
     $category_path_ids = array();
     foreach ($category_path as $cat) {
         $category_path_ids[] = $cat['id_category'];
     }
     $currency = new Currency(intval($params['cookie']->id_currency));
     $bestsellers = ProductSale::getBestSalesLight(intval($params['cookie']->id_lang), 0, 25);
     $best_sellers = array();
     $nr = 0;
     foreach ($bestsellers as $bestseller) {
         if ($nr >= 5) {
             break;
         }
         $display = false;
         foreach (Product::getIndexedCategories($bestseller['id_product']) as $row) {
             if (in_array($row['id_category'], $category_path_ids)) {
                 $display = true;
                 break;
             }
         }
         if ($display) {
             $bestseller['price'] = Tools::displayPrice(Product::getPriceStaticLC(intval($bestseller['id_product'])), $currency, false, false);
             $best_sellers[] = $bestseller;
             $nr += 1;
         }
     }
     $smarty->assign(array('best_sellers' => $best_sellers, 'mediumSize' => Image::getSize('medium'), 'static_token' => Tools::getToken(false)));
     return $this->display(__FILE__, 'blockbestsellers.tpl');
 }
开发者ID:redb,项目名称:prestashop,代码行数:31,代码来源:blockbestsellers.php

示例2: process

 public function process()
 {
     $this->productSort();
     $nbProducts = (int) ProductSale::getNbSales();
     $this->pagination($nbProducts);
     self::$smarty->assign(array('products' => ProductSale::getBestSales((int) self::$cookie->id_lang, (int) $this->p - 1, (int) $this->n, $this->orderBy, $this->orderWay), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize('home')));
 }
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:7,代码来源:BestSalesController.php

示例3: renderContent

 public function renderContent($setting)
 {
     $t = array('list_type' => '', 'limit' => 12, 'image_width' => '200', 'image_height' => '200');
     $products = array();
     $setting = array_merge($t, $setting);
     switch ($setting['list_type']) {
         case 'newest':
             $products = Product::getNewProducts($this->lang_id, 0, (int) $setting['limit']);
             break;
         case 'featured':
             $category = new Category(Context::getContext()->shop->getCategory(), $this->lang_id);
             $nb = (int) $setting['limit'];
             $products = $category->getProducts((int) $this->lang_id, 1, $nb ? $nb : 8);
             break;
         case 'bestseller':
             $products = ProductSale::getBestSalesLight((int) $this->lang_id, 0, (int) $setting['limit']);
             break;
         case 'special':
             $products = Product::getPricesDrop($this->lang_id, 0, (int) $setting['limit']);
             break;
     }
     $setting['products'] = $products;
     $output = array('type' => 'productlist', 'data' => $setting);
     return $output;
 }
开发者ID:vuduykhuong1412,项目名称:GitHub,代码行数:25,代码来源:productlist.php

示例4: initContent

 public function initContent()
 {
     if (Configuration::get('PS_DISPLAY_BEST_SELLERS')) {
         parent::initContent();
         $this->productSort();
         $nb_products = (int) ProductSale::getNbSales();
         $this->pagination($nb_products);
         if (!Tools::getValue('orderby')) {
             $this->orderBy = 'sales';
         }
         $products = ProductSale::getBestSales($this->context->language->id, $this->p - 1, $this->n, $this->orderBy, $this->orderWay);
         $this->addColorsToProductList($products);
         /************************* /Images Array ******************************/
         if (method_exists('Product', 'getProductsImgs')) {
             $image_array = array();
             for ($i = 0; $i < $nb_products; $i++) {
                 if (isset($products[$i]['id_product'])) {
                     $image_array[$products[$i]['id_product']] = Product::getProductsImgs($products[$i]['id_product']);
                 }
             }
             $this->context->smarty->assign('productimg', (isset($image_array) and $image_array) ? $image_array : NULL);
         }
         /************************* /Images Array ******************************/
         $this->context->smarty->assign(array('products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nb_products, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
         $this->setTemplate(_PS_THEME_DIR_ . 'best-sales.tpl');
     } else {
         Tools::redirect('index.php?controller=404');
     }
 }
开发者ID:evgrishin,项目名称:se1614,代码行数:29,代码来源:BestSalesController.php

示例5: initContent

 public function initContent()
 {
     parent::initContent();
     $this->productSort();
     $nbProducts = (int) ProductSale::getNbSales();
     $this->pagination($nbProducts);
     $this->context->smarty->assign(array('products' => ProductSale::getBestSales($this->context->language->id, $this->p - 1, $this->n, $this->orderBy, $this->orderWay), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize('home_default'), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
     $this->setTemplate(_PS_THEME_DIR_ . 'best-sales.tpl');
 }
开发者ID:rrameshsat,项目名称:Prestashop,代码行数:9,代码来源:BestSalesController.php

示例6: hookRightColumn

 function hookRightColumn($params)
 {
     global $smarty;
     $currency = new Currency(intval($params['cookie']->id_currency));
     $bestsellers = ProductSale::getBestSalesLight(intval($params['cookie']->id_lang), 0, 5);
     $best_sellers = array();
     foreach ($bestsellers as $bestseller) {
         $bestseller['price'] = Tools::displayPrice(Product::getPriceStatic(intval($bestseller['id_product'])), $currency);
         $best_sellers[] = $bestseller;
     }
     $smarty->assign(array('best_sellers' => $best_sellers, 'mediumSize' => Image::getSize('medium')));
     return $this->display(__FILE__, 'blockbestsellers.tpl');
 }
开发者ID:sealence,项目名称:local,代码行数:13,代码来源:blockbestsellers.php

示例7: getBestSellers

 protected function getBestSellers($params)
 {
     if (Configuration::get('PS_CATALOG_MODE')) {
         return false;
     }
     if (!($result = ProductSale::getBestSalesLight((int) $params['cookie']->id_lang, 0, 3))) {
         return Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY') ? array() : false;
     }
     $currency = new Currency($params['cookie']->id_currency);
     $usetax = Product::getTaxCalculationMethod((int) $this->context->customer->id) != PS_TAX_EXC;
     foreach ($result as &$row) {
         $row['price'] = Tools::displayPrice(Product::getPriceStatic((int) $row['id_product'], $usetax), $currency);
     }
     return $result;
 }
开发者ID:paolobattistella,项目名称:aphro,代码行数:15,代码来源:blockbestsellers.php

示例8: initContent

 public function initContent()
 {
     if (Configuration::get('PS_DISPLAY_BEST_SELLERS')) {
         parent::initContent();
         $this->productSort();
         $nbProducts = (int) ProductSale::getNbSales();
         $this->pagination($nbProducts);
         $products = ProductSale::getBestSales($this->context->language->id, $this->p - 1, $this->n, $this->orderBy, $this->orderWay);
         $this->addColorsToProductList($products);
         $this->context->smarty->assign(array('products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
         $this->setTemplate(_PS_THEME_DIR_ . 'best-sales.tpl');
     } else {
         Tools::redirect('index.php?controller=404');
     }
 }
开发者ID:carloslastresDev,项目名称:HealthyTaiwan_UsingPrestaShop,代码行数:15,代码来源:BestSalesController.php

示例9: renderContent

 public function renderContent($args, $setting)
 {
     # validate module
     unset($args);
     $t = array('name' => '', 'html' => '');
     $setting = array_merge($t, $setting);
     $nb = $setting['itemstab'] ? (int) $setting['itemstab'] : 8;
     $orderby = $setting['orderby'] ? $setting['orderby'] : 'date_add';
     $orderway = $setting['orderway'] ? $setting['orderway'] : 'date_add';
     $items_page = $columns_page = 3;
     if (isset($setting['itemspage']) && $setting['itemspage']) {
         $items_page = $setting['itemspage'];
     }
     if (isset($setting['columns']) && $setting['columns']) {
         $columns_page = $setting['columns'];
     }
     $interval = isset($setting['interval']) ? (int) $setting['interval'] : 8000;
     switch ($setting['specialtype']) {
         case 'newest':
             $products = Product::getNewProducts($this->langID, 0, $nb, false, $orderby, $orderway);
             break;
         case 'featured':
             $category = new Category(Context::getContext()->shop->getCategory(), $this->langID);
             $products = $category->getProducts((int) $this->langID, 1, $nb, $orderby, $orderway);
             break;
         case 'bestseller':
             $products = ProductSale::getBestSalesLight((int) $this->langID, 0, $nb);
             break;
         case 'special':
             $products = Product::getPricesDrop($this->langID, 0, $nb, false, $orderby, $orderway);
             break;
         case 'random':
             $random = true;
             $products = $this->getProducts('WHERE  p.id_product > 0', (int) Context::getContext()->language->id, 1, $nb, $orderby, $orderway, false, true, $random, $nb);
             Configuration::updateValue('LEO_CURRENT_RANDOM_CACHE', '1');
             break;
     }
     $setting['specialtype'] = $setting['specialtype'];
     Context::getContext()->controller->addColorsToProductList($products);
     $setting['products'] = $products;
     $setting['itemsperpage'] = $items_page;
     $setting['columnspage'] = $columns_page;
     $setting['scolumn'] = 12 / $columns_page;
     $setting['interval'] = $interval;
     $setting['tab'] = 'leospecialproduct' . rand(20, rand());
     $output = array('type' => 'specialproduct', 'data' => $setting);
     return $output;
 }
开发者ID:ahmedonee,项目名称:morinella,代码行数:48,代码来源:specialcarousel.php

示例10: renderContent

 public function renderContent($args, $setting)
 {
     # validate module
     unset($args);
     $t = array('name' => '', 'html' => '');
     $setting = array_merge($t, $setting);
     $setting['special'] = array();
     $setting['bestseller'] = array();
     $setting['featured'] = array();
     $setting['newproducts'] = array();
     $category = new Category(Context::getContext()->shop->getCategory(), (int) Context::getContext()->language->id);
     $nb = $setting['itemstab'] ? (int) $setting['itemstab'] : 6;
     $orderby = $setting['orderby'] ? $setting['orderby'] : 'position';
     $orderway = $setting['orderway'] ? $setting['orderway'] : 'ASC';
     $items_page = $setting['itemspage'] ? (int) $setting['itemspage'] : 3;
     $columns_page = $setting['columns'] ? (int) $setting['columns'] : 3;
     $interval = isset($setting['interval']) ? (int) $setting['interval'] : 8000;
     if ($setting['featured_display'] && $setting['featured_display'] == 1) {
         $pro_featured = $category->getProducts((int) Context::getContext()->language->id, 1, $nb, $orderby, $orderway);
         Context::getContext()->controller->addColorsToProductList($pro_featured);
         $setting['featured'] = $pro_featured;
     }
     if ($setting['newarrivals_display'] && $setting['newarrivals_display'] == 1) {
         $pro_newproducts = Product::getNewProducts((int) Context::getContext()->language->id, 0, $nb, false, $orderby, $orderway);
         Context::getContext()->controller->addColorsToProductList($pro_newproducts);
         $setting['newproducts'] = $pro_newproducts;
     }
     if ($setting['special_display'] && $setting['special_display'] == 1) {
         $pro_special = Product::getPricesDrop((int) Context::getContext()->language->id, 0, $nb, false, $orderby, $orderway);
         Context::getContext()->controller->addColorsToProductList($pro_special);
         $setting['special'] = $pro_special;
     }
     if ($setting['bestseller_display'] && $setting['bestseller_display'] == 1) {
         $pro_bestseller = ProductSale::getBestSales((int) Context::getContext()->language->id, 0, $nb, $orderby, $orderway);
         Context::getContext()->controller->addColorsToProductList($pro_bestseller);
         $setting['bestseller'] = $pro_bestseller;
     }
     $setting['itemsperpage'] = $items_page;
     $setting['columnspage'] = $columns_page;
     $setting['interval'] = $interval;
     $setting['scolumn'] = 12 / $columns_page;
     $setting['homeSize'] = Image::getSize(ImageType::getFormatedName('home'));
     $setting['myTab'] = 'leoproducttab' . rand(20, rand());
     $output = array('type' => 'producttabs', 'data' => $setting);
     return $output;
 }
开发者ID:ahmedonee,项目名称:morinella,代码行数:46,代码来源:producttabs.php

示例11: hookRightColumn

 public function hookRightColumn($params)
 {
     if (Configuration::get('PS_CATALOG_MODE')) {
         return;
     }
     global $smarty;
     $currency = new Currency((int) $params['cookie']->id_currency);
     $bestsellers = ProductSale::getBestSalesLight((int) $params['cookie']->id_lang, 0, 5);
     if (!$bestsellers and !Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY')) {
         return;
     }
     $best_sellers = array();
     foreach ($bestsellers as $bestseller) {
         $bestseller['price'] = Tools::displayPrice(Product::getPriceStatic((int) $bestseller['id_product']), $currency);
         $best_sellers[] = $bestseller;
     }
     $smarty->assign(array('best_sellers' => $best_sellers, 'mediumSize' => Image::getSize('medium')));
     return $this->display(__FILE__, 'blockbestsellers.tpl');
 }
开发者ID:hecbuma,项目名称:quali-fisioterapia,代码行数:19,代码来源:blockbestsellers.php

示例12: changeIdOrderState

 public function changeIdOrderState($new_order_state = NULL, $id_order)
 {
     if ($new_order_state != NULL) {
         Hook::updateOrderStatus(intval($new_order_state), intval($id_order));
         /* Best sellers */
         $newOS = new OrderState(intval($new_order_state));
         $oldOrderStatus = OrderHistory::getLastOrderState(intval($id_order));
         $cart = Cart::getCartByOrderId($id_order);
         $isValidated = $this->isValidated();
         if (Validate::isLoadedObject($cart)) {
             foreach ($cart->getProducts() as $product) {
                 /* If becoming logable => adding sale */
                 if ($newOS->logable and (!$oldOrderStatus or !$oldOrderStatus->logable)) {
                     ProductSale::addProductSale($product['id_product'], $product['cart_quantity']);
                 } elseif (!$newOS->logable and ($oldOrderStatus and $oldOrderStatus->logable)) {
                     ProductSale::removeProductSale($product['id_product'], $product['cart_quantity']);
                 }
                 if (!$isValidated and $newOS->logable and isset($oldOrderStatus) and $oldOrderStatus and $oldOrderStatus->id == _PS_OS_ERROR_) {
                     Product::updateQuantity($product);
                     Hook::updateQuantity($product, $order);
                 }
             }
         }
         $this->id_order_state = intval($new_order_state);
         /* Change invoice number of order ? */
         $newOS = new OrderState(intval($new_order_state));
         $order = new Order(intval($id_order));
         if (!Validate::isLoadedObject($newOS) or !Validate::isLoadedObject($order)) {
             die(Tools::displayError('Invalid new order state'));
         }
         /* The order is valid only if the invoice is available and the order is not cancelled */
         $order->valid = $newOS->logable;
         $order->update();
         if ($newOS->invoice and !$order->invoice_number) {
             $order->setInvoice();
         }
         if ($newOS->delivery and !$order->delivery_number) {
             $order->setDelivery();
         }
         Hook::postUpdateOrderStatus(intval($new_order_state), intval($id_order));
     }
 }
开发者ID:vincent,项目名称:theinvertebrates,代码行数:42,代码来源:OrderHistory.php

示例13: initContent

 public function initContent()
 {
     if (Configuration::get('PS_DISPLAY_BEST_SELLERS')) {
         parent::initContent();
         $this->productSort();
         $nbProducts = (int) ProductSale::getNbSales();
         $this->pagination($nbProducts);
         $products = ProductSale::getBestSales($this->context->language->id, $this->p - 1, $this->n, $this->orderBy, $this->orderWay);
         $this->addColorsToProductList($products);
         $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displayLeftColumn'), 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
         if ($this->ajax) {
             $product_list = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'product-list.tpl');
             $pagination = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'pagination.tpl');
             $nbLeftProducts = $nbProducts - ($this->n * ($this->p - 1) + count($products));
             $nbLeftProductsPercentage = ($nbProducts - $nbLeftProducts) / $nbProducts * 100;
             echo Tools::jsonEncode(array('productList' => utf8_encode($product_list), 'pagination' => $pagination, 'nbRenderedProducts' => $nbProducts, 'nbLeftProducts' => $nbLeftProducts, 'nbLeftProductsPercentage' => $nbLeftProductsPercentage));
             die;
         } else {
             $this->setTemplate(_PS_THEME_DIR_ . 'best-sales.tpl');
         }
     } else {
         Tools::redirect('index.php?controller=404');
     }
 }
开发者ID:WhisperingTree,项目名称:etagerca,代码行数:24,代码来源:BestSalesController.php

示例14: removeProductSale

    public static function removeProductSale($id_product, $qty = 1)
    {
        $total_sales = ProductSale::getNbrSales($id_product);
        if ($total_sales > 1) {
            return Db::getInstance()->execute('
				UPDATE ' . _DB_PREFIX_ . 'product_sale
				SET `quantity` = `quantity` - ' . (int) $qty . ', `sale_nbr` = `sale_nbr` - 1, `date_upd` = NOW()
				WHERE `id_product` = ' . (int) $id_product);
        } elseif ($total_sales == 1) {
            return Db::getInstance()->delete('product_sale', 'id_product = ' . (int) $id_product);
        }
        return true;
    }
开发者ID:WhisperingTree,项目名称:etagerca,代码行数:13,代码来源:ProductSale.php

示例15: hookHome

 /**
  * hook home to display generate the product list associated to home featured, news products and best sellers Modules
  */
 public function hookHome()
 {
     $ga_scripts = '';
     // Home featured products
     if ($this->isModuleEnabled('homefeatured')) {
         $category = new Category($this->context->shop->getCategory(), $this->context->language->id);
         $home_featured_products = $this->wrapProducts($category->getProducts((int) Context::getContext()->language->id, 1, Configuration::get('HOME_FEATURED_NBR') ? (int) Configuration::get('HOME_FEATURED_NBR') : 8, 'position'), array(), true);
         $ga_scripts .= $this->addProductImpression($home_featured_products) . $this->addProductClick($home_featured_products);
     }
     // New products
     if ($this->isModuleEnabled('blocknewproducts') && (Configuration::get('PS_NB_DAYS_NEW_PRODUCT') || Configuration::get('PS_BLOCK_NEWPRODUCTS_DISPLAY'))) {
         $new_products = Product::getNewProducts((int) $this->context->language->id, 0, (int) Configuration::get('NEW_PRODUCTS_NBR'));
         $new_products_list = $this->wrapProducts($new_products, array(), true);
         $ga_scripts .= $this->addProductImpression($new_products_list) . $this->addProductClick($new_products_list);
     }
     // Best Sellers
     if ($this->isModuleEnabled('blockbestsellers') && (!Configuration::get('PS_CATALOG_MODE') || Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY'))) {
         $ga_homebestsell_product_list = $this->wrapProducts(ProductSale::getBestSalesLight((int) $this->context->language->id, 0, 8), array(), true);
         $ga_scripts .= $this->addProductImpression($ga_homebestsell_product_list) . $this->addProductClick($ga_homebestsell_product_list);
     }
     $this->js_state = 1;
     return $this->_runJs($this->filter($ga_scripts));
 }
开发者ID:pierreavizou,项目名称:ganalytics,代码行数:26,代码来源:ganalytics.php


注:本文中的ProductSale类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。