Jump to content
surlan

Стоимость опций в категории "от 000 руб."

Recommended Posts

Всем привет!

Как можно реализовать возможность вывода в категории минимальную стоимость из списка опций товара, если основная стоимость товара равна 0? Нашел на форуме вот такой модификатор (вроде рабочий, но у меня не сработал).

Версия движка 2.3, модификатор (по словам автора) тоже тестировался на этой версии. Кто что думает?

 

<?xml version="1.0" encoding="UTF-8"?>
<modification>
  <name>Нулевая цена в категории заменяется на цену опции OC2.3</name>
  <code>fix-zero-2x</code>
  <version>2.0.0</version>
  <vqmver></vqmver>
  <link></link>
  <author>mpn2005</author>
  <date>2017.12.14</date>
  
  <file path="catalog/model/catalog/product.php">
    <operation>  
      <search><![CDATA[return array(]]></search>
      <add position="before"><![CDATA[
        $price_text = '';
        if (!(float)$query->row['price']) {
            $option_price_query = $this->db->query("SELECT price FROM " . DB_PREFIX . "product_option_value WHERE product_id = '" . (int)$query->row['product_id'] . "' AND (subtract = '0' OR quantity > '0') AND (price_prefix = '=') ORDER BY price LIMIT 1");
            if ($option_price_query->num_rows) {
                $query->row['price'] = $option_price_query->row['price'];
                $price_text = '<span style="font-weight:normal;">от</span> ';
            }
        }
      ]]></add>
    </operation>        
    <operation>  
      <search><![CDATA[return array(]]></search>
      <add position="after"><![CDATA[
        'price_text' => $price_text,
      ]]></add>
    </operation>        
  </file>
  <file path="catalog/controller/*/*.php">
    <operation error="skip">                           
      <search><![CDATA[$this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')]]></search>
      <add position="replace"><![CDATA[(isset($result['price_text']) ? $result['price_text'] : '').$this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')]]></add>
    </operation>        
    <operation error="skip">                           
      <search><![CDATA[$this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')]]></search>
      <add position="replace"><![CDATA[(isset($product_info['price_text']) ? $product_info['price_text'] : '').$this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')]]></add>
    </operation>        
  </file>
  
</modification>

 

Share this post


Link to post
Share on other sites
В 26.12.2019 в 18:02, surlan сказал:

Всем привет!

Как можно реализовать возможность вывода в категории минимальную стоимость из списка опций товара, если основная стоимость товара равна 0? Нашел на форуме вот такой модификатор (вроде рабочий, но у меня не сработал).

Версия движка 2.3, модификатор (по словам автора) тоже тестировался на этой версии. Кто что думает?

 


<?xml version="1.0" encoding="UTF-8"?>
<modification>
  <name>Нулевая цена в категории заменяется на цену опции OC2.3</name>
  <code>fix-zero-2x</code>
  <version>2.0.0</version>
  <vqmver></vqmver>
  <link></link>
  <author>mpn2005</author>
  <date>2017.12.14</date>
  
  <file path="catalog/model/catalog/product.php">
    <operation>  
      <search><![CDATA[return array(]]></search>
      <add position="before"><![CDATA[
        $price_text = '';
        if (!(float)$query->row['price']) {
            $option_price_query = $this->db->query("SELECT price FROM " . DB_PREFIX . "product_option_value WHERE product_id = '" . (int)$query->row['product_id'] . "' AND (subtract = '0' OR quantity > '0') AND (price_prefix = '=') ORDER BY price LIMIT 1");
            if ($option_price_query->num_rows) {
                $query->row['price'] = $option_price_query->row['price'];
                $price_text = '<span style="font-weight:normal;">от</span> ';
            }
        }
      ]]></add>
    </operation>        
    <operation>  
      <search><![CDATA[return array(]]></search>
      <add position="after"><![CDATA[
        'price_text' => $price_text,
      ]]></add>
    </operation>        
  </file>
  <file path="catalog/controller/*/*.php">
    <operation error="skip">                           
      <search><![CDATA[$this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')]]></search>
      <add position="replace"><![CDATA[(isset($result['price_text']) ? $result['price_text'] : '').$this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')]]></add>
    </operation>        
    <operation error="skip">                           
      <search><![CDATA[$this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')]]></search>
      <add position="replace"><![CDATA[(isset($product_info['price_text']) ? $product_info['price_text'] : '').$this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')]]></add>
    </operation>        
  </file>
  
</modification>

 

Актуально еще?

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.


  • 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.