/**
  * @throws HttpException
  */
 public function actionSave()
 {
     $this->requireAdmin();
     $this->requirePostRequest();
     $variant = new Market_VariantModel();
     // Shared attributes
     $params = ['id', 'productId', 'sku', 'price', 'width', 'height', 'length', 'weight', 'stock', 'unlimitedStock', 'minQty', 'maxQty', 'isImplicit'];
     foreach ($params as $param) {
         $variant->{$param} = craft()->request->getPost($param);
     }
     $variant->setContentFromPost('fields');
     // Save it
     if (craft()->market_variant->save($variant)) {
         craft()->userSession->setNotice(Craft::t('Variant saved.'));
         $this->redirectToPostedUrl($variant);
     } else {
         craft()->userSession->setError(Craft::t('Couldn’t save variant.'));
     }
     // Send the model back to the template
     craft()->urlManager->setRouteVariables(['variant' => $variant]);
 }