コード例 #1
0
ファイル: post_rebuild.php プロジェクト: kirkbauer2/kirkxc
/**
 * X-Cart
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the software license agreement
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.x-cart.com/license-agreement.html
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to licensing@x-cart.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not modify this file if you wish to upgrade X-Cart to newer versions
 * in the future. If you wish to customize X-Cart for your needs please
 * refer to http://www.x-cart.com/ for more information.
 *
 * @category  X-Cart 5
 * @author    Qualiteam software Ltd <*****@*****.**>
 * @copyright Copyright (c) 2011-2015 Qualiteam software Ltd <*****@*****.**>. All rights reserved
 * @license   http://www.x-cart.com/license-agreement.html X-Cart 5 License Agreement
 * @link      http://www.x-cart.com/
 */
function getProductsQuery($i, $batchSize)
{
    $repo = \XLite\Core\Database::getRepo('XLite\\Model\\Product');
    $andCnd = new \Doctrine\ORM\Query\Expr\Andx();
    $andCnd->add('p.pinCodesEnabled = :true');
    $andCnd->add('p.autoPinCodes = :false');
    return $repo->createQueryBuilder()->innerJoinInventory()->andWhere($andCnd)->setParameter('true', true)->setParameter('false', false)->setFirstResult($i * $batchSize)->setMaxResults($batchSize)->getQuery();
}
コード例 #2
0
ファイル: Product.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Prepare certain search condition
  *
  * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare
  * @param array                      $value        Condition data
  * @param boolean                    $countOnly    Count only flag
  *
  * @return void
  */
 protected function prepareCndParticipateSale(\Doctrine\ORM\QueryBuilder $queryBuilder, $value, $countOnly)
 {
     $cnd = new \Doctrine\ORM\Query\Expr\Orx();
     $pricePercentCnd = new \Doctrine\ORM\Query\Expr\Andx();
     $pricePercentCnd->add('p.discountType = :discountTypePercent');
     $pricePercentCnd->add('p.salePriceValue > 0');
     $priceAbsoluteCnd = new \Doctrine\ORM\Query\Expr\Andx();
     $priceAbsoluteCnd->add('p.discountType = :discountTypePrice');
     $priceAbsoluteCnd->add('p.price > p.salePriceValue');
     $cnd->add($pricePercentCnd);
     $cnd->add($priceAbsoluteCnd);
     if (!$countOnly) {
         $queryBuilder->addSelect('if(p.discountType = :discountTypePercent, p.salePriceValue, 100 - 100 * p.salePriceValue / p.price) ' . static::PERCENT_CALCULATED_FIELD);
     }
     $queryBuilder->andWhere('p.participateSale = :participateSale')->andWhere($cnd)->setParameter('participateSale', $value)->setParameter('discountTypePercent', \XLite\Module\CDev\Sale\Model\Product::SALE_DISCOUNT_TYPE_PERCENT)->setParameter('discountTypePrice', \XLite\Module\CDev\Sale\Model\Product::SALE_DISCOUNT_TYPE_PRICE);
 }
コード例 #3
0
 public function buildQuery(QueryConfigInterface $query, TableInterface $table)
 {
     parent::buildQuery($query, $table);
     $_query = $table->getOption('_query');
     $params = $table->getOption('rows_params');
     if ($table->getOption('allow_select')) {
         if (!isset($_query['selectedRows'])) {
             throw new \InvalidArgumentException('selectedRows is required');
         }
         if (count($_query['selectedRows']) === 0) {
             $query->setValid(false);
             return;
         }
         if (count($params) === 1) {
             $name = key($params);
             $param = reset($params);
             $selectedRowIds = array();
             foreach ($_query['selectedRows'] as $row) {
                 if (!isset($row[$name])) {
                     throw new \UnexpectedValueException('Parameter "' . $name . '" not found.');
                 }
                 $selectedRowIds[] = $row[$name];
             }
             $orX = new \Doctrine\ORM\Query\Expr\Orx();
             $orX->add($param . ' in (:selectedRowIds)');
             $query->setConstraints($orX)->addParameter('selectedRowIds', $selectedRowIds);
         } else {
             $reversedParams = array_flip($params);
             if (count($params) !== count($reversedParams)) {
                 throw new \RuntimeException('rows_params values must be unique');
             }
             $query->setParameters(array());
             $orX = new \Doctrine\ORM\Query\Expr\Orx();
             $selectedRows = array_values($_query['selectedRows']);
             foreach ($selectedRows as $i => $row) {
                 $row = $this->type->resolveParams($reversedParams, $row);
                 $andX = new \Doctrine\ORM\Query\Expr\Andx();
                 foreach ($row as $param => $value) {
                     $andX->add($param . ' = :' . $reversedParams[$param] . $i);
                     $query->addParameter($reversedParams[$param] . $i, $value);
                 }
                 $orX->add($andX);
             }
             $query->setConstraints($orX);
         }
     }
 }
コード例 #4
0
ファイル: OrderAbstract.php プロジェクト: kewaunited/xcart
 /**
  * Prepare certain search condition
  *
  * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare
  * @param integer                    $value        Condition data
  *
  * @return void
  */
 protected function prepareCndAccessLevel(\Doctrine\ORM\QueryBuilder $queryBuilder, $value)
 {
     if (!empty($value)) {
         switch ($value) {
             case \XLite\View\FormField\Select\Order\CustomerAccessLevel::ACCESS_LEVEL_ANONYMOUS:
                 $anonymous = 1;
                 break;
             case \XLite\View\FormField\Select\Order\CustomerAccessLevel::ACCESS_LEVEL_REGISTERED:
                 $anonymous = 0;
                 break;
             default:
                 $anonymous = '';
                 break;
         }
         if ('' !== $anonymous) {
             $cnd = new \Doctrine\ORM\Query\Expr\Orx();
             $anonymousCnd = new \Doctrine\ORM\Query\Expr\Andx();
             $anonymousCnd->add('op.profile_id IS NULL');
             $anonymousCnd->add('p.anonymous = :accessLevel');
             $cnd->add('op.anonymous = :accessLevel');
             $cnd->add($anonymousCnd);
             $queryBuilder->andWhere($cnd)->setParameter('accessLevel', $anonymous);
         }
     }
 }
コード例 #5
0
ファイル: Product.php プロジェクト: kewaunited/xcart
 /**
  * Prepare certain search condition (ALL WORDS method)
  *
  * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare
  * @param string                     $value        Condition data
  *
  * @return \Doctrine\ORM\Query\Expr\Base Condition class
  */
 protected function getCndSubstringAll(\Doctrine\ORM\QueryBuilder $queryBuilder, $value)
 {
     $searchWords = $this->getSearchWords($value);
     $cnd = new \Doctrine\ORM\Query\Expr\Orx();
     foreach ($this->getSubstringSearchFields() as $field) {
         $fieldCnd = new \Doctrine\ORM\Query\Expr\Andx();
         foreach ($searchWords as $index => $word) {
             // Collect AND expressions for one field
             $fieldCnd->add($field . ' LIKE :word' . $index);
             $queryBuilder->setParameter('word' . $index, '%' . $word . '%');
         }
         // Add AND expression into OR main expression
         // (
         //    ((field1 LIKE word1) AND (field1 LIKE word2))
         //        OR
         //    ((field2 LIKE word1) AND (field2 LIKE word2))
         // )
         $cnd->add($fieldCnd);
     }
     return $cnd;
 }
コード例 #6
0
ファイル: LanguageLabel.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Prepare certain search condition
  *
  * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare
  * @param \XLite\Model\Profile       $value        Profile
  *
  * @return void
  */
 protected function prepareCndSubstring(\Doctrine\ORM\QueryBuilder $queryBuilder, $value)
 {
     if (!empty($value)) {
         $queryBuilder->leftJoin('l.translations', 'lt');
         $or = new \Doctrine\ORM\Query\Expr\Orx();
         // Use non-standard Doctrine function CAST(expr AS CHAR)
         $or->add('CastChar(l.name) LIKE :substring');
         $and = new \Doctrine\ORM\Query\Expr\Andx();
         $and->add('lt.label LIKE :substring');
         $and->add($queryBuilder->expr()->in('lt.code', $this->searchCodes));
         $or->add($and);
         $queryBuilder->andWhere($or)->setParameter('substring', '%' . $value . '%');
     }
 }
コード例 #7
0
 /**
  * Check if a Snippet is disabled
  * Internal use only
  *
  * @param Doctrine\ORM\QueryBuilder $queryBuilder
  * @param mixed $result
  * @param string $show
  */
 protected function checkIfSnippetIsDisabled($queryBuilder, $result, $show)
 {
     if ($show == 'enabled' && is_null($result)) {
         $expr = $queryBuilder->getDQLPart('where')->getParts();
         $newExpr = new \Doctrine\ORM\Query\Expr\Andx();
         $newExpr->addMultiple(preg_grep("/\\bsnippet.enabled\\b/i", $expr, PREG_GREP_INVERT));
         $queryBuilder->resetDQLPart('where');
         $queryBuilder->add('where', $newExpr);
         if (!is_null($queryBuilder->getQuery()->getOneOrNullResult())) {
             throw new \Exception('Result was found but disabled.');
         }
     }
     return $result;
 }