本文整理汇总了PHP中Magento\Catalog\Test\Fixture\CatalogProductSimple::persist方法的典型用法代码示例。如果您正苦于以下问题:PHP CatalogProductSimple::persist方法的具体用法?PHP CatalogProductSimple::persist怎么用?PHP CatalogProductSimple::persist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Test\Fixture\CatalogProductSimple
的用法示例。
在下文中一共展示了CatalogProductSimple::persist方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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 CustomerAccountLogin $customerAccountLogin
* @param CustomerAccountLogout $customerAccountLogout
* @param CustomerInjectable $customer
* @param CatalogProductView $catalogProductView
* @param CheckoutCart $checkoutCart
* @param AddressInjectable $address
* @param array $shipping
* @param TaxRule $initialTaxRule
* @return void
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function processAssert(FixtureFactory $fixtureFactory, TaxRule $taxRule, CustomerAccountLogin $customerAccountLogin, CustomerAccountLogout $customerAccountLogout, CustomerInjectable $customer, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, AddressInjectable $address, array $shipping, 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' => '100_dollar_product_for_tax_rule', 'data' => ['tax_class_id' => ['tax_product_class' => $taxProductClass]]]);
$this->productSimple->persist();
// Customer login
$customerAccountLogout->open();
$customerAccountLogin->open();
$customerAccountLogin->getLoginBlock()->login($customer);
// Clearing shopping cart and adding product to shopping cart
$checkoutCart->open()->getCartBlock()->clearShoppingCart();
$catalogProductView->init($this->productSimple);
$catalogProductView->open();
$catalogProductView->getViewBlock()->clickAddToCart();
// Estimate Shipping and Tax
$checkoutCart->getShippingBlock()->openEstimateShippingAndTax();
$checkoutCart->getShippingBlock()->fill($address);
$checkoutCart->getShippingBlock()->clickGetQuote();
$checkoutCart->getShippingBlock()->selectShippingMethod($shipping);
$this->assert();
}
示例2: __inject
/**
* Injection data
*
* @param CatalogProductIndex $productGrid
* @param CatalogProductEdit $editProductPage
* @param CatalogCategory $category
* @param FixtureFactory $fixtureFactory
* @return array
*/
public function __inject(CatalogProductIndex $productGrid, CatalogProductEdit $editProductPage, CatalogCategory $category, FixtureFactory $fixtureFactory)
{
$this->product = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'default', 'data' => ['category_ids' => ['category' => $category]]]);
$this->product->persist();
$this->productGrid = $productGrid;
$this->editProductPage = $editProductPage;
}
示例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: 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();
}
示例5: 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();
}
}
示例6: testUpdateSitemap
/**
* Update Sitemap Entity
*
* @param Sitemap $sitemap
* @param CatalogProductSimple $product
* @param CatalogCategory $catalog
* @param CmsPage $cmsPage
* @return void
*/
public function testUpdateSitemap(Sitemap $sitemap, CatalogProductSimple $product, CatalogCategory $catalog, CmsPage $cmsPage)
{
// Preconditions
$sitemap->persist();
$product->persist();
$catalog->persist();
$cmsPage->persist();
$filter = ['sitemap_filename' => $sitemap->getSitemapFilename(), 'sitemap_path' => $sitemap->getSitemapPath(), 'sitemap_id' => $sitemap->getSitemapId()];
// Steps
$this->sitemapIndex->open()->getSitemapGrid()->search($filter);
$this->sitemapIndex->getSitemapGrid()->generate();
}
示例7: test
/**
* Run update product simple entity test
*
* @param CatalogProductSimple $initialProduct
* @param CatalogProductSimple $product
* @return array
*/
public function test(CatalogProductSimple $initialProduct, CatalogProductSimple $product)
{
// Preconditions
$initialProduct->persist();
$initialCategory = $initialProduct->hasData('category_ids') ? $initialProduct->getDataFieldConfig('category_ids')['source']->getCategories()[0] : null;
$category = $product->hasData('category_ids') && $product->getCategoryIds()[0] ? $product->getDataFieldConfig('category_ids')['source']->getCategories()[0] : $initialCategory;
// Steps
$filter = ['sku' => $initialProduct->getSku()];
$this->productGrid->open();
$this->productGrid->getProductGrid()->searchAndOpen($filter);
$this->editProductPage->getProductForm()->fill($product);
$this->editProductPage->getFormPageActions()->save();
return ['category' => $category];
}
示例8: test
/**
* Create product URL Rewrite.
*
* @param CatalogProductSimple $product
* @param UrlRewrite $urlRewrite
* @return void
*/
public function test(CatalogProductSimple $product, UrlRewrite $urlRewrite)
{
//Precondition
$product->persist();
$filter = ['id' => $product->getId()];
//Steps
$this->urlRewriteIndex->open();
$this->urlRewriteIndex->getPageActionsBlock()->addNew();
$this->urlRewriteEdit->getFormBlock()->fill($urlRewrite);
$this->urlRewriteEdit->getProductGridBlock()->searchAndOpen($filter);
$category = $product->hasData('category_ids') ? $product->getDataFieldConfig('category_ids')['source']->getCategories()[0] : null;
$this->urlRewriteEdit->getTreeBlock()->selectCategory($category);
$this->urlRewriteEdit->getFormBlock()->fill($urlRewrite);
$this->urlRewriteEdit->getPageMainActions()->save();
}
示例9: testUpdateProductAttribute
/**
* Run UpdateProductAttributeEntity test
*
* @param CatalogProductAttribute $productAttributeOriginal
* @param CatalogProductAttribute $attribute
* @param CatalogAttributeSet $attributeSet
* @param CatalogProductAttributeIndex $attributeIndex
* @param CatalogProductAttributeNew $attributeNew
* @param CatalogProductSimple $productSimple
* @return array
*/
public function testUpdateProductAttribute(CatalogProductAttribute $productAttributeOriginal, CatalogProductAttribute $attribute, CatalogAttributeSet $attributeSet, CatalogProductAttributeIndex $attributeIndex, CatalogProductAttributeNew $attributeNew, CatalogProductSimple $productSimple)
{
//Precondition
$attributeSet->persist();
$productAttributeOriginal->persist();
$filter = ['attribute_code' => $productAttributeOriginal->getAttributeCode()];
//Steps
$attributeIndex->open();
$attributeIndex->getGrid()->searchAndOpen($filter);
$attributeNew->getAttributeForm()->fill($attribute);
$attributeNew->getPageActions()->save();
$attribute = $this->prepareAttribute($attribute, $productAttributeOriginal);
$productSimple->persist();
return ['product' => $this->prepareProduct($productSimple, $attribute, $attributeSet)];
}
示例10: test
/**
* Run mass update product simple entity test.
*
* @param CatalogProductSimple $initialProduct
* @param CatalogProductSimple $product
* @param string $configData
* @return array
*/
public function test(CatalogProductSimple $initialProduct, CatalogProductSimple $product, $configData)
{
$this->configData = $configData;
// Preconditions
$initialProduct->persist();
$this->objectManager->create('Magento\\Config\\Test\\TestStep\\SetupConfigurationStep', ['configData' => $configData])->run();
// Steps
$this->productGrid->open();
$this->productGrid->getProductGrid()->updateAttributes([['sku' => $initialProduct->getSku()]]);
$this->attributeMassActionPage->getAttributesBlockForm()->fill($product);
$this->attributeMassActionPage->getFormPageActions()->save();
$data = array_merge($initialProduct->getData(), $product->getData());
$product = $this->objectManager->create('Magento\\Catalog\\Test\\Fixture\\CatalogProductSimple', ['data' => $data]);
return ['category' => $initialProduct->getDataFieldConfig('category_ids')['source']->getCategories()[0], 'product' => $product];
}
示例11: 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);
}
}
示例12: test
/**
* Run update product simple entity test.
*
* @param CatalogProductSimple $initialProduct
* @param CatalogProductSimple $product
* @param string $configData
* @return array
*/
public function test(CatalogProductSimple $initialProduct, CatalogProductSimple $product, $configData = '')
{
$this->configData = $configData;
// Preconditions
$initialProduct->persist();
$initialCategory = $initialProduct->hasData('category_ids') ? $initialProduct->getDataFieldConfig('category_ids')['source']->getCategories()[0] : null;
$category = $product->hasData('category_ids') && $product->getCategoryIds()[0] ? $product->getDataFieldConfig('category_ids')['source']->getCategories()[0] : $initialCategory;
$this->objectManager->create('Magento\\Config\\Test\\TestStep\\SetupConfigurationStep', ['configData' => $configData])->run();
// Steps
$filter = ['sku' => $initialProduct->getSku()];
$this->productGrid->open();
$this->productGrid->getProductGrid()->searchAndOpen($filter);
$this->editProductPage->getProductForm()->fill($product);
$this->editProductPage->getFormPageActions()->save();
return ['category' => $category];
}
示例13: 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);
}
示例14: processAssert
/**
* Assert that widget with type Recently Compared Products is present on Product Compare page
*
* @param CatalogProductCompare $catalogProductCompare
* @param CmsIndex $cmsIndex
* @param CatalogProductView $catalogProductView
* @param BrowserInterface $browser
* @param Widget $widget
* @param CatalogProductSimple $productSimple1
* @param CatalogProductSimple $productSimple2
* @param AdminCache $adminCache
* @var string
* @return void
*/
public function processAssert(CatalogProductCompare $catalogProductCompare, CmsIndex $cmsIndex, CatalogProductView $catalogProductView, BrowserInterface $browser, Widget $widget, CatalogProductSimple $productSimple1, CatalogProductSimple $productSimple2, AdminCache $adminCache)
{
// Flush cache
$adminCache->open();
$adminCache->getActionsBlock()->flushMagentoCache();
$adminCache->getMessagesBlock()->waitSuccessMessage();
$this->catalogProductCompare = $catalogProductCompare;
$this->catalogProductView = $catalogProductView;
$this->browser = $browser;
$this->cmsIndex = $cmsIndex;
$productSimple1->persist();
$products[] = $productSimple1;
$productSimple2->persist();
$products[] = $productSimple2;
$cmsIndex->open();
$this->addProducts($products);
$this->removeCompareProducts();
\PHPUnit_Framework_Assert::assertTrue($this->catalogProductCompare->getWidgetView()->isWidgetVisible($widget, 'Recently Compared'), 'Widget is absent on Product Compare page.');
}
示例15: test
/**
* Test product prices with tax.
*
* @param CatalogProductSimple $product
* @param string $configData
* @param SalesRule $salesRule [optional]
* @param CatalogRule $catalogRule [optional]
* @return void
*/
public function test(CatalogProductSimple $product, $configData, SalesRule $salesRule = null, CatalogRule $catalogRule = null)
{
//Preconditions
if ($salesRule !== null) {
$salesRule->persist();
$this->salesRule = $salesRule;
}
if ($catalogRule !== null) {
$catalogRule->persist();
$this->catalogRule = $catalogRule;
}
$this->objectManager->create('Magento\\Config\\Test\\TestStep\\SetupConfigurationStep', ['configData' => $configData])->run();
$product->persist();
}