/** * @param \DOMXPath $xpath * @param Product $product */ protected function restoreAttributesFromDOMContent($xpath, Product $product) { $attributeNodes = $xpath->query("//attribute"); $attributes = array(); foreach ($attributeNodes as $attributeNode) { /** @var $attributeNode \DOMElement */ $name = $attributeNode->getAttribute("name"); $type = $attributeNode->getAttribute("type"); $forSearching = $attributeNode->getAttribute("forsearching") == "1"; $forFaceting = $attributeNode->getAttribute("forfaceting") == "1"; $forSorting = $attributeNode->getAttribute("forsorting") == "1"; $attribute = new ProductAttribute(); $attribute->setName($name); $attribute->setType($type); $attribute->setForSearching($forSearching); $attribute->setForFaceting($forFaceting); $attribute->setForSorting($forSorting); $values = $xpath->query("value", $attributeNode); foreach ($values as $value) { /** @var $value \DOMElement */ $attribute->addValue($value->textContent); } $attributes[$attribute->getName()] = $attribute; } $product->__setProperty('attributes', $attributes); }
/** * @param ProductAttribute $attribute */ public function removeAttribute(ProductAttribute $attribute) { return $this->removeAttributeByName($attribute->getName()); }