- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Disable "Simple Product"
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Disable "Simple Product"
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.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Disable "Simple Product"
Hi.
I am using module from CreativeMinds.
Thanks, Christoph
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Disable "Simple Product"
Try once below solution:
https://magento.stackexchange.com/a/273814
I hope it will help you!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Disable "Simple Product"
Thank you.
Christoph
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Disable "Simple Product"
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Disable "Simple Product"
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; } }
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Disable "Simple Product"
What about this code line?
$arrAlowedTypesIds = array('simple');
Shouldn't there be other types of products?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Disable "Simple Product"
I found the files in magento/module-catalog, where types are set. Unfortunatelly after I change it magenti crashes.
Christoph
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Disable "Simple Product"
$arrAlowedTypesIds = array('simple');
You can add multiple product type in above array which you want to remove.
For eg:
$arrAlowedTypesIds = array('simple','group');
In this case all product type shows except simple and group.
You don't need to change default Magento code.
Or you can use same code as per stackoverflow. Then you need to add product type which you want to show in below line.
$arrAlowedTypesIds = array('simple','group');
In this case simple and group type shows.
I hope it make sense.