From c158dc887752913c3ffcdaf5007b146420cc55d1 Mon Sep 17 00:00:00 2001 From: Nikolay Sumrak Date: Tue, 30 Aug 2016 17:25:26 +0300 Subject: [PATCH] Fix for Product Attribute's Conditions Fix for Product Attribute's Conditions if attribute option is deleted. Description bug: 1. Create new cart rule or edit existing. 2. Add condition with multiselect product attribute (ex. attr activity in magento2+sample data) 3. Choose one option of attribute in condition and save rule 4. Delete this option in Stores->Product attributes 5. Reload Cart Rule Page in admin 1 exception(s): Exception #0 (Exception): Warning: iconv_strlen() expects parameter 1 to be string, array given in /var/www/sources/sumrak/dev21/vendor/magento/framework/Stdlib/StringUtils.php on line 151 Exception #0 (Exception): Warning: iconv_strlen() expects parameter 1 to be string, array given in /var/www/sources/sumrak/dev21/vendor/magento/framework/Stdlib/StringUtils.php on line 151 #0 [internal function]: Magento\Framework\App\ErrorHandler->handler(2, 'iconv_strlen() ...', '/var/www/source...', 151, Array) #1 /var/www/sources/sumrak/dev21/vendor/magento/framework/Stdlib/StringUtils.php(151): iconv_strlen(Array, 'UTF-8') #2 /var/www/sources/sumrak/dev21/vendor/magento/framework/Filter/Truncate.php(76): Magento\Framework\Stdlib\StringUtils->strlen(Array) #3 /var/www/sources/sumrak/dev21/vendor/magento/framework/Filter/FilterManager.php(133): Magento\Framework\Filter\Truncate->filter(Array) #4 /var/www/sources/sumrak/dev21/vendor/magento/module-rule/Block/Editable.php(74): Magento\Framework\Filter\FilterManager->__call('truncate', Array) #5 /var/www/sources/sumrak/dev21/vendor/magento/module-rule/Block/Editable.php(74): Magento\Framework\Filter\FilterManager->truncate(Array, Array) #6 /var/www/sources/sumrak/dev21/vendor/magento/framework/Data/Form/Element/AbstractElement.php(453): Magento\Rule\Block\Editable->render(Object(Magento\Framework\Data\Form\Element\Multiselect)) #7 /var/www/sources/sumrak/dev21/vendor/magento/module-rule/Model/Condition/AbstractCondition.php(649): Magento\Framework\Data\Form\Element\AbstractElement->getHtml() #8 /var/www/sources/sumrak/dev21/vendor/magento/module-rule/Model/Condition/AbstractCondition.php(477): Magento\Rule\Model\Condition\AbstractCondition->getValueElementHtml() #9 /var/www/sources/sumrak/dev21/vendor/magento/module-rule/Model/Condition/AbstractCondition.php(488): Magento\Rule\Model\Condition\AbstractCondition->asHtml() #10 /var/www/sources/sumrak/dev21/vendor/magento/module-rule/Model/Condition/Combine.php(292): Magento\Rule\Model\Condition\AbstractCondition->asHtmlRecursive() #11 /var/www/sources/sumrak/dev21/vendor/magento/module-rule/Model/Condition/Combine.php(292): Magento\Rule\Model\Condition\Combine->asHtmlRecursive() #12 /var/www/sources/sumrak/dev21/vendor/magento/module-rule/Block/Conditions.php(19): Magento\Rule\Model\Condition\Combine->asHtmlRecursive() #13 /var/www/sources/sumrak/dev21/vendor/magento/framework/Data/Form/Element/AbstractElement.php(453): Magento\Rule\Block\Conditions->render(Object(Magento\Framework\Data\Form\Element\Text)) #14 /var/www/sources/sumrak/dev21/vendor/magento/framework/Data/Form/Element/Text.php(43): Magento\Framework\Data\Form\Element\AbstractElement->getHtml() #15 /var/www/sources/sumrak/dev21/vendor/magento/framework/Data/Form/Element/AbstractElement.php(467): Magento\Framework\Data\Form\Element\Text->getHtml() #16 /var/www/sources/sumrak/dev21/vendor/magento/framework/Data/Form/Element/Fieldset.php(229): Magento\Framework\Data\Form\Element\AbstractElement->toHtml() #17 /var/www/sources/sumrak/dev21/vendor/magento/framework/Data/Form/Element/Fieldset.php(80): Magento\Framework\Data\Form\Element\Fieldset->_elementsToHtml(Array) #18 /var/www/sources/sumrak/dev21/vendor/magento/module-catalog-rule/view/adminhtml/templates/promo/fieldset.phtml(23): Magento\Framework\Data\Form\Element\Fieldset->getChildrenHtml() #19 /var/www/sources/sumrak/dev21/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/var/www/source...') #20 /var/www/sources/sumrak/dev21/vendor/magento/framework/View/Element/Template.php(255): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Backend\Block\Widget\Form\Renderer\Fieldset), '/var/www/source...', Array) #21 /var/www/sources/sumrak/dev21/vendor/magento/framework/View/Element/Template.php(279): Magento\Framework\View\Element\Template->fetchView('/var/www/source...') #22 /var/www/sources/sumrak/dev21/vendor/magento/module-backend/Block/Template.php(104): Magento\Framework\View\Element\Template->_toHtml() #23 /var/www/sources/sumrak/dev21/vendor/magento/framework/View/Element/AbstractBlock.php(659): Magento\Backend\Block\Template->_toHtml() #24 /var/www/sources/sumrak/dev21/vendor/magento/module-backend/Block/Widget/Form/Renderer/Fieldset.php(45): Magento\Framework\View\Element\AbstractBlock->toHtml() #25 /var/www/sources/sumrak/dev21/vendor/magento/framework/Data/Form/Element/AbstractElement.php(453): Magento\Backend\Block\Widget\Form\Renderer\Fieldset->render(Object(Magento\Framework\Data\Form\Element\Fieldset)) #26 /var/www/sources/sumrak/dev21/vendor/magento/framework/Data/Form/Element/AbstractElement.php(467): Magento\Framework\Data\Form\Element\AbstractElement->getHtml() #27 /var/www/sources/sumrak/dev21/vendor/magento/framework/Data/Form.php(322): Magento\Framework\Data\Form\Element\AbstractElement->toHtml() #28 /var/www/sources/sumrak/dev21/vendor/magento/framework/Data/Form.php(337): Magento\Framework\Data\Form->toHtml() #29 /var/www/sources/sumrak/dev21/vendor/magento/module-backend/Block/Widget/Form.php(98): Magento\Framework\Data\Form->getHtml() #30 /var/www/sources/sumrak/dev21/vendor/magento/module-backend/view/adminhtml/templates/widget/form.phtml(15): Magento\Backend\Block\Widget\Form->getFormHtml() #31 /var/www/sources/sumrak/dev21/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/var/www/source...') #32 /var/www/sources/sumrak/dev21/vendor/magento/framework/View/Element/Template.php(255): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Conditions), '/var/www/source...', Array) #33 /var/www/sources/sumrak/dev21/vendor/magento/framework/View/Element/Template.php(279): Magento\Framework\View\Element\Template->fetchView('/var/www/source...') #34 /var/www/sources/sumrak/dev21/vendor/magento/module-backend/Block/Template.php(104): Magento\Framework\View\Element\Template->_toHtml() #35 /var/www/sources/sumrak/dev21/vendor/magento/framework/View/Element/AbstractBlock.php(659): Magento\Backend\Block\Template->_toHtml() #36 /var/www/sources/sumrak/dev21/vendor/magento/module-ui/Component/HtmlContent.php(50): Magento\Framework\View\Element\AbstractBlock->toHtml() #37 /var/www/sources/sumrak/dev21/vendor/magento/framework/View/Layout/Generator/UiComponent.php(148): Magento\Ui\Component\HtmlContent->prepare() #38 /var/www/sources/sumrak/dev21/vendor/magento/framework/View/Layout/Generator/UiComponent.php(145): Magento\Framework\View\Layout\Generator\UiComponent->prepareComponent(Object(Magento\Ui\Component\HtmlContent)) #39 /var/www/sources/sumrak/dev21/vendor/magento/framework/View/Layout/Generator/UiComponent.php(145): Magento\Framework\View\Layout\Generator\UiComponent->prepareComponent(Object(Magento\Ui\Component\Container)) #40 /var/www/sources/sumrak/dev21/vendor/magento/framework/View/Layout/Generator/UiComponent.php(145): Magento\Framework\View\Layout\Generator\UiComponent->prepareComponent(Object(Magento\Ui\Component\Form\Fieldset)) #41 /var/www/sources/sumrak/dev21/vendor/magento/framework/View/Layout/Generator/UiComponent.php(126): Magento\Framework\View\Layout\Generator\UiComponent->prepareComponent(Object(Magento\Ui\Component\Form)) #42 /var/www/sources/sumrak/dev21/vendor/magento/framework/View/Layout/Generator/UiComponent.php(93): Magento\Framework\View\Layout\Generator\UiComponent->generateComponent(Object(Magento\Framework\View\Layout\Data\Structure), 'sales_rule_form', Array, Object(Magento\Framework\View\Layout\Interceptor)) #43 /var/www/sources/sumrak/dev21/vendor/magento/framework/View/Layout/GeneratorPool.php(86): Magento\Framework\View\Layout\Generator\UiComponent->process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context)) #44 /var/www/sources/sumrak/dev21/vendor/magento/framework/View/Layout.php(327): Magento\Framework\View\Layout\GeneratorPool->process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context)) #45 /var/www/sources/sumrak/dev21/var/generation/Magento/Framework/View/Layout/Interceptor.php(89): Magento\Framework\View\Layout->generateElements() #46 /var/www/sources/sumrak/dev21/vendor/magento/framework/View/Layout/Builder.php(129): Magento\Framework\View\Layout\Interceptor->generateElements() #47 /var/www/sources/sumrak/dev21/vendor/magento/framework/View/Page/Builder.php(55): Magento\Framework\View\Layout\Builder->generateLayoutBlocks() #48 /var/www/sources/sumrak/dev21/vendor/magento/framework/View/Layout/Builder.php(65): Magento\Framework\View\Page\Builder->generateLayoutBlocks() #49 /var/www/sources/sumrak/dev21/vendor/magento/framework/View/Layout.php(244): Magento\Framework\View\Layout\Builder->build() #50 /var/www/sources/sumrak/dev21/vendor/magento/framework/View/Layout.php(859): Magento\Framework\View\Layout->build() #51 /var/www/sources/sumrak/dev21/var/generation/Magento/Framework/View/Layout/Interceptor.php(414): Magento\Framework\View\Layout->getBlock('promo_sales_rul...') #52 /var/www/sources/sumrak/dev21/vendor/magento/module-sales-rule/Controller/Adminhtml/Promo/Quote/Edit.php(59): Magento\Framework\View\Layout\Interceptor->getBlock('promo_sales_rul...') #53 /var/www/sources/sumrak/dev21/var/generation/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Edit/Interceptor.php(24): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\Edit->execute() #54 /var/www/sources/sumrak/dev21/vendor/magento/framework/App/Action/Action.php(102): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\Edit\Interceptor->execute() #55 /var/www/sources/sumrak/dev21/vendor/magento/module-backend/App/AbstractAction.php(226): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http)) #56 /var/www/sources/sumrak/dev21/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Backend\App\AbstractAction->dispatch(Object(Magento\Framework\App\Request\Http)) #57 /var/www/sources/sumrak/dev21/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\Edit\Interceptor->___callParent('dispatch', Array) #58 /var/www/sources/sumrak/dev21/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\SalesRu...', 'dispatch', Object(Magento\SalesRule\Controller\Adminhtml\Promo\Quote\Edit\Interceptor), Array, 'adminAuthentica...') #59 /var/www/sources/sumrak/dev21/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http)) #60 /var/www/sources/sumrak/dev21/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Magento\SalesRule\Controller\Adminhtml\Promo\Quote\Edit\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http)) #61 /var/www/sources/sumrak/dev21/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\SalesRu...', 'dispatch', Object(Magento\SalesRule\Controller\Adminhtml\Promo\Quote\Edit\Interceptor), Array, 'adminMassaction...') #62 /var/www/sources/sumrak/dev21/vendor/magento/module-backend/App/Action/Plugin/MassactionKey.php(33): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\Edit\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http)) #63 /var/www/sources/sumrak/dev21/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Backend\App\Action\Plugin\MassactionKey->aroundDispatch(Object(Magento\SalesRule\Controller\Adminhtml\Promo\Quote\Edit\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http)) #64 /var/www/sources/sumrak/dev21/var/generation/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Edit/Interceptor.php(39): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\Edit\Interceptor->___callPlugins('dispatch', Array, Array) #65 /var/www/sources/sumrak/dev21/vendor/magento/framework/App/FrontController.php(55): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\Edit\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http)) #66 /var/www/sources/sumrak/dev21/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http)) #67 /var/www/sources/sumrak/dev21/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array) #68 /var/www/sources/sumrak/dev21/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install') #69 /var/www/sources/sumrak/dev21/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http)) #70 /var/www/sources/sumrak/dev21/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http)) #71 /var/www/sources/sumrak/dev21/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array) #72 /var/www/sources/sumrak/dev21/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http)) #73 /var/www/sources/sumrak/dev21/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch() #74 /var/www/sources/sumrak/dev21/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http)) --- app/code/Magento/Rule/Model/Condition/AbstractCondition.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/code/Magento/Rule/Model/Condition/AbstractCondition.php b/app/code/Magento/Rule/Model/Condition/AbstractCondition.php index cbab59a95a3e0..8224694794cab 100644 --- a/app/code/Magento/Rule/Model/Condition/AbstractCondition.php +++ b/app/code/Magento/Rule/Model/Condition/AbstractCondition.php @@ -441,6 +441,8 @@ public function getValueName() } if (!empty($valueArr)) { $value = implode(', ', $valueArr); + } elseif(is_array($value)) { + $value = implode(', ', $value); } return $value; }