Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $id = $doc->createElement("id");
- $id->appendChild(
- $doc->createTextNode($_product->getId())
- );
- $product->appendChild($id);
- $name = $doc->createElement("name");
- $name->appendChild(
- $doc->createTextNode(trim($_product->getName()))
- );
- $product->appendChild($name);
- $description = $doc->createElement("description");
- $str = strip_tags($_product->getDescription());
- //preg_replace('/[^a-zA-Z0-9_ %[].()%&-]/s', '', $str);
- $description->appendChild(
- $doc->createTextNode($str)
- );
- $product->appendChild($description);
- $url = $doc->createElement("url");
- $url->appendChild(
- $doc->createTextNode(trim($_product->getProductUrl()))
- );
- $product->appendChild($url);
- $brand = $doc->createElement("brand");
- $brand->appendChild(
- $doc->createTextNode($_product->getBrand())
- );
- $product->appendChild($brand);
- $price = $doc->createElement("price");
- $price->appendChild(
- $doc->createTextNode(trim((int)$_product->getPrice()))
- );
- $product->appendChild($price);
- $original_price = $doc->createElement("original_price");
- $original_price->appendChild(
- $doc->createTextNode(trim((int)$_product->getOriginalPrice()))
- );
- $product->appendChild($original_price);
- $currency = $doc->createElement("currency");
- $currency->appendChild(
- $doc->createTextNode($_product->getCurrency())
- );
- $product->appendChild($currency);
- $category = $doc->createElement("category");
- $category->appendChild(
- $doc->createTextNode($_product->getCategory())
- );
- $product->appendChild($category);
- $root->appendChild($product);
- }
- file_put_contents($file, $doc->saveXML(), FILE_APPEND);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement