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


PHP Product::setParameters方法代碼示例

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


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

示例1: testImportDelete

 /**
  * @magentoAppArea adminhtml
  * @magentoDbIsolation enabled
  * @magentoAppIsolation enabled
  * @magentoDataFixture Magento/Catalog/_files/product_simple.php
  */
 public function testImportDelete()
 {
     $productRepository = $this->objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
     $index = 0;
     $ids = [];
     $origPricingData = [];
     while (isset($skus[$index])) {
         $ids[$index] = $productRepository->get($skus[$index])->getId();
         $origPricingData[$index] = $this->objectManager->create(\Magento\Catalog\Model\Product::class)->load($ids[$index])->getTierPrices();
         $index++;
     }
     $csvfile = uniqid('importexport_') . '.csv';
     /** @var \Magento\AdvancedPricingImportExport\Model\Export\AdvancedPricing $exportModel */
     $exportModel = $this->objectManager->create(\Magento\AdvancedPricingImportExport\Model\Export\AdvancedPricing::class);
     $exportModel->setWriter(\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\ImportExport\Model\Export\Adapter\Csv::class, ['fileSystem' => $this->fileSystem, 'destination' => $csvfile]));
     $this->assertNotEmpty($exportModel->export());
     $directory = $this->fileSystem->getDirectoryWrite(DirectoryList::VAR_DIR);
     $source = $this->objectManager->create(\Magento\ImportExport\Model\Import\Source\Csv::class, ['file' => $csvfile, 'directory' => $directory]);
     $errors = $this->model->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE, 'entity' => 'advanced_pricing'])->setSource($source)->validateData();
     $this->assertTrue($errors->getErrorsCount() == 0, 'Advanced Pricing import error, imported from file:' . $csvfile);
     $this->model->importData();
     while ($index > 0) {
         $index--;
         $newPricingData = $this->objectManager->create(\Magento\Catalog\Model\Product::class)->load($ids[$index])->getTierPrices();
         $this->assertEquals(0, count($newPricingData));
     }
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:33,代碼來源:AdvancedPricingTest.php

示例2: testValidateUrlKeysMultipleStores

 /**
  * @magentoDataFixture Magento/Store/_files/website.php
  * @magentoDataFixture Magento/Store/_files/core_fixturestore.php
  * @magentoDataFixture Magento/Catalog/Model/ResourceModel/_files/product_simple.php
  * @magentoAppIsolation enabled
  */
 public function testValidateUrlKeysMultipleStores()
 {
     $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\Filesystem');
     $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
     $source = $this->objectManager->create('\\Magento\\ImportExport\\Model\\Import\\Source\\Csv', ['file' => __DIR__ . '/_files/products_to_check_valid_url_keys_multiple_stores.csv', 'directory' => $directory]);
     $errors = $this->_model->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND, 'entity' => 'catalog_product'])->setSource($source)->validateData();
     $this->assertTrue($errors->getErrorsCount() == 0);
 }
開發者ID:dragonsword007008,項目名稱:magento2,代碼行數:14,代碼來源:ProductTest.php

示例3: testProductWithUseConfigSettings

 /**
  * @magentoAppIsolation enabled
  */
 public function testProductWithUseConfigSettings()
 {
     $products = ['simple1' => true, 'simple2' => true, 'simple3' => false];
     $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\Filesystem');
     $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
     $source = $this->objectManager->create('\\Magento\\ImportExport\\Model\\Import\\Source\\Csv', ['file' => __DIR__ . '/_files/products_to_import_with_use_config_settings.csv', 'directory' => $directory]);
     $errors = $this->_model->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND, 'entity' => 'catalog_product'])->setSource($source)->validateData();
     $this->assertTrue($errors->getErrorsCount() == 0);
     $this->_model->importData();
     foreach ($products as $sku => $manageStockUseConfig) {
         /** @var \Magento\CatalogInventory\Model\StockRegistry $stockRegistry */
         $stockRegistry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\CatalogInventory\\Model\\StockRegistry');
         $stockItem = $stockRegistry->getStockItemBySku($sku);
         $this->assertEquals($manageStockUseConfig, $stockItem->getUseConfigManageStock());
     }
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:19,代碼來源:ProductTest.php

示例4: testProductsWithMultipleStores

 /**
  * @magentoDataFixture Magento/Catalog/_files/categories.php
  * @magentoDataFixture Magento/Store/_files/core_fixturestore.php
  * @magentoDataFixture Magento/Catalog/Model/Layer/Filter/_files/attribute_with_option.php
  * @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_attribute.php
  * @magentoAppIsolation enabled
  */
 public function testProductsWithMultipleStores()
 {
     $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $filesystem = $objectManager->create('Magento\\Framework\\Filesystem');
     $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
     $source = new \Magento\ImportExport\Model\Import\Source\Csv(__DIR__ . '/_files/products_multiple_stores.csv', $directory);
     $this->_model->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND, 'entity' => 'catalog_product'])->setSource($source)->isDataValid();
     $this->_model->importData();
     /** @var \Magento\Catalog\Model\Product $product */
     $product = $objectManager->create('Magento\\Catalog\\Model\\Product');
     $id = $product->getIdBySku('Configurable 03');
     $product->load($id);
     $this->assertEquals('1', $product->getHasOptions());
     $objectManager->get('Magento\\Store\\Model\\StoreManagerInterface')->setCurrentStore('fixturestore');
     /** @var \Magento\Catalog\Model\Product $simpleProduct */
     $simpleProduct = $objectManager->create('Magento\\Catalog\\Model\\Product');
     $id = $simpleProduct->getIdBySku('Configurable 03-option_0');
     $simpleProduct->load($id);
     $this->assertEquals('Option Label', $simpleProduct->getAttributeText('attribute_with_option'));
 }
開發者ID:niranjanssiet,項目名稱:magento2,代碼行數:27,代碼來源:ProductTest.php


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