|
@@ -335,8 +335,8 @@ class UpdateSeoTdk extends Command |
|
@@ -335,8 +335,8 @@ class UpdateSeoTdk extends Command |
|
335
|
}
|
335
|
}
|
|
336
|
else if ($table == 'gl_product_keyword' && $field == 'seo_title') {
|
336
|
else if ($table == 'gl_product_keyword' && $field == 'seo_title') {
|
|
337
|
# TODO 聚合页seo title 特殊处理 前缀_1 . 关键词 . 后缀_2
|
337
|
# TODO 聚合页seo title 特殊处理 前缀_1 . 关键词 . 后缀_2
|
|
338
|
- $prefix = $this->getPrefixKeyword($project_id, 'prefix', 1);
|
|
|
|
339
|
- $suffix = $this->getPrefixKeyword($project_id, 'suffix', 2);
|
338
|
+ $prefix = $this->getPrefixKeyword($project_id, 'prefix', 1, $v[$this->topic_fields[$table]]);
|
|
|
|
339
|
+ $suffix = $this->getPrefixKeyword($project_id, 'suffix', 2, $v[$this->topic_fields[$table]]);
|
|
340
|
if (empty($prefix) || empty($suffix))
|
340
|
if (empty($prefix) || empty($suffix))
|
|
341
|
continue;
|
341
|
continue;
|
|
342
|
$seo_title = $prefix . ' ' . $v[$this->topic_fields[$table]] . ' ' . $suffix;
|
342
|
$seo_title = $prefix . ' ' . $v[$this->topic_fields[$table]] . ' ' . $suffix;
|
|
@@ -499,12 +499,31 @@ class UpdateSeoTdk extends Command |
|
@@ -499,12 +499,31 @@ class UpdateSeoTdk extends Command |
|
499
|
* @param $num
|
499
|
* @param $num
|
|
500
|
* @return string
|
500
|
* @return string
|
|
501
|
*/
|
501
|
*/
|
|
502
|
- public function getPrefixKeyword($project_id, $type, $num)
|
502
|
+ public function getPrefixKeyword($project_id, $type, $num, $topic='')
|
|
503
|
{
|
503
|
{
|
|
504
|
$str = '';
|
504
|
$str = '';
|
|
505
|
$info = $this->getDeployOptimize($project_id);
|
505
|
$info = $this->getDeployOptimize($project_id);
|
|
506
|
if (!empty($info['keyword_' . $type])) {
|
506
|
if (!empty($info['keyword_' . $type])) {
|
|
507
|
$fix_keyword = explode(",", $info['keyword_' . $type]);
|
507
|
$fix_keyword = explode(",", $info['keyword_' . $type]);
|
|
|
|
508
|
+
|
|
|
|
509
|
+ //去掉标题存在的词
|
|
|
|
510
|
+ if ($topic) {
|
|
|
|
511
|
+ foreach ($fix_keyword as $k=>$keyword) {
|
|
|
|
512
|
+ //处理单词复数 s es ies ves
|
|
|
|
513
|
+ $keyword = rtrim($keyword, 'ves');
|
|
|
|
514
|
+ $keyword = rtrim($keyword, 'ies');
|
|
|
|
515
|
+ $keyword = rtrim($keyword, 'es');
|
|
|
|
516
|
+ $keyword = rtrim($keyword, 's');
|
|
|
|
517
|
+
|
|
|
|
518
|
+ $topic_words = explode(" ", $topic);
|
|
|
|
519
|
+ if($type == 'prefix' && Str::startsWith($topic_words[0], $keyword)){
|
|
|
|
520
|
+ unset($fix_keyword[$k]);
|
|
|
|
521
|
+ }
|
|
|
|
522
|
+ if($type == 'suffix' && Str::startsWith($topic_words[count($topic_words)-1], $keyword)){
|
|
|
|
523
|
+ unset($fix_keyword[$k]);
|
|
|
|
524
|
+ }
|
|
|
|
525
|
+ }
|
|
|
|
526
|
+ }
|
|
508
|
//随机取
|
527
|
//随机取
|
|
509
|
shuffle($fix_keyword);
|
528
|
shuffle($fix_keyword);
|
|
510
|
if (count($fix_keyword) < $num)
|
529
|
if (count($fix_keyword) < $num)
|