<?php

namespace ArtabanMarketplace\Model;

use ArtabanMarketplace\Model\Base\AmpSellerProductQuery as BaseAmpSellerProductQuery;

/**
 * Skeleton subclass for performing query and update operations on the 'amp_seller_product' table.
 *
 *
 *
 * You should add additional methods to this class to meet the
 * application requirements.  This class will only be generated as
 * long as it does not already exist in the output directory.
 *
 */

/**
 * Check if a AmpSellerProduct exists
 *
 * @param     integer $sellerId
 * @param     integer $productId
 *
 * @return    Boolean
 */
class AmpSellerProductQuery extends BaseAmpSellerProductQuery {

    public function existsAmpSellerProduct($sellerId, $productId) {
        $ampSellerProductFromSeller = BaseAmpSellerProductQuery::create()->filterByAmpSellerId($sellerId);
        $ampSellerProductFromProduct = BaseAmpSellerProductQuery::create()->filterByProductId($productId);

        $ampSellerProductFromSellerArray = array();
        foreach ($ampSellerProductFromSeller as $item) {
            $ampSellerProductFromSellerArray[] = $item->getId();
        }

        $ampSellerProductFromProductArray = array();
        foreach ($ampSellerProductFromProduct as $item) {
            $ampSellerProductFromProductArray[] = $item->getId();
        }

        $ampSellerProductCommonArray = array();
        $ampSellerProductCommonArray = array_intersect($ampSellerProductFromSellerArray, $ampSellerProductFromProductArray);

        $out = !empty($ampSellerProductCommonArray);

        return $out;
    }

}

// AmpSellerProductQuery