$item->getQtyBackordered() in magento 2?

by goplastic   Last Updated January 13, 2018 13:09 PM

i can't find the right way to get if a product is backordered. In magento 1 was

$item->getQtyBackordered()

In magento 2?

this is my cart.phtml:

<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
?>
<?php
/**
* Shopping cart template
*
* @var $block \Magento\Checkout\Block\Cart
*/

$check = false;

foreach($block->getItems() as $item) {

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$GP = $objectManager->create('Magento\Catalog\Model\Product')->load($item->getProductId());
$disp = $GP->getResource()->getAttribute('selezione_disponibilita')->getFrontend()->getValue($GP);

if(strpos($disp, 'disponibile') !== false){

    $check = true;

}

if($item->getQtyBackordered() > 0){
   $check = true;
};   

}

if($check == true){

?>

<div style="display:block; background-color: #f5f5f5; padding: 20px; margin: 20px 0px 20px 0px;">
    <?php 
    echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('avviso_spedizione')->toHtml();
    ?> 
</div>

<?php

}

if ($block->getItemsCount()) {
echo $block->getChildHtml('with-items');
} else {
echo $block->getChildHtml('no-items');
}
Tags : magento2


Answers 1


Yes in Magento2 it is the same getQtyBackordered() you can find it Implementations from \Magento\Sales\Model\Order\Item

     /**
     * Returns qty_backordered
     *
     * @return float|null
     */
    public function getQtyBackordered()
    {
        return $this->getData(OrderItemInterface::QTY_BACKORDERED);
    }
Keyur Shah
Keyur Shah
January 13, 2018 13:02 PM

Related Questions


Cart Price Rules having issues

Updated October 01, 2018 18:09 PM


Magento 2.2 Not Loading theme and blocks

Updated January 11, 2018 02:09 AM