Example #1
0
 /**
  * @param \Extcode\Cart\Domain\Model\Dto\Product\ProductDemand $demand
  *
  * @return array<\TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface>
  */
 protected function createOrderingsFromDemand($demand)
 {
     $orderings = [];
     $orderList = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $demand->getOrder(), true);
     if (!empty($orderList)) {
         foreach ($orderList as $orderItem) {
             list($orderField, $ascDesc) = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(' ', $orderItem, true);
             if ($ascDesc) {
                 $orderings[$orderField] = strtolower($ascDesc) == 'desc' ? \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING : \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING;
             } else {
                 $orderings[$orderField] = \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING;
             }
         }
     }
     return $orderings;
 }
Example #2
0
 /**
  * @param \Extcode\Cart\Domain\Model\Dto\Product\ProductDemand $demand
  * @param array $settings
  *
  * @return void
  */
 protected function addCategoriesToDemandObjectFromSettings(&$demand, $settings)
 {
     if ($this->settings['categoriesList']) {
         $selectedCategories = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $this->settings['categoriesList'], true);
         $categories = [];
         if ($this->settings['listSubcategories']) {
             foreach ($selectedCategories as $selectedCategory) {
                 $category = $this->categoryRepository->findByUid($selectedCategory);
                 $categories = array_merge($categories, $this->categoryRepository->findSubcategoriesRecursiveAsArray($category));
             }
         } else {
             $categories = $selectedCategories;
         }
         $demand->setCategories($categories);
     }
 }