cancel
Showing results for 
Search instead for 
Did you mean: 

Warning: count(): Parameter must be an array or an object that implements Countable

Warning: count(): Parameter must be an array or an object that implements Countable

I got this error on my Magic Slider Log

can please can help me?

1 exception(s):
Exception #0 (Exception): Notice: Undefined index: media_gallery in /home/foodyolr/public_html/app/code/Magiccart/Magicslider/Block/Adminhtml/Magicslider/Helper/Grid/Image.php on line 61

Exception #0 (Exception): Notice: Undefined index: media_gallery in /home/foodyolr/public_html/app/code/Magiccart/Magicslider/Block/Adminhtml/Magicslider/Helper/Grid/Image.php on line 61
<pre>#1 Magiccart\Magicslider\Block\Adminhtml\Magicslider\Helper\Grid\Image->render(&Magiccart\Magicslider\Model\Magicslider#000000005a1e19d500000000011f476b#) called at [vendor/magento/module-backend/Block/Widget/Grid/Column.php:279]
#2 Magento\Backend\Block\Widget\Grid\Column->getRowField(&Magiccart\Magicslider\Model\Magicslider#000000005a1e19d500000000011f476b#) called at [vendor/magento/module-backend/view/adminhtml/templates/widget/grid/extended.phtml:191]
#3 include('/home/foodyolr/p...') called at [vendor/magento/framework/View/TemplateEngine/Php.php:59]
#4 Magento\Framework\View\TemplateEngine\Php->render(&Magiccart\Magicslider\Block\Adminhtml\Magicslider\Grid#000000005a1e300600000000011f476b#, '/home/foodyolr/p...', array()) called at [vendor/magento/framework/View/Element/Template.php:271]
#5 Magento\Framework\View\Element\Template->fetchView('/home/foodyolr/p...') called at [vendor/magento/framework/View/Element/Template.php:301]
#6 Magento\Framework\View\Element\Template->_toHtml() called at [vendor/magento/module-backend/Block/Template.php:129]
#7 Magento\Backend\Block\Template->_toHtml() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1097]
#8 Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1101]
#9 Magento\Framework\View\Element\AbstractBlock->_loadCache() called at [vendor/magento/framework/View/Element/AbstractBlock.php:671]
#10 Magento\Framework\View\Element\AbstractBlock->toHtml() called at [vendor/magento/framework/View/Layout.php:557]
#11 Magento\Framework\View\Layout->_renderBlock('adminhtml_magics...') called at [vendor/magento/framework/View/Layout.php:533]
#12 Magento\Framework\View\Layout->renderNonCachedElement('adminhtml_magics...') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#13 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('adminhtml_magics...') called at [vendor/magento/framework/View/Layout.php:488]
#14 Magento\Framework\View\Layout->renderElement('adminhtml_magics...', true) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#15 Magento\Framework\View\Layout\Interceptor->renderElement('adminhtml_magics...', true) called at [vendor/magento/framework/View/Element/AbstractBlock.php:518]
#16 Magento\Framework\View\Element\AbstractBlock->getChildHtml('grid') called at [vendor/magento/module-backend/Block/Widget/Grid/Container.php:119]
#17 Magento\Backend\Block\Widget\Grid\Container->getGridHtml() called at [vendor/magento/module-backend/view/adminhtml/templates/widget/grid/container.phtml:10]
#18 include('/home/foodyolr/p...') called at [vendor/magento/framework/View/TemplateEngine/Php.php:59]
#19 Magento\Framework\View\TemplateEngine\Php->render(&Magiccart\Magicslider\Block\Adminhtml\Magicslider#000000005a1e303600000000011f476b#, '/home/foodyolr/p...', array()) called at [vendor/magento/framework/View/Element/Template.php:271]
#20 Magento\Framework\View\Element\Template->fetchView('/home/foodyolr/p...') called at [vendor/magento/framework/View/Element/Template.php:301]
#21 Magento\Framework\View\Element\Template->_toHtml() called at [vendor/magento/module-backend/Block/Template.php:129]
#22 Magento\Backend\Block\Template->_toHtml() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1097]
#23 Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1101]
#24 Magento\Framework\View\Element\AbstractBlock->_loadCache() called at [vendor/magento/framework/View/Element/AbstractBlock.php:671]
#25 Magento\Framework\View\Element\AbstractBlock->toHtml() called at [vendor/magento/framework/View/Layout.php:557]
#26 Magento\Framework\View\Layout->_renderBlock('admin.block.magi...') called at [vendor/magento/framework/View/Layout.php:533]
#27 Magento\Framework\View\Layout->renderNonCachedElement('admin.block.magi...') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#28 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('admin.block.magi...') called at [vendor/magento/framework/View/Layout.php:488]
#29 Magento\Framework\View\Layout->renderElement('admin.block.magi...', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#30 Magento\Framework\View\Layout\Interceptor->renderElement('admin.block.magi...', false) called at [vendor/magento/framework/View/Layout.php:585]
#31 Magento\Framework\View\Layout->_renderContainer('content', false) called at [vendor/magento/framework/View/Layout.php:535]
#32 Magento\Framework\View\Layout->renderNonCachedElement('content') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#33 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('content') called at [vendor/magento/framework/View/Layout.php:488]
#34 Magento\Framework\View\Layout->renderElement('content', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#35 Magento\Framework\View\Layout\Interceptor->renderElement('content', false) called at [vendor/magento/framework/View/Layout.php:585]
#36 Magento\Framework\View\Layout->_renderContainer('main.col', false) called at [vendor/magento/framework/View/Layout.php:535]
#37 Magento\Framework\View\Layout->renderNonCachedElement('main.col') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#38 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('main.col') called at [vendor/magento/framework/View/Layout.php:488]
#39 Magento\Framework\View\Layout->renderElement('main.col', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#40 Magento\Framework\View\Layout\Interceptor->renderElement('main.col', false) called at [vendor/magento/framework/View/Layout.php:585]
#41 Magento\Framework\View\Layout->_renderContainer('admin.scope.col....', false) called at [vendor/magento/framework/View/Layout.php:535]
#42 Magento\Framework\View\Layout->renderNonCachedElement('admin.scope.col....') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#43 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('admin.scope.col....') called at [vendor/magento/framework/View/Layout.php:488]
#44 Magento\Framework\View\Layout->renderElement('admin.scope.col....', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#45 Magento\Framework\View\Layout\Interceptor->renderElement('admin.scope.col....', false) called at [vendor/magento/framework/View/Layout.php:585]
#46 Magento\Framework\View\Layout->_renderContainer('page.main.contai...', false) called at [vendor/magento/framework/View/Layout.php:535]
#47 Magento\Framework\View\Layout->renderNonCachedElement('page.main.contai...') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#48 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('page.main.contai...') called at [vendor/magento/framework/View/Layout.php:488]
#49 Magento\Framework\View\Layout->renderElement('page.main.contai...', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#50 Magento\Framework\View\Layout\Interceptor->renderElement('page.main.contai...', false) called at [vendor/magento/framework/View/Layout.php:585]
#51 Magento\Framework\View\Layout->_renderContainer('page.content', false) called at [vendor/magento/framework/View/Layout.php:535]
#52 Magento\Framework\View\Layout->renderNonCachedElement('page.content') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#53 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('page.content') called at [vendor/magento/framework/View/Layout.php:488]
#54 Magento\Framework\View\Layout->renderElement('page.content', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#55 Magento\Framework\View\Layout\Interceptor->renderElement('page.content', false) called at [vendor/magento/framework/View/Layout.php:585]
#56 Magento\Framework\View\Layout->_renderContainer('page.wrapper', false) called at [vendor/magento/framework/View/Layout.php:535]
#57 Magento\Framework\View\Layout->renderNonCachedElement('page.wrapper') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#58 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('page.wrapper') called at [vendor/magento/framework/View/Layout.php:488]
#59 Magento\Framework\View\Layout->renderElement('page.wrapper', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#60 Magento\Framework\View\Layout\Interceptor->renderElement('page.wrapper', false) called at [vendor/magento/framework/View/Layout.php:585]
#61 Magento\Framework\View\Layout->_renderContainer('backend.page', false) called at [vendor/magento/framework/View/Layout.php:535]
#62 Magento\Framework\View\Layout->renderNonCachedElement('backend.page') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#63 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('backend.page') called at [vendor/magento/framework/View/Layout.php:488]
#64 Magento\Framework\View\Layout->renderElement('backend.page', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#65 Magento\Framework\View\Layout\Interceptor->renderElement('backend.page', false) called at [vendor/magento/framework/View/Layout.php:585]
#66 Magento\Framework\View\Layout->_renderContainer('root', false) called at [vendor/magento/framework/View/Layout.php:535]
#67 Magento\Framework\View\Layout->renderNonCachedElement('root') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#68 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('root') called at [vendor/magento/framework/View/Layout.php:488]
#69 Magento\Framework\View\Layout->renderElement('root', true) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#70 Magento\Framework\View\Layout\Interceptor->renderElement('root') called at [vendor/magento/framework/View/Layout.php:954]
#71 Magento\Framework\View\Layout->getOutput() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:492]
#72 Magento\Framework\View\Layout\Interceptor->getOutput() called at [vendor/magento/framework/View/Result/Page.php:258]
#73 Magento\Framework\View\Result\Page->render(&Magento\Framework\App\Response\Http\Interceptor#000000005a1e37e100000000011f476b#) called at [vendor/magento/framework/View/Result/Layout.php:171]
#74 Magento\Framework\View\Result\Layout->renderResult(&Magento\Framework\App\Response\Http\Interceptor#000000005a1e37e100000000011f476b#) called at [generated/code/Magento/Backend/Model/View/Result/Page/Interceptor.php:193]
#75 Magento\Backend\Model\View\Result\Page\Interceptor->renderResult(&Magento\Framework\App\Response\Http\Interceptor#000000005a1e37e100000000011f476b#) called at [vendor/magento/framework/App/Http.php:141]
#76 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24]
#77 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:261]
#78 Magento\Framework\App\Bootstrap->run(&Magento\Framework\App\Http\Interceptor#000000005a1e37ee00000000011f476b#) called at [index.php:39]
</pre>

 

 

2 REPLIES 2

Re: Warning: count(): Parameter must be an array or an object that implements Countable

@dhavisdjgm7fa4 

 

are you using php -7.2? if yes might be this plugin not compatible with php 7.2.

 

Reason why it's happening, in php7.2 count on null throws warning, see https://www.php.net/manual/en/migration72.incompatible.php 

 

https://mage2.pro/t/topic/5238

Manish Mittal
https://www.manishmittal.com/

Re: Warning: count(): Parameter must be an array or an object that implements Countable

Hi @dhavisdjgm7fa4 

To resolve According to expcetion "1 exception(s):Exception #0 (Exception): Notice: Undefined index: media_gallery".

For better practice you can try to use Magento2 Service Layer. You can save a new image using \Magento\Catalog\Api\ProductAttributeMediaGalleryManagementInterface::create

Under the method the attribute "media_gallery" will be set and then \Magento\Catalog\Api\ProductRepositoryInterface::save will be invoked. And inside of this method the method \Magento\Catalog\Model\Product\Gallery\Processor::addImage will be invoked, which basically invoked, when you run addImageToMediaGallery.

It may help you to resolve issue.