コード例 #1
0
ファイル: Add2CartPopup.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Get products list
  *
  * @param integer $productId  Current product ID
  * @param array   $productIds Product ID which must be excluded from the search result
  * @param integer $maxCount   Maximum number of products
  *
  * @return array
  */
 public function getSourceRelatedProducts($productId, $productIds, $maxCount)
 {
     $result = array();
     $cnd = new \XLite\Core\CommonCell();
     if ($productIds) {
         $cnd->{\XLite\Module\XC\Upselling\Model\Repo\UpsellingProduct::SEARCH_EXCL_PRODUCT_ID} = $productIds;
     }
     $cnd->{\XLite\Module\XC\Upselling\Model\Repo\UpsellingProduct::SEARCH_PARENT_PRODUCT_ID} = $productId;
     $cnd->{\XLite\Module\XC\Upselling\Model\Repo\UpsellingProduct::SEARCH_DATE} = \XLite\Core\Converter::getDayEnd(\XLite\Base\SuperClass::getUserTime());
     $cnd->{\XLite\Module\XC\Upselling\Model\Repo\UpsellingProduct::SEARCH_LIMIT} = array(0, $maxCount + 1);
     $products = \XLite\Core\Database::getRepo('XLite\\Module\\XC\\Upselling\\Model\\UpsellingProduct')->search($cnd, false);
     foreach ($products as $product) {
         $result[] = $product->getProduct();
     }
     return $result;
 }
コード例 #2
0
ファイル: Product.php プロジェクト: kewaunited/xcart
 /**
  * Adds additional condition to the query for checking if product is up-to-date
  *
  * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder object
  * @param string                     $alias        Entity alias OPTIONAL
  *
  * @return void
  */
 protected function addDateCondition(\Doctrine\ORM\QueryBuilder $queryBuilder, $alias = null)
 {
     if (!\XLite::isAdminZone()) {
         $alias = $alias ?: $queryBuilder->getRootAlias();
         $queryBuilder->andWhere($alias . '.arrivalDate < :now')->setParameter('now', \XLite\Core\Converter::getDayEnd(\XLite\Base\SuperClass::getUserTime()));
     }
 }
コード例 #3
0
ファイル: Product.php プロジェクト: kewaunited/xcart
 /**
  * Prepare certain search condition
  *
  * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare
  * @param string                     $value        Condition data
  *
  * @return void
  */
 protected function prepareCndInStock(\Doctrine\ORM\QueryBuilder $queryBuilder, $value)
 {
     if ($value) {
         $queryBuilder->innerJoinInventory()->andWhere('i.amount > :zero OR i.enabled = 0')->setParameter('zero', 0)->andWhere('p.arrivalDate < :now')->setParameter('now', \XLite\Core\Converter::getDayEnd(\XLite\Base\SuperClass::getUserTime()));
     }
 }
コード例 #4
0
ファイル: Profile.php プロジェクト: kirkbauer2/kirkxc
 /**
  * getDateRange
  *
  * :FIXME: simplify
  *
  * @return \XLite\Core\CommonCell
  */
 protected function getDateRange()
 {
     $result = null;
     $paramDatePeriod = self::SEARCH_DATE_PERIOD;
     if (isset($this->currentSearchCnd->{$paramDatePeriod})) {
         $datePeriod = $this->currentSearchCnd->{$paramDatePeriod};
         $startDate = null;
         $endDate = \XLite\Core\Converter::time();
         if ('M' === $datePeriod) {
             $startDate = mktime(0, 0, 0, date('n', $endDate), 1, date('Y', $endDate));
         } elseif ('W' === $datePeriod) {
             $startDate = \XLite\Core\Converter::getDayStart($endDate - date('w', $endDate) * 86400);
         } elseif ('D' === $datePeriod) {
             $startDate = \XLite\Core\Converter::getDayStart($endDate);
         } elseif ('C' === $datePeriod) {
             $paramStartDate = static::SEARCH_START_DATE;
             $paramEndDate = static::SEARCH_END_DATE;
             $paramDateRange = static::SEARCH_DATE_RANGE;
             if (!empty($this->currentSearchCnd->{$paramStartDate}) && !empty($this->currentSearchCnd->{$paramEndDate})) {
                 $tmpDate = strtotime($this->currentSearchCnd->{$paramStartDate});
                 if (false !== $tmpDate) {
                     $startDate = \XLite\Core\Converter::getDayStart($tmpDate);
                 }
                 $tmpDate = strtotime($this->currentSearchCnd->{$paramEndDate});
                 if (false !== $tmpDate) {
                     $endDate = \XLite\Core\Converter::getDayEnd($tmpDate);
                 }
             } elseif (!empty($this->currentSearchCnd->{$paramDateRange})) {
                 list($startDate, $endDate) = \XLite\View\FormField\Input\Text\DateRange::convertToArray($this->currentSearchCnd->{$paramDateRange});
             }
         }
         if (null !== $startDate && false !== $startDate && false !== $endDate) {
             $result = new \XLite\Core\CommonCell();
             $result->startDate = $startDate;
             $result->endDate = $endDate;
         }
     }
     return $result;
 }
コード例 #5
0
ファイル: AComingSoon.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Return params list to use for search
  *
  * @param \XLite\Core\CommonCell $cnd Initial search conditions
  *
  * @return \XLite\Core\CommonCell
  */
 protected function getSearchConditions(\XLite\Core\CommonCell $cnd)
 {
     $currentDate = \XLite\Core\Converter::getDayEnd(\XLite\Base\SuperClass::getUserTime());
     $cnd->{\XLite\Module\CDev\ProductAdvisor\Model\Repo\Product::P_ARRIVAL_DATE} = array($currentDate, null);
     $cnd->{\XLite\Model\Repo\Product::P_ORDER_BY} = array('p.arrivalDate', 'ASC');
     return $cnd;
 }
コード例 #6
0
ファイル: ANewArrivals.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Return params list to use for search
  *
  * @param \XLite\Core\CommonCell $cnd Initial search conditions
  *
  * @return \XLite\Core\CommonCell
  */
 protected function getSearchConditions(\XLite\Core\CommonCell $cnd)
 {
     $currentDate = static::getUserTime();
     $daysOffset = abs(intval(\XLite\Core\Config::getInstance()->CDev->ProductAdvisor->na_max_days)) ?: \XLite\Module\CDev\ProductAdvisor\Main::PA_MODULE_OPTION_DEFAULT_DAYS_OFFSET;
     $startDate = \XLite\Core\Converter::getDayStart($currentDate - $daysOffset * 24 * 60 * 60);
     $endDate = \XLite\Core\Converter::getDayEnd($currentDate);
     $cnd->{\XLite\Module\CDev\ProductAdvisor\Model\Repo\Product::P_ARRIVAL_DATE} = array($startDate, $endDate);
     $cnd->{\XLite\Model\Repo\Product::P_ORDER_BY} = array('p.arrivalDate', 'DESC');
     return $cnd;
 }