cancel
Showing results for 
Search instead for 
Did you mean: 

Update Extension from m1 to m2

Update Extension from m1 to m2

Hi Community

 

I'm very new in Magento 1 & 2.

So I know m1 only a bit, and I don't know m2 at all.

 

I have now to update some m1 extensions from my company to m2.

But because of my leak in my m1 knowhow, it's not as easy as I thought so.

 

The most extensions are payment modules with solvency checks or just a solvency check for existing payment methods.

 

Is there a list of what's changed for extension-developers?

I found some sites, which explain "how to make a extension in m2" but nothing like "how to update an extension to m2".

 

Or may someone can tell me what I'm doing wrong?

I did so far the following changes:

 

I created the the extension dir like "app/code/MyCompany/MyExtension" (name's are replaced, sry).
In this directory I created the files "composer.json" and "registration.php" with the following content:

 

composer.json:

{
  "name": "MyCompany/MyExtension",
  "description": "*MyExtension* Module by *MyCompany*",
  "require": {
      "php": "~5.5.0|~5.6.0|~7.0.0",
  },
  "type": "magento2-module",
  "version": "2.0.0",
  "autoload": {
      "files": [ "registration.php" ]
  },
  "extra": {
    "map": [
      [
        "*",
        "MyCompany/MyExtension"
      ]
    ]
  },
  "authors": [
    {
      "name": "MyCompany",
      "homepage": "http://www.MyCompany.ups/",
      "role": "Developer"
    }
  ]
}

registration.php

<?php

/**
 * This software is copyrighted by blablabla ...... shorted
 *
 * @category    MyCompany
 * @package     MyCompany_MyExtension
 * @author      me <****@***.***>
 */

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'MyCompany_MyExtension',
    __DIR__
);

So far, this should be okay. I readed a lot of Blogs and the Magento doc and everywhere it look like the same.

 

 Now I created the the app/code/MyCompany/MyExtension/etc/module.xml with a content like this:

 

<?xml version="1.0"?>

<!--
/**
 * This software is copyrighted ........ shorted, again ...
 *
 * @category    placeholder ...
 * @package     placeholder ...
 * @author      placeholder ..
 */
-->

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
  <module name="MyCompany_MyExtension" setup_version="2.0.0">
  </module>
</config>

 

Now I moved the translation files from /app/locale/lng_code/MyExtension.csv to app/code/MyCompany/MyExtension/i18n/*lng_code".csv.

 

Then I moved every thing, like it should by (by this link: magento/module-file-structure.html).

Some points I'm not sure at, are:

1. The js file which was in /js/ in m1. I moved it to "app/code/MyCompany/MyExtension/View/frontend/adminhtml/web/js/MyExtension.js".

2. The file "resources/connect.wsdl" I moved to the same place as it was in m1 (no change).

3. I moved the file "libraries/WSSoapClient/WSSoapClient.php" also to the same place as it was in m1 (no change).

 

Then I created the "Setup" folder with the file "InstallSchema.php":

<?php namespace MyCompany\MyExtension\Setup;
use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\DB\Ddl\Table;

class InstallSchema implements InstallSchemaInterface
{
    public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
      $installer = $setup;

      $installer->startSetup();

      $table = $installer->getConnection()
          ->newTable($installer->getTable('MyExtension/MyExtension')) //should it be MyCompnay/MyExtension ?
          ->addColumn(
              'id',
              Varien_DB_Ddl_Table::TYPE_BIGINT,
              null,
              array(
                  'unsigned' => true,
                  'nullable' => false,
                  'primary' => true,
              ),
              'Customer Address ID'
          )
          ->addColumn(
              'timestamp',
              Varien_DB_Ddl_Table::TYPE_DATETIME,
              null,
              array(
                  'nullable' => true,
                  'default' => null,
              ),
              'Timestamp'
          )
          ->addColumn(
              'decision',
              Varien_DB_Ddl_Table::TYPE_VARCHAR,
              null,
              array(
                  'nullable' => false,
                  'default' => '',
              ),
              'Decision'
          )
          ->addColumn(
              'custom',
              Varien_DB_Ddl_Table::TYPE_TINYINT,
              null,
              array(
                  'unsigned' => true,
                  'nullable' => false,
                  'default' => '0',
              ),
              'Temporary or ...shorted'
          )
          ->setComment('*removedname* table');

      $installer->getConnection()->createTable($table);

      $installer->endSetup();
    }
}
?>

The old (m1) DB creating file looked like:

<?php

$installer = $this;

$installer->startSetup();

$table = $installer->getConnection()
    ->newTable($installer->getTable('MyExtension/MyExtension')) // Varien_DB_DDl_table
    ->addColumn(
        'id',
        Varien_DB_Ddl_Table::TYPE_BIGINT,
        null,
        array(
            'unsigned' => true,
            'nullable' => false,
            'primary' => true,
        ),
        'Customer Address ID'
    )
    ->addColumn(
        'timestamp',
        Varien_DB_Ddl_Table::TYPE_DATETIME,
        null,
        array(
            'nullable' => true,
            'default' => null,
        ),
        'Timestamp'
    )
    ->addColumn(
        'decision',
        Varien_DB_Ddl_Table::TYPE_VARCHAR,
        null,
        array(
            'nullable' => false,
            'default' => '',
        ),
        'Decision'
    )
    ->addColumn(
        'custom',
        Varien_DB_Ddl_Table::TYPE_TINYINT,
        null,
        array(
            'unsigned' => true,
            'nullable' => false,
            'default' => '0',
        ),
        '......'
    )
    ->setComment('......');

$installer->getConnection()->createTable($table);

$installer->endSetup(); 
?>

So when I go in the CLI now, I have the following errors:

 

Command: 

  bin/magento module:enable --clear-static-content MyCompany_MyExtension

Result:

                                                            

  [InvalidArgumentException]                                

  There are no commands defined in the "module" namespace. 

                                                          

 

Command: 

  bin/magento setup:upgrade

Result:

 

                                                           

  [InvalidArgumentException]                               

  There are no commands defined in the "setup" namespace. 

    

 

 Also I've seen that in all how to's all extensions are written with namespaces and all our extensions are written without namespaces. So do I need to use namespaces in all extensions now since m2?

 

Does a list exist with all m2 namespaces and classes? Because as an example:

When I want to translate 

class NewClassExamp extends Mage_Core_Model_Abstract {

I don't think it should look like

class NewClassExamp extends Mage/Core/Model/Abstract

 

Sorry for the many questions, but I'm pretty new in this area.

 

Thanks a lot

 

FuFu

5 REPLIES 5

Re: Update Extension from m1 to m2

How to fix the «There are no commands defined» failure while executing a console command: https://mage2.pro/t/176

Re: Update Extension from m1 to m2

I was able to 'install' the module after I removed the composer.json file (>Details<).

So I can see the Extension now Stores>Advanced>Advanced as enabled.

 

But I can't find the configuration-area for the extension in the backend.

On m1 it was on System>Configuration>Sales>MyExtensionName.

 

I can't find it on m2 on the same place or somewhere else (May I'm to stupid, but may I have to change some configuration xml?).

 

Re: Update Extension from m1 to m2

Where are an extension's backend settings located? https://mage2.pro/t/556

Re: Update Extension from m1 to m2

Yes I checkd in Stores>Configuration>Sales, but it's not there.

I think I have to change something in one of the extension xml files.

 

Is there something changed id the admin-xml hierarchy?

Re: Update Extension from m1 to m2

I'm still on the same problem.

 

I have a file called adminhtml.xml and a file system.xml from the m1 extension.

I don't have any ideas what I have to do with them in m2, that the extension get displayed in the m2 backend.

 

It should be displayed in Stores>Configuration>Sales>ModulName.

 

I don't have any controller for the backend, it were be placed with the xml files in m1.

So I think I don't need an menu.xml and an routes.xml file, do I?

 

My adminhtml.xml looks like:

<?xml version="1.0"?>
<config>
	<menu>
		<customer>
	    <children>
				<myextension>
	            	<title>Extension Name</title>
	            	<sort_order>1273</sort_order>
	            	<action>adminhtml/customer_myextension/</action>
	        	</myextension>
			</children>
		</customer>
	</menu>
	<layout>
	    <updates>
	        <myextension>
	            <file>myextension.xml</file>
	        </myextension>
	    </updates>
	</layout>
		<resources>
            <admin>
                <children>
                    <system>
                        <children>
                            <config>
                                <children>
                                    <myextension_options>
                                        <title>Store myextension Module Section</title>
                                    </myextension_options>
                                </children>
                            </config>
                        </children>
                    </system>
                </children>
            </admin>
        </resources>
	<acl>
		<resources>
			<all>
				<title>Allow Everything</title>
			</all>
			<admin>
				<children>
					<customer>
		        		<children>
		        			<myextension >
		                		<title>My Extension Module</title>
		            		</myextension>
		        		</children>
		  			</customer>
	                <system>
	                    <children>
	                        <config>
	                            <children>
	                                <myextension>
	                                    <title>Vendor Extension Name</title>
	                                </myextension>
	                            </children>
	                        </config>
	                    </children>
	                </system>
	        	</children>
			</admin>
		</resources>
	</acl>
</config>

My system.xml looks like:

<?xml version="1.0"?>
<config>
   	<sections>
		<!-- payment tab -->
        <myextension translate="label" >
            <label>Vendor extension name</label>
            <class>myextension-section</class>
            <tab>sales</tab>
            <frontend_type>text</frontend_type>
            <sort_order>1273</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>
            <groups>

				<!-- myextension fieldset -->
                <config translate="label" >

					<!-- will have title Vendor extension name -->
                    <label>Vendor Extension name</label>

					<!-- position between other payment methods -->
                    <sort_order>677</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>

                        <!-- Status des Moduls -->
                        <active translate="label" >

                            <!-- Bezeichnung des Eingabefeldes -->
                            <label>Enabled</label>

                            <!-- Eingabetyp (text,select,mutliselect, text, texarea, etc...) -->
                            <frontend_type>select</frontend_type>

                            <!-- Model welches die Inhalte dere Auswahl liefert -->
                            <source_model>adminhtml/system_config_source_yesno</source_model>

                            <!-- Position im Backend -->
                            <sort_order>0</sort_order>

                            <!-- Kommentar -->
                            <comment><![CDATA[]]></comment>

                            <!-- Anzeige der jeweiligen Konfig.-Bereiches -->
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </active>

                        <!-- Auftragsstatus nach der Bestellung -->
                        <username translate="label" >
                            <label>Username</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>1</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </username>

                        <password translate="label" >
                            <label>Password</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>2</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </password>

                        <!-- Payment-Modulauswahl -->
                        <specific_payment_methods translate="label comment" >
                            <label>Vendor Extensionname enabled only for specific payment methods</label>
                            <frontend_type>multiselect</frontend_type>
                            <sort_order>4</sort_order>
                            <source_model>adminhtml/system_config_source_payment_allowedmethods</source_model>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <comment><![CDATA[Select payment methods for Vendor Extensionname]]></comment>
                        </specific_payment_methods>

                        <!-- Aktivierung fuer Laenderspezifizierung -->
                        <allowspecific translate="label comment" >
                            <label>Extensionname enabled only for specific countries</label>
                            <frontend_type>allowspecific</frontend_type>
                            <sort_order>5</sort_order>
                            <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </allowspecific>

                        <!-- Laenderauswahl -->
                        <specificcountry translate="label" >
                            <label>Specific countries for Extensionname</label>
                            <frontend_type>multiselect</frontend_type>
                            <sort_order>6</sort_order>
                            <source_model>adminhtml/system_config_source_country</source_model>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <comment><![CDATA[Select countries for Extensionname]]></comment>
                        </specificcountry>

                        <timestamp_exp translate="label">
                            <label>Check expiration (in days)</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>7</sort_order>
                            <validate>validate-digits</validate>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </timestamp_exp>

                        <private_company translate="label" >
                            <label>Use Extensionname on</label>
                            <frontend_type>select</frontend_type>
                            <source_model>myextension/source_privatecompany</source_model>
                            <sort_order>8</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
						</private_company>

                        <!-- Mindestbestellwert für Extensionname -->
                        <price_range_mode_min translate="label" >
                            <label>Min. order amount mode</label>
                            <frontend_type>select</frontend_type>
                            <source_model>myextension/source_pricerangemode</source_model>
                            <sort_order>12</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </price_range_mode_min>

						<order_min_value translate="label" >
	                        <label>Min. order amount (default currency)</label>
	                        <frontend_type>text</frontend_type>
	                        <sort_order>14</sort_order>
                            <validate>validate-digits</validate>
                            <show_in_default>1</show_in_default>
	                        <show_in_website>1</show_in_website>
	                        <show_in_store>1</show_in_store>
	                    </order_min_value>

						<price_range_mode_max translate="label" >
                            <label>Max. order amount mode</label>
                            <frontend_type>select</frontend_type>
                            <source_model>myextension/source_pricerangemode</source_model>
                            <sort_order>16</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </price_range_mode_max>

						<order_max_value translate="label" >
	                        <label>Max. order amount (default currency)</label>
	                        <frontend_type>text</frontend_type>
	                        <sort_order>18</sort_order>
                            <validate>validate-digits</validate>
                            <show_in_default>1</show_in_default>
	                        <show_in_website>1</show_in_website>
	                        <show_in_store>1</show_in_store>
	                    </order_max_value>

						<block_methods_on_differing_addresses translate="label" >
							<label>Lock payment methods when billing and shipping addresses differ</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>26</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </block_methods_on_differing_addresses>

                        <solvent_on_yellow translate="label" >
                            <label>Solvent on yellow</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>28</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </solvent_on_yellow>

                        <solvent_on_error translate="label" >
                            <label>Solvent on error</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>30</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </solvent_on_error>

                        <check_after_checkout translate="label" >
                            <label>*placeholder* only after clicking on place order</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>32</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
						</check_after_checkout>

                        <request_log translate="label" >
                            <label>Log ExtensionCustomer requests</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>36</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </request_log>
                    </fields>
                </config>
            </groups>
        </myextension>
    </sections>
</config>