Jump to content
Sign in to follow this  
kokhonov

Вывод цены товара в каталоге по минимальной из опций

Recommended Posts

Приветствую.
Столкнулся с проблемой вывода цен. Мне нужно чтобы выводилась минимальная цена из опций вместо обычной.
Нашел на забугорном форуме файлец для vqmod, который вроде для версии 1.5.3. 
Сам использую ocStore 1.5.5.1, и некоторым товарам он и вправду изменил цену на минимальную из опций, но не всем(как мне показалось изменил только первым нескольким позициям). В чем может быть проблема?

<modification>
	<id>Starting At Option Price</id>
	<version>1.5.x</version>
	<vqmver>2.1.5</vqmver>
	<author>qphoria</author>
	<file name="catalog/model/catalog/product.php">
	
		<operation info="Move price manipulation up so it can be managed">
			<search position="before"><![CDATA[
			return array(
			]]></search>
			<add><![CDATA[
			$query->row['price'] = ($query->row['discount'] ? $query->row['discount'] : $query->row['price']);
			
			
			// Show first (lowest) option price as "Starting at" price
			// But for product page, to avoid issues with option price update, use a different method
			if ($query->row['price'] == 0) {
				$options = $this->getProductOptions($product_id);
				
				$option_prices = array();
				if ($options) {
					foreach ($options as $j => $option) {
						if (!$option['option_value']) { continue; }
						foreach ($option['option_value'] as $l => $option_value) {
							if (!(float)$option_value['price']) { continue; }
							if ($option_value['price_prefix'] == '-') {
								$option_prices[] = -$option_value['price'];
							} else {
								$option_prices[] = $option_value['price'];
							}
							$options[$j]['option_value'][$l]['price_prefix'] = '';
						}
					}
				}
				if ($option_prices) {
					sort($option_prices);
					//if (!isset($this->request->get['product_id']) && !isset($this->request->post['product_id'])) {
					//if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH']!='XMLHttpRequest' && !isset($this->request->get['product_id']) && !isset($this->request->post['product_id'])) {
					//if (isset($this->request->get['route']) && $this->request->get['route'] != 'product/product') {
					if ((!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH']!='XMLHttpRequest') && ((isset($this->request->get['route']) && $this->request->get['route'] != 'product/product') || !isset($this->request->get['route']))) {
						$query->row['price'] = reset($option_prices);
					} else {
						$this->session->data['start_at_price'] = $this->tax->calculate($option_prices[0], $query->row['tax_class_id']);
						$this->session->data['start_at_price_ex_tax'] = $option_prices[0];
					}
				}				
			}
			]]></add>
		</operation>
	
		<operation info="replace the original with the new variable">
			<search position="replace"><![CDATA[
			($query->row['discount'] ? $query->row['discount'] : $query->row['price']),
			]]></search>
			<add><![CDATA[
			$query->row['price'],
			]]></add>
		</operation>
	</file>
	
	<file name="system/library/currency.php">
		<operation>
			<search position="after"><![CDATA[
			public function format($number,
			]]></search>
			<add><![CDATA[
			$trace = debug_backtrace();
			if (isset($trace[1]['class']) && $trace[1]['class'] == 'ControllerProductProduct') {
				if ($number == 0 && !empty($this->session->data['start_at_price'])) {
					$number = $this->session->data['start_at_price'];
					$starting = true;
					unset($this->session->data['start_at_price']);
				}
				if ($number == 0 && !empty($this->session->data['start_at_price_ex_tax'])) {
					$number = $this->session->data['start_at_price_ex_tax'];
					$starting = true;
					unset($this->session->data['start_at_price_ex_tax']);
				}
			}
			]]></add>
		</operation>
		<operation>
			<search position="before"><![CDATA[
			return $string;
			]]></search>
			<add><![CDATA[
			if (isset($starting) && $starting) {
				$starting = false;
				$string = "Starting at $string";
			}
			]]></add>
		</operation>
		
	</file>

</modification>

price_by_options_153x.xml

Share this post


Link to post
Share on other sites

Перезалил с 1с цены, всё плохо, этот код ничего не изменил... При выгрузке из 1с сайт цепляет первую цену для товара в файле offers, но она не та что нужна, так как пользуюсь связанными опциями с разными ценами(без + и -, а фиксированной).
Хотелось бы просто узнать, возможно отображать минимальную цену из опций для товара в каталоге, т.к. хочу сделать цены в виде: 'от 777 р'.

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.