<?php
/******************************************************************************
 *   ______                                                                   *
 *  /       \                                                                 *
 * /$$$$$$  | ________  __    __   ______    ______                           *
 * $$ |__$$ |/        |/  |  /  | /      \  /      \                          *
 * $$    $$ |$$$$$$$$/ $$ |  $$ |/$$$$$$  |/$$$$$$  |                         *
 * $$$$$$$$ |  /  $$/  $$ |  $$ |$$ |  $$/ $$    $$ |                         *
 * $$ |  $$ | /$$$$/__ $$ \__$$ |$$ |      $$$$$$$$/                          *
 * $$ |  $$ |/$$      |$$    $$/ $$ |      $$       |                         *
 * $$/   $$/ $$$$$$$$/  $$$$$$/  $$/        $$$$$$$/                          *
 *                                                                            *
 * @PROJECT    : 3D Preview Extension [Magetop.com]                           *
 * @AUTHOR     : Azure - Developer                                            *
 * @COPYRIGHT  : © 2019  Magetop.com                                          *
 * @LINK       : https://Magetop.com                                          *
 * @CREATED    :  10/01/2022                                                  *
 ******************************************************************************/


/** @var \Magetop\Advancepreview\Block\CustomProduct $block */
//$relateProducts = $block->getRerateProducts();
$_product = $block->getPreviewProductData();


//print_r($lastOpens);
$lastOpens = $block->checkPreviewProduct($_product);
//$lastOpens = array_reverse($lastOpens);
//echo $_product->getData('generalinfo');
//echo get_class($block);
?>
<?php /*<?php if(count($relateProducts) > 0 ) : ?>
<div class="mgt-product-fillings">
    <?php $filling = 0; ?>
    <?php foreach ($relateProducts as $relateProduct) : ?>
        <?php if($filling > 5) { break ; } ?>
        <?php $product = $block->getProductById($relateProduct->getId()) ?>
        <div class="mgt-product-filling">
            <span>
                <a href="<?php echo $product->getProductUrl() ?>"><?php echo substr($product->getName(),0,20); ?></a>
            </span>
        </div>
        <?php $filling++; ?>
    <?php endforeach; ?>
    <div class="clearfix"></div>
</div>
<?php endif; ?>*/ ?>
<?php //echo $block->getLayout()->createBlock('Magetop\Advancepreview\Block\ReWrites\Related')->setTemplate('Magetop_Advancepreview::product/items/relate-items.phtml')->toHtml(); ?>
<?php /*<?php if(count($lastOpens)) : ?>
    <div class="mgt-product-fillings">
        <?php $i = 0; ?>
        <?php foreach ($lastOpens as $kp => $lastOpen) : ?>
            <?php if($i > 5) { break; } ?>

            <?php if((int)$kp == $_product->getId()) { continue; } ?>
            <div class="mgt-product-filling">
                <span>

                     <a href="#"><?php echo substr($lastOpen,0,20); ?></a>
                </span>
            </div>
            <?php $i++; ?>
        <?php endforeach ?>
        <div class="clearfix"></div>
    </div>
<?php endif; ?>
*/ ?>
<?php if(count($lastOpens) > 0) : ?>
    <?php //echo $block->getLayout()->createBlock('Magetop\Advancepreview\Block\ReWrites\Related')->setLastOpend($lastOpens)->setTemplate('Magetop_Advancepreview::product/items/filling-items.phtml')->toHtml(); ?>
<?php endif; ?>
