SeoProduct.php
3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
namespace frontend\components;
use artbox\core\models\Alias;
use artbox\core\models\interfaces\AliasInterface;
use yii\base\Object;
class SeoProduct extends Object implements AliasInterface
{
/**
* @var int
*/
public $languageId;
/**
* @var string
*/
public $productTitle;
public $productPrice;
/**
* @var string
*/
public $tel = '(044) 490 70 07';
/**
* @var Alias
*/
public $productAlias;
/**
* @var string
*/
protected $title = '';
/**
* @var string
*/
protected $description = '';
/**
* @var string
*/
protected $h1 = '';
/**
* @var string
*/
protected $robots = '';
/**
* @var string
*/
protected $text = '';
public function init()
{
$this->generateData();
$this->generateRobots();
}
public function getFields(): string
{
return '';
}
public function getSeoText(): string
{
return $this->text ?? '';
}
public function getId()
{
return 0;
}
public function getTitle(): string
{
return $this->title ?? '';
}
public function getDesc(): string
{
return $this->description ?? '';
}
public function getH1(): string
{
return $this->h1 ?? '';
}
public function getText(): string
{
return $this->text ?? '';
}
public function getRobots(): string
{
return $this->robots ?? '';
}
private function selectH1()
{
if (!empty($this->productAlias->h1)) {
$this->h1 = $this->productAlias->h1;
} else {
$this->h1 = $this->productTitle;
}
}
protected function selectDescription() {
// if (!empty($this->productAlias->description)) {
// $this->description = $this->productAlias->description;
// } else {
$this->description = 'Купити '.$this->h1.' в інтернет-магазині ACDC | Тільки оригінал > Доступні ціни > Покупка в кредит > Швидка доставка по Україні';
// }
}
protected function selectTitle()
{
// if (!empty($this->productAlias->title)) { // у всех продуктов задан алиас, пришлось убрать кастомные алиасы,
// $this->title = $this->productAlias->title; // чтобы применить массовые
// } else {
$this->title = $this->h1.' купити в Україні: Київ, Харків, Одесса - ціна, фото, відгуки | інтернет-магазин ACDC';
// }
}
private function generateData()
{
$this->selectH1();
$this->selectTitle();
$this->selectDescription();
}
private function generateRobots()
{
if(!empty($this->productAlias->robots)) {
$this->robots = $this->productAlias->robots;
} else {
$this->robots = 'index, follow';
}
}
}