當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Category::getUrlKey方法代碼示例

本文整理匯總了PHP中Magento\Catalog\Test\Fixture\Category::getUrlKey方法的典型用法代碼示例。如果您正苦於以下問題:PHP Category::getUrlKey方法的具體用法?PHP Category::getUrlKey怎麽用?PHP Category::getUrlKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Catalog\Test\Fixture\Category的用法示例。


在下文中一共展示了Category::getUrlKey方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: processAssert

 /**
  * Assert that category name is different on different store view.
  *
  * @param BrowserInterface $browser
  * @param CatalogCategoryView $categoryView
  * @param Category $category
  * @param Category $initialCategory
  * @param CmsIndex $cmsIndex
  * @return void
  */
 public function processAssert(BrowserInterface $browser, CatalogCategoryView $categoryView, Category $category, Category $initialCategory, CmsIndex $cmsIndex)
 {
     $cmsIndex->open();
     $cmsIndex->getLinksBlock()->waitWelcomeMessage();
     $browser->open($_ENV['app_frontend_url'] . $initialCategory->getUrlKey() . '.html');
     \PHPUnit_Framework_Assert::assertEquals($initialCategory->getName(), $categoryView->getTitleBlock()->getTitle(), 'Wrong category name is displayed for default store.');
     $store = $category->getDataFieldConfig('store_id')['source']->store->getName();
     $cmsIndex->getStoreSwitcherBlock()->selectStoreView($store);
     $cmsIndex->getLinksBlock()->waitWelcomeMessage();
     $browser->open($_ENV['app_frontend_url'] . $initialCategory->getUrlKey() . '.html');
     \PHPUnit_Framework_Assert::assertEquals($category->getName(), $categoryView->getTitleBlock()->getTitle(), 'Wrong category name is displayed for ' . $store);
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:22,代碼來源:AssertCategoryWithCustomStoreOnFrontend.php

示例2: processAssert

 /**
  * Assert that the category cannot be accessed from the navigation bar in the frontend
  *
  * @param CmsIndex $cmsIndex
  * @param Category $category
  * @param BrowserInterface $browser
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, Category $category, BrowserInterface $browser)
 {
     $cmsIndex->open();
     \PHPUnit_Framework_Assert::assertFalse($cmsIndex->getTopmenu()->isCategoryVisible($category->getName()), 'Category can be accessed from the navigation bar in the frontend.');
     $browser->open($_ENV['app_frontend_url'] . $category->getUrlKey() . '.html');
     \PHPUnit_Framework_Assert::assertEquals(self::NOT_FOUND_MESSAGE, $cmsIndex->getTitleBlock()->getTitle(), 'Wrong page is displayed.');
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:15,代碼來源:AssertCategoryIsNotActive.php

示例3: __inject

 /**
  * Prepare datasets and pages
  *
  * @param UrlRewriteIndex $urlRewriteIndex
  * @param UrlRewriteEdit $urlRewriteEdit
  * @param FixtureFactory $fixtureFactory
  * @param Category $category
  * @return array
  */
 public function __inject(UrlRewriteIndex $urlRewriteIndex, UrlRewriteEdit $urlRewriteEdit, FixtureFactory $fixtureFactory, Category $category)
 {
     $this->urlRewriteIndex = $urlRewriteIndex;
     $this->urlRewriteEdit = $urlRewriteEdit;
     $category->persist();
     $categoryRedirect = $fixtureFactory->createByCode('urlRewrite', ['dataset' => 'default', 'data' => ['target_path' => $category->getUrlKey() . '.html']]);
     $categoryRedirect->persist();
     return ['categoryRedirect' => $categoryRedirect, 'category' => $category];
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:18,代碼來源:UpdateCategoryUrlRewriteEntityTest.php

示例4: processAssert

 /**
  * Assert that sitemap.xml file contains correct content according to dataset:
  *  - product url
  *  - category url
  *  - CMS page url
  *
  * @param CatalogProductSimple $product
  * @param Category $catalog
  * @param CmsPage $cmsPage
  * @param Sitemap $sitemap
  * @param SitemapIndex $sitemapIndex
  * @return void
  */
 public function processAssert(CatalogProductSimple $product, Category $catalog, CmsPage $cmsPage, Sitemap $sitemap, SitemapIndex $sitemapIndex)
 {
     $sitemapIndex->open()->getSitemapGrid()->sortGridByField('sitemap_id');
     $filter = ['sitemap_filename' => $sitemap->getSitemapFilename(), 'sitemap_path' => $sitemap->getSitemapPath()];
     $sitemapIndex->getSitemapGrid()->search($filter);
     $content = file_get_contents($sitemapIndex->getSitemapGrid()->getLinkForGoogle());
     $urls = [$_ENV['app_frontend_url'] . $product->getUrlKey() . '.html', $_ENV['app_frontend_url'] . $catalog->getUrlKey() . '.html', $_ENV['app_frontend_url'] . $cmsPage->getIdentifier()];
     \PHPUnit_Framework_Assert::assertTrue($this->checkContent($content, $urls), 'Content of file sitemap.xml does not include one or more of next urls:' . implode("\n", $urls));
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:22,代碼來源:AssertSitemapContent.php

示例5: processAssert

 /**
  * Assert that displayed assigned products on category page equals passed from fixture
  *
  * @param Category $category
  * @param CatalogCategoryView $categoryView
  * @param BrowserInterface $browser
  * @return void
  */
 public function processAssert(Category $category, CatalogCategoryView $categoryView, BrowserInterface $browser)
 {
     $categoryUrlKey = $category->hasData('url_key') ? strtolower($category->getUrlKey()) : trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $category->getName())), '-');
     $products = $category->getDataFieldConfig('category_products')['source']->getProducts();
     $browser->open($_ENV['app_frontend_url'] . $categoryUrlKey . '.html');
     foreach ($products as $productFixture) {
         \PHPUnit_Framework_Assert::assertTrue($categoryView->getListProductBlock()->getProductItem($productFixture)->isVisible(), "Products '{$productFixture->getName()}' not find.");
     }
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:17,代碼來源:AssertCategoryForAssignedProducts.php

示例6: getCategoryUrl

 /**
  * Get category url to open.
  *
  * @param Category $category
  * @return string
  */
 protected function getCategoryUrl(Category $category)
 {
     $categoryUrlKey = [];
     while ($category) {
         $categoryUrlKey[] = $category->hasData('url_key') ? strtolower($category->getUrlKey()) : trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $category->getName())), '-');
         $category = $category->getDataFieldConfig('parent_id')['source']->getParentCategory();
         if (1 == $category->getParentId()) {
             $category = null;
         }
     }
     return $_ENV['app_frontend_url'] . implode('/', array_reverse($categoryUrlKey)) . '.html';
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:18,代碼來源:AssertCategoryPage.php

示例7: processAssert

 /**
  * Assert that the category is no longer available on the top menu bar
  *
  * @param CmsIndex $cmsIndex
  * @param Category $category
  * @param BrowserInterface $browser
  * @param CatalogCategoryView $categoryView
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, Category $category, BrowserInterface $browser, CatalogCategoryView $categoryView)
 {
     $cmsIndex->open();
     \PHPUnit_Framework_Assert::assertFalse($cmsIndex->getTopmenu()->isCategoryVisible($category->getName()), 'Category can be accessed from the navigation bar in the frontend.');
     $browser->open($_ENV['app_frontend_url'] . $category->getUrlKey() . '.html');
     \PHPUnit_Framework_Assert::assertEquals($category->getName(), $categoryView->getTitleBlock()->getTitle(), 'Wrong page is displayed.');
     if (isset($category->getDataFieldConfig('category_products')['source'])) {
         $products = $category->getDataFieldConfig('category_products')['source']->getProducts();
         foreach ($products as $productFixture) {
             \PHPUnit_Framework_Assert::assertTrue($categoryView->getListProductBlock()->isProductVisible($productFixture->getName()), "Products '{$productFixture->getName()}' not find.");
         }
     }
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:22,代碼來源:AssertCategoryIsNotIncludeInMenu.php

示例8: processAssert

 /**
  * Assert that url rewrite category in grid
  *
  * @param Category $category
  * @param UrlRewriteIndex $urlRewriteIndex
  * @return void
  */
 public function processAssert(Category $category, UrlRewriteIndex $urlRewriteIndex)
 {
     $urlRewriteIndex->open();
     $filter = ['target_path' => strtolower($category->getUrlKey())];
     \PHPUnit_Framework_Assert::assertTrue($urlRewriteIndex->getUrlRedirectGrid()->isRowVisible($filter, true, false), 'URL Rewrite with request path "' . $category->getUrlKey() . '" is absent in grid.');
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:13,代碼來源:AssertUrlRewriteCategoryInGrid.php

示例9: processAssert

 /**
  * Assert that old Category URL lead to appropriate Category in frontend
  *
  * @param Category $category
  * @param BrowserInterface $browser
  * @param Category $initialCategory
  * @return void
  */
 public function processAssert(Category $category, BrowserInterface $browser, Category $initialCategory)
 {
     $browser->open($_ENV['app_frontend_url'] . $initialCategory->getUrlKey() . '.html');
     \PHPUnit_Framework_Assert::assertEquals($browser->getUrl(), $_ENV['app_frontend_url'] . strtolower($category->getUrlKey()) . '.html', 'URL rewrite category redirect false.');
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:13,代碼來源:AssertCategoryRedirect.php

示例10: processAssert

 /**
  * Assert check URL rewrite category redirect
  *
  * @param UrlRewrite $urlRewrite
  * @param Category $category
  * @param BrowserInterface $browser
  * @return void
  */
 public function processAssert(UrlRewrite $urlRewrite, Category $category, BrowserInterface $browser)
 {
     $browser->open($_ENV['app_frontend_url'] . $urlRewrite->getRequestPath());
     $url = $urlRewrite->getRedirectType() == 'No' ? $urlRewrite->getRequestPath() : $category->getUrlKey() . '.html';
     \PHPUnit_Framework_Assert::assertEquals($browser->getUrl(), $_ENV['app_frontend_url'] . $url, 'URL rewrite category redirect false.' . "\nExpected: " . $_ENV['app_frontend_url'] . $url . "\nActual: " . $browser->getUrl());
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:14,代碼來源:AssertUrlRewriteCategoryRedirect.php

示例11: processAssert

 /**
  * Assert that not displayed category in frontend main menu
  *
  * @param BrowserInterface $browser
  * @param CatalogCategoryView $categoryView
  * @param Category $category
  * @return void
  */
 public function processAssert(BrowserInterface $browser, CatalogCategoryView $categoryView, Category $category)
 {
     $browser->open($_ENV['app_frontend_url'] . $category->getUrlKey() . '.html');
     \PHPUnit_Framework_Assert::assertEquals(self::NOT_FOUND_MESSAGE, $categoryView->getTitleBlock()->getTitle(), 'Wrong page is displayed.');
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:13,代碼來源:AssertCategoryAbsenceOnFrontend.php

示例12: getCategoryUrl

 /**
  * Get category url to open
  *
  * @param Category $category
  * @return string
  */
 protected function getCategoryUrl(Category $category)
 {
     $categoryUrlKey = $category->hasData('url_key') ? strtolower($category->getUrlKey()) : trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $category->getName())), '-');
     return $_ENV['app_frontend_url'] . $categoryUrlKey . '.html';
 }
開發者ID:whoople,項目名稱:magento2-testing,代碼行數:11,代碼來源:AssertCategoryPage.php

示例13: processAssert

 /**
  * Assert that category url rewrite not in grid
  *
  * @param UrlRewriteIndex $urlRewriteIndex
  * @param Category $category
  * @return void
  */
 public function processAssert(UrlRewriteIndex $urlRewriteIndex, Category $category)
 {
     $urlRewriteIndex->open();
     $filter = ['request_path' => $category->getUrlKey()];
     \PHPUnit_Framework_Assert::assertFalse($urlRewriteIndex->getUrlRedirectGrid()->isRowVisible($filter), "URL Rewrite with request path '{$category->getUrlKey()}' is present in grid.");
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:13,代碼來源:AssertUrlRewriteCategoryNotInGrid.php


注:本文中的Magento\Catalog\Test\Fixture\Category::getUrlKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。