本文整理汇总了PHP中Thelia\Model\CategoryQuery::findAllChild方法的典型用法代码示例。如果您正苦于以下问题:PHP CategoryQuery::findAllChild方法的具体用法?PHP CategoryQuery::findAllChild怎么用?PHP CategoryQuery::findAllChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thelia\Model\CategoryQuery
的用法示例。
在下文中一共展示了CategoryQuery::findAllChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postDelete
/**
* {@inheritDoc}
*/
public function postDelete(ConnectionInterface $con = null)
{
$this->markRewrittenUrlObsolete();
//delete all subcategories
$subCategories = CategoryQuery::findAllChild($this->getId());
foreach ($subCategories as $category) {
if (!is_null($this->dispatcher)) {
$category->setDispatcher($this->getDispatcher());
}
$category->delete();
}
$this->dispatchEvent(TheliaEvents::AFTER_DELETECATEGORY, new CategoryEvent($this));
}
示例2: buildModelCriteria
public function buildModelCriteria()
{
Tlog::getInstance()->addInfo("-- 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, array('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);
}
$categoryIds = null;
$category = $this->getCategory();
$categoryDefault = $this->getCategoryDefault();
if (!is_null($category) || !is_null($categoryDefault)) {
$categoryIds = array();
if (!is_array($category)) {
$category = array();
}
if (!is_array($categoryDefault)) {
$categoryDefault = array();
}
$categoryIds = array_merge($categoryIds, $category, $categoryDefault);
$categories = CategoryQuery::create()->filterById($categoryIds, Criteria::IN)->find();
$depth = $this->getDepth();
if (null !== $depth) {
foreach (CategoryQuery::findAllChild($category, $depth) as $subCategory) {
$categories->prepend($subCategory);
}
}
$search->filterByCategory($categories, Criteria::IN);
}
$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();
//.........这里部分代码省略.........