本文整理汇总了PHP中Magento\Catalog\Test\Fixture\CatalogProductSimple::getUrlKey方法的典型用法代码示例。如果您正苦于以下问题:PHP CatalogProductSimple::getUrlKey方法的具体用法?PHP CatalogProductSimple::getUrlKey怎么用?PHP CatalogProductSimple::getUrlKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Test\Fixture\CatalogProductSimple
的用法示例。
在下文中一共展示了CatalogProductSimple::getUrlKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processAssert
/**
* Assert that product rating is not displayed on frontend on product review
*
* @param CatalogProductView $catalogProductView
* @param CatalogProductSimple $product
* @param Rating $productRating
* @param BrowserInterface $browser
* @return void
*/
public function processAssert(CatalogProductView $catalogProductView, CatalogProductSimple $product, Rating $productRating, BrowserInterface $browser)
{
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
$catalogProductView->getReviewSummary()->getAddReviewLink()->click();
$reviewForm = $catalogProductView->getReviewFormBlock();
\PHPUnit_Framework_Assert::assertFalse($reviewForm->isVisibleRating($productRating), 'Product rating "' . $productRating->getRatingCode() . '" is displayed.');
}
示例2: processAssert
/**
* @param CatalogProductView $catalogProductView
* @param BrowserInterface $browser
* @param CatalogProductSimple $product
* @return void
*/
public function processAssert(CatalogProductView $catalogProductView, BrowserInterface $browser, CatalogProductSimple $product)
{
//Open product view page
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
//Process assertions
$this->assertOnProductView($product, $catalogProductView);
}
示例3: processAssert
/**
* 1. Creating product simple with custom tax product class
* 2. Log In as customer
* 3. Add product to shopping cart
* 4. Estimate Shipping and Tax
* 5. Implementation assert
*
* @param FixtureFactory $fixtureFactory
* @param TaxRule $taxRule
* @param Customer $customer
* @param CatalogProductView $catalogProductView
* @param CheckoutCart $checkoutCart
* @param Address $address
* @param array $shipping
* @param BrowserInterface $browser
* @param TaxRule $initialTaxRule
* @return void
*/
public function processAssert(FixtureFactory $fixtureFactory, TaxRule $taxRule, Customer $customer, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, Address $address, array $shipping, BrowserInterface $browser, TaxRule $initialTaxRule = null)
{
$this->initialTaxRule = $initialTaxRule;
$this->taxRule = $taxRule;
$this->checkoutCart = $checkoutCart;
$this->shipping = $shipping;
if ($this->initialTaxRule !== null) {
$this->taxRuleCode = $this->taxRule->hasData('code') ? $this->taxRule->getCode() : $this->initialTaxRule->getCode();
} else {
$this->taxRuleCode = $this->taxRule->getCode();
}
// Creating simple product with custom tax class
/** @var \Magento\Tax\Test\Fixture\TaxClass $taxProductClass */
$taxProductClass = $taxRule->getDataFieldConfig('tax_product_class')['source']->getFixture()[0];
$this->productSimple = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'product_100_dollar_for_tax_rule', 'data' => ['tax_class_id' => ['tax_product_class' => $taxProductClass]]]);
$this->productSimple->persist();
// Customer login
$this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
// Clearing shopping cart and adding product to shopping cart
$checkoutCart->open()->getCartBlock()->clearShoppingCart();
$browser->open($_ENV['app_frontend_url'] . $this->productSimple->getUrlKey() . '.html');
$catalogProductView->getViewBlock()->clickAddToCart();
$catalogProductView->getMessagesBlock()->waitSuccessMessage();
// Estimate Shipping and Tax
$checkoutCart->open();
$checkoutCart->getShippingBlock()->openEstimateShippingAndTax();
$checkoutCart->getShippingBlock()->fill($address);
$checkoutCart->getShippingBlock()->clickGetQuote();
$checkoutCart->getShippingBlock()->selectShippingMethod($shipping);
$this->assert();
}
示例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));
}
示例5: processAssert
/**
* Assert that after applying changes, currency symbol changed on Product Details Page.
*
* @param CatalogProductSimple $product
* @param BrowserInterface $browser
* @param CmsIndex $cmsIndex
* @param CatalogProductView $catalogProductView
* @param CurrencySymbolEntity $currencySymbol
* @return void
*/
public function processAssert(CatalogProductSimple $product, BrowserInterface $browser, CmsIndex $cmsIndex, CatalogProductView $catalogProductView, CurrencySymbolEntity $currencySymbol)
{
$cmsIndex->open();
$cmsIndex->getCurrencyBlock()->switchCurrency($currencySymbol);
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
$price = $catalogProductView->getViewBlock()->getPriceBlock()->getPrice();
preg_match('`(.*?)\\d`', $price, $matches);
$symbolOnPage = isset($matches[1]) ? $matches[1] : null;
\PHPUnit_Framework_Assert::assertEquals($currencySymbol->getCustomCurrencySymbol(), $symbolOnPage, 'Wrong Currency Symbol is displayed on Product page.');
}
示例6: processAssert
/**
* Assert that product is not displayed in up-sell section.
*
* @param BrowserInterface $browser
* @param CatalogProductSimple $product
* @param CatalogProductView $catalogProductView
* @param InjectableFixture[]|null $promotedProducts
* @return void
*/
public function processAssert(BrowserInterface $browser, CatalogProductSimple $product, CatalogProductView $catalogProductView, array $promotedProducts = null)
{
if (!$promotedProducts) {
$promotedProducts = $product->hasData('up_sell_products') ? $product->getDataFieldConfig('up_sell_products')['source']->getProducts() : [];
}
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
foreach ($promotedProducts as $promotedProduct) {
\PHPUnit_Framework_Assert::assertFalse($catalogProductView->getUpsellBlock()->getProductItem($promotedProduct)->isVisible(), 'Product \'' . $promotedProduct->getName() . '\' is exist in up-sells products.');
}
}
示例7: processAssert
/**
* Assert that product rating is displayed on product review(frontend)
*
* @param CatalogProductView $catalogProductView
* @param BrowserInterface $browser
* @param CatalogProductSimple $product
* @param Review|null $review [optional]
* @param Rating|null $productRating [optional]
* @return void
*/
public function processAssert(CatalogProductView $catalogProductView, BrowserInterface $browser, CatalogProductSimple $product, Review $review = null, Rating $productRating = null)
{
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
$reviewSummaryBlock = $catalogProductView->getReviewSummary();
if ($reviewSummaryBlock->isVisible()) {
$reviewSummaryBlock->getAddReviewLink()->click();
}
$rating = $productRating ? $productRating : $review->getDataFieldConfig('ratings')['source']->getRatings()[0];
$reviewForm = $catalogProductView->getReviewFormBlock();
\PHPUnit_Framework_Assert::assertTrue($reviewForm->isVisibleRating($rating), 'Product rating "' . $rating->getRatingCode() . '" is not displayed.');
}
示例8: processAssert
/**
* Assert that product url in url rewrite grid.
*
* @param CatalogProductSimple $product
* @param CatalogProductSimple $initialProduct
* @param UrlRewriteIndex $urlRewriteIndex
* @return void
*/
public function processAssert(CatalogProductSimple $product, CatalogProductSimple $initialProduct, UrlRewriteIndex $urlRewriteIndex)
{
$urlRewriteIndex->open();
$category = $product->getDataFieldConfig('category_ids')['source']->getCategories()[0];
$targetPath = "catalog/product/view/id/{$initialProduct->getId()}/category/{$category->getId()}";
$url = strtolower($product->getCategoryIds()[0] . '/' . $product->getUrlKey());
$filter = ['request_path' => $url, 'target_path' => $targetPath];
\PHPUnit_Framework_Assert::assertTrue($urlRewriteIndex->getUrlRedirectGrid()->isRowVisible($filter, true, false), "URL Rewrite with request path '{$url}' is absent in grid.");
$categoryInitial = $initialProduct->getDataFieldConfig('category_ids')['source']->getCategories()[0];
$targetPath = "catalog/product/view/id/{$initialProduct->getId()}/category/{$categoryInitial->getId()}";
\PHPUnit_Framework_Assert::assertFalse($urlRewriteIndex->getUrlRedirectGrid()->isRowVisible(['target_path' => $targetPath], true, false), "URL Rewrite with target path '{$targetPath}' is present in grid.");
}
示例9: test
/**
* Create products in cart report entity
*
* @param Customer $customer
* @param CatalogProductSimple $product
* @param string $isGuest
* @param BrowserInterface $browser
* @return void
*/
public function test(Customer $customer, CatalogProductSimple $product, $isGuest, BrowserInterface $browser)
{
// Preconditions
$product->persist();
//Steps
$this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
$productUrl = $_ENV['app_frontend_url'] . $product->getUrlKey() . '.html';
$browser->open($productUrl);
$this->catalogProductView->getViewBlock()->addToCart($product);
if ($isGuest) {
$this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LogoutCustomerOnFrontendStep')->run();
$browser->open($productUrl);
$this->catalogProductView->getViewBlock()->addToCart($product);
}
}
示例10: processAssert
/**
* Assert that product is not displayed in cross-sell section.
*
* @param BrowserInterface $browser
* @param CatalogProductSimple $product
* @param CatalogProductView $catalogProductView
* @param CheckoutCart $checkoutCart
* @param InjectableFixture[]|null $promotedProducts
* @return void
*/
public function processAssert(BrowserInterface $browser, CatalogProductSimple $product, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, array $promotedProducts = null)
{
if (!$promotedProducts) {
$promotedProducts = $product->hasData('cross_sell_products') ? $product->getDataFieldConfig('cross_sell_products')['source']->getProducts() : [];
}
$checkoutCart->open();
$checkoutCart->getCartBlock()->clearShoppingCart();
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
$catalogProductView->getViewBlock()->addToCart($product);
$catalogProductView->getMessagesBlock()->waitSuccessMessage();
$checkoutCart->open();
foreach ($promotedProducts as $promotedProduct) {
\PHPUnit_Framework_Assert::assertFalse($checkoutCart->getCrosssellBlock()->getProductItem($promotedProduct)->isVisible(), 'Product \'' . $promotedProduct->getName() . '\' is exist in cross-sell section.');
}
}
示例11: processAssert
/**
* Assert that widget with type Recently Viewed Products is present on category page
*
* @param CmsIndex $cmsIndex
* @param AdminCache $adminCache
* @param CatalogCategoryView $catalogCategoryView
* @param BrowserInterface $browser
* @param CatalogProductSimple $productSimple
* @param Category $category
* @param Customer $customer
* @return void
*/
public function processAssert(CmsIndex $cmsIndex, AdminCache $adminCache, CatalogCategoryView $catalogCategoryView, BrowserInterface $browser, CatalogProductSimple $productSimple, Category $category, Customer $customer)
{
$this->browser = $browser;
$this->cmsIndex = $cmsIndex;
$this->catalogCategoryView = $catalogCategoryView;
// Flush cache
$adminCache->open();
$adminCache->getActionsBlock()->flushMagentoCache();
$adminCache->getMessagesBlock()->waitSuccessMessage();
// Log in customer
$customer->persist();
$this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
// Open products
$productSimple->persist();
$category->persist();
$this->browser->open($_ENV['app_frontend_url'] . $productSimple->getUrlKey() . '.html');
$this->checkRecentlyViewedBlockOnCategory($productSimple, $category);
}
示例12: test
/**
* Test Creation for CustomerReviewReportEntity
*
* @param Review $review
* @param Customer $customer
* @param $customerLogin
* @param CatalogProductSimple $product
* @param BrowserInterface $browser
* @return array
*
* @SuppressWarnings(PHPMD.ConstructorWithNameAsEnclosingClass)
*/
public function test(Review $review, Customer $customer, CatalogProductSimple $product, BrowserInterface $browser, $customerLogin)
{
// Preconditions
$product->persist();
$this->cmsIndex->open();
if ($customerLogin == 'Yes') {
$this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
}
// Steps
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
$this->pageCatalogProductView->getReviewSummary()->getAddReviewLink()->click();
$this->pageCatalogProductView->getReviewFormBlock()->fill($review);
$this->pageCatalogProductView->getReviewFormBlock()->submit();
return ['product' => $product];
}
示例13: test
/**
* Share wish list
*
* @param BrowserInterface $browser
* @param Customer $customer
* @param CatalogProductSimple $product
* @param array $sharingInfo
* @return void
*/
public function test(BrowserInterface $browser, Customer $customer, CatalogProductSimple $product, array $sharingInfo)
{
//Steps
$this->loginCustomer($customer);
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
$this->catalogProductView->getViewBlock()->clickAddToWishlist();
$this->wishlistIndex->getMessagesBlock()->waitSuccessMessage();
$this->wishlistIndex->getWishlistBlock()->clickShareWishList();
$this->cmsIndex->getCmsPageBlock()->waitPageInit();
$this->wishlistShare->getSharingInfoForm()->fillForm($sharingInfo);
$this->wishlistShare->getSharingInfoForm()->shareWishlist();
}
示例14: test
/**
* Test Creation for CustomerReviewReportEntity
*
* @param Review $review
* @param Customer $customer
* @param $customerLogin
* @param CatalogProductSimple $product
* @param BrowserInterface $browser
* @return array
*
* @SuppressWarnings(PHPMD.ConstructorWithNameAsEnclosingClass)
*/
public function test(Review $review, Customer $customer, CatalogProductSimple $product, BrowserInterface $browser, $customerLogin)
{
// Preconditions
$product->persist();
$this->cmsIndex->open();
if ($customerLogin == 'Yes') {
$this->cmsIndex->getLinksBlock()->openLink("Log In");
$this->customerAccountLogin->getLoginBlock()->login($customer);
}
// Steps
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
$this->pageCatalogProductView->getReviewSummary()->getAddReviewLink()->click();
$this->pageCatalogProductView->getReviewFormBlock()->fill($review);
$this->pageCatalogProductView->getReviewFormBlock()->submit();
return ['product' => $product];
}
示例15: test
/**
* Create products in cart report entity
*
* @param Customer $customer
* @param CatalogProductSimple $product
* @param string $isGuest
* @param BrowserInterface $browser
* @return void
*/
public function test(Customer $customer, CatalogProductSimple $product, $isGuest, BrowserInterface $browser)
{
// Preconditions
$product->persist();
//Steps
$this->cmsIndex->open()->getLinksBlock()->openLink("Log In");
$this->customerAccountLogin->getLoginBlock()->login($customer);
$productUrl = $_ENV['app_frontend_url'] . $product->getUrlKey() . '.html';
$browser->open($productUrl);
$this->catalogProductView->getViewBlock()->addToCart($product);
if ($isGuest) {
$this->customerAccountLogout->open();
$browser->open($productUrl);
$this->catalogProductView->getViewBlock()->addToCart($product);
}
}