Page 1 of 1

vqmod not working correctly in finding string.

Posted: Tue Sep 15, 2015 1:58 pm
by jasonc310771
I have removed all other vqmods and ocmods, and I use the original core files.

For some reason the follow is not able to find

if (isset($this->request->get['filter_model'])) {
$filter_model = $this->request->get['filter_model'];

in

admin/controller/catalog/product.php

even though it is there...

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<modification>
    <id>Show date_modified on admin product listing page</id>
    <version>1.0</version>
    <name>Show date_modified on admin product listing page</name>
    <code>Show_date_modified_on_admin_product_listing_page</code>
    <author>Jason</author>
    <file path="admin/controller/catalog/product.php">
        <operation>
            <search><![CDATA[
if (isset($this->request->get['filter_model'])) {
$filter_model = $this->request->get['filter_model'];
            ]]></search> 
            <add position="before"><![CDATA[
		if (isset($this->request->get['filter_date_modified'])) {
			$filter_date_modified = $this->request->get['filter_date_modified'];
            ]]>
            </add>
        </operation>
        <operation>
            <search><![CDATA[
		if (isset($this->request->get['filter_model'])) {
			$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
            ]]></search> 
            <add position="before"><![CDATA[
		if (isset($this->request->get['filter_date_modified'])) {
			$url .= '&filter_date_modified=' . urlencode(html_entity_decode($this->request->get['filter_date_modified'], ENT_QUOTES, 'UTF-8'));
		}
            ]]>
            </add>
        </operation>
        <operation>
            <search><![CDATA[
			'filter_model'	  => $filter_model,
            ]]></search> 
            <add position="before"><![CDATA[
			'filter_name'	  => $filter_date_modified,
            ]]>
            </add>
        </operation>
        <operation>
            <search><![CDATA[
				'model'      => $result['model'],
            ]]></search> 
            <add position="before"><![CDATA[
				'date_modified'       => $result['date_modified'],
            ]]>
            </add>
        </operation>
        <operation>
            <search><![CDATA[
		$data['column_model'] = $this->language->get('column_model');
            ]]></search> 
            <add position="before"><![CDATA[
		$data['column_date_modified'] = $this->language->get('column_date_modified');
            ]]>
            </add>
        </operation>
        <operation>
            <search><![CDATA[
		$data['sort_model'] = $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . '&sort=p.model' . $url, 'SSL');
            ]]></search> 
            <add position="before"><![CDATA[
		$data['sort_date_modified'] = $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . '&sort=pd.date_modified' . $url, 'SSL');
            ]]>
            </add>
        </operation>
        <operation>
            <search><![CDATA[
		$data['filter_model'] = $filter_model;
            ]]></search> 
            <add position="before"><![CDATA[
		$data['filter_date_modified'] = $filter_date_modified;
            ]]>
            </add>
        </operation>
    </file>
    <file path="admin/view/template/catalog/product_list.tpl">
        <operation>
            <search><![CDATA[
             <td class="text-left"><?php if ($sort == 'p.model') { ?>
            ]]></search>
            <add position="before"><![CDATA[
                  <td class="text-left"><?php if ($sort == 'pd.date_modified') { ?>
                    <a href="<?php echo $sort_date_modified; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_date_modified; ?></a>
                    <?php } else { ?>
                    <a href="<?php echo $sort_date_modified; ?>"><?php echo $column_date_modified; ?></a>
                    <?php } ?></td>
            ]]>
            </add>
        </operation>
        <operation>
            <search><![CDATA[
             <td class="text-left"><?php echo $product['model']; ?></td>
            ]]></search>
            <add position="before"><![CDATA[
                  <td class="text-left"><?php echo $product['date_modified']; ?></td>
            ]]>
            </add>
        </operation>
        <operation>
            <search><![CDATA[
             var filter_model = $('input[name=\'filter_model\']').val();
            ]]></search>
            <add position="before"><![CDATA[
	var filter_date_modified = $('input[name=\'filter_date_modified\']').val();

	if (filter_date_modified) {
		url += '&filter_date_modified=' + encodeURIComponent(filter_date_modified);
	}
            ]]>
            </add>
        </operation>
    </file>
</modification>
But I get these errors...

Notice: Undefined variable: filter_date_modified in /home/****/public_html/test/system/modification/admin/controller/catalog/product.php on line 331
Notice: Undefined variable: filter_date_modified in /home/****/public_html/test/system/modification/admin/controller/catalog/product.php on line 521


2015-09-15 9:40:11 - MOD: Modification Default
FILE: system/engine/action.php
REGEX: ~(require|include)(_once)?\(([^)]+)~
LINE: 58
FILE: system/engine/loader.php
REGEX: ~(require|include)(_once)?\(([^)]+)~
LINE: 20
LINE: 37
LINE: 54
LINE: 65
FILE: system/library/config.php
REGEX: ~(require|include)(_once)?\(([^)]+)~
LINE: 23
FILE: system/library/language.php
REGEX: ~(require|include)(_once)?\(([^)]+)~
LINE: 21
LINE: 27
----------------------------------------------------------------
MOD: Show date_modified on admin product listing page
FILE: admin/controller/catalog/product.php
CODE: if (isset($this->request->get['filter_model'])) {
$filter_model = $this->request->get['filter_model'];
NOT FOUND!
CODE: if (isset($this->request->get['filter_model'])) {
$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
NOT FOUND!
CODE: 'filter_model' => $filter_model,
LINE: 332
CODE: 'model' => $result['model'],
LINE: 374
LINE: 1445
CODE: $data['column_model'] = $this->language->get('column_model');
LINE: 396
CODE: $data['sort_model'] = $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . '&sort=p.model' . $url, 'SSL');
LINE: 472
CODE: $data['filter_model'] = $filter_model;
LINE: 522
FILE: admin/view/template/catalog/product_list.tpl
CODE: <td class="text-left"><?php if ($sort == 'p.model') { ?>
LINE: 94
CODE: <td class="text-left"><?php echo $product['model']; ?></td>
LINE: 135
CODE: var filter_model = $('input[name=\'filter_model\']').val();
LINE: 186
----------------------------------------------------------------

Re: vqmod not working correctly in finding string.

Posted: Thu Sep 17, 2015 11:25 pm
by clorne
As stanadard vQmod/OCMOD searches will only find single lines.

There are several workarounds including

http://forum.opencart.com/viewtopic.php?f=183&t=139813
http://www.opencartjazz.com/en/opencart ... -installer

but I would stick with searching for single lines.

Re: vqmod not working correctly in finding string.

Posted: Fri Sep 18, 2015 2:56 am
by jasonc310771
I would also like to stick with single, but with the file I need to alter there are a lot of lines the same, but I need to change add code before certin ones and not all of them.

I do not like the idea of changing the core code. Has anyone else used this method without any issues ?

I just re-read the second link and see that it is a 'fix'

Is this a fix or a suggested change to the core files?

If its a fix to the original code then I would be happy to use the newer code.

Re: vqmod not working correctly in finding string.

Posted: Fri Sep 18, 2015 2:59 am
by Qphoria
You should be using a more unique string.. or use the index="1" attribute on the search tag that tells it to only apply to certain instances, counting from the top down.

what is your actual operation... perhaps we can recommend a cleaner approach.

Re: vqmod not working correctly in finding string.

Posted: Fri Sep 18, 2015 3:07 am
by jasonc310771
True there is the index method I hear of, but what if another vqmod or ocmod is adding something as well to the same file which is the case then it would not work properly.

What I am looking to add is a Date_Modified column to the product view page in admin. But also have the same function as the other columns, to sort by that column.