Beispiel #1
0
 /**
  * @param \Magento\Framework\App\RequestInterface $request
  * @param UrlRewrite $rewrite
  * @return \Magento\Framework\App\ActionInterface|null
  */
 protected function processRedirect($request, $rewrite)
 {
     $target = $rewrite->getTargetPath();
     if ($rewrite->getEntityType() !== Rewrite::ENTITY_TYPE_CUSTOM || ($prefix = substr($target, 0, 6)) !== 'http:/' && $prefix !== 'https:') {
         $target = $this->url->getUrl('', ['_direct' => $target]);
     }
     return $this->redirect($request, $target, $rewrite->getRedirectType());
 }
 /**
  * @param \Magento\UrlRewrite\Service\V1\Data\UrlRewrite $url
  * @param int $storeId
  * @return array
  */
 protected function generateForCustom($url, $storeId)
 {
     $urls = [];
     $targetPath = !$url->getRedirectType() ? $url->getTargetPath() : $this->categoryUrlPathGenerator->getUrlPathWithSuffix($this->category, $storeId);
     if ($url->getRequestPath() !== $targetPath) {
         $urls[$url->getRequestPath() . '_' . $storeId] = $this->urlRewriteFactory->create()->setEntityType(CategoryUrlRewriteGenerator::ENTITY_TYPE)->setEntityId($this->category->getId())->setRequestPath($url->getRequestPath())->setTargetPath($targetPath)->setRedirectType($url->getRedirectType())->setStoreId($storeId)->setDescription($url->getDescription())->setIsAutogenerated(0)->setMetadata($url->getMetadata());
     }
     return $urls;
 }
 /**
  * @param UrlRewrite $url
  * @param Category $category
  * @return array
  */
 protected function generateForCustom($url, $category)
 {
     $storeId = $url->getStoreId();
     $productId = $url->getEntityId();
     if (isset($this->products[$productId][$storeId])) {
         $product = $this->products[$productId][$storeId];
         $targetPath = $url->getRedirectType() ? $this->productUrlPathGenerator->getUrlPathWithSuffix($product, $storeId, $category) : $url->getTargetPath();
         if ($url->getRequestPath() === $targetPath) {
             return [];
         }
         return [$this->urlRewriteFactory->create()->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE)->setEntityId($productId)->setRequestPath($url->getRequestPath())->setTargetPath($targetPath)->setRedirectType($url->getRedirectType())->setStoreId($storeId)->setDescription($url->getDescription())->setIsAutogenerated(0)->setMetadata($url->getMetadata())];
     }
     return [];
 }