|
...
|
...
|
@@ -377,9 +377,26 @@ class UpdateSeoTdk extends Command |
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$prefix = $this->getPrefixKeyword($project_id, 'prefix', 1, $v[$this->topic_fields[$table]]);
|
|
|
|
$suffix = $this->getPrefixKeyword($project_id, 'suffix', 2, $v[$this->topic_fields[$table]]);
|
|
|
|
$seo_title = $prefix . ' ' . $v[$this->topic_fields[$table]] . ' ' . $suffix;
|
|
|
|
$title = $v[$this->topic_fields[$table]];
|
|
|
|
|
|
|
|
$prefix = $this->getPrefixKeyword($project_id, 'prefix', 1, $title);
|
|
|
|
//in,for,with,to,near,from 这些介词 只拼前缀,不拼后缀
|
|
|
|
$suffix_ban = ['in ', 'for ', 'with ', 'to ', 'near ','from ', 'In ', 'For ', 'With ', 'To ', 'Near ','From '];
|
|
|
|
$suffix = '';
|
|
|
|
if(Str::contains($title, $suffix_ban)){
|
|
|
|
// 某些后缀不能并存的情况
|
|
|
|
$ban_suffix = [];
|
|
|
|
//services/service 结尾的词,后缀不拼manufacturer,factory
|
|
|
|
if (Str::endsWith($title, ['services', 'service', 'Services', 'Service'])) {
|
|
|
|
$ban_suffix = ['manufacturer', 'factory', 'Manufacturer', 'Factory', 'Factories', 'Manufacturers'];
|
|
|
|
}
|
|
|
|
//前缀有wholesale或cheap的词,后缀不拼 manufacturer,factory,exporter,company
|
|
|
|
if (Str::startsWith($title, ['wholesale', 'cheap', 'Wholesale', 'Cheap'])) {
|
|
|
|
$ban_suffix = array_merge($ban_suffix, ['manufacturer', 'factory', 'exporter', 'company', 'Manufacturer', 'Factory', 'Exporter', 'Company', 'Factories', 'Manufacturers', 'Exporters', 'Companies']);
|
|
|
|
}
|
|
|
|
$suffix = $this->getPrefixKeyword($project_id, 'suffix', 2, $title, $ban_suffix);
|
|
|
|
}
|
|
|
|
$seo_title = $prefix . ' ' . $title . ' ' . $suffix;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data[$field] = trim($seo_title);
|
|
...
|
...
|
@@ -548,7 +565,7 @@ class UpdateSeoTdk extends Command |
|
|
|
* @param $num
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getPrefixKeyword($project_id, $type, $num, $topic='')
|
|
|
|
public function getPrefixKeyword($project_id, $type, $num, $topic='', $ban_suffix = [])
|
|
|
|
{
|
|
|
|
$str = '';
|
|
|
|
$info = $this->getDeployOptimize($project_id);
|
|
...
|
...
|
@@ -579,7 +596,7 @@ class UpdateSeoTdk extends Command |
|
|
|
//随机取
|
|
|
|
shuffle($fix_keyword);
|
|
|
|
if (count($fix_keyword) < $num)
|
|
|
|
return $str;
|
|
|
|
return implode(", ", $fix_keyword);
|
|
|
|
$keyword = array_slice($fix_keyword, 0, $num);
|
|
|
|
$str = implode(", ", $keyword);
|
|
|
|
|
...
|
...
|
|