Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit f971ac6

Browse files
authored
Merge pull request #8 from ggrachdev/dev
0.0.4
2 parents b877c17 + 94ae0af commit f971ac6

File tree

7 files changed

+291
-168
lines changed

7 files changed

+291
-168
lines changed

ggrachdev.multiregionality/classes/general/Multiregionality/Configurator/RegionsConfigurator.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public function getCodePropertyFormName5(): string {
4949
public function getCodePropertyFormName6(): string {
5050
return 'NAME_FORM_6';
5151
}
52+
53+
public function getCodePropertyLocations(): string {
54+
return 'IDS_LOCATIONS';
55+
}
5256

5357
public function getCodePropertyIsDefaultRegion(): string {
5458
return 'IS_DEFAULT_REGION';
@@ -58,4 +62,8 @@ public function __toString(): string {
5862
return 'standart_configurator';
5963
}
6064

65+
public function getCodePropertyTypesPrice(): string {
66+
return 'TYPES_PRICE';
67+
}
68+
6169
}

ggrachdev.multiregionality/classes/general/Multiregionality/Contract/IConfigurator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,8 @@ public function getCodePropertyFormName4(): string;
2828
public function getCodePropertyFormName5(): string;
2929

3030
public function getCodePropertyFormName6(): string;
31+
32+
public function getCodePropertyLocations(): string;
33+
34+
public function getCodePropertyTypesPrice(): string;
3135
}

ggrachdev.multiregionality/classes/general/Multiregionality/Entity/Region.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ final class Region {
99
protected $isDefaultRegion;
1010
protected $nameForms = [];
1111
protected $url;
12+
protected $arLocationIds;
13+
protected $arLocationsData = null;
14+
protected $arPricesData = [];
1215
protected $data = [];
1316

1417
public function getId() {
@@ -19,6 +22,68 @@ public function getName() {
1922
return $this->name;
2023
}
2124

25+
public function setLocationIds($arLocationIds) {
26+
$this->arLocationIds = \array_filter($arLocationIds, function($location) {
27+
return \is_numeric($location) && $location > 0;
28+
});
29+
}
30+
31+
public function setPricesData($arPrices) {
32+
33+
$arPricesData = [];
34+
35+
if(!empty($arPrices)) {
36+
foreach ($arPrices as $arPrice) {
37+
if(
38+
isset($arPrice['VALUE']) &&
39+
isset($arPrice['ID'])
40+
)
41+
{
42+
$arPricesData[] = [
43+
'CODE' => $arPrice['VALUE'],
44+
'ID' => $arPrice['ID']
45+
];
46+
}
47+
}
48+
}
49+
50+
$this->arPricesData = $arPricesData;
51+
}
52+
53+
public function getTypePrices(): array {
54+
return $this->arPricesData;
55+
}
56+
57+
public function getLocations(): array {
58+
if($this->arLocationsData === null)
59+
{
60+
if(!empty($this->arLocationIds) && \Bitrix\Main\Loader::includeModule('sale'))
61+
{
62+
$arPriceIds = [];
63+
64+
$dbLocations = \Bitrix\Sale\Location\LocationTable::getList([
65+
'filter' => [
66+
'=ID' => $this->arLocationIds,
67+
'SALE_LOCATION_LOCATION_NAME_LANGUAGE_ID' => 'ru'
68+
],
69+
'select' => [
70+
'ID',
71+
'CODE',
72+
'NAME'
73+
]
74+
]);
75+
76+
$this->arLocationsData = $dbLocations->fetchAll();
77+
}
78+
else
79+
{
80+
$this->arLocationsData = [];
81+
}
82+
}
83+
84+
return $this->arLocationsData;
85+
}
86+
2287
public function getNameForms(): array {
2388
return $this->nameForms;
2489
}

0 commit comments

Comments
 (0)