/** * Defines the category products links collection * * @param \XLite\Model\Product $product Product * @param array $categories Categories * @param array $categoryIds Category IDs to filter categories * * @return \Doctrine\Common\Collections\ArrayCollection */ protected function getCategoryProducts($product, $categories, $categoryIds) { $links = array(); foreach ($categories as $category) { if (in_array($category->getCategoryId(), $categoryIds)) { $links[] = new \XLite\Model\CategoryProducts(array('category' => $category, 'product' => $product, 'orderby' => $product->getOrderby($category->getCategoryId()))); } } return new \Doctrine\Common\Collections\ArrayCollection($links); }