Commit 1ac9ccfe by dhn

Merge branch 'developer' of http://47.99.244.21:9999/root/joshine into Branch_developer

parents 1eaa7415 4f990143
...@@ -20,6 +20,7 @@ use Magento\Catalog\Model\CategoryList; ...@@ -20,6 +20,7 @@ use Magento\Catalog\Model\CategoryList;
use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Eav\Api\AttributeRepositoryInterface; use Magento\Eav\Api\AttributeRepositoryInterface;
use Magento\Store\Model\Website; use Magento\Store\Model\Website;
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
/** /**
* Class SomeCommand * Class SomeCommand
*/ */
...@@ -49,6 +50,8 @@ class GoogleFeed extends Command ...@@ -49,6 +50,8 @@ class GoogleFeed extends Command
private $attributeRepositoryInterface; private $attributeRepositoryInterface;
/* @var Website */ /* @var Website */
private $webSite; private $webSite;
/* @var Configurable */
private $configurable;
/*table title*/ /*table title*/
private $columns = array( private $columns = array(
'id', 'id',
...@@ -105,9 +108,9 @@ class GoogleFeed extends Command ...@@ -105,9 +108,9 @@ class GoogleFeed extends Command
]; ];
private $pattern = [ private $pattern = [
'one piece', 'Only One Piece',
'bikini', 'Only Bikini',
'cover up' 'Only Cover Up'
]; ];
/** /**
* @inheritDoc * @inheritDoc
...@@ -146,7 +149,8 @@ class GoogleFeed extends Command ...@@ -146,7 +149,8 @@ class GoogleFeed extends Command
CategoryList $categoryList, CategoryList $categoryList,
ScopeConfigInterface $scopeConfigInterface, ScopeConfigInterface $scopeConfigInterface,
AttributeRepositoryInterface $attributeRepositoryInterface, AttributeRepositoryInterface $attributeRepositoryInterface,
Website $webSite Website $webSite,
Configurable $configurable
) )
{ {
$this->state = $state; $this->state = $state;
...@@ -162,6 +166,7 @@ class GoogleFeed extends Command ...@@ -162,6 +166,7 @@ class GoogleFeed extends Command
$this->scopeConfigInterface = $scopeConfigInterface; $this->scopeConfigInterface = $scopeConfigInterface;
$this->attributeRepositoryInterface = $attributeRepositoryInterface; $this->attributeRepositoryInterface = $attributeRepositoryInterface;
$this->webSite = $webSite; $this->webSite = $webSite;
$this->configurable = $configurable;
parent::__construct(); parent::__construct();
} }
...@@ -271,8 +276,8 @@ class GoogleFeed extends Command ...@@ -271,8 +276,8 @@ class GoogleFeed extends Command
$data['google product category'] = $categoryGoogleProductCategory[$categoryId]['GoogleProductCategory']; $data['google product category'] = $categoryGoogleProductCategory[$categoryId]['GoogleProductCategory'];
$data['product type'] = $categoryGoogleProductCategory[$categoryId]['product type']; $data['product type'] = $categoryGoogleProductCategory[$categoryId]['product type'];
$data['link'] = $product->getProductUrl(); $data['link'] = $this->getConfigProductUrl($product);
$data['mobile link'] = $product->getProductUrl(); $data['mobile link'] = $data['link'];
$currentStore = $this->storeManager->getStore(); $currentStore = $this->storeManager->getStore();
$mediaUrl = $currentStore->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA); $mediaUrl = $currentStore->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
...@@ -350,4 +355,20 @@ class GoogleFeed extends Command ...@@ -350,4 +355,20 @@ class GoogleFeed extends Command
return $name; return $name;
} }
public function getConfigProductUrl($product){
$configProductIds = $this->configurable->getParentIdsByChild($product->getId());
if (!$configProductIds){
return $product->getProductUrl();
}
if(is_array($configProductIds) && !empty($configProductIds)){
$configProductId = $configProductIds[0];
}
if(is_int($configProductIds)){
$configProductId = $configProductIds;
}
$configurablProduct =$this->productRepository->getById($configProductId, false, $product->getStoreId());
$url = $configurablProduct->getUrlModel()->getUrl($configurablProduct);
return $url;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment