Ordered_By_Costomer - Version 0.1.1

Version Notes

Layout bugs fixed

Download this release

Release Info

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


Code changes from version 0.1.0 to 0.1.1

app/code/local/Arvobc/Obc/Block/Obc.php CHANGED
@@ -19,6 +19,9 @@ class Arvobc_Obc_Block_Obc extends Mage_Core_Block_Template
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)
@@ -60,7 +63,7 @@ class Arvobc_Obc_Block_Obc extends Mage_Core_Block_Template
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);
19
  * Get all unique order IDs for items with a particular ID.
20
  */
21
  public function getOrderIds() {
22
+ if (!Mage::registry('current_product')) {
23
+ return;
24
+ }
25
  $product_id = Mage::registry('current_product')->getId();
26
  $orderItems = Mage::getResourceModel('sales/order_item_collection')
27
  ->addFieldToFilter('product_id', $product_id)
63
  return $configs;
64
  }
65
 
66
+ public function format_interval($first_date, $second_date='') {
67
  $second_date = date('Y-m-d H:i:s');
68
  $first_date = new DateTime($first_date);
69
  $second_date = new DateTime($second_date);
app/code/local/Arvobc/Obc/Model/Observer.php CHANGED
@@ -5,22 +5,25 @@ class Arvobc_Obc_Model_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
  }
5
  {
6
  $configs = Arvobc_Obc_Block_Obc::getObcConfigs();
7
 
8
+ $orderIds = Arvobc_Obc_Block_Obc::getOrderIds();
9
+ if ($configs['obc_enabled'] && $orderIds['totalRecords']) {
10
+ $action = $observer->getEvent()->getAction();
11
+ $fullActionName = $action->getFullActionName();
12
+ $position = (isset($configs['obc_position'])) ? ($configs['obc_position']) : 'right';
13
+ $sub_position = 'before="cart_sidebar"';
14
+ if (isset($configs['obc_position_before']) && !empty($configs['obc_position_before'])) {
15
+ $sub_position = 'before="'.$configs['obc_position_before'].'"';
16
+ }
17
+ if (isset($configs['obc_position_after']) && !empty($configs['obc_position_after'])) {
18
+ $sub_position = 'after="'.$configs['obc_position_after'].'"';
19
+ }
20
 
21
+ $myXml = '<reference name="'.$position.'"><block type="obc/obc" name="obc" template="obc/obc.phtml" '.$sub_position.' /></reference>';
22
+ $layout = $observer->getEvent()->getLayout();
23
+ if ($fullActionName=='catalog_product_view') {
24
+ $layout->getUpdate()->addUpdate($myXml);
25
+ $layout->generateXml();
26
+ }
27
  }
28
  }
29
  }
app/code/local/Arvobc/Obc/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Arvobc_Obc>
5
- <version>0.1.0</version>
6
  </Arvobc_Obc>
7
  </modules>
8
  <frontend>
2
  <config>
3
  <modules>
4
  <Arvobc_Obc>
5
+ <version>0.1.1</version>
6
  </Arvobc_Obc>
7
  </modules>
8
  <frontend>
app/design/adminhtml/default/default/layout/obc.xml CHANGED
@@ -1,5 +1,5 @@
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" />
1
  <?xml version="1.0"?>
2
+ <layout version="0.1.1">
3
  <obc_adminhtml_obc_index>
4
  <reference name="content">
5
  <block type="obc/adminhtml_obc" name="obc" />
app/design/frontend/default/default/layout/obc.xml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.1">
3
+ <default>
4
+ <reference name="head">
5
+ <block type="core/text" name="google.cdn.jquery">
6
+ <action method="setText">
7
+ <text><![CDATA[<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script><script type="text/javascript">jQuery.noConflict();</script>]]>
8
+ </text>
9
+ </action>
10
+ </block>
11
+ </reference>
12
+ </default>
13
+ </layout>
app/design/frontend/default/default/template/obc/obc.phtml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $config = $this->getObcConfigs();
3
+
4
+ if ($config['obc_enabled']) {
5
+
6
+ $orderIds = $this->getOrderIds();
7
+ ?>
8
+
9
+ <?php if ($orderIds['totalRecords']): ?>
10
+ <?php $orderCollection = $this->getOrderCollection($orderIds) ?>
11
+ <div class="block block-cart">
12
+ <?php $_cartQty = $this->getSummaryCount() ?>
13
+ <div class="block-title">
14
+ <strong><span><?php echo $this->__('Recently Orderd By') ?></span></strong>
15
+ </div>
16
+ <div class="block-content">
17
+ <?php $_items = $this->getRecentItems() ?>
18
+ <?php if($orderCollection->count()): ?>
19
+ <ol id="obc_box" class="mini-products-list">
20
+ <?php foreach ($orderCollection as $order): ?>
21
+ <?php $customer = Mage::getModel('customer/customer')->load($order->getCustomerId()); ?>
22
+ <p class="empty product-name">
23
+ <?php echo $customer->getFirstname(). ' ' .$customer->getLastname() ?>
24
+ <?php if ($config['obc_showaddress']): ?>
25
+ <?php $address = $order->getShippingAddress()->getData() ?>
26
+ <?php echo ', ' . $address['city'] ?>
27
+ <?php endif; ?>
28
+ <?php if ($config['obc_showdate']): ?>
29
+ <?php $date = $order->getCreatedAt() ?>
30
+ <?php $interval = $this->format_interval($date) ?>
31
+ <p class="empty right">
32
+ <?php echo $interval ?>
33
+ </p>
34
+ <?php endif; ?>
35
+ </p>
36
+ <?php endforeach; ?>
37
+ </ol>
38
+ <script type="text/javascript">decorateList('obc_box', 'none-recursive')</script>
39
+ <?php else: ?>
40
+ <p class="empty"><?php echo $this->__('You have no items in your shopping cart.') ?></p>
41
+ <?php endif ?>
42
+ </div>
43
+ </div>
44
+ <?php endif;?>
45
+ <?php
46
+ }
47
+ ?>
package.xml CHANGED
@@ -1,18 +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>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Ordered_By_Costomer</name>
4
+ <version>0.1.1</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>Layout bugs fixed</notes>
12
  <authors><author><name>Arvind Bhardwaj</name><user>Arvind07</user><email>bhardwajsonheight@gmail.com</email></author></authors>
13
+ <date>2013-03-29</date>
14
+ <time>06:27:39</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="7e711c15641f55712257b36fe24e5a3a"/></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="69bfb02b24e394f9f18272d31e5d0d41"/></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="54ff46f9ade05eeca5c4e7339eb5c94f"/><file name="system.xml" hash="137300a027d3b8d65c8a52caa98d99ff"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="obc.xml" hash="bc19717f1b896e90f36669cd4f119c9b"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="obc.xml" hash="737b3496a49c21cab29793a2681b1a16"/></dir><dir name="template"><dir name="obc"><file name="obc.phtml" hash="01dcb0de61c45ac7047fe9b98d98d00f"/></dir></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>