0

I have used plugin in one extension

<type name="Magento\Checkout\Model\DefaultConfigProvider">
    <plugin name="Amasty_Checkout::DefaultConfigProvider" type="Amasty\Checkout\Plugin\DefaultConfigProvider" />
</type>

public function afterGetConfig(\Magento\Checkout\Model\DefaultConfigProvider $subject, $config)
    {
        if (!in_array('amasty_checkout', $this->layout->getUpdate()->getHandles()))
            return $config;

        $quote = $this->checkoutSession->getQuote();

        foreach ($config['quoteItemData'] as &$item) {
            $additionalConfig = $this->itemHelper->getItemOptionsConfig($quote, $item['item_id']);

            if ($this->moduleManager->isEnabled(self::AMASTY_STOCKSTATUS_MODULE_NAMESPACE)) {
                $item['amstockstatus'] = $this->itemHelper->getItemCustomStockStatus($quote, $item['item_id']);
            }

            if (!empty($additionalConfig)) {
                $item['amcheckout'] = $additionalConfig;
            }
        }

        return $config;
    }

Now I want to show attribute and add url to product in checkout sidebar http://prntscr.com/jape88 for that i have to use

public function afterGetConfig(
        \Magento\Checkout\Model\DefaultConfigProvider $subject,
        array $result
    ) {
        $items = $result['totalsData']['items'];
        foreach ($items as $index => $item) {
            $quoteItem = $this->checkoutSession->getQuote()->getItemById($item['item_id']);
            $result['quoteItemData'][$index]['manufacturer'] = $quoteItem->getProduct()->getAttributeText('manufacturer');
        }
        return $result;
    }

How can I merge second one with first? Or should I create saperate module for this?

1

The right approach would be creating separate module for the second plugin, you can use sortOrder property to fit concrete execution order with your needings

http://devdocs.magento.com/guides/v2.2/extension-dev-guide/plugins.html

Prioritizing plugins

The sortOrder property for plugins determine when their before, after, or around methods get called when more than one plugins are observing the same method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.