Skip to main content
added 135 characters in body
Source Link
Daniel Ifrim
  • 3.4k
  • 2
  • 23
  • 36

In class \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable there is the function bellow.

/**
 * Returns additional values for js config, con be overridden by descendants
 *
 * @return array
 */
protected function _getAdditionalConfig()
{
    return [];
}

How one could "rewrite" (use plugin) it since it is protected. I wanted to add additional data in this function because it is used in "getJsonConfig" function.

I guess if I'd want to make a plugin I would need to use getJsonConfig function because it is public. Which comes back to my question. Should _getAdditionalConfig() be used by end users or it's just for Magento core use ?

Edit I could use a preference for this block class.

Edit 2 Adding a preference for this block class doesn't seem to work

Edit 3 Made a plugin on \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable. Function used is getJsonConfig.

In class \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable there is the function bellow.

/**
 * Returns additional values for js config, con be overridden by descendants
 *
 * @return array
 */
protected function _getAdditionalConfig()
{
    return [];
}

How one could "rewrite" (use plugin) it since it is protected. I wanted to add additional data in this function because it is used in "getJsonConfig" function.

I guess if I'd want to make a plugin I would need to use getJsonConfig function because it is public. Which comes back to my question. Should _getAdditionalConfig() be used by end users or it's just for Magento core use ?

Edit I could use a preference for this block class.

Edit 2 Adding a preference for this block class doesn't seem to work

In class \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable there is the function bellow.

/**
 * Returns additional values for js config, con be overridden by descendants
 *
 * @return array
 */
protected function _getAdditionalConfig()
{
    return [];
}

How one could "rewrite" (use plugin) it since it is protected. I wanted to add additional data in this function because it is used in "getJsonConfig" function.

I guess if I'd want to make a plugin I would need to use getJsonConfig function because it is public. Which comes back to my question. Should _getAdditionalConfig() be used by end users or it's just for Magento core use ?

Edit I could use a preference for this block class.

Edit 2 Adding a preference for this block class doesn't seem to work

Edit 3 Made a plugin on \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable. Function used is getJsonConfig.

edited title
Source Link
Daniel Ifrim
  • 3.4k
  • 2
  • 23
  • 36

Magento2 - How to use _getAdditionalConfig() from \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable

In class \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable there is the function bellow.

/**
 * Returns additional values for js config, con be overridden by descendants
 *
 * @return array
 */
protected function _getAdditionalConfig()
{
    return [];
}

How one could "rewrite" (use plugin) it since it is protected. I wanted to add additional data in this function because it is used in "getJsonConfig" function.

I guess if I'd want to make a plugin I would need to use getJsonConfig function because it is public. Which comes back to my question. Should _getAdditionalConfig() be used by end users or it's just for Magento core use ?

Edit I could use a preference for this block class.

Edit 2 Adding a preference for this block class doesn't seem to work

How to use _getAdditionalConfig() from \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable

In class \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable there is the function bellow.

/**
 * Returns additional values for js config, con be overridden by descendants
 *
 * @return array
 */
protected function _getAdditionalConfig()
{
    return [];
}

How one could "rewrite" it since it is protected. I wanted to add additional data in this function because it is used in "getJsonConfig" function.

I guess if I'd want to make a plugin I would need to use getJsonConfig function because it is public. Which comes back to my question. Should _getAdditionalConfig() be used by end users or it's just for Magento core use ?

Edit I could use a preference for this block class.

Magento2 - How to use _getAdditionalConfig() from \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable

In class \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable there is the function bellow.

/**
 * Returns additional values for js config, con be overridden by descendants
 *
 * @return array
 */
protected function _getAdditionalConfig()
{
    return [];
}

How one could "rewrite" (use plugin) it since it is protected. I wanted to add additional data in this function because it is used in "getJsonConfig" function.

I guess if I'd want to make a plugin I would need to use getJsonConfig function because it is public. Which comes back to my question. Should _getAdditionalConfig() be used by end users or it's just for Magento core use ?

Edit I could use a preference for this block class.

Edit 2 Adding a preference for this block class doesn't seem to work

added 60 characters in body
Source Link
Daniel Ifrim
  • 3.4k
  • 2
  • 23
  • 36

In class \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable there is the function bellow.

/**
 * Returns additional values for js config, con be overridden by descendants
 *
 * @return array
 */
protected function _getAdditionalConfig()
{
    return [];
}

How one could "rewrite" it since it is protected. I wanted to add additional data in this function because it is used in "getJsonConfig" function.

I guess if I'd want to make a plugin I would need to use getJsonConfig function because it is public. Which comes back to my question. Should _getAdditionalConfig() be used by end users or it's just for Magento core use ?

Edit I could use a preference for this block class.

In class \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable there is the function bellow.

/**
 * Returns additional values for js config, con be overridden by descendants
 *
 * @return array
 */
protected function _getAdditionalConfig()
{
    return [];
}

How one could "rewrite" it since it is protected. I wanted to add additional data in this function because it is used in "getJsonConfig" function.

I guess if I'd want to make a plugin I would need to use getJsonConfig function because it is public. Which comes back to my question. Should _getAdditionalConfig() be used by end users or it's just for Magento core use ?

In class \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable there is the function bellow.

/**
 * Returns additional values for js config, con be overridden by descendants
 *
 * @return array
 */
protected function _getAdditionalConfig()
{
    return [];
}

How one could "rewrite" it since it is protected. I wanted to add additional data in this function because it is used in "getJsonConfig" function.

I guess if I'd want to make a plugin I would need to use getJsonConfig function because it is public. Which comes back to my question. Should _getAdditionalConfig() be used by end users or it's just for Magento core use ?

Edit I could use a preference for this block class.

Source Link
Daniel Ifrim
  • 3.4k
  • 2
  • 23
  • 36
Loading