<?php

namespace Magetop\Agency\Model\Plugin;

use Magento\Catalog\Model\Product as CatalogProduct;

class Product
{
    public function __construct(
        \Magetop\Agency\Helper\Data $helper
    ) {
        $this->_helper = $helper;
    }
    
    public function afterIsSalable(CatalogProduct $subject, $result)
    {
        $productId = $subject->getId();
        $allProducts = $this->_helper->getAssignProductCollection($productId);
        if (count($allProducts) > 0) {
            return true;
        }
        
        return $result;
    }
}
