/**
  * @param \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $attrSetColFac
  * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $prodAttrColFac
  * @param array $params
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function __construct(\Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $attrSetColFac, \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $prodAttrColFac, array $params)
 {
     $this->_attrSetColFac = $attrSetColFac;
     $this->_prodAttrColFac = $prodAttrColFac;
     if ($this->isSuitable()) {
         if (!isset($params[0]) || !isset($params[1]) || !is_object($params[0]) || !$params[0] instanceof \Magento\CatalogImportExport\Model\Import\Product) {
             throw new \Magento\Framework\Exception\LocalizedException(__('Please correct the parameters.'));
         }
         $this->_entityModel = $params[0];
         $this->_type = $params[1];
         foreach ($this->_messageTemplates as $errorCode => $message) {
             $this->_entityModel->addMessageTemplate($errorCode, $message);
         }
         $this->_initAttributes();
     }
 }
Example #2
0
 /**
  * @param array $templateCollection
  * @return $this
  */
 protected function initMessageTemplates(array $templateCollection)
 {
     foreach ($templateCollection as $errorCode => $message) {
         $this->_entityModel->addMessageTemplate($errorCode, $message);
     }
     return $this;
 }
Example #3
0
 /**
  * Initialization of error message templates
  *
  * @return $this
  */
 protected function _initMessageTemplates()
 {
     // @codingStandardsIgnoreStart
     $this->_productEntity->addMessageTemplate(self::ERROR_INVALID_STORE, __('Value for \'price\' sub attribute in \'store\' attribute contains incorrect value'));
     $this->_productEntity->addMessageTemplate(self::ERROR_INVALID_TYPE, __('Value for \'type\' sub attribute in \'custom_options\' attribute contains incorrect value, acceptable values are: \'dropdown\', \'checkbox\''));
     $this->_productEntity->addMessageTemplate(self::ERROR_EMPTY_TITLE, __('Please enter a value for title.'));
     $this->_productEntity->addMessageTemplate(self::ERROR_INVALID_PRICE, __('Value for \'price\' sub attribute in \'custom_options\' attribute contains incorrect value'));
     $this->_productEntity->addMessageTemplate(self::ERROR_INVALID_MAX_CHARACTERS, __('Value for \'maximum characters\' sub attribute in \'custom_options\' attribute contains incorrect value'));
     $this->_productEntity->addMessageTemplate(self::ERROR_INVALID_SORT_ORDER, __('Value for \'sort order\' sub attribute in \'custom_options\' attribute contains incorrect value'));
     $this->_productEntity->addMessageTemplate(self::ERROR_INVALID_ROW_PRICE, __('Value for \'value price\' sub attribute in \'custom_options\' attribute contains incorrect value'));
     $this->_productEntity->addMessageTemplate(self::ERROR_INVALID_ROW_SORT, __('Value for \'sort order\' sub attribute in \'custom_options\' attribute contains incorrect value'));
     $this->_productEntity->addMessageTemplate(self::ERROR_AMBIGUOUS_NEW_NAMES, __('This name is already being used for custom option. Please enter a different name.'));
     $this->_productEntity->addMessageTemplate(self::ERROR_AMBIGUOUS_OLD_NAMES, __('This name is already being used for custom option. Please enter a different name.'));
     $this->_productEntity->addMessageTemplate(self::ERROR_AMBIGUOUS_TYPES, __('Custom options have different types.'));
     // @codingStandardsIgnoreEnd
     return $this;
 }
Example #4
0
 /**
  * Initialization of error message templates
  *
  * @return $this
  */
 protected function _initMessageTemplates()
 {
     // @codingStandardsIgnoreStart
     $this->_productEntity->addMessageTemplate(self::ERROR_INVALID_STORE, __('Invalid custom option store.'));
     $this->_productEntity->addMessageTemplate(self::ERROR_INVALID_TYPE, __('Invalid custom option type.'));
     $this->_productEntity->addMessageTemplate(self::ERROR_EMPTY_TITLE, __('Empty custom option title.'));
     $this->_productEntity->addMessageTemplate(self::ERROR_INVALID_PRICE, __('Invalid custom option price.'));
     $this->_productEntity->addMessageTemplate(self::ERROR_INVALID_MAX_CHARACTERS, __('Invalid custom option maximum characters value.'));
     $this->_productEntity->addMessageTemplate(self::ERROR_INVALID_SORT_ORDER, __('Invalid custom option sort order.'));
     $this->_productEntity->addMessageTemplate(self::ERROR_INVALID_ROW_PRICE, __('Invalid custom option value price.'));
     $this->_productEntity->addMessageTemplate(self::ERROR_INVALID_ROW_SORT, __('Invalid custom option value sort order.'));
     $this->_productEntity->addMessageTemplate(self::ERROR_AMBIGUOUS_NEW_NAMES, __('Custom option with such title already declared in source file.'));
     $this->_productEntity->addMessageTemplate(self::ERROR_AMBIGUOUS_OLD_NAMES, __('There are several existing custom options with such name.'));
     $this->_productEntity->addMessageTemplate(self::ERROR_AMBIGUOUS_TYPES, __('Custom options have different types.'));
     // @codingStandardsIgnoreEnd
     return $this;
 }
Example #5
0
 /**
  * Initialization of error message templates
  *
  * @return $this
  */
 protected function _initMessageTemplates()
 {
     // @codingStandardsIgnoreStart
     $this->_productEntity->addMessageTemplate(self::ERROR_INVALID_STORE, __('Please enter a correct value for "store."'));
     $this->_productEntity->addMessageTemplate(self::ERROR_INVALID_TYPE, __('Please enter a correct value for "type."'));
     $this->_productEntity->addMessageTemplate(self::ERROR_EMPTY_TITLE, __('Please enter a value for title.'));
     $this->_productEntity->addMessageTemplate(self::ERROR_INVALID_PRICE, __('Please enter a correct value for "price."'));
     $this->_productEntity->addMessageTemplate(self::ERROR_INVALID_MAX_CHARACTERS, __('Please enter a correct value for "maximum characters."'));
     $this->_productEntity->addMessageTemplate(self::ERROR_INVALID_SORT_ORDER, __('Please enter a correct value for "sort order."'));
     $this->_productEntity->addMessageTemplate(self::ERROR_INVALID_ROW_PRICE, __('Please enter a correct value for "value price."'));
     $this->_productEntity->addMessageTemplate(self::ERROR_INVALID_ROW_SORT, __('Please enter a correct value for "sort order."'));
     $this->_productEntity->addMessageTemplate(self::ERROR_AMBIGUOUS_NEW_NAMES, __('This name is already being used for custom option. Please enter a different name.'));
     $this->_productEntity->addMessageTemplate(self::ERROR_AMBIGUOUS_OLD_NAMES, __('This name is already being used for custom option. Please enter a different name.'));
     $this->_productEntity->addMessageTemplate(self::ERROR_AMBIGUOUS_TYPES, __('Custom options have different types.'));
     // @codingStandardsIgnoreEnd
     return $this;
 }