private function _updateCategories(Product &$product, $param) { //update categories if (isset($param->CallbackParameter->categoryIds) && count($categoryIds = $param->CallbackParameter->categoryIds) > 0) { Product_Category::deleteByCriteria('productId = ?', array(trim($product->getId()))); foreach ($categoryIds as $categoryId) { if (!($category = ProductCategory::get($categoryId))) { continue; } Product_Category::create($product, $category); } } return $this; }
/** * adding the category to this product * * @param ProductCategory $category * * @return Product */ public function addCategory(ProductCategory $category) { Product_Category::create($this, $category); return $this; }