0

I had this block of code for long time but it suddenly stopped working:

PHP Fatal error: Call to undefined method Model\ResourceModel\Campaign\Collection::getCollection()

My code is this:

 $campaignLimit = $this->_campaignCollection->create()
            ->getCollection()
            ->addFieldToFilter('email', $email)
            ->addFieldToFilter('event_name', 'Lost Basket')
            ->addFieldToFilter('sent_at', $updated)
            ->count();

All necessary classes are injected in the constructor

1

You already create collection object using $this->_campaignCollection->create(), No need to call again ->getCollection().

Try following way:

$campaignLimit = $this->_campaignCollection->create()
            ->addFieldToFilter('email', $email)
            ->addFieldToFilter('event_name', 'Lost Basket')
            ->addFieldToFilter('sent_at', $updated)
            ->count();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.