Files
bx.discount/admin/main/submenu/settings/include/config.php
T
2026-02-05 16:22:55 +03:00

102 lines
3.7 KiB
PHP

<?php
/**
* @var Wt\Core\Admin\Templater $this
*/
use Wt\Core\Support\System;
$system = new System();
$config = discountApp()->config();
$data = [];
$data['env'] = discountApp()->env();
$data['enable'] = $this->getCheckTemplate($config->get('enable'));
$data['update_element_index'] = $this->getCheckTemplate($config->get('update_element_index'));
$priceTypeIdList = $config->get('catalog_group_id_list', []);
$data['catalog_group_id_list'] = $priceTypeIdList->join(', ');
foreach ($priceTypeIdList as $priceTypeId){
$priceTypeEntity = app()->factory()->shop()->getPriceTypeFactory()->getEntityById($priceTypeId);
if($priceTypeEntity){
$linkTemplate = "<a href=\"{$priceTypeEntity->getUrl()}\" target=\"_blank\">$priceTypeId</a>";
$data["catalog_group_id_list_$priceTypeId"] = "[$linkTemplate] {$priceTypeEntity->getName()}";
}
}
$data['page_size'] = $config->get('page_size');
?>
<table cellpadding="5" border="1" style="border-collapse: collapse; width: 100%">
<?php
foreach ($data as $key => $value) {
?><tr><td><?= $key ?></td><td><?= $value ?></td></tr><?php
}
?>
</table>
<br>
<h3>Инфоблоки</h3>
<table cellpadding="5" border="1" style="border-collapse: collapse; width: 100%">
<tr style="font-size: 0.9em; text-align: left;">
<th>Config Name</th>
<th>Title</th>
<th>isSectionProperty</th>
</tr>
<tr>
<?php
$catalogIBlockId = discountApp()->config('catalog_iblock_id', 0);
$catalogTitle = "<span class='errortext'>".($catalogIBlockId?:'Undefined'). '</span>';
$catalogEntity = app()->factory()->main()->getIBlockFactory()->getEntityById($catalogIBlockId);
if($catalogEntity){
$catalogTitle = "[{$catalogEntity->getId()}] {$catalogEntity->getName()}";
$catalogTitle = "[<a href=\"{$catalogEntity->getAdminUrl()}\" target=\"_blank\">{$catalogEntity->getId()}</a>] {$catalogEntity->getName()}";
}
?>
<td><?='catalog_iblock_id'?></td><td><?=$catalogTitle?></td><td><?=$catalogEntity->isSectionProperty()?'Да':'Нет'?></td>
</tr>
</table>
<br>
<h3>Mapping</h3>
<?php
$af = app()->factory()->iBlock()->getEntityById($catalogIBlockId);
$propertyFactory = $af->getPropertyFactory();
$map = $config->get('MAP', [])->toArray();
?>
<table cellpadding="5" border="1" style="border-collapse: collapse; width: 100%">
<tr style="font-size: 0.8em; color: #6e6e6e"><td>Type</td><td>Property</td><td>PropertyValue</td></tr>
<?php
foreach ($map as $type => $typeMap){
foreach ($typeMap as $propertyCode => $propertyValue) {
\Bx\Discount\Tools::prepareMapPropertyCodeAndValue($propertyCode, $propertyValue);
$propertyEntity = $propertyFactory->getEntityByCode($propertyCode);
if($propertyEntity?->getBaseType() != 'L'){
continue;
}
/**
* @var \Wt\Core\Collection\IBlock\PropertyEnumCollection $valueCollection
*/
$valueCollection = $propertyEntity->getValueCollection();
$valueEntity = $valueCollection->getByXmlId($propertyValue);
?>
<tr>
<td><?= $type ?></td>
<td><?php
$propertyEntity->getUrl();
$linkTemplate = "<a href=\"{$propertyEntity->getUrl()}\" target=\"_blank\">{$propertyEntity->getId()}</a>";
echo "[$linkTemplate] {$propertyEntity->getName()}";
?></td>
<td><?php
if($valueEntity){
echo "[{$valueEntity->getId()}] {$valueEntity->getName()}";
}
?></td>
</tr>
<?php
}
}?>
</table>