/** * 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; }
/** * 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; }
/** * get product variety list */ function getProductVarietyList($product_id) { if (!is_numeric($product_id)) { return false; } require_once 'models/ecommerce/ecommerce_product_variety.php'; $ProductVariety = new ecommerce_product_variety(); $varieties = $ProductVariety->listing("product_id = {$product_id}", 'priority DESC, id ASC'); if (is_array($varieties)) { foreach ($varieties as $kv => $v) { $variety[$kv] = $ProductVariety->getVarietyDetail($v['id']); } return $variety; } else { msg("Product id {$product_id} has no varieties", 'error', 1); return false; } }