1. Home
  2. Docs
  3. Magento 1 B2B Extensions
  4. Pro Configurable Grid Table View
  5. Common Problems

Common Problems

How to fix “Please specify the product’s option(s)” error?

A common error with Pro configurable product grid table view extension is the conflict with ajax add to cart extension. The conflict is shown with an error message “Please specify the product’s option(s)”

Please find below some ways to fix this issue with some ajax add to cart extension from various extension’s provider.

1. Conflict with Smartwave_Ajaxcart

Edit file: Smartwave/Ajaxcart/controller/IndexController.php

  • Edit function addAction();
  • Edit extends => Bss_Configurablegridview_CartControlle

Sample file: https://www.dropbox.com/s/1xzfpakoqftlk3t/IndexController.php?dl=0

2. Conflict with PT_Ajax

edit file: PT/Ajax/controllers/Checkout/CartController.php

  • Edit extends Bss_Configurablegridview_CartController
  • Edit function addAction();
  • Edit function updateItemOptionsAction();

Sample file: https://www.dropbox.com/s/qvlfx1jg2z6743r/PT_Ajax_CartController.php?dl=0

3. Conflict with Amasty Ajax add to cart

In the file: app/code/local/Amasty/Cart/controllers/AjaxController.php

Add function: _initProduct();

Edit function indexAction() into:

public function indexAction()
    {
      $idProduct = Mage::app()->getRequest()->getParam('product_id');
      $idProduct = Mage::app()->getRequest()->getParam('product')? Mage::app()->getRequest()->getParam('product'): $idProduct;
      $IsProductView = Mage::app()->getRequest()->getParam('IsProductView');
      $params = Mage::app()->getRequest()->getParams();
      $related = $this->getRequest()->getParam('related_product');
      unset($params['product_id']);
      unset($params['IsProductView']);

      if($this->getRequest()->getParam('configurable_grid_table') == 'Yes') {
        $params = $this->getRequest()->getParams();
        $config_super_attributes = $params['super_attribute_quickshop'];
        $cart = Mage::getSingleton('checkout/cart');
        $config_table_qty = $params['config_table_qty'];
        $options = isset($params['options']) ? $params['options'] : null;

        $qty_config = array();

        foreach($config_table_qty as $sup_qty => $_super_qty) {
          $qty_config[$sup_qty] =$_super_qty;
          $required += $_super_qty;
        }

        if($required == 0) {
          $this->_getSession()->addError($this->__('Cannot add the item to shopping cart.'));
          $this->_goBack();
          return;
        }

        $config_table_qty = $qty_config;

        foreach($config_super_attributes as $sId => $config_attribute) {
          if(!isset($config_table_qty[$sId]) || $config_table_qty[$sId]=='' || !is_numeric($config_table_qty[$sId])){
            if($config_table_qty[$sId] != '0'){
              $config_table_qty[$sId] = 1;
            }
          }

          if(isset($config_table_qty[$sId]) && $config_table_qty[$sId]!='' && $config_table_qty[$sId] > 0) {
            $product= $this->_initProduct();
            $related= $this->getRequest()->getParam('related_product');

            if (!$product) {
              $this->_goBack();
              return;
            }

            if(isset($config_table_qty[$sId])) {
              $params = array();
              $params['qty'] = $config_table_qty[$sId];
              $params['super_attribute'] = $config_attribute;

              if($options != null) $params['options'] = $options;

              try {
                if($params['qty'] > 0 && $params['qty']!='') {
                  $cart->addProduct($product, $params);
                  if (!empty($related)) {
                        $cart->addProductsByIds(explode(',', $related));
                  }
                  $cart->save();
                  Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
                  if (!$cart->getQuote()->getHasError()){
                      $responseText = $this->addToCartResponse($product, $cart, $IsProductView, $params,0);    
                  }    
                } else {
                  $responseText = $this->showOptionsResponse($product, $IsProductView);    
                }
              } catch (Exception $e) {
                  $responseText = $this->addToCartResponse($product, $cart, $IsProductView, $params, $e->getMessage());
                  Mage::logException($e);
              } 
            }
          }
        }
      } else {
  	    if($related) unset($params['related_product']);
          $product = Mage::getModel('catalog/product')
                     ->setStoreId(Mage::app()->getStore()->getId())
                     ->load($idProduct);
          $responseText = '';
          if ($product->getId())
          {
              if(!array_key_exists('qty', $params)) {
                  $params['qty'] = $product->getStockItem()->getMinSaleQty();
              }
              try{
                  if(($product->getTypeId() == 'simple' && !($product->getRequiredOptions() || (Mage::getStoreConfig('amcart/general/display_options') && $product->getHasOptions())))
                      || count($params) > 2
                      || ($product->getTypeId() == 'virtual' && !($product->getRequiredOptions() || (Mage::getStoreConfig('amcart/general/display_options') && $product->getHasOptions()))))
                  {
                      $cart = Mage::getSingleton('checkout/cart');
                      $cart->addProduct($product, $params);
  		            if (!empty($related)) {
                          $cart->addProductsByIds(explode(',', $related));
                      }
                      $cart->save();
                      Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
                      if (!$cart->getQuote()->getHasError()){
                          $responseText = $this->addToCartResponse($product, $cart, $IsProductView, $params,0);    
                      }    
                  }
                  else{
                       $responseText = $this->showOptionsResponse($product, $IsProductView);    
                  }
                      
              }
              catch (Exception $e) {
                  $responseText = $this->addToCartResponse($product, $cart, $IsProductView, $params, $e->getMessage());
                  Mage::logException($e);
              }
          }
        }
        $this->getResponse()->setBody($responseText);
    }

Sample file: https://www.dropbox.com/s/vz9bjgx9rd2ue97/AjaxController.php?dl=0

4. Conflict with Magentothem_Ajaxcartsuper

Edit file: /app/code/local/Magentothem/Ajaxcartsuper/controllers/AjaxcartController.php

Edit function addAction() to:

{quote}public function addAction()
    {
		header("Content-type: application/json");

        if($this->getRequest()->getParam('callback')) {
            $cart   = $this->_getCart();
            $ajaxData = array();
            $productInfo = array();
            $params = $this->getRequest()->getParams();

            try {
                if($this->getRequest()->getParam('configurable_grid_table') == 'Yes') {
                    $params = $this->getRequest()->getParams();
                    $config_super_attributes = $params['super_attribute_quickshop'];
                    $cart   = $this->_getCart();
                    $config_table_qty = $params['config_table_qty'];
                    $options = isset($params['options']) ? $params['options'] : null;
                    $qty_config = array();
                    foreach($config_table_qty as $sup_qty => $_super_qty) {
                        $qty_config[$sup_qty] =$_super_qty;
                        $required += $_super_qty;
                    }
                    if($required == 0) {
                      $this->_getSession()->addError($this->__('Cannot add the item to shopping cart.'));
                      $this->_goBack();
                      return;
                    }
                    $config_table_qty = $qty_config;
                    foreach($config_super_attributes as $sId => $config_attribute) {
                      if(isset($config_table_qty[$sId]) && $config_table_qty[$sId]!='' && $config_table_qty[$sId] > 0) {
                        $product= $this->_initProduct();
                        $related= $this->getRequest()->getParam('related_product');
                        if (!$product) {
                          $this->_goBack();
                          return;
                        }
                        if(isset($config_table_qty[$sId])) {
                          $params2 = array();
                          $params2['qty'] = $config_table_qty[$sId];
                          $params2['super_attribute'] = $config_attribute;
                          if($options != null) $params2['options'] = $options;
                          if($params2['qty'] > 0 && $params2['qty']!='') {
                            $cart->addProduct($product, $params2);
                            if (!empty($related)) {
                              $cart->addProductsByIds(explode(',', $related));
                            }
                          }
                        }
                      }
                    }
                } else {
                    if (isset($params['qty'])) {
                        $filter = new Zend_Filter_LocalizedToNormalized(
                            array('locale' => Mage::app()->getLocale()->getLocaleCode())
                        );

                        $params['qty'] = $filter->filter($params['qty']);
                    }

                    $product = $this->_initProduct();
                    if($params['type_product']==1) {
                        $productInfo['type_product'] = $product->getTypeId();
                        $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($productInfo));
                        return ;

                    }

                    $related = $this->getRequest()->getParam('related_product');

                    /**
                     * Check product availability
                     */
                    if (!$product) {
                        	$ajaxData['status'] = 0;
                            $ajaxData['message'] = $this->__('Unable to find Product ID');
                    }

                    $cart->addProduct($product, $params);

                    if (!empty($related)) {
                        $cart->addProductsByIds(explode(',', $related));
                    }
                }

                $cart->save();
                $this->_getSession()->setCartWasUpdated(true);

                /**

                 * @todo remove wishlist observer processAddToCart

                 */

                Mage::dispatchEvent('checkout_cart_add_product_complete',

                    array('product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse())

                );



                if (!$this->_getSession()->getNoCartRedirect(true)) {
                    if (!$cart->getQuote()->getHasError()){
                        $message = $this->__('%s was added to your shopping cart.', Mage::helper('core')->escapeHtml($product->getName()));
                       // $this->_getSession()->addSuccess($message);
                        $ajaxData['status'] = 1;
                        $this->loadLayout();
                        $sidebarCart = "";
                        $mini_cart = "";
                        $toplink = "";
						
                        if ($this->getLayout()->getBlock('cart_sidebar')) {
                            $sidebarCart = $this->getLayout()->getBlock('cart_sidebar')->toHtml();
                        }

                        if ($this->getLayout()->getBlock('cart_sidebar_mini')) {
                            $mini_cart = $this->getLayout()->getBlock('cart_sidebar_mini')->toHtml();
                        }

                        if ($this->getLayout()->getBlock('top.links')) {
                            $toplink = $this->getLayout()->getBlock('top.links')->toHtml();
                        }

                        $pimage = Mage::helper('catalog/image')->init($product, 'small_image')->resize(55);
                        $ajaxData['sidebar_cart'] = $sidebarCart;
                        $ajaxData['top_link'] = $toplink;
                        $ajaxData['mini_cart'] = $mini_cart;
                        //show or hide cofirmbox when add product to cart

                        if (Mage::getStoreConfig('ajaxcartsuper/ajaxcartsuper_config/show_confirm')) {
                            $ajaxData['product_info'] = Mage::helper('ajaxcartsuper/data')->productHtml($product->getName(), $product->getProductUrl(), $pimage);
                        }

                    }

                }
            } catch (Mage_Core_Exception $e) {
                $msg = "";
				
                if ($this->_getSession()->getUseNotice(true)) {
                    $msg = $e->getMessage();
                } else {
                    $messages = array_unique(explode("\n", $e->getMessage()));
                    foreach ($messages as $message) {
                        $msg .= $message . '
';
                    }
                }

                $ajaxData['status'] = 0;
                $ajaxData['message'] = $msg;
                $ajaxData['type_product_ajax'] = 1;

            } catch (Exception $e) {
                $ajaxData['status'] = 0;
                $ajaxData['message'] = $this->__('Cannot add the this product to shopping cart.');
            }
           $this->getResponse()->setBody($this->getRequest()->getParam('callback').'('.Mage::helper('core')->jsonEncode($ajaxData).')');
           return;

        }  else {
            parent::addAction();
        }
    }{quote}

Sample file: https://www.dropbox.com/s/frkidfqdke3p5kp/AjaxcartController.php?dl=0

Was this article helpful to you? Yes No

How can we help?