|
...
|
...
|
@@ -335,8 +335,8 @@ class UpdateSeoTdk extends Command |
|
|
|
}
|
|
|
|
else if ($table == 'gl_product_keyword' && $field == 'seo_title') {
|
|
|
|
# TODO 聚合页seo title 特殊处理 前缀_1 . 关键词 . 后缀_2
|
|
|
|
$prefix = $this->getPrefixKeyword($project_id, 'prefix', 1);
|
|
|
|
$suffix = $this->getPrefixKeyword($project_id, 'suffix', 2);
|
|
|
|
$prefix = $this->getPrefixKeyword($project_id, 'prefix', 1, $v[$this->topic_fields[$table]]);
|
|
|
|
$suffix = $this->getPrefixKeyword($project_id, 'suffix', 2, $v[$this->topic_fields[$table]]);
|
|
|
|
if (empty($prefix) || empty($suffix))
|
|
|
|
continue;
|
|
|
|
$seo_title = $prefix . ' ' . $v[$this->topic_fields[$table]] . ' ' . $suffix;
|
|
...
|
...
|
@@ -499,12 +499,31 @@ class UpdateSeoTdk extends Command |
|
|
|
* @param $num
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getPrefixKeyword($project_id, $type, $num)
|
|
|
|
public function getPrefixKeyword($project_id, $type, $num, $topic='')
|
|
|
|
{
|
|
|
|
$str = '';
|
|
|
|
$info = $this->getDeployOptimize($project_id);
|
|
|
|
if (!empty($info['keyword_' . $type])) {
|
|
|
|
$fix_keyword = explode(",", $info['keyword_' . $type]);
|
|
|
|
|
|
|
|
//去掉标题存在的词
|
|
|
|
if ($topic) {
|
|
|
|
foreach ($fix_keyword as $k=>$keyword) {
|
|
|
|
//处理单词复数 s es ies ves
|
|
|
|
$keyword = rtrim($keyword, 'ves');
|
|
|
|
$keyword = rtrim($keyword, 'ies');
|
|
|
|
$keyword = rtrim($keyword, 'es');
|
|
|
|
$keyword = rtrim($keyword, 's');
|
|
|
|
|
|
|
|
$topic_words = explode(" ", $topic);
|
|
|
|
if($type == 'prefix' && Str::startsWith($topic_words[0], $keyword)){
|
|
|
|
unset($fix_keyword[$k]);
|
|
|
|
}
|
|
|
|
if($type == 'suffix' && Str::startsWith($topic_words[count($topic_words)-1], $keyword)){
|
|
|
|
unset($fix_keyword[$k]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//随机取
|
|
|
|
shuffle($fix_keyword);
|
|
|
|
if (count($fix_keyword) < $num)
|
...
|
...
|
|