Beispiel #1
0
 /**
  * Prepares websites list with groups and stores as array
  *
  * @return array
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function getWebsitesList()
 {
     if (!empty($this->websitesList)) {
         return $this->websitesList;
     }
     $this->websitesList = [];
     $groupList = $this->groupRepository->getList();
     $storesList = $this->storeRepository->getList();
     foreach ($this->websiteRepository->getList() as $website) {
         $websiteId = $website->getId();
         if (!$websiteId) {
             continue;
         }
         $websiteRow = ['id' => $websiteId, 'name' => $website->getName(), 'storesCount' => 0, 'groups' => []];
         foreach ($groupList as $group) {
             $groupId = $group->getId();
             if (!$groupId || $group->getWebsiteId() != $websiteId) {
                 continue;
             }
             $groupRow = ['id' => $groupId, 'name' => $group->getName(), 'stores' => []];
             foreach ($storesList as $store) {
                 $storeId = $store->getId();
                 if (!$storeId || $store->getStoreGroupId() != $groupId) {
                     continue;
                 }
                 $websiteRow['storesCount']++;
                 $groupRow['stores'][] = ['id' => $storeId, 'name' => $store->getName()];
             }
             $websiteRow['groups'][] = $groupRow;
         }
         $this->websitesList[] = $websiteRow;
     }
     return $this->websitesList;
 }
 /**
  * {@inheritdoc}
  */
 public function getGroups($withDefault = false)
 {
     $groups = $this->groupRepository->getList();
     return $withDefault ? $groups : array_filter($groups, function ($item) {
         return $item->getId() != 0;
     });
 }