Commit 515794e8 by liumengfei

Merge branch 'developer' into production

parents 11fcf67d 4f3ff447
......@@ -3,6 +3,7 @@
namespace Joshine\GoogleFeed\Console\Command;
use Magento\Framework\App\State;
use Magento\Setup\Exception;
use Magento\Store\Model\Store;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
......@@ -233,6 +234,11 @@ class GoogleFeed extends Command
$productRows['header'] = $this->generateRow($this->columns);
foreach ($products as $key => $product) {
//去除没有主产品的子产品
$configProductIds = $this->configurable->getParentIdsByChild($product->getId());
if (empty($configProductIds)){
continue;
}
$_product = $this->productRepository->getById($product->getId());
$data = $this->generateProductData($_product,$categoryGoogleProductCategory);
if (count($data) > 0) {
......@@ -284,7 +290,14 @@ class GoogleFeed extends Command
$data['id'] = $product->getSku();
$data['title'] = $this->getStoreName() .' '. str_replace('"', '\'', $product->getName());
$data['description'] = strip_tags(str_replace('"', '\'', $product->getDescription()));
//获取主产品描述信息
if (empty($data['description'])){
var_dump($product->getSku());
$desc = $this->getConfigProductDescription($product);
if (!empty($desc)){
$data['description'] = strip_tags(str_replace('"', '\'', $desc));
}
}
foreach( $product->getCategoryIds() as $k=>$v){
if (isset($categoryGoogleProductCategory[$v])){
......@@ -375,6 +388,29 @@ class GoogleFeed extends Command
return $name;
}
public function getConfigProductDescription($product){
$configProductIds = $this->configurable->getParentIdsByChild($product->getId());
if (!$configProductIds){
return "";
}
if(is_array($configProductIds) && !empty($configProductIds)){
$configProductId = $configProductIds[0];
}
if(is_int($configProductIds)){
$configProductId = $configProductIds;
}
$configurablProduct =$this->productRepository->getById($configProductId, false, $product->getStoreId());
try {
$desc = $configurablProduct->getCustomAttribute("description");
}catch (Exception $e){
$desc = false;
}
if ($desc){
return $desc->getValue();
}
return "";
}
public function getConfigProductUrl($product){
$configProductIds = $this->configurable->getParentIdsByChild($product->getId());
if (!$configProductIds){
......
......@@ -299,11 +299,6 @@ fieldset[disabled] a.joshine-btn {
-webkit-overflow-scrolling: touch;
outline: 0;
}
.j-modal .j-modal-dialog {
position: relative;
width: 530px;
margin: 7rem auto;
}
.j-modal .j-modal-content {
position: relative;
padding: 40px 50px 30px;
......@@ -321,6 +316,8 @@ fieldset[disabled] a.joshine-btn {
}
.joshine-model-warp .j-modal .j-modal-dialog {
width: 1050px;
position: relative;
margin: 7rem auto;
}
.joshine-close {
position: absolute;
......@@ -336,7 +333,11 @@ fieldset[disabled] a.joshine-btn {
position: relative;
line-height: 1.2;
}
.joshine-model-warp .j-modal.j-modal-vertical {
justify-content: center;
align-items: center;
display: flex;
}
.swiper-button-prev {
height: 100%;
......@@ -360,11 +361,4 @@ fieldset[disabled] a.joshine-btn {
left: auto;
z-index: 12;
cursor: url('@{baseDir}images/favicon-next.ico'), auto;
}
}
\ No newline at end of file
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