Q:

Magento2 : How to get quantity in dropdown for configurable product in cart page

I want quantity in dropdown, I wrote code in: 

app/design/frontend/Namespace/Theme/Magento_Checkout/templates/cart/item/default.phtml

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$productStockObj = $objectManager->get('Magento\CatalogInventory\Api\StockRegistryInterface')->getStockItem($product->getId());
$qty = $productStockObj->getQty();
?>
<div class="field qty">
    <select id="cart-<?php /* @escapeNotVerified */
    echo $_item->getId() ?>-qty" name="cart[<?php /* @escapeNotVerified */
    echo $_item->getId() ?>][qty]" title="<?php echo $block->escapeHtml(__('Qty')); ?>" data - cart - item -
            id="<?php /* @escapeNotVerified */
            echo $_item->getSku() ?>">
        <?php for ($i = 1; $i <= $qty; $i++): ?>
            <option value="<?php echo $i; ?>"<?php if ($i == $block->getQty()) {
                echo 'selected';
            } ?>><?php echo $i; ?></option>
        <?php endfor; ?>
    </select>
</div>

But in cart page only simple product quantity showing, but configurable product not showing

A:

This  will work for simple products for configurable product you have to pass child product as parent do not have quantity (quantity is manage for child product in case of configurable proudcts)

check this on how to get child of Configurable product

load vendor\magento\module-checkout\view\frontend\templates\cart\item\default.phtml in you theme
Create instance of StockStateInterface to get quantity of product.
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$StockState = $objectManager->get('\Magento\CatalogInventory\Api\StockStateInterface');
?>

in place of input field update the  code below
  <td class="col qty" data-th="<?php echo $block->escapeHtml(__('Qty')); ?>">
        <div class="field qty">
            <label class="label" for="cart-<?php /* @escapeNotVerified */ echo $_item->getId() ?>-qty">
                <span><?php /* @escapeNotVerified */ echo __('Qty') ?></span>
            </label>
            <div class="control qty">
                <select id="cart-<?php /* @escapeNotVerified */ echo $_item->getId() ?>-qty"
                       name="cart[<?php /* @escapeNotVerified */ echo $_item->getId() ?>][qty]"
                       data-cart-item-id="<?php /* @escapeNotVerified */ echo $_item->getSku() ?>"
                     title="<?php echo $block->escapeHtml(__('Qty')); ?>" >
                    <option value="1">Select Qty</option>
                    <?php 
                    $qtyInc = 1;
                    $stock = $StockState->getStockQty($_item->getId(), $_item->getStore()->getWebsiteId()); 
                        do {
                            $selected = ($block->getQty() == $qtyInc) ? 'selected="selected"' : '' ;
                            echo '<option value="'.$qtyInc.'" '. $selected .'>'.$qtyInc.'</option>';
                            $qtyInc++;
                        } while ($qtyInc <= $stock);
                    ?>
                </select>
            </div>
        </div>
    </td>

Final code in default.phtml (complete code)
<?php
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

/** @var $block \Magento\Checkout\Block\Cart\Item\Renderer */

$_item = $block->getItem();
$product = $_item->getProduct();
$isVisibleProduct = $product->isVisibleInSiteVisibility();
/** @var \Magento\Msrp\Helper\Data $helper */
$helper = $this->helper('Magento\Msrp\Helper\Data');
$canApplyMsrp = $helper->isShowBeforeOrderConfirm($product) && $helper->isMinimalPriceLessMsrp($product);
?>
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$StockState = $objectManager->get('\Magento\CatalogInventory\Api\StockStateInterface');
?>
<tbody class="cart item">
    <tr class="item-info">
        <td data-th="<?php echo $block->escapeHtml(__('Item')); ?>" class="col item">
            <?php if ($block->hasProductUrl()):?>
                <a href="<?php /* @escapeNotVerified */ echo $block->getProductUrl() ?>"
                   title="<?php echo $block->escapeHtml($block->getProductName()) ?>"
                   tabindex="-1"
                   class="product-item-photo">
            <?php else:?>
                <span class="product-item-photo">
            <?php endif;?>
            <?php echo $block->getImage($block->getProductForThumbnail(), 'cart_page_product_thumbnail')->toHtml(); ?>
            <?php if ($block->hasProductUrl()):?>
                </a>
            <?php else: ?>
                </span>
            <?php endif; ?>
            <div class="product-item-details">
                <strong class="product-item-name">
                    <?php if ($block->hasProductUrl()):?>
                        <a href="<?php /* @escapeNotVerified */ echo $block->getProductUrl() ?>"><?php echo $block->escapeHtml($block->getProductName()) ?></a>
                    <?php else: ?>
                        <?php echo $block->escapeHtml($block->getProductName()) ?>
                    <?php endif; ?>
                </strong>
                <?php if ($_options = $block->getOptionList()):?>
                    <dl class="item-options">
                        <?php foreach ($_options as $_option) : ?>
                            <?php $_formatedOptionValue = $block->getFormatedOptionValue($_option) ?>
                            <dt><?php echo $block->escapeHtml($_option['label']) ?></dt>
                            <dd>
                                <?php if (isset($_formatedOptionValue['full_view'])): ?>
                                    <?php /* @escapeNotVerified */ echo $_formatedOptionValue['full_view'] ?>
                                <?php else: ?>
                                    <?php /* @escapeNotVerified */ echo $_formatedOptionValue['value'] ?>
                                <?php endif; ?>
                            </dd>
                        <?php endforeach; ?>
                    </dl>
                <?php endif;?>
                <?php if ($messages = $block->getMessages()): ?>
                    <?php foreach ($messages as $message): ?>
                        <div class="cart item message <?php /* @escapeNotVerified */ echo $message['type'] ?>"><div><?php echo $block->escapeHtml($message['text']) ?></div></div>
                    <?php endforeach; ?>
                <?php endif; ?>
                <?php $addInfoBlock = $block->getProductAdditionalInformationBlock(); ?>
                <?php if ($addInfoBlock): ?>
                    <?php echo $addInfoBlock->setItem($_item)->toHtml() ?>
                <?php endif;?>
            </div>
        </td>

        <?php if ($canApplyMsrp): ?>
            <td class="col msrp" data-th="<?php echo $block->escapeHtml(__('Price')); ?>">
                <span class="pricing msrp">
                    <span class="msrp notice"><?php /* @escapeNotVerified */ echo __('See price before order confirmation.'); ?></span>
                    <?php $helpLinkId = 'cart-msrp-help-' . $_item->getId(); ?>
                    <a href="#" class="action help map" id="<?php /* @escapeNotVerified */ echo($helpLinkId); ?>" data-mage-init='{"addToCart":{"helpLinkId": "#<?php /* @escapeNotVerified */ echo $helpLinkId;?>","productName": "<?php /* @escapeNotVerified */ echo $product->getName(); ?>","showAddToCart": false}}'>
                        <span><?php /* @escapeNotVerified */ echo __("What's this?"); ?></span>
                    </a>
                </span>
            </td>
        <?php else: ?>
            <td class="col price" data-th="<?php echo $block->escapeHtml(__('Price')); ?>">
                <?php echo $block->getUnitPriceHtml($_item); ?>
            </td>
        <?php endif; ?>
        <td class="col qty" data-th="<?php echo $block->escapeHtml(__('Qty')); ?>">
            <div class="field qty">
                <label class="label" for="cart-<?php /* @escapeNotVerified */ echo $_item->getId() ?>-qty">
                    <span><?php /* @escapeNotVerified */ echo __('Qty') ?></span>
                </label>
                <div class="control qty">
                    <select id="cart-<?php /* @escapeNotVerified */ echo $_item->getId() ?>-qty"
                           name="cart[<?php /* @escapeNotVerified */ echo $_item->getId() ?>][qty]"
                           data-cart-item-id="<?php /* @escapeNotVerified */ echo $_item->getSku() ?>"
                         title="<?php echo $block->escapeHtml(__('Qty')); ?>" >
                        <option value="1">Select Qty</option>
                        <?php 
                        $qtyInc = 1;
                        $stock = $StockState->getStockQty($_item->getId(), $_item->getStore()->getWebsiteId()); 
                            do {
                                $selected = ($block->getQty() == $qtyInc) ? 'selected="selected"' : '' ;
                                echo '<option value="'.$qtyInc.'" '. $selected .'>'.$qtyInc.'</option>';
                                $qtyInc++;
                            } while ($qtyInc <= $stock);
                        ?>
                    </select>
                </div>
            </div>
        </td>

        <td class="col subtotal" data-th="<?php echo $block->escapeHtml(__('Subtotal'));?>">
            <?php if ($canApplyMsrp): ?>
                <span class="cart msrp subtotal">--</span>
            <?php else: ?>
                <?php echo $block->getRowTotalHtml($_item); ?>
            <?php endif; ?>
        </td>
        <td class="col remove" data-th="<?php echo $block->escapeHtml(__('Remove'));?>">
            <div class="actions-toolbar">
                <?php /* @escapeNotVerified */ echo $block->getActions($_item) ?>
            </div>
        </td>
    </tr>
    <?php /*
    <tr class="item-actions">
        <td colspan="100">
            <div class="actions-toolbar">
                <?php echo $block->getActions($_item) ?>
            </div>
        </td>
    </tr>
    */ ?>

</tbody>

