Skip to content

Commit

Permalink
1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Magmodules committed May 30, 2017
0 parents commit 3e7ff79
Show file tree
Hide file tree
Showing 16 changed files with 558 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
*.zip
.DS_Store
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Sort By Date for Magento® 1

Sort your product listing by date to show the newest product first.

## Development by Magmodules

We are a Dutch Magento® Only Agency dedicated to the development of extensions for Magento® 1 and Magento® 2. All our extensions are coded by our own team and our support team is always there to help you out.

## Links

[Visit Magmodules.eu](https://www.magmodules.eu/)

[Terms and Conditions](https://www.magmodules.eu/terms.html)

[Contact Us](https://www.magmodules.eu/contact-us.html)
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php
/**
* Magmodules.eu - http://www.magmodules.eu
*
* 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 [email protected] so we can send you a copy immediately.
*
* @category Magmodules
* @package Magmodules_Sortbydate
* @author Magmodules <[email protected]>
* @copyright Copyright (c) 2017 (http://www.magmodules.eu)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class Magmodules_Sortbydate_Block_Adminhtml_Render_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
{

/**
* @param Varien_Data_Form_Element_Abstract $element
*
* @return mixed
*/
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{

$eavAttribute = new Mage_Eav_Model_Mysql4_Entity_Attribute();
$attributeId = $eavAttribute->getIdByCode('catalog_product', 'created_at');

if ($attributeId) {
$attributeModel = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', 'created_at');
$sort = $attributeModel['used_for_sort_by'];
if ($sort) {
$url = $this->getUrl('*/updatesort/index');
$title = Mage::helper('sortbydate')->__('Remove as listing option');
} else {
$url = $this->getUrl('*/updatesort/index');
$title = Mage::helper('sortbydate')->__('Add as listing option');
}
} else {
$url = $this->getUrl('*/updatesort/index');
$title = Mage::helper('sortbydate')->__('Add as listing option');
}

$this->setElement($element);
$html = $this->getLayout()->createBlock('adminhtml/widget_button')
->setType('button')
->setClass('scalable')
->setLabel($title)
->setOnClick("setLocation('$url')")
->toHtml();

return $html;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* Magmodules.eu - http://www.magmodules.eu
*
* 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 [email protected] so we can send you a copy immediately.
*
* @category Magmodules
* @package Magmodules_Sortbydate
* @author Magmodules <[email protected]>
* @copyright Copyright (c) 2017 (http://www.magmodules.eu)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class Magmodules_Sortbydate_Block_Adminhtml_Render_Status extends Mage_Adminhtml_Block_System_Config_Form_Field
{

/**
* @param Varien_Data_Form_Element_Abstract $element
*
* @return string
*/
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{

$eavAttribute = new Mage_Eav_Model_Mysql4_Entity_Attribute();
$attributeId = $eavAttribute->getIdByCode('catalog_product', 'created_at');

if ($attributeId) {
$attributeModel = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', 'created_at');
$sort = $attributeModel['used_for_sort_by'];
if ($sort) {
$html = '<strong>' . Mage::helper('sortbydate')->__('Installed!') . '</strong>';
} else {
$html = '<strong>' . Mage::helper('sortbydate')->__('Not Installed') . '</strong>';
}
} else {
$html = '<strong>' . Mage::helper('sortbydate')->__('Not Installed') . '</strong>';
}
return $html;
}

}
24 changes: 24 additions & 0 deletions app/code/local/Magmodules/Sortbydate/Helper/Data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* Magmodules.eu - http://www.magmodules.eu
*
* 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 [email protected] so we can send you a copy immediately.
*
* @category Magmodules
* @package Magmodules_Sortbydate
* @author Magmodules <[email protected]>
* @copyright Copyright (c) 2017 (http://www.magmodules.eu)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class Magmodules_Sortbydate_Helper_Data extends Mage_Core_Helper_Abstract
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* Magmodules.eu - http://www.magmodules.eu
*
* 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 [email protected] so we can send you a copy immediately.
*
* @category Magmodules
* @package Magmodules_Sortbydate
* @author Magmodules <[email protected]>
* @copyright Copyright (c) 2017 (http://www.magmodules.eu)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class Magmodules_Sortbydate_Model_System_Config_Source_Sorting
{

/**
* @return array
*/
public function toOptionArray()
{
$sorting = array();
$sorting[] = array('value' => '', 'label' => Mage::helper('sortbydate')->__('Default'));
$sorting[] = array('value' => '1', 'label' => Mage::helper('sortbydate')->__('Newest First'));
return $sorting;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
/**
* Magmodules.eu - http://www.magmodules.eu
*
* 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 [email protected] so we can send you a copy immediately.
*
* @category Magmodules
* @package Magmodules_Sortbydate
* @author Magmodules <[email protected]>
* @copyright Copyright (c) 2017 (http://www.magmodules.eu)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class Magmodules_Sortbydate_Adminhtml_UpdatesortController extends Mage_Adminhtml_Controller_Action
{

/**
*
*/
public function indexAction()
{
$eavAttribute = new Mage_Eav_Model_Mysql4_Entity_Attribute();
$attributeId = $eavAttribute->getIdByCode('catalog_product', 'created_at');

if($attributeId) {
$attributeModel = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', 'created_at');
$sort = $attributeModel['used_for_sort_by'];
if($sort) {
$attributeModel->setUsedForSortBy(0);
$attributeModel->save();
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('sortbydate')->__('Sort by date has been removed as listing option'));
} else {
$attributeModel->setUsedForSortBy(1);
$attributeModel->save();
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('sortbydate')->__('Sort by date has been added to the listing options'));
}
} else {
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('sortbydate')->__('Sort by date has been added to the listing options'));
}

$this->_redirect('adminhtml/system_config/edit/section/sortbydate');
}

/**
* @return mixed
*/
protected function _isAllowed()
{
return true;
}
}
50 changes: 50 additions & 0 deletions app/code/local/Magmodules/Sortbydate/etc/adminhtml.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0"?>
<!--
~ Magmodules.eu - http://www.magmodules.eu
~
~ 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 [email protected] so we can send you a copy immediately.
~
~ @category Magmodules
~ @package Magmodules_Sortbydate
~ @author Magmodules <[email protected]>
~ @copyright Copyright (c) 2017 (http://www.magmodules.eu)
~ @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
-->
<config>
<acl>
<resources>
<admin>
<children>
<updatesort translate="title" module="sortbydate">
<title>Sort By Date</title>
<sort_order>-100</sort_order>
<children>
<index translate="title">
<title>Index Action</title>
<sort_order>1</sort_order>
</index>
</children>
</updatesort>
<system>
<children>
<config>
<children>
<sortbydate translate="title" module="sortbydate">
<title>Sort by Date</title>
</sortbydate>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</config>
83 changes: 83 additions & 0 deletions app/code/local/Magmodules/Sortbydate/etc/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0"?>
<!--
~ Magmodules.eu - http://www.magmodules.eu
~
~ 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 [email protected] so we can send you a copy immediately.
~
~ @category Magmodules
~ @package Magmodules_Sortbydate
~ @author Magmodules <[email protected]>
~ @copyright Copyright (c) 2017 (http://www.magmodules.eu)
~ @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
-->
<config>
<modules>
<Magmodules_Sortbydate>
<version>1.5.0</version>
</Magmodules_Sortbydate>
</modules>
<global>
<helpers>
<sortbydate>
<class>Magmodules_Sortbydate_Helper</class>
</sortbydate>
</helpers>
<models>
<sortbydate>
<class>Magmodules_Sortbydate_Model</class>
</sortbydate>
</models>
<blocks>
<sortbydate>
<class>Magmodules_Sortbydate_Block</class>
</sortbydate>
</blocks>
<resources>
<sortbydate_setup>
<setup>
<module>Magmodules_Sortbydate</module>
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</sortbydate_setup>
</resources>
</global>
<frontend>
<translate>
<modules>
<Magmodules_Sortbydate>
<files>
<default>Magmodules_Sortbydate.csv</default>
</files>
</Magmodules_Sortbydate>
</modules>
</translate>
<layout>
<updates>
<Magmodules_Sortbydate>
<file>magmodules_sortbydate.xml</file>
</Magmodules_Sortbydate>
</updates>
</layout>
</frontend>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<magmodules_sortbydate after="Mage_Adminhtml">Magmodules_Sortbydate_Adminhtml</magmodules_sortbydate>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
Loading

0 comments on commit 3e7ff79

Please sign in to comment.