Post by abuobaida » Thu Oct 14, 2021 5:23 pm

HELLO ,
I'm trying to have my own extension with specific modification in some files after I install the extension I Modifications appear in the modification lists at the admin panel but not apply the changes in the files , I'm using Opencart .
I've checked every thing is correct as far as I know : upload folder and install.xml

the modification list is here :

Code: Select all

[code]
----------------------------------------------------------------
MOD: MegaIntegration 

FILE: admin/controller/common/dashboard.php
CODE: $data['security'] = $this->load->controller('common/security');
LINE: 83

FILE: catalog/controller/checkout/confirm.php
CODE: $order_data = array();
LINE: 56
CODE: $this->response->setOutput($this->load->view('checkout/confirm', $data));
LINE: 449

FILE: catalog/controller/checkout/success.php
CODE: if (isset($this->session->data['order_id'])) {
LINE: 5

FILE: catalog/model/checkout/order.php
CODE: class ModelCheckoutOrder extends Model {
LINE: 46

FILE: catalog/model/extension/shipping/pickup.php
CODE: class ModelExtensionShippingPickup extends Model {
LINE: 28
CODE: $method_data = array();
LINE: 46
----------------------------------------------------------------
[/code]

here also my xml file :

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<modification>
	<id>mega_integration</id>
	<name>MegaIntegration </name>
	<code>mega_integration</code>
	<version>1.0.0</version>
	<author>Mega</author>
	<link>https://mega-technology.info</link>

	<!-- <file path="admin/controller/common/dashboard.php">
		<operation>
			<search><![CDATA[$data['security'] = $this->load->controller('common/security');]]></search>
			<add position="replace"><![CDATA[$data['security'] = '';]]></add>
		</operation>
	</file> -->

	<file path="catalog/controller/checkout/confirm.php">
		<operation>
			<search><![CDATA[$order_data = array();]]></search>
			<add position="replace"><![CDATA[
			$order_data = array();]
				if($mega_data){
				$order_data['sector_id'] = $this->session->data['sector_id'];
				} 
			]]></add>
		</operation>
	</file>

	<file path="catalog/controller/checkout/success.php">
		<operation>
			<search><![CDATA[if (isset($this->session->data['order_id'])) {]]></search>
			<add position="replace"><![CDATA[
			if (isset($this->session->data['order_id'])) {
				$this->load->model('checkout/order');
			$order_data = $this->model_checkout_order->getOrder($this->session->data['order_id']);
			$products = $this->model_checkout_order->getOrderProducts($this->session->data['order_id']);
			$this->model_checkout_order->sendOrderToMega($this->session->data['order_id'],$order_data,$products);

			]]></add>
		</operation>
	</file>
	
	<file path="catalog/model/extension/shipping/pickup.php">
		<operation>
			<search><![CDATA[$method_data = array();]]></search>
			<add position="after"><![CDATA[
			$total =  $this->getDeliveryCost($address['zone_id']);

			]]></add>
		</operation>
	</file>
</modification>
any suggestion please?

Newbie

Posts

Joined
Mon Sep 27, 2021 9:41 pm

Post by straightlight » Thu Oct 14, 2021 9:54 pm

abuobaida wrote:
Thu Oct 14, 2021 5:23 pm
HELLO ,
I'm trying to have my own extension with specific modification in some files after I install the extension I Modifications appear in the modification lists at the admin panel but not apply the changes in the files , I'm using Opencart .
I've checked every thing is correct as far as I know : upload folder and install.xml

the modification list is here :

Code: Select all

[code]
----------------------------------------------------------------
MOD: MegaIntegration 

FILE: admin/controller/common/dashboard.php
CODE: $data['security'] = $this->load->controller('common/security');
LINE: 83

FILE: catalog/controller/checkout/confirm.php
CODE: $order_data = array();
LINE: 56
CODE: $this->response->setOutput($this->load->view('checkout/confirm', $data));
LINE: 449

FILE: catalog/controller/checkout/success.php
CODE: if (isset($this->session->data['order_id'])) {
LINE: 5

FILE: catalog/model/checkout/order.php
CODE: class ModelCheckoutOrder extends Model {
LINE: 46

FILE: catalog/model/extension/shipping/pickup.php
CODE: class ModelExtensionShippingPickup extends Model {
LINE: 28
CODE: $method_data = array();
LINE: 46
----------------------------------------------------------------
[/code]

here also my xml file :

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<modification>
	<id>mega_integration</id>
	<name>MegaIntegration </name>
	<code>mega_integration</code>
	<version>1.0.0</version>
	<author>Mega</author>
	<link>https://mega-technology.info</link>

	<!-- <file path="admin/controller/common/dashboard.php">
		<operation>
			<search><![CDATA[$data['security'] = $this->load->controller('common/security');]]></search>
			<add position="replace"><![CDATA[$data['security'] = '';]]></add>
		</operation>
	</file> -->

	<file path="catalog/controller/checkout/confirm.php">
		<operation>
			<search><![CDATA[$order_data = array();]]></search>
			<add position="replace"><![CDATA[
			$order_data = array();]
				if($mega_data){
				$order_data['sector_id'] = $this->session->data['sector_id'];
				} 
			]]></add>
		</operation>
	</file>

	<file path="catalog/controller/checkout/success.php">
		<operation>
			<search><![CDATA[if (isset($this->session->data['order_id'])) {]]></search>
			<add position="replace"><![CDATA[
			if (isset($this->session->data['order_id'])) {
				$this->load->model('checkout/order');
			$order_data = $this->model_checkout_order->getOrder($this->session->data['order_id']);
			$products = $this->model_checkout_order->getOrderProducts($this->session->data['order_id']);
			$this->model_checkout_order->sendOrderToMega($this->session->data['order_id'],$order_data,$products);

			]]></add>
		</operation>
	</file>
	
	<file path="catalog/model/extension/shipping/pickup.php">
		<operation>
			<search><![CDATA[$method_data = array();]]></search>
			<add position="after"><![CDATA[
			$total =  $this->getDeliveryCost($address['zone_id']);

			]]></add>
		</operation>
	</file>
</modification>
any suggestion please?
OC version. Contact the extension developer for those inquiries.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by abuobaida » Thu Oct 14, 2021 9:58 pm

OpenCart Version 3.0.3.8 , I'm developing the extension and trying to modify some core files

Newbie

Posts

Joined
Mon Sep 27, 2021 9:41 pm

Post by OSWorX » Thu Oct 14, 2021 11:00 pm

abuobaida wrote:
Thu Oct 14, 2021 5:23 pm
I'm trying to have my own extension with specific modification in some files after I install the extension I Modifications appear in the modification lists at the admin panel but not apply the changes in the files , I'm using Opencart .
I've checked every thing is correct as far as I know : upload folder and install.xml
After you have posted your exact OpenCart version (which btw. is mandatory to get further help), you tell us that the changes are not applied.
As far as I can see, you try to modify 3 different files.

First: using OCMod is a very bad idea.
Better to achieve that with events.

Second: which changes are not applied?
Post more details, currently no further help is possible.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by abuobaida » Thu Oct 14, 2021 11:08 pm

OSWorX wrote:
Thu Oct 14, 2021 11:00 pm
abuobaida wrote:
Thu Oct 14, 2021 5:23 pm
I'm trying to have my own extension with specific modification in some files after I install the extension I Modifications appear in the modification lists at the admin panel but not apply the changes in the files , I'm using Opencart .
I've checked every thing is correct as far as I know : upload folder and install.xml
After you have posted your exact OpenCart version (which btw. is mandatory to get further help), you tell us that the changes are not applied.
As far as I can see, you try to modify 3 different files.

First: using OCMod is a very bad idea.
Better to achieve that with events.

Second: which changes are not applied?
Post more details, currently no further help is possible.
Thanks for your reply
All of the modifications that I'm trying to make it didn't apply in those files
Sorry , how can I achieve it using events I'm new in opencart ?
the changes are all functions as you can see.
appreciated your help

Newbie

Posts

Joined
Mon Sep 27, 2021 9:41 pm

Post by straightlight » Thu Oct 14, 2021 11:15 pm

abuobaida wrote:
Thu Oct 14, 2021 11:08 pm
OSWorX wrote:
Thu Oct 14, 2021 11:00 pm
abuobaida wrote:
Thu Oct 14, 2021 5:23 pm
I'm trying to have my own extension with specific modification in some files after I install the extension I Modifications appear in the modification lists at the admin panel but not apply the changes in the files , I'm using Opencart .
I've checked every thing is correct as far as I know : upload folder and install.xml
After you have posted your exact OpenCart version (which btw. is mandatory to get further help), you tell us that the changes are not applied.
As far as I can see, you try to modify 3 different files.

First: using OCMod is a very bad idea.
Better to achieve that with events.

Second: which changes are not applied?
Post more details, currently no further help is possible.
Thanks for your reply
All of the modifications that I'm trying to make it didn't apply in those files
Sorry , how can I achieve it using events I'm new in opencart ?
the changes are all functions as you can see.
appreciated your help
Core files should not be modified. As for the Event Triggers, see this documentation: https://github.com/opencart/opencart/wiki/Events-System

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by abuobaida » Thu Oct 14, 2021 11:26 pm

straightlight wrote:
Thu Oct 14, 2021 11:15 pm
abuobaida wrote:
Thu Oct 14, 2021 11:08 pm
OSWorX wrote:
Thu Oct 14, 2021 11:00 pm


After you have posted your exact OpenCart version (which btw. is mandatory to get further help), you tell us that the changes are not applied.
As far as I can see, you try to modify 3 different files.

First: using OCMod is a very bad idea.
Better to achieve that with events.

Second: which changes are not applied?
Post more details, currently no further help is possible.
Thanks for your reply
All of the modifications that I'm trying to make it didn't apply in those files
Sorry , how can I achieve it using events I'm new in opencart ?
the changes are all functions as you can see.
appreciated your help
Core files should not be modified. As for the Event Triggers, see this documentation: https://github.com/opencart/opencart/wiki/Events-System
Thanks for help , I'm not modify something or remove , I'm adding new function to them like sending some request to other server and getting data from them . can I add new function using events ?

Newbie

Posts

Joined
Mon Sep 27, 2021 9:41 pm

Post by OSWorX » Thu Oct 14, 2021 11:33 pm

abuobaida wrote:
Thu Oct 14, 2021 11:26 pm
Thanks for help , I'm not modify something or remove , I'm adding new function to them like sending some request to other server and getting data from them . can I add new function using events ?
In short: yes.
More: you can do much more with events you ever will "reach" with OCMods, even to replace complete function just with 1 line of code.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by OSWorX » Thu Oct 14, 2021 11:40 pm

Really not clear how such should work.
For example (your code):

Code: Select all

<search><![CDATA[$data['security'] = $this->load->controller('common/security');]]></search>
			<add position="replace"><![CDATA[$data['security'] = '';]]></add>
Here you are looking for the line

Code: Select all

$data['security'] = $this->load->controller('common/security');
But where should that be?
Not a line of the core, maybe added by some other extension?

Then:

Code: Select all

$this->model_checkout_order->sendOrderToMega($this->session->data['order_id'],$order_data,$products);
For that, you have to modify first the checkout/order model to add the new function- why?
Instead add a new model (e.g. extension/module/somewhat/mega) and call that - therefore you have not to modify existing files.
Which btw. should not be done.

Are you sure you know what you are doing?
All a bit confusing what you are describing .. or is there more you not telling us?

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by abuobaida » Fri Oct 15, 2021 12:04 am

OSWorX wrote:
Thu Oct 14, 2021 11:40 pm
Really not clear how such should work.
For example (your code):

Code: Select all

<search><![CDATA[$data['security'] = $this->load->controller('common/security');]]></search>
			<add position="replace"><![CDATA[$data['security'] = '';]]></add>
Here you are looking for the line

Code: Select all

$data['security'] = $this->load->controller('common/security');
But where should that be?
Not a line of the core, maybe added by some other extension?

Then:

Code: Select all

$this->model_checkout_order->sendOrderToMega($this->session->data['order_id'],$order_data,$products);
For that, you have to modify first the checkout/order model to add the new function- why?
Instead add a new model (e.g. extension/module/somewhat/mega) and call that - therefore you have not to modify existing files.
Which btw. should not be done.

Are you sure you know what you are doing?
All a bit confusing what you are describing .. or is there more you not telling us?

Code: Select all

<search><![CDATA[$data['security'] = $this->load->controller('common/security');]]></search>
			<add position="replace"><![CDATA[$data['security'] = '';]]></add>
Thanks actually this line I forget to remove I was trying some solution


the thing is I have made this function on the order model as you said

Code: Select all

this->model_checkout_order->sendOrderToMega()
my code of extension all about getting price of delivery from api and adding them to the checkout and delivery page to sum them with the price and after the order confirmed successfully send the order data to the api using this function .

I made all the change manually and all work fine so I was trying to do it using ocmod for the files on :
model/order.php
catalog/controller/checkout/confrim.php
catalog/controller/checkout/success.php
catalog/controller/extension/shipping/pickup.php

Newbie

Posts

Joined
Mon Sep 27, 2021 9:41 pm

Post by OSWorX » Fri Oct 15, 2021 12:34 am

As written before: try to achieve this with events not via OCMod.
Second: if the "hard coded" solution works, your mod should also ..
So, does it work now - or not?

Final note: why should modifications via OCMod be avoided?
Because in future versions of Opencart, OCMod does not work anymore - only events.
So better to do it the "right" way, you will learn a lot and have a solution which work also in future versions of Opencart.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by straightlight » Fri Oct 15, 2021 3:12 am

abuobaida wrote:
Thu Oct 14, 2021 11:26 pm
straightlight wrote:
Thu Oct 14, 2021 11:15 pm
abuobaida wrote:
Thu Oct 14, 2021 11:08 pm


Thanks for your reply
All of the modifications that I'm trying to make it didn't apply in those files
Sorry , how can I achieve it using events I'm new in opencart ?
the changes are all functions as you can see.
appreciated your help
Core files should not be modified. As for the Event Triggers, see this documentation: https://github.com/opencart/opencart/wiki/Events-System
Thanks for help , I'm not modify something or remove , I'm adding new function to them like sending some request to other server and getting data from them . can I add new function using events ?
You can add both; either new methods or functions since Event Triggers are normally used as callbacks of the original controllers being launched from the Loader Engine.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Users browsing this forum: No registered users and 121 guests