/** * @return string */ protected function getCanonicalTargetPath() { $product = $this->_getProduct()->getId() ? $this->_getProduct() : null; $category = $this->_getCategory()->getId() ? $this->_getCategory() : null; return $product ? $this->productUrlPathGenerator->getCanonicalUrlPath($product, $category) : $this->categoryUrlPathGenerator->getCanonicalUrlPath($category); }
public function testGetCanonicalUrlPath() { $this->category->expects($this->once())->method('getId')->will($this->returnValue(1)); $this->assertEquals( 'catalog/category/view/id/1', $this->categoryUrlPathGenerator->getCanonicalUrlPath($this->category) ); }
/** * Generate list based on store view * * @param int $storeId * @param \Magento\Catalog\Model\Category $category * @return \Magento\UrlRewrite\Service\V1\Data\UrlRewrite[] */ public function generate($storeId, Category $category) { $urlPath = $this->categoryUrlPathGenerator->getUrlPathWithSuffix($category, $storeId); $result = [$urlPath . '_' . $storeId => $this->urlRewriteFactory->create()->setStoreId($storeId)->setEntityType(CategoryUrlRewriteGenerator::ENTITY_TYPE)->setEntityId($category->getId())->setRequestPath($urlPath)->setTargetPath($this->categoryUrlPathGenerator->getCanonicalUrlPath($category))]; return $result; }
/** * @param \Magento\Catalog\Model\Product|null $product * @param \Magento\Catalog\Model\Category|null $category * @return string */ protected function getTargetPath($product = null, $category = null) { return $product ? $this->productUrlPathGenerator->getCanonicalUrlPath($product, $category) : $this->categoryUrlPathGenerator->getCanonicalUrlPath($category); }