Version Notes
Compatibility with magento 1.9
Download this release
Release Info
Developer | Auguria |
Extension | auguriainsurance |
Version | 0.0.1 |
Comparing to | |
See all releases |
Version 0.0.1
- app/code/community/Auguria/Core/Helper/Data.php +9 -0
- app/code/community/Auguria/Core/Model/Attribute/Backend/Image/Abstract.php +59 -0
- app/code/community/Auguria/Core/Model/Customer/Attribute/Source/Group.php +22 -0
- app/code/community/Auguria/Core/Model/System/Config/Source/Config.php +35 -0
- app/code/community/Auguria/Core/Model/System/Config/Source/Customer/Group/Multiselect.php +34 -0
- app/code/community/Auguria/Core/etc/config.xml +50 -0
- app/code/community/Auguria/Core/etc/system.xml +17 -0
- app/code/community/Auguria/Insurance/Block/Checkout/Cart/Total/Insurance.php +63 -0
- app/code/community/Auguria/Insurance/Block/Checkout/Insurance.php +83 -0
- app/code/community/Auguria/Insurance/Block/Sales/Order/Total/Insurance.php +157 -0
- app/code/community/Auguria/Insurance/Helper/Config.php +47 -0
- app/code/community/Auguria/Insurance/Helper/Data.php +33 -0
- app/code/community/Auguria/Insurance/Model/Catalog/Product/Type/Insurance.php +25 -0
- app/code/community/Auguria/Insurance/Model/Observer.php +89 -0
- app/code/community/Auguria/Insurance/Model/Sales/Order/Pdf/Items/Default.php +19 -0
- app/code/community/Auguria/Insurance/Model/Sales/Order/Pdf/Total/Insurance.php +70 -0
- app/code/community/Auguria/Insurance/Model/Sales/Quote/Address/Total/Insurance.php +31 -0
- app/code/community/Auguria/Insurance/controllers/IndexController.php +98 -0
- app/code/community/Auguria/Insurance/etc/adminhtml.xml +30 -0
- app/code/community/Auguria/Insurance/etc/config.xml +185 -0
- app/code/community/Auguria/Insurance/etc/system.xml +81 -0
- app/code/community/Auguria/Insurance/sql/auguria_insurance_setup/install-0.0.1.php +129 -0
- app/design/adminhtml/default/default/layout/auguria/core.xml +19 -0
- app/design/adminhtml/default/default/template/auguria/insurance/checkout/cart/total/insurance.phtml +23 -0
- app/design/adminhtml/default/default/template/auguria/insurance/sales/order/total/insurance.phtml +22 -0
- app/design/frontend/base/default/layout/auguria/insurance.xml +338 -0
- app/design/frontend/base/default/template/auguria/insurance/checkout/cart/item/insurance.phtml +11 -0
- app/design/frontend/base/default/template/auguria/insurance/checkout/cart/total/insurance.phtml +23 -0
- app/design/frontend/base/default/template/auguria/insurance/checkout/insurance.phtml +65 -0
- app/design/frontend/base/default/template/auguria/insurance/sales/order/total/insurance.phtml +22 -0
- app/etc/modules/Auguria_Core.xml +17 -0
- app/etc/modules/Auguria_Insurance.xml +20 -0
- app/locale/en_US/Auguria_Core.csv +0 -0
- app/locale/en_US/Auguria_Insurance.csv +0 -0
- app/locale/fr_FR/Auguria_Core.csv +0 -0
- app/locale/fr_FR/Auguria_Insurance.csv +13 -0
- package.xml +25 -0
- skin/adminhtml/default/default/auguria/core.css +17 -0
- skin/adminhtml/default/default/auguria/images/section-header.png +0 -0
- skin/adminhtml/default/default/auguria/images/tab-header.png +0 -0
- skin/frontend/base/default/css/auguria/insurance/style.css +19 -0
app/code/community/Auguria/Core/Helper/Data.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Core
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Auguria_Core_Helper_Data extends Mage_Core_Helper_Abstract {}
|
app/code/community/Auguria/Core/Model/Attribute/Backend/Image/Abstract.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Core
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
|
7 |
+
*/
|
8 |
+
|
9 |
+
abstract class Auguria_Core_Model_Attribute_Backend_Image_Abstract extends Mage_Eav_Model_Entity_Attribute_Backend_Abstract
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Save uploaded file
|
13 |
+
*
|
14 |
+
* @param Varien_Object $object
|
15 |
+
*/
|
16 |
+
public function afterSave($object)
|
17 |
+
{
|
18 |
+
$value = $object->getData($this->getAttribute()->getName());
|
19 |
+
|
20 |
+
if (is_array($value) && !empty($value['delete'])) {
|
21 |
+
$object->setData($this->getAttribute()->getName(), '');
|
22 |
+
$this->getAttribute()->getEntity()
|
23 |
+
->saveAttribute($object, $this->getAttribute()->getName());
|
24 |
+
return;
|
25 |
+
}
|
26 |
+
|
27 |
+
try {
|
28 |
+
$uploader = new Mage_Core_Model_File_Uploader($this->getAttribute()->getName());
|
29 |
+
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
|
30 |
+
$uploader->setAllowRenameFiles(true);
|
31 |
+
$result = $uploader->save($this->_getPath());
|
32 |
+
|
33 |
+
$object->setData($this->getAttribute()->getName(), $this->_getPrefix() . $result['file']);
|
34 |
+
$this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
|
35 |
+
} catch (Exception $e) {
|
36 |
+
if ($e->getCode() != Mage_Core_Model_File_Uploader::TMP_NAME_EMPTY) {
|
37 |
+
Mage::logException($e);
|
38 |
+
}
|
39 |
+
return;
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Get path to save file
|
45 |
+
*
|
46 |
+
* @return string
|
47 |
+
*/
|
48 |
+
abstract protected function _getPath();
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Get prefix when save path file in attribute value
|
52 |
+
*
|
53 |
+
* @return string
|
54 |
+
*/
|
55 |
+
protected function _getPrefix()
|
56 |
+
{
|
57 |
+
return;
|
58 |
+
}
|
59 |
+
}
|
app/code/community/Auguria/Core/Model/Customer/Attribute/Source/Group.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Core
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Auguria_Core_Model_Customer_Attribute_Source_Group extends Mage_Eav_Model_Entity_Attribute_Source_Table
|
10 |
+
{
|
11 |
+
public function getAllOptions()
|
12 |
+
{
|
13 |
+
if (!$this->_options) {
|
14 |
+
$this->_options = Mage::getResourceModel('customer/group_collection')
|
15 |
+
//->setRealGroupsFilter() GET NOT LOGGED IN GROUP
|
16 |
+
->load()
|
17 |
+
->toOptionArray()
|
18 |
+
;
|
19 |
+
}
|
20 |
+
return $this->_options;
|
21 |
+
}
|
22 |
+
}
|
app/code/community/Auguria/Core/Model/System/Config/Source/Config.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Core
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
|
7 |
+
*/
|
8 |
+
|
9 |
+
abstract class Auguria_Core_Model_System_Config_Source_Config
|
10 |
+
{
|
11 |
+
|
12 |
+
const CONFIG_OPTIONS_PATH = '';
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Options getter
|
16 |
+
*
|
17 |
+
* @return array
|
18 |
+
*/
|
19 |
+
public function toOptionArray()
|
20 |
+
{
|
21 |
+
$nodes = Mage::getConfig()->getNode(static::CONFIG_OPTIONS_PATH);
|
22 |
+
$translator = (string)$nodes->getAttribute('translator'); // used to translate label
|
23 |
+
|
24 |
+
$options = array();
|
25 |
+
|
26 |
+
foreach($nodes as $_node){
|
27 |
+
foreach ($_node as $_option){
|
28 |
+
$options[] = array('value' => (string)$_option->value, 'label' => Mage::helper($translator)->__((string)$_option->label));
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
return $options;
|
33 |
+
}
|
34 |
+
|
35 |
+
}
|
app/code/community/Auguria/Core/Model/System/Config/Source/Customer/Group/Multiselect.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Core
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Auguria_Core_Model_System_Config_Source_Customer_Group_Multiselect
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Customer groups options array
|
14 |
+
*
|
15 |
+
* @var null|array
|
16 |
+
*/
|
17 |
+
protected $_options;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Retrieve customer groups as array
|
21 |
+
*
|
22 |
+
* @return array
|
23 |
+
*/
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
+
if (!$this->_options) {
|
27 |
+
$this->_options = Mage::getResourceModel('customer/group_collection')
|
28 |
+
//->setRealGroupsFilter() Get the NOT LOGGED IN GROUP TOO
|
29 |
+
->loadData()->toOptionArray();
|
30 |
+
}
|
31 |
+
return $this->_options;
|
32 |
+
}
|
33 |
+
|
34 |
+
}
|
app/code/community/Auguria/Core/etc/config.xml
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category Auguria
|
5 |
+
* @package Auguria_Core
|
6 |
+
* @author Auguria
|
7 |
+
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
|
12 |
+
<modules>
|
13 |
+
<Auguria_Core>
|
14 |
+
<version/>
|
15 |
+
</Auguria_Core>
|
16 |
+
</modules>
|
17 |
+
|
18 |
+
<global>
|
19 |
+
<helpers>
|
20 |
+
<auguria_core>
|
21 |
+
<class>Auguria_Core_Helper</class>
|
22 |
+
</auguria_core>
|
23 |
+
</helpers>
|
24 |
+
<models>
|
25 |
+
<auguria_core>
|
26 |
+
<class>Auguria_Core_Model</class>
|
27 |
+
</auguria_core>
|
28 |
+
</models>
|
29 |
+
</global>
|
30 |
+
|
31 |
+
<adminhtml>
|
32 |
+
<layout>
|
33 |
+
<updates>
|
34 |
+
<auguria_core>
|
35 |
+
<file>auguria/core.xml</file>
|
36 |
+
</auguria_core>
|
37 |
+
</updates>
|
38 |
+
</layout>
|
39 |
+
<translate>
|
40 |
+
<modules>
|
41 |
+
<Auguria_Core>
|
42 |
+
<files>
|
43 |
+
<default>Auguria_Core.csv</default>
|
44 |
+
</files>
|
45 |
+
</Auguria_Core>
|
46 |
+
</modules>
|
47 |
+
</translate>
|
48 |
+
</adminhtml>
|
49 |
+
|
50 |
+
</config>
|
app/code/community/Auguria/Core/etc/system.xml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Core
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
|
7 |
+
*/
|
8 |
+
-->
|
9 |
+
<config>
|
10 |
+
<tabs>
|
11 |
+
<auguria>
|
12 |
+
<label></label>
|
13 |
+
<sort_order>150</sort_order>
|
14 |
+
<class>auguria-tab</class>
|
15 |
+
</auguria>
|
16 |
+
</tabs>
|
17 |
+
</config>
|
app/code/community/Auguria/Insurance/Block/Checkout/Cart/Total/Insurance.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Insurance
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Auguria_Insurance_Block_Checkout_Cart_Total_Insurance extends Mage_Checkout_Block_Total_Default
|
10 |
+
{
|
11 |
+
protected $_insurances = null;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Custom template
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
protected $_template = 'auguria/insurance/checkout/cart/total/insurance.phtml';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Get products insurances
|
22 |
+
*
|
23 |
+
* @return array
|
24 |
+
*/
|
25 |
+
public function getInsurances()
|
26 |
+
{
|
27 |
+
if(is_null($this->_insurances)){
|
28 |
+
$this->_insurances = array();
|
29 |
+
|
30 |
+
foreach ($this->getQuote()->getItemsCollection() as $_item){
|
31 |
+
/* @var $_item Mage_Sales_Model_Quote_Item*/
|
32 |
+
if($_item->getProductType() == Auguria_Insurance_Model_Catalog_Product_Type_Insurance::AUGURIA_INSURANCE_PRODUCT_TYPE_ID){
|
33 |
+
$this->_insurances[] = $_item;
|
34 |
+
}
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
return $this->_insurances;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Get formated price with insurance configuration
|
43 |
+
*
|
44 |
+
* @param Mage_Sales_Model_Quote_Item $insurance
|
45 |
+
* @return string
|
46 |
+
*/
|
47 |
+
public function getFormatedPrice(Mage_Sales_Model_Quote_Item $insurance)
|
48 |
+
{
|
49 |
+
$displayType = Mage::helper('auguria_insurance/config')->getInsuranceCartDisplayType();
|
50 |
+
|
51 |
+
if($displayType == Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX){ // Excl. Tax
|
52 |
+
return Mage::helper('checkout')->formatPrice($insurance->getPrice());
|
53 |
+
|
54 |
+
}elseif($displayType == Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX){ // Incl. Tax
|
55 |
+
return Mage::helper('checkout')->formatPrice($insurance->getPriceInclTax());
|
56 |
+
|
57 |
+
}else{ // Both
|
58 |
+
return $this->__('Excl. Tax ') . Mage::helper('checkout')->formatPrice($insurance->getPrice())
|
59 |
+
. '<br>' . $this->__('Incl. Tax ') . Mage::helper('checkout')->formatPrice($insurance->getPriceInclTax());
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
}
|
app/code/community/Auguria/Insurance/Block/Checkout/Insurance.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Insurance
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Auguria_Insurance_Block_Checkout_Insurance extends Mage_Catalog_Block_Product
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Retrieve shopping cart model object
|
13 |
+
*
|
14 |
+
* @return Mage_Checkout_Model_Cart
|
15 |
+
*/
|
16 |
+
protected function _getCart()
|
17 |
+
{
|
18 |
+
return Mage::getSingleton('checkout/cart');
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Check if the cart is empty
|
23 |
+
*
|
24 |
+
* @return bool
|
25 |
+
*/
|
26 |
+
public function isNotEmptyCart()
|
27 |
+
{
|
28 |
+
return (bool)Mage::getSingleton('checkout/session')->getQuote()->getItemsCount();
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Get assurances associated to the current store
|
33 |
+
*
|
34 |
+
* return Mage_Catalog_Model_Resource_Product_Collection
|
35 |
+
*/
|
36 |
+
public function getInsurances()
|
37 |
+
{
|
38 |
+
return Mage::getResourceModel('catalog/product_collection')
|
39 |
+
->addAttributeToSelect('name')
|
40 |
+
->addAttributeToSelect('short_description')
|
41 |
+
->addAttributeToFilter('type_id', Auguria_Insurance_Model_Catalog_Product_Type_Insurance::AUGURIA_INSURANCE_PRODUCT_TYPE_ID)
|
42 |
+
->addStoreFilter()
|
43 |
+
->addPriceData();
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Check if insurance is in cart
|
48 |
+
*
|
49 |
+
* @param Mage_Catalog_Model_Product $insurance
|
50 |
+
* @return bool
|
51 |
+
*/
|
52 |
+
public function isInsuranceInCart(Mage_Catalog_Model_Product $insurance)
|
53 |
+
{
|
54 |
+
$items = $this->_getCart()->getItems();
|
55 |
+
|
56 |
+
if ($items && $items->getSize()) {
|
57 |
+
foreach ($items as $item) { // compare all items in cart
|
58 |
+
if ($item->getProductId() == $insurance->getId()) {
|
59 |
+
return true; // insurance exists in cart
|
60 |
+
}
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
return false;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* FOR 1.8 BUG (get special price attribute in price template)
|
69 |
+
* bug in catalog/product/price.phml line 50
|
70 |
+
*
|
71 |
+
* Retrieve attribute instance by name, id or config node
|
72 |
+
*
|
73 |
+
* If attribute is not found false is returned
|
74 |
+
*
|
75 |
+
* @param string|integer|Mage_Core_Model_Config_Element $attribute
|
76 |
+
* @return Mage_Eav_Model_Entity_Attribute_Abstract || false
|
77 |
+
*/
|
78 |
+
public function getProductAttribute($attribute)
|
79 |
+
{
|
80 |
+
return $this->getProduct()->getResource()->getAttribute($attribute);
|
81 |
+
}
|
82 |
+
|
83 |
+
}
|
app/code/community/Auguria/Insurance/Block/Sales/Order/Total/Insurance.php
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Insurance
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Auguria_Insurance_Block_Sales_Order_Total_Insurance extends Mage_Core_Block_Template
|
10 |
+
{
|
11 |
+
protected $_source;
|
12 |
+
protected $_items = array();
|
13 |
+
protected $_colspan = 4;
|
14 |
+
protected $_colspanCreditmemo = 6;
|
15 |
+
protected $_additionnalAttributes;
|
16 |
+
protected $_additionnalStyles;
|
17 |
+
protected $_store;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Get data (totals) source model
|
21 |
+
*
|
22 |
+
* @return Varien_Object
|
23 |
+
*/
|
24 |
+
public function getSource()
|
25 |
+
{
|
26 |
+
return $this->_source;
|
27 |
+
}
|
28 |
+
|
29 |
+
public function initTotals()
|
30 |
+
{
|
31 |
+
$parent = $this->getParentBlock();
|
32 |
+
$this->_source = $parent->getSource();
|
33 |
+
$this->_store = Mage::app()->getStore($this->_source->getStoreId());
|
34 |
+
|
35 |
+
if ($this->_source && $this->_hasInsurances($this->_source)) {
|
36 |
+
$this->_addInsurance();
|
37 |
+
}
|
38 |
+
|
39 |
+
return $this;
|
40 |
+
}
|
41 |
+
|
42 |
+
protected function _hasInsurances($source)
|
43 |
+
{
|
44 |
+
foreach ($source->getItemsCollection() as $_item){
|
45 |
+
if($_item instanceof Mage_Sales_Model_Order_Item){ // Order
|
46 |
+
$productType = $_item->getProductType();
|
47 |
+
}else{ // Invoice, Creditmemo
|
48 |
+
$productType = $_item->getOrderItem()->getProductType();
|
49 |
+
}
|
50 |
+
|
51 |
+
if($productType == Auguria_Insurance_Model_Catalog_Product_Type_Insurance::AUGURIA_INSURANCE_PRODUCT_TYPE_ID){ // is insurance
|
52 |
+
$this->_items[] = $_item;
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
return $this->_items;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Add insurance total string
|
61 |
+
*
|
62 |
+
* @param string $after
|
63 |
+
* @return Auguria_Insurance_Block_Sales_Order_Insurance
|
64 |
+
*/
|
65 |
+
protected function _addInsurance($after = 'last')
|
66 |
+
{
|
67 |
+
$amount = 1;
|
68 |
+
|
69 |
+
$total = new Varien_Object(array(
|
70 |
+
'code' => 'auguria_insurance',
|
71 |
+
'field' => 'auguria_insurance_amount',
|
72 |
+
'block_name' => $this->getNameInLayout(),
|
73 |
+
'value' => $amount,
|
74 |
+
'label' => $this->helper('auguria_insurance')->__('Insurances')
|
75 |
+
));
|
76 |
+
|
77 |
+
$this->getParentBlock()->addTotal($total, $after);
|
78 |
+
|
79 |
+
return $this;
|
80 |
+
}
|
81 |
+
|
82 |
+
public function getTotal()
|
83 |
+
{
|
84 |
+
return $this->getParentBlock()->getTotal('auguria_insurance');
|
85 |
+
}
|
86 |
+
|
87 |
+
public function getInsurances()
|
88 |
+
{
|
89 |
+
return $this->_items;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Set colspan (in layout)
|
94 |
+
*
|
95 |
+
* @param string $code
|
96 |
+
* @param int $number
|
97 |
+
*/
|
98 |
+
public function setColspan($code = 'default', $number)
|
99 |
+
{
|
100 |
+
if($code == 'default'){
|
101 |
+
$this->_colspan = $number;
|
102 |
+
}elseif($code == 'creditmemo'){
|
103 |
+
$this->_colspanCreditmemo = $number;
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
public function getColspan()
|
108 |
+
{
|
109 |
+
if($this->_source instanceof Mage_Sales_Model_Order_Creditmemo){
|
110 |
+
return $this->_colspanCreditmemo;
|
111 |
+
}
|
112 |
+
|
113 |
+
return $this->_colspan;
|
114 |
+
}
|
115 |
+
|
116 |
+
public function setAdditionnalAttributes($attributes)
|
117 |
+
{
|
118 |
+
$this->_additionnalAttributes = $attributes;
|
119 |
+
}
|
120 |
+
|
121 |
+
public function getAdditionnalAttributes()
|
122 |
+
{
|
123 |
+
return $this->_additionnalAttributes;
|
124 |
+
}
|
125 |
+
|
126 |
+
public function setAdditionnalStyles($styles)
|
127 |
+
{
|
128 |
+
$this->_additionnalStyles = $styles;
|
129 |
+
}
|
130 |
+
|
131 |
+
public function getAdditionnalStyles()
|
132 |
+
{
|
133 |
+
return $this->_additionnalStyles;
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Get formated price with insurance configuration
|
138 |
+
*
|
139 |
+
* @param mixed $insurance
|
140 |
+
* @return string
|
141 |
+
*/
|
142 |
+
public function getFormatedPrice($insurance)
|
143 |
+
{
|
144 |
+
$displayType = Mage::helper('auguria_insurance/config')->getInsuranceCartDisplayType();
|
145 |
+
|
146 |
+
if($displayType == Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX){ // Excl. Tax
|
147 |
+
return $this->_store->formatPrice($insurance->getPrice());
|
148 |
+
|
149 |
+
}elseif($displayType == Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX){ // Incl. Tax
|
150 |
+
return $this->_store->formatPrice($insurance->getPriceInclTax());
|
151 |
+
|
152 |
+
}else{ // Both
|
153 |
+
return $this->__('Excl. Tax ') . $this->_store->formatPrice($insurance->getPrice())
|
154 |
+
. '<br>' . $this->__('Incl. Tax ') . $this->_store->formatPrice($insurance->getPriceInclTax());
|
155 |
+
}
|
156 |
+
}
|
157 |
+
}
|
app/code/community/Auguria/Insurance/Helper/Config.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Insurance
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Auguria_Insurance_Helper_Config extends Mage_Core_Helper_Abstract
|
10 |
+
{
|
11 |
+
/* PATH TO CONFIGURATION */
|
12 |
+
const XML_PATH_INSURANCE_ACTIVE = 'auguria_insurance/general/active';
|
13 |
+
|
14 |
+
const XML_PATH_INSURANCE_CART_DISPLAY_PRICE = 'auguria_insurance/cart/display_price';
|
15 |
+
|
16 |
+
const XML_PATH_INSURANCE_SALES_DISPLAY_PRICE = 'auguria_insurance/sales/display_price';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Check if insurance extension is active for the current store
|
20 |
+
*
|
21 |
+
* @return bool
|
22 |
+
*/
|
23 |
+
public function isInsuranceActive()
|
24 |
+
{
|
25 |
+
return Mage::getStoreConfigFlag(self::XML_PATH_INSURANCE_ACTIVE);
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Check if cart price must be displayed Excl. Tax, Incl. Tax...
|
30 |
+
*
|
31 |
+
* @return int
|
32 |
+
*/
|
33 |
+
public function getInsuranceCartDisplayType()
|
34 |
+
{
|
35 |
+
return Mage::getStoreConfig(self::XML_PATH_INSURANCE_CART_DISPLAY_PRICE);
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Check if sales price must be displayed Excl. Tax, Incl. Tax...
|
40 |
+
*
|
41 |
+
* @return int
|
42 |
+
*/
|
43 |
+
public function getInsuranceSalesDisplayType()
|
44 |
+
{
|
45 |
+
return Mage::getStoreConfig(self::XML_PATH_INSURANCE_SALES_DISPLAY_PRICE);
|
46 |
+
}
|
47 |
+
}
|
app/code/community/Auguria/Insurance/Helper/Data.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Insurance
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Auguria_Insurance_Helper_Data extends Mage_Core_Helper_Abstract
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Get all insurances
|
13 |
+
*
|
14 |
+
* @return array
|
15 |
+
*/
|
16 |
+
public function getInsuranceIds()
|
17 |
+
{
|
18 |
+
return Mage::getResourceModel('catalog/product_collection')
|
19 |
+
->addAttributeToFilter('type_id', Auguria_Insurance_Model_Catalog_Product_Type_Insurance::AUGURIA_INSURANCE_PRODUCT_TYPE_ID)
|
20 |
+
->addStoreFilter()
|
21 |
+
->getAllIds();
|
22 |
+
}
|
23 |
+
|
24 |
+
public function setInsuranceExcluded($id, $value)
|
25 |
+
{
|
26 |
+
Mage::getSingleton('checkout/session')->setData("auguria_insurance_{$id}_excluded", $value);
|
27 |
+
}
|
28 |
+
|
29 |
+
public function getInsuranceExcluded($id)
|
30 |
+
{
|
31 |
+
return Mage::getSingleton('checkout/session')->getData("auguria_insurance_{$id}_excluded");
|
32 |
+
}
|
33 |
+
}
|
app/code/community/Auguria/Insurance/Model/Catalog/Product/Type/Insurance.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Insurance
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Auguria_Insurance_Model_Catalog_Product_Type_Insurance extends Mage_Catalog_Model_Product_Type_Abstract
|
10 |
+
{
|
11 |
+
const AUGURIA_INSURANCE_PRODUCT_TYPE_ID = 'auguria_insurance';
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Check is virtual product
|
15 |
+
* BUG with label cart rule ?
|
16 |
+
*
|
17 |
+
* @param Mage_Catalog_Model_Product $product
|
18 |
+
* @return bool
|
19 |
+
*/
|
20 |
+
// public function isVirtual($product = null)
|
21 |
+
// {
|
22 |
+
// return true;
|
23 |
+
// }
|
24 |
+
|
25 |
+
}
|
app/code/community/Auguria/Insurance/Model/Observer.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Insurance
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Auguria_Insurance_Model_Observer
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Update quote qty informations
|
13 |
+
*
|
14 |
+
* Event : sales_quote_collect_totals_after
|
15 |
+
*
|
16 |
+
* @param Varien_Event_Observer $observer
|
17 |
+
* @return Auguria_Insurance_Model_Observer
|
18 |
+
*/
|
19 |
+
public function initQuoteQty(Varien_Event_Observer $observer)
|
20 |
+
{
|
21 |
+
/* @var Mage_Sales_Model_Quote $quote */
|
22 |
+
$quote = $observer->getEvent()->getQuote();
|
23 |
+
|
24 |
+
$insuranceCount = 0;
|
25 |
+
$insuranceQty = 0;
|
26 |
+
|
27 |
+
// get insurance product type qty
|
28 |
+
foreach ($quote->getAllVisibleItems() as $_item){
|
29 |
+
if($_item->getProductType() == Auguria_Insurance_Model_Catalog_Product_Type_Insurance::AUGURIA_INSURANCE_PRODUCT_TYPE_ID){
|
30 |
+
$insuranceCount ++;
|
31 |
+
$insuranceQty += $_item->getQty();
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
// update quote qty informations
|
36 |
+
$quote->setItemsCount($quote->getItemsCount() - $insuranceCount);
|
37 |
+
$quote->setItemsQty((float) $quote->getItemsQty() - $insuranceQty);
|
38 |
+
|
39 |
+
return $this;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Update item qty
|
44 |
+
*
|
45 |
+
* Event : sales_quote_item_qty_set_after
|
46 |
+
*
|
47 |
+
* @param Varien_Event_Observer $observer
|
48 |
+
* @return Auguria_Insurance_Model_Observer
|
49 |
+
*/
|
50 |
+
public function initItemQty(Varien_Event_Observer $observer)
|
51 |
+
{
|
52 |
+
/* @var Mage_Sales_Model_Quote_Item $item */
|
53 |
+
$item = $observer->getEvent()->getItem();
|
54 |
+
|
55 |
+
if($item->getProductType() == Auguria_Insurance_Model_Catalog_Product_Type_Insurance::AUGURIA_INSURANCE_PRODUCT_TYPE_ID){
|
56 |
+
$item->setData('qty', 1); // force qty (bug when reorder if not forced)
|
57 |
+
}
|
58 |
+
|
59 |
+
return $this;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Init insurances in quote
|
64 |
+
*
|
65 |
+
* Event : controller_action_predispatch_checkout_cart_index
|
66 |
+
*
|
67 |
+
* @param Varien_Event_Observer $observer
|
68 |
+
* @return Auguria_Insurance_Model_Observer
|
69 |
+
*/
|
70 |
+
public function initQuoteInsurances(Varien_Event_Observer $observer)
|
71 |
+
{
|
72 |
+
/* @var Mage_Sales_Model_Quote $quote */
|
73 |
+
$quote = Mage::getSingleton('checkout/cart')->getQuote();
|
74 |
+
|
75 |
+
foreach (Mage::helper('auguria_insurance')->getInsuranceIds() as $_id){
|
76 |
+
if(!Mage::helper('auguria_insurance')->getInsuranceExcluded($_id)){
|
77 |
+
|
78 |
+
try {
|
79 |
+
$_insurance = Mage::getModel('catalog/product')->load($_id);
|
80 |
+
if($_insurance->getAuguriaInsuranceIsDefault()){ // insurance is added by default
|
81 |
+
$quote->addProduct($_insurance);
|
82 |
+
}
|
83 |
+
} catch (Exception $e) {
|
84 |
+
Mage::logException($e);
|
85 |
+
}
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
+
}
|
app/code/community/Auguria/Insurance/Model/Sales/Order/Pdf/Items/Default.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Insurance
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Auguria_Insurance_Model_Sales_Order_Pdf_Items_Default extends Mage_Sales_Model_Order_Pdf_Items_Abstract
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Draw item line
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
public function draw()
|
16 |
+
{
|
17 |
+
return $this;
|
18 |
+
}
|
19 |
+
}
|
app/code/community/Auguria/Insurance/Model/Sales/Order/Pdf/Total/Insurance.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Insurance
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Auguria_Insurance_Model_Sales_Order_Pdf_Total_Insurance extends Mage_Sales_Model_Order_Pdf_Total_Default
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Get array of arrays with totals information for display in PDF
|
13 |
+
* array(
|
14 |
+
* $index => array(
|
15 |
+
* 'amount' => $amount,
|
16 |
+
* 'label' => $label,
|
17 |
+
* 'font_size'=> $font_size
|
18 |
+
* )
|
19 |
+
* )
|
20 |
+
* @return array
|
21 |
+
*/
|
22 |
+
public function getTotalsForDisplay()
|
23 |
+
{
|
24 |
+
$label = Mage::helper('sales')->__($this->getTitle()) . ':';
|
25 |
+
$fontSize = $this->getFontSize() ? $this->getFontSize() : 7;
|
26 |
+
|
27 |
+
$totals = array(); // multiple totals
|
28 |
+
|
29 |
+
foreach ($this->getSource()->getItemsCollection() as $_item){
|
30 |
+
if($_item instanceof Mage_Sales_Model_Order_Item){ // Order
|
31 |
+
$productType = $_item->getProductType();
|
32 |
+
}else{ // Invoice, Creditmemo
|
33 |
+
$productType = $_item->getOrderItem()->getProductType();
|
34 |
+
}
|
35 |
+
|
36 |
+
if($productType == Auguria_Insurance_Model_Catalog_Product_Type_Insurance::AUGURIA_INSURANCE_PRODUCT_TYPE_ID){ // is insurance
|
37 |
+
// add the insurance total
|
38 |
+
$totals[] = array(
|
39 |
+
'amount' => $this->getFormatedPrice($_item, $this->getSource()->getStore()),
|
40 |
+
'label' => $_item->getName() . ' ' . Mage::helper('auguria_insurance')->__('(included in total amount)'),
|
41 |
+
'font_size' => $fontSize
|
42 |
+
);
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
return $totals;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Get formated price with insurance configuration
|
51 |
+
*
|
52 |
+
* @param mixed $insurance
|
53 |
+
* @return string
|
54 |
+
*/
|
55 |
+
public function getFormatedPrice($insurance, $store)
|
56 |
+
{
|
57 |
+
$displayType = Mage::helper('auguria_insurance/config')->getInsuranceCartDisplayType();
|
58 |
+
|
59 |
+
if($displayType == Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX){ // Excl. Tax
|
60 |
+
return $store->formatPrice($insurance->getPrice(), false);
|
61 |
+
|
62 |
+
}elseif($displayType == Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX){ // Incl. Tax
|
63 |
+
return $store->formatPrice($insurance->getPriceInclTax(), false);
|
64 |
+
|
65 |
+
}else{ // Both
|
66 |
+
return $this->__('Excl. Tax ') . $store->formatPrice($insurance->getPrice(), false)
|
67 |
+
. "\n" . $this->__('Incl. Tax ') . $store->formatPrice($insurance->getPriceInclTax(), false);
|
68 |
+
}
|
69 |
+
}
|
70 |
+
}
|
app/code/community/Auguria/Insurance/Model/Sales/Quote/Address/Total/Insurance.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Insurance
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Auguria_Insurance_Model_Sales_Quote_Address_Total_Insurance extends Mage_Sales_Model_Quote_Address_Total_Abstract
|
10 |
+
{
|
11 |
+
public function collect(Mage_Sales_Model_Quote_Address $address)
|
12 |
+
{
|
13 |
+
return $this;
|
14 |
+
}
|
15 |
+
|
16 |
+
public function fetch(Mage_Sales_Model_Quote_Address $address)
|
17 |
+
{
|
18 |
+
$title = Mage::helper('auguria_insurance')->__('Insurances');
|
19 |
+
|
20 |
+
$address->addTotal(array(
|
21 |
+
'code' => $this->getCode(),
|
22 |
+
'title' => $title,
|
23 |
+
'value' => 1,
|
24 |
+
'style' => 'insurance',
|
25 |
+
'area' => 'footer',
|
26 |
+
));
|
27 |
+
|
28 |
+
return $this;
|
29 |
+
}
|
30 |
+
|
31 |
+
}
|
app/code/community/Auguria/Insurance/controllers/IndexController.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Insurance
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Auguria_Insurance_IndexController extends Mage_Core_Controller_Front_Action
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Retrieve shopping cart model object
|
13 |
+
*
|
14 |
+
* @return Mage_Checkout_Model_Cart
|
15 |
+
*/
|
16 |
+
protected function _getCart()
|
17 |
+
{
|
18 |
+
return Mage::getSingleton('checkout/cart');
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Get checkout session model instance
|
23 |
+
*
|
24 |
+
* @return Mage_Checkout_Model_Session
|
25 |
+
*/
|
26 |
+
protected function _getSession()
|
27 |
+
{
|
28 |
+
return Mage::getSingleton('checkout/session');
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Initialize product instance from request data
|
33 |
+
*
|
34 |
+
* @return Mage_Catalog_Model_Product || false
|
35 |
+
*/
|
36 |
+
protected function _initProduct()
|
37 |
+
{
|
38 |
+
$productId = (int) $this->getRequest()->getParam('insurance_id');
|
39 |
+
if ($productId) {
|
40 |
+
$product = Mage::getModel('catalog/product')
|
41 |
+
->setStoreId(Mage::app()->getStore()->getId())
|
42 |
+
->load($productId);
|
43 |
+
|
44 |
+
if ($product->getId()) {
|
45 |
+
return $product;
|
46 |
+
}
|
47 |
+
}
|
48 |
+
return false;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Add/Remove insurance to/from the cart
|
53 |
+
*/
|
54 |
+
public function updateInsuranceAction()
|
55 |
+
{
|
56 |
+
try {
|
57 |
+
|
58 |
+
if(!$this->getRequest()->getParam('is_in_cart')){ // insurance to add
|
59 |
+
if($insurance = $this->_initProduct()){ // init product insurance and check id
|
60 |
+
$cart = $this->_getCart();
|
61 |
+
$session = $this->_getSession();
|
62 |
+
|
63 |
+
$cart->addProduct($insurance); // qty forced in observer
|
64 |
+
$cart->save();
|
65 |
+
|
66 |
+
$session->setCartWasUpdated(true);
|
67 |
+
$session->addSuccess($this->__('The insurance has been added to the cart'));
|
68 |
+
}
|
69 |
+
}else{ // remove insurance
|
70 |
+
if($insuranceId = $this->getRequest()->getParam('insurance_id')){ // check insurance id
|
71 |
+
$cart = $this->_getCart();
|
72 |
+
$session = $this->_getSession();
|
73 |
+
$items = $cart->getItems();
|
74 |
+
|
75 |
+
if($items && $items->getSize()){ // if cart is not empty
|
76 |
+
foreach ($items as $_item){
|
77 |
+
if($_item->getProductId() == $insuranceId){
|
78 |
+
$cart->removeItem($_item->getId()); // remove assurance
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
$cart->save();
|
83 |
+
|
84 |
+
$session->setCartWasUpdated(true);
|
85 |
+
Mage::helper('auguria_insurance')->setInsuranceExcluded($insuranceId, 1); // for not adding it to cart automatically
|
86 |
+
$session->addSuccess($this->__('The insurance has been removed from the cart'));
|
87 |
+
}
|
88 |
+
}
|
89 |
+
}
|
90 |
+
} catch (Exception $e) {
|
91 |
+
$this->_getSession()->addError($this->__("An error occurs while updating the insurance in the cart"));
|
92 |
+
Mage::logException($e);
|
93 |
+
}
|
94 |
+
|
95 |
+
$this->_redirect('checkout/cart');
|
96 |
+
}
|
97 |
+
|
98 |
+
}
|
app/code/community/Auguria/Insurance/etc/adminhtml.xml
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category Auguria
|
5 |
+
* @package Auguria_Insurance
|
6 |
+
* @author Auguria
|
7 |
+
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<acl>
|
12 |
+
<resources>
|
13 |
+
<admin>
|
14 |
+
<children>
|
15 |
+
<system>
|
16 |
+
<children>
|
17 |
+
<config>
|
18 |
+
<children>
|
19 |
+
<auguria_insurance translate="title" module="auguria_insurance">
|
20 |
+
<title>Auguria insurance</title>
|
21 |
+
</auguria_insurance>
|
22 |
+
</children>
|
23 |
+
</config>
|
24 |
+
</children>
|
25 |
+
</system>
|
26 |
+
</children>
|
27 |
+
</admin>
|
28 |
+
</resources>
|
29 |
+
</acl>
|
30 |
+
</config>
|
app/code/community/Auguria/Insurance/etc/config.xml
ADDED
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category Auguria
|
5 |
+
* @package Auguria_Insurance
|
6 |
+
* @author Auguria
|
7 |
+
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
|
12 |
+
<modules>
|
13 |
+
<Auguria_Insurance>
|
14 |
+
<version>0.0.1</version>
|
15 |
+
</Auguria_Insurance>
|
16 |
+
</modules>
|
17 |
+
|
18 |
+
<global>
|
19 |
+
<resources>
|
20 |
+
<auguria_insurance_setup>
|
21 |
+
<setup>
|
22 |
+
<module>Auguria_Insurance</module>
|
23 |
+
<class>Mage_Catalog_Model_Resource_Setup</class>
|
24 |
+
</setup>
|
25 |
+
</auguria_insurance_setup>
|
26 |
+
</resources>
|
27 |
+
<blocks>
|
28 |
+
<auguria_insurance>
|
29 |
+
<class>Auguria_Insurance_Block</class>
|
30 |
+
</auguria_insurance>
|
31 |
+
</blocks>
|
32 |
+
<helpers>
|
33 |
+
<auguria_insurance>
|
34 |
+
<class>Auguria_Insurance_Helper</class>
|
35 |
+
</auguria_insurance>
|
36 |
+
</helpers>
|
37 |
+
<models>
|
38 |
+
<auguria_insurance>
|
39 |
+
<class>Auguria_Insurance_Model</class>
|
40 |
+
</auguria_insurance>
|
41 |
+
</models>
|
42 |
+
<events>
|
43 |
+
<sales_quote_collect_totals_after>
|
44 |
+
<observers>
|
45 |
+
<auguria_insurance_quote_summary_qty>
|
46 |
+
<class>auguria_insurance/observer</class>
|
47 |
+
<method>initQuoteQty</method>
|
48 |
+
</auguria_insurance_quote_summary_qty>
|
49 |
+
</observers>
|
50 |
+
</sales_quote_collect_totals_after>
|
51 |
+
<sales_quote_item_qty_set_after>
|
52 |
+
<observers>
|
53 |
+
<auguria_insurance_quote_item_qty>
|
54 |
+
<class>auguria_insurance/observer</class>
|
55 |
+
<method>initItemQty</method>
|
56 |
+
</auguria_insurance_quote_item_qty>
|
57 |
+
</observers>
|
58 |
+
</sales_quote_item_qty_set_after>
|
59 |
+
<controller_action_predispatch_checkout_cart_index>
|
60 |
+
<observers>
|
61 |
+
<auguria_insurance_init_quote_insurances>
|
62 |
+
<class>auguria_insurance/observer</class>
|
63 |
+
<method>initQuoteInsurances</method>
|
64 |
+
</auguria_insurance_init_quote_insurances>
|
65 |
+
</observers>
|
66 |
+
</controller_action_predispatch_checkout_cart_index>
|
67 |
+
</events>
|
68 |
+
|
69 |
+
<catalog>
|
70 |
+
<product>
|
71 |
+
<type>
|
72 |
+
<auguria_insurance translate="label" module="auguria_insurance">
|
73 |
+
<label>Insurance product</label>
|
74 |
+
<model>auguria_insurance/catalog_product_type_insurance</model>
|
75 |
+
<composite>0</composite>
|
76 |
+
<index_priority>0</index_priority>
|
77 |
+
</auguria_insurance>
|
78 |
+
</type>
|
79 |
+
</product>
|
80 |
+
</catalog>
|
81 |
+
<sales>
|
82 |
+
<quote>
|
83 |
+
<totals>
|
84 |
+
<auguria_insurance>
|
85 |
+
<class>auguria_insurance/sales_quote_address_total_insurance</class>
|
86 |
+
<after>-</after>
|
87 |
+
<renderer>auguria_insurance/checkout_cart_total_insurance</renderer>
|
88 |
+
<admin_renderer>auguria_insurance/adminhtml_checkout_cart_total_insurance</admin_renderer>
|
89 |
+
</auguria_insurance>
|
90 |
+
</totals>
|
91 |
+
</quote>
|
92 |
+
</sales>
|
93 |
+
<pdf>
|
94 |
+
<totals>
|
95 |
+
<auguria_insurance translate="title">
|
96 |
+
<title>Insurances</title>
|
97 |
+
<model>auguria_insurance/sales_order_pdf_total_insurance</model>
|
98 |
+
<font_size>7</font_size>
|
99 |
+
<display_zero>1</display_zero>
|
100 |
+
<sort_order>800</sort_order>
|
101 |
+
</auguria_insurance>
|
102 |
+
</totals>
|
103 |
+
<invoice>
|
104 |
+
<auguria_insurance>auguria_insurance/sales_order_pdf_items_default</auguria_insurance>
|
105 |
+
</invoice>
|
106 |
+
<shipment>
|
107 |
+
<auguria_insurance>auguria_insurance/sales_order_pdf_items_default</auguria_insurance>
|
108 |
+
</shipment>
|
109 |
+
<creditmemo>
|
110 |
+
<auguria_insurance>auguria_insurance/sales_order_pdf_items_default</auguria_insurance>
|
111 |
+
</creditmemo>
|
112 |
+
</pdf>
|
113 |
+
</global>
|
114 |
+
|
115 |
+
<frontend>
|
116 |
+
<routers>
|
117 |
+
<auguria_insurance>
|
118 |
+
<use>standard</use>
|
119 |
+
<args>
|
120 |
+
<module>Auguria_Insurance</module>
|
121 |
+
<frontName>insurance</frontName>
|
122 |
+
</args>
|
123 |
+
</auguria_insurance>
|
124 |
+
</routers>
|
125 |
+
<layout>
|
126 |
+
<updates>
|
127 |
+
<auguria_insurance>
|
128 |
+
<file>auguria/insurance.xml</file>
|
129 |
+
</auguria_insurance>
|
130 |
+
</updates>
|
131 |
+
</layout>
|
132 |
+
<translate>
|
133 |
+
<modules>
|
134 |
+
<Auguria_Insurance>
|
135 |
+
<files>
|
136 |
+
<default>Auguria_Insurance.csv</default>
|
137 |
+
</files>
|
138 |
+
</Auguria_Insurance>
|
139 |
+
</modules>
|
140 |
+
</translate>
|
141 |
+
</frontend>
|
142 |
+
|
143 |
+
<adminhtml>
|
144 |
+
<layout>
|
145 |
+
<updates>
|
146 |
+
<auguria_insurance>
|
147 |
+
<file>auguria/insurance.xml</file>
|
148 |
+
</auguria_insurance>
|
149 |
+
</updates>
|
150 |
+
</layout>
|
151 |
+
<translate>
|
152 |
+
<modules>
|
153 |
+
<Auguria_Insurance>
|
154 |
+
<files>
|
155 |
+
<default>Auguria_Insurance.csv</default>
|
156 |
+
</files>
|
157 |
+
</Auguria_Insurance>
|
158 |
+
</modules>
|
159 |
+
</translate>
|
160 |
+
<sales>
|
161 |
+
<order>
|
162 |
+
<create>
|
163 |
+
<available_product_types>
|
164 |
+
<auguria_insurance/>
|
165 |
+
</available_product_types>
|
166 |
+
</create>
|
167 |
+
</order>
|
168 |
+
</sales>
|
169 |
+
</adminhtml>
|
170 |
+
|
171 |
+
<default>
|
172 |
+
<auguria_insurance>
|
173 |
+
<general>
|
174 |
+
<active>1</active>
|
175 |
+
</general>
|
176 |
+
<cart>
|
177 |
+
<display_price>2</display_price>
|
178 |
+
</cart>
|
179 |
+
<sales>
|
180 |
+
<display_price>2</display_price>
|
181 |
+
</sales>
|
182 |
+
</auguria_insurance>
|
183 |
+
</default>
|
184 |
+
|
185 |
+
</config>
|
app/code/community/Auguria/Insurance/etc/system.xml
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Insurance
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
|
7 |
+
*/
|
8 |
+
-->
|
9 |
+
<config>
|
10 |
+
<sections>
|
11 |
+
<auguria_insurance translate="label" module="auguria_insurance">
|
12 |
+
<label>Insurance</label>
|
13 |
+
<tab>auguria</tab>
|
14 |
+
<header_css>auguria-header</header_css>
|
15 |
+
<frontend_type>text</frontend_type>
|
16 |
+
<sort_order>1100</sort_order>
|
17 |
+
<show_in_default>1</show_in_default>
|
18 |
+
<show_in_website>1</show_in_website>
|
19 |
+
<show_in_store>0</show_in_store>
|
20 |
+
<groups>
|
21 |
+
<general translate="label">
|
22 |
+
<label>General</label>
|
23 |
+
<frontend_type>text</frontend_type>
|
24 |
+
<sort_order>10</sort_order>
|
25 |
+
<show_in_default>1</show_in_default>
|
26 |
+
<show_in_website>1</show_in_website>
|
27 |
+
<show_in_store>1</show_in_store>
|
28 |
+
<fields>
|
29 |
+
<active translate="label">
|
30 |
+
<label>Is active</label>
|
31 |
+
<frontend_type>select</frontend_type>
|
32 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
33 |
+
<sort_order>1</sort_order>
|
34 |
+
<show_in_default>1</show_in_default>
|
35 |
+
<show_in_website>1</show_in_website>
|
36 |
+
<show_in_store>1</show_in_store>
|
37 |
+
</active>
|
38 |
+
</fields>
|
39 |
+
</general>
|
40 |
+
<cart tanslate="label">
|
41 |
+
<label>Cart</label>
|
42 |
+
<frontend_type>text</frontend_type>
|
43 |
+
<sort_order>20</sort_order>
|
44 |
+
<show_in_default>1</show_in_default>
|
45 |
+
<show_in_website>1</show_in_website>
|
46 |
+
<show_in_store>1</show_in_store>
|
47 |
+
<fields>
|
48 |
+
<display_price translate="label">
|
49 |
+
<label>Display prices</label>
|
50 |
+
<frontend_type>select</frontend_type>
|
51 |
+
<source_model>tax/system_config_source_tax_display_type</source_model>
|
52 |
+
<sort_order>10</sort_order>
|
53 |
+
<show_in_default>1</show_in_default>
|
54 |
+
<show_in_website>1</show_in_website>
|
55 |
+
<show_in_store>1</show_in_store>
|
56 |
+
</display_price>
|
57 |
+
</fields>
|
58 |
+
</cart>
|
59 |
+
<sales tanslate="label">
|
60 |
+
<label>Orders, invoices, creditmemos</label>
|
61 |
+
<frontend_type>text</frontend_type>
|
62 |
+
<sort_order>30</sort_order>
|
63 |
+
<show_in_default>1</show_in_default>
|
64 |
+
<show_in_website>1</show_in_website>
|
65 |
+
<show_in_store>1</show_in_store>
|
66 |
+
<fields>
|
67 |
+
<display_price translate="label">
|
68 |
+
<label>Display prices</label>
|
69 |
+
<frontend_type>select</frontend_type>
|
70 |
+
<source_model>tax/system_config_source_tax_display_type</source_model>
|
71 |
+
<sort_order>10</sort_order>
|
72 |
+
<show_in_default>1</show_in_default>
|
73 |
+
<show_in_website>1</show_in_website>
|
74 |
+
<show_in_store>1</show_in_store>
|
75 |
+
</display_price>
|
76 |
+
</fields>
|
77 |
+
</sales>
|
78 |
+
</groups>
|
79 |
+
</auguria_insurance>
|
80 |
+
</sections>
|
81 |
+
</config>
|
app/code/community/Auguria/Insurance/sql/auguria_insurance_setup/install-0.0.1.php
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_ProductMatrix
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
|
7 |
+
*/
|
8 |
+
|
9 |
+
/* @var $this Mage_Catalog_Model_Resource_Setup */
|
10 |
+
|
11 |
+
$entityTypeId = $this->getEntityTypeId('catalog_product');
|
12 |
+
|
13 |
+
# add price attribute for insurance product
|
14 |
+
|
15 |
+
/* @var $attribute array */
|
16 |
+
$attribute = $this->getAttribute($entityTypeId, 'price');
|
17 |
+
|
18 |
+
$applyTo = $attribute['apply_to']; // get existing apply to product type for attribute
|
19 |
+
$applyToAsArray = explode(',', $applyTo);
|
20 |
+
|
21 |
+
$applyToAsArray[] = Auguria_Insurance_Model_Catalog_Product_Type_Insurance::AUGURIA_INSURANCE_PRODUCT_TYPE_ID; // add insurance produc type
|
22 |
+
$applyToAsArray = array_unique($applyToAsArray); // prevent doublon
|
23 |
+
$applyTo = join(',', $applyToAsArray);
|
24 |
+
|
25 |
+
$this->updateAttribute($entityTypeId, 'price', 'apply_to', $applyTo); // update attribute
|
26 |
+
|
27 |
+
# add tax class id attribute for insurance product
|
28 |
+
|
29 |
+
/* @var $attribute Mage_Catalog_Model_Entity_Attribute */
|
30 |