From 0677686fa9dc7686aa6ae2a66e7bee8f32626048 Mon Sep 17 00:00:00 2001 From: yusufpangal Date: Sat, 24 May 2025 02:31:43 +0300 Subject: [PATCH 1/2] Updated Hello World message --- Block/Example.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Block/Example.php b/Block/Example.php index 5303b77..fb78ac9 100644 --- a/Block/Example.php +++ b/Block/Example.php @@ -18,6 +18,6 @@ class Example extends Template * @return string */ public function getContent() { - return "Hello World"; + return "Hello World, Welcome to Magento"; } } \ No newline at end of file From 71fed8f833c383d1b3c4c7832b08e98e633582ec Mon Sep 17 00:00:00 2001 From: yusufpangal Date: Sat, 24 May 2025 03:08:32 +0300 Subject: [PATCH 2/2] OpenAI chat integration --- etc/frontend/routes.xml | 11 +++-------- view/frontend/templates/chat.phtml | 10 ++++++++++ view/frontend/web/js/chat.js | 17 +++++++++++++++++ 3 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 view/frontend/templates/chat.phtml create mode 100644 view/frontend/web/js/chat.js diff --git a/etc/frontend/routes.xml b/etc/frontend/routes.xml index b85b4e5..4dad8ee 100644 --- a/etc/frontend/routes.xml +++ b/etc/frontend/routes.xml @@ -1,8 +1,3 @@ - - - - - - - - + + + diff --git a/view/frontend/templates/chat.phtml b/view/frontend/templates/chat.phtml new file mode 100644 index 0000000..df68307 --- /dev/null +++ b/view/frontend/templates/chat.phtml @@ -0,0 +1,10 @@ +
+ + +
+
+ diff --git a/view/frontend/web/js/chat.js b/view/frontend/web/js/chat.js new file mode 100644 index 0000000..28f07d2 --- /dev/null +++ b/view/frontend/web/js/chat.js @@ -0,0 +1,17 @@ +define(['jquery'], function($) { + 'use strict'; + return function(config, element) { + .on('submit', function(event) { + event.preventDefault(); + var message = .val(); + $.ajax({ + url: '/openai/chat', + type: 'POST', + data: { message: message }, + success: function(response) { + .append('
' + response + '
'); + } + }); + }); + }; +});