마 젠토 2 : catalog_attributes.xml 파일은 무엇입니까?


14

Magento 2에는 catalog_attributes.xml다음 폴더에 여러 파일이 포함되어 있습니다 .

  • app/code/Magento/Bundle/etc
  • app/code/Magento/Catalog/etc
  • app/code/Magento/CatalogSearch/etc
  • app/code/Magento/CatalogUrlRewrite/etc
  • app/code/Magento/Downloadable/etc
  • app/code/Magento/GiftMessage/etc
  • app/code/Magento/Msrp/etc
  • app/code/Magento/Sales/etc
  • app/code/Magento/Tax/etc
  • app/code/Magento/Wishlist/etc

해당 파일은 다음과 같습니다 ( Sales파일 예 ).

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Catalog:etc/catalog_attributes.xsd">
    <group name="quote_item">
        <attribute name="sku"/>
        <attribute name="type_id"/>
        <attribute name="name"/>
        <attribute name="status"/>
        <attribute name="visibility"/>
        <attribute name="price"/>
        <attribute name="weight"/>
        <attribute name="url_path"/>
        <attribute name="url_key"/>
        <attribute name="thumbnail"/>
        <attribute name="small_image"/>
        <attribute name="tax_class_id"/>
        <attribute name="special_from_date"/>
        <attribute name="special_to_date"/>
        <attribute name="special_price"/>
        <attribute name="cost"/>
        <attribute name="gift_message_available"/>
    </group>
</config>

그 파일들은 무엇에 사용됩니까?



답변:


20

일반적으로 이러한 파일에는 다른 용도로 사용되는 속성 목록이 있습니다. 카탈로그 모듈의 파일에서
그룹 used_in_autogeneration은 값이 자동 생성 된 속성을 나열하는 역할을합니다.
그들은에서 검색\Magento\Catalog\Helper\Product::getAttributesAllowedForAutogeneration

그룹 quote_item은 제품에서 견적 항목으로 복사 될 속성을 나타냅니다.

unassignable 속성 세트에서 할당을 취소 할 수없는 속성 목록을 포함합니다.

죄송하지만 사용 가능한 모든 그룹을 모릅니다.
그러나 기존 그룹에만 국한되지는 않습니다. 전화를 걸어서 원하는대로 직접 추가하고 사용할 수 있습니다 \Magento\Catalog\Model\Attribute\Config::getAttributeNames('group_name_here'). (하지만 먼저 클래스를 인스턴스화하십시오).

[편집]
이것에 대해 잘 모르겠지만, 사물 catalog_categorycatalog_product그룹은 제품과 카테고리에 대한 시스템 속성을 가지고 있습니다.


9

어제 나는 처음으로 넘어졌다. 예를 들어 항목 제품을 인용하기 위해 사용자 정의 속성을 추가하는 데 사용됩니다. 그렇지 않으면 리소스를 저장하기 위해로드되지 않습니다 (제 경우 color에는 장바구니 페이지에 속성 을 표시하려고했습니다 ). Magento 1에서는 다음과 같이 모듈에 입력합니다 config.xml.

<config>
    <global>
        <sales>
            <quote>
                <item>
                    <product_attributes>
                        <color />
                    </product_attributes>
                </item>
            </quote>
        </sales>
    </global>
</config>

M2에서도 동일하게하려면 catalog_attributes.xml모듈에 를 추가 하고 다음을 수행해야합니다.

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Catalog:etc/catalog_attributes.xsd">
    <group name="quote_item">
        <attribute name="color" />
    </group>
</config>
당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.