Get product configurable attribute with value (Child of configurable) from QuoteFactory

by Greg   Last Updated October 19, 2019 12:09 PM - source

How can I retrieve simple product configurable attribute with its value from \Magento\Quote\Model\QuoteFactory (or any other method?)?

I can retrieve some information using this:

 public function __construct(
        \Magento\Catalog\Block\Product\Context $context,
        Helper\Font $font,
        \Dotdigitalgroup\Email\Model\Catalog\UrlFinder $urlFinder,
        \Magento\Store\Model\App\EmulationFactory $emulationFactory,
        \Magento\Quote\Model\QuoteFactory $quoteFactory,
        \Dotdigitalgroup\Email\Helper\Data $helper,
        \Magento\Framework\Pricing\Helper\Data $priceHelper,
        array $data = []
    ) {
        $this->quoteFactory     = $quoteFactory;
        $this->helper           = $helper;
        $this->priceHelper      = $priceHelper;
        $this->emulationFactory = $emulationFactory;

        parent::__construct($context, $font, $urlFinder, $data);

public function getBasketItems()
 $this->quote = $quoteModel;
 $quoteItems = $quoteModel->getAllItems();

    foreach ($quoteItems as $quoteItem) {
        echo 'ID: '.$quoteItem->getProductId().'<br />';
        echo 'Name: '.$quoteItem->getName().'<br />';
        echo 'Sku: '.$quoteItem->getSku().'<br />';
        echo 'Quantity: '.$quoteItem->getQty().'<br />';
        echo 'Price: '.$quoteItem->getPrice().'<br />';
        echo "<br />";           

I need to get the configurable attribute name with value. E.g:

Id:       1 
Name:     T-Shirt 
Sku:      foobar 
Quantity: 5 
Price:    9.99 
Color[The configurable attribute]: Red [Configurable attribute value]

Related Questions

Add options to quote programmaticaly

Updated May 20, 2019 14:09 PM