/** * @param \DOMXPath $xpath * @param Product $product */ protected function restoreCategoryPathsFromDOMContent($xpath, Product $product) { $categoryPaths = array(); $categoryPathNodes = $xpath->query("//category_path"); foreach ($categoryPathNodes as $categoryPathNode) { /** @var $node \DOMElement */ $productCategoryPath = new ProductCategoryPath(); $productCategoryPath->setCategoryPath((string) $categoryPathNode->textContent); for ($i = 0; $i < 5; $i++) { if (!isset($categoryPathNode->nextSibling)) { break; } $categoryPathNode = $categoryPathNode->nextSibling; if ($categoryPathNode->nodeName == 'category_id') { $productCategoryPath->setCategoryId((int) $categoryPathNode->textContent); break; } } $categoryPaths[$productCategoryPath->getCategoryId()] = $productCategoryPath; } $product->__setProperty('categoryPaths', $categoryPaths); }
/** * @param ProductCategoryPath $categoryPath */ public function removeCategoryPath(ProductCategoryPath $categoryPath) { return $this->removeCategoryPathById($categoryPath->getCategoryId()); }