コード例 #1
0
ファイル: Save.php プロジェクト: kidaa30/magento2-platformsh
 /**
  * Override urlrewrite data, basing on current category and product
  *
  * @param \Magento\UrlRewrite\Model\UrlRewrite $model
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _handleCatalogUrlRewrite($model)
 {
     $productId = $this->_getProduct()->getId();
     $categoryId = $this->_getCategory()->getId();
     if ($productId || $categoryId) {
         if ($model->isObjectNew()) {
             $model->setEntityType($productId ? self::ENTITY_TYPE_PRODUCT : self::ENTITY_TYPE_CATEGORY)->setEntityId($productId ?: $categoryId);
             if ($productId && $categoryId) {
                 $model->setMetadata(serialize(['category_id' => $categoryId]));
             }
         }
         $model->setTargetPath($this->getTargetPath($model));
     }
 }