public function getOptions($includeInheritedOptions = false) { $parent = $this->getParent(); ClassLoader::import('application.model.product.ProductOption'); $f = new ARSelectFilter(); $f->setOrder(new ARFieldHandle('ProductOption', 'position'), 'ASC'); $options = $parent->getRelatedRecordSet('ProductOption', $f, array('DefaultChoice' => 'ProductOptionChoice')); if ($includeInheritedOptions) { $options->merge($parent->getCategory()->getOptions(true)); foreach ($parent->getAdditionalCategories() as $cat) { // do not include options with repeating names from secondary categories foreach ($cat->getOptions(true) as $option) { $name = $option->getValueByLang('name'); $nameExists = false; foreach ($options as $opt) { if ($opt->getValueByLang('name') == $name) { $nameExists = true; break; } } if (!$nameExists) { $options->add($option); } } //$options->merge($cat->getOptions(true)); } ProductOption::loadChoicesForRecordSet($options); foreach ($options as $mainIndex => $mainOption) { for ($k = $mainIndex + 1; $k <= $options->size(); $k++) { if ($options->get($k) && $mainOption->getID() == $options->get($k)->getID()) { $options->remove($k); } } } } return $options; }