Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. $id = $doc->createElement("id");
  2. $id->appendChild(
  3. $doc->createTextNode($_product->getId())
  4. );
  5. $product->appendChild($id);
  6.  
  7. $name = $doc->createElement("name");
  8. $name->appendChild(
  9. $doc->createTextNode(trim($_product->getName()))
  10. );
  11. $product->appendChild($name);
  12.  
  13. $description = $doc->createElement("description");
  14. $str = strip_tags($_product->getDescription());
  15. //preg_replace('/[^a-zA-Z0-9_ %[].()%&-]/s', '', $str);
  16. $description->appendChild(
  17. $doc->createTextNode($str)
  18. );
  19. $product->appendChild($description);
  20.  
  21. $url = $doc->createElement("url");
  22. $url->appendChild(
  23. $doc->createTextNode(trim($_product->getProductUrl()))
  24. );
  25. $product->appendChild($url);
  26.  
  27. $brand = $doc->createElement("brand");
  28. $brand->appendChild(
  29. $doc->createTextNode($_product->getBrand())
  30. );
  31. $product->appendChild($brand);
  32.  
  33.  
  34. $price = $doc->createElement("price");
  35. $price->appendChild(
  36. $doc->createTextNode(trim((int)$_product->getPrice()))
  37. );
  38. $product->appendChild($price);
  39.  
  40. $original_price = $doc->createElement("original_price");
  41. $original_price->appendChild(
  42. $doc->createTextNode(trim((int)$_product->getOriginalPrice()))
  43. );
  44. $product->appendChild($original_price);
  45.  
  46. $currency = $doc->createElement("currency");
  47. $currency->appendChild(
  48. $doc->createTextNode($_product->getCurrency())
  49. );
  50. $product->appendChild($currency);
  51.  
  52. $category = $doc->createElement("category");
  53. $category->appendChild(
  54. $doc->createTextNode($_product->getCategory())
  55. );
  56. $product->appendChild($category);
  57.  
  58.  
  59.  
  60.  
  61. $root->appendChild($product);
  62.  
  63. }
  64. file_put_contents($file, $doc->saveXML(), FILE_APPEND);
  65. }
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement