Skip to content

Commit ad9d867

Browse files
author
Stanislav Idolov
authored
ENGCOM-3078: [Forwardport] Fixes saving product in single-store mode if website_id <> 1 #18210
2 parents 56fe05b + 25616fe commit ad9d867

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

app/code/Magento/Catalog/Model/Product.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ public function getPrice()
591591
* @see \Magento\Catalog\Model\Product\Visibility
592592
*
593593
* @return int
594+
* @codeCoverageIgnoreStart
594595
*/
595596
public function getVisibility()
596597
{
@@ -813,6 +814,9 @@ public function getStoreIds()
813814
if (!$this->hasStoreIds()) {
814815
$storeIds = [];
815816
if ($websiteIds = $this->getWebsiteIds()) {
817+
if ($this->_storeManager->isSingleStoreMode()) {
818+
$websiteIds = array_keys($websiteIds);
819+
}
816820
foreach ($websiteIds as $websiteId) {
817821
$websiteStores = $this->_storeManager->getWebsite($websiteId)->getStoreIds();
818822
$storeIds = array_merge($storeIds, $websiteStores);
@@ -923,7 +927,7 @@ public function beforeSave()
923927
*
924928
* If value specified, it will be set.
925929
*
926-
* @param bool $value
930+
* @param bool|null $value
927931
* @return bool
928932
*/
929933
public function canAffectOptions($value = null)
@@ -1044,7 +1048,8 @@ public function reindex()
10441048
*
10451049
* Register indexing event before delete product
10461050
*
1047-
* @return \Magento\Catalog\Model\Product
1051+
* @return $this
1052+
* @throws \Magento\Framework\Exception\LocalizedException
10481053
*/
10491054
public function beforeDelete()
10501055
{
@@ -1718,8 +1723,6 @@ public function getIsSalable()
17181723
/**
17191724
* Check is a virtual product
17201725
*
1721-
* Data helper wrapper
1722-
*
17231726
* @return bool
17241727
*/
17251728
public function isVirtual()
@@ -2028,7 +2031,7 @@ public function getIsVirtual()
20282031
*
20292032
* @param string $code Option code
20302033
* @param mixed $value Value of the option
2031-
* @param int|Product $product Product ID
2034+
* @param int|Product|null $product Product ID
20322035
* @return $this
20332036
*/
20342037
public function addCustomOption($code, $value, $product = null)
@@ -2222,9 +2225,9 @@ public function getPreconfiguredValues()
22222225
}
22232226

22242227
/**
2225-
* Prepare product custom options.
2228+
* Prepare product custom options
22262229
*
2227-
* To be sure that all product custom options does not has ID and has product instance
2230+
* To be sure that all product custom options does not has ID and has product instance.
22282231
*
22292232
* @return \Magento\Catalog\Model\Product
22302233
*/
@@ -2581,10 +2584,11 @@ public function setExtensionAttributes(\Magento\Catalog\Api\Data\ProductExtensio
25812584
//@codeCoverageIgnoreEnd
25822585

25832586
/**
2584-
* Convert array to media gallery interface
2587+
* Convert Image to ProductAttributeMediaGalleryEntryInterface
25852588
*
25862589
* @param array $mediaGallery
25872590
* @return \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface[]
2591+
* @throws \Magento\Framework\Exception\LocalizedException
25882592
*/
25892593
protected function convertToMediaGalleryInterface(array $mediaGallery)
25902594
{
@@ -2603,6 +2607,7 @@ protected function convertToMediaGalleryInterface(array $mediaGallery)
26032607
* Returns media gallery entries
26042608
*
26052609
* @return \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface[]|null
2610+
* @throws \Magento\Framework\Exception\LocalizedException
26062611
*/
26072612
public function getMediaGalleryEntries()
26082613
{
@@ -2620,6 +2625,7 @@ public function getMediaGalleryEntries()
26202625
*
26212626
* @param ProductAttributeMediaGalleryEntryInterface[] $mediaGalleryEntries
26222627
* @return $this
2628+
* @throws \Magento\Framework\Exception\LocalizedException
26232629
*/
26242630
public function setMediaGalleryEntries(array $mediaGalleryEntries = null)
26252631
{

0 commit comments

Comments
 (0)