Rus
Eng
Яндекс.Маркет добавляем к param пользовательский data аттрибут
Order site
By contacting me you will receive a reliable and knowledgeable contractor who will quickly and efficiently implement any task for you and your business.

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:

Yandex.Market add a custom data attribute to param

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

There are no comments yet, you can be the first to leave it

Leave a comment

The site uses a comment pre-moderation system, so your message will be published only after approval by the moderator

You are replying to a user's comment

Send

FEEDBACK

Email me

Please message me to discuss the task. I work remotely and officially (as a self-employed professional); my hourly rate is 1,800 RUB, and I can dedicate 3–4 hours a day to the project. I respond quickly, and the consultation is free.

An error occurred while sending, please try again after a while
Message sent successfully

Phones

+7(993) 007-18-96

Email

info@tichiy.ru

Address

Россия, г. Москва

By submitting the form, you automatically confirm that you have read and accept the Privacy Policy site