bkubicki/module-configurable-product-attribute-handles

Module adds to catalog frontend custom layout handles based on configurable product

1.0.0 2021-06-09 06:18 UTC

This package is auto-updated.

Last update: 2024-11-09 14:11:35 UTC


README

Overview

Module adds custom frontend layout handles\extension points for easier frontend customization of configurable product.

Features

  • product card - handles basing on product super attributes, pattern: catalog_product_view_type_configurable_super_{{attribute_code}}
  • product card - specific templates for configurable options block. Block vendor/magento/module-swatches/Block/Product/Renderer/Configurable.php:443 allows only two templates (one from Magento_Swatches and the default one from Magento_ConfigurableProduct), ignoring any layout instructions. By adding some data in layout, we can change template for custom one, based on product super attributes:
<referenceBlock name="product.info.options.swatches">
    <arguments>
        <argument name="configurable_super_templates" xsi:type="array">
            <item name="configurable_super_colour" xsi:type="string">Vendor_Module::product/view/type/options/configurable-super-colour.phtml</item>
        </argument>
    </arguments>
</referenceBlock>

Such an instruction can be combined with product super attributes handles, but it doesn't have to be.

  • product listing - possibility to define additional renderers for configurable super products, pattern: configurable_super_{{attribute_code}}'. Usage example:
<block name="category.product.type.details.renderers.configurable_super_example_attribute" as="configurable_super_example_attribute"
       template="Vendor_Module::product/listing/super-example-attribute-renderer.phtml"/>

Don't forget to add alias for renderer, as it is used for renderer picking.

Please see attached module to fully understand possible usage of these features.

Prerequisites

  • PHP 7.3|7.4

Installation

To install the extension use the following commands:

 composer require bkubicki/module-configurable-product-attribute-handles

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Changelog

See changelog here.

Authors

License

This project is licensed under the MIT License - see the LICENSE file for details.