{"id":360,"date":"2011-06-06T23:02:05","date_gmt":"2011-06-06T22:02:05","guid":{"rendered":"https:\/\/greladesign.co\/blog\/?p=360"},"modified":"2011-07-14T16:52:25","modified_gmt":"2011-07-14T15:52:25","slug":"modify-admin-dashboards-default-period-time-select-range","status":"publish","type":"post","link":"https:\/\/greladesign.co\/blog\/2011\/06\/06\/modify-admin-dashboards-default-period-time-select-range\/","title":{"rendered":"Modify admin dashboard&#8217;s default period time (&#8220;Select range&#8221;)"},"content":{"rendered":"<p>Hi, <\/p>\n<p>by default on dashboard you will see results from last 24hours, if you want to have it by default in different time span than you will be in trouble as there is no facility to set it up.<br \/>\n<!--more--><br \/>\nYou can do something however to remedy this, you will need to modify some core files, and as I do not suggest modifying original files we need to copy them to local code pool as described in this <a href=\"https:\/\/greladesign.co\/blog\/2010\/09\/19\/patching-magento\/\">post<\/a>.<\/p>\n<p>Copy following files:<\/p>\n<ol>\n<li>magento\\app\\code\\<strong>core<\/strong>\\Mage\\Adminhtml\\Block\\Dashboard\\Tab\\Amounts.php<\/li>\n<li>magento\\app\\code\\<strong>core<\/strong>\\Mage\\Adminhtml\\Block\\Dashboard\\Tab\\Orders.php<\/li>\n<li>magento\\app\\code\\<strong>core<\/strong>\\Mage\\Adminhtml\\Helper\\Dashboard\\Data.php<\/li>\n<\/ol>\n<p>into local code pool<\/p>\n<ol>\n<li>magento\\app\\code\\<strong>local<\/strong>\\Mage\\Adminhtml\\Block\\Dashboard\\Tab\\Amounts.php<\/li>\n<li>magento\\app\\code\\<strong>local<\/strong>\\Mage\\Adminhtml\\Block\\Dashboard\\Tab\\Orders.php<\/li>\n<li>magento\\app\\code\\<strong>local<\/strong>\\Mage\\Adminhtml\\Helper\\Dashboard\\Data.php<\/li>\n<\/ol>\n<p>In first two the change is the same, update following line (line breaks added for clarity):<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n$this-&gt;getRequest()-&gt;getParam('period')?\r\n$this-&gt;getRequest()-&gt;getParam('period'):'24h'\r\n<\/pre>\n<p>to be (line breaks added for clarity):<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n$this-&gt;getRequest()-&gt;getParam('period')?\r\n$this-&gt;getRequest()-&gt;getParam('period'):'7d'\r\n<\/pre>\n<p>now save them, clear magento cache and see results, you should see graph in last 7 days state but the drop down displays last 24 hours. That is where the third file comes in, locate the getDatePeriods() function and swap first 2 entries to look like this:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n    public function getDatePeriods()\r\n    {\r\n        return array(\r\n            '7d'=&gt;$this-&gt;__('Last 7 Days'),\r\n            '24h'=&gt;$this-&gt;__('Last 24 Hours'),\r\n            '1m'=&gt;$this-&gt;__('Current Month'),\r\n            '1y'=&gt;$this-&gt;__('YTD'),\r\n            '2y'=&gt;$this-&gt;__('2YTD')\r\n        );\r\n    }\r\n<\/pre>\n<p>If you don&#8217;t like this update (change to Data.php) you still make it work as you like:) go to the <em>graph.phtml<\/em> file located in following folder: magento\\app\\design\\adminhtml\\default\\default\\template\\dashboard\\ and put following changes:<\/p>\n<p>somwhere above the line with:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;div style=&quot;margin:20px;&quot;&gt;<\/pre>\n<p>put:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n$localPeriod = $this-&gt;getRequest()-&gt;getParam('period');\r\nswitch ($localPeriod)\r\n{\r\n\tcase '24h':\r\n\tcase '7d':\r\n\tcase '1m':\r\n\tcase '1y':\r\n\tcase '2y':\r\n\t\tbreak;\r\n\tdefault:\r\n\t\t$localPeriod = '7d';\r\n}\r\n\r\n?&gt;\r\n<\/pre>\n<p>then change this (line breaks added for clarity)<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">&lt;?php if($this-&gt;getRequest()\r\n-&gt;getParam('period')==$_value): ?&gt;<\/pre>\n<p>into this<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">&lt;?php if($localPeriod==$_value): ?&gt;<\/pre>\n<p>now it will properly set as selected the last 7 days (or what ever you have set as default) option.<\/p>\n<p>best regards<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, by default on dashboard you will see results from last 24hours, if you want to have it by default in different time span than you will be in trouble as there is no facility to set it up.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":""},"categories":[4,29],"tags":[97,102,98,99,103,100,104,300,101],"_links":{"self":[{"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/posts\/360"}],"collection":[{"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/comments?post=360"}],"version-history":[{"count":5,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/posts\/360\/revisions"}],"predecessor-version":[{"id":380,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/posts\/360\/revisions\/380"}],"wp:attachment":[{"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/media?parent=360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/categories?post=360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/tags?post=360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}