Giter VIP home page Giter VIP logo

magento2-code-generator's Introduction

Magento 2 Code Generator Tool

Project Status: Abandoned – Initial development has started, but there has not yet been a stable, usable release; the project has been abandoned and the author(s) do not intend on continuing development. License Version Code Climate Total Downloads

Installation

Option1: Downloading .phar

wget https://github.com/staempfli/magento2-code-generator/releases/download/<version>/mg2-codegen.phar
chmod +x ./mg2-codegen.phar
# use the command globally on your system
sudo mv ./mg2-codegen.phar /usr/local/bin/mg2-codegen

Option2: Using Composer

Install globally on your system with the following command:

composer global require "staempfli/magento2-code-generator"

Just make sure you have the composer bin dir in your $PATH. The default value is ~/.composer/vendor/bin/

Note: if you have dependency problems with other projects installed globally, we recommend you to use consolidation/cgr

Usage

  1. List all templates: mg2-codegen template:list

  2. Generate template: mg2-codegen template:generate <template>

NOTE:

  • template:generate command must be executed on the module root folder where the registration.php file is. You can also use option --root-dir to specify this path, if you execute it from a different location.

  • When creating a new module, you must create first the module parent folder and execute the command from there.

Demo

Video Demo

You can also watch a more detailed video demos on Youtube:

Available Templates

Featured
  ajaxHtml
  consoleCommand
  crudEAV
  crudEAVWithFile
  frontController
  requireJs
  logger
  widget

More Templates
  ajaxJson
  ajaxRestApi
  blockHtml
  crud
  crudEAVWithMultipleFiles
  customConfigXml
  customDBConnection
  email
  emailFormRequest
  fileEAVAttribute
  fileEAVMultiple
  fileModel
  fileProcessor
  fotoramaSlider
  language
  model
  module

Create new Templates

Clone and Install Project

For that you cannot use the .phar binary, so you need to install the project:

Contribute with new Templates

Private Templates

If current templates do not fill your needs, you can easily create your own templates. Just follow the manual:

Prerequisites

  • PHP >= 5.6.*

Developers

Licence

Copyright

(c) 2016 Staempfli AG

magento2-code-generator's People

Contributors

audef1 avatar gfernandes410 avatar jalogut avatar julienanquetil avatar piotrkwiecinski avatar rev42 avatar telmiger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

magento2-code-generator's Issues

Phar file?

Can we download phar file directly from repo using link to master? (cant find the version)

Also is this compatible and according to M2.3.1.standards?

Thanks.

Unable to run without sudo when installed globally

mg2-codegen is part of a local development toolbox I maintain, but I'm not using it daily or familiar with it much, so please forgive my ignorance.

I noticed mg2-codegen won't run as a regular user when installed globally (/usr/local/bin). It invokes a self-update process, which attempts to write to /usr/local/bin/ and fails.

Installation

sudo curl -sSL https://github.com/staempfli/magento2-code-generator/releases/download/1.10.1/mg2-codegen.phar -o /usr/local/bin/mg2-codegen
sudo chmod +x /usr/local/bin/mg2-codegen

Running as a regular user

mg2-codegen --version

Fatal error: Uncaught Humbug\SelfUpdate\Exception\FilesystemException: The current phar file is not writeable and cannot be replaced: /usr/local/bin/mg2-codegen. in phar:///usr/local/bin/mg2-codegen/vendor/padraic/phar-updater/src/Updater.php:430
Stack trace:
#0 phar:///usr/local/bin/mg2-codegen/vendor/padraic/phar-updater/src/Updater.php(101): Humbug\SelfUpdate\Updater->setLocalPharFile('/usr/local/bin/...')
#1 phar:///usr/local/bin/mg2-codegen/src/Staempfli/Mg2CodeGenerator/Command/SelfUpdateCommand.php(35): Humbug\SelfUpdate\Updater->__construct(NULL, false, 'github')
#2 phar:///usr/local/bin/mg2-codegen/vendor/staempfli/universal-code-generator/src/Staempfli/UniversalGenerator/Application.php(57): Staempfli\Mg2CodeGenerator\Command\SelfUpdateCommand->__construct('self-update')
#3 phar:///usr/local/bin/mg2-codegen/vendor/staempfli/universal-code-generator/src/Staempfli/UniversalGenerator/Application.php(68): Staempfli\UniversalGenerator\Application->loadGeneratorCommands()
#4 phar:///usr/local/bin/mg2-codegen/bin/mg2-c in phar:///usr/local/bin/mg2-codegen/vendor/padraic/phar-updater/src/Updater.php on line 430

Running with sudo

sudo mg2-codegen --version
mg2-codegen 1.10.1

Expected results

Be able to run mg2-codegen (installed globally) as a regular users (without sudo).

Errors with generated files of "crudEAVWithMultipleFiles "

Magento 2.3.2
I tried the template crudEAVWithMultipleFiles

Listing is not working with error message :
Type Error occurred when creating object: Mycompany\Collec\Model\ResourceModel\Collec\Grid\Collection

And when i try to add a new object, the ImageCollection does not exists. And indeed, the file does not exists.

Any idea before i dig into it ?

Thx.

Undefined Index Notice While Generating Module

Why i'm getting this ???

mg2-codegen t:g module

PHP Notice: Undefined index: HOME in C:\Users\S.P Zakir\AppData\Roaming\Composer\vendor\staempfli\universal-code-generator\src\Staempfli\UniversalGenerator\Helper\Files\ApplicationFilesHelper.php on line 58

Notice: Undefined index: HOME in C:\Users\S.P Zakir\AppData\Roaming\Composer\vendor\staempfli\universal-code-generator\src\Staempfli\UniversalGenerator\Helper\Files\ApplicationFilesHelper.php on line 58
Template Generate: module
PHP Notice: Undefined index: HOME in C:\Users\S.P Zakir\AppData\Roaming\Composer\vendor\staempfli\universal-code-generator\src\Staempfli\UniversalGenerator\Helper\Files\ApplicationFilesHelper.php on line 58

Notice: Undefined index: HOME in C:\Users\S.P Zakir\AppData\Roaming\Composer\vendor\staempfli\universal-code-generator\src\Staempfli\UniversalGenerator\Helper\Files\ApplicationFilesHelper.php on line 58

crudEAV cannot handle "Use Default Value"

I've created an EAV entity with this template, and added a custom attribute with store view scope.

e.g.

        $attributes = [];
        $attributes['name'] = [
            'type' => 'varchar',
            'label' => 'Name',
            'input' => 'text',
            'required' => true, //true/false
            'sort_order' => 10,
            'global' => ScopedAttributeInterface::SCOPE_STORE,
            'group' => 'General',
        ];

        foreach($attributes as $attributeCode => $attributeData){
            $this->eavSetup->addAttribute(CookieSetup::ENTITY_TYPE_CODE, $attributeCode, $attributeData);
        }

My problem here is when trying to save the object in the backend for a different store view other than default, I'm unable to reset the value to use default.

image

I've tried modifying the ui form component to add the "Use Default Value" checkbox to test, but it's totally ignored

e.g.

        <field name="name" formElement="input" sortOrder="20" >
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="service" xsi:type="array">
                        <item name="template" xsi:type="string">ui/form/element/helper/service</item>
                    </item>
                </item>
            </argument>
            <settings>
                <visible>true</visible>
                <dataType>text</dataType>
                <label translate="true">Name</label>
                <validation>
                    <rule name="required-entry" xsi:type="boolean">true</rule>
                </validation>
            </settings>
        </field>

image

And after saving the value still remains. It's never deleted for the current store view.

I'm assuming something is missing from the resourceModel to handle the "Use Default Value"?

Error during installation via composer

Hey there, I got the error when I was trying install package by Option2: Using Composer.

dchizhov@macbook:~$ composer global require "staempfli/magento2-code-generator"
Changed current directory to /Users/dchizhov/.composer
Using version ^1.11 for staempfli/magento2-code-generator
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for staempfli/magento2-code-generator ^1.11 -> satisfiable by staempfli/magento2-code-generator[1.11.0].
    - Conclusion: remove symfony/console v4.2.3
    - Conclusion: don't install symfony/console v4.2.3
    - staempfli/magento2-code-generator 1.11.0 requires staempfli/universal-code-generator ^1.2 -> satisfiable by staempfli/universal-code-generator[1.2, 1.2.1].
    - staempfli/universal-code-generator 1.2 requires symfony/console ~3.0|~2.7 -> satisfiable by symfony/console[v2.7.0, v2.7.1, v2.7.10, v2.7.11, v2.7.12, v2.7.13, v2.7.14, v2.7.15, v2.7.16, v2.7.17, v2.7.18, v2.7.19, v2.7.2, v2.7.20, v2.7.21, v2.7.22, v2.7.23, v2.7.24, v2.7.25, v2.7.26, v2.7.27, v2.7.28, v2.7.29, v2.7.3, v2.7.30, v2.7.31, v2.7.32, v2.7.33, v2.7.34, v2.7.35, v2.7.36, v2.7.37, v2.7.38, v2.7.39, v2.7.4, v2.7.40, v2.7.41, v2.7.42, v2.7.43, v2.7.44, v2.7.45, v2.7.46, v2.7.47, v2.7.48, v2.7.49, v2.7.5, v2.7.50, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.10, v2.8.11, v2.8.12, v2.8.13, v2.8.14, v2.8.15, v2.8.16, v2.8.17, v2.8.18, v2.8.19, v2.8.2, v2.8.20, v2.8.21, v2.8.22, v2.8.23, v2.8.24, v2.8.25, v2.8.26, v2.8.27, v2.8.28, v2.8.29, v2.8.3, v2.8.30, v2.8.31, v2.8.32, v2.8.33, v2.8.34, v2.8.35, v2.8.36, v2.8.37, v2.8.38, v2.8.39, v2.8.4, v2.8.40, v2.8.41, v2.8.42, v2.8.43, v2.8.44, v2.8.45, v2.8.46, v2.8.47, v2.8.48, v2.8.49, v2.8.5, v2.8.6, v2.8.7, v2.8.8, v2.8.9, v3.0.0, v3.0.1, v3.0.2, v3.0.3, v3.0.4, v3.0.5, v3.0.6, v3.0.7, v3.0.8, v3.0.9, v3.1.0, v3.1.1, v3.1.10, v3.1.2, v3.1.3, v3.1.4, v3.1.5, v3.1.6, v3.1.7, v3.1.8, v3.1.9, v3.2.0, v3.2.1, v3.2.10, v3.2.11, v3.2.12, v3.2.13, v3.2.14, v3.2.2, v3.2.3, v3.2.4, v3.2.5, v3.2.6, v3.2.7, v3.2.8, v3.2.9, v3.3.0, v3.3.1, v3.3.10, v3.3.11, v3.3.12, v3.3.13, v3.3.14, v3.3.15, v3.3.16, v3.3.17, v3.3.18, v3.3.2, v3.3.3, v3.3.4, v3.3.5, v3.3.6, v3.3.7, v3.3.8, v3.3.9, v3.4.0, v3.4.1, v3.4.10, v3.4.11, v3.4.12, v3.4.13, v3.4.14, v3.4.15, v3.4.16, v3.4.17, v3.4.18, v3.4.19, v3.4.2, v3.4.20, v3.4.21, v3.4.22, v3.4.3, v3.4.4, v3.4.5, v3.4.6, v3.4.7, v3.4.8, v3.4.9].
    - staempfli/universal-code-generator 1.2.1 requires symfony/console ~3.0|~2.7 -> satisfiable by symfony/console[v2.7.0, v2.7.1, v2.7.10, v2.7.11, v2.7.12, v2.7.13, v2.7.14, v2.7.15, v2.7.16, v2.7.17, v2.7.18, v2.7.19, v2.7.2, v2.7.20, v2.7.21, v2.7.22, v2.7.23, v2.7.24, v2.7.25, v2.7.26, v2.7.27, v2.7.28, v2.7.29, v2.7.3, v2.7.30, v2.7.31, v2.7.32, v2.7.33, v2.7.34, v2.7.35, v2.7.36, v2.7.37, v2.7.38, v2.7.39, v2.7.4, v2.7.40, v2.7.41, v2.7.42, v2.7.43, v2.7.44, v2.7.45, v2.7.46, v2.7.47, v2.7.48, v2.7.49, v2.7.5, v2.7.50, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.10, v2.8.11, v2.8.12, v2.8.13, v2.8.14, v2.8.15, v2.8.16, v2.8.17, v2.8.18, v2.8.19, v2.8.2, v2.8.20, v2.8.21, v2.8.22, v2.8.23, v2.8.24, v2.8.25, v2.8.26, v2.8.27, v2.8.28, v2.8.29, v2.8.3, v2.8.30, v2.8.31, v2.8.32, v2.8.33, v2.8.34, v2.8.35, v2.8.36, v2.8.37, v2.8.38, v2.8.39, v2.8.4, v2.8.40, v2.8.41, v2.8.42, v2.8.43, v2.8.44, v2.8.45, v2.8.46, v2.8.47, v2.8.48, v2.8.49, v2.8.5, v2.8.6, v2.8.7, v2.8.8, v2.8.9, v3.0.0, v3.0.1, v3.0.2, v3.0.3, v3.0.4, v3.0.5, v3.0.6, v3.0.7, v3.0.8, v3.0.9, v3.1.0, v3.1.1, v3.1.10, v3.1.2, v3.1.3, v3.1.4, v3.1.5, v3.1.6, v3.1.7, v3.1.8, v3.1.9, v3.2.0, v3.2.1, v3.2.10, v3.2.11, v3.2.12, v3.2.13, v3.2.14, v3.2.2, v3.2.3, v3.2.4, v3.2.5, v3.2.6, v3.2.7, v3.2.8, v3.2.9, v3.3.0, v3.3.1, v3.3.10, v3.3.11, v3.3.12, v3.3.13, v3.3.14, v3.3.15, v3.3.16, v3.3.17, v3.3.18, v3.3.2, v3.3.3, v3.3.4, v3.3.5, v3.3.6, v3.3.7, v3.3.8, v3.3.9, v3.4.0, v3.4.1, v3.4.10, v3.4.11, v3.4.12, v3.4.13, v3.4.14, v3.4.15, v3.4.16, v3.4.17, v3.4.18, v3.4.19, v3.4.2, v3.4.20, v3.4.21, v3.4.22, v3.4.3, v3.4.4, v3.4.5, v3.4.6, v3.4.7, v3.4.8, v3.4.9].
    - Can only install one of: symfony/console[v2.7.0, v4.2.3].
    - Can only install one of: symfony/console[v2.7.1, v4.2.3].
    - Can only install one of: symfony/console[v2.7.10, v4.2.3].
    - Can only install one of: symfony/console[v2.7.11, v4.2.3].
    - Can only install one of: symfony/console[v2.7.12, v4.2.3].
    - Can only install one of: symfony/console[v2.7.13, v4.2.3].
    - Can only install one of: symfony/console[v2.7.14, v4.2.3].
    - Can only install one of: symfony/console[v2.7.15, v4.2.3].
    - Can only install one of: symfony/console[v2.7.16, v4.2.3].
    - Can only install one of: symfony/console[v2.7.17, v4.2.3].
    - Can only install one of: symfony/console[v2.7.18, v4.2.3].
    - Can only install one of: symfony/console[v2.7.19, v4.2.3].
    - Can only install one of: symfony/console[v2.7.2, v4.2.3].
    - Can only install one of: symfony/console[v2.7.20, v4.2.3].
    - Can only install one of: symfony/console[v2.7.21, v4.2.3].
    - Can only install one of: symfony/console[v2.7.22, v4.2.3].
    - Can only install one of: symfony/console[v2.7.23, v4.2.3].
    - Can only install one of: symfony/console[v2.7.24, v4.2.3].
    - Can only install one of: symfony/console[v2.7.25, v4.2.3].
    - Can only install one of: symfony/console[v2.7.26, v4.2.3].
    - Can only install one of: symfony/console[v2.7.27, v4.2.3].
    - Can only install one of: symfony/console[v2.7.28, v4.2.3].
    - Can only install one of: symfony/console[v2.7.29, v4.2.3].
    - Can only install one of: symfony/console[v2.7.3, v4.2.3].
    - Can only install one of: symfony/console[v2.7.30, v4.2.3].
    - Can only install one of: symfony/console[v2.7.31, v4.2.3].
    - Can only install one of: symfony/console[v2.7.32, v4.2.3].
    - Can only install one of: symfony/console[v2.7.33, v4.2.3].
    - Can only install one of: symfony/console[v2.7.34, v4.2.3].
    - Can only install one of: symfony/console[v2.7.35, v4.2.3].
    - Can only install one of: symfony/console[v2.7.36, v4.2.3].
    - Can only install one of: symfony/console[v2.7.37, v4.2.3].
    - Can only install one of: symfony/console[v2.7.38, v4.2.3].
    - Can only install one of: symfony/console[v2.7.39, v4.2.3].
    - Can only install one of: symfony/console[v2.7.4, v4.2.3].
    - Can only install one of: symfony/console[v2.7.40, v4.2.3].
    - Can only install one of: symfony/console[v2.7.41, v4.2.3].
    - Can only install one of: symfony/console[v2.7.42, v4.2.3].
    - Can only install one of: symfony/console[v2.7.43, v4.2.3].
    - Can only install one of: symfony/console[v2.7.44, v4.2.3].
    - Can only install one of: symfony/console[v2.7.45, v4.2.3].
    - Can only install one of: symfony/console[v2.7.46, v4.2.3].
    - Can only install one of: symfony/console[v2.7.47, v4.2.3].
    - Can only install one of: symfony/console[v2.7.48, v4.2.3].
    - Can only install one of: symfony/console[v2.7.49, v4.2.3].
    - Can only install one of: symfony/console[v2.7.5, v4.2.3].
    - Can only install one of: symfony/console[v2.7.50, v4.2.3].
    - Can only install one of: symfony/console[v2.7.6, v4.2.3].
    - Can only install one of: symfony/console[v2.7.7, v4.2.3].
    - Can only install one of: symfony/console[v2.7.8, v4.2.3].
    - Can only install one of: symfony/console[v2.7.9, v4.2.3].
    - Can only install one of: symfony/console[v2.8.0, v4.2.3].
    - Can only install one of: symfony/console[v2.8.1, v4.2.3].
    - Can only install one of: symfony/console[v2.8.10, v4.2.3].
    - Can only install one of: symfony/console[v2.8.11, v4.2.3].
    - Can only install one of: symfony/console[v2.8.12, v4.2.3].
    - Can only install one of: symfony/console[v2.8.13, v4.2.3].
    - Can only install one of: symfony/console[v2.8.14, v4.2.3].
    - Can only install one of: symfony/console[v2.8.15, v4.2.3].
    - Can only install one of: symfony/console[v2.8.16, v4.2.3].
    - Can only install one of: symfony/console[v2.8.17, v4.2.3].
    - Can only install one of: symfony/console[v2.8.18, v4.2.3].
    - Can only install one of: symfony/console[v2.8.19, v4.2.3].
    - Can only install one of: symfony/console[v2.8.2, v4.2.3].
    - Can only install one of: symfony/console[v2.8.20, v4.2.3].
    - Can only install one of: symfony/console[v2.8.21, v4.2.3].
    - Can only install one of: symfony/console[v2.8.22, v4.2.3].
    - Can only install one of: symfony/console[v2.8.23, v4.2.3].
    - Can only install one of: symfony/console[v2.8.24, v4.2.3].
    - Can only install one of: symfony/console[v2.8.25, v4.2.3].
    - Can only install one of: symfony/console[v2.8.26, v4.2.3].
    - Can only install one of: symfony/console[v2.8.27, v4.2.3].
    - Can only install one of: symfony/console[v2.8.28, v4.2.3].
    - Can only install one of: symfony/console[v2.8.29, v4.2.3].
    - Can only install one of: symfony/console[v2.8.3, v4.2.3].
    - Can only install one of: symfony/console[v2.8.30, v4.2.3].
    - Can only install one of: symfony/console[v2.8.31, v4.2.3].
    - Can only install one of: symfony/console[v2.8.32, v4.2.3].
    - Can only install one of: symfony/console[v2.8.33, v4.2.3].
    - Can only install one of: symfony/console[v2.8.34, v4.2.3].
    - Can only install one of: symfony/console[v2.8.35, v4.2.3].
    - Can only install one of: symfony/console[v2.8.36, v4.2.3].
    - Can only install one of: symfony/console[v2.8.37, v4.2.3].
    - Can only install one of: symfony/console[v2.8.38, v4.2.3].
    - Can only install one of: symfony/console[v2.8.39, v4.2.3].
    - Can only install one of: symfony/console[v2.8.4, v4.2.3].
    - Can only install one of: symfony/console[v2.8.40, v4.2.3].
    - Can only install one of: symfony/console[v2.8.41, v4.2.3].
    - Can only install one of: symfony/console[v2.8.42, v4.2.3].
    - Can only install one of: symfony/console[v2.8.43, v4.2.3].
    - Can only install one of: symfony/console[v2.8.44, v4.2.3].
    - Can only install one of: symfony/console[v2.8.45, v4.2.3].
    - Can only install one of: symfony/console[v2.8.46, v4.2.3].
    - Can only install one of: symfony/console[v2.8.47, v4.2.3].
    - Can only install one of: symfony/console[v2.8.48, v4.2.3].
    - Can only install one of: symfony/console[v2.8.49, v4.2.3].
    - Can only install one of: symfony/console[v2.8.5, v4.2.3].
    - Can only install one of: symfony/console[v2.8.6, v4.2.3].
    - Can only install one of: symfony/console[v2.8.7, v4.2.3].
    - Can only install one of: symfony/console[v2.8.8, v4.2.3].
    - Can only install one of: symfony/console[v2.8.9, v4.2.3].
    - Can only install one of: symfony/console[v3.0.0, v4.2.3].
    - Can only install one of: symfony/console[v3.0.1, v4.2.3].
    - Can only install one of: symfony/console[v3.0.2, v4.2.3].
    - Can only install one of: symfony/console[v3.0.3, v4.2.3].
    - Can only install one of: symfony/console[v3.0.4, v4.2.3].
    - Can only install one of: symfony/console[v3.0.5, v4.2.3].
    - Can only install one of: symfony/console[v3.0.6, v4.2.3].
    - Can only install one of: symfony/console[v3.0.7, v4.2.3].
    - Can only install one of: symfony/console[v3.0.8, v4.2.3].
    - Can only install one of: symfony/console[v3.0.9, v4.2.3].
    - Can only install one of: symfony/console[v3.1.0, v4.2.3].
    - Can only install one of: symfony/console[v3.1.1, v4.2.3].
    - Can only install one of: symfony/console[v3.1.10, v4.2.3].
    - Can only install one of: symfony/console[v3.1.2, v4.2.3].
    - Can only install one of: symfony/console[v3.1.3, v4.2.3].
    - Can only install one of: symfony/console[v3.1.4, v4.2.3].
    - Can only install one of: symfony/console[v3.1.5, v4.2.3].
    - Can only install one of: symfony/console[v3.1.6, v4.2.3].
    - Can only install one of: symfony/console[v3.1.7, v4.2.3].
    - Can only install one of: symfony/console[v3.1.8, v4.2.3].
    - Can only install one of: symfony/console[v3.1.9, v4.2.3].
    - Can only install one of: symfony/console[v3.2.0, v4.2.3].
    - Can only install one of: symfony/console[v3.2.1, v4.2.3].
    - Can only install one of: symfony/console[v3.2.10, v4.2.3].
    - Can only install one of: symfony/console[v3.2.11, v4.2.3].
    - Can only install one of: symfony/console[v3.2.12, v4.2.3].
    - Can only install one of: symfony/console[v3.2.13, v4.2.3].
    - Can only install one of: symfony/console[v3.2.14, v4.2.3].
    - Can only install one of: symfony/console[v3.2.2, v4.2.3].
    - Can only install one of: symfony/console[v3.2.3, v4.2.3].
    - Can only install one of: symfony/console[v3.2.4, v4.2.3].
    - Can only install one of: symfony/console[v3.2.5, v4.2.3].
    - Can only install one of: symfony/console[v3.2.6, v4.2.3].
    - Can only install one of: symfony/console[v3.2.7, v4.2.3].
    - Can only install one of: symfony/console[v3.2.8, v4.2.3].
    - Can only install one of: symfony/console[v3.2.9, v4.2.3].
    - Can only install one of: symfony/console[v3.3.0, v4.2.3].
    - Can only install one of: symfony/console[v3.3.1, v4.2.3].
    - Can only install one of: symfony/console[v3.3.10, v4.2.3].
    - Can only install one of: symfony/console[v3.3.11, v4.2.3].
    - Can only install one of: symfony/console[v3.3.12, v4.2.3].
    - Can only install one of: symfony/console[v3.3.13, v4.2.3].
    - Can only install one of: symfony/console[v3.3.14, v4.2.3].
    - Can only install one of: symfony/console[v3.3.15, v4.2.3].
    - Can only install one of: symfony/console[v3.3.16, v4.2.3].
    - Can only install one of: symfony/console[v3.3.17, v4.2.3].
    - Can only install one of: symfony/console[v3.3.18, v4.2.3].
    - Can only install one of: symfony/console[v3.3.2, v4.2.3].
    - Can only install one of: symfony/console[v3.3.3, v4.2.3].
    - Can only install one of: symfony/console[v3.3.4, v4.2.3].
    - Can only install one of: symfony/console[v3.3.5, v4.2.3].
    - Can only install one of: symfony/console[v3.3.6, v4.2.3].
    - Can only install one of: symfony/console[v3.3.7, v4.2.3].
    - Can only install one of: symfony/console[v3.3.8, v4.2.3].
    - Can only install one of: symfony/console[v3.3.9, v4.2.3].
    - Can only install one of: symfony/console[v3.4.0, v4.2.3].
    - Can only install one of: symfony/console[v3.4.1, v4.2.3].
    - Can only install one of: symfony/console[v3.4.10, v4.2.3].
    - Can only install one of: symfony/console[v3.4.11, v4.2.3].
    - Can only install one of: symfony/console[v3.4.12, v4.2.3].
    - Can only install one of: symfony/console[v3.4.13, v4.2.3].
    - Can only install one of: symfony/console[v3.4.14, v4.2.3].
    - Can only install one of: symfony/console[v3.4.15, v4.2.3].
    - Can only install one of: symfony/console[v3.4.16, v4.2.3].
    - Can only install one of: symfony/console[v3.4.17, v4.2.3].
    - Can only install one of: symfony/console[v3.4.18, v4.2.3].
    - Can only install one of: symfony/console[v3.4.19, v4.2.3].
    - Can only install one of: symfony/console[v3.4.2, v4.2.3].
    - Can only install one of: symfony/console[v3.4.20, v4.2.3].
    - Can only install one of: symfony/console[v3.4.21, v4.2.3].
    - Can only install one of: symfony/console[v3.4.22, v4.2.3].
    - Can only install one of: symfony/console[v3.4.3, v4.2.3].
    - Can only install one of: symfony/console[v3.4.4, v4.2.3].
    - Can only install one of: symfony/console[v3.4.5, v4.2.3].
    - Can only install one of: symfony/console[v3.4.6, v4.2.3].
    - Can only install one of: symfony/console[v3.4.7, v4.2.3].
    - Can only install one of: symfony/console[v3.4.8, v4.2.3].
    - Can only install one of: symfony/console[v3.4.9, v4.2.3].
    - Installation request for symfony/console (locked at v4.2.3) -> satisfiable by symfony/console[v4.2.3].


Installation failed, reverting ./composer.json to its original content.

Please clarify the license of the generated code

Thanks for providing this code generator - after reading this and seeing that it might be arguable how much of the code (ie the templates) end up in the final generated output can you please clarify what the output is licensed under?

Error on edit if identifier not set

Hi Guys,

First of all, nice project and thank you for all suport!

If you not set identifier on create a register, you will get an error on edit this register.
My suggestion is on VENDOR\MODULE\Controller\Adminhtml\ENTITY*Save.php* before you save, make an validation and if the identifier is null make same random.

Some thing like that:

            if($objectInstance->getData('identifier') == null) {
                $objectInstance->setIdentifier($this->generateRandomString());
            }

Not load attribute from current store

Preconditions

  1. PHP 7.0
  2. Magento 2.2.4

Steps to reproduce
mg2-codegen template:generate crudEAV
magento/admin->content->gridItem->item->edit
If have more than one store and form item have input select.
There is a problem: I select any value from any input select field for the US store view and save it. Then I switch to other store view (for example UK store) and select the same value for the same input select field and save it, this value is not saved. The problem lies in $objectInstance->load($data['entity_id']); method, that loads object with attributes which belong to one store view, regardless the store view this object is saved form.

In order to fix this issue the following should be done: in resource model change method protected function _getLoadAttributesSelect($object, $table)

from that

protected function _getLoadAttributesSelect($object, $table)
    {
        if ($this->_storeManager->hasSingleStore()) {
            $storeId = (int) $this->_storeManager->getStore(true)->getId();
        } else {
            $storeId = (int) $object->getStoreId();
        }

        $storeIds = [$this->getDefaultStoreId()];
        if ($storeId != $this->getDefaultStoreId()) {
            $storeIds[] = $storeId;
        }
        $select = $this->getConnection()->select()->from(
            $table,
            []
        )->where(
            $this->getEntityIdField() . ' =?',
            $object->getId()
        )->where('store_id IN (?)', $storeIds);
        return $select;
    }

Irrelevant datasource name in some templates?

I found some irrelevant datasource names.

Is it intended to prepend them with "computer_games"?

<dataSource name="computer_games_form_data_source">

Found in:

  • templates/crud/view/adminhtml/ui_component/${vendorname}${modulename}${entityname}_form.xml
  • templates/crudEAV/view/adminhtml/ui_component/${vendorname}${modulename}${entityname}_form.xml

question: how to generate multiple entities with crudEAV in the same module

While trying to execute

  • t:g generate with EntityName1
  • t:g generate with EntityName2

Multiple files are going to the same paths, thus causing to overwrite the previously created data and breaking the previous entity.

For example

1. the collection and eav attribute

  • app/code/Vendor/Module/Model/ResourceModel/Attribute/Collection.php (this relies on the entity name)
  • app/code/Vendor/Module/Model/ResourceModel/Eav/Attribute.php (this relies on the entity name)

Could these two be named based on the EntityName like EntityNameCollection and EntityNameAttribute ? They only seem to be used in the EntityNameSetup file.

2. the resource model attribute

  • app/code/Vendor/Module/Model/ResourceModel/Attribute.php (this also uses internally the entity name )

3. the configuration files which create a lot of data

├── etc
│   ├── acl.xml
│   ├── adminhtml
│   │   ├── menu.xml
│   │   └── routes.xml
│   ├── di.xml

4. the setup code.

Setup/
├── EavTablesSetup.php
├── EntityName1Setup.php
├── InstallData.php
├── InstallSchema.php
├── EntityName2Setup.php
└── Uninstall.php

I'm wondering if there's a way to make it merge the files or if not would it be possible to get a second option to append (maybe commented out) the code to the existing files instead of overwriting?

That way it is going to be easier to repair the files that need to be adjusted. Pretty much copy paste the code in the relevant parts from the commented out areas

[Perhaps not an issue] can't display info in DB

Hi,
I use your magic module to make and EAV crud.
Everything is working well.
but I expererience something strange.
I create an item

In the grid my field "title" is empty
capture d ecran 2018-07-04 a 13 27 04

If i search for the title, it's displayed on the grid

capture d ecran 2018-07-04 a 15 31 10

But on my edit page, I got all my data (and it's fine in DB).

capture d ecran 2018-07-04 a 13 27 29

Do you know or have a hint on what I may doing wrong ?

Thanks

Magento 2.2.1+: DataProvider constructor PHPDoc is missing string type

Hello,
When creating a crud template, the PHPDoc of the DataProvider __construct does not specify the string type.

Actual constructor:

/**
     * DataProvider constructor.
     * @param $name
     * @param $primaryFieldName
     * @param $requestFieldName
     * @param Collection $collection
     * @param FilterPool $filterPool
     * @param array $meta
     * @param array $data
     */
    public function __construct(
        $name,
        $primaryFieldName,
        $requestFieldName,
        Collection $collection,
        FilterPool $filterPool,
        array $meta = [],
        array $data = []
    ) {
        parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
        $this->collection = $collection;
        $this->filterPool = $filterPool;
    }

Expected:

/**
     * DataProvider constructor.
     * @param string $name
     * @param string $primaryFieldName
     * @param string $requestFieldName
     * @param Collection $collection
     * @param FilterPool $filterPool
     * @param array $meta
     * @param array $data
     */
    public function __construct(
        $name,
        $primaryFieldName,
        $requestFieldName,
        Collection $collection,
        FilterPool $filterPool,
        array $meta = [],
        array $data = []
    ) {
        parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
        $this->collection = $collection;
        $this->filterPool = $filterPool;
    }

From Magento 2.2.1, the DI is looking at the constructor comments and compilation fails if it does'nt have the types with the error Incompatible argument type: Required type: string. Actual type: \Vendor\Module\Ui\Component\Form\Entity\name;

mg2-codegen.phar attached to the 1.11.2 release tag is wrong version

The binary attached to the 1.11.2 release reports version 1.11.1

docker@a265668cc290:/var/www$ curl -LO https://github.com/staempfli/magento2-code-generator/releases/download/1.11.2/mg2-codegen.phar
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   622  100   622    0     0   1429      0 --:--:-- --:--:-- --:--:--  1429
100 2857k  100 2857k    0     0  1674k      0  0:00:01  0:00:01 --:--:-- 2840k
docker@a265668cc290:/var/www$ chmod +x ./mg2-codegen.phar 
docker@a265668cc290:/var/www$ ./mg2-codegen.phar --version
mg2-codegen.phar 1.11.1

Crud - Not registered handle Error

Just installed your generator and created a new crud.

When I go to index page I get the error message

Not registered handle neei_module_type_listing_data_source

I've tried twice just in case I've missed something. Any idea?

Need to correct typo mistake in 2magento add column

Can you please fix the type of length when we use 2magento add column ? This is what I am getting:

$setup->getConnection()->addColumn(
            $setup->getTable(''),
            '',
            [
                'type' => Table::TYPE_,
                'lenght' => null,
                'nullable' => true,
                'default' => '',
                'comment' => '',
            ]
        );

mg2-codepen command not found

I have installed codepen via composer made sure my path was correct. Now no matter what folder I run this any mg2 commands from i get the mg2-codepen command not found.

Kinda unsure what to do! Any help would be greatly appreciated

[CrudEAV] "Fatal Error: Class not found" after generation, but class exists and namespace correct

I got this fatal error after generating a custom EAV Model :

Fatal error: Method Magento\Ui\TemplateEngine\Xhtml\Result::__toString() must not throw an exception, caught Error: Class 'VehicleCompany\Cars\Model\ResourceModel\Car\Grid\Collection' not found in /<magento_root_dir>/vendor/magento/module-ui/Component/Wrapper/UiComponent.php on line 0

But this class exists, and its namespace is correct (no typos).

Please, how to fix this issue ? I've been searching for several hours, but i didn't manage to find a solution.

Files :

  • <magento_root_dir>/app/code/VehicleCompany/Cars/Model/ResourceModel/Car/Grid/Collection.php :
<?php
/**
 * Collection.php
 *
 * @copyright Copyright © 2017 Vehicle Company. All rights reserved.
 * @author    [email protected]
 */

namespace VehicleCompany\Cars\Model\ResourceModel\Car\Grid;

use Magento\Framework\Api\Search\AggregationInterface;
use Magento\Framework\Api\Search\SearchResultInterface;
use Magento\Framework\Api\SearchCriteriaInterface;
use Magento\Eav\Model\Config;
use Magento\Eav\Model\EntityFactory as EavEntityFactory;
use Magento\Eav\Model\ResourceModel\Helper;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
use Magento\Framework\Data\Collection\EntityFactory;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\Event\ManagerInterface;
use Magento\Framework\Validator\UniversalFactory;
use Magento\Store\Model\StoreManagerInterface;
use Psr\Log\LoggerInterface;

/**
 * Class Collection
 * Collection for displaying grid
 */
class Collection extends \VehicleCompany\Cars\Model\ResourceModel\Car\Collection implements SearchResultInterface
{
    /**
     * @var AggregationInterface
     */
    protected $aggregations;

    /**
     * Collection constructor.
     * @param EntityFactory $entityFactory
     * @param LoggerInterface $logger
     * @param FetchStrategyInterface $fetchStrategy
     * @param ManagerInterface $eventManager
     * @param Config $eavConfig
     * @param ResourceConnection $resource
     * @param EavEntityFactory $eavEntityFactory
     * @param Helper $resourceHelper
     * @param UniversalFactory $universalFactory
     * @param StoreManagerInterface $eventPrefix
     * @param $eventObject
     * @param $resourceModel
     * @param string $model
     * @param StoreManagerInterface $storeManager
     * @param AdapterInterface|null $connection
     *
     * @SuppressWarnings(PHPMD.ExcessiveParameterList)
     */
    public function __construct(
        EntityFactory $entityFactory,
        LoggerInterface $logger,
        FetchStrategyInterface $fetchStrategy,
        ManagerInterface $eventManager,
        Config $eavConfig,
        ResourceConnection $resource,
        EavEntityFactory $eavEntityFactory,
        Helper $resourceHelper,
        UniversalFactory $universalFactory,
        StoreManagerInterface $storeManager,
        $eventPrefix,
        $eventObject,
        $resourceModel,
        $model = 'VehicleCompany\Cars\Ui\Component\Listing\DataProvider\Document',
        AdapterInterface $connection = null
    )
    {
        parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $eavConfig, $resource, $eavEntityFactory, $resourceHelper, $universalFactory, $storeManager, $connection);
        $this->_eventPrefix = $eventPrefix;
        $this->_eventObject = $eventObject;
        $this->_init($model, $resourceModel);
    }

    /**
     * @return AggregationInterface
     */
    public function getAggregations()
    {
        return $this->aggregations;
    }

    /**
     * @param AggregationInterface $aggregations
     * @return $this
     */
    public function setAggregations($aggregations)
    {
        $this->aggregations = $aggregations;
    }

    /**
     * Retrieve all ids for collection
     * Backward compatibility with EAV collection
     *
     * @param int $limit
     * @param int $offset
     * @return array
     */
    public function getAllIds($limit = null, $offset = null)
    {
        return $this->getConnection()->fetchCol($this->_getAllIdsSelect($limit, $offset), $this->_bindParams);
    }

    /**
     * Get search criteria.
     *
     * @return SearchCriteriaInterface|null
     */
    public function getSearchCriteria()
    {
        return null;
    }

    /**
     * Set search criteria.
     *
     * @param SearchCriteriaInterface $searchCriteria
     * @return $this
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     */
    public function setSearchCriteria(SearchCriteriaInterface $searchCriteria = null)
    {
        return $this;
    }

    /**
     * Get total count.
     *
     * @return int
     */
    public function getTotalCount()
    {
        return $this->getSize();
    }

    /**
     * Set total count.
     *
     * @param int $totalCount
     * @return $this
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     */
    public function setTotalCount($totalCount)
    {
        return $this;
    }

    /**
     * Set items list.
     *
     * @param \Magento\Framework\Api\ExtensibleDataInterface[] $items
     * @return $this
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     */
    public function setItems(array $items = null)
    {
        return $this;
    }
}

Configuration :

  • Magento 2.1.5
  • PHP 7.0.17 (installed via Homebrew)
  • Apache 2.4.18
  • OSX Sierra

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.