Magento Expert Forum - Improve your Magento experience
-
Integrating PHP function or API with Magento 2
I have just installed Magento 2 community edition and getting the hang of of using it. I am curious to know though, if I have a php function (called for example like: my_function(param1, param2, param3) ) or if I downloaded an API that I wanted to use with my shopping site, how would I integrate these with Magento?
View more threads in the same category:
-
-
You need to implement your custom code in term of any class in extension and then use Magento 2 object manager instance feature to call it. Here is example code in which I have used Magento 2 log functionlity:
$om = \Magento\Framework\App\ObjectManager::getInstance( );
$storeManager = $om->get('Psr\Log\LoggerInterface');
In this code, replace "Psr\Log\LoggerInterface" with your file path and then use $storeManager to call your function like $storeManager->my_function(param1, param2, param3).
-
-
Magento 2 support REST(Representational State Transfer) and SOAP, much like the old version of magento we were used to. Official documentation is mostly based on raw curl request without examples in some specific language. PHP is what we do and there will be many people using it as well.
There are three user types that have access to API in magento,
1, Guest user
2, Administrator/Integration
3, Customer
-
-
went trough on how to configure integration and utilize Magento 2 apis. You would need only two things, module.xml and register.php for Within model we add our functionality that will be executed by call to API method.
-
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks