Answer the question
In order to leave comments, you need to log in
How to add a new infoblock element property via a script so that it is available only for a certain section?
The question is, is it possible to add new properties to products (infoblock elements) in the code using the Bitrix API, so that this property is available only for elements of a certain section of the catalog?
For example, there is a trade catalog (infoblock) - Electronics. The infoblock contains sections Mobile devices, Cameras and Laptops. The Exposure parameter is available only for products from the Cameras section. How can this parameter be in the code so that it is not displayed for elements of other sections?
By default, in order for the property to be displayed only for a specific product section,
in the infoblock settings, uncheck the Show on the list of elements page checkbox for the property and then
indicate the desired property
in the required section in the Element Properties tab .
The second question, how can I make it so that after adding it through the script, the new property is immediately displayed in the Product tab?
Answer the question
In order to leave comments, you need to log in
This mechanism is not supplied in the box.
What is there?
1) Is it possible to add features (feature) to the property (property)?
Can. To do this, you need to supplement them on the OnPropertyFeatureBuildList event. There is no documentation, but digging the kernel in the \Bitrix\Iblock\Model\PropertyFeature class will help you
2) Is it possible to make certain properties be displayed depending on some conditions?
Yes and no. There is no such mechanism in the box, but you can completely redefine the form to edit the element .
But again, these changes will not display data in the product card (in the public part).
How is it usually done? They make a general element card, and then make several tabs for different sections.
By the way, it is good practice (and indeed very useful) not to make sections within one infoblock, but to create different infoblocks for different types of goods. This, of course, complicates the exchange with 1C (you will have to throw out what is out of the box and order your own), but it increases productivity and immediately solves such problems.
As far as I remember, there is such a class CIBlockSectionPropertyLink. He has these methods.
CIBlockSectionPropertyLink::Add($SECTION_ID, $PROPERTY_ID, $arLink = array())
CIBlockSectionPropertyLink::Delete($SECTION_ID, $PROPERTY_ID)
CIBlockSectionPropertyLink::DeleteByIBlock($IBLOCK_ID)
CIBlockSectionPropertyLink::DeleteByProperty($PROPERTY_ID)
CIBlockSectionPropertyLink::DeleteBySection($SECTION_ID)
CIBlockSectionPropertyLink::GetArray($IBLOCK_ID, $SECTION_ID = 0, $bNewSection = false)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question