cancel
Showing results for 
Search instead for 
Did you mean: 

Disable "Simple Product"

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

9 REPLIES 9

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.

Re: Disable "Simple Product"

Hi.

I am using module from CreativeMinds.

Thanks, Christoph

Re: Disable "Simple Product"

Hi @kristophro,

Try once below solution:

https://magento.stackexchange.com/a/273814

I hope it will help you!

Re: Disable "Simple Product"

Ok. I will.
Thank you.
Christoph

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

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;
    }
}

Re: Disable "Simple Product"

One more thing...
What about this code line?
$arrAlowedTypesIds = array('simple');
Shouldn't there be other types of products?

Re: Disable "Simple Product"

... and the default should be changed as well
I found the files in magento/module-catalog, where types are set. Unfortunatelly after I change it magenti crashes.
Christoph

Re: Disable "Simple Product"

I had changed code little bit in my last comment. I haven't tested my code.
$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.