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;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Eav\Api\AttributeRepositoryInterface;
use Magento\Store\Model\Website;
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
/**
* Class SomeCommand
*/
......@@ -49,6 +50,8 @@ class GoogleFeed extends Command
private $attributeRepositoryInterface;
/* @var Website */
private $webSite;
/* @var Configurable */
private $configurable;
/*table title*/
private $columns = array(
'id',
......@@ -105,9 +108,9 @@ class GoogleFeed extends Command
];
private $pattern = [
'one piece',
'bikini',
'cover up'
'Only One Piece',
'Only Bikini',
'Only Cover Up'
];
/**
* @inheritDoc
......@@ -146,7 +149,8 @@ class GoogleFeed extends Command
CategoryList $categoryList,
ScopeConfigInterface $scopeConfigInterface,
AttributeRepositoryInterface $attributeRepositoryInterface,
Website $webSite
Website $webSite,
Configurable $configurable
)
{
$this->state = $state;
......@@ -162,6 +166,7 @@ class GoogleFeed extends Command
$this->scopeConfigInterface = $scopeConfigInterface;
$this->attributeRepositoryInterface = $attributeRepositoryInterface;
$this->webSite = $webSite;
$this->configurable = $configurable;
parent::__construct();
}
......@@ -271,8 +276,8 @@ class GoogleFeed extends Command
$data['google product category'] = $categoryGoogleProductCategory[$categoryId]['GoogleProductCategory'];
$data['product type'] = $categoryGoogleProductCategory[$categoryId]['product type'];
$data['link'] = $product->getProductUrl();
$data['mobile link'] = $product->getProductUrl();
$data['link'] = $this->getConfigProductUrl($product);
$data['mobile link'] = $data['link'];
$currentStore = $this->storeManager->getStore();
$mediaUrl = $currentStore->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
......@@ -350,4 +355,20 @@ class GoogleFeed extends Command
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