dimensionFactory = $dimensionFactory; $this->collectionFactory = $collectionFactory; } /** * @inheritdoc */ public function getIterator(): \Traversable { foreach ($this->getCustomerGroups() as $customerGroup) { yield $this->dimensionFactory->create(self::DIMENSION_NAME, (string)$customerGroup); } } /** * Get Customer Groups * * @return array */ private function getCustomerGroups(): array { if ($this->customerGroupsDataIterator === null) { $customerGroups = $this->collectionFactory->create()->getAllIds(); $this->customerGroupsDataIterator = is_array($customerGroups) ? $customerGroups : []; } return $this->customerGroupsDataIterator; } }