Nous ne répondons seulement qu'aux sujets dont l'auteur a complété sa signature [Lire]



Vous avez des soucis avec votre Opencart v1.5.x, nous pouvons résoudre vos problèmes,
contactez le Bureau France !

par tel: 0 891 690 175 ou par
email

Problème produits apparentés

Inscrire dans ce forum tous les types de problèmes que vous rencontrez avec OpenCart

Problème produits apparentés

Messagepar cricri92 » 22 Nov 2011, 08:14

Bonjour
Depuis le début de mon installation d'Opencart je n'ai pas fait de mise à jour. Je viens de m’apercevoir que dans la partie "admin" au niveau des produits apparentés, lorsque je sélectionne les produits, ils sont bien présent dans la boutique au niveau des produits apparentés, mais lorsque je retourne dans la partie "admin", il n'y sont pas. J'ai beau refaire la manip, ils sont présents dans la boutique mais pas dans les produits apparentés du produit concerné dans la partie "Admin".
Quelqu'un à t'il eu le même problème.
Merci d'avance
Version Opencart 1.4.8 Fr sur serveur Infomaniak
Version Opencart 1.5.4.1 sur JOOMLA avec module AceShop
modules additionnels : CMS Categories, Stock report, Product extra fields, Poll, Visiteur counter, NextAndPreviousProductLink, MiniSlider
Avatar de l’utilisateur
cricri92
Utilisateur enregistré
Utilisateur enregistré
 
Messages: 138
Inscription: 02 Juil 2010, 05:28
Localisation: haut de Seine

Re: Problème produits apparentés

Messagepar LeorLindel » 22 Nov 2011, 12:38

Bonjour,

Dans le fichier admin/model/catalog/product.php :

Chercher ces lignes :
Code: Tout sélectionner
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_related SET product_id = '" . (int)$product_id . "', related_id = '" . (int)$related_id . "'");
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_related SET product_id = '" . (int)$related_id . "', related_id = '" . (int)$product_id . "'");
Et et les remplacer par celles-ci :
Code: Tout sélectionner
            $this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$product_id . "' AND related_id = '" . (int)$related_id . "'");
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_related SET product_id = '" . (int)$product_id . "', related_id = '" . (int)$related_id . "'");
            $this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$related_id . "' AND related_id = '" . (int)$product_id . "'");
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_related SET product_id = '" . (int)$related_id . "', related_id = '" . (int)$product_id . "'");
Chercher cette ligne (188) :
Code: Tout sélectionner
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$product_id . "'");
Ajouter cette ligne dessous :
Code: Tout sélectionner
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE related_id = '" . (int)$product_id . "'");
Chercher cette ligne (191) :
Code: Tout sélectionner
         foreach ($data['product_related'] as $related_id) {
Ajouter cette ligne dessous :
Code: Tout sélectionner
            $this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$product_id . "' AND related_id = '" . (int)$related_id . "'");
Chercher cette ligne (258) :
Code: Tout sélectionner
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$product_id . "'");
Ajouter cette ligne dessous :
Code: Tout sélectionner
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE related_id = '" . (int)$product_id . "'");

Rappel : Avant toute modification, penser à faire une sauvegarde.
Image
1 - A lire avant de poster un sujet
2 - Politique sur la signature.

Quand le sujet est résolu, pensez à ajouter la petite coche verte Image dans le titre initial en éditant votre premier message et non dans votre dernière réponse.
Merci


Toutes les extensions commerciales (templates ou modules payants) ne peuvent pas faire l'objet d'ouverture de sujet, prière de bien vouloir s'adresser au concepteur en cas de problème ou demande de renseignements.

Seul, on avance plus vite, à plusieurs on avance plus loin.
Avatar de l’utilisateur
LeorLindel
Administrateur
Administrateur
 
Messages: 4227
Inscription: 19 Fév 2010, 13:44
Localisation: Lutéce

Re: Problème produits apparentés

Messagepar cricri92 » 28 Nov 2011, 10:20

merci pour ta réponse, j'ai effectué les modifications demandées, mais j'ai toujours le même problème.
Version Opencart 1.4.8 Fr sur serveur Infomaniak
Version Opencart 1.5.4.1 sur JOOMLA avec module AceShop
modules additionnels : CMS Categories, Stock report, Product extra fields, Poll, Visiteur counter, NextAndPreviousProductLink, MiniSlider
Avatar de l’utilisateur
cricri92
Utilisateur enregistré
Utilisateur enregistré
 
Messages: 138
Inscription: 02 Juil 2010, 05:28
Localisation: haut de Seine

Re: Problème produits apparentés

Messagepar LeorLindel » 28 Nov 2011, 11:19

As-tu fait l'essai en modifiant tes fiches produits et en remettant pour celles-ci les produits apparentés désirés ?
Image
1 - A lire avant de poster un sujet
2 - Politique sur la signature.

Quand le sujet est résolu, pensez à ajouter la petite coche verte Image dans le titre initial en éditant votre premier message et non dans votre dernière réponse.
Merci


Toutes les extensions commerciales (templates ou modules payants) ne peuvent pas faire l'objet d'ouverture de sujet, prière de bien vouloir s'adresser au concepteur en cas de problème ou demande de renseignements.

Seul, on avance plus vite, à plusieurs on avance plus loin.
Avatar de l’utilisateur
LeorLindel
Administrateur
Administrateur
 
Messages: 4227
Inscription: 19 Fév 2010, 13:44
Localisation: Lutéce

Re: Problème produits apparentés

Messagepar cricri92 » 28 Nov 2011, 12:04

oui
J'ai repris une fiche, j'ai sélectionner une catégorie puis les produits que j'ai transférer dans la partie droite et enfin j'ai enregisté la fiche. Tout est bon dans la boutique, mais dans la partie "admin", je n'ai toujours pas mes produits apparentés afficher.
C'est un truc de ouf...
Version Opencart 1.4.8 Fr sur serveur Infomaniak
Version Opencart 1.5.4.1 sur JOOMLA avec module AceShop
modules additionnels : CMS Categories, Stock report, Product extra fields, Poll, Visiteur counter, NextAndPreviousProductLink, MiniSlider
Avatar de l’utilisateur
cricri92
Utilisateur enregistré
Utilisateur enregistré
 
Messages: 138
Inscription: 02 Juil 2010, 05:28
Localisation: haut de Seine

Re: Problème produits apparentés

Messagepar LeorLindel » 28 Nov 2011, 12:20

Peux-tu mettre tes fichiers :

- admin/controller/catalog/product.php
- admin/model/catalog/product.php
- admin/view/template/catalog/product_form.tpl et product_list.tpl

Que l'on regarde.
Image
1 - A lire avant de poster un sujet
2 - Politique sur la signature.

Quand le sujet est résolu, pensez à ajouter la petite coche verte Image dans le titre initial en éditant votre premier message et non dans votre dernière réponse.
Merci


Toutes les extensions commerciales (templates ou modules payants) ne peuvent pas faire l'objet d'ouverture de sujet, prière de bien vouloir s'adresser au concepteur en cas de problème ou demande de renseignements.

Seul, on avance plus vite, à plusieurs on avance plus loin.
Avatar de l’utilisateur
LeorLindel
Administrateur
Administrateur
 
Messages: 4227
Inscription: 19 Fév 2010, 13:44
Localisation: Lutéce

Re: Problème produits apparentés

Messagepar cricri92 » 28 Nov 2011, 13:03

admin/controller/catalog/product.php
Code: Tout sélectionner
<?php
class ControllerCatalogProduct extends Controller {
   private $error = array();
     
     public function index() {
      $this->load->language('catalog/product');
       
      $this->document->title = $this->language->get('heading_title');
      
      $this->load->model('catalog/product');
      
      $this->getList();
     }
 
     public function insert() {
       $this->load->language('catalog/product');

       $this->document->title = $this->language->get('heading_title');
      
      $this->load->model('catalog/product');
      
       if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
         $this->model_catalog_product->addProduct($this->request->post);
           
         $this->session->data['success'] = $this->language->get('text_success');
    
         $url = '';
         
         if (isset($this->request->get['filter_name'])) {
            $url .= '&filter_name=' . $this->request->get['filter_name'];
         }
      
         if (isset($this->request->get['filter_model'])) {
            $url .= '&filter_model=' . $this->request->get['filter_model'];
         }
         
         if (isset($this->request->get['filter_quantity'])) {
            $url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
         }
         
//filter category start//
         if (isset($this->request->get['filter_category'])) {
                                $url .= '&filter_category=' . $this->request->get['filter_category'];
                        }
//filter category end//

         if (isset($this->request->get['filter_status'])) {
            $url .= '&filter_status=' . $this->request->get['filter_status'];
         }
               
         if (isset($this->request->get['page'])) {
            $url .= '&page=' . $this->request->get['page'];
         }

         if (isset($this->request->get['sort'])) {
            $url .= '&sort=' . $this->request->get['sort'];
         }

         if (isset($this->request->get['order'])) {
            $url .= '&order=' . $this->request->get['order'];
         }
         
         $this->redirect(HTTPS_SERVER . 'index.php?route=catalog/product&token=' . $this->session->data['token'] . $url);
       }
   
       $this->getForm();
     }

     public function update() {
       $this->load->language('catalog/product');

       $this->document->title = $this->language->get('heading_title');
      
      $this->load->model('catalog/product');
   
       if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
         $this->model_catalog_product->editProduct($this->request->get['product_id'], $this->request->post);
         
         $this->session->data['success'] = $this->language->get('text_success');
         
         $url = '';
         
         if (isset($this->request->get['filter_name'])) {
            $url .= '&filter_name=' . $this->request->get['filter_name'];
         }
      
         if (isset($this->request->get['filter_model'])) {
            $url .= '&filter_model=' . $this->request->get['filter_model'];
         }
         
         if (isset($this->request->get['filter_quantity'])) {
            $url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
         }   
//filter category start//
         if (isset($this->request->get['filter_category'])) {
                                $url .= '&filter_category=' . $this->request->get['filter_category'];
                        }
//filter category end//
         if (isset($this->request->get['filter_status'])) {
            $url .= '&filter_status=' . $this->request->get['filter_status'];
         }
               
         if (isset($this->request->get['page'])) {
            $url .= '&page=' . $this->request->get['page'];
         }

         if (isset($this->request->get['sort'])) {
            $url .= '&sort=' . $this->request->get['sort'];
         }

         if (isset($this->request->get['order'])) {
            $url .= '&order=' . $this->request->get['order'];
         }
         
         $this->redirect(HTTPS_SERVER . 'index.php?route=catalog/product&token=' . $this->session->data['token'] . $url);
      }

       $this->getForm();
     }

     public function delete() {
       $this->load->language('catalog/product');

       $this->document->title = $this->language->get('heading_title');
      
      $this->load->model('catalog/product');
      
      if (isset($this->request->post['selected']) && $this->validateDelete()) {
         foreach ($this->request->post['selected'] as $product_id) {
            $this->model_catalog_product->deleteProduct($product_id);
           }

         $this->session->data['success'] = $this->language->get('text_success');
         
         $url = '';
         
         if (isset($this->request->get['filter_name'])) {
            $url .= '&filter_name=' . $this->request->get['filter_name'];
         }
      
         if (isset($this->request->get['filter_model'])) {
            $url .= '&filter_model=' . $this->request->get['filter_model'];
         }
         
         if (isset($this->request->get['filter_quantity'])) {
            $url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
         }   
      
//filter category start//
         if (isset($this->request->get['filter_category'])) {
                                $url .= '&filter_category=' . $this->request->get['filter_category'];
                        }
//filter category end//
         if (isset($this->request->get['filter_status'])) {
            $url .= '&filter_status=' . $this->request->get['filter_status'];
         }
               
         if (isset($this->request->get['page'])) {
            $url .= '&page=' . $this->request->get['page'];
         }

         if (isset($this->request->get['sort'])) {
            $url .= '&sort=' . $this->request->get['sort'];
         }

         if (isset($this->request->get['order'])) {
            $url .= '&order=' . $this->request->get['order'];
         }
         
         $this->redirect(HTTPS_SERVER . 'index.php?route=catalog/product&token=' . $this->session->data['token'] . $url);
      }

       $this->getList();
     }

     public function copy() {
       $this->load->language('catalog/product');

       $this->document->title = $this->language->get('heading_title');
      
      $this->load->model('catalog/product');
      
      if (isset($this->request->post['selected']) && $this->validateCopy()) {
         foreach ($this->request->post['selected'] as $product_id) {
            $this->model_catalog_product->copyProduct($product_id);
           }

         $this->session->data['success'] = $this->language->get('text_success');
         
         $url = '';
         
         if (isset($this->request->get['filter_name'])) {
            $url .= '&filter_name=' . $this->request->get['filter_name'];
         }
      
         if (isset($this->request->get['filter_model'])) {
            $url .= '&filter_model=' . $this->request->get['filter_model'];
         }
         
         if (isset($this->request->get['filter_quantity'])) {
            $url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
         }   
      
//filter category start//
         if (isset($this->request->get['filter_category'])) {
                                $url .= '&filter_category=' . $this->request->get['filter_category'];
                        }
//filter category end//

         if (isset($this->request->get['filter_status'])) {
            $url .= '&filter_status=' . $this->request->get['filter_status'];
         }
               
         if (isset($this->request->get['page'])) {
            $url .= '&page=' . $this->request->get['page'];
         }

         if (isset($this->request->get['sort'])) {
            $url .= '&sort=' . $this->request->get['sort'];
         }

         if (isset($this->request->get['order'])) {
            $url .= '&order=' . $this->request->get['order'];
         }
         
         $this->redirect(HTTPS_SERVER . 'index.php?route=catalog/product&token=' . $this->session->data['token'] . $url);
      }

       $this->getList();
     }
   
     private function getList() {            
      if (isset($this->request->get['page'])) {
         $page = $this->request->get['page'];
      } else {
         $page = 1;
      }
      
      if (isset($this->request->get['sort'])) {
         $sort = $this->request->get['sort'];
      } else {
         $sort = 'pd.name';
      }
      
      if (isset($this->request->get['order'])) {
         $order = $this->request->get['order'];
      } else {
         $order = 'ASC';
      }

      if (isset($this->request->get['filter_name'])) {
         $filter_name = $this->request->get['filter_name'];
      } else {
         $filter_name = NULL;
      }

      if (isset($this->request->get['filter_model'])) {
         $filter_model = $this->request->get['filter_model'];
      } else {
         $filter_model = NULL;
      }

      if (isset($this->request->get['filter_quantity'])) {
         $filter_quantity = $this->request->get['filter_quantity'];
      } else {
         $filter_quantity = NULL;
      }

//filter category start//
      if (isset($this->request->get['filter_category'])) {
         $filter_category = $this->request->get['filter_category'];
      } else {
         $filter_category = NULL;
      }
//filter category end//

      if (isset($this->request->get['filter_status'])) {
         $filter_status = $this->request->get['filter_status'];
      } else {
         $filter_status = NULL;
      }
      
      $url = '';
                  
      if (isset($this->request->get['filter_name'])) {
         $url .= '&filter_name=' . $this->request->get['filter_name'];
      }
      
      if (isset($this->request->get['filter_model'])) {
         $url .= '&filter_model=' . $this->request->get['filter_model'];
      }
      
      if (isset($this->request->get['filter_quantity'])) {
         $url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
      }      

//filter category start//
      if (isset($this->request->get['filter_category'])) {
         $url .= '&filter_category=' . $this->request->get['filter_category'];
      }
//filter category end//

                if (isset($this->request->get['filter_status'])) {
         $url .= '&filter_status=' . $this->request->get['filter_status'];
      }
                  
      if (isset($this->request->get['page'])) {
         $url .= '&page=' . $this->request->get['page'];
      }
      
      if (isset($this->request->get['sort'])) {
         $url .= '&sort=' . $this->request->get['sort'];
      }

      if (isset($this->request->get['order'])) {
         $url .= '&order=' . $this->request->get['order'];
      }

        $this->document->breadcrumbs = array();

         $this->document->breadcrumbs[] = array(
             'href'      => HTTPS_SERVER . 'index.php?route=common/home&token=' . $this->session->data['token'],
             'text'      => $this->language->get('text_home'),
            'separator' => FALSE
         );

         $this->document->breadcrumbs[] = array(
             'href'      => HTTPS_SERVER . 'index.php?route=catalog/product&token=' . $this->session->data['token'] . $url,
             'text'      => $this->language->get('heading_title'),
            'separator' => ' :: '
         );
      
      $this->data['insert'] = HTTPS_SERVER . 'index.php?route=catalog/product/insert&token=' . $this->session->data['token'] . $url;
      $this->data['copy'] = HTTPS_SERVER . 'index.php?route=catalog/product/copy&token=' . $this->session->data['token'] . $url;   
      $this->data['delete'] = HTTPS_SERVER . 'index.php?route=catalog/product/delete&token=' . $this->session->data['token'] . $url;
       
      $this->data['products'] = array();

      $data = array(
         'filter_name'     => $filter_name,
         'filter_model'     => $filter_model,
         'filter_quantity' => $filter_quantity,
//filter category start//
                        'filter_category' => $filter_category,
//filter category end//
         'filter_status'   => $filter_status,
         'sort'            => $sort,
         'order'           => $order,
         'start'           => ($page - 1) * $this->config->get('config_admin_limit'),
         'limit'           => $this->config->get('config_admin_limit')
      );
      
      $this->load->model('tool/image');
      
      $product_total = $this->model_catalog_product->getTotalProducts($data);
         
      $results = $this->model_catalog_product->getProducts($data);
      $this->data['product_total'] = $product_total;
      $results = $this->model_catalog_product->getProducts($data);
      
//filter category start//
      $this->load->model('catalog/category');
      $this->data['categories'] = $this->model_catalog_category->getCategories(0);
//filter category end//

      foreach ($results as $result) {
         $action = array();
         
         $action[] = array(
            'text' => $this->language->get('text_edit'),
            'href' => HTTPS_SERVER . 'index.php?route=catalog/product/update&token=' . $this->session->data['token'] . '&product_id=' . $result['product_id'] . $url
         );
         
//filter category start//
                $category =  $this->model_catalog_product->getProductCategories($result['product_id']);
//filter category end//

         if ($result['image'] && file_exists(DIR_IMAGE . $result['image'])) {
            $image = $this->model_tool_image->resize($result['image'], 40, 40);
         } else {
            $image = $this->model_tool_image->resize('no_image.jpg', 40, 40);
         }
         
            $this->data['products'][] = array(
            'product_id' => $result['product_id'],
            'name'       => $result['name'],
            'model'      => $result['model'],
//filter category start//
            'category'   => $category,
//filter category end//
            'image'      => $image,
            'quantity'   => $result['quantity'],
            'status'     => ($result['status'] ? $this->language->get('text_enabled') : $this->language->get('text_disabled')),
            'selected'   => isset($this->request->post['selected']) && in_array($result['product_id'], $this->request->post['selected']),
            'action'     => $action
         );
       }
      
      $this->data['heading_title'] = $this->language->get('heading_title');

      $this->data['text_enabled'] = $this->language->get('text_enabled');
      $this->data['text_disabled'] = $this->language->get('text_disabled');
      $this->data['text_no_results'] = $this->language->get('text_no_results');
      $this->data['text_image_manager'] = $this->language->get('text_image_manager');

      $this->data['column_image'] = $this->language->get('column_image');
      $this->data['column_name'] = $this->language->get('column_name');
                $this->data['column_model'] = $this->language->get('column_model');
//filter category start//
                $this->data['column_category'] = $this->language->get('column_category');
//filter category end//
      $this->data['column_quantity'] = $this->language->get('column_quantity');
      $this->data['column_status'] = $this->language->get('column_status');
      $this->data['column_action'] = $this->language->get('column_action');
      
      $this->data['button_copy'] = $this->language->get('button_copy');
      $this->data['button_insert'] = $this->language->get('button_insert');
      $this->data['button_delete'] = $this->language->get('button_delete');
      $this->data['button_filter'] = $this->language->get('button_filter');
 
       $this->data['token'] = $this->session->data['token'];
      
       if (isset($this->error['warning'])) {
         $this->data['error_warning'] = $this->error['warning'];
      } else {
         $this->data['error_warning'] = '';
      }

      if (isset($this->session->data['success'])) {
         $this->data['success'] = $this->session->data['success'];
      
         unset($this->session->data['success']);
      } else {
         $this->data['success'] = '';
      }

      $url = '';

      if (isset($this->request->get['filter_name'])) {
         $url .= '&filter_name=' . $this->request->get['filter_name'];
      }
      
      if (isset($this->request->get['filter_model'])) {
         $url .= '&filter_model=' . $this->request->get['filter_model'];
      }
//filter category start//
      if (isset($this->request->get['filter_category'])) {
         $url .= '&filter_category=' . $this->request->get['filter_category'];
      }
//filter category end//
      if (isset($this->request->get['filter_quantity'])) {
         $url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
      }
      
      if (isset($this->request->get['filter_status'])) {
         $url .= '&filter_status=' . $this->request->get['filter_status'];
      }
                        
      if ($order == 'ASC') {
         $url .= '&order=DESC';
      } else {
         $url .= '&order=ASC';
      }

      if (isset($this->request->get['page'])) {
         $url .= '&page=' . $this->request->get['page'];
      }
               
      $this->data['sort_name'] = HTTPS_SERVER . 'index.php?route=catalog/product&token=' . $this->session->data['token'] . '&sort=pd.name' . $url;
      $this->data['sort_model'] = HTTPS_SERVER . 'index.php?route=catalog/product&token=' . $this->session->data['token'] . '&sort=p.model' . $url;
      $this->data['sort_quantity'] = HTTPS_SERVER . 'index.php?route=catalog/product&token=' . $this->session->data['token'] . '&sort=p.quantity' . $url;
//filter category start//
      $this->data['sort_category'] = HTTPS_SERVER . 'index.php?route=catalog/product&token=' . $this->session->data['token'] . '&sort=category' . $url;
//filter category end//
                $this->data['sort_status'] = HTTPS_SERVER . 'index.php?route=catalog/product&token=' . $this->session->data['token'] . '&sort=p.status' . $url;
      $this->data['sort_order'] = HTTPS_SERVER . 'index.php?route=catalog/product&token=' . $this->session->data['token'] . '&sort=p.sort_order' . $url;
      
      $url = '';

      if (isset($this->request->get['filter_name'])) {
         $url .= '&filter_name=' . $this->request->get['filter_name'];
      }
      
      if (isset($this->request->get['filter_model'])) {
         $url .= '&filter_model=' . $this->request->get['filter_model'];
      }
//filter category start//
      if (isset($this->request->get['filter_category'])) {
         $url .= '&filter_category=' . $this->request->get['filter_category'];
      }
//filter category end//
      if (isset($this->request->get['filter_quantity'])) {
         $url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
      }

      if (isset($this->request->get['filter_status'])) {
         $url .= '&filter_status=' . $this->request->get['filter_status'];
      }

      if (isset($this->request->get['sort'])) {
         $url .= '&sort=' . $this->request->get['sort'];
      }
                                    
      if (isset($this->request->get['order'])) {
         $url .= '&order=' . $this->request->get['order'];
      }
            
      $pagination = new Pagination();
      $pagination->total = $product_total;
      $pagination->page = $page;
      $pagination->limit = $this->config->get('config_admin_limit');
      $pagination->text = $this->language->get('text_pagination');
      $pagination->url = HTTPS_SERVER . 'index.php?route=catalog/product&token=' . $this->session->data['token'] . $url . '&page={page}';
         
      $this->data['pagination'] = $pagination->render();
   
      $this->data['filter_name'] = $filter_name;
      $this->data['filter_model'] = $filter_model;
//filter category start//
      $this->data['filter_category'] = $filter_category;
//filter category end//
      $this->data['filter_quantity'] = $filter_quantity;
      $this->data['filter_status'] = $filter_status;
      
      $this->data['sort'] = $sort;
      $this->data['order'] = $order;

      $this->template = 'catalog/product_list.tpl';
      $this->children = array(
         'common/header',   
         'common/footer'   
      );
      
      $this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
     }

     private function getForm() {
                $this->data['heading_title'] = $this->language->get('heading_title');
 
                $this->data['text_enabled'] = $this->language->get('text_enabled');
                $this->data['text_disabled'] = $this->language->get('text_disabled');
                $this->data['text_none'] = $this->language->get('text_none');
          $this->data['text_confirm_cancel'] = $this->language->get('text_confirm_cancel');
                $this->data['text_yes'] = $this->language->get('text_yes');
                $this->data['text_no'] = $this->language->get('text_no');
      $this->data['text_plus'] = $this->language->get('text_plus');
      $this->data['text_minus'] = $this->language->get('text_minus');
      $this->data['text_default'] = $this->language->get('text_default');
      $this->data['text_image_manager'] = $this->language->get('text_image_manager');
      $this->data['text_option'] = $this->language->get('text_option');
      $this->data['text_option_value'] = $this->language->get('text_option_value');
      $this->data['text_select'] = $this->language->get('text_select');
      $this->data['text_none'] = $this->language->get('text_none');
      
      $this->data['tab_shipping'] = $this->language->get('tab_shipping');
      $this->data['tab_links'] = $this->language->get('tab_links');
      
      $this->data['entry_name'] = $this->language->get('entry_name');
      $this->data['entry_meta_keywords'] = $this->language->get('entry_meta_keywords');
      $this->data['entry_meta_description'] = $this->language->get('entry_meta_description');
      $this->data['entry_description'] = $this->language->get('entry_description');
      $this->data['entry_store'] = $this->language->get('entry_store');
      $this->data['entry_keyword'] = $this->language->get('entry_keyword');
       $this->data['entry_model'] = $this->language->get('entry_model');
      $this->data['entry_sku'] = $this->language->get('entry_sku');
      $this->data['entry_location'] = $this->language->get('entry_location');
      $this->data['entry_minimum'] = $this->language->get('entry_minimum');
      $this->data['entry_manufacturer'] = $this->language->get('entry_manufacturer');
       $this->data['entry_shipping'] = $this->language->get('entry_shipping');
       $this->data['entry_date_available'] = $this->language->get('entry_date_available');
       $this->data['entry_quantity'] = $this->language->get('entry_quantity');
      $this->data['entry_stock_status'] = $this->language->get('entry_stock_status');
       $this->data['entry_status'] = $this->language->get('entry_status');
       $this->data['entry_tax_class'] = $this->language->get('entry_tax_class');
       $this->data['entry_price'] = $this->language->get('entry_price');
      $this->data['entry_display_call_for_price'] = $this->language->get('entry_display_call_for_price'); // call for price
      $this->data['entry_label_call_for_price'] = $this->language->get('entry_label_call_for_price'); // call for price
      $this->data['entry_cost'] = $this->language->get('entry_cost');
      $this->data['entry_subtract'] = $this->language->get('entry_subtract');
       $this->data['entry_weight_class'] = $this->language->get('entry_weight_class');
       $this->data['entry_weight'] = $this->language->get('entry_weight');
      $this->data['entry_dimension'] = $this->language->get('entry_dimension');
      $this->data['entry_length'] = $this->language->get('entry_length');
       $this->data['entry_image'] = $this->language->get('entry_image');
       $this->data['entry_download'] = $this->language->get('entry_download');
       $this->data['entry_category'] = $this->language->get('entry_category');
      $this->data['entry_related'] = $this->language->get('entry_related');
      $this->data['entry_option'] = $this->language->get('entry_option');
      $this->data['entry_option_value'] = $this->language->get('entry_option_value');
      $this->data['entry_extra_field_value'] = $this->language->get('entry_extra_field_value');
      $this->data['entry_sort_order'] = $this->language->get('entry_sort_order');
      $this->data['entry_prefix'] = $this->language->get('entry_prefix');
      $this->data['entry_customer_group'] = $this->language->get('entry_customer_group');
      $this->data['entry_date_start'] = $this->language->get('entry_date_start');
      $this->data['entry_date_end'] = $this->language->get('entry_date_end');
      $this->data['entry_priority'] = $this->language->get('entry_priority');
      $this->data['entry_tags'] = $this->language->get('entry_tags');
      
       $this->data['button_save'] = $this->language->get('button_save');
       $this->data['button_cancel'] = $this->language->get('button_cancel');
      $this->data['button_add_option'] = $this->language->get('button_add_option');
      $this->data['button_add_option_value'] = $this->language->get('button_add_option_value');
      $this->data['button_add_discount'] = $this->language->get('button_add_discount');
      $this->data['button_add_special'] = $this->language->get('button_add_special');
      $this->data['button_add_image'] = $this->language->get('button_add_image');
      $this->data['button_remove'] = $this->language->get('button_remove');
      
       $this->data['tab_general'] = $this->language->get('tab_general');
       $this->data['tab_data'] = $this->language->get('tab_data');
      $this->data['tab_discount'] = $this->language->get('tab_discount');
      $this->data['tab_special'] = $this->language->get('tab_special');
      $this->data['tab_option'] = $this->language->get('tab_option');
       $this->data['tab_image'] = $this->language->get('tab_image');
      $this->data['tab_extra_field'] = $this->language->get('tab_extra_field');
 
       if (isset($this->error['warning'])) {
         $this->data['error_warning'] = $this->error['warning'];
      } else {
         $this->data['error_warning'] = '';
      }

       if (isset($this->error['name'])) {
         $this->data['error_name'] = $this->error['name'];
      } else {
         $this->data['error_name'] = '';
      }

       if (isset($this->error['meta_description'])) {
         $this->data['error_meta_description'] = $this->error['meta_description'];
      } else {
         $this->data['error_meta_description'] = '';
      }      
   
         if (isset($this->error['description'])) {
         $this->data['error_description'] = $this->error['description'];
      } else {
         $this->data['error_description'] = '';
      }   
      
         if (isset($this->error['model'])) {
         $this->data['error_model'] = $this->error['model'];
      } else {
         $this->data['error_model'] = '';
      }      
        
      if (isset($this->error['date_available'])) {
         $this->data['error_date_available'] = $this->error['date_available'];
      } else {
         $this->data['error_date_available'] = '';
      }   

      $url = '';

      if (isset($this->request->get['filter_name'])) {
         $url .= '&filter_name=' . $this->request->get['filter_name'];
      }
      
      if (isset($this->request->get['filter_model'])) {
         $url .= '&filter_model=' . $this->request->get['filter_model'];
      }
//filter category start//
      if (isset($this->request->get['filter_category'])) {
         $url .= '&filter_category=' . $this->request->get['filter_category'];
      }
//filter category end//
      if (isset($this->request->get['filter_quantity'])) {
         $url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
      }   
      
      if (isset($this->request->get['filter_status'])) {
         $url .= '&filter_status=' . $this->request->get['filter_status'];
      }
                        
      if (isset($this->request->get['page'])) {
         $url .= '&page=' . $this->request->get['page'];
      }
      
      if (isset($this->request->get['sort'])) {
         $url .= '&sort=' . $this->request->get['sort'];
      }

      if (isset($this->request->get['order'])) {
         $url .= '&order=' . $this->request->get['order'];
      }

        $this->document->breadcrumbs = array();

         $this->document->breadcrumbs[] = array(
             'href'      => HTTPS_SERVER . 'index.php?route=common/home&token=' . $this->session->data['token'],
             'text'      => $this->language->get('text_home'),
         'separator' => FALSE
         );

         $this->document->breadcrumbs[] = array(
             'href'      => HTTPS_SERVER . 'index.php?route=catalog/product&token=' . $this->session->data['token'] . $url,
             'text'      => $this->language->get('heading_title'),
            'separator' => ' :: '
         );
                           
      if (!isset($this->request->get['product_id'])) {
         $this->data['action'] = HTTPS_SERVER . 'index.php?route=catalog/product/insert&token=' . $this->session->data['token'] . $url;
      } else {
         $this->data['action'] = HTTPS_SERVER . 'index.php?route=catalog/product/update&token=' . $this->session->data['token'] . '&product_id=' . $this->request->get['product_id'] . $url;
      }
      
      $this->data['cancel'] = HTTPS_SERVER . 'index.php?route=catalog/product&token=' . $this->session->data['token'] . $url;

      $this->data['token'] = $this->session->data['token'];

      if (isset($this->request->get['product_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
            $product_info = $this->model_catalog_product->getProduct($this->request->get['product_id']);
       }

      $this->load->model('localisation/language');
      
      $this->data['languages'] = $this->model_localisation_language->getLanguages();
      
      if (isset($this->request->post['product_description'])) {
         $this->data['product_description'] = $this->request->post['product_description'];
      } elseif (isset($product_info)) {
         $this->data['product_description'] = $this->model_catalog_product->getProductDescriptions($this->request->get['product_id']);
      } else {
         $this->data['product_description'] = array();
      }
      
      if (isset($this->request->post['product_extra_field'])) {
         $this->data['product_extra_fields'] = $this->request->post['product_extra_field'];
      } elseif (isset($product_info)) {
         $this->data['product_extra_fields'] = $this->model_catalog_product->getProductExtrafields($this->request->get['product_id']);
      } else {
         $this->data['product_extra_fields'] = array();
      }
      
      if (isset($this->request->post['model'])) {
            $this->data['model'] = $this->request->post['model'];
       } elseif (isset($product_info)) {
         $this->data['model'] = $product_info['model'];
      } else {
            $this->data['model'] = '';
       }

      if (isset($this->request->post['sku'])) {
            $this->data['sku'] = $this->request->post['sku'];
       } elseif (isset($product_info)) {
         $this->data['sku'] = $product_info['sku'];
      } else {
            $this->data['sku'] = '';
       }
      
      if (isset($this->request->post['location'])) {
            $this->data['location'] = $this->request->post['location'];
       } elseif (isset($product_info)) {
         $this->data['location'] = $product_info['location'];
      } else {
            $this->data['location'] = '';
       }

      $this->load->model('setting/store');
      
      $this->data['stores'] = $this->model_setting_store->getStores();
      
      if (isset($this->request->post['product_store'])) {
         $this->data['product_store'] = $this->request->post['product_store'];
      } elseif (isset($product_info)) {
         $this->data['product_store'] = $this->model_catalog_product->getProductStores($this->request->get['product_id']);
      } else {
         $this->data['product_store'] = array(0);
      }   
      
      if (isset($this->request->post['keyword'])) {
         $this->data['keyword'] = $this->request->post['keyword'];
      } elseif (isset($product_info)) {
         $this->data['keyword'] = $product_info['keyword'];
      } else {
         $this->data['keyword'] = '';
      }
      
      if (isset($this->request->post['product_tags'])) {
         $this->data['product_tags'] = $this->request->post['product_tags'];
      } elseif (isset($product_info)) {
         $this->data['product_tags'] = $this->model_catalog_product->getProductTags($this->request->get['product_id']);
      } else {
         $this->data['product_tags'] = array();
      }
      
      if (isset($this->request->post['image'])) {
         $this->data['image'] = $this->request->post['image'];
      } elseif (isset($product_info)) {
         $this->data['image'] = $product_info['image'];
      } else {
         $this->data['image'] = '';
      }
      
      $this->load->model('tool/image');
      
      if (isset($product_info) && $product_info['image'] && file_exists(DIR_IMAGE . $product_info['image'])) {
         $this->data['preview'] = $this->model_tool_image->resize($product_info['image'], 100, 100);
      } else {
         $this->data['preview'] = $this->model_tool_image->resize('no_image.jpg', 100, 100);
      }
   
      $this->load->model('catalog/manufacturer');
      
       $this->data['manufacturers'] = $this->model_catalog_manufacturer->getManufacturers();

       if (isset($this->request->post['manufacturer_id'])) {
            $this->data['manufacturer_id'] = $this->request->post['manufacturer_id'];
      } elseif (isset($product_info)) {
         $this->data['manufacturer_id'] = $product_info['manufacturer_id'];
      } else {
            $this->data['manufacturer_id'] = 0;
       }
      
       if (isset($this->request->post['shipping'])) {
            $this->data['shipping'] = $this->request->post['shipping'];
       } elseif (isset($product_info)) {
            $this->data['shipping'] = $product_info['shipping'];
       } else {
         $this->data['shipping'] = 1;
      }
         
      if (isset($this->request->post['date_available'])) {
             $this->data['date_available'] = $this->request->post['date_available'];
      } elseif (isset($product_info)) {
         $this->data['date_available'] = date('Y-m-d', strtotime($product_info['date_available']));
      } else {
         $this->data['date_available'] = date('Y-m-d', time()-86400);
      }
                                 
       if (isset($this->request->post['quantity'])) {
            $this->data['quantity'] = $this->request->post['quantity'];
       } elseif (isset($product_info)) {
            $this->data['quantity'] = $product_info['quantity'];
       } else {
         $this->data['quantity'] = 1;
      }
      
      if (isset($this->request->post['minimum'])) {
            $this->data['minimum'] = $this->request->post['minimum'];
       } elseif (isset($product_info)) {
            $this->data['minimum'] = $product_info['minimum'];
       } else {
         $this->data['minimum'] = 1;
      }
      
      if (isset($this->request->post['subtract'])) {
            $this->data['subtract'] = $this->request->post['subtract'];
       } elseif (isset($product_info)) {
            $this->data['subtract'] = $product_info['subtract'];
       } else {
         $this->data['subtract'] = 1;
      }
      
      if (isset($this->request->post['sort_order'])) {
            $this->data['sort_order'] = $this->request->post['sort_order'];
       } elseif (isset($product_info)) {
            $this->data['sort_order'] = $product_info['sort_order'];
       } else {
         $this->data['sort_order'] = 1;
      }

      $this->load->model('localisation/stock_status');
      
      $this->data['stock_statuses'] = $this->model_localisation_stock_status->getStockStatuses();
       
      if (isset($this->request->post['stock_status_id'])) {
            $this->data['stock_status_id'] = $this->request->post['stock_status_id'];
       } else if (isset($product_info)) {
            $this->data['stock_status_id'] = $product_info['stock_status_id'];
       } else {
         $this->data['stock_status_id'] = $this->config->get('config_stock_status_id');
      }
      
       if (isset($this->request->post['price'])) {
            $this->data['price'] = $this->request->post['price'];
       } else if (isset($product_info)) {
         $this->data['price'] = $product_info['price'];
      } else {
            $this->data['price'] = '';
       }
      
       if (isset($this->request->post['call_for_price'])) {
            $this->data['call_for_price'] = $this->request->post['call_for_price'];
       } else if (isset($product_info)) {
         $this->data['call_for_price'] = $product_info['call_for_price'];
      } else {
            $this->data['call_for_price'] = '';
       }
      
      if (isset($this->request->post['cost'])) {
            $this->data['cost'] = $this->request->post['cost'];
       } else if (isset($product_info)) {
         $this->data['cost'] = $product_info['cost'];
      } else {
            $this->data['cost'] = '';
       }

       if (isset($this->request->post['status'])) {
            $this->data['status'] = $this->request->post['status'];
       } else if (isset($product_info)) {
         $this->data['status'] = $product_info['status'];
      } else {
            $this->data['status'] = 1;
       }
      
      $this->load->model('localisation/tax_class');
      
      $this->data['tax_classes'] = $this->model_localisation_tax_class->getTaxClasses();
       
      if (isset($this->request->post['tax_class_id'])) {
            $this->data['tax_class_id'] = $this->request->post['tax_class_id'];
       } else if (isset($product_info)) {
         $this->data['tax_class_id'] = $product_info['tax_class_id'];
      } else {
            $this->data['tax_class_id'] = 0;
       }

       if (isset($this->request->post['weight'])) {
            $this->data['weight'] = $this->request->post['weight'];
      } else if (isset($product_info)) {
         $this->data['weight'] = $product_info['weight'];
       } else {
            $this->data['weight'] = '';
       }
      
      $this->load->model('localisation/weight_class');
      
      $this->data['weight_classes'] = $this->model_localisation_weight_class->getWeightClasses();
       
       $weight_info = $this->model_localisation_weight_class->getWeightClassDescriptionByUnit($this->config->get('config_weight_class'));
       
      if (isset($this->request->post['weight_class_id'])) {
            $this->data['weight_class_id'] = $this->request->post['weight_class_id'];
       } elseif (isset($product_info)) {
            $this->data['weight_class_id'] = $product_info['weight_class_id'];
       } elseif (isset($weight_info)) {
            $this->data['weight_class_id'] = $weight_info['weight_class_id'];
      } else {
            $this->data['weight_class_id'] = '';
       }
      
      if (isset($this->request->post['length'])) {
            $this->data['length'] = $this->request->post['length'];
       } elseif (isset($product_info)) {
         $this->data['length'] = $product_info['length'];
      } else {
            $this->data['length'] = '';
       }
      
      if (isset($this->request->post['width'])) {
            $this->data['width'] = $this->request->post['width'];
      } elseif (isset($product_info)) {   
         $this->data['width'] = $product_info['width'];
       } else {
            $this->data['width'] = '';
       }
      
      if (isset($this->request->post['height'])) {
            $this->data['height'] = $this->request->post['height'];
      } elseif (isset($product_info)) {
         $this->data['height'] = $product_info['height'];
       } else {
            $this->data['height'] = '';
       }

      $this->load->model('localisation/length_class');
      
      $this->data['length_classes'] = $this->model_localisation_length_class->getLengthClasses();
       
       $length_info = $this->model_localisation_length_class->getLengthClassDescriptionByUnit($this->config->get('config_length_class'));
       
      if (isset($this->request->post['length_class_id'])) {
            $this->data['length_class_id'] = $this->request->post['length_class_id'];
       } elseif (isset($product_info)) {
            $this->data['length_class_id'] = $product_info['length_class_id'];
       } elseif (isset($length_info)) {
            $this->data['length_class_id'] = $length_info['length_class_id'];
       } else {
          $this->data['length_class_id'] = '';
      }
      
      $this->data['language_id'] = $this->config->get('config_language_id');
      
      if (isset($this->request->post['product_option'])) {
         $this->data['product_options'] = $this->request->post['product_option'];
      } elseif (isset($product_info)) {
         $this->data['product_options'] = $this->model_catalog_product->getProductOptions($this->request->get['product_id']);
      } else {
         $this->data['product_options'] = array();
      }
      
      $this->load->model('sale/customer_group');
      
      $this->data['customer_groups'] = $this->model_sale_customer_group->getCustomerGroups();
      
      if (isset($this->request->post['product_discount'])) {
         $this->data['product_discounts'] = $this->request->post['product_discount'];
      } elseif (isset($product_info)) {
         $this->data['product_discounts'] = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']);
      } else {
         $this->data['product_discounts'] = array();
      }

      if (isset($this->request->post['product_special'])) {
         $this->data['product_specials'] = $this->request->post['product_special'];
      } elseif (isset($product_info)) {
         $this->data['product_specials'] = $this->model_catalog_product->getProductSpecials($this->request->get['product_id']);
      } else {
         $this->data['product_specials'] = array();
      }
      
      $this->data['no_image'] = $this->model_tool_image->resize('no_image.jpg', 100, 100);
      
      $this->data['product_images'] = array();
      
      if (isset($product_info)) {
         $results = $this->model_catalog_product->getProductImages($this->request->get['product_id']);
         
         foreach ($results as $result) {
            if ($result['image'] && file_exists(DIR_IMAGE . $result['image'])) {
               $this->data['product_images'][] = array(
                  'preview' => $this->model_tool_image->resize($result['image'], 100, 100),
                  'file'    => $result['image']
               );
            } else {
               $this->data['product_images'][] = array(
                  'preview' => $this->model_tool_image->resize('no_image.jpg', 100, 100),
                  'file'    => $result['image']
               );
            }
         }
      }      

      $this->load->model('catalog/download');
      
      $this->data['downloads'] = $this->model_catalog_download->getDownloads();
      
      if (isset($this->request->post['product_download'])) {
         $this->data['product_download'] = $this->request->post['product_download'];
      } elseif (isset($product_info)) {
         $this->data['product_download'] = $this->model_catalog_product->getProductDownloads($this->request->get['product_id']);
      } else {
         $this->data['product_download'] = array();
      }      
      
      $this->load->model('catalog/category');
            
      $this->data['categories'] = $this->model_catalog_category->getCategories(0);
      
      if (isset($this->request->post['product_category'])) {
         $this->data['product_category'] = $this->request->post['product_category'];
      } elseif (isset($product_info)) {
         $this->data['product_category'] = $this->model_catalog_product->getProductCategories($this->request->get['product_id']);
      } else {
         $this->data['product_category'] = array();
      }      
      
       if (isset($this->request->post['product_related'])) {
         $this->data['product_related'] = $this->request->post['product_related'];
      } elseif (isset($product_info)) {
         $this->data['product_related'] = $this->model_catalog_product->getProductRelated($this->request->get['product_id']);
      } else {
         $this->data['product_related'] = array();
      }
            
      $this->template = 'catalog/product_form.tpl';
      $this->children = array(
         'common/header',   
         'common/footer'   
      );
      
      $this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
     }
   
     private function validateForm() {
       if (!$this->user->hasPermission('modify', 'catalog/product')) {
            $this->error['warning'] = $this->language->get('error_permission');
       }

       foreach ($this->request->post['product_description'] as $language_id => $value) {
            if ((strlen(utf8_decode($value['name'])) < 1) || (strlen(utf8_decode($value['name'])) > 255)) {
              $this->error['name'][$language_id] = $this->language->get('error_name');
            }
       }
      
       if ((strlen(utf8_decode($this->request->post['model'])) < 1) || (strlen(utf8_decode($this->request->post['model'])) > 64)) {
            $this->error['model'] = $this->language->get('error_model');
       }
      
       if (!$this->error) {
         return TRUE;
       } else {
         if (!isset($this->error['warning'])) {
            $this->error['warning'] = $this->language->get('error_required_data');
         }
            return FALSE;
       }
     }
   
     private function validateDelete() {
       if (!$this->user->hasPermission('modify', 'catalog/product')) {
            $this->error['warning'] = $this->language->get('error_permission'); 
       }
      
      if (!$this->error) {
           return TRUE;
      } else {
           return FALSE;
      }
     }
     
     private function validateCopy() {
       if (!$this->user->hasPermission('modify', 'catalog/product')) {
            $this->error['warning'] = $this->language->get('error_permission'); 
       }
      
      if (!$this->error) {
           return TRUE;
      } else {
           return FALSE;
      }
     }
   
   public function category() {
      $this->load->model('catalog/product');
      
      if (isset($this->request->get['category_id'])) {
         $category_id = $this->request->get['category_id'];
      } else {
         $category_id = 0;
      }
      
      $product_data = array();
      
      $results = $this->model_catalog_product->getProductsByCategoryId($category_id);
      
      foreach ($results as $result) {
         $product_data[] = array(
            'product_id' => $result['product_id'],
            'name'       => $result['name'],
            'model'      => $result['model']
         );
      }
      
      $this->load->library('json');
      
      $this->response->setOutput(Json::encode($product_data));
   }
   
}

?>
Version Opencart 1.4.8 Fr sur serveur Infomaniak
Version Opencart 1.5.4.1 sur JOOMLA avec module AceShop
modules additionnels : CMS Categories, Stock report, Product extra fields, Poll, Visiteur counter, NextAndPreviousProductLink, MiniSlider
Avatar de l’utilisateur
cricri92
Utilisateur enregistré
Utilisateur enregistré
 
Messages: 138
Inscription: 02 Juil 2010, 05:28
Localisation: haut de Seine

Re: Problème produits apparentés

Messagepar cricri92 » 28 Nov 2011, 13:04

admin/model/catalog/product.php
Code: Tout sélectionner
<?php
class ModelCatalogProduct extends Model {
   public function addProduct($data) {
      $this->db->query("INSERT INTO " . DB_PREFIX . "product SET model = '" . $this->db->escape($data['model']) . "', sku = '" . $this->db->escape($data['sku']) . "', location = '" . $this->db->escape($data['location']) . "', quantity = '" . (int)$data['quantity'] . "', minimum = '" . (int)$data['minimum'] . "', subtract = '" . (int)$data['subtract'] . "', stock_status_id = '" . (int)$data['stock_status_id'] . "', date_available = '" . $this->db->escape($data['date_available']) . "', manufacturer_id = '" . (int)$data['manufacturer_id'] . "', shipping = '" . (int)$data['shipping'] . "', price = '" . (float)$data['price'] . "', cost = '" . (float)$data['cost'] . "', call_for_price = '" . $this->db->escape($data['call_for_price']) . "', weight = '" . (float)$data['weight'] . "', weight_class_id = '" . (int)$data['weight_class_id'] . "', length = '" . (float)$data['length'] . "', width = '" . (float)$data['width'] . "', height = '" . (float)$data['height'] . "', length_class_id = '" . (int)$data['length_class_id'] . "', status = '" . (int)$data['status'] . "', tax_class_id = '" . (int)$data['tax_class_id'] . "', sort_order = '" . (int)$data['sort_order'] . "', date_added = NOW()");
      
      $product_id = $this->db->getLastId();
      
      if (isset($data['image'])) {
         $this->db->query("UPDATE " . DB_PREFIX . "product SET image = '" . $this->db->escape($data['image']) . "' WHERE product_id = '" . (int)$product_id . "'");
      }
      
      foreach ($data['product_description'] as $language_id => $value) {
         $this->db->query("INSERT INTO " . DB_PREFIX . "product_description SET product_id = '" . (int)$product_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', meta_keywords = '" . $this->db->escape($value['meta_keywords']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', description = '" . $this->db->escape($value['description']) . "'");
      }
      
      if (isset($data['product_store'])) {
         foreach ($data['product_store'] as $store_id) {
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_to_store SET product_id = '" . (int)$product_id . "', store_id = '" . (int)$store_id . "'");
         }
      }
      
      if (isset($data['product_option'])) {
         foreach ($data['product_option'] as $product_option) {
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_option SET product_id = '" . (int)$product_id . "', sort_order = '" . (int)$product_option['sort_order'] . "'");
            
            $product_option_id = $this->db->getLastId();
            
            foreach ($product_option['language'] as $language_id => $language) {
               $this->db->query("INSERT INTO " . DB_PREFIX . "product_option_description SET product_option_id = '" . (int)$product_option_id . "', language_id = '" . (int)$language_id . "', product_id = '" . (int)$product_id . "', name = '" . $this->db->escape($language['name']) . "'");
            }            
            
            if (isset($product_option['product_option_value'])) {
               foreach ($product_option['product_option_value'] as $product_option_value) {
                  $this->db->query("INSERT INTO " . DB_PREFIX . "product_option_value SET product_option_id = '" . (int)$product_option_id . "', product_id = '" . (int)$product_id . "', quantity = '" . (int)$product_option_value['quantity'] . "', subtract = '" . (int)$product_option_value['subtract'] . "', price = '" . (float)$product_option_value['price'] . "', prefix = '" . $this->db->escape($product_option_value['prefix']) . "', sort_order = '" . (int)$product_option_value['sort_order'] . "'");
            
                  $product_option_value_id = $this->db->getLastId();
            
                  foreach ($product_option_value['language'] as $language_id => $language) {
                     $this->db->query("INSERT INTO " . DB_PREFIX . "product_option_value_description SET product_option_value_id = '" . (int)$product_option_value_id . "', language_id = '" . (int)$language_id . "', product_id = '" . (int)$product_id . "', name = '" . $this->db->escape($language['name']) . "'");
                  }               
               }
            }
         }
      }
      
      if (isset($data['product_discount'])) {
         foreach ($data['product_discount'] as $value) {
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_discount SET product_id = '" . (int)$product_id . "', customer_group_id = '" . (int)$value['customer_group_id'] . "', quantity = '" . (int)$value['quantity'] . "', priority = '" . (int)$value['priority'] . "', price = '" . (float)$value['price'] . "', date_start = '" . $this->db->escape($value['date_start']) . "', date_end = '" . $this->db->escape($value['date_end']) . "'");
         }
      }

      if (isset($data['product_special'])) {
         foreach ($data['product_special'] as $value) {
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_special SET product_id = '" . (int)$product_id . "', customer_group_id = '" . (int)$value['customer_group_id'] . "', priority = '" . (int)$value['priority'] . "', price = '" . (float)$value['price'] . "', date_start = '" . $this->db->escape($value['date_start']) . "', date_end = '" . $this->db->escape($value['date_end']) . "'");
         }
      }
      
      if (isset($data['product_image'])) {
         foreach ($data['product_image'] as $image) {
              $this->db->query("INSERT INTO " . DB_PREFIX . "product_image SET product_id = '" . (int)$product_id . "', image = '" . $this->db->escape($image) . "'");
         }
      }
      
      if (isset($data['product_download'])) {
         foreach ($data['product_download'] as $download_id) {
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_to_download SET product_id = '" . (int)$product_id . "', download_id = '" . (int)$download_id . "'");
         }
      }
      
      if (isset($data['product_category'])) {
         foreach ($data['product_category'] as $category_id) {
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_to_category SET product_id = '" . (int)$product_id . "', category_id = '" . (int)$category_id . "'");
         }
      }
      
      if (isset($data['product_related'])) {
         foreach ($data['product_related'] as $related_id) {
             $this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$product_id . "' AND related_id = '" . (int)$related_id . "'");
                $this->db->query("INSERT INTO " . DB_PREFIX . "product_related SET product_id = '" . (int)$product_id . "', related_id = '" . (int)$related_id . "'");
                $this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$related_id . "' AND related_id = '" . (int)$product_id . "'");
                $this->db->query("INSERT INTO " . DB_PREFIX . "product_related SET product_id = '" . (int)$related_id . "', related_id = '" . (int)$product_id . "'");

         }
      }
      
      if ($data['keyword']) {
         $this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET query = 'product_id=" . (int)$product_id . "', keyword = '" . $this->db->escape($data['keyword']) . "'");
      }
      
      foreach ($data['product_tags'] as $language_id => $value) {
         $tags = explode(',', $value);
         foreach ($tags as $tag) {
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_tags SET product_id = '" . (int)$product_id . "', language_id = '" . (int)$language_id . "', tag = '" . $this->db->escape(trim($tag)) . "'");
         }
      }
      
      if (isset($data['product_extra_field'])) {
         foreach($data['product_extra_field'] as $product_extra_field_id => $product_extra_field) {
            foreach($product_extra_field['value'] as $language_id => $value) {
               if ($value['value'] != ''){
                  $this->db->query("INSERT INTO " . DB_PREFIX . "product_extra_field_value SET product_id = '" . (int)$product_id . "', language_id = '" . (int)$language_id . "', value = '" . $this->db->escape($value['value']) . "', product_extra_field_id = '" . (int)$product_extra_field_id . "'");
               }
            }
         }
      }
      
      $this->cache->delete('product');
   }
   
   public function editProduct($product_id, $data) {
      $this->db->query("UPDATE " . DB_PREFIX . "product SET model = '" . $this->db->escape($data['model']) . "', sku = '" . $this->db->escape($data['sku']) . "', location = '" . $this->db->escape($data['location']) . "', quantity = '" . (int)$data['quantity'] . "', minimum = '" . (int)$data['minimum'] . "', subtract = '" . (int)$data['subtract'] . "', stock_status_id = '" . (int)$data['stock_status_id'] . "', date_available = '" . $this->db->escape($data['date_available']) . "', manufacturer_id = '" . (int)$data['manufacturer_id'] . "', shipping = '" . (int)$data['shipping'] . "', price = '" . (float)$data['price'] . "', cost = '" . (float)$data['cost'] . "', call_for_price = '" . $this->db->escape($data['call_for_price']) . "', weight = '" . (float)$data['weight'] . "', weight_class_id = '" . (int)$data['weight_class_id'] . "', length = '" . (float)$data['length'] . "', width = '" . (float)$data['width'] . "', height = '" . (float)$data['height'] . "', length_class_id = '" . (int)$data['length_class_id'] . "', status = '" . (int)$data['status'] . "', tax_class_id = '" . (int)$data['tax_class_id'] . "', sort_order = '" . (int)$data['sort_order'] . "', date_modified = NOW() WHERE product_id = '" . (int)$product_id . "'");

      if (isset($data['image'])) {
         $this->db->query("UPDATE " . DB_PREFIX . "product SET image = '" . $this->db->escape($data['image']) . "' WHERE product_id = '" . (int)$product_id . "'");
      }
      
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_description WHERE product_id = '" . (int)$product_id . "'");
      
      foreach ($data['product_description'] as $language_id => $value) {
         $this->db->query("INSERT INTO " . DB_PREFIX . "product_description SET product_id = '" . (int)$product_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', meta_keywords = '" . $this->db->escape($value['meta_keywords']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', description = '" . $this->db->escape($value['description']) . "'");
      }

      $this->db->query("DELETE FROM " . DB_PREFIX . "product_to_store WHERE product_id = '" . (int)$product_id . "'");

      if (isset($data['product_store'])) {
         foreach ($data['product_store'] as $store_id) {
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_to_store SET product_id = '" . (int)$product_id . "', store_id = '" . (int)$store_id . "'");
         }
      }
      
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_option WHERE product_id = '" . (int)$product_id . "'");
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_option_description WHERE product_id = '" . (int)$product_id . "'");
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_option_value WHERE product_id = '" . (int)$product_id . "'");
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_option_value_description WHERE product_id = '" . (int)$product_id . "'");
      
      if (isset($data['product_option'])) {
         foreach ($data['product_option'] as $product_option) {
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_option SET product_id = '" . (int)$product_id . "', sort_order = '" . (int)$product_option['sort_order'] . "'");
            
            $product_option_id = $this->db->getLastId();
            
            foreach ($product_option['language'] as $language_id => $language) {
               $this->db->query("INSERT INTO " . DB_PREFIX . "product_option_description SET product_option_id = '" . (int)$product_option_id . "', language_id = '" . (int)$language_id . "', product_id = '" . (int)$product_id . "', name = '" . $this->db->escape($language['name']) . "'");
            }            
            
            if (isset($product_option['product_option_value'])) {
               foreach ($product_option['product_option_value'] as $product_option_value) {
                  $this->db->query("INSERT INTO " . DB_PREFIX . "product_option_value SET product_option_id = '" . (int)$product_option_id . "', product_id = '" . (int)$product_id . "', quantity = '" . (int)$product_option_value['quantity'] . "', subtract = '" . (int)$product_option_value['subtract'] . "', price = '" . (float)$product_option_value['price'] . "', prefix = '" . $this->db->escape($product_option_value['prefix']) . "', sort_order = '" . (int)$product_option_value['sort_order'] . "'");
            
                  $product_option_value_id = $this->db->getLastId();
            
                  foreach ($product_option_value['language'] as $language_id => $language) {
                     $this->db->query("INSERT INTO " . DB_PREFIX . "product_option_value_description SET product_option_value_id = '" . (int)$product_option_value_id . "', language_id = '" . (int)$language_id . "', product_id = '" . (int)$product_id . "', name = '" . $this->db->escape($language['name']) . "'");
                  }               
               }
            }
         }
      }
      
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "'");

      if (isset($data['product_discount'])) {
         foreach ($data['product_discount'] as $value) {
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_discount SET product_id = '" . (int)$product_id . "', customer_group_id = '" . (int)$value['customer_group_id'] . "', quantity = '" . (int)$value['quantity'] . "', priority = '" . (int)$value['priority'] . "', price = '" . (float)$value['price'] . "', date_start = '" . $this->db->escape($value['date_start']) . "', date_end = '" . $this->db->escape($value['date_end']) . "'");
         }
      }
      
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_special WHERE product_id = '" . (int)$product_id . "'");
      
      if (isset($data['product_special'])) {
         foreach ($data['product_special'] as $value) {
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_special SET product_id = '" . (int)$product_id . "', customer_group_id = '" . (int)$value['customer_group_id'] . "', priority = '" . (int)$value['priority'] . "', price = '" . (float)$value['price'] . "', date_start = '" . $this->db->escape($value['date_start']) . "', date_end = '" . $this->db->escape($value['date_end']) . "'");
         }
      }
      
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "'");
      
      if (isset($data['product_image'])) {
         foreach ($data['product_image'] as $image) {
              $this->db->query("INSERT INTO " . DB_PREFIX . "product_image SET product_id = '" . (int)$product_id . "', image = '" . $this->db->escape($image) . "'");
         }
      }
      
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_to_download WHERE product_id = '" . (int)$product_id . "'");
      
      if (isset($data['product_download'])) {
         foreach ($data['product_download'] as $download_id) {
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_to_download SET product_id = '" . (int)$product_id . "', download_id = '" . (int)$download_id . "'");
         }
      }
      
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'");
      
      if (isset($data['product_category'])) {
         foreach ($data['product_category'] as $category_id) {
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_to_category SET product_id = '" . (int)$product_id . "', category_id = '" . (int)$category_id . "'");
         }      
      }

      $this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$product_id . "'");
        $this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE related_id = '" . (int)$product_id . "'");


      if (isset($data['product_related'])) {
         foreach ($data['product_related'] as $related_id) {
                $this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$product_id . "' AND related_id = '" . (int)$related_id . "'");
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_related SET product_id = '" . (int)$product_id . "', related_id = '" . (int)$related_id . "'");
            $this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$related_id . "' AND related_id = '" . (int)$product_id . "'");
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_related SET product_id = '" . (int)$related_id . "', related_id = '" . (int)$product_id . "'");
         }
      }
      
      $this->db->query("DELETE FROM " . DB_PREFIX . "url_alias WHERE query = 'product_id=" . (int)$product_id. "'");
      
      if ($data['keyword']) {
         $this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET query = 'product_id=" . (int)$product_id . "', keyword = '" . $this->db->escape($data['keyword']) . "'");
      }
      
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_tags WHERE product_id = '" . (int)$product_id. "'");
      
      foreach ($data['product_tags'] as $language_id => $value) {
         $tags = explode(',', $value);
         foreach ($tags as $tag) {
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_tags SET product_id = '" . (int)$product_id . "', language_id = '" . (int)$language_id . "', tag = '" . $this->db->escape(trim($tag)) . "'");
         }
      }
      
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_extra_field_value WHERE product_id = '" . (int)$product_id . "'");
      
      if (isset($data['product_extra_field'])) {
         foreach($data['product_extra_field'] as $product_extra_field_id => $product_extra_field) {
            foreach($product_extra_field['value'] as $language_id => $value) {
               if ($value['value'] != '') {
                  $this->db->query("INSERT INTO " . DB_PREFIX . "product_extra_field_value SET product_id = '" . (int)$product_id . "', language_id = '" . (int)$language_id . "', value = '" . $this->db->escape($value['value']) . "', product_extra_field_id = '" . (int)$product_extra_field_id . "'");
               }
            }
         }
      }
      
      $this->cache->delete('product');
   }
   
   public function copyProduct($product_id) {
      $query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
      
      if ($query->num_rows) {
         $data = array();
         
         $data = $query->row;
         
         $data = array_merge($data, array('product_description' => $this->getProductDescriptions($product_id)));
         $data = array_merge($data, array('product_option' => $this->getProductOptions($product_id)));
                  
         $data['keyword'] = '';
                  
         $data['product_image'] = array();
         
         $results = $this->getProductImages($product_id);
         
         foreach ($results as $result) {
            $data['product_image'][] = $result['image'];
         }
         
         $data = array_merge($data, array('product_discount' => $this->getProductDiscounts($product_id)));
         $data = array_merge($data, array('product_special' => $this->getProductSpecials($product_id)));
         $data = array_merge($data, array('product_download' => $this->getProductDownloads($product_id)));
         $data = array_merge($data, array('product_category' => $this->getProductCategories($product_id)));
         $data = array_merge($data, array('product_store' => $this->getProductStores($product_id)));
         $data = array_merge($data, array('product_related' => $this->getProductRelated($product_id)));
         $data = array_merge($data, array('product_tags' => $this->getProductTags($product_id)));
         
         $this->addProduct($data);
      }
   }
   
   public function deleteProduct($product_id) {
      $this->db->query("DELETE FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product_id . "'");
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_description WHERE product_id = '" . (int)$product_id . "'");
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_option WHERE product_id = '" . (int)$product_id . "'");
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_option_description WHERE product_id = '" . (int)$product_id . "'");
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_option_value WHERE product_id = '" . (int)$product_id . "'");
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_option_value_description WHERE product_id = '" . (int)$product_id . "'");
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "'");
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "'");
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$product_id . "'");
       $this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE related_id = '" . (int)$product_id . "'");

      $this->db->query("DELETE FROM " . DB_PREFIX . "product_to_download WHERE product_id = '" . (int)$product_id . "'");
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'");
      $this->db->query("DELETE FROM " . DB_PREFIX . "review WHERE product_id = '" . (int)$product_id . "'");
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_to_store WHERE product_id = '" . (int)$product_id . "'");
      $this->db->query("DELETE FROM " . DB_PREFIX . "url_alias WHERE query = 'product_id=" . (int)$product_id. "'");
      $this->db->query("DELETE FROM " . DB_PREFIX . "product_tags WHERE product_id='" . (int)$product_id. "'");
      
      $this->cache->delete('product');
   }
   
   public function getProduct($product_id) {
      $query = $this->db->query("SELECT DISTINCT *, (SELECT keyword FROM " . DB_PREFIX . "url_alias WHERE query = 'product_id=" . (int)$product_id . "') AS keyword FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
            
      return $query->row;
   }
   
   public function getProducts($data = array()) {
      if ($data) {
         $sql = "SELECT p.*,pd.name, cd.name AS category FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (p.product_id = p2c.product_id) LEFT JOIN " . DB_PREFIX . "category_description cd ON (p2c.category_id = cd.category_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
      
         if (isset($data['filter_name']) && !is_null($data['filter_name'])) {
            $sql .= " AND LCASE(pd.name) LIKE '%" . $this->db->escape(strtolower($data['filter_name'])) . "%'";
         }

         if (isset($data['filter_model']) && !is_null($data['filter_model'])) {
            $sql .= " AND LCASE(p.model) LIKE '%" . $this->db->escape(strtolower($data['filter_model'])) . "%'";
         }
         
                        if (isset($data['filter_category']) && !is_null($data['filter_category'])) {
            $sql .= " AND p2c.category_id = '" . $this->db->escape($data['filter_category']) . "'";
         }
         
         if (isset($data['filter_quantity']) && !is_null($data['filter_quantity'])) {
            $sql .= " AND p.quantity = '" . $this->db->escape($data['filter_quantity']) . "'";
         }
         
         if (isset($data['filter_status']) && !is_null($data['filter_status'])) {
            $sql .= " AND p.status = '" . (int)$data['filter_status'] . "'";
         }

         $sort_data = array(
            'pd.name',
            'p.model',
                                'category',
            'p.quantity',
            'p.status',
            'p.sort_order'
         );   
         $sql .= " GROUP BY pd.name"  ;
         
         if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
            $sql .= " ORDER BY " . $data['sort'];   
         } else {
            $sql .= " ORDER BY pd.name";   
         }
         
         if (isset($data['order']) && ($data['order'] == 'DESC')) {
            $sql .= " DESC";
         } else {
            $sql .= " ASC";
         }
      
         if (isset($data['start']) || isset($data['limit'])) {
            if ($data['start'] < 0) {
               $data['start'] = 0;
            }            

            if ($data['limit'] < 1) {
               $data['limit'] = 20;
            }   
         
            $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
         }   
         
         $query = $this->db->query($sql);
      
         return $query->rows;
      } else {
         $product_data = $this->cache->get('product.' . $this->config->get('config_language_id'));
      
         if (!$product_data) {
            $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY pd.name ASC");
   
            $product_data = $query->rows;
         
            $this->cache->set('product.' . $this->config->get('config_language_id'), $product_data);
         }   
   
         return $product_data;
      }
   }

   public function addFeatured($data) {
         $this->db->query("DELETE FROM " . DB_PREFIX . "product_featured");
         
      if (isset($data['featured_product'])) {
            foreach ($data['featured_product'] as $product_id) {
              $this->db->query("INSERT INTO " . DB_PREFIX . "product_featured SET product_id = '" . (int)$product_id . "'");
            }         
      }
   }
   
   public function getFeaturedProducts() {
      $query = $this->db->query("SELECT product_id FROM " . DB_PREFIX . "product_featured");
      
      $featured = array();
      
      foreach ($query->rows as $product) {
         $featured[] = $product['product_id'];
      }
      return $featured;
   }
   
   public function getProductsByKeyword($keyword) {
      if ($keyword) {
         $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND (LCASE(pd.name) LIKE '%" . $this->db->escape(strtolower($keyword)) . "%' OR LCASE(p.model) LIKE '%" . $this->db->escape(strtolower($keyword)) . "%')");
                            
         return $query->rows;
      } else {
         return array();   
      }      
   }
   
   public function getProductsByCategoryId($category_id) {
      $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (p.product_id = p2c.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p2c.category_id = '" . (int)$category_id . "' ORDER BY pd.name ASC");
                         
      return $query->rows;
   }
   
   public function getProductDescriptions($product_id) {
      $product_description_data = array();
      
      $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_description WHERE product_id = '" . (int)$product_id . "'");
      
      foreach ($query->rows as $result) {
         $product_description_data[$result['language_id']] = array(
            'name'             => $result['name'],
            'meta_keywords'    => $result['meta_keywords'],
            'meta_description' => $result['meta_description'],
            'description'      => $result['description']
         );
      }
      
      return $product_description_data;
   }

   public function getProductOptions($product_id) {
      $product_option_data = array();
      
      $product_option = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option WHERE product_id = '" . (int)$product_id . "' ORDER BY sort_order");
      
      foreach ($product_option->rows as $product_option) {
         $product_option_value_data = array();
         
         $product_option_value = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value WHERE product_option_id = '" . (int)$product_option['product_option_id'] . "' ORDER BY sort_order");
         
         foreach ($product_option_value->rows as $product_option_value) {
            $product_option_value_description_data = array();
            
            $product_option_value_description = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value_description WHERE product_option_value_id = '" . (int)$product_option_value['product_option_value_id'] . "'");

            foreach ($product_option_value_description->rows as $result) {
               $product_option_value_description_data[$result['language_id']] = array('name' => $result['name']);
            }
         
            $product_option_value_data[] = array(
               'product_option_value_id' => $product_option_value['product_option_value_id'],
               'language'                => $product_option_value_description_data,
                  'quantity'                => $product_option_value['quantity'],
               'subtract'                => $product_option_value['subtract'],
               'price'                   => $product_option_value['price'],
                  'prefix'                  => $product_option_value['prefix'],
               'sort_order'              => $product_option_value['sort_order']
            );
         }
         
         $product_option_description_data = array();
         
         $product_option_description = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_description WHERE product_option_id = '" . (int)$product_option['product_option_id'] . "'");

         foreach ($product_option_description->rows as $result) {
            $product_option_description_data[$result['language_id']] = array('name' => $result['name']);
         }
      
           $product_option_data[] = array(
              'product_option_id'    => $product_option['product_option_id'],
            'language'             => $product_option_description_data,
            'product_option_value' => $product_option_value_data,
            'sort_order'           => $product_option['sort_order']
           );
         }   
      
      return $product_option_data;
   }
   
   public function getProductImages($product_id) {
      $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "'");
      
      return $query->rows;
   }
   
   public function getProductDiscounts($product_id) {
      $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "' ORDER BY quantity, priority, price");
      
      return $query->rows;
   }
   
   public function getProductSpecials($product_id) {
      $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_special WHERE product_id = '" . (int)$product_id . "' ORDER BY priority, price");
      
      return $query->rows;
   }
   
   public function getProductDownloads($product_id) {
      $product_download_data = array();
      
      $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_download WHERE product_id = '" . (int)$product_id . "'");
      
      foreach ($query->rows as $result) {
         $product_download_data[] = $result['download_id'];
      }
      
      return $product_download_data;
   }

   public function getProductStores($product_id) {
      $product_store_data = array();
      
      $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_store WHERE product_id = '" . (int)$product_id . "'");

      foreach ($query->rows as $result) {
         $product_store_data[] = $result['store_id'];
      }
      
      return $product_store_data;
   }
   
   public function getProductCategories($product_id) {
      $product_category_data = array();
      
      $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'");
      
      foreach ($query->rows as $result) {
         $product_category_data[] = $result['category_id'];
      }

      return $product_category_data;
   }

   public function getProductRelated($product_id) {
      $product_related_data = array();
      
      $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$product_id . "'");
      
      foreach ($query->rows as $result) {
         $product_related_data[] = $result['related_id'];
      }
      
      return $product_related_data;
   }
   
   public function getProductTags($product_id) {
      $product_tag_data = array();
      
      $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_tags WHERE product_id = '" . (int)$product_id . "'");
      
      $tag_data = array();
      
      foreach ($query->rows as $result) {
         $tag_data[$result['language_id']][] = $result['tag'];
      }
      
      foreach ($tag_data as $language => $tags) {
         $product_tag_data[$language] = implode(',', $tags);
      }
      
      return $product_tag_data;
   }
   
   public function getTotalProducts($data = array()) {
      $sql = "SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
      
      if (isset($data['filter_name']) && !is_null($data['filter_name'])) {
         $sql .= " AND LCASE(pd.name) LIKE '%" . $this->db->escape(strtolower($data['filter_name'])) . "%'";
      }

      if (isset($data['filter_model']) && !is_null($data['filter_model'])) {
         $sql .= " AND LCASE(p.model) LIKE '%" . $this->db->escape(strtolower($data['filter_model'])) . "%'";
      }
      
      if (isset($data['filter_quantity']) && !is_null($data['filter_quantity'])) {
         $sql .= " AND p.quantity = '" . $this->db->escape($data['filter_quantity']) . "'";
      }
      
      if (isset($data['filter_status']) && !is_null($data['filter_status'])) {
         $sql .= " AND p.status = '" . (int)$data['filter_status'] . "'";
      }

      $query = $this->db->query($sql);
      
      return $query->row['total'];
   }   
   
   public function getTotalProductsByStockStatusId($stock_status_id) {
         $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product WHERE stock_status_id = '" . (int)$stock_status_id . "'");

      return $query->row['total'];
   }
   
   public function getTotalProductsByImageId($image_id) {
         $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product WHERE image_id = '" . (int)$image_id . "'");

      return $query->row['total'];
   }
   
   public function getTotalProductsByTaxClassId($tax_class_id) {
         $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product WHERE tax_class_id = '" . (int)$tax_class_id . "'");

      return $query->row['total'];
   }
   
   public function getTotalProductsByWeightClassId($weight_class_id) {
         $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product WHERE weight_class_id = '" . (int)$weight_class_id . "'");

      return $query->row['total'];
   }
   
   public function getTotalProductsByLengthClassId($length_class_id) {
         $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product WHERE length_class_id = '" . (int)$length_class_id . "'");

      return $query->row['total'];
   }
   
   public function getTotalProductsByOptionId($option_id) {
         $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product_to_option WHERE option_id = '" . (int)$option_id . "'");

      return $query->row['total'];
   }

   public function getTotalProductsByDownloadId($download_id) {
         $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product_to_download WHERE download_id = '" . (int)$download_id . "'");
      
      return $query->row['total'];
   }
   
   public function getTotalProductsByManufacturerId($manufacturer_id) {
         $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");

      return $query->row['total'];
   }
   public function getProductExtrafields($product_id) {
      $product_extra_field_data = array();
      $product_extra_fields = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_extra_field ORDER BY sort_order");
      
      foreach($product_extra_fields->rows as $product_extra_field){
         
         $product_extra_field_description = array();
         $pef_description_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_extra_field_description WHERE product_extra_field_id = " . $product_extra_field['product_extra_field_id']);
         foreach ($pef_description_query->rows as $pef_description) {
            $product_extra_field_description[$pef_description['language_id']] = array(
               'name'          => $pef_description['name'],
               'list_values'   => $pef_description['list_values']
            );
         }
         
         $product_extra_field_value = array();
         $pef_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_extra_field_value WHERE product_extra_field_id = " . $product_extra_field['product_extra_field_id'] . " AND product_id = " . $product_id);
         if($pef_value_query->num_rows){
            foreach ($pef_value_query->rows as $pef_value) {
               $product_extra_field_value[$pef_value['language_id']] = array(
                  'value'          => $pef_value['value']
                  
               );
            }
         }
         
      
         $product_extra_field_data[] = array(
                         'product_extra_field_id' => $product_extra_field['product_extra_field_id'],
                         'status' => $product_extra_field['status'],
                         'islist' => $product_extra_field['islist'],
                         'description' => $product_extra_field_description,
                         'value' => $product_extra_field_value
                        );
         
      }
      
      return $product_extra_field_data;
      
      
   }
   
}
?>
Version Opencart 1.4.8 Fr sur serveur Infomaniak
Version Opencart 1.5.4.1 sur JOOMLA avec module AceShop
modules additionnels : CMS Categories, Stock report, Product extra fields, Poll, Visiteur counter, NextAndPreviousProductLink, MiniSlider
Avatar de l’utilisateur
cricri92
Utilisateur enregistré
Utilisateur enregistré
 
Messages: 138
Inscription: 02 Juil 2010, 05:28
Localisation: haut de Seine

Re: Problème produits apparentés

Messagepar cricri92 » 28 Nov 2011, 13:09

En pièce jointe les deux fichiers
admin/view/template/catalog/product_form.tpl et product_list.tpl
Fichiers joints
product_form.tpl.zip
(6.28 Kio) Téléchargé 170 fois
product_list.tpl.zip
(1.76 Kio) Téléchargé 173 fois
Version Opencart 1.4.8 Fr sur serveur Infomaniak
Version Opencart 1.5.4.1 sur JOOMLA avec module AceShop
modules additionnels : CMS Categories, Stock report, Product extra fields, Poll, Visiteur counter, NextAndPreviousProductLink, MiniSlider
Avatar de l’utilisateur
cricri92
Utilisateur enregistré
Utilisateur enregistré
 
Messages: 138
Inscription: 02 Juil 2010, 05:28
Localisation: haut de Seine


Retourner vers Rapports de Problèmes

Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 0 invités

cron