/** * main action */ public function mainAction() { header('Content-Type: text/xml; charset=UTF-8'); require_once 'models/common/common_node.php'; $Node = new common_node(); require_once 'models/ecommerce/ecommerce_product.php'; $Product = new ecommerce_product(); require_once 'models/ecommerce/ecommerce_product_image.php'; $Image = new ecommerce_product_image(); $products = $Product->getProductList(); //print_r($products);exit; $this->tpl->assign('ITEM_TYPE', 'new'); //new or bazaar $this->tpl->assign('DUES', 0); //poplatky mimo postovneho $this->tpl->assign('DELIVERY_DATE', 1); //doba expedice $this->tpl->assign('TOLLFREE', 0); foreach ($products as $p) { //get product detail URL $current = $Product->findProductInNode($p['id']); $product_node_data = $current[0]; $page_id = $product_node_data['id']; $p['url'] = "http://{$_SERVER['HTTP_HOST']}" . $Node->getSeoURL($page_id); //description $p['description'] = html_entity_decode(strip_tags($p['description']), ENT_QUOTES, 'UTF-8'); //image $images = $Image->listing("role = 'main' AND node_id=" . $p['id'], "priority DESC, id ASC", '0,1'); $this->tpl->assign('IMAGE_PRODUCT', "http://{$_SERVER['HTTP_HOST']}/image/{$images[0]['src']}"); //assign to template $this->tpl->assign('PRODUCT', $p); //variety list if (is_array($p['variety'])) { foreach ($p['variety'] as $v) { //$v['description'] = html_entity_decode(strip_tags($v['description'])); $this->tpl->assign('VARIETY', $v); $this->tpl->assign('PRICE', $v['price']['value']); if ($v['publish'] == 1) { $this->tpl->parse("content.item_product.item_variety"); } } } if ($p['publish'] == 1) { $this->tpl->parse("content.item_product"); } } return true; }
/** * main action */ public function mainAction() { set_time_limit(0); header('Content-Type: text/xml; charset=UTF-8'); require_once 'models/common/common_node.php'; $Node = new common_node(); require_once 'models/ecommerce/ecommerce_product.php'; require_once 'models/ecommerce/ecommerce_product_image.php'; $Product = new ecommerce_product(); $Image = new ecommerce_product_image(); $products = $Product->getProductList(); //print_r($products);exit; if (is_array($products)) { foreach ($products as $p) { if ($p['publish'] == 1) { $nodes = $Product->findProductInNode($p['id']); $link = $Node->getSeoURL($nodes[0]['id']); $p['link'] = "http://{$_SERVER['HTTP_HOST']}{$link}"; $images = $Image->listing("role = 'main' AND node_id=" . $p['id'], "priority DESC, id ASC"); $p['image_src'] = "http://{$_SERVER['HTTP_HOST']}/image/{$images[0]['src']}"; $this->tpl->assign('PRODUCT', $p); if (is_array($p['variety'])) { foreach ($p['variety'] as $k => $v) { //show only first variety if ($k == 0) { $this->tpl->assign('VARIETY', $v); $this->tpl->assign('PRICE', $v['price']); //set availibity, other possible values are 'available for order' and 'preorder' //if ($v['stock'] > 0) $this->tpl->assign('AVAILIBILITY', 'in stock'); //else $this->tpl->assign('AVAILIBILITY', 'out of stock'); $this->tpl->assign('AVAILIBILITY', 'in stock'); //always on stock, because first variety can be out of stock, but other not, we should do a check if any variety is in stock $this->tpl->parse("content.generated.item"); } } } } } } //save it to the file $this->tpl->parse("content.generated"); file_put_contents(ONXSHOP_PROJECT_DIR . "var/files/googlebase.xml", $this->tpl->text("content.generated")); return true; }
/** * parseProductSelect */ function parseProductSelect() { require_once 'models/ecommerce/ecommerce_product.php'; $Product = new ecommerce_product(); $Image = new ecommerce_product_image(); $listing = $Product->listing('', 'name ASC'); foreach ($listing as $item) { if ($item['publish'] == 0) { $item['class'] = 'notpublic'; } $detail = $this->Node->listing("node_group = 'page' AND node_controller ~ 'product' AND content = '{$item['id']}'"); if (count($detail) == 0) { $item['disabled'] = 'disabled'; } $image = $Image->listing("node_id = {$item['id']}", "priority DESC, id ASC"); if (count($image) > 0) { $item['image_src'] = $image[0]['src']; } else { $item['image_src'] = '/var/files/placeholder.png'; } $this->tpl->assign("PRODUCT", $item); $this->tpl->parse("content.product_select_item"); } }
/** * process images */ function processImages($product) { /** * product image conf */ require_once 'models/ecommerce/ecommerce_product_image.php'; $ecommerce_product_image_conf = ecommerce_product_image::initConfiguration(); /** * image width */ if (is_numeric($this->GET['image_width'])) { $image_width = $this->GET['image_width']; } else { $image_width = $GLOBALS['onxshop_conf']['global']['product_detail_image_width']; } $this->tpl->assign("IMAGE_WIDTH", $image_width); //for full product detail (product_radio), use image_gallery if ($template_block == 'product_radio') { switch ($GLOBALS['onxshop_conf']['global']['product_image_gallery']) { case 'simple_list': $image_controller = 'component/image'; break; case 'gallery': $image_controller = 'component/image_gallery'; break; case 'gallery_smooth': default: $image_controller = 'component/image_gallery_smooth'; break; } $image_limit = '0,1'; } else { $image_controller = 'component/image'; $image_limit = '0,1'; } $cycle = array(); $cycle['fx'] = $ecommerce_product_image_conf['cycle_fx']; $cycle['easing'] = $ecommerce_product_image_conf['cycle_easing']; $cycle['timeout'] = $ecommerce_product_image_conf['cycle_timeout']; $cycle['speed'] = $ecommerce_product_image_conf['cycle_speed']; $Image = new Onxshop_Request("{$image_controller}&relation=product&role=main&width={$image_width}&node_id={$product['id']}&limit={$image_limit}&cycle_fx={$cycle['fx']}&cycle_easing={$cycle['easing']}&cycle_timeout={$cycle['timeout']}&cycle_speed={$cycle['speed']}"); $this->tpl->assign('PRODUCT_IMAGE', $Image->getContent()); /** * variety image */ //$Image = new Onxshop_Request("image&relation=product_variety&role=main&node_id={$product['variety'][0]['id']}&limit=0,1"); //$this->tpl->assign('IMAGE_VARIETY', $Image->getContent()); }
/** * getOpenGraphImage */ public function getOpenGraphImage($node_id, $content = false) { if (is_numeric($content)) { $product_id = $content; require_once 'models/ecommerce/ecommerce_product_image.php'; $Image = new ecommerce_product_image(); $image_list = $Image->listFiles($product_id); if (is_array($image_list) && count($image_list) > 0) { return $image_list[0]; } } else { // Option to implement og:image associated to common_node record } return false; }
/** * Find where the file is used * * @param string $file * file src * * @return array * file using places list */ function getRelations($file) { require_once 'models/common/common_file.php'; $CommonFile = new common_file(); $file_list['file'] = $CommonFile->getFileLink($file); require_once 'models/common/common_image.php'; $CommonImage = new common_image(); $file_list['node'] = $CommonImage->getFileLink($file); require_once 'models/ecommerce/ecommerce_product_image.php'; $ProductImage = new ecommerce_product_image(); $file_list['product'] = $ProductImage->getFileLink($file); require_once 'models/ecommerce/ecommerce_product_variety_image.php'; $ProductVarietyImage = new ecommerce_product_variety_image(); $file_list['product_variety'] = $ProductVarietyImage->getFileLink($file); require_once 'models/common/common_taxonomy_label_image.php'; $TaxonomyImage = new common_taxonomy_label_image(); $file_list['taxonomy'] = $TaxonomyImage->getFileLink($file); require_once 'models/ecommerce/ecommerce_recipe_image.php'; $RecipeImage = new ecommerce_recipe_image(); $file_list['recipe'] = $RecipeImage->getFileLink($file); require_once 'models/ecommerce/ecommerce_store_image.php'; $StoreImage = new ecommerce_store_image(); $file_list['store'] = $StoreImage->getFileLink($file); require_once 'models/education/education_survey_image.php'; $SurveyImage = new education_survey_image(); $file_list['survey'] = $SurveyImage->getFileLink($file); $file_list['count'] = count($file_list['file']) + count($file_list['node']) + count($file_list['product']) + count($file_list['product_variety']) + count($file_list['taxonomy']) + count($file_list['recipe']) + count($file_list['store']) + count($file_list['survey']); return $file_list; }