Пример #1
0
 /**
  * Assign calculated field
  *
  * @param \XLite\Model\QueryBuilder\AQueryBuilder $queryBuilder Query builder
  * @param string                                  $name         Field name
  *
  * @return \XLite\Model\QueryBuilder\AQueryBuilder
  */
 protected function assignCalculatedField(\XLite\Model\QueryBuilder\AQueryBuilder $queryBuilder, $name)
 {
     $uname = ucfirst($name);
     $method = 'defineCalculated' . $uname . 'DQL';
     if (method_exists($this, $method) && null === $queryBuilder->getDataCell(static::CALCULATED_FIELD_FLAG . $name)) {
         $value = $this->{$method}($queryBuilder, $queryBuilder->getRootAlias());
         $queryBuilder->addSelect($value . ' calculated' . $uname);
         $queryBuilder->setDataStorage(static::CALCULATED_FIELD_FLAG . $name, $value);
     }
     return $queryBuilder;
 }
Пример #2
0
 /**
  * Assign calculated field
  *
  * @param \XLite\Model\QueryBuilder\AQueryBuilder $queryBuilder Query builder
  * @param string                                  $name         Field name
  *
  * @return \XLite\Model\QueryBuilder\AQueryBuilder
  */
 protected function assignCalculatedField(\XLite\Model\QueryBuilder\AQueryBuilder $queryBuilder, $name)
 {
     $uname = ucfirst($name);
     $method = 'defineCalculated' . $uname . 'DQL';
     if (method_exists($this, $method) && !$queryBuilder->getFlag('calculated.' . $name)) {
         $alias = $alias ?: $queryBuilder->getRootAlias();
         $queryBuilder->addSelect($this->{$method}($queryBuilder, $alias) . ' calculated' . $uname);
         $queryBuilder->setFlag('calculated.' . $name, true);
     }
     return $queryBuilder;
 }
Пример #3
0
 /**
  * Define calculated price definition DQL
  *
  * @param \XLite\Model\QueryBuilder\AQueryBuilder $queryBuilder Query builder
  * @param string                                  $alias        Main alias
  *
  * @return string
  */
 protected function defineCalculatedPriceDQL(\XLite\Model\QueryBuilder\AQueryBuilder $queryBuilder, $alias)
 {
     $profile = \XLite\Core\Auth::getInstance()->getProfile();
     if ($profile && $profile->getMembership()) {
         $queryBuilder->innerJoin($alias . '.quickData', 'qd', 'WITH', 'qd.membership = :qdMembership')->setParameter('qdMembership', $profile->getMembership());
     } else {
         $queryBuilder->innerJoin($alias . '.quickData', 'qd', 'WITH', 'qd.membership is null');
     }
     return 'qd.price';
 }
Пример #4
0
 /**
  * getResult
  *
  * @return mixed
  */
 public function getResult()
 {
     $this->hasJoinedInventory = false;
     return parent::getResult();
 }
Пример #5
0
 /**
  * Prepare attribute search condition
  *
  * @param \XLite\Model\QueryBuilder\AQueryBuilder $queryBuilder Query builder to prepare
  * @param array                                   $value        Condition data
  *
  * @return void
  */
 protected function prepareCndAttribute(\XLite\Model\QueryBuilder\AQueryBuilder $queryBuilder, $value)
 {
     if (is_array($value) && !empty($value)) {
         $classes = array();
         $attributes = \XLite\Core\Database::getRepo('XLite\\Model\\Attribute')->findByIds(array_keys($value));
         if ($attributes) {
             foreach ($attributes as $attribute) {
                 if (isset($value[$attribute->getId()])) {
                     $queryBuilder->assignAttributeCondition($attribute, $value[$attribute->getId()]);
                 }
             }
         }
     }
 }