I have just upgraded my magento from 2.4.0 to 2.4.6 and also upgraded my php 7.4 to 8.2. All the commands are running fine but while reindexing i am getting this error and on frontend also. Can anyone tell me why this error is showing on frontend
Type Error occurred when creating object: Ves\Brand\Model\Brand, Ves\Brand\Model\Brand::__construct(): Argument #3 ($resource) must be of type ?Ves\Brand\Model\ResourceModel\Brand, Jes\ExtendCoreModules\Model\ResourceModel\Brand given, called in /home/websites/hollywoo/dev/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 121
<?php
namespace Ves\Brand\Model;
use Magento\Framework\DataObject\IdentityInterface;
/**
* Brand Model
*/
class Brand extends \Magento\Framework\Model\AbstractModel
{
const STATUS_ENABLED = 1;
const STATUS_DISABLED = 0;
const ATTRIBUTE_CODE = "product_brand";
/**
* Product collection factory
*
* @var \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory
*/
protected $_productCollectionFactory;
/** @var \Magento\Store\Model\StoreManagerInterface */
protected $_storeManager;
/**
* URL Model instance
*
* @var \Magento\Framework\UrlInterface
*/
protected $_url;
/**
* @var \Magento\Catalog\Helper\Category
*/
protected $_brandHelper;
protected $_eventPrefix = 'vesbrand_brand';
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Ves\Brand\Model\ResourceModel\Brand|null $resource
* @param \Ves\Brand\Model\ResourceModel\Brand\Collection|null $resourceCollection
* @param \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\UrlInterface $url
* @param \Ves\Brand\Helper\Data $brandHelper
* @param array $data
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Ves\Brand\Model\ResourceModel\Brand $resource = null,
\Ves\Brand\Model\ResourceModel\Brand\Collection $resourceCollection = null,
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\UrlInterface $url,
\Ves\Brand\Helper\Data $brandHelper,
array $data = []
) {
$this->_storeManager = $storeManager;
$this->_url = $url;
$this->_productCollectionFactory = $productCollectionFactory;
$this->_brandHelper = $brandHelper;
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
}
/**
* Initialize customer model
*
* @return void
*/
public function _construct()
{
$this->_init('Ves\Brand\Model\ResourceModel\Brand');
}
/**
* Prepare page's statuses.
* Available event cms_page_get_available_statuses to customize statuses.
*
* @return array
*/
public function getAvailableStatuses()
{
return [self::STATUS_ENABLED => __('Enabled'), self::STATUS_DISABLED => __('Disabled')];
}
/**
* Check if page identifier exist for specific store
* return page id if page exists
*
* @param string $identifier
* @param int $storeId
* @return int
*/
public function checkIdentifier($identifier, $storeId)
{
return $this->_getResource()->checkIdentifier($identifier, $storeId);
}
/**
* Get category products collection
*
* @return \Magento\Framework\Data\Collection\AbstractDb
*/
public function getProductCollection()
{
$collection = $this->_productCollectionFactory->create()->addAttributeToSelect('*')->addAttributeToFilter('product_brand',array('eq'=>$this->getId()));
return $collection;
}
public function getUrl()
{
$url = $this->_storeManager->getStore()->getBaseUrl();
$route = $this->_brandHelper->getConfig('general_settings/route');
$url_prefix = $this->_brandHelper->getConfig('general_settings/url_prefix');
$urlPrefix = '';
if($url_prefix){
$urlPrefix = $url_prefix.'/';
}
$url_suffix = $this->_brandHelper->getConfig('general_settings/url_suffix');
return $url.$urlPrefix.$this->getUrlKey().$url_suffix;
}
/**
* Retrive image URL
*
* @return string
*/
public function getImageUrl()
{
$url = false;
$image = $this->getImage();
if ($image) {
$url = $this->_storeManager->getStore()->getBaseUrl(
\Magento\Framework\UrlInterface::URL_TYPE_MEDIA
) . $image;
};
return $url;
}
public function loadByBrandName($brand_name = "") {
if($brand_name) {
$brand_id = $this->_getResource()->getBrandIdByName($brand_name);
if($brand_id) {
$this->load((int)$brand_id);
}
}
return $this;
}
public function saveProduct($product_id = "0") {
if($product_id) {
$this->_getResource()->saveProduct($this, $product_id);
}
return $this;
}
public function deleteBrandsByProduct($product_id = "0"){
if($product_id) {
$this->_getResource()->deleteBrandsByProduct($product_id);
}
return $this;
}
/**
* Retrive thumbnail URL
*
* @return string
*/
public function getThumbnailUrl()
{
$url = false;
$thumbnail = $this->getThumbnail();
if ($thumbnail) {
$url = $this->_storeManager->getStore()->getBaseUrl(
\Magento\Framework\UrlInterface::URL_TYPE_MEDIA
) . $thumbnail;
};
return $url;
}