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


PHP Fixture\CatalogProductSimple類代碼示例

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


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

示例1: checkRecentlyViewedBlockOnCategory

 /**
  * Check that block Recently Viewed contains product on category page
  *
  * @param CatalogProductSimple $productSimple
  * @param Category $category
  * @return void
  */
 protected function checkRecentlyViewedBlockOnCategory(CatalogProductSimple $productSimple, Category $category)
 {
     $this->cmsIndex->open();
     $this->cmsIndex->getTopmenu()->selectCategoryByName($category->getName());
     $products = $this->catalogCategoryView->getViewBlock()->getProductsFromRecentlyViewedBlock();
     \PHPUnit_Framework_Assert::assertTrue(in_array($productSimple->getName(), $products), 'Product' . $productSimple->getName() . ' is absent on Recently Viewed block on Category page.');
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:14,代碼來源:AssertWidgetRecentlyViewedProducts.php

示例2: 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.');
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:16,代碼來源:AssertProductRatingNotInProductPage.php

示例3: processAssert

 /**
  * Assert that product is not displayed in up-sell section
  *
  * @param CatalogProductSimple $product1
  * @param CatalogProductSimple $product2
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param CatalogProductView $catalogProductView
  * @return void
  */
 public function processAssert(CatalogProductSimple $product1, CatalogProductSimple $product2, CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductView $catalogProductView)
 {
     $categoryName = $product1->getCategoryIds()[0]['name'];
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
     $catalogCategoryView->getListProductBlock()->openProductViewPage($product1->getName());
     \PHPUnit_Framework_Assert::assertFalse($catalogProductView->getUpsellBlock()->isUpsellProductVisible($product2->getName()), 'Product \'' . $product2->getName() . '\' is exist in up-sells products.');
 }
開發者ID:Atlis,項目名稱:docker-magento2,代碼行數:18,代碼來源:AssertNoUpSellsProductsSection.php

示例4: processAssert

 /**
  * Assert that product is displayed in related products section
  *
  * @param CatalogProductSimple $product1
  * @param CatalogProductSimple $product2
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param CatalogProductView $catalogProductView
  * @return void
  */
 public function processAssert(CatalogProductSimple $product1, CatalogProductSimple $product2, CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductView $catalogProductView)
 {
     $categoryName = $product1->getCategoryIds()[0];
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
     $catalogCategoryView->getListProductBlock()->openProductViewPage($product1->getName());
     \PHPUnit_Framework_Assert::assertTrue($catalogProductView->getRelatedProductBlock()->isRelatedProductVisible($product2->getName()), 'Product \'' . $product2->getName() . '\' is absent in related products.');
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:18,代碼來源:AssertRelatedProductsSection.php

示例5: 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

示例6: processAssert

 /**
  * Assert that product is displayed in cross-sell section
  *
  * @param CatalogProductSimple $product1
  * @param CatalogProductSimple $product2
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @return void
  */
 public function processAssert(CatalogProductSimple $product1, CatalogProductSimple $product2, CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart)
 {
     $categoryName = $product1->getCategoryIds()[0];
     $checkoutCart->open();
     $checkoutCart->getCartBlock()->clearShoppingCart();
     $cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
     $catalogCategoryView->getListProductBlock()->openProductViewPage($product1->getName());
     $catalogProductView->getViewBlock()->addToCart($product1);
     \PHPUnit_Framework_Assert::assertTrue($checkoutCart->getCrosssellBlock()->verifyProductCrosssell($product2), 'Product \'' . $product2->getName() . '\' is absent in cross-sell section.');
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:21,代碼來源:AssertCrossSellsProductsSection.php

示例7: isProductVisible

 /**
  * Check if ordered product is in grid
  *
  * @param CatalogProductSimple $product
  * @return bool
  */
 public function isProductVisible(CatalogProductSimple $product)
 {
     $filter = [$product->getName(), $product->getPrice(), $product->getCheckoutData()['qty']];
     $rows = [];
     foreach ($filter as $value) {
         $rows[] = sprintf($this->rowTemplate, $value);
     }
     $location = $this->location . '[' . implode(' and ', $rows) . ']';
     return $this->_rootElement->find($location, Locator::SELECTOR_XPATH)->isVisible();
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:16,代碼來源:Ordered.php

示例8: test

 /**
  * Create currency rate test.
  *
  * @param CurrencyRate $currencyRate
  * @param CatalogProductSimple $product
  * @param $config
  * @return void
  */
 public function test(CurrencyRate $currencyRate, CatalogProductSimple $product, ConfigData $config)
 {
     // Preconditions:
     $product->persist();
     $config->persist();
     // Steps:
     $this->currencyIndexPage->open();
     $this->currencyIndexPage->getCurrencyRateForm()->fill($currencyRate);
     $this->currencyIndexPage->getFormPageActions()->save();
 }
開發者ID:opexsw,項目名稱:magento2,代碼行數:18,代碼來源:CreateCurrencyRateTest.php

示例9: 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.');
     }
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:19,代碼來源:AssertProductAbsentUpSells.php

示例10: 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.');
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:20,代碼來源:AssertCurrencySymbolOnProductPage.php

示例11: 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.');
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:21,代碼來源:AssertProductRatingInProductPage.php

示例12: isProductVisible

 /**
  * Check that product visible in grid
  *
  * @param CatalogProductSimple $product
  * @param string $carts
  * @return bool
  */
 public function isProductVisible(CatalogProductSimple $product, $carts)
 {
     $result = false;
     $productRowSelector = sprintf($this->productRow, $product->getName());
     $productPrice = sprintf($this->productPrice, $product->getPrice());
     $productRow = $this->_rootElement->find($productRowSelector, Locator::SELECTOR_XPATH);
     if ($productRow->isVisible()) {
         $result = $productRow->find($productPrice, Locator::SELECTOR_XPATH)->isVisible() && $productRow->find(sprintf($this->productCarts, $carts), Locator::SELECTOR_XPATH)->isVisible();
     }
     return $result;
 }
開發者ID:buskamuza,項目名稱:magento2-skeleton,代碼行數:18,代碼來源:Grid.php

示例13: processAssert

 /**
  * Check whether the attribute is unique.
  *
  * @param CatalogProductIndex $catalogProductIndex
  * @param CatalogProductEdit $catalogProductEdit
  * @param CatalogProductAttribute $attribute
  * @param CatalogProductSimple $product,
  * @param FixtureFactory $fixtureFactory
  * @throws \Exception
  * @return void
  */
 public function processAssert(CatalogProductIndex $catalogProductIndex, CatalogProductEdit $catalogProductEdit, CatalogProductAttribute $attribute, CatalogProductSimple $product, FixtureFactory $fixtureFactory)
 {
     $simpleProduct = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'product_with_category_with_anchor', 'data' => ['attribute_set_id' => ['attribute_set' => $product->getDataFieldConfig('attribute_set_id')['source']->getAttributeSet()], 'custom_attribute' => $attribute]]);
     $catalogProductIndex->open()->getGridPageActionBlock()->addProduct('simple');
     $productForm = $catalogProductEdit->getProductForm();
     $productForm->fill($simpleProduct);
     $catalogProductEdit->getFormPageActions()->save();
     $failedAttributes = $productForm->getRequireNoticeAttributes($simpleProduct);
     $actualMessage = isset($failedAttributes['product-details'][$attribute->getFrontendLabel()]) ? $failedAttributes['product-details'][$attribute->getFrontendLabel()] : null;
     \PHPUnit_Framework_Assert::assertEquals(sprintf(self::UNIQUE_MESSAGE, $attribute->getFrontendLabel()), $actualMessage, 'JS error notice on product edit page is not equal to expected.');
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:22,代碼來源:AssertProductAttributeIsUnique.php

示例14: processAssert

 /**
  * Assert that after applying changes, currency symbol changed on Catalog page
  *
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param CatalogProductSimple $product
  * @param CurrencySymbolEntity $currencySymbol
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductSimple $product, CurrencySymbolEntity $currencySymbol)
 {
     $categoryName = $product->getCategoryIds()[0];
     $cmsIndex->open();
     $cmsIndex->getCurrencyBlock()->switchCurrency($currencySymbol);
     $cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
     $price = $catalogCategoryView->getListProductBlock()->getProductItem($product)->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 Category page.');
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:20,代碼來源:AssertCurrencySymbolOnCatalogPage.php

示例15: testApplySeveralSalesRules

 /**
  * Apply several sales rules.
  *
  * @param array $salesRules
  * @param CatalogProductSimple $productForSalesRule1
  * @param CatalogProductSimple $productForSalesRule2
  */
 public function testApplySeveralSalesRules(array $salesRules, CatalogProductSimple $productForSalesRule1, CatalogProductSimple $productForSalesRule2)
 {
     // Preconditions
     $productForSalesRule1->persist();
     $productForSalesRule2->persist();
     // Create sales rules
     foreach ($salesRules as $key => $dataSet) {
         $salesRule[$key] = $this->fixtureFactory->createByCode('salesRule', ['dataset' => $dataSet]);
         $salesRule[$key]->persist();
     }
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:18,代碼來源:ApplySeveralSalesRuleEntityTest.php


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