Skip to content

Add checkout agreement position, closes #1288 #1480

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

Merged
merged 1 commit into from
Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ protected function _prepareForm()
'title' => Mage::helper('checkout')->__('Content'),
'style' => 'height:24em;',
'wysiwyg' => false,
'required' => true,
'required' => false,
));

$fieldset->addField('content_height', 'text', array(
Expand All @@ -144,6 +144,15 @@ protected function _prepareForm()
'class' => 'validate-css-length',
));

$fieldset->addField('position', 'text', array(
'label' => Mage::helper('checkout')->__('Position'),
'title' => Mage::helper('checkout')->__('Position'),
'name' => 'position',
'value' => '0',
'required' => true,
'class' => 'validate-digits',
));

$form->setValues($model->getData());
$form->setUseContainer(true);
$this->setForm($form);
Expand Down
36 changes: 34 additions & 2 deletions app/code/core/Mage/Adminhtml/Block/Checkout/Agreement/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/**
* Class Mage_Adminhtml_Block_Checkout_Agreement_Grid
*
* @method Mage_Checkout_Model_Resource_Agreement_Collection getCollection()
*/
class Mage_Adminhtml_Block_Checkout_Agreement_Grid extends Mage_Adminhtml_Block_Widget_Grid
{

/**
* Mage_Adminhtml_Block_Checkout_Agreement_Grid constructor.
*/
public function __construct()
{
parent::__construct();
Expand All @@ -35,6 +43,9 @@ public function __construct()
$this->setSaveParametersInSession(true);
}

/**
* @inheritDoc
*/
protected function _prepareCollection()
{
$collection = Mage::getModel('checkout/agreement')
Expand All @@ -43,6 +54,9 @@ protected function _prepareCollection()
return parent::_prepareCollection();
}

/**
* @inheritDoc
*/
protected function _prepareColumns()
{
$this->addColumn('agreement_id',
Expand All @@ -54,6 +68,14 @@ protected function _prepareColumns()
)
);

$this->addColumn('position', array(
'header' => Mage::helper('adminhtml')->__('Position'),
'align' =>'right',
'width' => '50px',
'index' => 'position',
'type' => 'text',
));

$this->addColumn('name',
array(
'header'=>Mage::helper('checkout')->__('Condition Name'),
Expand Down Expand Up @@ -87,12 +109,19 @@ protected function _prepareColumns()
return parent::_prepareColumns();
}

/**
* @return void
*/
protected function _afterLoadCollection()
{
$this->getCollection()->walk('afterLoad');
parent::_afterLoadCollection();
}

/**
* @param $collection
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column
*/
protected function _filterStoreCondition($collection, $column)
{
if (!$value = $column->getFilter()->getValue()) {
Expand All @@ -102,9 +131,12 @@ protected function _filterStoreCondition($collection, $column)
$this->getCollection()->addStoreFilter($value);
}

/**
* @param Mage_Checkout_Model_Agreement $row
* @return string
*/
public function getRowUrl($row)
{
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
}

}
3 changes: 2 additions & 1 deletion app/code/core/Mage/Checkout/Block/Agreements.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public function getAgreements()
} else {
$agreements = Mage::getModel('checkout/agreement')->getCollection()
->addStoreFilter(Mage::app()->getStore()->getId())
->addFieldToFilter('is_active', 1);
->addFieldToFilter('is_active', 1)
->setOrder('position', Varien_Data_Collection::SORT_ORDER_ASC);
}
$this->setAgreements($agreements);
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Checkout/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<config>
<modules>
<Mage_Checkout>
<version>1.6.0.0</version>
<version>1.6.0.1</version>
</Mage_Checkout>
</modules>
<global>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magento.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* @category Mage
* @package Mage_Checkout
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/* @var Mage_Core_Model_Resource_Setup $installer */
$installer = $this;
$installer->startSetup();

$connection = $installer->getConnection();
$table = $installer->getTable('checkout/agreement');
$column = 'position';

if (!$connection->tableColumnExists($table, $column)) {
$connection->addColumn(
$table,
$column,
array(
'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
'length' => 2,
'nullable' => false,
'default' => 0,
'comment' => 'Agreement Position'
)
);
}

$installer->endSetup();