Hi all.
I've searched, but unfortunatelly without success so far. Maybe someone could help me.
I try to dissable the possibility to add Simple Product. By default it seems allways possible to add a Simple Product. I just need to turn it off. So if someone logs in and want to sell a product (Multivendor Shop), he / she should not be able to sell a Simple Product.
Does anyone know how to do this?
Where are the core files which determine Product Types?
Thanks for Your help, Christoph
Hello @kristophoro ,
Please let me know which mutli vendor module you are using for you Multivendor Shop, so that I would help you on this.
Regards.
Hi.
I am using module from CreativeMinds.
Thanks, Christoph
Hi again.
I am at coding at the moment.
The script you mentioned needs a little change.
<?php namespace Company\MyModule\Block\Adminhtml; class Product extends \Magento\Catalog\Block\Adminhtml\Product{ protected function _getAddProductButtonOptions() { /* var Array $arrAlowedTypes */ $arrAlowedTypesIds = array('simple'); $splitButtonOptions = []; $types = $this->_typeFactory->create()->getTypes(); uasort( $types, function ($elementOne, $elementTwo) { return ($elementOne['sort_order'] < $elementTwo['sort_order']) ? -1 : 1; } ); foreach ($types as $typeId => $type) { if(in_array($typeId,$arrAlowedTypesIds)) { $splitButtonOptions[$typeId] = [ 'label' => __($type['label']), 'onclick' => "setLocation('" . $this->_getProductCreateUrl($typeId) . "')", 'default' => \Magento\Catalog\Model\Product\Type::DEFAULT_TYPE == $typeId, ]; } } return $splitButtonOptions; } }
How to hide the Simple Product, but leave the rest unchanged? There are group, virtual, downloadable products. How to put them inside the code above, so only those were avaible for seller to add?
Thanks again, Christoph
HI @kristophoro
Try the following one once:
<?php namespace Company\MyModule\Block\Adminhtml; class Product extends \Magento\Catalog\Block\Adminhtml\Product { protected function _getAddProductButtonOptions() { /* var Array $arrAlowedTypes */ $arrAlowedTypesIds = array('simple'); $splitButtonOptions = []; $types = $this->_typeFactory->create()->getTypes(); uasort( $types, function ($elementOne, $elementTwo) { return ($elementOne['sort_order'] < $elementTwo['sort_order']) ? -1 : 1; } ); foreach ($types as $typeId => $type) { if(!in_array($typeId,$arrAlowedTypesIds)) { $splitButtonOptions[$typeId] = [ 'label' => __($type['label']), 'onclick' => "setLocation('" . $this->_getProductCreateUrl($typeId) . "')", 'default' => \Magento\Catalog\Model\Product\Type::DEFAULT_TYPE == $typeId, ]; } } return $splitButtonOptions; } }