RemoteProducts.php
1.91 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
<?php
namespace common\modules\product\models;
use Yii;
/**
* This is the model class for table "remote_products".
*
* @property string $Name
* @property string $Price
* @property string $Price_old
* @property string $ID_chief
* @property string $Article
* @property string $Brand
* @property string $ID
* @property string $Date_create
* @property integer $local_id
* @property ProductVariant $product
* @property RemoteCategories $remoteCategory
*/
class RemoteProducts extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'remote_products';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['Price', 'Price_old'], 'number'],
[['Date_create'], 'safe'],
[['Name'], 'string', 'max' => 100],
[['ID_chief', 'Article', 'ID'], 'string', 'max' => 20],
[['Brand'], 'string', 'max' => 25],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'Name' => Yii::t('product', 'Name'),
'Price' => Yii::t('product', 'Price'),
'Price_old' => Yii::t('product', 'Price Old'),
'ID_chief' => Yii::t('product', 'Id Chief'),
'Article' => Yii::t('product', 'Article'),
'Brand' => Yii::t('product', 'Brand'),
'ID' => Yii::t('product', 'ID'),
'Date_create' => Yii::t('product', 'Date Create'),
'local_id' => Yii::t('product', 'Local ID'),
];
}
public function getRemoteCategory() {
if (empty($this->ID_chief)) {
return null;
}
return RemoteCategories::findByID($this->ID_chief);
}
public function getProduct() {
if (empty($this->ID)) {
return null;
}
return ProductVariantSearch::findByRemoteID($this->ID);
}
}