/** * formatItem */ public function formatItem($original_item) { if (!is_array($original_item)) { return false; } $original_item['price_formatted'] = $this->formatPrice($original_item['price'], $original_item['currency_code']); require_once 'models/ecommerce/ecommerce_product.php'; $Product = new ecommerce_product(); $product_detail = $Product->getProductDetail($original_item['product_id']); if ($_SERVER['SSL_PROTOCOL'] || $_SERVER['HTTPS']) { $protocol = 'https'; } else { $protocol = 'http'; } $item['id'] = $original_item['offer_id']; $item['title'] = $product_detail['name']; $item['content'] = strip_tags($product_detail['description']); $item['url'] = "{$protocol}://{$_SERVER['HTTP_HOST']}/product/{$original_item['product_id']}"; $item['priority'] = $product_detail['priority']; $item['created'] = $product_detail['modified']; $item['modified'] = $product_detail['modified']; $item['images'] = array("{$protocol}://{$_SERVER['HTTP_HOST']}/image/" . $Product->getProductMainImageSrc($original_item['product_id'])); $item['thumbnails'] = array("{$protocol}://{$_SERVER['HTTP_HOST']}/thumbnail/" . self::$thumbnail_size . '/' . $Product->getProductMainImageSrc($original_item['product_id'])); $item['rondel'] = $this->getRoundelText($original_item); $item['rondel_image_url'] = $this->getRoundelImageSource($original_item); $item['price'] = money_format('%n', $original_item['price']); $item['start_date'] = $original_item['group_schedule_start']; $item['expiry_date'] = $original_item['group_schedule_end']; $item['categories'] = $Product->getRelatedTaxonomy($original_item['product_id']); $item['product_id'] = $product_detail['variety'][0]['sku']; //TODO this is showing only first ones //special offer group $item['group_id'] = $original_item['group_id']; $item['group_title'] = $original_item['group_title']; return $item; }
/** * main action */ public function mainAction() { /** * initialize */ require_once 'models/ecommerce/ecommerce_product.php'; require_once 'models/common/common_node.php'; $Node = new common_node(); $Product = new ecommerce_product(); /** * get node detail */ $node_data = $Node->nodeDetail($this->GET['id']); $product_id = $node_data['content']; /** * Check if this is a product homepage */ $product_node_homepage = $Node->getProductNodeHomepage($product_id); if ($node_data['id'] != $product_node_homepage['id']) { //forward to homepage $link = $Node->getSeoURL($product_node_homepage['id']); header("HTTP/1.1 301 Moved Permanently"); header("Location: http://{$_SERVER['SERVER_NAME']}{$link}"); exit; } /** * get simple product detail (just for basic product attributes) */ $simple_product_detail = $Product->detail($product_id); /** * get taxonomy_class */ $related_taxonomy = $Product->getRelatedTaxonomy($product_id); $simple_product_detail['taxonomy_class'] = $this->createTaxonomyClass($related_taxonomy); /** * save product taxonomy_class to registry */ $this->saveBodyCssClass($simple_product_detail['taxonomy_class']); /** * assign simple product data to template */ $this->tpl->assign("PRODUCT", $simple_product_detail); /** * varieties */ //$Variety_list = new Onxshop_Request("component/ecommerce/variety_list_ajax~product_id={$product_id}~"); //$this->tpl->assign('VARIETY_LIST', $Variety_list->getContent()); /** * taxonomy */ $_Onxshop_Request = new Onxshop_Request("component/taxonomy~relation=product:id={$product_id}:hide_root=1~"); $this->tpl->assign('TAXONOMY', $_Onxshop_Request->getContent()); /** * other product attributes */ $_Onxshop_Request = new Onxshop_Request("component/ecommerce/product_other_data~id={$product_id}~"); $this->tpl->assign('OTHER_DATA', $_Onxshop_Request->getContent()); /** * product reviews */ $_Onxshop_Request = new Onxshop_Request("component/ecommerce/product_review~node_id={$product_id}:allow_anonymouse_submit=0~"); $this->tpl->assign('PRODUCT_REVIEW', $_Onxshop_Request->getContent()); /** * standard page actions */ $this->processContainers(); $this->processPage(); if (strlen($simple_product_detail['name_aka']) > 0) { $this->tpl->parse('content.name_aka'); } /** * everything went well */ return true; }