Home of Products module shows ID, Name, Class, Grouping, Status, Category Name, Featured, Price and Actions.
Manage Products Page Overview
We use jquery dataTables to show our information. This will allow us to sort by each column, display different number of rows and seach.
Download Page
Class and Grouping
The purpose of Class and Grouping is for sorting images and I needed these fields. You can find it in action here. This uses jquery and sort images and when you click a thumbnail, a lightbox starts. I will write about it in more details near future.
Status and Category Name
When you click ‘active’ in the Status column, it will change to inactive and won’t be shown in the front-end.
Names under Category Name are pulled from db which you added in the category module. As you guess, you can show all your products in the same category in your front-end.
Featured
I added two options in Featured column. ‘front’ which is a main frontpage and ‘webshop’
which is webshop frontpage. There are often you have two websites, one for your company and one for your webshop. And you want to show images in both pages. You can use this field to show which image in which web front.
For this purpose I am using
If you want to change this, either you need to change db
and inputs in views should reflect your changes, or change to varchar to enter any words.
Create Product/Edit Product Page Overview

‘Create Product’ page and ‘Edit Product’ page has the following fields.
You need to select a category name from a dropdown. The dropdown list is created from
categories which you added in the category page/module.
Add ‘Name’, ‘Short Description’ and ‘Long Description’ which we used TinyMCE for textareas.
You select your large image for ‘Upload Image’ and a small image for ‘Upload Thumbnail’. Those images will be stored in a folder which has the same name as the category name and the thumbnails will be in the thumbnail folder. For example, if your category is Tshirts, assets/images/Tshirts/yellowshirt.jpg and assets/images/Tshirts/thumbnails/yellowshirt_small.jpg.
You select ‘Status’, active or inactive. The default is active.
Add any name for ‘Class’ which is used for sorting images.
Add any name for ‘Grouping’ which is used for a jquery lightbox effect.
You may leave both field blank if you wish.
Select an option from the ‘Featured’ dropdown if you wish. This will be used for either your main front page or a web shop front page.
I also included ‘Other Feature’ dropdown options. Options are ‘Most sold’ and ‘New Product’. If you wish to change or add to them, you need to change the database entries.
On the right you find a jquery accordion which you can add instruction for other admin users. You can modify it through modules/products/views/admin/product_right.php.
Database
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`shortdesc` varchar(255) NOT NULL,
`longdesc` text NOT NULL,
`thumbnail` varchar(255) NOT NULL,
`image` varchar(255) NOT NULL,
`class` varchar(255) DEFAULT NULL,
`grouping` varchar(16) DEFAULT NULL,
`status` enum(‘active’,'inactive’) NOT NULL,
`category_id` int(11) NOT NULL,
`featured` enum(‘none’,'front’,'webshop’) NOT NULL,
`other_feature` enum(‘none’,'most sold’,'new product’) NOT NULL,
`price` float(7,2) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=122 ;
Module structure
You can see the structure in this image. Please click to enlarge the image.

admin controller
Please read the comments in the following code. modules/products/controllers/admin.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Admin extends Admin_Controller {
function Admin(){
parent::Admin_Controller();
// Check for access permission
check('Products');
// load modules/categories/model/mcats
$this->load->module_model('categories','MCats');
// load the MProducts model
$this->load->model('MProducts');
// Set breadcrumb
$this->bep_site->set_crumb($this->lang->line('backendpro_products'),'products/admin');
}
function index(){
// Setting variables
$data['title'] = "Manage Products";
$data['products'] = $this->MProducts->getAllProducts();
$data['categories'] = $this->MCats->getCategoriesDropDown();
// we are pulling a header word from language file
$data['header'] = $this->lang->line('backendpro_access_control');
$data['page'] = $this->config->item('backendpro_template_admin') . "admin_product_home";
$data['module'] = 'products';
$this->load->view($this->_container,$data);
}
function create(){
// we are using TinyMCE in this page, so load it
$this->bep_assets->load_asset_group('TINYMCE');
if ($this->input->post('name')){
// fields are filled up so do the followings
$this->MProducts->addProduct();
// CI way to set flashdata, but we are not using it
// $this->session->set_flashdata('message','Product created');
// we are using Bep function for flash msg
flashMsg('success','Product created');
redirect('products/admin/index','refresh');
}else{
// this must be the first time, so set variables
$data['title'] = "Create Product";
$data['categories'] = $this->MCats->getCategoriesDropDown();
$data['right'] = 'admin/product_right';
// Set breadcrumb
$this->bep_site->set_crumb($this->lang->line('userlib_product_create'),'products/admin/create');
$data['header'] = $this->lang->line('backendpro_access_control');
$data['page'] = $this->config->item('backendpro_template_admin') . "admin_product_create";
$data['module'] = 'products';
$this->load->view($this->_container,$data);
}
}
function edit($id=0){
// we are using TinyMCE in edit as well
$this->bep_assets->load_asset_group('TINYMCE');
if ($this->input->post('name')){
// fields filled up so,
$this->MProducts->updateProduct();
// CI way to set flashdata, but we are not using it
// $this->session->set_flashdata('message','Product updated');
// we are using Bep function for flash msg
flashMsg('success','Product updated');
redirect('products/admin/index','refresh');
}else{
//$id = $this->uri->segment(4);
$data['title'] = "Edit Product";
// $data['main'] = 'admin_product_edit';
$data['page'] = $this->config->item('backendpro_template_admin') . "admin_product_edit";
$data['product'] = $this->MProducts->getProduct($id);
$data['categories'] = $this->MCats->getCategoriesDropDown();
$data['assigned_colors'] = $this->MProducts->getAssignedColors($id);
$data['assigned_sizes'] = $this->MProducts->getAssignedSizes($id);
$data['right'] = 'admin/product_right';
if (!count($data['product'])){
redirect('products/admin/index','refresh');
}
// Set breadcrumb
$this->bep_site->set_crumb($this->lang->line('userlib_product_edit'),'products/admin/edit');
$data['header'] = $this->lang->line('backendpro_access_control');
$data['module'] = 'products';
$this->load->view($this->_container,$data);
}
}
function delete($id){
$this->MProducts->deleteProduct($id);
$this->session->set_flashdata('message','Product deleted');
redirect('products/admin/index','refresh');
}
function changeProductStatus($id){
$this->MProducts->changeProductStatus($id);
$this->session->set_flashdata('message','Page status changed');
redirect('products/admin/index','refresh');
}
function batchmode(){
$this->MProducts->batchUpdate();
redirect('products/admin/index','refresh');
}
function export(){
$this->load->helper('download');
$csv = $this->MProducts->exportCsv();
$name = "product_export.csv";
force_download($name,$csv);
}
function import(){
if ($this->input->post('csvinit')){
$data['csv'] = $this->MProducts->importCsv();
$data['title'] = "Preview Import Data";
// Set breadcrumb
$this->bep_site->set_crumb($this->lang->line('userlib_product_import'),'products/admin/import');
$data['header'] = $this->lang->line('backendpro_access_control');
$data['page'] = $this->config->item('backendpro_template_admin') . "admin_product_csv";
$data['module'] = 'products';
$this->load->view($this->_container,$data);
}elseif($this->input->post('csvgo')){
if (eregi("finalize", $this->input->post('submit'))){
$this->MProducts->csv2db();
$this->session->set_flashdata('message','CSV data imported');
}else{
$this->session->set_flashdata('message','CSV data import cancelled');
}
redirect('products/admin/index','refresh');
}
}
}
?>
mproducts model
File Uploading Class
In this model we are going to use CI’s File Uploading Class.
modules/products/models/mproducts.php
–UPDATED 14 Feb 2010–
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MProducts extends Model{
function MProducts(){
parent::Model();
}
function getProduct($id){
// getting info of single product.
$data = array();
$options = array('id' => id_clean($id));
$Q = $this->db->getwhere('omc_product',$options,1);
if ($Q->num_rows() > 0){
$data = $Q->row_array();
}
$Q->free_result();
return $data;
}
function getAllProducts(){
// getting all the products of the same categroy.
$data = array();
$Q = $this->db->query('SELECT P.*, C.Name AS CatName FROM omc_product AS P LEFT JOIN omc_category AS C ON C.id = P.category_id');
if ($Q->num_rows() > 0){
foreach ($Q->result_array() as $row){
$data[] = $row;
}
}
$Q->free_result();
return $data;
}
/* Not used any more
* This was used to get featured products. Need to replace featured_name_here to a featured name.
function getProducts(){
$data = array();
$Q = $this->db->query('SELECT P.*, C.Name AS CatName
FROM omc_product AS P
LEFT JOIN omc_category AS C ON C.id = P.category_id
WHERE featured = "featured_name_here"');
return $Q;
}
*/
function getProductsByCategory($catid){
// this is used in function cat($id) in the shop frontend
// When a product is clicked this will be used.
// If not $cat['parentid'] < 1
// $catid is given in URI, the third element
$data = array();
$this->db->where('category_id', id_clean($catid));
$this->db->where('status', 'active');
$this->db->orderby('name','asc');
$Q = $this->db->get('omc_product');
if ($Q->num_rows() > 0){
foreach ($Q->result_array() as $row){
$data[] = $row;
}
}
$Q->free_result();
return $data;
}
function getProductsByGroup($limit,$group,$skip){
// page 99
// for the shop fron-end controller function product($id)
$data = array();
if ($limit == 0){
$limit=3;
}
$this->db->select('id,name,shortdesc,thumbnail');
$this->db->where('grouping', db_clean($group,16));
$this->db->where('status', 'active');
$this->db->where('id !=', id_clean($skip));
$this->db->orderby('name','asc');
$this->db->limit($limit);
$Q = $this->db->get('omc_product');
if ($Q->num_rows() > 0){
foreach ($Q->result_array() as $row){
$data[] = $row;
}
}
$Q->free_result();
return $data;
}
function getGallery($id){
$data = array();
$Q = $this->db->query('SELECT P.*, C.Name AS CatName
FROM omc_product AS P
LEFT JOIN omc_category C
ON C.id = P.category_id
WHERE C.Name = "Galleri ' . $id . '"
AND p.status = "active"
');
if ($Q->num_rows() > 0){
foreach ($Q->result_array() as $row){
$data[] = $row;
}
}
$Q->free_result();
return $data;
}
function getMainFeature(){
$data = array();
$this->db->select("id,name,shortdesc,image");
$this->db->where('featured','true');
$this->db->where('status', 'active');
$this->db->order_by('name','random');
$Q = $this->db->get('omc_product');
if ($Q->num_rows() > 0){
foreach ($Q->result_array() as $row){
$data[] = $row;
}
}
$Q->free_result();
return $data;
}
function getFrontFeature($feature){
$data = array();
$this->db->where('featured',$feature);
$this->db->where('status', 'active');
$this->db->LIMIT(9);
$this->db->order_by('name','random');
$Q = $this->db->get('omc_product');
if ($Q->num_rows() > 0){
foreach ($Q->result_array() as $row){
$data[] = $row;
}
}
$Q->free_result();
return $data;
}
function getFeatureProducts($catname){
$data = array();
$Q = $this->db->query("SELECT P.*, C.Name AS CatName
FROM omc_product AS P
LEFT JOIN omc_category AS C
ON C.id = P.category_id
WHERE C.Name = '$catname'
AND p.status = 'active'
ORDER BY RAND()
");
if ($Q->num_rows() > 0){
foreach ($Q->result_array() as $row){
$data[] = $row;
}
}
$Q->free_result();
return $data;
}
function getFrontbottom(){
$data = array();
$Q = $this->db->query("SELECT P.*, C.Name AS CatName
FROM omc_product AS P
LEFT JOIN omc_category AS C
ON C.id = P.category_id
WHERE C.Name = 'Front bottom'
AND p.status = 'active''
ORDER BY RAND()
");
if ($Q->num_rows() > 0){
foreach ($Q->result_array() as $row){
$data[] = $row;
}
}
$Q->free_result();
return $data;
}
function getRandomProducts($limit,$skip){
// when you want to select three random products, use this.
$data = array();
$temp = array();
if ($limit == 0){
$limit=3; // change this number
}
$this->db->select("id,name,thumbnail,category_id");
$this->db->where('id !=', id_clean($skip));
$this->db->where('status','active');
$this->db->orderby("category_id","asc");
$this->db->limit(100);
$Q = $this->db->get('omc_product');
if ($Q->num_rows() > 0){
foreach ($Q->result_array() as $row){
$temp[$row['category_id']] = array(
"id" => $row['id'],
"name" => $row['name'],
"thumbnail" => $row['thumbnail']
);
}
}
shuffle($temp);
if (count($temp)){
for ($i=1;$i<=$limit; $i++){
$data[] = array_shift($temp);
}
}
$Q->free_result();
return $data;
}
function search($term){
$data = array();
$this->db->select('id,name,shortdesc,thumbnail');
$this->db->where("(name LIKE '%$term%' OR shortdesc LIKE '%$term%' OR longdesc LIKE '%$term%') AND status='active'");
$this->db->orderby('name','asc');
$this->db->limit(50);
$Q = $this->db->get('omc_product');
if ($Q->num_rows() > 0){
foreach ($Q->result_array() as $row){
$data[] = $row;
}
}
$Q->free_result();
return $data;
}
function addProduct(){
$data = $this->_uploadFile();
$this->db->insert('omc_product', $data);
$new_product_id = $this->db->insert_id();
if (isset($_POST['colors'])){
foreach ($_POST['colors'] as $value){
$data = array('product_id' => $new_product_id,
'color_id' => $value);
$this->db->insert('omc_product_colors',$data);
}
}
if (isset($_POST['sizes'])){
foreach ($_POST['sizes'] as $value){
$data = array('product_id' => $new_product_id,
'size_id' => $value);
$this->db->insert('omc_product_sizes',$data);
}
}
}
function updateProduct(){
$data = $this->_uploadFile();
$this->db->where('id', $_POST['id']);
$this->db->update('omc_product', $data);
$this->db->where('product_id', $_POST['id']);
$this->db->delete('omc_product_colors');
$this->db->where('product_id', $_POST['id']);
$this->db->delete('omc_product_sizes');
if (isset($_POST['colors'])){
foreach ($_POST['colors'] as $value){
$data = array('product_id' => $_POST['id'],
'color_id' => $value);
$this->db->insert('omc_product_colors',$data);
}
}
if (isset($_POST['sizes'])){
foreach ($_POST['sizes'] as $value){
$data = array('product_id' => $_POST['id'],
'size_id' => $value);
$this->db->insert('omc_product_sizes',$data);
}
}
}
function getFeaturedProducts($feature){
$data = array();
$this->db->from('omc_product');
$this->db->where('other_feature', $feature);
$this->db->where('status', 'active');
$this->db->limit(1);
$this->db->order_by("id", "random");
$Q = $this->db->get();
if ($Q->num_rows() > 0){
foreach ($Q->result_array() as $row){
$data[] = $row;
}
}
$Q->free_result();
return $data;
}
function _uploadFile(){
$data = array(
'name' => db_clean($_POST['name']),
'shortdesc' => db_clean($_POST['shortdesc']),
'longdesc' => db_clean($_POST['longdesc'],5000),
'status' => db_clean($_POST['status'],8),
'class' => db_clean($_POST['class'],30),
'grouping' => db_clean($_POST['grouping'],16),
'category_id' => id_clean($_POST['category_id']),
'featured' => db_clean($_POST['featured'],20),
'price' => db_clean($_POST['price'],16),
'other_feature' => db_clean($_POST['other_feature'],20)
);
$catname = array();
$category_id = $data['category_id'];
$catname = $this->MCats->getCategoryNamebyProduct($category_id);
foreach ($catname as $key => $name){
$foldername = createdirname($name);
}
if ($_FILES){
$config['upload_path'] = './assets/images/'.$foldername.'/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '200';
$config['remove_spaces'] = true;
$config['overwrite'] = true;
$config['max_width'] = '0';
$config['max_height'] = '0';
// Here we are loading CI's file uploading class
$this->load->library('upload', $config);
if (strlen($_FILES['image']['name'])){
if(!$this->upload->do_upload('image')){
$this->upload->display_errors();
exit("unable to open file ($foldername). The folder does not exist. You need to create a category first.");
}
$image = $this->upload->data();
if ($image['file_name']){
$data['image'] = "assets/images/".$foldername."/".$image['file_name'];
}
}
$config['upload_path'] = './assets/images/'.$foldername.'/thumbnails/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '200';
$config['remove_spaces'] = true;
$config['overwrite'] = true;
$config['max_width'] = '0';
$config['max_height'] = '0';
//initialize otherwise thumb will take the first one
$this->upload->initialize($config);
if (strlen($_FILES['thumbnail']['name'])){
if(!$this->upload->do_upload('thumbnail')){
$this->upload->display_errors();
exit("unable to open a thumbnail folder in the folder ($foldername). You need to contact Admin.");
}
$thumb = $this->upload->data();
if ($thumb['file_name']){
$data['thumbnail'] = "assets/images/".$foldername."/thumbnails/".$thumb['file_name'];
}
}
}
return $data;
}
function deleteProduct($id){
// $data = array('status' => 'inactive');
$this->db->where('id', id_clean($id));
$this->db->delete('omc_product');
}
function changeProductStatus($id){
// getting status of page
$productinfo = array();
$productinfo = $this->getProduct($id);
$status = $productinfo['status'];
if($status =='active'){
$data = array('status' => 'inactive');
$this->db->where('id', id_clean($id));
$this->db->update('omc_product', $data);
}else{
$data = array('status' => 'active');
$this->db->where('id', id_clean($id));
$this->db->update('omc_product', $data);
}
}
function batchUpdate(){
if (count($this->input->post('p_id'))){
$data = array('category_id' => id_clean($this->input->post('category_id')),
'grouping' => db_clean($this->input->post('grouping'))
);
$idlist = implode(",",array_values($this->input->post('p_id')));
$where = "id in ($idlist)";
$this->db->where($where);
$this->db->update('omc_product',$data);
$this->session->set_flashdata('message', 'Products updated');
}else{
$this->session->set_flashdata('message', 'Nothing to update!');
}
}
function exportCsv(){
$this->load->dbutil();
$Q = $this->db->query("select * from omc_product");
return $this->dbutil->csv_from_result($Q,",","\n");
}
function importCsv(){
$config['upload_path'] = './csv/';
$config['allowed_types'] = 'csv';
$config['max_size'] = '2000';
$config['remove_spaces'] = true;
$config['overwrite'] = true;
// Here we are loaind CI's File Uploading class
$this->load->library('upload', $config);
$this->load->library('CSVReader');
if(!$this->upload->do_upload('csvfile')){
$this->upload->display_errors();
exit();
}
$csv = $this->upload->data();
$path = $csv['full_path'];
return $this->csvreader->parseFile($path);
}
function csv2db(){
unset($_POST['submit']);
unset($_POST['csvgo']);
foreach ($_POST as $line => $data){
if (isset($data['id'])){
$this->db->where('id',$data['id']);
unset($data['id']);
$this->db->update('omc_product',$data);
}else{
$this->db->insert('omc_product',$data);
}
}
}
function reassignProducts(){
$data = array('category_id' => $this->input->post('categories'));
$idlist = implode(",",array_keys($this->session->userdata('orphans')));
$where = "id in ($idlist)";
$this->db->where($where);
$this->db->update('omc_product',$data);
}
function getAssignedColors($id){
// not using anymore
$data = array();
$this->db->select('color_id');
$this->db->where('product_id',id_clean($id));
$Q = $this->db->get('omc_product_colors');
if ($Q->num_rows() > 0){
/**
* products_colors table have product_id and color_id
* This will select color_id. where product_id=$id.
* e.g. product id = 7 may have color_id 2, 3, 4.
*/
foreach ($Q->result_array() as $row){
$data[] = $row['color_id'];
}
}
$Q->free_result();
return $data;
}
function getAssignedSizes($id){
// not using anymore
/**
* products_sizes table has product_id and size_id fields
* This will be the same as getAssignedColors() function above
* It will returns size_id where product_id is $id
* e.g product id=7 may have size_id 2,3,4 etc
*/
$data = array();
$this->db->select('size_id');
$this->db->where('product_id',id_clean($id));
$Q = $this->db->get('omc_product_sizes');
if ($Q->num_rows() > 0){
foreach ($Q->result_array() as $row){
$data[] = $row['size_id'];
}
}
$Q->free_result();
return $data;
}
}//end class
?>
Views
admin_product_create
modules/products/views/admin/admin_product_create.php
<div id="pageleftcont">
<div id="create_edit">
<h2><?php echo $title;?></h2>
<?php
echo form_open_multipart('products/admin/create')."\n";
echo "<p><label for='parent'>Category</label><br/>\n";
echo form_dropdown('category_id',$categories) ."</p>\n";
echo "<p><label for='pname'>Name</label><br/>";
$data = array('name'=>'name','id'=>'pname','size'=>25);
echo form_input($data) ."</p>\n";
echo "<p><label for='short'>Short Description</label><br/>";
$data = array('name'=>'shortdesc','id'=>'short','rows'=>5, 'cols'=>'40');
echo form_textarea($data) ."</p>\n";
echo "<p><label for='long'>Long Description</label><br/>";
$data = array('name'=>'longdesc','id'=>'long','rows'=>10, 'cols'=>'40');
echo form_textarea($data) ."</p>\n";
echo "<p><label for='uimage'>Upload Image</label><br/>";
$data = array('name'=>'image','id'=>'uimage','size'=>80);
echo form_upload($data) ."</p>\n";
echo "<p><label for='uthumb'>Upload Thumbnail</label><br/>";
$data = array('name'=>'thumbnail','id'=>'uthumb','size'=>80);
echo form_upload($data) ."</p>\n";
echo "<p><label for='status'>Status</label><br/>";
$options = array('active' => 'active', 'inactive' => 'inactive');
echo form_dropdown('status',$options) ."</p>\n";
echo "<p><label for='class'>Class</label><br/>";
$data = array('name'=>'class','id'=>'class','size'=>50);
echo form_input($data) ."</p>\n";
echo "<p><label for='group'>Grouping</label><br/>";
$data = array('name'=>'grouping','id'=>'group','size'=>50);
echo form_input($data) ."</p>\n";
echo "<p><label for='price'>Price</label><br/>";
$data = array('name'=>'price','id'=>'price','size'=>20);
echo form_input($data) ."</p>\n";
echo "<p><label for='featured'>Featured?</label><br/>\n";
$options = array('none' => 'none', 'front' => 'main frontpage', 'webshop' => 'webshop frontpage');
echo form_dropdown('featured',$options) ."</p>\n";
echo "<p><label for='other_feature'>Other Feature?</label><br/>\n";
$options = array('none' => 'none', 'most solgt' => 'Most sold', 'new product' => 'New Product');
echo form_dropdown('other_feature',$options) ."</p>\n";
echo form_submit('submit','create product');
echo form_close();
?>
</div>
</div>
<div id="pagerightcont">
<?php $this->load->view($right);?>
</div>
admin_product_edit
modules/products/views/admin/admin_product_edit.php
<div id="pageleftcont">
<div id="create_edit">
<h2><?php echo $title;?></h2>
<?php
echo form_open_multipart('products/admin/edit');
echo "\n<p><label for='parent'>Category</label><br/>\n";
echo form_dropdown('category_id',$categories,$product['category_id']) ."</p>\n";
echo "<p><label for='pname'>Name(This will be used for image alt.)</label><br/>\n";
$data = array('name'=>'name','id'=>'pname','size'=>25, 'value' => $product['name']);
echo form_input($data) ."</p>\n";
echo "<p><label for='short'>Short Description</label><br/>\n";
$data = array('name'=>'shortdesc','id'=>'short','size'=>40, 'value' => $product['shortdesc']);
echo form_textarea($data) ."</p>\n";
echo "<p><label for='long'>Long Description</label><br/>\n";
$data = array('name'=>'longdesc','id'=>'long','rows'=>5, 'cols'=>'40', 'value' => $product['longdesc']);
echo form_textarea($data) ."</p>\n";
echo "<p><label for='uimage'>Upload Image</label><br/>\n";
$data = array('name'=>'image','id'=>'uimage','size'=>100);
echo form_upload($data) ."<br/>Current image: ". $product['image']."</p>\n";
echo "<p><label for='uthumb'>Upload Thumbnail</label><br/>\n";
$data = array('name'=>'thumbnail','id'=>'uthumb','size'=>100);
echo form_upload($data) ."<br/>Current thumbnail: ". $product['thumbnail']."</p>\n";
echo "<p><label for='status'>Status</label><br/>\n";
$options = array('active' => 'active', 'inactive' => 'inactive');
echo form_dropdown('status',$options, $product['status']) ."</p>\n";
echo "<p><label for='class'>Class(This will be used for html class and filtable.)</label><br/>";
$data = array('name'=>'class','id'=>'class','size'=>50, 'value' => $product['class']);
echo form_input($data) ."</p>\n";
echo "<p><label for='group'>Grouping(This will be used for light box grouping and added to rel.)</label><br/>\n";
$data = array('name'=>'grouping','id'=>'group','size'=>50, 'value' => $product['grouping']);
echo form_input($data) ."</p>";
echo "<p><label for='price'>Price</label><br/>\n";
$data = array('name'=>'price','id'=>'price','size'=>20, 'value' => $product['price']);
echo form_input($data) ."</p>\n";
echo "<p><label for='featured'>Featured?</label><br/>\n";
$options = array('none' => 'none', 'front' => 'Main frontpage', 'webshop' => 'Webshop frontpage');
echo form_dropdown('featured',$options, $product['featured']) ."</p>\n";
echo "<p><label for='other_feature'>Other Feature?</label><br/>\n";
$options = array('none' => 'none', 'mest solgt' => 'Mest solgt', 'siste nytt' => 'Siste nytt');
echo form_dropdown('other_feature',$options, $product['other_feature']) ."</p>\n";
echo form_hidden('id',$product['id']);
echo form_submit('submit','update product');
echo form_close();
?>
</div>
</div>
<div id="pagerightcont">
<?php $this->load->view($right);?>
</div>
admin_product_home
modules/products/views/admin/admin_product_home.php
<?php print displayStatus();?>
<h2><?php echo $title;?></h2>
<p><?php echo anchor("products/admin/create", "Create new product");?> | <?php echo anchor("products/admin/export","Export");?></p>
<?php
echo form_open_multipart("products/admin/import");
$data = array('name' => 'csvfile', 'size'=>15);
echo form_upload($data);
echo form_hidden('csvinit',true);
echo form_submit('submit','IMPORT');
echo form_close();
?>
<?php
/* We not using this CI flashmsg
if ($this->session->flashdata('message')){
echo "<div class='status_box'>".$this->session->flashdata('message')."</div>";
}
*/
if (count($products)){
echo form_open("products/admin/batchmode");
echo "<p>Category: ". form_dropdown('category_id',$categories);
echo " ";
$data = array('name'=>'grouping','size'=>'10');
echo "Grouping: ". form_input($data);
echo form_submit("submit","batch update");
echo "</p>";
echo '<table id="tablesorter_product" class="tablesorter" border="1" cellspacing="0" cellpadding="3" width="100%">';
echo "<thead>\n<tr valign='top'>\n";
echo "<th> </th><th>Product ID</th>\n<th>Name</th><th>Class</th><th>Grouping</th><th>Status</th><th>Category Name</th><th>Featured</th><th>Price</th><th>Actions</th>\n";
echo "</tr>\n</thead>\n<tbody>\n";
foreach ($products as $key => $list){
echo "<tr valign='top'>\n";
echo "<td align='center'>".form_checkbox('p_id[]',$list['id'],FALSE)."</td>";
echo "<td align='center'>".$list['id']."</td>\n";
echo "<td align='center'>".$list['name']."</td>\n";
echo "<td align='center'>".$list['class']."</td>\n";
echo "<td align='center'>".$list['grouping']."</td>\n";
echo "<td align='center'>";
echo anchor('products/admin/changeProductStatus/'.$list['id'],$list['status'], array('class' => $list['status']));
echo "</td>\n";
// echo "<td align='center'>".$list['category_id']."</td>\n";
echo "<td align='center'>".$list['CatName']."</td>\n";
echo "<td align='center'>".$list['featured']."</td>\n";
echo "<td align='center'>".$list['price']."</td>\n";
echo "<td align='center'>";
echo anchor('products/admin/edit/'.$list['id'],'edit');
echo " | ";
echo anchor('products/admin/delete/'.$list['id'],'delete');
echo "</td>\n";
echo "</tr>\n";
}
echo "</tbody></table>";
echo form_close();
}
?>
product_right
modules/products/views/admin/product_right.php
<h2>Product Categories Notes</h2>
<div class="basic" id="accordion">
<a>Gallery 1 Class</a>
<div>
<h3>Class</h3>
<p>You can add your information here. This is just an example.Class is used for sorting images <b>only in Galleri 1</b> at the moment. <br />Use the following class for grouping.
<br />For example, input message-from-the-wee-folk. </p>
<p>new-flight: Book New Flight<br />
det-hemmelige-eventyret: Det Hemmelige Eventyret<br />
cumulus: Cumulus<br />
messages-from-the-wee-fork: Message from the Wee Folk<br />
wisdom-of-four-winds: Wisdom of four winds<br />
amina: Amina</p>
<h3>Image size:</h3>
<h4>Thumb</h4>
<p>
width: 77px; height: 105px;</p>
<h4>Big image</h4>
<p>max width: 800px; max height: 800px</p>
</div>
<a>Web Design Gallerie</a>
<div>
<h3>Image Size</h3>
<p>Thumb: width 150px<br />
Big image: max width: 800px;</p>
<p>Name will be in anchor title, <br />
i.e. www.vitaveritas.no </p>
<p>rel will be image rel,<br />
i.e. imagebox-lights.</p>
<p>shortdesc will be in alt in img and in anchor, <br />
i.e. http://www.vitaveritas.no/.</p>
<p>longdesc will be used as Plattform: Visma Avendo
nettbutikk
</p>
<p>No class for web site gallery</p>
<p>Grouping: use image-light</p>
<p>Example: <li><a href="images/web/vitaveritas_b.jpg" rel="imagebox-lights" title="www.vitaveritas.no/" ><img src="images/web/vitaveritas.jpg" alt="www.vitaveritas.no/" width="150" height="97" /></a>
<a href="http://www.vitaveritas.no/" target="_blank">www.vitaveritas.no</a><br />
Plattform: Visma Avendo</li></p>
</div>
<a>Front Page Top</a>
<div>
<ul>
<li>No plug-ins or system updates</li>
<li>Browser based administration</li>
<li>Unlimited products, categories</li>
<li>Use as complete storefront</li>
<li>Integrates into any existing web</li>
<li>Free add-ons for gateways, languages and real-time shipping</li>
<li>Turn on shopping features as you need them</li>
<li>Simple shops can be up and running in an hour. Just add your products. </li>
</ul>
</div>
<a>Front Page Bottom</a>
<div>
<ul>
<li>No plug-ins or system updates</li>
<li>Browser based administration</li>
<li>Unlimited products, categories</li>
<li>Use as complete storefront</li>
<li>Integrates into any existing web</li>
<li>Free add-ons for gateways, languages and real-time shipping</li>
<li>Turn on shopping features as you need them</li>
<li>Simple shops can be up and running in an hour. Just add your products. </li>
</ul>
</div>
</div> <!--End of id accordion -->
admin_product_csv
modules/products/views/admin/admin_product_csv.php
<?php
if (count($csv)){
echo form_open('products/admin/import');
echo form_submit('cancel','<< start over');
echo form_submit('submit','finalize import >>');
?>
<table border='1' cellspacing='0' cellpadding='5'>
<tr valign='top'>
<?php
$headers = array_keys($csv[0]);
foreach ($headers as $v){
$hdr = trim(str_replace('"','',$v));
if ($hdr != '' && !eregi("thumbnail",$hdr) && !eregi("image",$hdr)){
echo "<th>".$hdr."</th>\n";
}
}
?>
</tr>
<?php
foreach ($csv as $key => $line){
echo "<tr valign='top'>\n";
foreach ($line as $f => $d){
$FIELD = trim(str_replace('"','',$f));
$FDATA = trim(str_replace('"','',$d));
if ($FIELD != '' && !eregi("thumbnail",$FDATA) && !eregi("image",$FDATA)){
echo "<td>";
echo $FDATA . "\n";
echo form_hidden("line_$key"."[".$FIELD."]",$FDATA);
echo "</td>\n";
}
}
echo "</tr>\n";
}
?>
</table>
<?php
echo form_hidden('csvgo',true);
echo form_close();
}else{
echo "<h1>We detected a problem...</h1>";
echo "<p>No records to import! Please try again.</p>";
}
?>




















hi, in your add products, – there is something missing, often a same product can have option features, lets say a shirt, may have color option : red, blue, yellow, and a size feature : small, medium, extra large.
your shop doesn’t support that kind of option, and is almost an essential.
Also, how are we suppose to transmit info to paypal, is there any compatibility, and can you add custom hidden fields for a product??
Thanks !!! the rest of the system looks real nice
@sylvain: If you look at version 1.0, it has options you are talking about. It has size and color. You can add or change them in the code. It also has google payment as well. The version 1.1 is created for only small e-commerce. However you are welcome to change codes as you like.