It's caused by the fact that your model constructor does not match your original model constructor.
So this is the constructor from Magento\Newsletter\Model\Queue
:
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Newsletter\Model\Template\Filter $templateFilter,
\Magento\Framework\Stdlib\DateTime\DateTime $date,
\Magento\Newsletter\Model\TemplateFactory $templateFactory,
\Magento\Newsletter\Model\ProblemFactory $problemFactory,
\Magento\Newsletter\Model\ResourceModel\Subscriber\CollectionFactory $subscriberCollectionFactory,
\Magento\Newsletter\Model\Queue\TransportBuilder $transportBuilder,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
) {
parent::__construct(
$context,
$registry,
$resource,
$resourceCollection,
$data
);
$this->_templateFilter = $templateFilter;
$this->_date = $date;
$this->_templateFactory = $templateFactory;
$this->_problemFactory = $problemFactory;
$this->_subscribersCollection = $subscriberCollectionFactory->create();
$this->_transportBuilder = $transportBuilder;
}
To fix your constructor it needs to be:
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Newsletter\Model\Template\Filter $templateFilter,
\Magento\Framework\Stdlib\DateTime\DateTime $date,
\Magento\Newsletter\Model\TemplateFactory $templateFactory,
\Magento\Newsletter\Model\ProblemFactory $problemFactory,
\Magento\Newsletter\Model\ResourceModel\Subscriber\CollectionFactory $subscriberCollectionFactory,
\Magento\Newsletter\Model\Queue\TransportBuilder $transportBuilder,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
\Vendor\Module\Block\Testing $customergroup,
\Magento\Customer\Model\ResourceModel\Group\Collection $customergroupdata,
array $data = []
)
{
$this->_customergroup = $customergroup;
$this->_customergroupdata = $customergroupdata;
parent::__construct(
$context,
$registry,
$templateFilter,
$date,
$templateFactory,
$problemFactory,
$subscriberCollectionFactory,
$transportBuilder,
$resource,
$resourceCollection,
$data
);
}
There is a function available in PHP (>=7.3) which checks if a variable is countable is_countable
Try it like
if (is_countable($bannerGroupData) && count($bannerGroupData) > 0):
// Your code
endif;
If the function is not available, you can use below
if (($bannerGroupData instanceof Countable) || is_array($bannerGroupData)) && count($bannerGroupData) > 0):
// Your code
endif;
Best Answer
Remove
count
andreturn
direct$model->getConditions()
addprint_r
and check what result you are getting. You will know what you have to do after that