示例#1
0
 /**
  * Return products list
  *
  * @param \XLite\Core\CommonCell $cnd       Search condition
  * @param boolean                $countOnly Return items list or only its size OPTIONAL
  *
  * @return mixed
  */
 protected function getData(\XLite\Core\CommonCell $cnd, $countOnly = false)
 {
     if (!isset($this->products)) {
         $productIds = $this->getExcludedProductIds();
         $methods = \XLite\Module\XC\Add2CartPopup\Core\Add2CartPopup::getInstance()->getActiveSources();
         foreach ($methods as $method) {
             $products = \XLite\Module\XC\Add2CartPopup\Core\Add2CartPopup::getInstance()->{$method}($this->getProductId(), $productIds, static::PARAM_MAX_PRODUCT_COUNT);
             if ($products) {
                 foreach ($products as $product) {
                     $this->products[] = $product;
                     $productIds[] = $product->getProductId();
                     if (static::PARAM_MAX_PRODUCT_COUNT <= count($this->products)) {
                         break;
                     }
                 }
             }
             if (static::PARAM_MAX_PRODUCT_COUNT <= count($this->products)) {
                 break;
             }
         }
     }
     return $countOnly ? count($this->products) : $this->products;
 }
示例#2
0
 /**
  * Return true if products list shoud be displayed in popup
  *
  * @return boolean
  */
 protected function isProductsListEnabled()
 {
     $options = \XLite\Module\XC\Add2CartPopup\Core\Add2CartPopup::getInstance()->getSelectedSourcesOption();
     return !empty($options);
 }
示例#3
0
 /**
  * Return options list
  *
  * @param \XLite\Core\CommonCell $cnd       Search condition
  * @param boolean                $countOnly Return items list or only its size OPTIONAL
  *
  * @return array|integer
  */
 protected function getData(\XLite\Core\CommonCell $cnd, $countOnly = false)
 {
     $options = \XLite\Module\XC\Add2CartPopup\Core\Add2CartPopup::getInstance()->getSourcesOptions();
     return $countOnly ? count($options) : $options;
 }