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


PHP Product::getErrorMessages方法代碼示例

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


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

示例1: testProductWithInvalidWeight

 /**
  * @magentoDbIsolation enabled
  */
 public function testProductWithInvalidWeight()
 {
     // import data from CSV file
     $pathToFile = __DIR__ . '/_files/product_to_import_invalid_weight.csv';
     $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\Filesystem');
     $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
     $source = new \Magento\ImportExport\Model\Import\Source\Csv($pathToFile, $directory);
     $validationResult = $this->_model->setSource($source)->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND])->isDataValid();
     $expectedErrors = ["Product weight is invalid" => [2]];
     $this->assertFalse($validationResult);
     $this->assertEquals($expectedErrors, $this->_model->getErrorMessages());
 }
開發者ID:niranjanssiet,項目名稱:magento2,代碼行數:15,代碼來源:ProductTest.php

示例2: testValidateInvalidMultiselectValues

 /**
  * @magentoDataFixture Magento/Catalog/_files/products_with_multiselect_attribute.php
  */
 public function testValidateInvalidMultiselectValues()
 {
     // import data from CSV file
     $pathToFile = __DIR__ . '/_files/products_with_invalid_multiselect_values.csv';
     $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\App\\Filesystem');
     $directory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::ROOT_DIR);
     $source = new \Magento\ImportExport\Model\Import\Source\Csv($pathToFile, $directory);
     $validationResult = $this->_model->setSource($source)->setParameters(array('behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND))->isDataValid();
     $this->assertFalse($validationResult);
     $errors = $this->_model->getErrorMessages();
     $expectedErrors = array("Please correct the value for 'multiselect_attribute'." => [2], "Orphan rows that will be skipped due default row errors" => [3, 4]);
     foreach ($expectedErrors as $message => $invalidRows) {
         $this->assertArrayHasKey($message, $errors);
         $this->assertEquals($invalidRows, $errors[$message]);
     }
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:19,代碼來源:ProductTest.php


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