Page 1 of 2

[SOLVED] Installing my custom extension make no changes to my store

Posted: Tue Jan 19, 2021 11:43 pm
by azzi-charbel
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>

Re: Installing my custom extension make no changes to my store

Posted: Tue Jan 19, 2021 11:46 pm
by straightlight
Ensure to install this patch: https://www.opencart.com/index.php?rout ... n_id=40451 . Then. clear your OC cache.

Re: Installing my custom extension make no changes to my store

Posted: Wed Jan 20, 2021 12:29 am
by azzi-charbel
It is already applied a month ago and I have already many extension installed on my store with no problems at all.

Re: Installing my custom extension make no changes to my store

Posted: Wed Jan 20, 2021 12:35 am
by by mona
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.

Re: Installing my custom extension make no changes to my store

Posted: Wed Jan 20, 2021 12:44 am
by straightlight
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 .

Re: Installing my custom extension make no changes to my store

Posted: Wed Jan 20, 2021 7:43 am
by azzi-charbel
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 !

Re: Installing my custom extension make no changes to my store

Posted: Wed Jan 20, 2021 7:50 am
by mikeinterserv
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

Re: Installing my custom extension make no changes to my store

Posted: Wed Jan 20, 2021 8:06 am
by by mona
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

Re: Installing my custom extension make no changes to my store

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

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>

Re: Installing my custom extension make no changes to my store

Posted: Wed Jan 20, 2021 8:19 am
by by mona
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

Re: Installing my custom extension make no changes to my store

Posted: Wed Jan 20, 2021 8:24 am
by xxvirusxx
That extension work just fine.
Refresh ocmod then clear Theme cache, SASS cache.

Re: Installing my custom extension make no changes to my store

Posted: Wed Jan 20, 2021 8:35 am
by azzi-charbel
@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 !!!

Re: Installing my custom extension make no changes to my store

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

Should be

Code: Select all

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

Re: Installing my custom extension make no changes to my store

Posted: Wed Jan 20, 2021 8:39 am
by mikeinterserv
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 ?

Re: Installing my custom extension make no changes to my store

Posted: Wed Jan 20, 2021 8:40 am
by xxvirusxx
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

Re: Installing my custom extension make no changes to my store

Posted: Wed Jan 20, 2021 9:05 am
by sw!tch
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.
-

Re: Installing my custom extension make no changes to my store

Posted: Wed Jan 20, 2021 9:53 am
by mikeinterserv
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.

Re: Installing my custom extension make no changes to my store

Posted: Wed Jan 20, 2021 10:04 am
by sw!tch
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

Re: Installing my custom extension make no changes to my store

Posted: Wed Jan 20, 2021 10:42 am
by mikeinterserv
Thanks for explaining
So the closing bracket does exist for that array just not in this code block. after its modified ?

Re: Installing my custom extension make no changes to my store

Posted: Wed Jan 20, 2021 5:44 pm
by azzi-charbel
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 !