cancel
Showing results for 
Search instead for 
Did you mean: 

checkout_agreement_store doesn't exist

SOLVED

checkout_agreement_store doesn't exist

Hi, any idea?

Preconditions
Starting from Magento CE 2.2.5
upgrade from 2.2.5 to 2.2.6
Steps to reproduce
Starting from Magento CE 2.2.5
created a terms and conditions (Store-->Terms and conditions)
upgrade from 2.2.5 to 2.2.6
The Terms and conditions created are not visible in admin (Store-->Terms and conditions)
Expected result
I can edit the old terms and conditions
I can insert a new terms and conditions
Actual result
old terms and conditions are not visible
In production mode I can add a new terms and conditions but is not visible in admin
In developer mode there is an exception:
2 exception(s):
Exception #0 (Zend_Db_Statement_Exception): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'XXXXXX.checkout_agreement_store' doesn't exist, query was: SELECT agreement_store.* FROM checkout_agreement_store AS agreement_store WHERE (agreement_store.agreement_id IN ('1'))
Exception #1 (PDOException): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'XXXXXX.checkout_agreement_store' doesn't exist

The table exist in DB; note that in sql there isn't the prefix to table.
1 ACCEPTED SOLUTION

Accepted Solutions

Re: checkout_agreement_store doesn't exist

HI,
I find the issue and the solution
In /vendor/magento/module-checkout-agreements/Model/ResourceModel/Agreement/Grid/Collection.php
There is an issue:

private function getStoresForAgreements()
    {
        $agreementId = $this->getColumnValues('agreement_id');

        if (!empty($agreementId)) {
            $select = $this->getConnection()->select()->from(
                ['agreement_store' => 'checkout_agreement_store']
            )->where(
                'agreement_store.agreement_id IN (?)',
                $agreementId
            );

            return $this->getConnection()->fetchAll($select);
        }

        return [];
    }

Change with

private function getStoresForAgreements()
    {
        $agreementId = $this->getColumnValues('agreement_id');

        if (!empty($agreementId)) {
            $select = $this->getConnection()->select()->from(
                [$this->getTable('agreement_store') => $this->getTable('checkout_agreement_store')]
            )->where(
                $this->getTable('agreement_store').'.agreement_id IN (?)',
                $agreementId
            );

            return $this->getConnection()->fetchAll($select);
        }

        return [];
    }

View solution in original post

1 REPLY 1

Re: checkout_agreement_store doesn't exist

HI,
I find the issue and the solution
In /vendor/magento/module-checkout-agreements/Model/ResourceModel/Agreement/Grid/Collection.php
There is an issue:

private function getStoresForAgreements()
    {
        $agreementId = $this->getColumnValues('agreement_id');

        if (!empty($agreementId)) {
            $select = $this->getConnection()->select()->from(
                ['agreement_store' => 'checkout_agreement_store']
            )->where(
                'agreement_store.agreement_id IN (?)',
                $agreementId
            );

            return $this->getConnection()->fetchAll($select);
        }

        return [];
    }

Change with

private function getStoresForAgreements()
    {
        $agreementId = $this->getColumnValues('agreement_id');

        if (!empty($agreementId)) {
            $select = $this->getConnection()->select()->from(
                [$this->getTable('agreement_store') => $this->getTable('checkout_agreement_store')]
            )->where(
                $this->getTable('agreement_store').'.agreement_id IN (?)',
                $agreementId
            );

            return $this->getConnection()->fetchAll($select);
        }

        return [];
    }