mage2gen / mage2gen Goto Github PK
View Code? Open in Web Editor NEWPython library for generating Magento 2 module
License: GNU General Public License v3.0
Python library for generating Magento 2 module
License: GNU General Public License v3.0
When i use a underscored model name "product_alert_stock" it implements a non excisting class.
class ProductAlertStockRepository implements product\alert\stockRepositoryInterface
should be
class ProductAlertStockRepository implements ProductAlertStockSearchResultsInterfaceFactory
When I click on the module custom link, Magento open the model page where the datagrid shown all the records. Into this page, the title has been not set correctly.
here the code
/**
* Index action
*
* @return \Magento\Framework\Controller\ResultInterface
*/
public function execute()
{
$resultPage = $this->resultPageFactory->create();
$resultPage->getConfig()->getTitle()->prepend(__("'+model_name+'"));
return $resultPage;
}
thanks
When I try to create a module sometimes I am focusing on the structure of the model (database) and I forget about the sorting of the fields. One of the best feature is the sorting of the fields in the model section in order to create a perfect form in Magento administration panel.
thanks
# Group Label
It isn't possible to add a System Group Label
# Sort Order
No default is set for the Sort Order of Tabs, Sections, Groups and fields
Travis always failing, think this happens because of the PHP version in Travis test environment.
Hi guys,
when I try to compile the code
./n98-magerun2.phar setup:di:compile
I get this error:
Extra parameters passed to parent construct: $coreRegistry.
The problem is this file:
/Controller/Adminhtml/Wiki/Save.php
Best Regards
Hello,
When creating a model, we can choose if we want the fields to be displayed on admin grid or not.
All columns with the selected option are added to the file view/adminhtml/ui_component/module_model_index.xml
, which is ok.
Then, the actionsColumn
is added, which is also ok.
But after this actionsColumn
, the columns which were not selected to be displayed on the admin grid are added. This is causing an error and blocks the admin grid render. The fix is to remove all columns after the actionsColumn
.
I would like to make a PR but in the model.py
file, I see the actionsColumn
part but I don't see how you handle the Adminhtml grid checkbox.
Thanks!
I am just wondering, when adding a new customer attribute, don't we need to implement plugins for loading and saving the extension attribute? It seems that is missing in the generator.
Hello,
I have discovered in my downloaded sample module that there is not any:
Mycompany\Mymodule\Model\ResourceModel\Domain\Grid\Collection
in the di.xml is declared but there is not any file in that directory.
thanks
Hello Guys,
I am using your fantastic software as a scaffolder of my modules and it saves me a lot of time! So, thanks! I would like to suggest you to improve the generation of the grids/listings and tab inside the adminhtml form.
the grid/listing needs to be improved using as possibile the Magento features like these:
The filters are raw and the user data are ignored.
For instance, If I need to create an adminhtml module with two tabs I need to rewrite your module adding the block classes and layout files.
I have to create the Block classes like these one because the UIComponent is too young to support the tab system. I have not found any documentation about the tab and form nesting by the UIComponent.
Ok! I have created the module and now I have downloaded it from your site to my store but... I forgot to add a db field in my model... and now?
I have to go to your website to add my new db field. I have to download again the module and I have to install it in my store but... the new field has been not created in the database ... why?
Because the setup_version remains "1.0.0" and Magento doesn't upgrade the databse when I execute the command by the bash:
php -f bin/magento setup:upgrade
So I suggest you to save the version of the module when the user download the module and offer a way to maintain the module releases.
Regards
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?
After clicking save and download you get a curl example like:
curl http://mage2gen.com/download/random-module-url.tar | tar xzC app/code
This should be
curl -L http://mage2gen.com/download/random-module-url.tar | tar xzC app/code
Because the url gets redirected.
While I was writing this I took a look at the Location
header. The reason it redirects is because of https. The provided url redirects to a https version. It will be better to just change that ๐
Mage2gen uses the whole namespace as path too the plugin class, but Magento has a convention to use the following path Vendor\Module\Plugin\{PluginClass}Plugin
For example if you write a plugin for the following class:
Aheadworks\Blog\Model\ResourceModel\PostRepository
Mage2Gen will generate the class on the following path Vendor\Module\Plugin\Aheadworks\Blog\Model\ResourceModel\PostRepository
But the Magento convention is Vendor\Module\Plugin\PostRepositoryPlugin
At a model, it would be nice to default to 12,4 precision.
Hello,
as described in the subject: How have I to create a textarea in the form?
Is there a way to create a file attachment object?
thanks
There seems to be an error with the Model generation.
While trying to get a list by using the Repository class:
Fatal error: Uncaught Error: Cannot instantiate interface Vendor\Module\Api\Data\ModelnameSearchResultsInterface in public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php on line 73
Short Trace:
Vendor\Modulename\Model\ModelnameRepository->getList( )
Vendor\Modulename\Api\Data\ModelnameSearchResultsInterfaceFactory->create( ) .../ModelnameRepository.php:109
Magento\Framework\ObjectManager\ObjectManager->create( ) .../ModelnameSearchResultsInterfaceFactory.php:43
Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create( ) .../ObjectManager.php:57
hi, after created a customer address attribute i get this error: unable to place order. Please try again later. went i try to place order.
this it the code:
registration.php
<?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Some_IdNumberShipping', __DIR__ );
composer.json
{ "name": "some/idnumbershipping", "description": "", "authors": [ { "email": "mail@mage2gen", "name": "Mage2Gen" } ], "minimum-stability": "dev", "require": {}, "autoload": { "files": [ "registration.php" ], "psr-4": { "Some\\IdNumberShipping\\": "" } } }
InstallData.php
<?php
namespace Some\IdNumberShipping\Setup;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Customer\Setup\CustomerSetupFactory;
use Magento\Customer\Model\Customer;
use Magento\Framework\Setup\ModuleContextInterface;
class InstallData implements InstallDataInterface {
private $customerSetupFactory;
public function __construct(
CustomerSetupFactory $customerSetupFactory
){
$this->customerSetupFactory = $customerSetupFactory;
}
public function install(
ModuleDataSetupInterface $setup,
ModuleContextInterface $context
){
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
$customerSetup->addAttribute('customer_address', 'id_shippingNumber', [
'label' => 'Id de quien recibe',
'input' => 'text',
'type' => 'varchar',
'source' => '',
'required' => True,
'position' => 1,
'visible' => True,
'system' => false,
'is_used_in_grid' => false,
'is_visible_in_grid' => false,
'is_filterable_in_grid' => false,
'is_searchable_in_grid' => false,
'backend' => ''
]);
$attribute = $customerSetup->getEavConfig()->getAttribute('customer_address', 'id_shippingNumber')->addData(['used_in_forms' => ['adminhtml_customer_address','customer_address_edit','customer_register_address']]);
$attribute->save();
}
}
InstallSchena.php
<?php
namespace Some\IdNumberShipping\Setup;
use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
class InstallSchema implements InstallSchemaInterface {
public function install(
SchemaSetupInterface $setup,
ModuleContextInterface $context
){
$installer = $setup;
$installer->startSetup();
$setup->endSetup();
}
}
etc/module.xml
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Some_IdNumberShipping" setup_version="1.0.0"/>
</config>
etc/extension_attributes.xml
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
<extension_attributes for="Magento\Customer\Api\Data\AddressInterface">
<attribute code="id_shippingNumber" type="string"/>
</extension_attributes>
</config>
If you create a product attribute with type date, both the input type and backend_type are set to date. While the backend_type should be datetime. Cause there is not product_date table only a product_datetime table.
When creating module via GUI interface (mage2gen.com) that has both customer and customer address attribute, InstallData.php is generated with an error on line 32: $customerSetupFactory is undefined. It seems it's missing in __construct.
It would be great if there could be inserted a small copyright and package/method documentation like:
At the top file
/**
* Some copyright text.
*
* @category ***
* @package ***
* @author ****
*/
for the Method:
/**
* Register user contexts.
*
* @param CompositeHelper $compositeHelper
* @param UserContextInterface[] $userContexts
* @return RETURN_TYPE
*/
protected function add(UserContextInterface $userContext)
{
$this->userContexts[] = $userContext;
return $this;
}
Between the comment/phpdoc and the function name is a new line.
Api/Data/{interface}
Hello guys,
I have found a problem in the NAMESPACE\MODULE\Model\ResourceModel\ENTITY when we use the MassAction in the Admin Grid.
You have to add this line:
protected $_idFieldName = 'entity_id';
thanks
Hi Krukas,
when you try to create more than one module, the Mage2Gen software creates the mysql tables using the setup class but there is a problem.
For instance: Take a look the Library project sample posted in the previous issue.
Just for testing:
We need to create a Library module and we need more than one data model. For instance:
The Module name: Library
The Models are:
So I have created my models in this way: https://mage2gen.com/load/e9a12f34-9313-4b73-a6dd-1e650cd2ce99
Now the setup install will create 3 tables:
Mage2Gen helps me to create all the models but the name of the classes and the name of the database tables could be create a bit of confusion when the project need more than 3 models.
So I have thought to group all the models using the project name:
but this solution creates a problem in the Magento folder structure.
Any hint?
wrong tag for page: "pagepage" need replace to "page"
I generated a model with "Web api" Checkbox enabled. However when i try to use the api https://example.com/rest/V1/XXXX/YYYY,
i get :
{
"message": "Request does not match any route.",
"trace": null
}
although am using the correct URL and parameters as defined in the webapi.xml
When I make a new model I like to add attributes that have similar content close to each other. Now I cannot reorder the attributes in the model when I make additional attributes.
if you try create a payment method, it will not show up on checkout page
i found incorrect generated layout xml
you can check at checkout_index_index.xml file
Not all source models are selectable in the dropdown when creating a customattribute
Er mist een punt comma achter de
$this->_options = [ ['value' => (string) 'experius_payment_multi_invoice1', 'label' => __('experius_payment_multi_invoice1')], ['value' => (string) 'msp', 'label' => __('msp')] ]
Hi first of all thanks for your project!
When I try to create a simple module with one admin controller, no menu.xml is created.
Can you check it?
thanks again
So I tried to create a new module with one observer and few system settings. But something is wrong with system.xml I guess. Everything works expect custom source_model. If I look into system.log it says
Class Company\MyAwesomeModule\Model\Config\Source\My_awesome_clss does not exist.
So if I comment out the fields using custom source_model inside system.xml , the group does appear inside admin area under my tab->section. but it I uncomment nothing shows inside configuration. Although tab and section is there........I hope you get it what I am trying to say here.
I think that replace string name to constant will be correct for all entities like category, product, customer and order.
Example:
addAttribute('customer'
=> addAttribute(Customer::ENTITY
with use Magento\Customer\Model\Customer;
$customerSetup->addAttribute('customer', '{attribute_code}', [
'type' => '{value_type}',
'label' => '{attribute_label}',
'input' => '{frontend_input}',
'source' => '{source_model}',
'required' => {required},
'visible' => {visible},
'position' => {sort_order},
'system' => false,
'backend' => '{backend_model}'
]);
https://github.com/krukas/Mage2Gen/blob/master/mage2gen/templates/attributes/customerattribute.tmpl
I have app/code/A4G/B2B/Model/Category/Attribute/Source/A4g_gtfeauters.php:
`<?php
namespace A4G\B2B\Model\Category\Attribute\Source;
class A4g_gtfeauters extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
{
/**
* @var array
*/
protected $_optionsData;
/**
* Constructor
*
* @param array $options
*/
public function __construct(\Psr\Log\LoggerInterface $logger, array $options)
{
$logger->addInfo('A4g_gtfeauters');
$this->_optionsData = $options;
}
/**
* getAllOptions
*
* @return array
*/
public function getAllOptions()
{
if ($this->_options === null) {
$this->_options = [
['value' => (string) 'CARP', 'label' => __('CARP')],
['value' => (string) 'CATFISH', 'label' => __('CATFISH')],
['value' => (string) 'COMPETITION', 'label' => __('COMPETITION')],
['value' => (string) 'FEEDER', 'label' => __('FEEDER')],
['value' => (string) 'FLY', 'label' => __('FLY')],
['value' => (string) 'ICE', 'label' => __('ICE')],
['value' => (string) 'MATCH', 'label' => __('MATCH')],
['value' => (string) 'SALTWATER', 'label' => __('SALTWATER')],
['value' => (string) 'SPINNIG', 'label' => __('SPINNIG')]
]
}
return $this->_options;
}
}
`
generated by Mage2Gen, but still Magento shows me error:
Exception #0 (ReflectionException): Class A4G\B2B\Model\Category\Attribute\Source\A4g_gtfeauters does not exist.
Can you tell me what can make this kind of error? Logger function doesn't give any efect, error in code as well.
protected $_optionsData;
/**
* Constructor
*
* @param array $options
*/
* Constructor
*
* @param array $options
*/
public function __construct(array $options)
{
$this->_optionsData = $options;
}
@dheesbeen
dit
public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Framework\View\Result\PageFactory $resultPageFactory ){ $this->resultPageFactory = $resultPageFactory; parent::__construct($context); }
Zou eigenlijk dit moeten zijn:
public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Framework\View\Result\PageFactory $resultPageFactory ){ $this->resultPageFactory = $resultPageFactory; parent::__construct($context); }
Hello,
thanks for your interesting wizard for Magento 2! It is very helpful!
Is there a way to create a simple form based on the model for the users?
I need to create a link on the user panel that helps the users to add information.
thanks
Hello,
I think the "Adminhtml form" checkbox from the model should be checked by default, what is your opinion?
It should be quite rare to want the field not to be displayed on the admin form.
The controller are being generated using the object Manager instead of Factories classes.
Any good reason for that?
I am testing your software ... here I will report the issues and the suggestions ... :)
If you create a attribute that uses a multiselect the backend_model is missing, I tested this on products. Did not try if it works correctly on customers.
It would be awesome if Mage2Gen scaffolds a XML config reader which can read XML configs of other modules.
There is no length validation for attribute codes. An attribute code must not be more than 30 characters.
Files are now generated without any docblocks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.