The last notes
All English-language materials have been translated fully automatically using the Google service
First of all, I warn you that you do not need to make modifications to the core of the project or classes of third-party modules.
By doing this, you do it at your own risk and understand that problems may arise with any update of the module
Sometimes, however, a situation may arise when you cannot wait for changes to be made to the module and the solution is needed here and now. I will describe how to add a custom attribute to the param tag in Yandex.Market for Sellers. In my case, I added the code attribute. If you do everything right, it will turn out like this:
1. Add a new attribute class based on the existing name.
Go to \bitrix\modules\yandex.market\lib\export\xml\attribute. We are looking for the file paramname.php and copy it to a new file. In my case it is paramcode.php
Replace everything related to name with code. You should end up with something like this:
<?php
namespace Yandex\Market\Export\Xml\Attribute;
use Yandex\Market;
class ParamCode extends Base
{
public function getDefaultParameters()
{
return [
'name' => 'code',
];
}
public function preselect(array $context)
{
return [
'TYPE' => Market\Export\Entity\Manager::TYPE_IBLOCK_PROPERTY_FEATURE,
'FIELD' => implode('.', [
Market\Config::getModuleName(),
Market\Ui\Iblock\PropertyFeature::getFeatureId($context['EXPORT_SERVICE']),
'CODE',
]),
];
}
}
2. Adding a new attribute to the Yandex.Market pop-up menu
Go to \bitrix\modules\yandex.market\lib\export\xml\format\yandexmarket
We are looking for the function getOfferDefaultChildren and in it the formation of the structure of the tag param with the following code new Xml\Tag\Param. In my case it is line 190
Add a call to our class:
new Xml\Attribute\ParamCode(['preselect' => true]),
It should look like this:
new Xml\Tag\Param([
'multiple' => true,
'visible' => true,
'preselect' => true,
'attributes' => [
new Xml\Attribute\ParamName(['required' => true, 'visible' => true, 'preselect' => true]),
new Xml\Attribute\ParamUnit(['preselect' => true]),
new Xml\Attribute\ParamCode(['preselect' => true]),
],
]),
Everything. Save your changes, go to Yandex Market price list generation, add the param tag and enjoy the new attribute.
Comments