Yandex.Market add a custom data attribute to param
Rus
Eng
Яндекс.Маркет добавляем к param пользовательский data аттрибут

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

Are you developing a new service, making improvements to the existing one and want to be better than your competitors? You have come to the right place. I offer you a comprehensive studio-level website development. From me you can order design, layout, programming, development of non-traditional functionality, implementation of communication between CMS, CRM and Data Analitics, as well as everything else related to sites, except for promotion.

Contact, I will always advise on all questions and help you find the most effective solution for your business. I am engaged in the creation of sites in Novosibirsk and in other regions of Russia, I also work with the CIS countries. You will be satisfied with our cooperation

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

Contact with me
Send message
By submitting the form, you automatically confirm that you have read and accept Privacy policy of site
Sending successful!
Thank you for contacting :) I will contact you as soon as possible
Sending failed
An error occurred while sending the request. Please wait and try again after a while or call my phone number