1

I'm integrating Magento 2 with NetSuite CRM.
I'm following this GitHub doc
I want all of the services provided in there

There are 3 files

1. NSconfig.php
2. NSPHPClient.php
3. NetSuiteService.php

The third one files contain 1,41,203 line of PHP code with 1587 classes.

How can I use it in Magento 2 and write every class in a single file and load each of them programmatically?

Any idea or suggestion would be great for me.

Thanks in advance.

  • Have you found solution? – Sneha Panchal Jan 8 '18 at 7:31
  • Please check my answer. – Bhavin Shah Jan 8 '18 at 7:40
2

Dont create the files. Use composer install

composer require travisghansen/netsuite-php-toolkit
  • 1
    Thank you, Krishnan. Will it work for all of the NetSuite services? – Bhavin Shah Dec 11 '17 at 7:35
  • 1
    Yes you can access classes using namspace – Krishnan Daiva Dec 11 '17 at 7:37
  • 1
    Can you please share example or documentation for this? – Bhavin Shah Dec 11 '17 at 9:09
  • 1
    It is giving me an error Exception #0 (RuntimeException): Class NetSuite\NetSuiteService does not exist – Bhavin Shah Dec 11 '17 at 9:30
  • is ther class NetSuiteService in that module? – Krishnan Daiva Dec 11 '17 at 9:39
2

I just done below thing in magento 2 and got what I wanted

  1. NSconfig.php
  2. NSPHPClient.php
  3. NetSuiteService.php

I just put above core PHP files in app/code/MyNamespace/MyModule/Netsuit

Then I created Model app/code/MyNamespace/MyModule/Model/NetsuitData.php

With below contents

<?php
namespace MyNamespace\MyModule\Model;
require_once dirname(__DIR__).'/Netsuit/NetSuiteService.php';
class NetsuitData
{
}

when I want to use all 1587 classes, I just instantiate above class and I'm able to use all the classes of NetSuite.

Thank You!

  • It works like a charm!!! – Sneha Panchal Jan 8 '18 at 7:37
  • You saved my day and It works for me. – Rajan Soni Jan 8 '18 at 7:37
0

Split up that file and implement a sane layout in the one class per file paradigm.

Btw. use an autoloader ...

  • I've resolved it and got solution please check. – Bhavin Shah Jan 8 '18 at 7:43
  • We do not need to spit anything. – Bhavin Shah Jan 8 '18 at 7:43
  • that's not a solution but a mere workaround around very bad code, sorry – steros Jan 8 '18 at 7:43
  • That is fine. It is correct code. Thank you for trying to help :) – Bhavin Shah Jan 8 '18 at 7:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.