-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Magmodules
committed
May 30, 2017
0 parents
commit 3e7ff79
Showing
16 changed files
with
558 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea | ||
*.zip | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
60 changes: 60 additions & 0 deletions
60
app/code/local/Magmodules/Sortbydate/Block/Adminhtml/Render/Button.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
app/code/local/Magmodules/Sortbydate/Block/Adminhtml/Render/Status.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
app/code/local/Magmodules/Sortbydate/Model/System/Config/Source/Sorting.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
app/code/local/Magmodules/Sortbydate/controllers/Adminhtml/UpdatesortController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.