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


PHP CategoryQuery::getCategoryTreeIds方法代码示例

本文整理汇总了PHP中Thelia\Model\CategoryQuery::getCategoryTreeIds方法的典型用法代码示例。如果您正苦于以下问题:PHP CategoryQuery::getCategoryTreeIds方法的具体用法?PHP CategoryQuery::getCategoryTreeIds怎么用?PHP CategoryQuery::getCategoryTreeIds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Thelia\Model\CategoryQuery的用法示例。


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

示例1: buildModelCriteria

 public function buildModelCriteria()
 {
     Tlog::getInstance()->debug("-- Starting new product build criteria");
     $currencyId = $this->getCurrency();
     if (null !== $currencyId) {
         $currency = CurrencyQuery::create()->findOneById($currencyId);
         if (null === $currency) {
             throw new \InvalidArgumentException('Cannot found currency id: `' . $currency . '` in product_sale_elements loop');
         }
     } else {
         $currency = $this->request->getSession()->getCurrency();
     }
     $defaultCurrency = CurrencyQuery::create()->findOneByByDefault(1);
     $defaultCurrencySuffix = '_default_currency';
     $priceToCompareAsSQL = '';
     $isPSELeftJoinList = [];
     $isProductPriceFirstLeftJoin = [];
     $search = ProductQuery::create();
     $complex = $this->getComplex();
     if (!$complex) {
         $search->innerJoinProductSaleElements('pse');
         $search->addJoinCondition('pse', '`pse`.IS_DEFAULT=1');
         $search->innerJoinProductSaleElements('pse_count');
         $priceJoin = new Join();
         $priceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'pse', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'price');
         $priceJoin->setJoinType(Criteria::LEFT_JOIN);
         $search->addJoinObject($priceJoin, 'price_join')->addJoinCondition('price_join', '`price`.`currency_id` = ?', $currency->getId(), null, \PDO::PARAM_INT);
         if ($defaultCurrency->getId() != $currency->getId()) {
             $priceJoinDefaultCurrency = new Join();
             $priceJoinDefaultCurrency->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'pse', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'price' . $defaultCurrencySuffix);
             $priceJoinDefaultCurrency->setJoinType(Criteria::LEFT_JOIN);
             $search->addJoinObject($priceJoinDefaultCurrency, 'price_join' . $defaultCurrencySuffix)->addJoinCondition('price_join' . $defaultCurrencySuffix, '`price' . $defaultCurrencySuffix . '`.`currency_id` = ?', $defaultCurrency->getId(), null, \PDO::PARAM_INT);
             /**
              * rate value is checked as a float in overloaded getRate method.
              */
             $priceToCompareAsSQL = 'CASE WHEN ISNULL(`price`.PRICE) OR `price`.FROM_DEFAULT_CURRENCY = 1 THEN
                 CASE WHEN `pse`.PROMO=1 THEN `price' . $defaultCurrencySuffix . '`.PROMO_PRICE ELSE `price' . $defaultCurrencySuffix . '`.PRICE END * ' . $currency->getRate() . '
             ELSE
                 CASE WHEN `pse`.PROMO=1 THEN `price`.PROMO_PRICE ELSE `price`.PRICE END
             END';
             $search->withColumn('ROUND(' . $priceToCompareAsSQL . ', 2)', 'real_price');
             $search->withColumn('CASE WHEN ISNULL(`price`.PRICE) OR `price`.FROM_DEFAULT_CURRENCY = 1 THEN `price' . $defaultCurrencySuffix . '`.PRICE * ' . $currency->getRate() . ' ELSE `price`.PRICE END', 'price');
             $search->withColumn('CASE WHEN ISNULL(`price`.PRICE) OR `price`.FROM_DEFAULT_CURRENCY = 1 THEN `price' . $defaultCurrencySuffix . '`.PROMO_PRICE * ' . $currency->getRate() . ' ELSE `price`.PROMO_PRICE END', 'promo_price');
         } else {
             $priceToCompareAsSQL = 'CASE WHEN `pse`.PROMO=1 THEN `price`.PROMO_PRICE ELSE `price`.PRICE END';
             $search->withColumn('ROUND(' . $priceToCompareAsSQL . ', 2)', 'real_price');
             $search->withColumn('`price`.PRICE', 'price');
             $search->withColumn('`price`.PROMO_PRICE', 'promo_price');
         }
     }
     /* manage translations */
     $this->configureI18nProcessing($search, ['TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM', 'META_TITLE', 'META_DESCRIPTION', 'META_KEYWORDS']);
     $id = $this->getId();
     if (!is_null($id)) {
         $search->filterById($id, Criteria::IN);
     }
     $ref = $this->getRef();
     if (!is_null($ref)) {
         $search->filterByRef($ref, Criteria::IN);
     }
     $title = $this->getTitle();
     if (!is_null($title)) {
         $search->where("CASE WHEN NOT ISNULL(`requested_locale_i18n`.ID) THEN `requested_locale_i18n`.`TITLE` ELSE `default_locale_i18n`.`TITLE` END " . Criteria::LIKE . " ?", "%" . $title . "%", \PDO::PARAM_STR);
     }
     $manualOrderAllowed = false;
     if (null !== ($categoryDefault = $this->getCategoryDefault())) {
         // Select the products which have $categoryDefault as the default category.
         $search->useProductCategoryQuery('DefaultCategorySelect')->filterByDefaultCategory(true)->filterByCategoryId($categoryDefault, Criteria::IN)->endUse();
         // We can only sort by position if we have a single category ID
         $manualOrderAllowed = 1 == count($categoryDefault);
     }
     if (null !== ($categoryIdList = $this->getCategory())) {
         // Select all products which have one of the required categories as the default one, or an associated one
         $depth = $this->getDepth();
         $allCategoryIDs = CategoryQuery::getCategoryTreeIds($categoryIdList, $depth);
         $search->useProductCategoryQuery('CategorySelect')->filterByCategoryId($allCategoryIDs, Criteria::IN)->endUse();
         // We can only sort by position if we have a single category ID, with a depth of 1
         $manualOrderAllowed = 1 == $depth && 1 == count($categoryIdList);
     }
     $current = $this->getCurrent();
     if ($current === true) {
         $search->filterById($this->request->get("product_id"), Criteria::EQUAL);
     } elseif ($current === false) {
         $search->filterById($this->request->get("product_id"), Criteria::NOT_IN);
     }
     $brand_id = $this->getBrand();
     if ($brand_id !== null) {
         $search->filterByBrandId($brand_id, Criteria::IN);
     }
     $sale_id = $this->getSale();
     if ($sale_id !== null) {
         $search->useSaleProductQuery("SaleProductSelect")->filterBySaleId($sale_id)->groupByProductId()->endUse();
     }
     $current_category = $this->getCurrent_category();
     if ($current_category === true) {
         $search->filterByCategory(CategoryQuery::create()->filterByProduct(ProductCategoryQuery::create()->findPk($this->request->get("product_id")), Criteria::IN)->find(), Criteria::IN);
     } elseif ($current_category === false) {
         $search->filterByCategory(CategoryQuery::create()->filterByProduct(ProductCategoryQuery::create()->findPk($this->request->get("product_id")), Criteria::IN)->find(), Criteria::NOT_IN);
     }
     $visible = $this->getVisible();
//.........这里部分代码省略.........
开发者ID:jeremyFreeAgent,项目名称:thelia,代码行数:101,代码来源:Product.php


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