/** * Get product options * * @param FixtureInterface $product * @return array * @throws \Exception */ public function getOptions(FixtureInterface $product) { if ($product instanceof InjectableFixture) { /** @var CatalogProductBundle $product */ $bundleSelections = $product->getBundleSelections(); $bundleOptions = isset($bundleSelections['bundle_options']) ? $bundleSelections['bundle_options'] : []; } else { // TODO: Removed after refactoring(removed) old product fixture. /** @var BundleDataFixture $product */ $bundleOptions = $product->getBundleOptions(); } $listFormOptions = $this->getListOptions(); $formOptions = []; foreach ($bundleOptions as $option) { $title = $option['title']; if (!isset($listFormOptions[$title])) { throw new \Exception("Can't find option: \"{$title}\""); } /** @var Element $optionElement */ $optionElement = $listFormOptions[$title]; $getTypeData = 'get' . $this->optionNameConvert($option['type']) . 'Data'; $optionData = $this->{$getTypeData}($optionElement); $optionData['title'] = $title; $optionData['type'] = $option['type']; $optionData['is_require'] = $optionElement->find($this->required, Locator::SELECTOR_XPATH)->isVisible() ? 'Yes' : 'No'; $formOptions[] = $optionData; } return $formOptions; }