Post by azzi-charbel » Tue Jan 19, 2021 11:43 pm

Hello,
I am new to Opencart development and below in my first extension but somehow after installing it and clearing all modifications, it is not making any changes to my store (specifically to catalog > products page)

Can anyone please point me to the issue ?

For OC v3.0.3.6, I have created an "install.xml" file where I have added the below code:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<modification>
    <name>Sort Admin Products by ID (V3x)</name>
    <code>sort_admin_products_by_id</code>
    <version>3.0</version>
    <author>azzicharbel</author>

    <file path="admin/view/template/catalog/product_list.twig">
		<operation>
			<search><![CDATA[<td class="text-center">{{ column_image }}</td>]]></search>
			<add position="before"><![CDATA[
				<td class="text-center">{% if sort == 'p.product_id' %} <a href="{{ sort_product_id }}" class="{{ order|lower }}">ID</a> {% else %} <a href="{{ sort_product_id }}">ID</a> {% endif %}</td>
	            ]]></add>
		</operation>
		<operation>
			<search><![CDATA[<td class="text-center">{% if product.image %} <img src="{{ product.image }}" alt="{{ product.name }}" class="img-thumbnail" /> {% else %} <span class="img-thumbnail list"><i class="fa fa-camera fa-2x"></i></span> {% endif %}</td>]]></search>
			<add position="before"><![CDATA[
				<td class="text-center">{{ product.product_id }}</td>
	            ]]></add>
		</operation>
	</file>
	<file path="admin/controller/catalog/product.php">
		<operation>
			<search><![CDATA[$data['sort_name'] = $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . '&sort=pd.name' . $url, true);]]></search>
			<add position="before"><![CDATA[
				$data['sort_product_id'] = $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . '&sort=p.product_id' . $url, true);
	            ]]></add>
		</operation>
		<operation>
			<search><![CDATA[$sort = 'pd.name';]]></search>
			<add position="replace"><![CDATA[
				$sort = 'p.product_id';
	            ]]></add>
		</operation>
		<operation>
			<search><![CDATA[$order = 'ASC';]]></search>
			<add position="replace"><![CDATA[
				$order = 'DESC';
	            ]]></add>
		</operation>
	</file>
	<file path="admin/model/catalog/product.php">
		<operation>
			<search><![CDATA[$sort_data = array(]]></search>
			<add position="after"><![CDATA[
				'p.product_id',
	            ]]></add>
		</operation>
	</file>
</modification>

New member

Posts

Joined
Wed Nov 06, 2019 8:30 pm

Post by straightlight » Tue Jan 19, 2021 11:46 pm

Ensure to install this patch: https://www.opencart.com/index.php?rout ... n_id=40451 . Then. clear your OC cache.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by azzi-charbel » Wed Jan 20, 2021 12:29 am

It is already applied a month ago and I have already many extension installed on my store with no problems at all.

New member

Posts

Joined
Wed Nov 06, 2019 8:30 pm

Post by by mona » Wed Jan 20, 2021 12:35 am

and have you checked your modification log to see if there is an error?

And just to make sure, go into modifications, go into the log, clear it using the red button and then refresh. This has two effects, one it solves the twig issue with modifications which can be a little buggy even with the fix AND will also give you a nice clean list of the current errors of all your modifications, so the above will be easier.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by straightlight » Wed Jan 20, 2021 12:44 am

azzi-charbel wrote:
Wed Jan 20, 2021 12:29 am
It is already applied a month ago and I have already many extension installed on my store with no problems at all.
Not mentioned on your first post. A month has already passed. Regarding the storage folder, see this FAQ (first post): viewtopic.php?f=134&t=215776#p717782 .

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by azzi-charbel » Wed Jan 20, 2021 7:43 am

The error log is totally clear after installing my custom module... no errors displayed !

any ideas please ? is there something wrong with my code ?

the weird is if I manually apply the changes listed in my "install.xml" file, and then refresh all modifications... the changes took effect at catalog > product page !
This make me believe that there is something wrong in my code !

New member

Posts

Joined
Wed Nov 06, 2019 8:30 pm

Post by mikeinterserv » Wed Jan 20, 2021 7:50 am

azzi-charbel wrote:
Tue Jan 19, 2021 11:43 pm
<operation>
<search><![CDATA[$sort_data = array(]]></search>
<add position="after"><![CDATA[
'p.product_id',
]]></add>
</operation>
Something looks wrong here

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by by mona » Wed Jan 20, 2021 8:06 am

azzi-charbel wrote:
Wed Jan 20, 2021 7:43 am
the weird is if I manually apply the changes listed in my "install.xml" file, and then refresh all modifications... the changes took effect at catalog > product page !
This make me believe that there is something wrong in my code !
The error log is totally clear
What do you mean by error log.

I appreciate language is an issue but you must be clearer.
Go into your extensions => modifications => log tab
THIS CAN NOT BE CLEAR !!!!!!!!
Please post it

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by azzi-charbel » Wed Jan 20, 2021 8:12 am

Code: Select all

<operation>
<search><![CDATA[$sort_data = array(]]></search>
<add position="after"><![CDATA[
'p.product_id',
]]></add>
</operation>
Here I am trying to add 'p.product_id', after $sort_data = array( so I don't think is wrong !

However, I have replace it with below code and yet no changes:

Code: Select all

<file path="admin/model/catalog/product.php">
		<operation>
			<search><![CDATA['pd.name',]]></search>
			<add position="before"><![CDATA[
				'p.product_id',
				]]></add>
		</operation>
	</file>

New member

Posts

Joined
Wed Nov 06, 2019 8:30 pm

Post by by mona » Wed Jan 20, 2021 8:19 am

There is nothing wrong with what you have written (on the big scale)
There is a conflict somewhere - or your modifications is playing up - that is all

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by xxvirusxx » Wed Jan 20, 2021 8:24 am

That extension work just fine.
Refresh ocmod then clear Theme cache, SASS cache.

My converted modules | Buy me a beer | Opencart upgrade service


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by azzi-charbel » Wed Jan 20, 2021 8:35 am

@by mona my bad, I was speaking about "System > Maintenance > Error Logs" Page which is showing no errors.

Step by Step:
1) Extensions > installer > uploading the custom extension (sort_admin_products_by_id.ocmod.zip)
2) Dashboard > Clear caches
3) Extensions > modifications > clear
4) Extensions > modifications > log page.

Every installed module has records on this page but my module (Mod: Sort Admin Products by ID (V3x)) does not have any records at all !!!

New member

Posts

Joined
Wed Nov 06, 2019 8:30 pm

Post by sw!tch » Wed Jan 20, 2021 8:38 am

You are not zipping it correctly.

Should be

Code: Select all

install.xml
upload (folder)
Then name it yourmod.ocmod.zip

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm
Location - USA

Post by mikeinterserv » Wed Jan 20, 2021 8:39 am

azzi-charbel wrote:
Wed Jan 20, 2021 8:12 am

Code: Select all

<operation>
<search><![CDATA[$sort_data = array(]]></search>
<add position="after"><![CDATA[
'p.product_id',
]]></add>
</operation>
How does that array work coded like that ?
and shouldn't that comma be a semi colon or nothing ?
Last edited by mikeinterserv on Wed Jan 20, 2021 8:46 am, edited 1 time in total.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by xxvirusxx » Wed Jan 20, 2021 8:40 am

Replace <operation> with <operation error="log"> and check modification log again.

sw!tch wrote:
Wed Jan 20, 2021 8:38 am
You are not zipping it correctly.

Should be

Code: Select all

install.xml
upload (folder)
Then name it yourmod.ocmod.zip
No need on 3.x if doesn't have files to upload.
Is enough to be zipped only install.xml

Attachments

Last edited by xxvirusxx on Wed Jan 20, 2021 8:45 am, edited 1 time in total.

My converted modules | Buy me a beer | Opencart upgrade service


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by sw!tch » Wed Jan 20, 2021 9:05 am

mikeinterserv wrote:
Wed Jan 20, 2021 8:39 am
azzi-charbel wrote:
Wed Jan 20, 2021 8:12 am

Code: Select all

<operation>
<search><![CDATA[$sort_data = array(]]></search>
<add position="after"><![CDATA[
'p.product_id',
]]></add>
</operation>
How does that array work coded like that ?
and shouldn't that comma be a semi colon or nothing ?
It's correct.

In short - Its searching for $sort_data = array(

Then its adding 'p.product_id', after

Which becomes

Code: Select all

$sort_data = array( 
'p.product_id', 
// existing code .... 
If it doesn't show up in modifications the problem is likely that it's not zipped properly. OP should try what @xxvirusxx uploaded.
-

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm
Location - USA

Post by mikeinterserv » Wed Jan 20, 2021 9:53 am

Why is there no need to close the opening ( below

In short - Its searching for $sort_data = array(

I can't find a reference to an array called in this way
sorry to get in the way of the thread.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by sw!tch » Wed Jan 20, 2021 10:04 am

mikeinterserv wrote:
Wed Jan 20, 2021 9:53 am
Why is there no need to close the opening ( below

In short - Its searching for $sort_data = array(

I can't find a reference to an array called in this way
sorry to get in the way of the thread.
Its not calling anything its a search and modification.

ex:

Code: Select all

$sort_data = array(
  'pd.name',
  'p.model',
  'p.price',
  'p.quantity',
  'p.status',
  'p.sort_order'
);
Becomes

Code: Select all

$sort_data = array(
  'p.product_id',
  'pd.name',
  'p.model',
  'p.price',
  'p.quantity',
  'p.status',
  'p.sort_order'
);
Refer to the documentation - https://github.com/opencart/opencart/wi ... ion-System

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm
Location - USA

Post by mikeinterserv » Wed Jan 20, 2021 10:42 am

Thanks for explaining
So the closing bracket does exist for that array just not in this code block. after its modified ?

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by azzi-charbel » Wed Jan 20, 2021 5:44 pm

Finally, it is working now !
Thank you guys for your kind help !

Explanation:
Mainly it was a zipping issue nothing more !

I did create a folder named "my-extension" and inside this folder I have created the "install.xml" file as below:

Code: Select all

- my-extension
-- install.xml
and I used to select the entire folder and create a zip file from it... This mainly was the issue and why Opencart was not reading my extension.

What I did now is creating a zip file directly from "install.xml" file and now the extension has been installed successfully !

Thank you agin for your help !

New member

Posts

Joined
Wed Nov 06, 2019 8:30 pm
Who is online

Users browsing this forum: No registered users and 4 guests