00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 class Mage_Weee_Model_Mysql4_Attribute_Backend_Weee_Tax extends Mage_Core_Model_Mysql4_Abstract
00037 {
00038 protected function _construct()
00039 {
00040 $this->_init('weee/tax', 'value_id');
00041 }
00042
00043 public function loadProductData($product, $attribute)
00044 {
00045 $select = $this->_getReadAdapter()->select()
00046 ->from($this->getMainTable(), array(
00047 'website_id',
00048 'country',
00049 'state',
00050 'value'
00051 ))
00052 ->where('entity_id=?', $product->getId())
00053 ->where('attribute_id=?', $attribute->getId());
00054 if ($attribute->isScopeGlobal()) {
00055 $select->where('website_id=?', 0);
00056 }
00057 else {
00058 if ($storeId = $product->getStoreId()) {
00059 $select->where('website_id IN (?)', array(0, Mage::app()->getStore($storeId)->getWebsiteId()));
00060 }
00061 }
00062 return $this->_getReadAdapter()->fetchAll($select);
00063 }
00064
00065 public function deleteProductData($product, $attribute)
00066 {
00067 $condition = array();
00068
00069 if (!$attribute->isScopeGlobal()) {
00070 if ($storeId = $product->getStoreId()) {
00071 $condition[] = $this->_getWriteAdapter()->quoteInto('website_id IN (?)', array(0, Mage::app()->getStore($storeId)->getWebsiteId()));
00072 }
00073 }
00074
00075 $condition[] = $this->_getWriteAdapter()->quoteInto('entity_id=?', $product->getId());
00076 $condition[] = $this->_getWriteAdapter()->quoteInto('attribute_id=?', $attribute->getId());
00077
00078 $this->_getWriteAdapter()->delete($this->getMainTable(), implode(' AND ', $condition));
00079 return $this;
00080 }
00081
00082 public function insertProductData($product, $data)
00083 {
00084 $data['entity_id'] = $product->getId();
00085 $data['entity_type_id'] = $product->getEntityTypeId();
00086
00087 $this->_getWriteAdapter()->insert($this->getMainTable(), $data);
00088 return $this;
00089 }
00090 }