After having made a working "Hello World" module, I tried to make my first magento 2 real module. The goal is to add a new product type. Using several tutorials, I did :
Mine\Custproducttype\etc\module.xml
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Mine_Custproducttype" schema_version="2.0.0">
<sequence>
<module name="Magento_Catalog"/>
</sequence>
</module>
</config>
Mine\Custproducttype\etc\product_types.xml
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Catalog:etc/product_types.xsd">
<type name="pcbproto" label="PCB Prototype" modelInstance="Mine\Custproducttype\Model\Product\Type\Pcbproto" indexPriority="10" sortOrder="25">
<customAttributes>
<attribute name="refundable" value="true"/>
<attribute name="taxable" value="true"/>
</customAttributes>
</type>
<composableTypes>
<type name="pcbproto" />
</composableTypes>
</config>
Mine\Custproducttype\Model\Product\Type\Pcbproto.php
<?php
namespace Mine\Custproducttype\Model\Product\Type;
class Pcbproto extends \Magento\Catalog\Model\Product\Type\AbstractType
{
/**
* Product type code
*/
const TYPE_CODE = 'pcbproto';
/**
* Delete data specific for Simple product type
*
* @param \Magento\Catalog\Model\Product $product
* @return void
*/
public function deleteTypeSpecificData(\Magento\Catalog\Model\Product $product)
{
}
}
Mine\Custproducttype\registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Mine_Custproducttype',
__DIR__
);
When I add my module to the magento2 app/code
directory all magento commands stop working (ex : php bin/magento module:status
) and give an error :
There are no commands defined in the "module" namespace.
Removing the module and is starts working again.
Thank you for your help,