Jump to content
Sign in to follow this  
Gann

модуль Подбора по характеристикам

Recommended Posts

Приветствую!

Есть модуль подбора по характеристикам. Автор @Designer. Хочу немного доработать его. Автор последние несколько месяцев отвечает только "Нет времени" и т.д. (заказывал у него).

 

В общем нужно:

1. добавить вывод атрибутов подобранных товаров.

2. вывод количества на складе подобранных товаров.

 

код функции:

 

	### Подбор по атрибутам
	public function tuckup() {
		$this->load->model('catalog/tuckup');
		$this->load->model('tool/image');

		$json = array();

		if (isset($this->request->get['product_id']) && isset($this->request->get['category_id']) && isset($this->request->get['attribute']) ) {

			if (! is_array($this->request->get['attribute'])) {
				$json['error'] = 'Не выбрана характеристика для подбора!';
			}
			
			if (! isset($json['error'])) {
				$attributes = $this->request->get['attribute'];
				
				$attribute_data = array();
		
				if ($attributes) {
					foreach ($attributes as $attribute) {
						list($attribute_id, $text) = explode('_', $attribute);											
						$attribute_data[] = array('attribute_id' => $attribute_id, 'text' => $text);
					}
				}

				$products = $this->model_catalog_tuckup->getTuckup($this->request->get['product_id'], $this->request->get['category_id'], $attribute_data);
		
				foreach ($products as $product) {
					if ($product['image']) {
						$image = $this->model_tool_image->resize($product['image'], $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height'));
					} else {
						$image = $this->model_tool_image->resize('placeholder.png', $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height'));
					}

					if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
						$price = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')));
					} else {
						$price = false;
					}

					if ((float)$product['special']) {
						$special = $this->currency->format($this->tax->calculate($product['special'], $product['tax_class_id'], $this->config->get('config_tax')));
					} else {
						$special = false;
					}

					$json['success'][] = array(
						'product_id'  => $product['product_id'],
						'thumb'       => $image,
						'name'        => $product['name'],
						'description' => utf8_substr(strip_tags(html_entity_decode($product['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
						'price'       => $price,
						'special'     => $special,
						'minimum'     => $product['minimum'] > 0 ? $product['minimum'] : 1,
						'href'        => $this->url->link('product/product', 'product_id=' . $product['product_id'])
					);
				}
			}
		}
	
		$this->response->addHeader('Content-Type: application/json');
		$this->response->setOutput(json_encode($json));
	}
	###

Т.е. нужно в $json['success'][] = array( передать ещё:

'attribute'

'stock'

 

как это сделать?

спасибо за помощь

 DesDesignerigner

Share this post


Link to post
Share on other sites

с выводом количества на складе разобрался... добавив в $json['success'][] = array

 

'stock'       => $product['quantity'],

 

и выведя скриптом: + json['success']['stock'] +

 

вопрос с атрибутами открыт

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

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.