/** * Edit product infotabs * * @param $product_id = Product ID * @param $infotab_id = Infotab ID * @param $hotspot_id = Hotspot ID * */ public function action_infotab_edit($produt_id = false, $infotab_id = false, $hotspot_id = false) { // Check for product if (!is_numeric($produt_id)) { \Response::redirect('admin/product/list'); } // Get news item to edit if (!($product = Model_Product::find_one_by_id($produt_id))) { \Response::redirect('admin/product/list'); } // Check for infotab if (!is_numeric($infotab_id)) { \Response::redirect('admin/product/list'); } // Get news item to edit if (!($item = Model_Product_To_Infotabs::find_by_pk($infotab_id))) { \Response::redirect('admin/product/list'); } // Get hotspot is exist if (is_numeric($hotspot_id)) { if (!($hotspot = Model_Infotab_Image::find_by_pk($hotspot_id))) { unset($hotspot); } } if (\Input::post()) { $val = Model_Product_To_Infotabs::validate('update', $item->type); // Upload image and display errors if there are any $image = $this->upload_infotab_image(); if (!$image['exists'] && \Config::get('infotab.image.required', false) && empty($item->images)) { // No previous images and image is not selected and it is required \Messages::error('<strong>There was an error while trying to upload infotab image</strong>'); \Messages::error('You have to select image'); } elseif ($image['errors']) { \Messages::error('<strong>There was an error while trying to upload infotab image</strong>'); foreach ($image['errors'] as $error) { \Messages::error($error); } } if ($val->run() && $image['is_valid'] && !(!$image['exists'] && \Config::get('infotab.image.required', false) && empty($item->images))) { /** IMAGES **/ // Get all alt texts to update if there is no image change foreach (\Arr::filter_prefixed(\Input::post(), 'alt_text_') as $image_id => $alt_text) { if (strpos($image_id, 'new_') === false) { $item_images[$image_id] = array('id' => $image_id, 'data' => array('alt_text' => \Input::post('alt_text_' . $image_id, ''))); } } // Save images if new files are submitted if (isset($this->_infotab_image_data)) { foreach ($this->_infotab_image_data as $image_data) { $cover_count = count($item->images); if (strpos($image_data['field'], 'new_') === false) { // Update existing image if (str_replace('image_', '', $image_data['field']) != 0) { $image_id = (int) str_replace('image_', '', $image_data['field']); $cover_count--; $item_images[$image_id] = array('id' => $image_id, 'data' => array('infotab_id' => $item->unique_id, 'image' => $image_data['saved_as'], 'alt_text' => \Input::post('alt_text_' . $image_id, ''))); $this->delete_infotab_image(\Input::post('image_db_' . $image_id, '')); } } else { // Save new image $image_tmp = str_replace('image_new_', '', $image_data['field']); $item_images[0] = array('id' => 0, 'data' => array('infotab_id' => $item->unique_id, 'image' => $image_data['saved_as'], 'alt_text' => \Input::post('alt_text_new_' . $image_tmp, ''), 'cover' => $cover_count == 0 ? 1 : 0, 'sort' => $cover_count + 1)); } } } Model_Infotab::bind_images($item_images); /** END OF IMAGES **/ // Get POST values $insert = \Input::post(); // Prep some values $insert['description'] = trim($insert['description']); $insert['active'] = !empty($insert['description']) ? 1 : 0; $item->set($insert); try { $item->save(); \Messages::success('Infotab successfully updated.'); \Response::redirect(\Input::post('exit', false) ? \Uri::create('admin/product/infotab_list/' . $product->id) : \Uri::admin('current')); } catch (\Database_Exception $e) { // show validation errors \Messages::error('<strong>There was an error while trying to update infotab</strong>'); // Uncomment lines below to show database errors //$errors = $e->getMessage(); //\Messages::error($errors); } } else { // Delete uploaded images if there is product saving error if (isset($this->_infotab_image_data)) { foreach ($this->_infotab_image_data as $image_data) { $this->delete_infotab_image($image_data['saved_as']); } } if ($val->error() != array()) { // show validation errors \Messages::error('<strong>There was an error while trying to update infotab</strong>'); foreach ($val->error() as $e) { \Messages::error($e->get_message()); } } } } $item = Model_Product_To_Infotabs::find_by_pk($infotab_id); $theme_partial = \Theme::instance()->set_partial('content', $this->view_dir . 'infotabs_edit_' . strtolower($item->type))->set('product', $product)->set('infotab', $item); if (isset($hotspot)) { $theme_partial->set('hotspot', $hotspot); } }
/** * Update product price * * @access public * @return Response */ public function action_update($id = false) { $flag = true; if (!is_numeric($id)) { \Response::redirect('admin/product/list'); } // Get product item to edit if (!($item = Model_Product::find_one_by_id($id))) { \Response::redirect('admin/product/list'); } // Redirect to attribute group if (\Input::get('attribute_group', false) === false && !empty($item->attributes)) { foreach ($item->attributes as $attr_obj) { if ($attr_obj->attribute_group_id > 0) { \Response::redirect(\Uri::create(\Uri::admin(), array(), array('attribute_group' => $attr_obj->attribute_group_id))); } } } // NRB-Gem: Comment out; Logic does not apply anymore // if(\Input::get('user_group', false) === false) // { // \Response::redirect(\Uri::create(\Uri::admin(), array(), array('user_group' => 3) + \Input::get())); // } \View::set_global('title', 'Edit Product Price'); \View::set_global('quick_menu_save', 'form.main_form'); // Update if (\Input::post()) { $post = \Input::post(); $return_to = is_numeric(\Input::post('return_to')) ? '#' . \Input::post('return_to') : ''; //$val = Model_Attribute::validate(); try { if (isset($post[$post['price_type']])) { foreach ($post[$post['price_type']] as $key => $price) { if ($update_price = Model_Attribute_Price::find_one_by_id($key)) { if (isset($post['active'][$key])) { $update_price->active = $post['active'][$key]; } if (isset($post['product_group_discount_id'][$key])) { $update_price->product_group_discount_id = $post['product_group_discount_id'][$key]; } $update_price->save(); } } } $multiple_images = array(); $image_new = false; foreach ($post['attributes'] as $key => $attribute) { if (!empty($post['delete_items'])) { $delete_items = explode(',', $post['delete_items']); $result1 = \DB::delete('product_attributes')->where('id', 'in', $delete_items)->execute(); $result2 = \DB::delete('product_attribute_price')->where('product_attribute_id', 'in', $delete_items)->execute(); } // Check existing product attribute group $existing_attribute_group = Model_Attribute::find(function ($query) use($post) { $query->where('product_id', $post['product_id']); $query->and_where_open(); $query->where('attribute_group_id', null, \DB::expr('IS NOT NULL')); // $query->and_where('attribute_group_id', '!=' , 0); $query->and_where('attribute_group_id', '!=', $post['attribute_group_id']); $query->and_where_close(); }); //if($existing_attribute_group && $post['attribute_group_id'] != 0) if ($existing_attribute_group) { foreach ($existing_attribute_group as $item) { $delete_attribute = $item->id; $item->delete(); $attribute_option = Model_Attribute_Price::find_one_by_product_attribute_id($delete_attribute); if ($attribute_option) { $attribute_option->delete(); } } } // Update if (isset($post['update_items'][$key])) { // Lightmedia - michael: check if product attribute code is exists on the product if ($this->check_attr_code_exists($id, $post['update_items'][$key], $post['product_code'][$key])) { $flag = false; \Messages::error($post['product_code'][$key] . ' code already used'); continue; } $update = Model_Attribute::find_one_by_id($post['update_items'][$key]); if ($update) { $item_images = array(); $data = array('product_id' => $post['product_id'], 'attribute_group_id' => $post['attribute_group_id'], 'attributes' => $attribute, 'product_code' => $post['product_code'][$key], 'retail_price' => $post['retail_price'][$key], 'sale_price' => $post['sale_price'][$key], 'stock_quantity' => $post['stock_quantity'][$key], 'active' => isset($post['active']) && $post['active'][$key] ? $post['active'][$key] : $post['active_new'][$key]); // Default radio $data['default'] = 0; if (isset($post['default']) && $post['default'] == $key) { $this->reset_default($item->id); $data['default'] = 1; } $update->set($data); $update->save(); $attr_id = $update->id; // Get combinations for multiple images if (isset($post['apply_image']) && isset($post['action'])) { if (in_array($attr_id, $post['action'])) { $multiple_images['action'][$attr_id] = $attr_id; } } if (isset($_FILES['image_new_' . $attr_id])) { // Upload image and display errors if there are any $image = $this->upload_image('image'); if ($image['errors'] && $image['exists']) { \Messages::error('<strong>There was an error while trying to upload product attribute image</strong>'); foreach ($image['errors'] as $error) { \Messages::error($error); } } // if($image['is_valid'] && !(!$image['exists'] && \Config::get('details.image.required', false) && empty($item->images))) if ($image['is_valid'] && !(!$image['exists'] && \Config::get('details.image.required', false))) { /** IMAGES **/ // Get all alt texts to update if there is no image change foreach (\Arr::filter_prefixed(\Input::post(), 'alt_text_') as $image_id => $alt_text) { if (strpos($image_id, 'new_') === false) { $item_images[$image_id] = array('id' => $image_id, 'data' => array('alt_text' => \Input::post('alt_text_' . $image_id, ''))); if (!empty($item_images)) { Model_Attribute::bind_images($item_images); } } } // Save images if new files are submitted if (isset($this->_image_data) && $image['exists'] !== false) { foreach ($this->_image_data as $image_data) { $cover_count = count($update->images); if (strpos($image_data['field'], 'new_') === false) { // Update existing image if (str_replace('image_', '', $image_data['field']) != 0) { $image_id = (int) str_replace('image_', '', $image_data['field']); $cover_count--; $item_images[$image_id] = array('id' => $image_id, 'data' => array('content_id' => $attr_id, 'image' => $image_data['saved_as'], 'alt_text' => \Input::post('alt_text_' . $image_id, ''))); //$this->delete_image(\Input::post('image_db_' . $image_id, '')); } if (!empty($item_images)) { Model_Attribute::bind_images($item_images); } } else { // Save new image $image_tmp = str_replace('image_new_', '', $image_data['field']); $image_new = $item_images[0] = array('id' => 0, 'data' => array('content_id' => $attr_id, 'image' => $image_data['saved_as'], 'alt_text' => \Input::post('alt_text_new_' . $image_tmp, ''), 'cover' => $cover_count == 0 ? 1 : 0, 'sort' => $cover_count + 1)); if (!empty($item_images)) { Model_Attribute::bind_images($item_images); } // Multiple images if (isset($post['apply_image']) && isset($post['action']) && false) { foreach ($post['action'] as $action_value) { if ($action_value == $attr_id) { continue; } $item_images = array(); if ($action_value > 0) { $image_new[0] = array('id' => 0, 'data' => array('content_id' => $action_value, 'image' => $image_data['saved_as'], 'alt_text' => \Input::post('alt_text_new_' . $image_tmp, ''), 'cover' => $cover_count == 0 ? 1 : 0, 'sort' => $cover_count + 1)); } if (!empty($item_images)) { Model_Attribute::bind_images($item_images); } } } } } } /** END OF IMAGES **/ } } if (isset($post['active_new'][$key])) { //NRB-Gem: insert attributes to existing Products added to Pricing Groups $this->add_attribute_price($post, array('attr_id' => $attr_id, 'key' => $key)); } } } else { if ($this->check_attr_code_exists($post['product_id'], false, $post['product_code_new'][$key])) { $flag = false; \Messages::error($post['product_code_new'][$key] . ' code already used'); continue; } $item_images = array(); $insert = Model_Attribute::forge(array('product_id' => $post['product_id'], 'attribute_group_id' => $post['attribute_group_id'], 'attributes' => $attribute, 'product_code' => $post['product_code_new'][$key], 'retail_price' => $post['retail_price_new'][$key], 'active' => $post['active_new'][$key], 'sale_price' => $post['sale_price_new'][$key], 'stock_quantity' => $post['stock_quantity'][$key])); // Default radio $insert->default = 0; if (isset($post['default']) && $post['default'] == $key) { $this->reset_default($item->id); $insert->default = 1; } $insert->save(); $attr_id = $insert->id; // Get combinations for multiple images if (isset($post['apply_image']) && isset($post['action_new'][$key]) && $post['action_new'][$key] == 1) { $multiple_images['action_new'][$attr_id] = $attr_id; } if (isset($_FILES['_image_new_' . $key])) { // Upload image and display errors if there are any $image = $this->upload_image('image'); if ($image['errors'] && $image['exists']) { \Messages::error('<strong>There was an error while trying to upload product attribute image</strong>'); foreach ($image['errors'] as $error) { \Messages::error($error); } } // if($image['is_valid'] && !(!$image['exists'] && \Config::get('details.image.required', false) && empty($item->images))) if ($image['is_valid'] && !(!$image['exists'] && \Config::get('details.image.required', false))) { /** IMAGES **/ // Save images if new files are submitted if (isset($this->_image_data) && $image['exists'] !== false) { foreach ($this->_image_data as $image_data) { $cover_count = 0; // Save new image $image_tmp = str_replace('_image_new_', '', $image_data['field']); $image_new = $item_images[0] = array('id' => 0, 'data' => array('content_id' => $attr_id, 'image' => $image_data['saved_as'], 'alt_text' => \Input::post('_alt_text_new_' . $image_tmp, ''), 'cover' => $cover_count == 0 ? 1 : 0, 'sort' => $cover_count + 1)); if (!empty($item_images)) { Model_Attribute::bind_images($item_images); } // Multiple images if (isset($post['apply_image']) && isset($post['action_new']) && false) { foreach ($post['action_new'] as $action_key => $action_value) { if ($action_value == $attr_id) { continue; } $item_images = array(); if ($action_value > 0) { $image_new[0] = array('id' => 0, 'data' => array('content_id' => $action_value, 'image' => $image_data['saved_as'], 'alt_text' => \Input::post('alt_text_new_' . $image_tmp, ''), 'cover' => $cover_count == 0 ? 1 : 0, 'sort' => $cover_count + 1)); } if (!empty($item_images)) { Model_Attribute::bind_images($item_images); } } } } } /** END OF IMAGES **/ } } if (isset($post[$post['price_type'] . '_new'][$key])) { //NRB-Gem: insert attributes to existing Products added to Pricing Groups $this->add_attribute_price($post, array('attr_id' => $attr_id, 'key' => $key)); } } } // Update/insert multiple images if (!empty($multiple_images) && !empty($image_new) && isset($image_new['data'])) { $content_id = $image_new['data']['content_id']; if (isset($multiple_images['action']) && !empty($multiple_images['action'])) { foreach ($multiple_images['action'] as $value) { $item_images = array(); if ($content_id == $value) { continue; } $image_new['data']['content_id'] = $value; $item_images[0] = $image_new; Model_Attribute::bind_images($item_images); } } if (isset($multiple_images['action_new']) && !empty($multiple_images['action_new'])) { foreach ($multiple_images['action_new'] as $value) { $item_images = array(); if ($content_id == $value) { continue; } $image_new['data']['content_id'] = $value; $item_images[0] = $image_new; Model_Attribute::bind_images($item_images); } } } if ($flag) { \Messages::success('Product successfully updated.'); } } catch (\Database_Exception $e) { // show validation errors \Messages::error('<strong>There was an error while trying to update product attributes</strong>'); // Uncomment lines below to show database errors // $errors = $e->getMessage(); // \Messages::error($errors); \Response::redirect(\Uri::create(\Uri::admin('current'), array(), \Input::get()) . $return_to); } \Response::redirect(\Uri::create(\Uri::admin('current'), array(), \Input::get()) . $return_to); } // Get current product $product = Model_Product::find_one_by_id($id); // Create array for attribute group select $attribute_groups_select = \Attribute\Model_Attribute_Group::fetch_pair('id', 'title', array(), array('0' => '- No Attributes -')); // Set user group for lazy load if (\Input::get('user_group')) { Model_Attribute::set_user_group(); } // Set tier price group for lazy load if (\Input::get('tier_price')) { Model_Attribute::set_tier_price(); } $param = \Input::get(); // Find attributes for current product $items_db = Model_Attribute::find(function ($query) use($id, $param) { $query->select('product_attributes.*'); $query->join('attribute_groups', 'LEFT')->on('attribute_groups.id', '=', 'product_attributes.attribute_group_id'); $query->where('product_id', $id); if (isset($param['attribute_group']) && is_numeric($param['attribute_group'])) { $query->and_where('product_attributes.attribute_group_id', $param['attribute_group']); } $query->order_by('attribute_groups.sort', 'asc'); }, 'id'); // Decode attribute json $combinations_db_arr = $this->decode_attribute_json($items_db); // Find current attribute group $attribute_group = array(); if (\Input::get('attribute_group')) { $attribute_group = \Attribute\Model_Attribute_Group::find_one_by_id(\Input::get('attribute_group')); } // Set vars $combinations = array(); $combinations_data = array(); $combinations_tmp = array(); $attributes_order = array(); $compared = array(); $update_items = array(); $delete_items = ''; // Create attribute combinations if ($attribute_group && $attribute_group->attributes) { $i = 0; foreach ($attribute_group->attributes as $attribute) { $attributes_order[] = $attribute->id; if ($attribute->options) { foreach ($attribute->options as $option) { $combinations[$i][] = $attribute->title . ': ' . $option->title; //$combinations[$i][] = array($attribute->title => $option->title); $combinations_tmp[$i][] = array($attribute->id => $option->id); } } $i++; } // Create combinations from current attributes $combinations = $this->combos($combinations); $combinations_tmp = $this->combos($combinations_tmp); // Sort product atributes from database if ($combinations_db_arr) { $sorted_db_arr = $this->sort_array(array_keys($attribute_group->attributes), $combinations_db_arr); if ($sorted_db_arr) { $compared = $this->compare_array($combinations_tmp, $sorted_db_arr, $combinations_db_arr); } } } // Something crazy if (!empty($compared) && !empty($items_db)) { if (!empty($compared['not_exist_in1'])) { $delete_items = array_keys($compared['not_exist_in1']); $delete_items = implode(',', $delete_items); } if (!empty($compared['exist_id'])) { $update_items = $compared['exist_id']; } } // Sort array asc $combinations_sorted = $this->sort_array_asc($combinations_tmp); foreach ($combinations_sorted as $key => $value) { $combinations_data[$key] = json_encode($value); } // Select user groups $user_groups = \Sentry::group()->all('front'); if (!empty($user_groups)) { $user_groups = \Model_Base::fetch_pair('id', 'name', array(), false, $user_groups); } else { $user_groups = array(); } $price_select = array(3 => 'Sale Price'); $price_select_fields = array(3 => 'sale_price'); // Set default user price type or use selected $price_field = 'sale_price'; if (isset($price_select_fields[\Input::get('special')])) { $price_field = $price_select_fields[\Input::get('special')]; } $listing = true; if (\Input::get('special') == 2 && !\Input::get('tier_price')) { $listing = false; } // Product pricing group if ($item->pricing_group) { $pricing_group = $item->pricing_group->id; } else { $pricing_group = false; } // NRB-Gem: removed logic // Find and select tier price // $tier_price = array(); // if(\Input::get('user_group') && is_numeric(\Input::get('user_group')) && $pricing_group) // { // $tier_price = \Product\Model_Group_Discounts::find(array( // 'where' => array( // 'user_group_id' => \Input::get('user_group'), // 'product_group_id' => $pricing_group, // ), // 'order_by' => array( // 'discount' => 'asc' // ) // )); // } // Reset to empty array if there are no result found by query if (is_null($combinations)) { $combinations = array(); } if (is_null($combinations_data)) { $combinations_data = array(); } $number_of_combinations = count($combinations); // Pagination per page default $per_page = \Input::get('per_page', 'all') == 'all' ? 9999 : \Input::get('per_page'); $show_all = $per_page > $number_of_combinations ? true : false; // Initiate pagination $pagination = \Hybrid\Pagination::make(array('total_items' => count($combinations), 'per_page' => $per_page, 'uri_segment' => null)); // Remove unwanted items, and show only required ones $combinations = array_slice($combinations, $pagination->offset, $pagination->per_page, true); $combinations_data = array_slice($combinations_data, $pagination->offset, $pagination->per_page, true); \Theme::instance()->set_partial('content', $this->view_dir . 'attributes')->set('product', $product)->set('price_select', $price_select, false)->set('combinations', $combinations, false)->set('combinations_data', $combinations_data, false)->set('attribute_groups_select', $attribute_groups_select, false)->set('delete_items', $delete_items, false)->set('update_items', $update_items, false)->set('items_db', $items_db, false)->set('price_field', $price_field)->set('listing', $listing)->set('pagination', $pagination, false)->set('number_of_combinations', $number_of_combinations)->set('show_all', $show_all); }
public function add_to_cart($return = 'return') { if (!\Input::post()) { return false; } // check for a valid CSRF token // if (!\Security::check_token()) // { // \Messages::error('CSRF attack or expired CSRF token.'); // return false; // } $post = \Input::post(); $product_id = $post['product_id']; if (!($product = Model_Product::find_one_by_id($product_id))) { return; } $selected_attributes = array(); $selected_attributes_json = null; if (isset($post['select']) && !empty($post['select'])) { ksort($post['select']); $selected_attributes_json = json_encode($post['select']); } $product_data = Model_Product::product_data($product, $selected_attributes_json, \Input::post('select'), \Input::post('attributeid')); if (!empty($product_data)) { $attr_obj = null; if (!empty($product_data['current_attributes'])) { $attr_obj = $product_data['current_attributes'][0]->product_attribute; } $item = array('title' => $product->title, 'id' => $product->id, 'product_attribute_id' => $attr_obj ? $attr_obj->id : null, 'quantity' => $post['quantity'], 'attributes' => $attr_obj ? $attr_obj->attributes : null, 'product_code' => $product_data['code'], 'unique_id' => uniqid()); if ($product_data['sale']) { $item += array('price' => $product_data['sale'], 'price_type' => 'sale_price'); } else { $item += array('price' => $product_data['retail_price'], 'price_type' => 'retail_price'); } $stock_options = \Config::load('stock-option.db'); if ($stock_options['allow_buy_out_of_stock'] != 1 && $product_data['stock_quantity'] < 1) { \Messages::error('Product is Out of Stock.'); echo \Messages::display(); return; } $uid = \Cart::generateUID($item); if (\Cart::exists($uid)) { $cart_item = \Cart::item($uid); $quantity = $cart_item->get('quantity'); if ($product_data['stock_quantity'] > 0 && $product_data['stock_quantity'] <= $quantity) { \Messages::error($product->title . ' has not enough stock to fulfill your request.'); echo \Messages::display(); return; } } if ($return == 'return') { \Cart::add($item); // Always return cart item id $uid = \Cart::generateUID($item); if (\Cart::exists($uid)) { return $uid; } return false; } else { $uid = \Cart::generateUID($item); if (\Cart::exists($uid)) { echo $uid; } echo ''; exit; } \Messages::success('Product successfully added to cart.'); echo \Messages::display(); } return false; }
/** * Get product by slug * * @param $slug */ public static function get_by_slug($slug = false) { if ($seo = \Product\Model_Product_Seo::find_one_by_slug($slug)) { return Model_Product::find_one_by_id($seo->content_id); } return false; }
protected function delete_product_attribute($product_id = null) { if ($item = Model_Product::find_one_by_id($product_id)) { if (!empty($item->attributes)) { foreach ($item->attributes as $attribute) { if (!empty($attribute->prices)) { foreach ($attribute->prices as $price) { $price->delete(); } } if (!empty($attribute->images)) { foreach ($attribute->images as $image) { $this->delete_image($image->image); $image->delete(); } } $attribute->delete(); } } } }
/** * Manage upsell products * * @param $id = Product ID */ public function action_list($id) { if (!is_numeric($id)) { \Response::redirect('admin/product/list'); } // Get news item to edit if (!($item = Model_Product::find_one_by_id($id))) { \Response::redirect('admin/product/list'); } if (\Input::post()) { $add = \Input::post('products.add', array()); $remove = \Input::post('products.remove', array()); $discounts = \Input::post('discount', array()); if (\Input::post('add', false)) { foreach ($add as $value) { $upsell = Model_Product_To_Upsell::forge(array('upsell_id' => $value, 'product_id' => $item->id)); $upsell->save(); } \Messages::success('Upsell products successfully added.'); } else { if (\Input::post('remove', false)) { foreach ($remove as $value) { $upsell = Model_Product_To_Upsell::find_one_by(array(array('upsell_id', '=', $value), array('product_id', '=', $item->id))); if (!is_null($upsell)) { $upsell->delete(); } } \Messages::success('Upsell products successfully removed.'); } else { if (\Input::post('save', false)) { foreach ($discounts as $key => $value) { $upsell = Model_Product_To_Upsell::find_one_by(array(array('upsell_id', '=', $key), array('product_id', '=', $item->id))); if (!is_null($upsell)) { $upsell->discount = round($value, 0); $upsell->save(); } } \Messages::success('Upsell discounts successfully saved.'); } } } if (\Input::is_ajax()) { echo \Messages::display('left', false); exit; } else { \Response::redirect(\Input::referrer(\Uri::create('admin/product/list'))); } } \View::set_global('title', 'List Upsell Products'); $search = $this->get_search_items($item); $pagination = $search['pagination']; $status = $search['status']; $item = $search['item']; \Theme::instance()->set_partial('content', $this->view_dir . 'list')->set('product', $item)->set('pagination', $pagination, false)->set('status', $status); }