Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Вывести данные из своей таблицы


 Share

Recommended Posts

Добрый день,
Есть таблица market с столбцами artikul, garant, detal_av. Нужно вывести данные из этой таблицы в админку (в зависимости от товара - model). К сожалению не до конца понял как берутся данные из БД в opencart, сделал по аналогии с выводом данных из таблицы опенкарт (product_description).
Подскажите, где ошибка (не выводится информация из таблицы market в админку):
Добавил в admin/model/catalog/product.php :

   public function getMarket($model) {
       $market_data = array();
       $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "market WHERE artikul = '" . $model . "'");
       foreach ($query->rows as $result) {
           $market_data = array(
               'detal_av'             => $result['detal_av'],
               'garant'               => $result['garant']
           );
       }
       return $market_data;
   }

Добавил в admin/controller/catalog/product.php :

       if (isset($this->request->post['market'])) {
           $data['market'] = $this->request->post['market'];
       } elseif (isset($this->request->get['model'])) {
           $data['market'] = $this->model_catalog_product->getMarket($this->request->get['model']);
       } else {
           $data['market'] = array();
       }

 

Добавил в admin/view/template/catalog/product_form.tpl :

<?php echo isset($market[$model]) ? $market['detal_av'] : ''; ?>

Но данные не выводятся (

Спасибо.

Link to comment
Share on other sites


Данные для описания товара представлены так:

		if (isset($this->request->post['product_description'])) {
			$data['product_description'] = $this->request->post['product_description'];
		} elseif (isset($this->request->get['product_id'])) {
			$data['product_description'] = $this->model_catalog_product->getProductDescriptions($this->request->get['product_id']);
		} else {
			$data['product_description'] = array();
		}

Сделал по этому примеру (здесь вывод описания в зависимости от product_id, у меня в зависимсоти от модели товара $modul). Это не правильно ($this->request->get['model'])?

Edited by Silver111
Link to comment
Share on other sites


11 минут назад, Silver111 сказал:

Это не правильно ($this->request->get['model'])?

в get данные из массива  $_GET, другими словами все что в запросе после знака вопроса

/admin/index.php?route=catalog/product/edit&token=bcqdcdbWJZ4RONpOgd09iAatJSxoyY7y&product_id=42

вы видите там model?

в вашем случае нужно как-то так

     if (isset($this->request->post['market'])) {
           $data['market'] = $this->request->post['market'];
       } elseif (!empty($product_info)) {
           $data['market'] = $this->model_catalog_product->getMarket($product_info['model']);
       } else {
           $data['market'] = array();
       }

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.