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

Вывод категории товара в order_info.tpl (в админке)


Recommended Posts

Добрый день! Не могу вывести категории товара в информации о заказе order_info.tpl (скриншот).

Что и где нужно прописать в контроллере, чтобы получить доступ к категориям товара?

screen.png

Edited by justrid
Link to comment
Share on other sites


В order.php прописал (отмечено комментариями):

 

foreach ($products as $product) {
				$option_data = array();

				$options = $this->model_sale_order->getOrderOptions($this->request->get['order_id'], $product['order_product_id']);

				foreach ($options as $option) {
					if ($option['type'] != 'file') {
						$option_data[] = array(
							'name'  => $option['name'],
							'value' => $option['value'],
							'type'  => $option['type']
						);
					} else {
						$upload_info = $this->model_tool_upload->getUploadByCode($option['value']);

						if ($upload_info) {
							$option_data[] = array(
								'name'  => $option['name'],
								'value' => $upload_info['name'],
								'type'  => $option['type'],
								'href'  => $this->url->link('tool/upload/download', 'token=' . $this->session->data['token'] . '&code=' . $upload_info['code'], 'SSL')
							);
						}
					}
				}

				$data['product_categories'] = array(); //добавил
				
				$data['products'][] = array(
					'order_product_id' => $product['order_product_id'],
					'product_id'       => $product['product_id'],
					'name'    	 	   => $product['name'],
					'model'    		   => $product['model'],
					'option'   		   => $option_data,
					'quantity'		   => $product['quantity'],
					'price'    		   => $this->currency->format($product['price'] + ($this->config->get('config_tax') ? $product['tax'] : 0), $order_info['currency_code'], $order_info['currency_value']),
					'total'    		   => $this->currency->format($product['total'] + ($this->config->get('config_tax') ? ($product['tax'] * $product['quantity']) : 0), $order_info['currency_code'], $order_info['currency_value']),
					'href'     		   => $this->url->link('catalog/product/edit', 'token=' . $this->session->data['token'] . '&product_id=' . $product['product_id'], 'SSL'),
					
					'product_categories'   => $product_categories //добавил
				);

				
				//ДОбавил здесь
				// Categories
					$this->load->model('catalog/category');

					if (isset($this->request->post['product_category'])) {
						$categories = $this->request->post['product_category'];
					} elseif (isset($this->request->get[$product['product_id']])) {
						$categories = $this->model_catalog_product->getProductCategories($this->request->get[$product['product_id']]);
					} else {
						$categories = array();
					}
					
					//$data['product_categories'] = array();

					foreach ($categories as $category_id) {
						$category_info = $this->model_catalog_category->getCategory($category_id);

						if ($category_info) {
							$data['product_categories'][] = array(
								'category_id' => $category_info['category_id'],
								'name' => ($category_info['path']) ? $category_info['path'] . ' > ' . $category_info['name'] : $category_info['name']
							);
						}
					}
				
				//Конец кода
				
			}

Вывод в order_info.tpl:

<?php foreach ($product['product_categories'] as $product_category) { ?>
	<?php echo $product_category['name']; ?>
<?php } ?>

 

Но ничего не выводит:(

Edited by justrid
Link to comment
Share on other sites


Упростил код. Теперь в order.php:


 

$categories2 = $this->model_catalog_product->getProductCategories($product['product_id']);
if ($categories2)
$categories_info = $this->model_catalog_category->getCategory($categories2[0]['category_id']);
$this->data['category_title'] = $categories_info['name'];

 

А вывод (order_info.tpl):

 

<?php echo $category_title; ?>

 

Но теперь выводит белый экран.

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.