Posted on

main.CRITICAL: Exception: Deprecated Functionality: array_key_exists(): Using array_key_exists() on objects is deprecated

{
public function execute(MagentoFrameworkEventObserver $observer)
{
$request = $this->_appRequestInterface->getPost();

try
{
if($this->_configScopeConfigInterface->getValue(‘minqty/general/enabled’, ScopeInterface::SCOPE_STORE,$this->_modelStoreManagerInterface->getStore())) :

$main_product_id = 0;
if(array_key_exists(‘super_group’,$request) && array_key_exists(‘product’,$request))
{
$main_product_id = $request[‘product’];
$main_product = $this->_modelProductFactory->create()->load($main_product_id);
$allowed_qty = $main_product->getCustomminqty();

if($allowed_qty > 0 && $allowed_qty != ”)
{
$total_qty = 0;
foreach($request[‘super_group’] as $cur_qty)
{
if($cur_qty != ”)
{
$total_qty = $total_qty + $cur_qty;
}
}

if($total_qty < $allowed_qty)
{
$message = “The minimum quantity allowed for purchase is “.$allowed_qty.”.”;
throw new MagentoFrameworkExceptionLocalizedException(__($message));
return;
}
}
}
endif;
}
catch(Exception $e)
{
throw new MagentoFrameworkExceptionLocalizedException(__($e->getMessage()));
return;
}}

Leave a Reply

Your email address will not be published.