/** * Process product data before save * * @param \Magento\Framework\DataObject $object * @return $this */ protected function _beforeSave(\Magento\Framework\DataObject $object) { /** * Check if declared category ids in object data. */ if ($object->hasCategoryIds()) { $categoryIds = $this->_catalogCategory->verifyIds($object->getCategoryIds()); $object->setCategoryIds($categoryIds); } $self = parent::_beforeSave($object); /** * Try detect product id by sku if id is not declared */ if (!$object->getId() && $object->getSku()) { $object->setId($this->getIdBySku($object->getSku())); } return $self; }
/** * {@inheritdoc} */ public function verifyIds(array $ids) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'verifyIds'); if (!$pluginInfo) { return parent::verifyIds($ids); } else { return $this->___callPlugins('verifyIds', func_get_args(), $pluginInfo); } }