function process($url, $prod) { echo "<h1>{$url}</h1>"; $exps = explode("/", $url); $id = array_pop($exps); $p = array_pop($exps); $name = str_replace("-", " ", array_pop($exps)); //if($id != '7974')return ""; $lines = file($url); $x = 0; $simpan = 0; foreach ($lines as $num => $line) { //echo $num." . ".htmlspecialchars($line)."<br>"; if (ereg('primary_image', $line) && ereg('div', $line)) { //cari first image $simpan = 1; } if ($simpan) { if (ereg('img', $line) && ereg("medias/", $line) && ereg($name, $line)) { echo "<h3>" . $num . " . " . htmlspecialchars($line) . "</h3>"; $simpan = 0; $exp = explode('"', $line); echo $exp[1]; $url2 = 'http://www.thebodyshop.co.id' . $exp[1]; $img = _PHOTOPATH . '/ecomm/' . $id . '.jpg'; file_put_contents($img, file_get_contents($url2)); $ec = new EComProd(); $ec->prod_id = $id; $ec->prod_name = $name; $ec->prod_pic_url = $exp[1]; $ec->prod_url = $url; $ec->prod_price = $prod->price->formattedValue; $ec->prod_obj = serialize($prod); $ec->save(1); } } #echo htmlspecialchars($line)."<br>"; } //print_r($table); $encoding = 'UTF-8'; //createXML($path,$table,$encoding); //return $table; }
public static function hybriscarousel() { //$mysongs = simplexml_load_file('http://preprod.tbsgroup.co.id:9001/rest/v1/thebodyshop/products'); //pr($mysongs); //$xml_feed_url = 'http://preprod.tbsgroup.co.id:9001/rest/v1/thebodyshop/products'; /*$xml_feed_url = 'http://192.168.0.57:8080/rest/v1/thebodyshop/products'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $xml_feed_url); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $xml = curl_exec($ch); curl_close($ch);*/ $ecom = new EComProd(); $arr = $ecom->getAll(); /*$p = xml_parser_create(); xml_parse_into_struct($p, $xml, $vals, $index); xml_parser_free($p); echo "Index array\n"; print_r($index); echo "\nVals array\n"; print_r($vals);*/ ?> <style> .prod-container { width : 100%; } .prod-item { /* float : left;*/ /* width : 20 %;*/ } .prod-item-dalaman { margin : 5px; padding : 10px; height : 220px; background-color : #ffffff; border-radius : 5px; overflow : hidden; } .prod-code { font-style : italic; font-size : 12px; } .prod-price { font-size : 17px; } .recommended-item-control { position : absolute; top : 41%; } .right { right : 0; } .left { left : 0; } </style> <div class="storeheader"><?php echo Lang::t('eCommerce'); ?> </div> <div class="recommended_items" style="margin-bottom: 10px;"><!--recommended_items--> <div id="recommended-item-carousel" class="carousel slide" data-ride="carousel"> <div class="carousel-inner" style="padding-left: 10px; padding-right: 10px;"> <?php $jml = count($arr) - 1; foreach ($arr as $num => $prod) { if ($num % 6 == 0) { ?> <div class="item <?php if ($num == 0) { ?> active<?php } ?> "> <?php } ?> <div class="prod-item col-md-2 col-xs-6"> <div class="prod-item-dalaman"> <div class="prod-code"> <?php echo $prod->prod_id; ?> </div> <div class="prod-img" style="width: 100%; text-align: center"> <img style="height: 100px;" src="<?php echo _PHOTOURL . 'ecomm/' . $prod->prod_id . '.jpg'; ?> "> </div> <div class="prod-name"> <a target="_blank" href="<?php echo $prod->prod_url; ?> "> <?php echo StorePortalWeb::setMaxChar($prod->prod_name); ?> </a> </div> <div class="prod-price"> <?php echo $prod->prod_price; ?> </div> </div> </div> <?php if ($num % 6 == 5 || $num == $jml) { ?> </div> <?php } } ?> </div> <a class="left recommended-item-control" href="#recommended-item-carousel" data-slide="prev"> <i class="glyphicon glyphicon-chevron-left"></i> </a> <a class="right recommended-item-control" href="#recommended-item-carousel" data-slide="next"> <i class="glyphicon glyphicon-chevron-right"></i> </a> </div> </div> <?php }