Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.3-develop' into 2.3-develop-mf…
Browse files Browse the repository at this point in the history
…tf-pr7
  • Loading branch information
zakdma committed Oct 16, 2018
2 parents f4a3583 + 515218f commit 1e501f2
Show file tree
Hide file tree
Showing 57 changed files with 457 additions and 217 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
use Magento\Search\Model\QueryInterface;
use Magento\AdvancedSearch\Model\SuggestedQueriesInterface;

/**
* Class DataProvider
*/
class DataProvider implements SuggestedQueriesInterface
{
/**
Expand Down Expand Up @@ -51,6 +54,8 @@ class DataProvider implements SuggestedQueriesInterface
private $recommendationsFactory;

/**
* DataProvider constructor.
*
* @param ScopeConfigInterface $scopeConfig
* @param \Magento\Catalog\Model\Layer\Resolver $layerResolver
* @param \Magento\AdvancedSearch\Model\ResourceModel\RecommendationsFactory $recommendationsFactory
Expand All @@ -69,18 +74,20 @@ public function __construct(
}

/**
* Is Results Count Enabled
*
* @return bool
*/
public function isResultsCountEnabled()
{
return (bool)$this->scopeConfig->getValue(
return $this->scopeConfig->isSetFlag(
self::CONFIG_RESULTS_COUNT_ENABLED,
ScopeInterface::SCOPE_STORE
);
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getItems(QueryInterface $query)
{
Expand All @@ -102,6 +109,8 @@ public function getItems(QueryInterface $query)
}

/**
* Return Search Recommendations
*
* @param QueryInterface $query
* @return array
*/
Expand All @@ -126,17 +135,21 @@ private function getSearchRecommendations(\Magento\Search\Model\QueryInterface $
}

/**
* Is Search Recommendations Enabled
*
* @return bool
*/
private function isSearchRecommendationsEnabled()
{
return (bool)$this->scopeConfig->getValue(
return $this->scopeConfig->isSetFlag(
self::CONFIG_IS_ENABLED,
ScopeInterface::SCOPE_STORE
);
}

/**
* Return Search Recommendations Count
*
* @return int
*/
private function getSearchRecommendationsCount()
Expand Down
16 changes: 7 additions & 9 deletions app/code/Magento/Catalog/Model/ImageUploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,9 @@ class ImageUploader
/**
* List of allowed image mime types
*
* @var array
* @var string[]
*/
private $allowedMimeTypes = [
'image/jpg',
'image/jpeg',
'image/gif',
'image/png',
];
private $allowedMimeTypes;

/**
* ImageUploader constructor
Expand All @@ -87,6 +82,7 @@ class ImageUploader
* @param string $baseTmpPath
* @param string $basePath
* @param string[] $allowedExtensions
* @param string[] $allowedMimeTypes
*/
public function __construct(
\Magento\MediaStorage\Helper\File\Storage\Database $coreFileStorageDatabase,
Expand All @@ -96,7 +92,8 @@ public function __construct(
\Psr\Log\LoggerInterface $logger,
$baseTmpPath,
$basePath,
$allowedExtensions
$allowedExtensions,
$allowedMimeTypes = []
) {
$this->coreFileStorageDatabase = $coreFileStorageDatabase;
$this->mediaDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA);
Expand All @@ -106,6 +103,7 @@ public function __construct(
$this->baseTmpPath = $baseTmpPath;
$this->basePath = $basePath;
$this->allowedExtensions = $allowedExtensions;
$this->allowedMimeTypes = $allowedMimeTypes;
}

/**
Expand Down Expand Up @@ -165,7 +163,7 @@ public function getBasePath()
}

/**
* Retrieve base path
* Retrieve allowed extensions
*
* @return string[]
*/
Expand Down
20 changes: 13 additions & 7 deletions app/code/Magento/Catalog/Model/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ public function getPrice()
* @see \Magento\Catalog\Model\Product\Visibility
*
* @return int
* @codeCoverageIgnoreStart
*/
public function getVisibility()
{
Expand Down Expand Up @@ -818,6 +819,9 @@ public function getStoreIds()
if (!$this->hasStoreIds()) {
$storeIds = [];
if ($websiteIds = $this->getWebsiteIds()) {
if ($this->_storeManager->isSingleStoreMode()) {
$websiteIds = array_keys($websiteIds);
}
foreach ($websiteIds as $websiteId) {
$websiteStores = $this->_storeManager->getWebsite($websiteId)->getStoreIds();
$storeIds = array_merge($storeIds, $websiteStores);
Expand Down Expand Up @@ -1049,7 +1053,8 @@ public function reindex()
*
* Register indexing event before delete product
*
* @return \Magento\Catalog\Model\Product
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function beforeDelete()
{
Expand Down Expand Up @@ -1723,8 +1728,6 @@ public function getIsSalable()
/**
* Check is a virtual product
*
* Data helper wrapper
*
* @return bool
*/
public function isVirtual()
Expand Down Expand Up @@ -2033,7 +2036,7 @@ public function getIsVirtual()
*
* @param string $code Option code
* @param mixed $value Value of the option
* @param int|Product $product Product ID
* @param int|Product|null $product Product ID
* @return $this
*/
public function addCustomOption($code, $value, $product = null)
Expand Down Expand Up @@ -2227,9 +2230,9 @@ public function getPreconfiguredValues()
}

/**
* Prepare product custom options.
* Prepare product custom options
*
* To be sure that all product custom options does not has ID and has product instance
* To be sure that all product custom options does not has ID and has product instance.
*
* @return \Magento\Catalog\Model\Product
*/
Expand Down Expand Up @@ -2586,10 +2589,11 @@ public function setExtensionAttributes(\Magento\Catalog\Api\Data\ProductExtensio
//@codeCoverageIgnoreEnd

/**
* Convert array to media gallery interface
* Convert Image to ProductAttributeMediaGalleryEntryInterface
*
* @param array $mediaGallery
* @return \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface[]
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function convertToMediaGalleryInterface(array $mediaGallery)
{
Expand All @@ -2608,6 +2612,7 @@ protected function convertToMediaGalleryInterface(array $mediaGallery)
* Returns media gallery entries
*
* @return \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface[]|null
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function getMediaGalleryEntries()
{
Expand All @@ -2625,6 +2630,7 @@ public function getMediaGalleryEntries()
*
* @param ProductAttributeMediaGalleryEntryInterface[] $mediaGalleryEntries
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function setMediaGalleryEntries(array $mediaGalleryEntries = null)
{
Expand Down
13 changes: 11 additions & 2 deletions app/code/Magento/Catalog/Test/Unit/Model/ImageUploaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,17 @@ class ImageUploaderTest extends \PHPUnit\Framework\TestCase
/**
* Allowed extensions
*
* @var string
* @var array
*/
private $allowedExtensions;

/**
* Allowed mime types
*
* @var array
*/
private $allowedMimeTypes;

protected function setUp()
{
$this->coreFileStorageDatabaseMock = $this->createMock(
Expand All @@ -97,6 +104,7 @@ protected function setUp()
$this->baseTmpPath = 'base/tmp/';
$this->basePath = 'base/real/';
$this->allowedExtensions = ['.jpg'];
$this->allowedMimeTypes = ['image/jpg', 'image/jpeg', 'image/gif', 'image/png'];

$this->imageUploader =
new \Magento\Catalog\Model\ImageUploader(
Expand All @@ -107,7 +115,8 @@ protected function setUp()
$this->loggerMock,
$this->baseTmpPath,
$this->basePath,
$this->allowedExtensions
$this->allowedExtensions,
$this->allowedMimeTypes
);
}

Expand Down
6 changes: 6 additions & 0 deletions app/code/Magento/Catalog/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@
<item name="gif" xsi:type="string">gif</item>
<item name="png" xsi:type="string">png</item>
</argument>
<argument name="allowedMimeTypes" xsi:type="array">
<item name="jpg" xsi:type="string">image/jpg</item>
<item name="jpeg" xsi:type="string">image/jpeg</item>
<item name="gif" xsi:type="string">image/gif</item>
<item name="png" xsi:type="string">image/png</item>
</argument>
</arguments>
</virtualType>
<type name="Magento\Catalog\Controller\Adminhtml\Category\Image\Upload">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
$label = $block->getChildData($alias, 'title');
?>
<div class="data item title"
aria-labeledby="tab-label-<?= /* @escapeNotVerified */ $alias ?>-title"
aria-labelledby="tab-label-<?= /* @escapeNotVerified */ $alias ?>-title"
data-role="collapsible" id="tab-label-<?= /* @escapeNotVerified */ $alias ?>">
<a class="data switch"
tabindex="-1"
Expand Down
Loading

0 comments on commit 1e501f2

Please sign in to comment.