Skip to content

Commit

Permalink
closes #1055 for magento 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloebiz committed Sep 11, 2020
1 parent bf88cdd commit 299ae78
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Model/Api/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function _sendProducts($magentoStoreId)
/**
* @var $product \Magento\Catalog\Model\Product
*/
$product = $this->_productRepository->getById($item->getId());
$product = $this->_productRepository->getById($item->getId(), false, $magentoStoreId);
if ($item->getMailchimpSyncModified() && $item->getMailchimpSyncDelta() &&
$item->getMailchimpSyncDelta() > $this->_helper->getMCMinSyncDateFlag()) {
$batchArray = array_merge($this->_buildOldProductRequest($product, $this->_batchId, $mailchimpStoreId, $magentoStoreId), $batchArray);
Expand Down Expand Up @@ -249,7 +249,7 @@ protected function _buildNewProductRequest(
$variantProducts[] = $product;
if (count($childProducts[0])) {
foreach ($childProducts[0] as $childId) {
$variantProducts[] = $this->_productRepository->getById($childId);
$variantProducts[] = $this->_productRepository->getById($childId, false, $magentoStoreId);
}
}
break;
Expand Down Expand Up @@ -337,7 +337,7 @@ protected function _buildOldProductRequest(
$variantProducts[] = $product;
if (count($childProducts[0])) {
foreach ($childProducts[0] as $childId) {
$variantProducts[] = $this->_productRepository->getById($childId);
$variantProducts[] = $this->_productRepository->getById($childId, false, $magentoStoreId);
}
}
} else {
Expand Down Expand Up @@ -382,7 +382,7 @@ protected function _buildProductData(
} elseif ($this->_parentImage) {
$data['image_url'] = $this->_parentImage;
} else {
$parent = $this->_getParent($product->getId());
$parent = $this->_getParent($product->getId(), $magentoStoreId);
if ($parent && $parent->getImage() && $parent->getImage()!='no_selection') {
$filePath = 'catalog/product'.$parent->getImage();
$data["image_url"] = $this->_helper->getBaserUrl($magentoStoreId, \Magento\Framework\UrlInterface::URL_TYPE_MEDIA).$filePath;
Expand All @@ -406,7 +406,7 @@ protected function _buildProductData(
$tailUrl = '';
$data["visibility"] = 'false';
if (!$parent) {
$parent = $this->_getParent($product->getId());
$parent = $this->_getParent($product->getId(), $magentoStoreId);
}
if ($parent) {
$options = $parent->getTypeInstance()->getConfigurableAttributesAsArray($parent);
Expand Down Expand Up @@ -483,12 +483,12 @@ protected function _buildProductData(
return $data;
}

protected function _getParent($productId)
protected function _getParent($productId, $magentoStoreId)
{
$parentIds =$this->_configurable->getParentIdsByChild($productId);
$parent = null;
foreach ($parentIds as $id) {
$parent = $this->_productRepository->getById($id);
$parent = $this->_productRepository->getById($id, false, $magentoStoreId);
if ($parent->getTypeId() == \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE) {
break;
} else {
Expand Down Expand Up @@ -534,7 +534,7 @@ public function sendModifiedProduct(\Magento\Sales\Model\Order $order, $mailchim
$items = $order->getAllVisibleItems();
foreach ($items as $item) {
//@todo get from the store not the default
$product = $this->_productRepository->getById($item->getProductId());
$product = $this->_productRepository->getById($item->getProductId(), false, $magentoStoreId);
$productSyncData = $this->_chimpSyncEcommerce->create()->getByStoreIdType(
$mailchimpStoreId,
$product->getId(),
Expand Down Expand Up @@ -571,7 +571,7 @@ public function sendQuoteModifiedProduct(\Magento\Quote\Model\Quote $quote, $mai
*/
foreach ($items as $item) {
//@todo get from the store not the default
$product = $this->_productRepository->getById($item->getProductId());
$product = $this->_productRepository->getById($item->getProductId(), false, $magentoStoreId);
$productSyncData = $this->_chimpSyncEcommerce->create()->getByStoreIdType(
$mailchimpStoreId,
$product->getId(),
Expand Down

0 comments on commit 299ae78

Please sign in to comment.