本文整理匯總了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());
}
示例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]);
}
}