public function process() { $result = array(); $result['all'] = array(); $config = array('hideUnsearchable' => '1', 'parents' => $this->config['parents'], 'resources' => $this->config['resources'], 'includeTVs' => $this->config['parentsIncludeTVs'], 'sortby' => $this->config['parentsSortby'], 'sortdir' => $this->config['parentsSortdir'], 'return' => 'data'); $msCategories = $this->pdoFetch->getCollection($this->classKey, array('class_key' => $this->classKey), $config); $result['all'] = array_map(function ($msCategory) { return array('id' => $msCategory['id'], 'text' => $this->pdoFetch->getChunk($this->config['tplSectionRow'], $msCategory, false)); }, $msCategories); if ($this->pid !== '0') { $categoryMembers = array_map(function ($msMember) { return $msMember['category_id']; }, $this->pdoFetch->getCollection('msCategoryMember', array('product_id' => $this->pid))); $msCategoriesIds = array_map(function ($msCategory) { return $msCategory['id']; }, $msCategories); $result['product'] = array_values(array_filter($categoryMembers, function ($categoryMember) use($msCategoriesIds) { if (in_array($categoryMember, $msCategoriesIds)) { return true; } })); } return $this->success('', $result); }