Skip to content

Commit ea60046

Browse files
kalashnikau-uladzimirA-Komar
authored andcommitted
MAGNIMEX-283: static test update
1 parent 002ac9d commit ea60046

File tree

8 files changed

+58
-17
lines changed

8 files changed

+58
-17
lines changed

app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class AdvancedPricing extends \Magento\CatalogImportExport\Model\Export\Product
7373
];
7474

7575
/**
76-
* Template array for export data
76+
* Export template
7777
*
7878
* @var array
7979
*/

app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\Abstract
6262
ValidatorInterface::ERROR_GROUP_PRICE_DATA_INCOMPLETE => 'Group Price data is incomplete',
6363
];
6464

65+
/**
66+
* Need to log in import history
67+
*
68+
* @var bool
69+
*/
70+
protected $logInHistory = true;
71+
6572
/**
6673
* @var \Magento\CatalogImportExport\Model\Import\Proxy\Product\ResourceFactory
6774
*/

app/code/Magento/AdvancedPricingImportExport/composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"require": {
55
"php": "~5.5.0|~5.6.0",
66
"magento/module-catalog": "0.74.0-beta13",
7+
"magento/module-catalog-inventory": "0.74.0-beta13",
8+
"magento/module-eav": "0.74.0-beta13",
79
"magento/module-import-export": "0.74.0-beta13",
810
"magento/module-catalog-import-export": "0.74.0-beta13",
911
"magento/module-customer": "0.74.0-beta13",

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
182182
'_upsell_' => \Magento\Catalog\Model\Product\Link::LINK_TYPE_UPSELL,
183183
];
184184

185+
/**
186+
* Need to log in import history
187+
*
188+
* @var bool
189+
*/
190+
protected $logInHistory = true;
191+
185192
/**
186193
* Attribute id for product images storage.
187194
*

app/code/Magento/CatalogImportExport/Model/Import/Product/CategoryProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function upsertCategories($categoriesString)
164164
*
165165
* @param int $categoryId
166166
*
167-
* @return
167+
* @return \Magento\Catalog\Model\Category|null
168168
*/
169169
public function getCategoryById($categoryId)
170170
{

app/code/Magento/ImportExport/Model/Import.php

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,6 @@ class Import extends \Magento\ImportExport\Model\AbstractModel
140140
*/
141141
protected $_filesystem;
142142

143-
/**
144-
* Entity types supporting import history
145-
*
146-
* @var array
147-
*/
148-
protected $processedReportsEntities = [
149-
\Magento\Catalog\Model\Product::ENTITY,
150-
\Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing::ENTITY_TYPE_CODE
151-
];
152-
153143
/**
154144
* @param \Psr\Log\LoggerInterface $logger
155145
* @param \Magento\Framework\Filesystem $filesystem
@@ -684,11 +674,20 @@ public function getUniqueEntityBehaviors()
684674
public function isReportEntityType($entity = null)
685675
{
686676
$result = false;
687-
if (!$entity) {
688-
$entity = $this->getEntity();
689-
}
690-
if (in_array($entity, $this->processedReportsEntities)) {
691-
$result = true;
677+
if ($entity !== null && $this->_getEntityAdapter()->getEntityTypeCode() != $entity) {
678+
$entities = $this->_importConfig->getEntities();
679+
if (isset($entities[$this->getEntity()])) {
680+
try {
681+
$adapter = $this->_entityFactory->create($entities[$entity]['model']);
682+
$result = $adapter->isNeedToLogInHistory();
683+
} catch (\Exception $e) {
684+
throw new \Magento\Framework\Exception\LocalizedException(__('Please enter a correct entity model'));
685+
}
686+
} else {
687+
throw new \Magento\Framework\Exception\LocalizedException(__('Please enter a correct entity model'));
688+
}
689+
} else {
690+
$result = $this->_entityAdapter->isNeedToLogInHistory();
692691
}
693692
return $result;
694693
}

app/code/Magento/ImportExport/Model/Import/Entity/AbstractEntity.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,12 @@ abstract class AbstractEntity
224224
*/
225225
protected $countItemsDeleted = 0;
226226

227+
/**
228+
* Need to log in import history
229+
*
230+
* @var bool
231+
*/
232+
protected $logInHistory = false;
227233

228234
/**
229235
* @param \Magento\Framework\Json\Helper\Data $jsonHelper
@@ -680,6 +686,16 @@ public function isRowAllowedToImport(array $rowData, $rowNum)
680686
return $this->validateRow($rowData, $rowNum) && !isset($this->_rowsToSkip[$rowNum]);
681687
}
682688

689+
/*
690+
* Is import need to log in history.
691+
*
692+
* @return bool
693+
*/
694+
public function isNeedToLogInHistory()
695+
{
696+
return $this->logInHistory;
697+
}
698+
683699
/**
684700
* Validate data row.
685701
*

app/code/Magento/ImportExport/Test/Unit/Model/Import/Entity/AbstractTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,16 @@ public function testValidateDataAttributeNames()
127127
$this->_model->validateData();
128128
}
129129

130+
/**
131+
* Test for method isNeedToLogInHistory()
132+
*
133+
* @covers \Magento\ImportExport\Model\Import\Entity\AbstractEntity::isNeedToLogInHistory
134+
*/
135+
public function testIsNeedToLogInHistory()
136+
{
137+
$this->assertEquals(false, $this->_model->isNeedToLogInHistory());
138+
}
139+
130140
/**
131141
* Test for method isAttributeValid()
132142
*

0 commit comments

Comments
 (0)