
<?php
    $helper = $this->helper('Magetop\Agency\Helper\Data');
    $_productCollection = $block->getLoadedProductCollection();
    $assignInfo = array();

    foreach ($_productCollection as $_product) {
        $check = false;
        $minPriceToShow = 0;
        $minPriceProduct = false;
        $productUrl = $_product->getProductUrl();
        $collection = $helper->getAssignProductCollection($_product->getId());
        $totalSellers = $collection->getSize();

        if (($_product->getTypeId() == 'simple')||($_product->getTypeId() == 'virtual') && $totalSellers) {
            $originalQty = $helper->getOriginalQty($_product->getId());
            $minPriceProducts = $helper->getMinimumPriceProductDetails($_product->getId(), $_product->getTypeId());
            if ($minPriceProducts) {
                $minPriceToShow = $this->helper('Magento\Framework\Pricing\Helper\Data')
                                        ->currency($minPriceProducts[0]['price'], true, false);
                $minPriceProduct = $minPriceProducts[0];
            }
            if ($originalQty > 0 && $totalSellers > 0) {
                $check = true;
            }
        }
        $assignInfo[$productUrl]['msg'] =  __('Available from %1 more seller(s)' , $totalSellers);
        $assignInfo[$productUrl]['stock'] = $check;
        $assignInfo[$productUrl]['minPrice'] = $minPriceToShow;
        $assignInfo[$productUrl]['minPriceProduct'] = $minPriceProduct;
    }
    $data = [
                "assignInfo" => $assignInfo,
                // "msg" => __('Availabe from other sellers'),
                "label" => __("view")
            ];
    $data = json_encode($data);
?>
<script type="text/x-magento-init">
    {
        "*": {
            "list": <?php echo $data ?>
        }
    }
</script>
