Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /proc/self/root/var/www/kanvakanva.com/public_html/application/controllers/ |
Upload File : |
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class XML_export_products extends Public_Controller { public function __construct() { parent::__construct(); } public function index() { $q_products = $this->db->get("products")->result(); $this->load->helper('xml'); $dom = xml_dom(); $ele_feed = xml_add_child($dom, 'feed'); xml_add_attribute($ele_feed, 'xmlns', 'http://www.w3.org/2005/Atom'); xml_add_attribute($ele_feed, 'xmlns:g', 'http://base.google.com/ns/1.0'); $ele_title = xml_add_child($ele_feed, 'title', 'Kanva Kanva HOME & LIVING Store'); $ele_link = xml_add_child($ele_feed, 'link', null); xml_add_attribute($ele_link, 'rel', 'self'); xml_add_attribute($ele_link, 'href', 'https://www.kanvakanva.com'); foreach ($q_products as $key) { $q_brands = $this->db->select("alias")->get_where("brands",array("id_brands"=>$key->brand_id))->row(); $q_stocks = $this->db->select("sum(stock) as stock")->get_where("stocks",array("product_id"=>$key->id_products))->row(); $q_categories = $this->db->select("c.category")-> from("category_product cp")->join("categories c","cp.id_category=c.id_categories")->where("cp.id_product",$key->id_products)->get()->row(); $t_stock = "out of stock"; if ($q_stocks->stock > 0 ) { $t_stock = "in stock"; } $price=number_format($key->price)." IDR"; if ($key->discount_price>0) { $price=number_format($key->discount_price)." IDR"; } $ele_item = xml_add_child($ele_feed, 'entry'); xml_add_child($ele_item, 'g:id', $key->alias); xml_add_child($ele_item, 'g:title', $key->title); xml_add_child($ele_item, 'g:description', strip_tags($key->description)); xml_add_child($ele_item, 'g:link', 'https://www.kanvakanva.com/product/'.strtolower($key->alias)); xml_add_child($ele_item, 'g:image_link', 'https://www.kanvakanva.com/uploads/product/'.$key->image1); xml_add_child($ele_item, 'g:brand', ucwords($q_brands->alias)); xml_add_child($ele_item, 'g:condition', 'new'); xml_add_child($ele_item, 'g:availability', $t_stock); xml_add_child($ele_item, 'g:price', $price); // $ele_shipping = xml_add_child($ele_item, 'g:shipping', null); // xml_add_child($ele_shipping, 'g:country', 'UK'); // xml_add_child($ele_shipping, 'g:service', 'Standard'); // xml_add_child($ele_shipping, 'g:price', '4.95 GBP'); xml_add_child($ele_item, 'g:google_product_category', ucwords($q_categories->category)); // $ele_applink = xml_add_child($ele_item, 'applink', null); // xml_add_attribute($ele_applink, 'property', 'ios_url'); // xml_add_attribute($ele_applink, 'content', 'example-ios://electronic'); } // xml_print($dom,false); // xml_print($dom,true); // echo $dom->saveXML(); $dom->formatOutput = true; $rs_xml = $dom->saveXML(); // $this->load->helper('download'); // force_download('test1.xml', $rs_xml); $this->load->helper('file'); write_file('./uploads/xml/product-data.xml', $rs_xml); echo "<h2>SYNC SUCCESS. YOU CAN CLOSE THIS WINDOW</h2>"; } }