正在显示
1 个修改的文件
包含
21 行增加
和
9 行删除
| @@ -374,10 +374,14 @@ class UpdateSeoTdk extends Command | @@ -374,10 +374,14 @@ class UpdateSeoTdk extends Command | ||
| 374 | $seo_title = $v[$this->topic_fields[$table]];; | 374 | $seo_title = $v[$this->topic_fields[$table]];; |
| 375 | //只有推广项目 且未标记特殊前后缀 才加 前后缀 | 375 | //只有推广项目 且未标记特殊前后缀 才加 前后缀 |
| 376 | if($project->type == Project::TYPE_TWO && !in_array(8, explode(',', $project->deploy_optimize->special))) { | 376 | if($project->type == Project::TYPE_TWO && !in_array(8, explode(',', $project->deploy_optimize->special))) { |
| 377 | - $prefix = $this->getPrefixKeyword($project_id, 'prefix', 1, $project->main_lang_id, $seo_title); | ||
| 378 | - $suffix = $this->getPrefixKeyword($project_id, 'suffix', 2, $project->main_lang_id, $seo_title); | 377 | + $prefix = $this->getPrefixKeyword($project_id, 'prefix', 1, $seo_title); |
| 378 | + $suffix = $this->getPrefixKeyword($project_id, 'suffix', 2, $seo_title); | ||
| 379 | + if(Str::startsWith($suffix, ', ')){ | ||
| 380 | + $seo_title = $prefix . ' ' . $seo_title . $suffix; | ||
| 381 | + }else{ | ||
| 379 | $seo_title = $prefix . ' ' . $seo_title . ' ' . $suffix; | 382 | $seo_title = $prefix . ' ' . $seo_title . ' ' . $suffix; |
| 380 | } | 383 | } |
| 384 | + } | ||
| 381 | 385 | ||
| 382 | $data[$field] = trim($seo_title); | 386 | $data[$field] = trim($seo_title); |
| 383 | $update[$table]['title']++; | 387 | $update[$table]['title']++; |
| @@ -547,11 +551,10 @@ class UpdateSeoTdk extends Command | @@ -547,11 +551,10 @@ class UpdateSeoTdk extends Command | ||
| 547 | * @param $project_id | 551 | * @param $project_id |
| 548 | * @param $type | 552 | * @param $type |
| 549 | * @param $num | 553 | * @param $num |
| 550 | - * @param int $main_lang_id | ||
| 551 | * @param string $topic | 554 | * @param string $topic |
| 552 | * @return string | 555 | * @return string |
| 553 | */ | 556 | */ |
| 554 | - public function getPrefixKeyword($project_id, $type, $num, $main_lang_id = 0, $topic='') | 557 | + public function getPrefixKeyword($project_id, $type, $num, $topic='') |
| 555 | { | 558 | { |
| 556 | $str = ''; | 559 | $str = ''; |
| 557 | $ban = []; //被禁用的前后缀 | 560 | $ban = []; //被禁用的前后缀 |
| @@ -563,11 +566,8 @@ class UpdateSeoTdk extends Command | @@ -563,11 +566,8 @@ class UpdateSeoTdk extends Command | ||
| 563 | return $str; | 566 | return $str; |
| 564 | } | 567 | } |
| 565 | 568 | ||
| 566 | - //前后缀(小语种包括自定义前后缀)如果已经存在,就不在拼接当前类型 后缀只包含了一个,要再拼一个(需去重) | ||
| 567 | - $all_prefixes = $this->getAllPrefix($type == 'prefix' ? 1 : 2, $main_lang_id == 1 ? 0 : $project_id); | ||
| 568 | - //加上选中的自定义前后缀 | ||
| 569 | - $all_prefixes = array_merge($all_prefixes, explode(",", $info['keyword_' . $type])); | ||
| 570 | - $all_prefixes = array_filter($all_prefixes); | 569 | + //前后缀(包括自定义前后缀)如果已经存在,就不在拼接当前类型 后缀只包含了一个,要再拼一个(需去重) |
| 570 | + $all_prefixes = $this->getAllPrefix($type == 'prefix' ? 1 : 2, $project_id); | ||
| 571 | $all_prefixes = array_map('strtolower', $all_prefixes); | 571 | $all_prefixes = array_map('strtolower', $all_prefixes); |
| 572 | 572 | ||
| 573 | //in,for,with,to,near,from 这些介词 只拼前缀,不拼后缀 | 573 | //in,for,with,to,near,from 这些介词 只拼前缀,不拼后缀 |
| @@ -598,10 +598,19 @@ class UpdateSeoTdk extends Command | @@ -598,10 +598,19 @@ class UpdateSeoTdk extends Command | ||
| 598 | if (Str::endsWith(strtolower($topic), ['services', 'service']) && $type == 'suffix') { | 598 | if (Str::endsWith(strtolower($topic), ['services', 'service']) && $type == 'suffix') { |
| 599 | $ban = array_merge($ban, ['manufacturer', 'manufacturers', 'factory', 'factories']); | 599 | $ban = array_merge($ban, ['manufacturer', 'manufacturers', 'factory', 'factories']); |
| 600 | } | 600 | } |
| 601 | + //manufacturer,factory 结尾的词,后缀不拼 services/service | ||
| 602 | + if (Str::endsWith(strtolower($topic), ['manufacturer', 'manufacturers', 'factory', 'factories']) && $type == 'suffix') { | ||
| 603 | + $ban = array_merge($ban, ['services', 'service']); | ||
| 604 | + } | ||
| 605 | + | ||
| 601 | //前缀有wholesale或cheap的词,后缀不拼 manufacturer,factory,exporter,company | 606 | //前缀有wholesale或cheap的词,后缀不拼 manufacturer,factory,exporter,company |
| 602 | if (Str::startsWith(strtolower($topic), ['wholesale', 'cheap']) && $type == 'prefix') { | 607 | if (Str::startsWith(strtolower($topic), ['wholesale', 'cheap']) && $type == 'prefix') { |
| 603 | $ban = array_merge($ban, ['manufacturer', 'manufacturers', 'factory', 'factories', 'exporter', 'exporters', 'company', 'companies', 'supplier', 'suppliers']); | 608 | $ban = array_merge($ban, ['manufacturer', 'manufacturers', 'factory', 'factories', 'exporter', 'exporters', 'company', 'companies', 'supplier', 'suppliers']); |
| 604 | } | 609 | } |
| 610 | + //关键词以manufacturer,factory,exporter,company结尾, 前缀不拼wholesale或cheap的词 | ||
| 611 | + if (Str::endsWith(strtolower($topic), ['manufacturer', 'manufacturers', 'factory', 'factories', 'exporter', 'exporters', 'company', 'companies', 'supplier', 'suppliers']) && $type == 'prefix') { | ||
| 612 | + $ban = array_merge($ban, ['wholesale', 'cheap']); | ||
| 613 | + } | ||
| 605 | 614 | ||
| 606 | //关键词是否包含 品牌词 | 615 | //关键词是否包含 品牌词 |
| 607 | $brand_keywords = explode("\r\n", $info['brand_keyword']); | 616 | $brand_keywords = explode("\r\n", $info['brand_keyword']); |
| @@ -651,6 +660,9 @@ class UpdateSeoTdk extends Command | @@ -651,6 +660,9 @@ class UpdateSeoTdk extends Command | ||
| 651 | $keywords[] = $v; | 660 | $keywords[] = $v; |
| 652 | $num--; | 661 | $num--; |
| 653 | } | 662 | } |
| 663 | + if ($type == 'suffix' && count($keywords) == 1 && in_array(Arr::last($topic_words), $all_prefixes)) { | ||
| 664 | + return ', ' . $keywords[0]; | ||
| 665 | + } | ||
| 654 | return implode(', ', $keywords); | 666 | return implode(', ', $keywords); |
| 655 | } | 667 | } |
| 656 | 668 |
-
请 注册 或 登录 后发表评论