<?php
 namespace App\EntityMatch; class SupplierProduct extends \App\EntityMatch\BaseAbstract { protected $exportFields = ['productName', 'serviceCode', 'destinationCountryCode', 'destinationCityId']; protected $matchingFilteringSQL = 'AND ent.deleted=0 AND ent.idRealSupplierProduct=0'; protected $entityClassName = '\Entity\SupplierProduct'; private $serviceCodeFilter; private $countryCodeFilter; private $cityIdFilter; protected function setTableName() { global $DBTSuppliersProducts; $this->tableName = $DBTSuppliersProducts; } public function setProductName($value, $useWildcard=true) { $this->setSearchCriterion('productName', $value, $useWildcard); } public function filterByServiceCode($value) { $this->serviceCodeFilter = $value; } public function filterByCountryCode($value) { $this->countryCodeFilter = $value; } public function filterByCityId($value) { $this->cityIdFilter = $value; } protected function cleanMatches() { if ($this->serviceCodeFilter or $this->countryCodeFilter or $this->cityIdFilter) { foreach($this->bulkMatches as $idx=>$matchesList) { foreach($matchesList as $entCode=>$entDet) { if ($this->serviceCodeFilter and $entDet['serviceCode']!=$this->serviceCodeFilter) { unset($this->bulkMatches[$idx][$entCode]); } if ($this->countryCodeFilter and $entDet['destinationCountryCode'] and $entDet['destinationCountryCode']!=$this->countryCodeFilter) { unset($this->bulkMatches[$idx][$entCode]); } if ($this->cityIdFilter and $entDet['destinationCityId'] and $entDet['destinationCityId']!=$this->cityIdFilter) { unset($this->bulkMatches[$idx][$entCode]); } } } $this->bulkMatches = array_filter($this->bulkMatches); } } } 