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


PHP Combination类代码示例

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


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

示例1: setProduct

 public function setProduct($product, $combination)
 {
     // create the product
     $context = Context::getContext();
     $this->give_it_product = new GiveItSdkProduct();
     $this->give_it_product->setCurrency($context->currency->iso_code);
     $usetax = Product::getTaxCalculationMethod((int) $context->customer->id) != PS_TAX_EXC;
     if ($combination['id_product_attribute'] == 0) {
         $combination['attributes'] = '';
         $image = Product::getCover($product->id);
     } else {
         $comb = new Combination($combination['id_product_attribute']);
         if ($image = $comb->getWsImages()) {
             $image = $image[0];
             $image['id_image'] = $image['id'];
         }
     }
     $image['id_product'] = $product->id;
     $image['id_image'] = Product::defineProductImage($image, Context::getContext()->language->id);
     $img_profile = version_compare(_PS_VERSION_, '1.5', '<') ? 'home' : ImageType::getFormatedName('medium');
     $image = $image ? $context->link->getImageLink($product->link_rewrite, $image['id_image'], $img_profile) : '';
     // first, set the product details.
     $this->give_it_product->setProductDetails(array('code' => $product->id . '_' . $combination['id_product_attribute'], 'price' => (int) (Product::getPriceStatic((int) $product->id, $usetax, $combination['id_product_attribute']) * 100), 'name' => $product->name . ($combination['attributes'] ? ' : ' . $combination['attributes'] : ''), 'image' => $image));
     $delivery = $this->setDelivery();
     // add the delivery option to the product
     $this->give_it_product->addBuyerOption($delivery);
     //We should validate this product
     $this->product_valid = $this->give_it_product->validate();
 }
开发者ID:TheTypoMaster,项目名称:neotienda,代码行数:29,代码来源:giveit.class.php

示例2: testCombinationSuccess

 public function testCombinationSuccess()
 {
     $combination = new Combination();
     $combination->isPublic = true;
     $combination->protocol_id = 1;
     $combination->power_generator_id = 1;
     $combination->needle_id = 1;
     $this->assertTrue($combination->save());
 }
开发者ID:philtweir,项目名称:glossia-scratch-test-site,代码行数:9,代码来源:CombinationTest.php

示例3: getStaticblockLists

    public function getStaticblockLists($id_shop = NULL, $hook_position = 'top')
    {
        if (!Combination::isFeatureActive()) {
            return array();
        }
        $id_lang = (int) Context::getContext()->language->id;
        $object = Db::getInstance()->executeS('
                    SELECT * FROM ' . _DB_PREFIX_ . 'pos_staticblock AS psb 
					LEFT JOIN ' . _DB_PREFIX_ . 'pos_staticblock_lang AS psl ON psb.id_posstaticblock = psl.id_posstaticblock
                    LEFT JOIN ' . _DB_PREFIX_ . 'pos_staticblock_shop AS pss ON psb.id_posstaticblock = pss.id_posstaticblock
                    WHERE id_shop =' . $id_shop . ' 
						AND id_lang =' . $id_lang . '
						AND `hook_position` = "' . $hook_position . '" 
						AND `showhook` = 1 ORDER BY `posorder` ASC
		');
        $newObject = array();
        if (count($newObject > 0)) {
            foreach ($object as $key => $ob) {
                $nameModule = $ob['name_module'];
                $hookModule = $ob['hook_module'];
                $blockModule = $this->getModuleAssign($nameModule, $hookModule);
                $ob['block_module'] = $blockModule;
                $description = $ob['description'];
                $description = str_replace('/pos_hitstore/', __PS_BASE_URI__, $description);
                $ob['description'] = $description;
                // array_push($ob, $blockModule);
                $newObject[$key] = $ob;
            }
            return $newObject;
        }
        return null;
    }
开发者ID:IngenioContenidoDigital,项目名称:serta,代码行数:32,代码来源:Staticblock.php

示例4: delete

 function delete($id = null)
 {
     if (!$id) {
         $this->Session->setFlash(__('Invalid id for Operatingsystem', true));
         $this->redirect(array('action' => 'index'));
     }
     if ($this->Operatingsystem->del($id)) {
         $combination = new Combination();
         $all_com = $combination->find('all', array('conditions' => array('Combination.operatingsystem_id' => $id)));
         foreach ($all_com as $key => $value) {
             $this->Operatingsystem->Combination->del($value['Combination']['id']);
         }
         $this->Session->setFlash(__('Operatingsystem deleted', true));
         $this->redirect(array('action' => 'index'));
     }
 }
开发者ID:erlendfh,项目名称:Bromine,代码行数:16,代码来源:operatingsystems_controller.php

示例5: testCombinationsStatic

 public function testCombinationsStatic()
 {
     // Size 0 combinations ---------------------------------------------------------------------
     $combinationList0 = Combination::get($this->_sourceDataSetKey, 0);
     $expectedList0 = [];
     $this->_assertCombination($combinationList0, $expectedList0, 0);
     // Size 1 combinations ---------------------------------------------------------------------
     $combinationList1 = Combination::get($this->_sourceDataSetKey, 1);
     $expectedList1 = [['a' => 5], ['b' => 6], ['c' => 8], ['d' => 10]];
     $this->_assertCombination($combinationList1, $expectedList1, 4, 1);
     // If this test pass, we don't need to check for other Index arrays as it proves that the
     // combination is still treated as a map and thus if the key arrays tests pass, so would the
     // indexed arrays
     $combinationIdxList1 = Combination::get($this->_sourceDataSetIdx, 1);
     $expectedIdxList1 = [[0 => 5], [1 => 6], [2 => 8], [3 => 10]];
     $this->_assertCombination($combinationIdxList1, $expectedIdxList1, 4, 1);
     // Size 3 combinations ---------------------------------------------------------------------
     $combinationList3 = Combination::get($this->_sourceDataSetKey, 3);
     $expectedList3 = [['a' => 5, 'b' => 6, 'c' => 8], ['a' => 5, 'b' => 6, 'd' => 10], ['a' => 5, 'c' => 8, 'd' => 10], ['b' => 6, 'c' => 8, 'd' => 10]];
     $this->_assertCombination($expectedList3, $combinationList3, 4, 3);
     // Size 4 combinations ---------------------------------------------------------------------
     $combinationList4 = Combination::get($this->_sourceDataSetKey, 4);
     $expectedList4 = [['a' => 5, 'b' => 6, 'c' => 8, 'd' => 10]];
     $this->_assertCombination($expectedList4, $combinationList4, 1, 4);
     // Size 3 combinations ---------------------------------------------------------------------
     $combinationList = Combination::get($this->_sourceDataSetKey);
     $expectedList = [['a' => 5], ['b' => 6], ['c' => 8], ['d' => 10], ['a' => 5, 'b' => 6], ['a' => 5, 'c' => 8], ['a' => 5, 'd' => 10], ['b' => 6, 'c' => 8], ['b' => 6, 'd' => 10], ['c' => 8, 'd' => 10], ['a' => 5, 'b' => 6, 'c' => 8], ['a' => 5, 'b' => 6, 'd' => 10], ['a' => 5, 'c' => 8, 'd' => 10], ['b' => 6, 'c' => 8, 'd' => 10], ['a' => 5, 'b' => 6, 'c' => 8, 'd' => 10]];
     $this->_assertCombination($expectedList, $combinationList, 15);
 }
开发者ID:alphazygma,项目名称:combinatorics,代码行数:29,代码来源:CombinationTest.php

示例6: set_to_scad_spr

 function set_to_scad_spr()
 {
     $s = '';
     //формируем начало 36 документа
     //нулевой байт
     $s .= pack('a1', '');
     $sql = "SELECT MAX(comb) FROM " . combinations;
     mysql_query($sql);
     switch (mysql_errno()) {
         case 1146:
             echo "<b>Table " . combinations . " doesn't exist. Please create DB.</b><br>";
             break;
         default:
             if (mysql_errno() > 0) {
                 echo mysql_errno() . '  ' . mysql_error() . '<br>';
             }
             $result = mysql_query($sql);
             if (mysql_num_rows($result) > 0) {
                 $comb_count = mysql_result($result, 0, 0);
                 if ($comb_count != NULL) {
                     //пишем кол-во комбинаций
                     $s .= pack('V', (string) $comb_count);
                     for ($i = 1; $i <= $comb_count; $i++) {
                         //2 нулевых байта
                         $s .= pack('a2', '');
                         $comb = new Combination();
                         $sql = "SELECT * FROM " . combinations . " WHERE comb = {$i}";
                         //                        echo $sql.'<br/>';
                         $result = mysql_query($sql);
                         if (mysql_num_rows($result) > 0) {
                             while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                                 $comb->factors[$row['koef']] = $row['value'];
                             }
                         }
                         //пишем комбинацию
                         $s .= $comb->set_to_spr();
                     }
                 } else {
                     $s .= pack('a4', '');
                 }
                 //кол-во комбинаций = 0 int 4 байта
             }
     }
     return $s;
 }
开发者ID:vokson,项目名称:scad.local,代码行数:45,代码来源:class_TCombination.php

示例7: assignPriceAndTax

 /**
  * Assign price and tax to the template
  */
 protected function assignPriceAndTax()
 {
     die('coucou');
     $id_customer = isset($this->context->customer) ? (int) $this->context->customer->id : 0;
     $id_group = (int) Group::getCurrent()->id;
     $id_country = $id_customer ? (int) Customer::getCurrentCountry($id_customer) : (int) Tools::getCountry();
     $group_reduction = GroupReduction::getValueForProduct($this->product->id, $id_group);
     if ($group_reduction === false) {
         $group_reduction = Group::getReduction((int) $this->context->cookie->id_customer) / 100;
     }
     // Tax
     $tax = (double) $this->product->getTaxesRate(new Address((int) $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
     $this->context->smarty->assign('tax_rate', $tax);
     $product_price_with_tax = Product::getPriceStatic($this->product->id, true, null, 6) * 10;
     if (Product::$_taxCalculationMethod == PS_TAX_INC) {
         $product_price_with_tax = Tools::ps_round($product_price_with_tax, 2);
     }
     $product_price_without_eco_tax = (double) $product_price_with_tax - $this->product->ecotax;
     $ecotax_rate = (double) Tax::getProductEcotaxRate($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
     $ecotax_tax_amount = Tools::ps_round($this->product->ecotax, 2);
     if (Product::$_taxCalculationMethod == PS_TAX_INC && (int) Configuration::get('PS_TAX')) {
         $ecotax_tax_amount = Tools::ps_round($ecotax_tax_amount * (1 + $ecotax_rate / 100), 2);
     }
     $id_currency = (int) $this->context->cookie->id_currency;
     $id_product = (int) $this->product->id;
     $id_shop = $this->context->shop->id;
     $quantity_discounts = SpecificPrice::getQuantityDiscounts($id_product, $id_shop, $id_currency, $id_country, $id_group, null, true, (int) $this->context->customer->id);
     foreach ($quantity_discounts as &$quantity_discount) {
         if ($quantity_discount['id_product_attribute']) {
             $combination = new Combination((int) $quantity_discount['id_product_attribute']);
             $attributes = $combination->getAttributesName((int) $this->context->language->id);
             foreach ($attributes as $attribute) {
                 $quantity_discount['attributes'] = $attribute['name'] . ' - ';
             }
             $quantity_discount['attributes'] = rtrim($quantity_discount['attributes'], ' - ');
         }
         if ((int) $quantity_discount['id_currency'] == 0 && $quantity_discount['reduction_type'] == 'amount') {
             $quantity_discount['reduction'] = Tools::convertPriceFull($quantity_discount['reduction'], null, Context::getContext()->currency);
         }
     }
     $product_price = $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false) * 10;
     $address = new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
     $this->context->smarty->assign(array('quantity_discounts' => $this->formatQuantityDiscounts($quantity_discounts, $product_price, (double) $tax, $ecotax_tax_amount), 'ecotax_tax_inc' => $ecotax_tax_amount, 'ecotax_tax_exc' => Tools::ps_round($this->product->ecotax, 2), 'ecotaxTax_rate' => $ecotax_rate, 'productPriceWithoutEcoTax' => (double) $product_price_without_eco_tax, 'group_reduction' => $group_reduction, 'no_tax' => Tax::excludeTaxeOption() || !$this->product->getTaxesRate($address), 'ecotax' => !count($this->errors) && $this->product->ecotax > 0 ? Tools::convertPrice((double) $this->product->ecotax) : 0, 'tax_enabled' => Configuration::get('PS_TAX') && !Configuration::get('AEUC_LABEL_TAX_INC_EXC'), 'customer_group_without_tax' => Group::getPriceDisplayMethod($this->context->customer->id_default_group)));
 }
开发者ID:ArnaudBenassy,项目名称:prestashop_test,代码行数:47,代码来源:ProductController.php

示例8: clean

 public function clean($command)
 {
     $lockedCombinations = \Combination::whereExists(function ($q) {
         $q->select(DB::raw(1))->from('Simulation')->whereRaw('Simulation.Combination_Id = Combination.Combination_Id');
     })->get();
     if (!$lockedCombinations->isEmpty()) {
         $command->info("The following combinations are locked for removal by simulations\n  * " . $lockedCombinations->implode('asString', "\n  * "));
     }
     \Combination::whereNotExists(function ($q) {
         $q->select(DB::raw(1))->from('Simulation')->whereRaw('Simulation.Combination_Id = Combination.Combination_Id');
     })->delete();
 }
开发者ID:philtweir,项目名称:glossia-scratch-test-site,代码行数:12,代码来源:CombinationSeeder.php

示例9: getProducts

    public static function getProducts($product_ids, $p = 1, $n, $active = true, Context $context = null)
    {
        if (!$context) {
            $context = Context::getContext();
        }
        $id_lang = $context->language->id;
        $front = true;
        if (!in_array($context->controller->controller_type, array('front', 'modulefront'))) {
            $front = false;
        }
        if ($p < 1) {
            $p = 1;
        }
        $sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) AS quantity' . (Combination::isFeatureActive() ? ', IFNULL(product_attribute_shop.id_product_attribute, 0) AS id_product_attribute,
					product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity' : '') . ', 
						pl.`description`, pl.`description_short`, pl.`available_now`,
					pl.`available_later`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, 
					pl.`meta_title`, pl.`name`, image_shop.`id_image` id_image,
					il.`legend` as legend, m.`name` AS manufacturer_name, cl.`name` AS category_default,
					DATEDIFF(product_shop.`date_add`, DATE_SUB("' . date('Y-m-d') . ' 00:00:00",
					INTERVAL ' . (int) Configuration::get('PS_NB_DAYS_NEW_PRODUCT') . ' DAY)) > 0 AS new, product_shop.price AS orderprice
				FROM `' . _DB_PREFIX_ . 'category_product` cp
				LEFT JOIN `' . _DB_PREFIX_ . 'product` p
					ON p.`id_product` = cp.`id_product`
				' . Shop::addSqlAssociation('product', 'p') . (Combination::isFeatureActive() ? ' LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_shop` product_attribute_shop
				ON (p.`id_product` = product_attribute_shop.`id_product` AND product_attribute_shop.`default_on` = 1 
					AND product_attribute_shop.id_shop=' . (int) $context->shop->id . ')' : '') . '
				' . Product::sqlStock('p', 0) . '
				LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl
					ON (product_shop.`id_category_default` = cl.`id_category`
					AND cl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('cl') . ')
				LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl
					ON (p.`id_product` = pl.`id_product`
					AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl') . ')
				LEFT JOIN `' . _DB_PREFIX_ . 'image_shop` image_shop
					ON (image_shop.`id_product` = p.`id_product` AND image_shop.cover=1 AND image_shop.id_shop=' . (int) $context->shop->id . ')
				LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il
					ON (image_shop.`id_image` = il.`id_image`
					AND il.`id_lang` = ' . (int) $id_lang . ')
				LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m
					ON m.`id_manufacturer` = p.`id_manufacturer`
				WHERE product_shop.`id_shop` = ' . (int) $context->shop->id . ($active ? ' AND product_shop.`active` = 1' : '') . ($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '') . ($product_ids ? ' AND p.id_product IN (0, ' . pSQL(implode(',', $product_ids)) . ')' : '') . ' GROUP BY cp.id_product';
        if ($n) {
            $sql .= ' LIMIT ' . ((int) $p - 1) * (int) $n . ',' . (int) $n;
        }
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql, true, false);
        if (!$result) {
            return array();
        }
        /* Modify SQL result */
        return Product::getProductsProperties($id_lang, $result);
    }
开发者ID:vuduykhuong1412,项目名称:GitHub,代码行数:52,代码来源:productrecommended.php

示例10: getAttributes

    public static function getAttributes($db, $id_product, $id_lang)
    {
        if (!Combination::isFeatureActive()) {
            return '';
        }
        $attributes = '';
        $attributesArray = $db->executeS('
		SELECT al.name FROM ' . _DB_PREFIX_ . 'product_attribute pa
		INNER JOIN ' . _DB_PREFIX_ . 'product_attribute_combination pac ON pa.id_product_attribute = pac.id_product_attribute
		INNER JOIN ' . _DB_PREFIX_ . 'attribute_lang al ON (pac.id_attribute = al.id_attribute AND al.id_lang = ' . (int) $id_lang . ')
		' . Shop::addSqlAssociation('product_attribute', 'pa') . '
		WHERE pa.id_product = ' . (int) $id_product);
        foreach ($attributesArray as $attribute) {
            $attributes .= $attribute['name'] . ' ';
        }
        return $attributes;
    }
开发者ID:rongandat,项目名称:vatfairfoot,代码行数:17,代码来源:Search.php

示例11: getCrossSells

    public static function getCrossSells($id_product, $id_lang, $limit = 12)
    {
        if (!$id_product || !$id_lang) {
            return;
        }
        $front = true;
        if (!in_array(Context::getContext()->controller->controller_type, array('front', 'modulefront'))) {
            $front = false;
        }
        $orders = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
		SELECT o.id_order
		FROM ' . _DB_PREFIX_ . 'orders o
		LEFT JOIN ' . _DB_PREFIX_ . 'order_detail od ON (od.id_order = o.id_order)
		WHERE o.valid = 1 AND od.product_id = ' . (int) $id_product);
        if (count($orders)) {
            $list = '';
            foreach ($orders as $order) {
                $list .= (int) $order['id_order'] . ',';
            }
            $list = rtrim($list, ',');
            $order_products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
				SELECT DISTINCT od.product_id, p.id_product, pl.name, pl.link_rewrite, p.reference, i.id_image, product_shop.show_price,
				cl.link_rewrite category, p.ean13, p.out_of_stock, p.id_category_default ' . (Combination::isFeatureActive() ? ', IFNULL(product_attribute_shop.id_product_attribute,0) id_product_attribute' : '') . '
				FROM ' . _DB_PREFIX_ . 'order_detail od
				LEFT JOIN ' . _DB_PREFIX_ . 'product p ON (p.id_product = od.product_id)
				' . Shop::addSqlAssociation('product', 'p') . (Combination::isFeatureActive() ? 'LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_shop` product_attribute_shop
				ON (p.`id_product` = product_attribute_shop.`id_product` AND product_attribute_shop.`default_on` = 1 AND product_attribute_shop.id_shop=' . (int) Context::getContext()->shop->id . ')' : '') . '
				LEFT JOIN ' . _DB_PREFIX_ . 'product_lang pl ON (pl.id_product = od.product_id' . Shop::addSqlRestrictionOnLang('pl') . ')
				LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (cl.id_category = product_shop.id_category_default' . Shop::addSqlRestrictionOnLang('cl') . ')
				LEFT JOIN ' . _DB_PREFIX_ . 'image i ON (i.id_product = od.product_id)
				WHERE od.id_order IN (' . $list . ')
					AND pl.id_lang = ' . (int) $id_lang . '
					AND cl.id_lang = ' . (int) $id_lang . '
					AND od.product_id != ' . (int) $id_product . '
					AND i.cover = 1
					AND product_shop.active = 1' . ($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '') . '
				ORDER BY RAND()
				LIMIT ' . (int) $limit . '
			', true, false);
            $tax_calc = Product::getTaxCalculationMethod();
            if (is_array($order_products)) {
                foreach ($order_products as &$order_product) {
                    $order_product['image'] = Context::getContext()->link->getImageLink($order_product['link_rewrite'], (int) $order_product['product_id'] . '-' . (int) $order_product['id_image'], ImageType::getFormatedName('medium'));
                    $order_product['link'] = Context::getContext()->link->getProductLink((int) $order_product['product_id'], $order_product['link_rewrite'], $order_product['category'], $order_product['ean13']);
                    if ($tax_calc == 0 || $tax_calc == 2) {
                        $order_product['displayed_price'] = Product::getPriceStatic((int) $order_product['product_id'], true, null);
                    } elseif ($tax_calc == 1) {
                        $order_product['displayed_price'] = Product::getPriceStatic((int) $order_product['product_id'], false, null);
                    }
                }
                return Product::getProductsProperties($id_lang, $order_products);
            }
        }
    }
开发者ID:nmardones,项目名称:PrestaShop,代码行数:54,代码来源:OrderDetail.php

示例12: getNewProducts

    public function getNewProducts($where, $id_lang, $page_number = 0, $nb_products = 10, $count = false, $order_by = null, $order_way = null, Context $context = null)
    {
        if (!$context) {
            $context = Context::getContext();
        }
        $front = true;
        if (!in_array($context->controller->controller_type, array('front', 'modulefront'))) {
            $front = false;
        }
        if ($page_number < 0) {
            $page_number = 0;
        }
        if ($nb_products < 1) {
            $nb_products = 10;
        }
        if (empty($order_by) || $order_by == 'position') {
            $order_by = 'date_add';
        }
        if (empty($order_way)) {
            $order_way = 'DESC';
        }
        if ($order_by == 'id_product' || $order_by == 'price' || $order_by == 'date_add' || $order_by == 'date_upd') {
            $order_by_prefix = 'p';
        } else {
            if ($order_by == 'name') {
                $order_by_prefix = 'pl';
            }
        }
        if (!Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way)) {
            die(Tools::displayError());
        }
        $sql_groups = '';
        if (Group::isFeatureActive()) {
            $groups = FrontController::getCurrentCustomerGroups();
            $sql_groups = 'AND p.`id_product` IN (
					SELECT cp.`id_product`
					FROM `' . _DB_PREFIX_ . 'category_group` cg
					LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`)
					WHERE cg.`id_group` ' . (count($groups) ? 'IN (' . implode(',', $groups) . ')' : '= 1') . '
				)';
        }
        if (strpos($order_by, '.') > 0) {
            $order_by = explode('.', $order_by);
            $order_by_prefix = $order_by[0];
            $order_by = $order_by[1];
        }
        if ($count) {
            $sql = 'SELECT COUNT(p.`id_product`) AS nb
						FROM `' . _DB_PREFIX_ . 'product` p
						' . Shop::addSqlAssociation('product', 'p') . '
						WHERE product_shop.`active` = 1
						AND product_shop.`date_add` > "' . date('Y-m-d', strtotime('-' . (Configuration::get('PS_NB_DAYS_NEW_PRODUCT') ? (int) Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20) . ' DAY')) . '"
						' . ($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '') . '
						' . $sql_groups;
            return (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
        }
        $sql = new DbQuery();
        $sql->select('p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
				pl.`meta_keywords`, pl.`meta_title`, pl.`name`, MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` AS manufacturer_name,
				product_shop.`date_add` > "' . date('Y-m-d', strtotime('-' . (Configuration::get('PS_NB_DAYS_NEW_PRODUCT') ? (int) Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20) . ' DAY')) . '" as new');
        $sql->from('product', 'p');
        $sql->join(Shop::addSqlAssociation('product', 'p'));
        $sql->leftJoin('product_lang', 'pl', '
				p.`id_product` = pl.`id_product`
				AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl'));
        $sql->leftJoin('image', 'i', 'i.`id_product` = p.`id_product`');
        $sql->join(Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1'));
        $sql->leftJoin('image_lang', 'il', 'i.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $id_lang);
        $sql->leftJoin('manufacturer', 'm', 'm.`id_manufacturer` = p.`id_manufacturer`');
        $sql->where('product_shop.`active` = 1');
        if ($front) {
            $sql->where('product_shop.`visibility` IN ("both", "catalog")');
        }
        $sql->where('product_shop.`date_add` > "' . date('Y-m-d', strtotime('-' . (Configuration::get('PS_NB_DAYS_NEW_PRODUCT') ? (int) Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20) . ' DAY')) . '"');
        if (Group::isFeatureActive()) {
            $sql->where('p.`id_product` IN (
					SELECT cp.`id_product`
					FROM `' . _DB_PREFIX_ . 'category_group` cg
					LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`)
					WHERE ' . $where . ' cg.`id_group` ' . $sql_groups . '
				)');
        }
        $sql->groupBy('product_shop.id_product');
        $sql->orderBy((isset($order_by_prefix) ? pSQL($order_by_prefix) . '.' : '') . '`' . pSQL($order_by) . '` ' . pSQL($order_way));
        $sql->limit($nb_products, $page_number * $nb_products);
        if (Combination::isFeatureActive()) {
            $sql->select('MAX(product_attribute_shop.id_product_attribute) id_product_attribute');
            $sql->leftOuterJoin('product_attribute', 'pa', 'p.`id_product` = pa.`id_product`');
            $sql->join(Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.default_on = 1'));
        }
        $sql->join(Product::sqlStock('p', Combination::isFeatureActive() ? 'product_attribute_shop' : 0));
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
        if ($order_by == 'price') {
            Tools::orderbyPrice($result, $order_way);
        }
        if (!$result) {
            return false;
        }
        $products_ids = array();
        foreach ($result as $row) {
//.........这里部分代码省略.........
开发者ID:evgrishin,项目名称:se1614,代码行数:101,代码来源:advancetab.php

示例13: isAttribute

    /**
     * Check if the given name is an Attribute within the given AttributeGroup
     *
     * @param int    $idAttributeGroup AttributeGroup
     * @param string $name             Attribute name
     * @param int    $idLang           Language ID
     *
     * @return array|bool
     */
    public static function isAttribute($idAttributeGroup, $name, $idLang)
    {
        if (!Combination::isFeatureActive()) {
            return array();
        }
        $result = Db::getInstance()->getValue('
			SELECT COUNT(*)
			FROM `' . _DB_PREFIX_ . 'attribute_group` ag
			LEFT JOIN `' . _DB_PREFIX_ . 'attribute_group_lang` agl
				ON (ag.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = ' . (int) $idLang . ')
			LEFT JOIN `' . _DB_PREFIX_ . 'attribute` a
				ON a.`id_attribute_group` = ag.`id_attribute_group`
			LEFT JOIN `' . _DB_PREFIX_ . 'attribute_lang` al
				ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = ' . (int) $idLang . ')
			' . Shop::addSqlAssociation('attribute_group', 'ag') . '
			' . Shop::addSqlAssociation('attribute', 'a') . '
			WHERE al.`name` = \'' . pSQL($name) . '\' AND ag.`id_attribute_group` = ' . (int) $idAttributeGroup . '
			ORDER BY agl.`name` ASC, a.`position` ASC
		');
        return (int) $result > 0;
    }
开发者ID:M03G,项目名称:PrestaShop,代码行数:30,代码来源:Attribute.php

示例14: dirname

require_once dirname(__FILE__) . '/../../config/config.inc.php';
require_once dirname(__FILE__) . '/../../init.php';
$context = Context::getContext();
$action = Tools::getValue('action');
$add = !strcmp($action, 'add') ? 1 : 0;
$id_product = (int) Tools::getValue('id_product');
$quantity = (int) Tools::getValue('quantity');
$id_product_attribute = (int) Tools::getValue('id_product_attribute');
$result = array();
$data = array();
$result['data'] = date('Y-m-d H:i:s');
$result['action'] = $action;
$product = new Product($id_product, false, $context->cookie->id_lang);
$result['name'] = $product->name;
$result['quantity'] = $quantity ? $quantity : 1;
$result['price'] = $product->price;
if ($id_product_attribute) {
    $combination = new Combination($id_product_attribute);
    $attributes = $combination->getAttributesName($context->cookie->id_lang);
    $name = array();
    foreach ($attributes as $a) {
        $name[] = $a['name'];
    }
    $name = implode(' ', $name);
    $result['name'] = $result['name'] . ' ' . $name;
    $result['price'] = $result['price'] + $combination->price;
}
$result['price'] = Tools::displayPrice($result['price']);
$data['params'] = $result;
$data['number'] = Configuration::get('YA_METRIKA_NUMBER');
die(Tools::jsonEncode($data));
开发者ID:petr-repyev,项目名称:yandex-money-cms-prestashop,代码行数:31,代码来源:action.php

示例15: postProcess

    public function postProcess()
    {
        /* PrestaShop demo mode */
        if (_PS_MODE_DEMO_) {
            $this->errors[] = Tools::displayError('This functionality has been disabled.');
            return;
        }
        Hook::exec('action' . get_class($this) . ucfirst($this->action) . 'Before', array('controller' => $this));
        if (Tools::isSubmit('submitAddServer')) {
            if ($this->tabAccess['add'] === '1') {
                if (!Tools::getValue('memcachedIp')) {
                    $this->errors[] = Tools::displayError('The Memcached IP is missing.');
                }
                if (!Tools::getValue('memcachedPort')) {
                    $this->errors[] = Tools::displayError('The Memcached port is missing.');
                }
                if (!Tools::getValue('memcachedWeight')) {
                    $this->errors[] = Tools::displayError('The Memcached weight is missing.');
                }
                if (!count($this->errors)) {
                    if (CacheMemcache::addServer(pSQL(Tools::getValue('memcachedIp')), (int) Tools::getValue('memcachedPort'), (int) Tools::getValue('memcachedWeight'))) {
                        Tools::redirectAdmin(self::$currentIndex . '&token=' . Tools::getValue('token') . '&conf=4');
                    } else {
                        $this->errors[] = Tools::displayError('The Memcached server cannot be added.');
                    }
                }
            } else {
                $this->errors[] = Tools::displayError('You do not have permission to add this.');
            }
        }
        if (Tools::getValue('deleteMemcachedServer')) {
            if ($this->tabAccess['add'] === '1') {
                if (CacheMemcache::deleteServer((int) Tools::getValue('deleteMemcachedServer'))) {
                    Tools::redirectAdmin(self::$currentIndex . '&token=' . Tools::getValue('token') . '&conf=4');
                } else {
                    $this->errors[] = Tools::displayError('There was an error when attempting to delete the Memcached server.');
                }
            } else {
                $this->errors[] = Tools::displayError('You do not have permission to delete this.');
            }
        }
        $redirectAdmin = false;
        if ((bool) Tools::getValue('smarty_up')) {
            if ($this->tabAccess['edit'] === '1') {
                Configuration::updateValue('PS_SMARTY_FORCE_COMPILE', Tools::getValue('smarty_force_compile', _PS_SMARTY_NO_COMPILE_));
                Configuration::updateValue('PS_SMARTY_CACHE', Tools::getValue('smarty_cache', 0));
                Configuration::updateValue('PS_SMARTY_CONSOLE', Tools::getValue('smarty_console', 0));
                Configuration::updateValue('PS_SMARTY_CONSOLE_KEY', Tools::getValue('smarty_console_key', 'SMARTY_DEBUG'));
                $redirecAdmin = true;
            } else {
                $this->errors[] = Tools::displayError('You do not have permission to edit this.');
            }
        }
        if ((bool) Tools::getValue('features_detachables_up')) {
            if ($this->tabAccess['edit'] === '1') {
                if (Tools::getValue('combination') || !Combination::isCurrentlyUsed()) {
                    Configuration::updateValue('PS_COMBINATION_FEATURE_ACTIVE', Tools::getValue('combination'));
                }
                if (Tools::getValue('customer_group') && !Group::isCurrentlyUsed()) {
                    Configuration::updateValue('PS_GROUP_FEATURE_ACTIVE', Tools::getValue('customer_group'));
                }
                Configuration::updateValue('PS_FEATURE_FEATURE_ACTIVE', Tools::getValue('feature'));
                $redirectAdmin = true;
            } else {
                $this->errors[] = Tools::displayError('You do not have permission to edit this.');
            }
        }
        if ((bool) Tools::getValue('ccc_up')) {
            if ($this->tabAccess['edit'] === '1') {
                $theme_cache_directory = _PS_ALL_THEMES_DIR_ . $this->context->shop->theme_directory . '/cache/';
                if (((bool) Tools::getValue('PS_CSS_THEME_CACHE') || (bool) Tools::getValue('PS_JS_THEME_CACHE')) && !is_writable($theme_cache_directory)) {
                    $this->errors[] = Tools::displayError(sprintf($this->l('To use Smart Cache directory %s must be writable.'), realpath($theme_cache_directory)));
                }
                if (!Configuration::updateValue('PS_CSS_THEME_CACHE', (int) Tools::getValue('PS_CSS_THEME_CACHE')) || !Configuration::updateValue('PS_JS_THEME_CACHE', (int) Tools::getValue('PS_JS_THEME_CACHE')) || !Configuration::updateValue('PS_HTML_THEME_COMPRESSION', (int) Tools::getValue('PS_HTML_THEME_COMPRESSION')) || !Configuration::updateValue('PS_JS_HTML_THEME_COMPRESSION', (int) Tools::getValue('PS_JS_HTML_THEME_COMPRESSION')) || !Configuration::updateValue('PS_HTACCESS_CACHE_CONTROL', (int) Tools::getValue('PS_HTACCESS_CACHE_CONTROL'))) {
                    $this->errors[] = Tools::displayError('Unknown error.');
                } else {
                    $redirectAdmin = true;
                    if (Configuration::get('PS_HTACCESS_CACHE_CONTROL')) {
                        Tools::generateHtaccess();
                    }
                }
            } else {
                $this->errors[] = Tools::displayError('You do not have permission to edit this.');
            }
        }
        if ((bool) Tools::getValue('media_server_up')) {
            if ($this->tabAccess['edit'] === '1') {
                if (Tools::getValue('_MEDIA_SERVER_1_') != null && !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_1_'))) {
                    $this->errors[] = Tools::displayError('Media server #1 is invalid');
                }
                if (Tools::getValue('_MEDIA_SERVER_2_') != null && !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_2_'))) {
                    $this->errors[] = Tools::displayError('Media server #2 is invalid');
                }
                if (Tools::getValue('_MEDIA_SERVER_3_') != null && !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_3_'))) {
                    $this->errors[] = Tools::displayError('Media server #3 is invalid');
                }
                if (!count($this->errors)) {
                    $base_urls = array();
                    $base_urls['_MEDIA_SERVER_1_'] = Tools::getValue('_MEDIA_SERVER_1_');
                    $base_urls['_MEDIA_SERVER_2_'] = Tools::getValue('_MEDIA_SERVER_2_');
//.........这里部分代码省略.........
开发者ID:dev-lav,项目名称:htdocs,代码行数:101,代码来源:AdminPerformanceController.php


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