Skip to content

Commit

Permalink
2.0.3 files added
Browse files Browse the repository at this point in the history
  • Loading branch information
Syam Mohan committed Oct 7, 2014
1 parent 58ae380 commit 18abcb0
Show file tree
Hide file tree
Showing 16 changed files with 589 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

/**
* Medma Marketplace
*
* NOTICE OF LICENSE
*
* This source file is subject to the Magento Team
* that is bundled with this package of Medma Infomatix Pvt. Ltd.
* =================================================================
* MAGENTO EDITION USAGE NOTICE
* =================================================================
* This package designed for Magento COMMUNITY edition
* Contact us Support does not guarantee correct work of this package
* on any other Magento edition except Magento COMMUNITY edition.
* =================================================================
*
* @category Medma
* @package Medma_MarketPlace
**/

class Medma_MarketPlace_Block_Vendor_List extends Mage_Core_Block_Template
{
public function __construct()
{
$this->setTemplate('marketplace/vendor/list.phtml');
parent::__construct();
}

public function getVendorListCollection()
{
//~ $vendorCollection = Mage::getModel('marketplace/profile')->getCollection();
//~ $vendorCollection->addFieldToSelect('entity_id');
//~ $vendorCollection->addFieldToSelect('user_id');
//~ $vendorCollection->addFieldToSelect('image');


//$userTable = Mage::getSingleton('core/resource')->getTableName('admin/user');
//$collection = Mage :: getModel('marketplace/profile')->getCollection();

// Cannot append getSelect right here because $collection will not be a collection
//return $collection->getSelect()->join(array('user' => $userTable),'main_table.user_id = user.user_id','main_table.*');


$collection = Mage::getModel('marketplace/profile')->getCollection();
$collection->getSelect()->joinInner( array('cat'=> Mage::getSingleton('core/resource')->getTableName('admin/user')), 'main_table.cat_id = cat.user_id', array('user_id'));
//echo $collection->getSelect(); die;
return $collection;

}
}

?>
71 changes: 71 additions & 0 deletions app/code/community/Medma/MarketPlace/Block/Vendor/List.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

/**
* Medma Marketplace
*
* NOTICE OF LICENSE
*
* This source file is subject to the Magento Team
* that is bundled with this package of Medma Infomatix Pvt. Ltd.
* =================================================================
* MAGENTO EDITION USAGE NOTICE
* =================================================================
* This package designed for Magento COMMUNITY edition
* Contact us Support does not guarantee correct work of this package
* on any other Magento edition except Magento COMMUNITY edition.
* =================================================================
*
* @category Medma
* @package Medma_MarketPlace
**/

class Medma_MarketPlace_Block_Vendor_List extends Mage_Core_Block_Template
{
public function __construct()
{
$this->setTemplate('marketplace/vendor/list.phtml');
parent::__construct();
}

public function getVendorListCollection()
{
$userCollection = Mage::getModel('admin/user')->getCollection()
->addFieldToFilter('is_active', 1);

$userCollection->getSelect()->join(
array('user_profile' => Mage::getSingleton('core/resource')->getTableName('marketplace/profile')),
'user_profile.user_id = main_table.user_id', array('user_profile.*')
);

return $userCollection;
}

public function getProductList($vendor_id)
{
return Mage::getModel('catalog/product')->getCollection()->addFieldToFilter('vendor', $vendor_id)->setPageSize(4);
}

public function getProductImage($product_id)
{
$productModel = Mage::getModel('catalog/product')->load($product_id);
return Mage::helper('catalog/image')->init($productModel, 'small_image')->resize(91, 91);
}

public function getVendorProfileUrl($vendorId)
{
return $this->getUrl('marketplace/vendor/profile', array('id' => $vendorId));
}

public function getViewAllProduct($vendorId)
{
return $this->getUrl('marketplace/vendor/items', array('id' => $vendorId));
}

public function getVendorImageUrl($vendorImageName)
{
$dirPath = 'vendor' . DS . 'images';
return Mage::helper('marketplace')->getImagesUrl($dirPath) . $vendorImageName;
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public function getHighestSellingProduct()
->addAttributeToFilter('vendor', $vendorId)
->getAllIds();

if(empty($productIds))
return null;

$productReportCollection = Mage::getResourceModel('reports/product_collection')
->addOrderedQty()
->addAttributeToSelect('*')
Expand Down
92 changes: 92 additions & 0 deletions app/code/community/Medma/MarketPlace/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,98 @@ public function catalogProductSaveBefore($observer)
$product->setCategoryIds($categoryIds);
}
}

public function notifyVendor($observer)
{
$orderIncrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$orderObject = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);

$vars['billing_address'] = $orderObject->getBillingAddress()->format('html');
$vars['shipping_address'] = $orderObject->getShippingAddress()->format('html');
$vars['get_is_not_virtual'] = $orderObject->getIsNotVirtual();
$vars['customer_name'] = $orderObject->getBillingAddress()->getName();
$vars['order_no'] = $orderIncrementId;

$head = '<thead style="background:#f9f9f9;">
<tr>
<th align="left" bgcolor="#EAEAEA" style="font-size: 13px; padding: 3px 9px;"><strong>Product</strong></th>
<th align="left" bgcolor="#EAEAEA" style="font-size: 13px; padding: 3px 9px;"><strong><span>Original Price</span></strong></th>
<th align="left" bgcolor="#EAEAEA" style="font-size: 13px; padding: 3px 9px;"><strong>Price</strong></th>
<th align="left" bgcolor="#EAEAEA" style="font-size: 13px; padding: 3px 9px;"><strong>Qty</strong></th>
<th align="left" bgcolor="#EAEAEA" style="font-size: 13px; padding: 3px 9px;"><strong><span>Row Total</strong></span></th>
</tr>
</thead>';

$orderItems = $orderObject->getAllItems();
$orderDetails = array();
foreach($orderItems as $item)
{
$attribute = '';
if($options = $item->getProductOptions())
{
foreach ($options['attributes_info'] as $option)
$attribute .='<div><strong>' . $option['label'] . ':</strong> ' . $option['value'] . '</div>';
}

$vendorId = Mage::getModel('catalog/product')->load($item->getProductId())->getVendor();
$vendorModel = Mage::getModel('admin/user')->load($vendorId);

$orderDetails[$vendorId]['vendor_name'] = $vendorModel->getName();
$orderDetails[$vendorId]['vendor_mail_id'] = $vendorModel->getEmail();
$orderDetails[$vendorId]['order_items'] .= '<tbody>
<tr>
<td align="left" valign="top" style="font-size: 11px; padding: 3px 9px; border-bottom: 1px dotted #CCCCCC;">
' . $item->getName() . '<br />
<strong>SKU:</strong> ' . $item->getSku()
. $attribute .
'</td>
<td align="left" valign="top" style="font-size: 11px; padding: 3px 9px; border-bottom: 1px dotted #CCCCCC;">' . Mage::helper('core')->currency($item->getData("price_incl_tax"), true, false) . '</td>
<td align="left" valign="top" style="font-size: 11px; padding: 3px 9px; border-bottom: 1px dotted #CCCCCC;">' . Mage::helper('core')->currency($item->getOriginalPrice(), true, false) . '</td>
<td align="left" valign="top" style="font-size: 11px; padding: 3px 9px; border-bottom: 1px dotted #CCCCCC;">' . intval($item->getQtyOrdered()) . '</td>
<td align="left" valign="top" style="font-size: 11px; padding: 3px 9px; border-bottom: 1px dotted #CCCCCC;">' . Mage::helper('core')->currency($item->getData("row_total_incl_tax"), true, false) . '</td>
</tr>
</tbody>';
}

foreach($orderDetails as $key => $value)
{
$vendorOrder = '<table cellspacing="0" cellpadding="0" border="0" width="650" style="border: 1px solid #EAEAEA;">';
$vendorOrder .= $head;
$vendorOrder .= $value['order_items'];
$vendorOrder .= '</table>';

$vars['sales_email_order_items'] = $vendorOrder;
$vars['vendor_name'] = $value['vendor_name'];
$this->sendTransactionalEmail($value['vendor_mail_id'], $vars);
}
}

public function sendTransactionalEmail($email, $vars)
{
// Transactional Email Template's ID
$templateId = Mage::getStoreConfig('marketplace/email/email_template');

// Set sender information
$senderInfo = Mage::getStoreConfig('marketplace/email/email_sender');
$senderName = Mage::getStoreConfig('trans_email/ident_'.$senderInfo.'/name');
$senderEmail = Mage::getStoreConfig('trans_email/ident_'.$senderInfo.'/email');

$sender = array('name' => $senderName, 'email' => $senderEmail);

// Set recepient information
$recepientEmail = $email;

// Get Store ID
$storeId = Mage::app()->getStore()->getId();

$translate = Mage::getSingleton('core/translate');

// Send Transactional Email
Mage::getModel('core/email_template')
->sendTransactional($templateId, $sender, $recepientEmail, $email,$vars, $storeId);

$translate->setTranslateInline(true);
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function registerAction()

public function profileAction()
{
$vendorId = $this->getRequest()->getParam('id');
$vendorId = $this->getRequest()->getParam('id');
$this->loadLayout();
$this->renderLayout();
}
Expand Down
46 changes: 43 additions & 3 deletions app/code/community/Medma/MarketPlace/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<Medma_MarketPlace>
<version>2.0.2</version>
<version>2.0.3</version>
</Medma_MarketPlace>
</modules>
<global>
Expand Down Expand Up @@ -81,7 +81,16 @@
<class>Medma_MarketPlace_Helper</class>
</marketplace>
</helpers>
<events>
<events>
<checkout_onepage_controller_success_action>
<observers>
<checkout_onepage_controller_success_action>
<type>singleton</type>
<class>Medma_MarketPlace_Model_Observer</class>
<method>notifyVendor</method>
</checkout_onepage_controller_success_action>
</observers>
</checkout_onepage_controller_success_action>
<catalog_product_save_before>
<observers>
<catalog_product_save_before>
Expand All @@ -98,8 +107,17 @@
<method>saveDomain</method>
</domain>
</observers>
</medma_domain_authentication>
</medma_domain_authentication>
</events>
<template>
<email>
<marketplace_email_email_template module="marketplace">
<label>New Vendor Order</label>
<file>sales/new_vendor_order.html</file>
<type>html</type>
</marketplace_email_email_template>
</email>
</template>
</global>
<frontend>
<routers>
Expand All @@ -118,6 +136,15 @@
</marketplace>
</updates>
</layout>
<translate>
<modules>
<marketplace>
<files>
<default>Medma_MarketPlace.csv</default>
</files>
</marketplace>
</modules>
</translate>
</frontend>
<admin>
<routers>
Expand Down Expand Up @@ -145,6 +172,15 @@
</marketplace>
</updates>
</layout>
<translate>
<modules>
<marketplace>
<files>
<default>Medma_MarketPlace.csv</default>
</files>
</marketplace>
</modules>
</translate>
<events>
<catalog_product_collection_load_before>
<observers>
Expand Down Expand Up @@ -267,6 +303,10 @@
<review>
<page_size>3,6,9</page_size>
</review>
<email>
<email_sender>sales</email_sender>
<email_template>marketplace_email_email_template</email_template>
</email>
</marketplace>
</default>
</config>
30 changes: 29 additions & 1 deletion app/code/community/Medma/MarketPlace/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<review translate="label">
<label>Review Options</label>
<frontend_type>select</frontend_type>
<sort_order>30</sort_order>
<sort_order>20</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
Expand All @@ -60,6 +60,34 @@
</page_size>
</fields>
</review>
<email translate="label">
<label>Email Options</label>
<frontend_type>select</frontend_type>
<sort_order>30</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<email_sender translate="label" module="adminhtml">
<label>Email Sender</label>
<frontend_type>select</frontend_type>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<source_model>adminhtml/system_config_source_email_identity</source_model>
</email_sender>
<email_template translate="label" module="adminhtml">
<label>Email Template</label>
<frontend_type>select</frontend_type>
<sort_order>20</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<source_model>adminhtml/system_config_source_email_template</source_model>
</email_template>
</fields>
</email>
</groups>
</marketplace>
</sections>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<td><h2><?php echo $this->__('This is a Vendor Order Grid !!'); ?></h2></td>
</tr>
<tr>
<td><?php echo $this->__('Please find your order details from ') . '<a href="' . $this->getSalesOrderUrl() . '">' . $this->__('Sales > Orders') . '</a>' . $this->__(' Page.'); ?></td>
<td><?php echo $this->__('Please find your order details from <a href="%s">Sales > Orders</a> Page.', $this->getSalesOrderUrl());?></td>
</tr>
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<td><h2><?php echo $this->__('This is a Vendor Review Grid !!'); ?></h2></td>
</tr>
<tr>
<td><?php echo $this->__('Please find your vendor reviews from ') . '<a href="' . $this->getReviewGridUrl() . '">' . $this->__('Medma > Market Place > Review and Ratings > All Ratings') . '</a>' . $this->__(' Page.'); ?></td>
<td><?php echo $this->__('Please find your vendor reviews from <a href="%s">Medma > Market Place > Review and Ratings > All Ratings</a> Page.', $this->getReviewGridUrl()); ?></td>
</tr>
</tbody>
</table>
Expand Down
Loading

0 comments on commit 18abcb0

Please sign in to comment.