Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot call addStoreLabel for different store views on the same collection #3083

Closed
TangLiang opened this issue Mar 14, 2023 · 5 comments
Closed
Labels

Comments

@TangLiang
Copy link

OpenMage 20.1.0-rc1, There is big problem, when add more store views,you can't create customers、orders on backend.blow are the error message.

2023-03-13T16:04:49+00:00 ERR (3): 
Exception: Cannot call addStoreLabel for different store views on the same collection in web/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Collection.php:441
Stack trace:
#0 web/app/code/core/Mage/Eav/Model/Config.php(213): Mage_Eav_Model_Resource_Entity_Attribute_Collection->addStoreLabel(1)
#1 web/app/code/core/Mage/Eav/Model/Config.php(172): Mage_Eav_Model_Config->_loadEntityAttributes(Object(Mage_Eav_Model_Entity_Type), 1)
#2 web/app/code/core/Mage/Eav/Model/Config.php(532): Mage_Eav_Model_Config->_initializeStore(1)
#3 web/app/code/core/Mage/Eav/Model/Entity/Abstract.php(503): Mage_Eav_Model_Config->getEntityAttributeCodes(Object(Mage_Eav_Model_Entity_Type), Object(Mage_Customer_Model_Customer))
#4 web/app/code/core/Mage/Eav/Model/Entity/Abstract.php(938): Mage_Eav_Model_Entity_Abstract->loadAllAttributes(Object(Mage_Customer_Model_Customer))
#5 web/app/code/core/Mage/Core/Model/Abstract.php(292): Mage_Eav_Model_Entity_Abstract->load(Object(Mage_Customer_Model_Customer), 1, NULL)
#6 web/app/code/core/Mage/Adminhtml/Model/Session/Quote.php(138): Mage_Core_Model_Abstract->load(1)
#7 web/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Abstract.php(68): Mage_Adminhtml_Model_Session_Quote->getCustomer()
#8 web/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Header.php(48): Mage_Adminhtml_Block_Sales_Order_Create_Abstract->getCustomer()
#9 web/app/code/core/Mage/Core/Block/Abstract.php(933): Mage_Adminhtml_Block_Sales_Order_Create_Header->_toHtml()
#10 web/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create.php(93): Mage_Core_Block_Abstract->toHtml()
#11 web/app/design/adminhtml/default/default/template/widget/form/container.phtml(29): Mage_Adminhtml_Block_Sales_Order_Create->getHeaderHtml()
#12 web/app/code/core/Mage/Core/Block/Template.php(257): include('/home/wwwroot/l...')
#13 web/app/code/core/Mage/Core/Block/Template.php(294): Mage_Core_Block_Template->fetchView('adminhtml/defau...')
#14 web/app/code/core/Mage/Core/Block/Template.php(307): Mage_Core_Block_Template->renderView()
#15 web/app/code/core/Mage/Adminhtml/Block/Template.php(74): Mage_Core_Block_Template->_toHtml()
#16 web/app/code/core/Mage/Adminhtml/Block/Widget/Container.php(300): Mage_Adminhtml_Block_Template->_toHtml()
#17 web/app/code/core/Mage/Core/Block/Abstract.php(933): Mage_Adminhtml_Block_Widget_Container->_toHtml()
#18 web/app/code/core/Mage/Core/Block/Abstract.php(650): Mage_Core_Block_Abstract->toHtml()
#19 web/app/code/core/Mage/Core/Block/Abstract.php(594): Mage_Core_Block_Abstract->_getChildHtml('content', true)
#20 web/app/design/adminhtml/default/default/template/page.phtml(69): Mage_Core_Block_Abstract->getChildHtml('content')
#21 web/app/code/core/Mage/Core/Block/Template.php(257): include('/home/wwwroot/l...')
#22 web/app/code/core/Mage/Core/Block/Template.php(294): Mage_Core_Block_Template->fetchView('adminhtml/defau...')
#23 web/app/code/core/Mage/Core/Block/Template.php(307): Mage_Core_Block_Template->renderView()
#24 web/app/code/core/Mage/Adminhtml/Block/Template.php(74): Mage_Core_Block_Template->_toHtml()
#25 web/app/code/core/Mage/Core/Block/Abstract.php(933): Mage_Adminhtml_Block_Template->_toHtml()
#26 web/app/code/core/Mage/Core/Model/Layout.php(580): Mage_Core_Block_Abstract->toHtml()
#27 web/app/code/core/Mage/Core/Controller/Varien/Action.php(397): Mage_Core_Model_Layout->getOutput()
#28 web/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php(344): Mage_Core_Controller_Varien_Action->renderLayout()
#29 web/app/code/core/Mage/Core/Controller/Varien/Action.php(428): Mage_Adminhtml_Sales_Order_CreateController->indexAction()
#30 web/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(262): Mage_Core_Controller_Varien_Action->dispatch('index')
#31 web/app/code/core/Mage/Core/Controller/Varien/Front.php(188): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#32 web/app/code/core/Mage/Core/Model/App.php(371): Mage_Core_Controller_Varien_Front->dispatch()
#33 web/app/Mage.php(745): Mage_Core_Model_App->run(Array)
#34 web/index.php(62): Mage::run('', 'store')

blow function for v20.1.0-rc1

public function addStoreLabel($storeId)
    {
        // if not called previously
        if ($this->_addedStoreLabelsFlag === false) {
            $adapter = $this->getConnection();
            $joinExpression = $adapter
                ->quoteInto('al.attribute_id = main_table.attribute_id AND al.store_id = ?', (int)$storeId);
            $this->getSelect()->joinLeft(
                ['al' => $this->getTable('eav/attribute_label')],
                $joinExpression,
                ['store_label' => $adapter->getIfNullSql('al.value', 'main_table.frontend_label')]
            );
            $this->_addedStoreLabelsFlag = $storeId;
        } // check that previous call $storeId matches current call
        elseif ($this->_addedStoreLabelsFlag !== $storeId) {
            throw new Exception('Cannot call addStoreLabel for different store views on the same collection');
        }

        return $this;
    }

this is for 1.9.4.x

public function addStoreLabel($storeId)
    {
        $adapter        = $this->getConnection();
        $joinExpression = $adapter
            ->quoteInto('al.attribute_id = main_table.attribute_id AND al.store_id = ?', (int) $storeId);
        $this->getSelect()->joinLeft(
            ['al' => $this->getTable('eav/attribute_label')],
            $joinExpression,
            ['store_label' => $adapter->getIfNullSql('al.value', 'main_table.frontend_label')]
        );

        return $this;
    }
```````````````````
@TangLiang TangLiang added the bug label Mar 14, 2023
@fballiano
Copy link
Contributor

Hi! Did you try this same thing on the "20.0" branch version? cause maybe it could have been solved already

@elidrissidev
Copy link
Member

That exception was added in #2993.

@TangLiang
Copy link
Author

@fballiano ,yes,yes,it's fixed by the 20.0,thank you guys!

@elidrissidev
Copy link
Member

@fballiano Maybe it's time for a new rc release? so people can try the new fixes.

@fballiano
Copy link
Contributor

@elidrissidev wrote the same thing on discord a few minutes ago heheheh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants