I have created a custom module.
di.xml
< type name="Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable"> < plugin name="ptgConfigurableProduct" type="ModuleName\Extendfiles\Plugin\Model\ResourceModel\Product\Type\Configurable" sortOrder="1" /> < /type>
Path: /ModuleName/Extendfiles/Model/ResourceModel/Product/Type/ Configurable.php
namespace ModuleName\Extendfiles\Plugin\Model\ResourceModel\Product\Type;
class Configurable extends \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable {
}
Function
public function afterGetAttributeOptions($superAttribute, $productId){
$scope = $this->getScopeResolver()->getScope(); $select = $this->getConnection()->select()->from( ['super_attribute' => $this->getTable('catalog_product_super_attribute')], [ 'sku' => 'entity.sku', 'product_id' => 'product_entity.entity_id', 'attribute_code' => 'attribute.attribute_code', 'value_index' => 'entity_value.value', 'option_title' => $this->getConnection()->getIfNullSql( 'option_value.value', 'default_option_value.value' ), 'default_title' => 'default_option_value.value', ] )->joinInner( ['product_entity' => $this->getTable('catalog_product_entity')], "product_entity.{$this->getProductEntityLinkField()} = super_attribute.product_id", [] )->joinInner( ['product_link' => $this->getTable('catalog_product_super_link')], 'product_link.parent_id = super_attribute.product_id', [] )->joinInner( ['attribute' => $this->getTable('eav_attribute')], 'attribute.attribute_id = super_attribute.attribute_id', [] )->joinInner( ['entity' => $this->getTable('catalog_product_entity')], 'entity.entity_id = product_link.product_id', [] )->joinInner( ['entity_value' => 'catalog_product_entity_int'], implode( ' AND ', [ 'entity_value.attribute_id = super_attribute.attribute_id', 'entity_value.store_id = 0', "entity_value.{$this->getProductEntityLinkField()} = " . "entity.entity_id", ] ), [] )->joinLeft( ['option_value' => $this->getTable('eav_attribute_option_value')], implode( ' AND ', [ 'option_value.option_id = entity_value.value', 'option_value.store_id = ' . $scope->getId(), ] ), [] )->joinLeft( ['default_option_value' => $this->getTable('eav_attribute_option_value')], implode( ' AND ', [ 'default_option_value.option_id = entity_value.value', 'default_option_value.store_id = ' . \Magento\Store\Model\Store::DEFAULT_STORE_ID, ] ), [] )->where( 'super_attribute.product_id = ?', $productId )->where( 'option_value.value != "N/A"', $productId )->where( 'attribute.attribute_id = ?', $superAttribute->getAttributeId() $attributeId ); return $this->getConnection()->fetchAll($select); }
Getting below error for this code
$superAttribute->getAttributeId()
, Fatal error: Call to undefined method Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Interceptor::getAttributeId()