Post by xxvirusxx » Sat Apr 07, 2018 5:38 pm

Hy

Who can tell me what is wrong with this code?
I have a vqmod filter module from 2.3.0.2 and I want to convert to oc 3.0.2.0

Error code:

Code: Select all

Fatal error: Uncaught exception 'Twig_Error_Syntax' with message 'Unknown "category" test in "catalog/product_list.twig" at line 55
OC 2.3.0.2 code:

Code: Select all

			<div class="form-group">
			  <label class="control-label" for="input-status"><?php echo $column_category; ?></label>
			  <select name="filter_category" id="input-status" class="form-control">
              <option value="*"></option>
              <?php foreach ($categories as $category) { ?>
			  <?php if ($category['product_count'] >= 1) { ?>
                <?php if ($category['category_id']==$filter_category) { ?>
                  <option value="<?php echo $category['category_id']; ?>" selected="selected"> <?php echo $category['name']; ?>- (<?php echo $category['product_count']; ?>)</option>
                <?php } else { ?>
                  <option value="<?php echo $category['category_id']; ?>"> <?php echo $category['name']; ?> <?php if ($category['product_count'] >= 1) { ?>
				   <strong>&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;(<?php echo $category['product_count']; ?>)</strong>
				   <?php } ?></option> 
                <?php } ?>
              <?php } ?>
			  <?php } ?>
              </select>
			  </div>
OC 3.0.2.0 code

Code: Select all

			<div class="form-group">
			  <label class="control-label" for="input-status">{{ column_category }}</label>
			  <select name="filter_category" id="input-status" class="form-control">
              <option value="*"></option>
              {% for category in categories %} 
			  {% if category.product_count >= 1 %} 
                {% if category.category_id is filter_category %} 
                  <option value="{{ category.category_id }}" selected="selected"> {{ category.name }}  - ({{ category.product_count }} )</option>
                 {% else %}   
                  <option value="{{ category.category_id }}"> {{ category.name }}  {% if category.product_count >= 1 %} 
				   <strong> - ({{ category.product_count }} )</strong>
				   {% endif %} </option> 
                {% endif %} 
              {% endif %}
              </select>
			  </div>
Tks
Last edited by xxvirusxx on Sat Apr 07, 2018 7:06 pm, edited 1 time in total.

Active Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm

Post by DigitCart » Sat Apr 07, 2018 6:20 pm

Hi,
I can't see endfor in your code.

Code: Select all

{% endfor %}

My Extensions / DigitCart


User avatar
Active Member

Posts

Joined
Thu Jun 22, 2017 5:32 pm


Post by xxvirusxx » Sat Apr 07, 2018 6:44 pm

I tried with, and same error

Code: Select all

<div class="form-group">
			  <label class="control-label" for="input-status">{{ column_category }}</label>
			  <select name="filter_category" id="input-status" class="form-control">
              <option value="*"></option>
              {% for category in categories %} 
			  {% if category.product_count >= 1 %} 
                {% if category.category_id is filter_category %} 
                  <option value="{{ category.category_id }}" selected="selected"> {{ category.name }}  - ({{ category.product_count }} )</option>
                 {% else %}   
                  <option value="{{ category.category_id }}"> {{ category.name }}  {% if category.product_count >= 1 %} 
				   <strong> - ({{ category.product_count }} )</strong>
				   {% endif %} </option> 
                {% endif %} 
              {% endif %}
                            {% endfor %}
              </select>
			  </div>
Also I don`t know why give this error: 'Unknown "filter_category"
I have already lines in product.php from controller

Code: Select all

			if (isset($this->request->get['filter_category'])) {
                $url .= '&filter_category=' . $this->request->get['filter_category'];
            }
and

Code: Select all

		if (isset($this->request->get['filter_category'])) {
			$filter_category = $this->request->get['filter_category'];
		} else {
			$filter_category = '';
		}
If delete php code and leave only html code, I can see Category on filter :)
More testing :)

LE. Fixed

Code: Select all

			<div class="form-group">
			  <label class="control-label" for="input-status">{{ column_category }}</label>
			  <select name="filter_category" id="input-status" class="form-control">
                <option value="*"></option>
                    {% for category in categories %}
                    {% if category.product_count >= 1 %}
                    {% if category.category_id == filter_category %} 
                <option value="{{ category.category_id }}" selected="selected"> {{ category.name }}  - ({{ category.product_count }} )</option>
                  {% else %}
                <option value="{{ category.category_id }}"> {{ category.name }}  {% if category.product_count >= 1 %} 
				   <strong>-({{ category.product_count }} )</strong>
				   {% endif %} </option>
                  {% endif %}
                  {% endif %}
                {% endfor %}
              </select>
			  </div>

Attachments

Screenshot_2018-04-07_13-47-07.png

Screenshot_2018-04-07_13-47-07.png (15.71 KiB) Viewed 243 times


Active Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Who is online

Users browsing this forum: No registered users and 8 guests