<?php
/**
 * Webkul Software.
 *
 * @category  Webkul
 * @package   Webkul_Agorae
 * @author    Webkul
 * @copyright Copyright (c) Webkul Software Private Limited (https://webkul.com)
 * @license   https://store.webkul.com/license.html
 */

// @codingStandardsIgnoreFile

/**
 * Seller pick collection at seller Collection page
 *
 * @var $block \Webkul\Marketplace\Block\Collection
 */
$partner = $block->getProfileDetail();
if($partner->getIsSeller() && $partner->getShopUrl()){
    $helper = $this->helper('Webkul\Agorae\Helper\Data');
    $_helper = $this->helper('Magento\Catalog\Helper\Output');
    $customLabels = $helper->getAgoraeImageCustomLabel();
    $_sellerProductCollection = $block->_getProductCollection();
    $_productCollection = $_sellerProductCollection->addAttributeToFilter(
        'is_seller_pick',1
    );
?>
    <style>
        .main{
            background-image:none;
            background-color:<?php echo $partner->getbackgroundth();?>
        }
    </style>
    <div class="wkagleft">
        <?php echo $block->getChildHtml('agorae_mp_sellercategory'); ?>
    </div>
    <div class="wkagright">
        <?php if(!$_productCollection->getSize()): ?>
            <p class="note-msg"><?php echo __('There are no products matching the selection.') ?></p>
        <?php else: ?>
            <div class="page-products page-with-filter fieldset wk-mp-fieldset"
                <?php if($_productCollection->count()){ echo 'style="padding: 0;"';}?>>
                <?php echo $block->getToolbarHtml() ?>
                <?php echo $block->getAdditionalHtml() ?>
                <?php
                if ($block->getMode() == 'grid') {
                    $viewMode = 'grid';
                    $image = 'category_page_grid';
                    $showDescription = false;
                    $templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::SHORT_VIEW;
                } else {
                    $viewMode = 'list';
                    $image = 'category_page_list';
                    $showDescription = true;
                    $templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::FULL_VIEW;
                }
                /**
                 * Position for actions regarding image size changing in vde if needed
                 */
                $pos = $block->getPositioned();
                ?>
                <div class="products wrapper <?php /* @escapeNotVerified */ echo $viewMode; ?> products-<?php /* @escapeNotVerified */ echo $viewMode; ?>">
                    <?php $iterator = 1; ?>
                    <ol class="products list items product-items">
                        <?php /** @var $_product \Magento\Catalog\Model\Product */ ?>
                        <?php foreach ($_productCollection as $_product): ?>
                            <?php if($_product->getIsSellerPick()): ?>
                                <?php
                                    $imglabel = '';
                                    $imagecustomlable = $_product->getImageCustomLabel();
                                    if(strlen($imagecustomlable) && array_key_exists($imagecustomlable, $customLabels)){
                                        $imglabel = $customLabels[$imagecustomlable];
                                    }
                                ?>
                                <?php /* @escapeNotVerified */ echo($iterator++ == 1) ? '<li class="item product product-item">' : '</li><li class="item product product-item">' ?>
                                <div class="product-item-info" data-container="product-grid">
                                    <?php
                                    $productImage = $block->getImage($_product, $image);
                                    if ($pos != null) {
                                        $position = ' style="left:' . $productImage->getWidth() . 'px;'
                                            . 'top:' . $productImage->getHeight() . 'px;"';
                                    }
                                    ?>
                                    <?php // Product Image ?>
                                    <?php if ($block->getMode() == 'list') { ?>
                                        <div class="product-item-photo">
                                            <?php echo $imglabel;?>
                                            <a href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>" class="product photo product-item-photo" tabindex="-1">
                                                <?php echo $productImage->toHtml(); ?>
                                            </a>
                                            <?php
                                                //echo $agoraeHelper->getSellerBlockHtml($_product, $block, $templateType);
                                            ?>
                                        </div>
                                        <?php
                                    }else{
                                        ?>
                                        <?php echo $imglabel;?>
                                        <?php // Product Image ?>
                                        <a href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>" class="product photo product-item-photo" tabindex="-1">
                                            <?php echo $productImage->toHtml(); ?>
                                        </a>
                                        <?php
                                    }?>
                                    <div class="product details product-item-details">
                                        <?php
                                            $_productNameStripped = $block->stripTags(
                                                $_product->getName(), null, true
                                            );
                                        ?>
                                        <strong class="product name product-item-name">
                                            <a class="product-item-link"
                                               href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>">
                                                <?php /* @escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>
                                            </a>
                                        </strong>
                                        <?php echo $block->getReviewsSummaryHtml($_product, $templateType); ?>
                                        <?php /* @escapeNotVerified */ echo $block->getProductPrice($_product) ?>
                                        <?php echo $block->getProductDetailsHtml($_product); ?>

                                        <div class="product-item-inner">
                                            <div class="product actions product-item-actions"<?php echo strpos($pos, $viewMode . '-actions') ? $position : ''; ?>>
                                            </div>
                                            <?php if ($showDescription):?>
                                                <div class="product description product-item-description">
                                                    <?php /* @escapeNotVerified */ echo $_helper->productAttribute(
                                                        $_product,
                                                        $_product->getShortDescription(),
                                                        'short_description'
                                                    ) ?>
                                                    <a href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>"
                                                        title="<?php /* @escapeNotVerified */ echo $_productNameStripped ?>"
                                                        class="action more">
                                                        <?php /* @escapeNotVerified */ echo __('Learn More') ?>
                                                    </a>
                                                </div>
                                            <?php endif; ?>
                                        </div>
                                    </div>
                                </div>
                                <?php echo($iterator == count($_productCollection)+1) ? '</li>' : '' ?>
                            <?php endif; ?>
                        <?php endforeach; ?>
                    </ol>
                </div>
                <?php echo $block->getToolbarHtml(); ?>
            </div>
        <?php endif; ?>
    </div>
<?php
} ?>
