Ordered_By_Costomer - Version 0.1.0

Version Notes

Stable version released.

Download this release

Release Info

Developer Arvind Bhardwaj
Extension Ordered_By_Costomer
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/local/Arvobc/Obc/Block/Obc.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Arvobc_Obc_Block_Obc extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ return parent::_prepareLayout();
7
+ }
8
+
9
+ public function getObc()
10
+ {
11
+ if (!$this->hasData('obc')) {
12
+ $this->setData('obc', Mage::registry('obc'));
13
+ }
14
+ return $this->getData('obc');
15
+
16
+ }
17
+
18
+ /*
19
+ * Get all unique order IDs for items with a particular ID.
20
+ */
21
+ public function getOrderIds() {
22
+ $product_id = Mage::registry('current_product')->getId();
23
+ $orderItems = Mage::getResourceModel('sales/order_item_collection')
24
+ ->addFieldToFilter('product_id', $product_id)
25
+ ->toArray(array('order_id'))
26
+ ;
27
+ $orderIds = array_unique(array_map(
28
+ function($orderItem) {
29
+ return $orderItem['order_id'];
30
+ },
31
+ $orderItems['items']
32
+ ));
33
+ return $orderItems;
34
+ }
35
+
36
+ /*
37
+ * Now get all unique customers from the orders of these items.
38
+ */
39
+ public function getOrderCollection($orderIds) {
40
+ $configs = $this->getObcConfigs();
41
+
42
+ $orderCollection = Mage::getResourceModel('sales/order_collection')
43
+ ->addAttributeToSort('created_at', 'DESC')
44
+ ->addFieldToFilter('entity_id', array('in' => $orderIds))
45
+ ->addFieldToFilter('customer_id', array('neq' => 'NULL'))
46
+ ;
47
+ $orderCollection->setPageSize($configs['obc_records'])->getSelect()->group('customer_id');
48
+ return $orderCollection;
49
+ }
50
+
51
+ public function getObcConfigs() {
52
+ $configs = array();
53
+ $configs['obc_enabled'] = Mage::getStoreConfig('obcconfig/obc_group/obc_enabled');
54
+ $configs['obc_records'] = Mage::getStoreConfig('obcconfig/obc_group/obc_records');
55
+ $configs['obc_showaddress'] = Mage::getStoreConfig('obcconfig/obc_group/obc_showaddress');
56
+ $configs['obc_showdate'] = Mage::getStoreConfig('obcconfig/obc_group/obc_showdate');
57
+ $configs['obc_position'] = Mage::getStoreConfig('obcconfig/obc_group/obc_position');
58
+ $configs['obc_position_before'] = Mage::getStoreConfig('obcconfig/obc_group/obc_position_before');
59
+ $configs['obc_position_after'] = Mage::getStoreConfig('obcconfig/obc_group/obc_position_after');
60
+ return $configs;
61
+ }
62
+
63
+ public function format_interval($first_date, $second_date) {
64
+ $second_date = date('Y-m-d H:i:s');
65
+ $first_date = new DateTime($first_date);
66
+ $second_date = new DateTime($second_date);
67
+
68
+ $interval = $first_date->diff($second_date);
69
+
70
+ $result = "";
71
+ if ($interval->y) {
72
+ $result .= $interval->format("%y year");
73
+ } else {
74
+ if ($interval->m) {
75
+ $result .= $interval->format("%m month");
76
+ } else {
77
+ if ($interval->d) {
78
+ $result .= $interval->format("%d day");
79
+ } else {
80
+ if ($interval->h) {
81
+ $result .= $interval->format("%h hour");
82
+ } else {
83
+ if ($interval->i) {
84
+ $result .= $interval->format("%i minute");
85
+ } else {
86
+ if ($interval->s) {
87
+ $result .= $interval->format("%s second");
88
+ }
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
94
+ if (intval($result) > 1) {
95
+ $result .= 's';
96
+ }
97
+ $result .= ' ago';
98
+ return $result;
99
+ }
100
+
101
+ }
app/code/local/Arvobc/Obc/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Arvobc_Obc_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/local/Arvobc/Obc/Model/Obc.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Arvobc_Obc_Model_Obc extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('obc/obc');
9
+ }
10
+ }
app/code/local/Arvobc/Obc/Model/Observer.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Arvobc_Obc_Model_Observer
3
+ {
4
+ public function add_obc_block($observer)
5
+ {
6
+ $configs = Arvobc_Obc_Block_Obc::getObcConfigs();
7
+
8
+ $action = $observer->getEvent()->getAction();
9
+ $fullActionName = $action->getFullActionName();
10
+ $position = (isset($configs['obc_position'])) ? ($configs['obc_position']) : 'right';
11
+ $sub_position = 'before="cart_sidebar"';
12
+ if (isset($configs['obc_position_before']) && !empty($configs['obc_position_before'])) {
13
+ $sub_position = 'before="'.$configs['obc_position_before'].'"';
14
+ }
15
+ if (isset($configs['obc_position_after']) && !empty($configs['obc_position_after'])) {
16
+ $sub_position = 'after="'.$configs['obc_position_after'].'"';
17
+ }
18
+
19
+ $myXml = '<reference name="'.$position.'"><block type="obc/obc" name="obc" template="obc/obc.phtml" '.$sub_position.' /></reference>';
20
+ $layout = $observer->getEvent()->getLayout();
21
+ if ($fullActionName=='catalog_product_view'){
22
+ $layout->getUpdate()->addUpdate($myXml);
23
+ $layout->generateXml();
24
+ }
25
+ }
26
+ }
app/code/local/Arvobc/Obc/controllers/IndexController.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Arvobc_Obc_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ $this->loadLayout();
7
+ $this->renderLayout();
8
+ }
9
+ }
app/code/local/Arvobc/Obc/etc/adminhtml.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <obcconfig translate="title" module="obc">
12
+ <title>Ordered By Config</title>
13
+ <sort_order>100</sort_order>
14
+ </obcconfig>
15
+ </children>
16
+ </config>
17
+ </children>
18
+ </system>
19
+ </children>
20
+ </admin>
21
+ </resources>
22
+ </acl>
23
+ </config>
app/code/local/Arvobc/Obc/etc/config.xml ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Arvobc_Obc>
5
+ <version>0.1.0</version>
6
+ </Arvobc_Obc>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <obc>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Arvobc_Obc</module>
14
+ <frontName>obc</frontName>
15
+ </args>
16
+ </obc>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <obc>
21
+ <file>obc.xml</file>
22
+ </obc>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <admin>
27
+ <routers>
28
+ <obc>
29
+ <use>admin</use>
30
+ <args>
31
+ <module>Arvobc_Obc</module>
32
+ <frontName>obc</frontName>
33
+ </args>
34
+ </obc>
35
+ </routers>
36
+ </admin>
37
+ <global>
38
+ <models>
39
+ <obc>
40
+ <class>Arvobc_Obc_Model</class>
41
+ <resourceModel>obc_mysql4</resourceModel>
42
+ </obc>
43
+ <obc_mysql4>
44
+ <class>Arvobc_Obc_Model_Mysql4</class>
45
+ <entities>
46
+ <obc>
47
+ <table>obc</table>
48
+ </obc>
49
+ </entities>
50
+ </obc_mysql4>
51
+ </models>
52
+ <resources>
53
+ <obc_setup>
54
+ <setup>
55
+ <module>Arvobc_Obc</module>
56
+ </setup>
57
+ <connection>
58
+ <use>core_setup</use>
59
+ </connection>
60
+ </obc_setup>
61
+ <obc_write>
62
+ <connection>
63
+ <use>core_write</use>
64
+ </connection>
65
+ </obc_write>
66
+ <obc_read>
67
+ <connection>
68
+ <use>core_read</use>
69
+ </connection>
70
+ </obc_read>
71
+ </resources>
72
+ <blocks>
73
+ <obc>
74
+ <class>Arvobc_Obc_Block</class>
75
+ </obc>
76
+ </blocks>
77
+ <helpers>
78
+ <obc>
79
+ <class>Arvobc_Obc_Helper</class>
80
+ </obc>
81
+ </helpers>
82
+ <events>
83
+ <controller_action_layout_generate_blocks_before>
84
+ <observers>
85
+ <obc_block_observer>
86
+ <type>singleton</type>
87
+ <class>Arvobc_Obc_Model_Observer</class>
88
+ <method>add_obc_block</method>
89
+ </obc_block_observer>
90
+ </observers>
91
+ </controller_action_layout_generate_blocks_before>
92
+ </events>
93
+ </global>
94
+ <default>
95
+ <obcconfig>
96
+ <obc_group>
97
+ <obc_enabled>1</obc_enabled>
98
+ <obc_records>10</obc_records>
99
+ <obc_showaddress>1</obc_showaddress>
100
+ <obc_showdate>1</obc_showdate>
101
+ <obc_position>right</obc_position>
102
+ <obc_position_before>cart_sidebar</obc_position_before>
103
+ <obc_position_after></obc_position_after>
104
+ </obc_group>
105
+ </obcconfig>
106
+ </default>
107
+ </config>
app/code/local/Arvobc/Obc/etc/system.xml ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <tabs>
4
+ <obc_tab module="obc" translate="label">
5
+ <label>Ordered By Config</label>
6
+ <sort_order>100</sort_order>
7
+ </obc_tab>
8
+ </tabs>
9
+ <sections>
10
+ <obcconfig module="obc" translate="label">
11
+ <label>Configuration</label>
12
+ <sort_order>200</sort_order>
13
+ <show_in_default>1</show_in_default>
14
+ <show_in_website>1</show_in_website>
15
+ <show_in_store>1</show_in_store>
16
+ <tab>obc_tab</tab>
17
+ <groups>
18
+ <obc_group translate="label">
19
+ <label>Ordered By Config</label>
20
+ <!--<comment>This is example of custom configuration.</comment>-->
21
+ <sort_order>10</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>1</show_in_store>
25
+ <fields>
26
+ <obc_enabled translate="label tooltip comment">
27
+ <label>Is Enabled</label>
28
+ <frontend_type>select</frontend_type>
29
+ <source_model>adminhtml/system_config_source_yesno</source_model>
30
+ <sort_order>0</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ <comment>Enable this module.</comment>
35
+ </obc_enabled>
36
+ <obc_records translate="label tooltip comment">
37
+ <label>No of Records</label>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>1</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ <comment>Number of records to show.</comment>
44
+ </obc_records>
45
+ <obc_showaddress translate="label tooltip comment">
46
+ <label>Show Address</label>
47
+ <frontend_type>select</frontend_type>
48
+ <source_model>adminhtml/system_config_source_yesno</source_model>
49
+ <sort_order>2</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ <comment>Hide/Show customer address.</comment>
54
+ </obc_showaddress>
55
+ <obc_showdate translate="label tooltip comment">
56
+ <label>Show Order Duration</label>
57
+ <frontend_type>select</frontend_type>
58
+ <source_model>adminhtml/system_config_source_yesno</source_model>
59
+ <sort_order>3</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>1</show_in_store>
63
+ <comment>Hide/Show order duration.</comment>
64
+ </obc_showdate>
65
+ <obc_position translate="label tooltip comment">
66
+ <label>Position</label>
67
+ <frontend_type>text</frontend_type>
68
+ <sort_order>4</sort_order>
69
+ <show_in_default>1</show_in_default>
70
+ <show_in_website>1</show_in_website>
71
+ <show_in_store>1</show_in_store>
72
+ <comment>Set the location of the module box on frontend. Examples: content, right, left</comment>
73
+ </obc_position>
74
+ <obc_position_before translate="label tooltip comment">
75
+ <label>Before</label>
76
+ <frontend_type>text</frontend_type>
77
+ <sort_order>5</sort_order>
78
+ <show_in_default>1</show_in_default>
79
+ <show_in_website>1</show_in_website>
80
+ <show_in_store>1</show_in_store>
81
+ <comment>Name of the block before which box is to be shown. Examples: cart_sidebar, -</comment>
82
+ </obc_position_before>
83
+ <obc_position_after translate="label tooltip comment">
84
+ <label>After</label>
85
+ <frontend_type>text</frontend_type>
86
+ <sort_order>6</sort_order>
87
+ <show_in_default>1</show_in_default>
88
+ <show_in_website>1</show_in_website>
89
+ <show_in_store>1</show_in_store>
90
+ <comment>Name of the block after which box is to be shown. Examples: cart_sidebar, -</comment>
91
+ </obc_position_after>
92
+ </fields>
93
+ </obc_group>
94
+ </groups>
95
+ </obcconfig>
96
+ </sections>
97
+ </config>
app/design/adminhtml/default/default/layout/obc.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <obc_adminhtml_obc_index>
4
+ <reference name="content">
5
+ <block type="obc/adminhtml_obc" name="obc" />
6
+ </reference>
7
+ </obc_adminhtml_obc_index>
8
+ </layout>
app/etc/modules/Arvobc_Obc.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Arvobc_Obc>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Arvobc_Obc>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Ordered_By_Costomer</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Order By Customer extension shows the names and location of customers who ordered the product recently.</summary>
10
+ <description>Order By Customer extension shows the name and location of customers who ordered the product recently. The block is displayed on the product detail page. So the customer can be assured that the product is being purchased by other customers also.</description>
11
+ <notes>Stable version released.</notes>
12
+ <authors><author><name>Arvind Bhardwaj</name><user>Arvind07</user><email>bhardwajsonheight@gmail.com</email></author></authors>
13
+ <date>2013-03-28</date>
14
+ <time>07:32:03</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="Arvobc_Obc.xml" hash="a4ceaea65c2cc0b9432b8ee26ff65908"/></dir></target><target name="magelocal"><dir name="Arvobc"><dir name="Obc"><dir name="Block"><file name="Obc.php" hash="17a131923982ff8f3e2b445e0470b9ab"/></dir><dir name="Helper"><file name="Data.php" hash="cdcbb121d6545d14440640c40dd2e22f"/></dir><dir name="Model"><file name="Obc.php" hash="f1e05ee73f49db968044213640e7204e"/><file name="Observer.php" hash="6377fa5f998ae2086c4eb15a91fd1e4b"/></dir><dir name="controllers"><file name="IndexController.php" hash="bf429fe6f515f93c2c2f62e6f4266221"/></dir><dir name="etc"><file name="adminhtml.xml" hash="bb2f3a7af1dc396210299f973ba9b7a7"/><file name="config.xml" hash="bc353f95a3083bf110732b8d75abff2e"/><file name="system.xml" hash="137300a027d3b8d65c8a52caa98d99ff"/></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="obc.xml" hash=""/></dir><dir name="template"><dir name="obc"><file name="obc.phtml" hash=""/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="obc.xml" hash="4bf2caa9f6de7e1ea044dc3bbff74afb"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>