Page 1 of 1

new to old product sorting opencart 3.x

Posted: Mon Aug 13, 2018 7:41 pm
by kg0925
i have customize this ocmod to sort new to old products. newest product show first. but it's not working. did i any mistake. please look in to code and let me know. thanks.

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<modification>
	<name>latest to old Checker</name>
	<version>1.0</version>
	<author>KG</author>
	<code>latest_to_old_sorting</code>
	<link>fashiondeal.in</link>
	<file name="catalog/controller/product/category.php">
        <operation>
            <search><![CDATA[$sort = 'p.sort_order';]]></search>
            <add position="replace"><![CDATA[$sort = 'p.date_added';]]></add>
        </operation>
        <operation>
            <search><![CDATA[$order = 'ASC';]]></search>
            <add position="replace"><![CDATA[$order = 'DESC';]]></add>
        </operation>
        <operation>
            <search><![CDATA['value' => 'p.sort_order-ASC',]]></search>
            <add position="after" offset="3"><![CDATA[
			$this->data['sorts'][] = array(
				'text'  => $this->language->get('text_date_added_asc'),
				'value' => 'p.date_added-ASC',
				'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.date_added&order=ASC' . $url)
			);
			
			$this->data['sorts'][] = array(
				'text'  => $this->language->get('text_date_added_desc'),
				'value' => 'p.date_added-DESC',
				'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.date_added&order=DESC' . $url)
			);
            ]]></add>
        </operation>
	</file>
	<file name="catalog/language/*/product/category.php">
        <operation>
            <search><![CDATA[$_['text_default']      = 'Default';]]></search>
            <add position="after"><![CDATA[$_['text_date_added_desc']   = 'Date (Latest - Oldest)';
$_['text_date_added_asc']   = 'Date (Oldest - Latest)';
			]]></add>
        </operation>
	</file>
</modification>

Re: new to old product sorting opencart 3.x

Posted: Mon Aug 13, 2018 9:22 pm
by xxvirusxx
Change

Code: Select all

$this->data['sorts'][] = array(
in to

Code: Select all

$data['sorts'][] = array(

Re: new to old product sorting opencart 3.x

Posted: Wed Aug 15, 2018 1:00 pm
by kg0925
xxvirusxx wrote:
Mon Aug 13, 2018 9:22 pm
Change

Code: Select all

$this->data['sorts'][] = array(
in to

Code: Select all

$data['sorts'][] = array(
it's not working. any other solution? i just need to show newest products first on category page.

Re: new to old product sorting opencart 3.x

Posted: Thu Aug 16, 2018 12:58 am
by cyclops12
Try this

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<modification>
	<name>latest to old Checker</name>
	<version>1.0</version>
	<author>KG</author>
	<code>latest_to_old_sorting</code>
	<link>fashiondeal.in</link>
	<file name="catalog/controller/product/category.php">
        <operation>
            <search><![CDATA[$sort = 'p.sort_order';]]></search>
            <add position="replace"><![CDATA[$sort = 'p.date_added';]]></add>
        </operation>
        <operation>
            <search><![CDATA[$order = 'ASC';]]></search>
            <add position="replace"><![CDATA[$order = 'DESC';]]></add>
        </operation>
        <operation>
            <search><![CDATA['value' => 'p.sort_order-ASC',]]></search>
            <add position="after" offset="3"><![CDATA[
			$data['sorts'][] = array(
				'text'  => $this->language->get('text_date_added_asc'),
				'value' => 'p.date_added-ASC',
				'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.date_added&order=ASC' . $url)
			);
			
			$data['sorts'][] = array(
				'text'  => $this->language->get('text_date_added_desc'),
				'value' => 'p.date_added-DESC',
				'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.date_added&order=DESC' . $url)
			);
            ]]></add>
        </operation>
	</file>
	<file name="catalog/language/*/product/category.php">
        <operation>
            <search><![CDATA[$_['text_default']      = 'Default';]]></search>
            <add position="after"><![CDATA[$_['text_date_added_desc']   = 'Date (Latest - Oldest)';
$_['text_date_added_asc']   = 'Date (Oldest - Latest)';
			]]></add>
        </operation>
	</file>
</modification>

Re: new to old product sorting opencart 3.x

Posted: Wed Aug 22, 2018 7:42 pm
by kg0925
cyclops12 wrote:
Thu Aug 16, 2018 12:58 am
Try this

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<modification>
	<name>latest to old Checker</name>
	<version>1.0</version>
	<author>KG</author>
	<code>latest_to_old_sorting</code>
	<link>fashiondeal.in</link>
	<file name="catalog/controller/product/category.php">
        <operation>
            <search><![CDATA[$sort = 'p.sort_order';]]></search>
            <add position="replace"><![CDATA[$sort = 'p.date_added';]]></add>
        </operation>
        <operation>
            <search><![CDATA[$order = 'ASC';]]></search>
            <add position="replace"><![CDATA[$order = 'DESC';]]></add>
        </operation>
        <operation>
            <search><![CDATA['value' => 'p.sort_order-ASC',]]></search>
            <add position="after" offset="3"><![CDATA[
			$data['sorts'][] = array(
				'text'  => $this->language->get('text_date_added_asc'),
				'value' => 'p.date_added-ASC',
				'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.date_added&order=ASC' . $url)
			);
			
			$data['sorts'][] = array(
				'text'  => $this->language->get('text_date_added_desc'),
				'value' => 'p.date_added-DESC',
				'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.date_added&order=DESC' . $url)
			);
            ]]></add>
        </operation>
	</file>
	<file name="catalog/language/*/product/category.php">
        <operation>
            <search><![CDATA[$_['text_default']      = 'Default';]]></search>
            <add position="after"><![CDATA[$_['text_date_added_desc']   = 'Date (Latest - Oldest)';
$_['text_date_added_asc']   = 'Date (Oldest - Latest)';
			]]></add>
        </operation>
	</file>
</modification>
this mod is not working with installer. if i directly change it to modification file then it's working. seems like ocmod is not working properly

Re: new to old product sorting opencart 3.x

Posted: Thu Aug 23, 2018 12:39 am
by cyclops12
Sorry that is a vqmod file so will not work using installer.
Can be changed into ocmod though.