1

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 admiview
  • 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 exists in DB; note that in sql there isn't the prefix to table.

1
  • Are you able to query agreement table from other cliet (cli or workbench or similar)?
    – Zefiryn
    Oct 3 '18 at 20:09
1

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 below

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 [];
}
1

In /vendor/magento/module-checkout-agreements/Model/ResourceModel/Agreement/Grid/Collection.php it is enough to change:

$select = $this->getConnection()->select()->from(
    ['agreement_store' => 'checkout_agreement_store']

To:

$select = $this->getConnection()->select()->from(
    ['agreement_store' => $this->getTable('checkout_agreement_store')]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.