Ejemplo n.º 1
0
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * initialize
      */
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product = new ecommerce_product();
     /**
      * get detail
      */
     $product = $Product->detail($this->GET['id']);
     $this->tpl->assign('PRODUCT', $product);
     /**
      * other data (attributes) list
      */
     $product['other_data'] = unserialize($product['other_data']);
     if (is_array($product['other_data'])) {
         foreach ($product['other_data'] as $key => $value) {
             $note['key'] = $key;
             $note['value'] = $value;
             if ($note['key'] != '') {
                 $this->tpl->assign('OTHER_DATA', $note);
                 $this->tpl->parse('content.other_data.item');
             }
         }
         if (count($product['other_data']) > 0) {
             $this->tpl->parse('content.other_data');
         }
     }
     return true;
 }
Ejemplo n.º 2
0
 /**
  * main action
  */
 public function mainAction()
 {
     require_once 'models/ecommerce/ecommerce_product_variety.php';
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product_variety = new ecommerce_product_variety();
     $Product = new ecommerce_product();
     $this->tpl->assign('VARIETY_CONF', $Product_variety->conf);
     $Product_variety->set('id', $this->GET['id']);
     if ($_POST['save'] == 'save') {
         if ($id = $Product_variety->updateVariety($_POST['product']['variety'])) {
             msg("Product variety updated.");
             /*onxshopGoTo($_SESSION['last_diff'], 2);*/
         } else {
             msg("Can't add the product variety, is you product SKU unique?");
         }
     }
     $variety = $Product_variety->getVarietyDetail($this->GET['id']);
     $variety['publish'] = $variety['publish'] == 1 ? 'checked="checked" ' : '';
     $p = $Product->detail($variety['product_id']);
     $p['variety'] = $variety;
     $this->tpl->assign('PRODUCT', $p);
     /**
      * display confirmation if notifications are about to be sent out
      */
     require_once 'models/common/common_watchdog.php';
     $Watchdog = new common_watchdog();
     $this->tpl->assign('NOTIFICATIONS', array('back_in_stock_customer' => $Watchdog->checkWatchdog('back_in_stock_customer', $variety_id, 0, 1, true)));
     return true;
 }
Ejemplo n.º 3
0
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * initialize
      */
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product = new ecommerce_product();
     /**
      * save
      */
     if ($_POST['save']) {
         $product_data = $_POST['product'];
         if ($id = $Product->updateProduct($product_data)) {
             /**
              * forward to product list main page and exit
              */
             onxshopGoTo("/backoffice/products");
             return true;
         }
     }
     /**
      * product detail
      */
     $product = $Product->detail($this->GET['id']);
     $product['publish'] = $product['publish'] == 1 ? 'checked="checked" ' : '';
     $this->tpl->assign('PRODUCT', $product);
     return true;
 }
Ejemplo n.º 4
0
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * check variety_id input
      */
     if (is_numeric($this->GET['id'])) {
         $variety_id = $this->GET['id'];
     } else {
         msg("Variety ID is not numeric", 'error');
         return false;
     }
     /**
      * initialize
      */
     require_once 'models/ecommerce/ecommerce_product_variety.php';
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product_variety = new ecommerce_product_variety();
     $Product = new ecommerce_product();
     $this->tpl->assign('VARIETY_CONF', $Product_variety->conf);
     /**
      * update variety
      */
     if ($_POST['save'] == 'save') {
         if (!isset($_POST['product']['variety']['publish'])) {
             $_POST['product']['variety']['publish'] = 0;
         }
         if ($id = $Product_variety->updateVariety($_POST['product']['variety'])) {
             msg("Product variety ID {$variety_id} updated.");
             /*onxshopGoTo($_SESSION['last_diff'], 2);*/
         } else {
             msg("Can't update the product variety, is you product code unique?", 'error');
         }
     }
     /**
      * get detail
      */
     $variety = $Product_variety->getVarietyDetail($variety_id);
     $variety['publish'] = $variety['publish'] == 1 ? 'checked="checked" ' : '';
     //alert if net weight is bigger than gross weight
     if ($variety['weight'] > $variety['weight_gross']) {
         msg("Net weight is bigger than gross weight", "error");
     }
     $p = $Product->detail($variety['product_id']);
     $p['variety'] = $variety;
     $this->tpl->assign('PRODUCT', $p);
     /**
      * display confirmation if notifications are about to be sent out
      */
     require_once 'models/common/common_watchdog.php';
     $Watchdog = new common_watchdog();
     $this->tpl->assign('NOTIFICATIONS', array('back_in_stock_customer' => $Watchdog->checkWatchdog('back_in_stock_customer', $variety['id'], 0, 1, true)));
     return true;
 }
 /**
  * main action
  */
 public function mainAction()
 {
     require_once 'models/ecommerce/ecommerce_product_to_product.php';
     require_once 'models/ecommerce/ecommerce_product.php';
     $PtP = new ecommerce_product_to_product();
     $Product = new ecommerce_product();
     $product_id = $this->GET['id'];
     $ptp_data = array();
     $ptp_data['product_id'] = $product_id;
     /**
      * saving
      */
     if (is_array($_POST['product_related'])) {
         $current = $PtP->listing("product_id = {$product_id}");
         foreach ($current as $c) {
             $PtP->delete($c['id']);
         }
         foreach ($_POST['product_related'] as $to_id) {
             if (is_numeric($to_id)) {
                 $ptp_data['related_product_id'] = $to_id;
                 $PtP->insert($ptp_data);
             }
         }
     }
     /**
      * listing
      */
     $current = $PtP->listing("product_id = {$product_id}");
     foreach ($current as $c) {
         $detail = $Product->detail($c['related_product_id']);
         if ($detail['publish'] == 0) {
             $detail['class'] = "class='disabled'";
         }
         $this->tpl->assign("CURRENT", $detail);
         $this->tpl->parse("content.ptn");
     }
     return true;
 }
Ejemplo n.º 6
0
 /**
  * load product details
  */
 protected function getProductDetails(&$page)
 {
     $product_id = $page['content'];
     if (!is_numeric($product_id)) {
         return false;
     }
     require_once "models/ecommerce/ecommerce_product.php";
     $Product = new ecommerce_product();
     $product = $Product->detail($product_id);
     if (strlen($page['description']) > 0) {
         $excerpt = $page['description'];
     } else {
         if (strlen($product['teaser']) > 0) {
             $excerpt = $product['teaser'];
         } else {
             $excerpt = $product['description'];
         }
     }
     $page['excerpt'] = $this->highlightKeywords(strip_tags($excerpt), $this->keywords);
     $page['type_priority'] = 300;
     $page['priority'] = $product['priority'];
 }
Ejemplo n.º 7
0
 /**
  * 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;
 }
Ejemplo n.º 8
0
 /**
  * main action
  */
 public function mainAction()
 {
     require_once 'models/ecommerce/ecommerce_promotion.php';
     $Promotion = new ecommerce_promotion();
     /**
      * Save on request
      */
     if ($_POST['save']) {
         $promotion_data = $_POST['promotion'];
         if ($promotion_data['publish'] == 'on' || $promotion_data['publish'] == 1) {
             $promotion_data['publish'] = 1;
         } else {
             $promotion_data['publish'] = 0;
         }
         if ($promotion_data['limit_to_first_order'] == 'on' || $promotion_data['limit_to_first_order'] == 1) {
             $promotion_data['limit_to_first_order'] = 1;
         } else {
             $promotion_data['limit_to_first_order'] = 0;
         }
         if ($promotion_data['discount_free_delivery'] == 'on' || $promotion_data['discount_free_delivery'] == 1) {
             $promotion_data['discount_free_delivery'] = 1;
         } else {
             $promotion_data['discount_free_delivery'] = 0;
         }
         if (!is_numeric($promotion_data['limit_cumulative_discount'])) {
             $promotion_data['limit_cumulative_discount'] = 0;
         }
         if (is_array($promotion_data['limit_list_products'])) {
             foreach ($promotion_data['limit_list_products'] as $product_id) {
                 if (is_numeric($product_id)) {
                     $limited_ids[] = $product_id;
                 }
             }
             if (is_array($limited_ids)) {
                 $promotion_data['limit_list_products'] = implode(",", $limited_ids);
             } else {
                 $promotion_data['limit_list_products'] = '';
             }
         }
         if (is_numeric($promotion_data['free_promo_products'])) {
             $promotion_data['free_promo_products'] = array(9999 => (int) $promotion_data['free_promo_products']);
         } else {
             $promotion_data['free_promo_products'] = null;
         }
         $promotion_data['limit_delivery_country_id'] = (int) $promotion_data['limit_delivery_country_id'];
         $promotion_data['limit_delivery_carrier_id'] = (int) $promotion_data['limit_delivery_carrier_id'];
         if ($Promotion->updatePromotion($promotion_data)) {
             msg("Promotion id={$promotion_data['id']} updated");
         } else {
             msg('Update failed', 'error');
         }
     }
     /**
      * Display Detail
      */
     $promotion_detail = $Promotion->getDetail($this->GET['id']);
     if (count($promotion_detail) > 0) {
         if ($promotion_detail['publish'] == 1) {
             $promotion_detail['publish_check'] = 'checked="checked"';
         } else {
             $promotion_detail['publish_check'] = '';
         }
         if ($promotion_detail['discount_free_delivery'] == 1) {
             $promotion_detail['discount_free_delivery_check'] = 'checked="checked"';
         } else {
             $promotion_detail['discount_free_delivery_check'] = '';
         }
         if ($promotion_detail['limit_to_first_order'] == 1) {
             $promotion_detail['limit_to_first_order_check'] = 'checked="checked"';
         } else {
             $promotion_detail['limit_to_first_order_check'] = '';
         }
         $promotion_detail['free_promo_products'] = $promotion_detail['free_promo_products'][9999];
         //find product in the node
         $limited_ids = explode(",", $promotion_detail['limit_list_products']);
         if (is_array($limited_ids)) {
             require_once 'models/ecommerce/ecommerce_product.php';
             $Product = new ecommerce_product();
             foreach ($limited_ids as $product_id) {
                 //find product in the node
                 if (is_numeric($product_id)) {
                     $detail = $Product->detail($product_id);
                     if ($detail['publish'] == 0) {
                         $detail['class'] = 'notpublic';
                     }
                     $this->tpl->assign('CURRENT', $detail);
                     $this->tpl->parse('content.item');
                 }
             }
         }
         $this->tpl->assign('PROMOTION', $promotion_detail);
     }
     return true;
 }
 /**
  * Return list of all ingredients for a recipe
  * Each element contains:
  *  - ingredient data
  *  - related product variety data as 'variety' field
  *  - related product data as 'product' field
  *  - unit name as 'unis_name' field
  */
 public function getIngredientsForRecipe($recipe_id)
 {
     if (!is_numeric($recipe_id)) {
         return false;
     }
     $ingredients = $this->listing("recipe_id = {$recipe_id}");
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product = new ecommerce_product();
     $units_raw = $this->getUnits();
     foreach ($units_raw as $unit) {
         $units[$unit['id']] = $unit['title'];
     }
     foreach ($ingredients as &$ingredient) {
         $ingredient['units_name'] = $units[$ingredient['units']];
         $ingredient['variety'] = $Product->getProductVarietyDetail($ingredient['product_variety_id']);
         if ($ingredient['variety']) {
             $ingredient['product'] = $Product->detail($ingredient['variety']['product_id']);
         }
         $ingredient['name'] = $ingredient['product']['name'];
     }
     $ingredients = php_multisort($ingredients, array(array('key' => 'group_title', 'sort' => 'asc'), array('key' => 'name', 'sort' => 'asc')));
     return $ingredients;
 }