Version Notes
DataFeedWatch Release version 0.2.1
Download this release
Release Info
| Developer | DataFeedWatch |
| Extension | DataFeedWatch_Connector |
| Version | 0.2.1 |
| Comparing to | |
| See all releases | |
Code changes from version 0.2.0 to 0.2.1
app/code/local/DataFeedWatch/Connector/Model/Datafeedwatch/Api.php
CHANGED
|
@@ -1,269 +1,334 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
-
class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model_Product_Api
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
}
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
$collection = Mage::getModel(self::CATALOG_PRODUCT_MODEL)
|
| 62 |
-
->getCollection()
|
| 63 |
-
->addAttributeToSelect('*')
|
| 64 |
-
->setPage($options['page'],$options['per_page']);
|
| 65 |
-
|
| 66 |
-
if (array_key_exists('store', $options)) {
|
| 67 |
-
$collection->addStoreFilter($this->_getStoreId($options['store']));
|
| 68 |
-
}
|
| 69 |
-
|
| 70 |
-
// clear options that are not filters
|
| 71 |
-
unset($options['page']);
|
| 72 |
-
unset($options['per_page']);
|
| 73 |
-
unset($options['store']);
|
| 74 |
-
|
| 75 |
-
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
| 76 |
-
$imageBaseURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).self::CATALOG_PRODUCT_MODEL;
|
| 77 |
-
|
| 78 |
-
$this->_loadCategories();
|
| 79 |
-
|
| 80 |
-
/** @var $apiHelper Mage_Api_Helper_Data */
|
| 81 |
-
$apiHelper = Mage::helper('api');
|
| 82 |
-
$filters = $apiHelper->parseFilters($options, $this->_filtersMap);
|
| 83 |
-
try {
|
| 84 |
-
foreach ($filters as $field => $value) {
|
| 85 |
-
$collection->addFieldToFilter($field, $value);
|
| 86 |
-
}
|
| 87 |
-
} catch (Mage_Core_Exception $e) {
|
| 88 |
-
$this->_fault('filters_invalid', $e->getMessage());
|
| 89 |
-
}
|
| 90 |
-
|
| 91 |
-
$result = array();
|
| 92 |
-
$product_cache = array();
|
| 93 |
-
$price_keys = array('price','special_price');
|
| 94 |
-
|
| 95 |
-
foreach ($collection as $product) {
|
| 96 |
-
$product_result = array( // Basic product data
|
| 97 |
-
'product_id' => $product->getId(),
|
| 98 |
-
'sku' => $product->getSku()
|
| 99 |
-
);
|
| 100 |
-
|
| 101 |
-
$parent_id = '0';
|
| 102 |
-
|
| 103 |
-
if ($product->getTypeId() == "simple") {
|
| 104 |
-
$parentIds = Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($product->getId());
|
| 105 |
-
if (!$parentIds) {
|
| 106 |
-
$parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
|
| 107 |
}
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 269 |
}
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model_Product_Api {
|
| 4 |
+
|
| 5 |
+
const STOCK_ITEM_MODEL = 'cataloginventory/stock_item';
|
| 6 |
+
const CATALOG_PRODUCT_MODEL = 'catalog/product';
|
| 7 |
+
|
| 8 |
+
// category
|
| 9 |
+
const CATALOG_CATEGORY_MODEL = 'catalog/category';
|
| 10 |
+
const CATEGORY_NAME_FIELD = 'name';
|
| 11 |
+
const CATEGORY_SEPARATOR = ' > ';
|
| 12 |
+
|
| 13 |
+
public function __construct() {
|
| 14 |
+
$this->categories = array();
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
public function version() {
|
| 18 |
+
return "0.2.0"; // this needs to be updated in etc/config.xml as well
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
public function product_count($options = array()) {
|
| 22 |
+
$collection = Mage::getModel(self::CATALOG_PRODUCT_MODEL)
|
| 23 |
+
->getCollection();
|
| 24 |
+
|
| 25 |
+
if (array_key_exists('store', $options)) {
|
| 26 |
+
$collection->addStoreFilter($this->_getStoreId($options['store']));
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
$apiHelper = Mage::helper('api');
|
| 30 |
+
$filters = $apiHelper->parseFilters($options, $this->_filtersMap);
|
| 31 |
+
try {
|
| 32 |
+
foreach ($filters as $field => $value) {
|
| 33 |
+
$collection->addFieldToFilter($field, $value);
|
| 34 |
+
}
|
| 35 |
+
} catch (Mage_Core_Exception $e) {
|
| 36 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
$numberOfProducts = 0;
|
| 40 |
+
if (!empty($collection)) {
|
| 41 |
+
$numberOfProducts = $collection->getSize();
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
return round($numberOfProducts);
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
public function products($options = array()) {
|
| 48 |
+
|
| 49 |
+
if (!array_key_exists('page', $options)) {
|
| 50 |
+
$options['page'] = 1;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
if (!array_key_exists('per_page', $options)) {
|
| 54 |
+
$options['per_page'] = 100;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
$collection = Mage::getModel(self::CATALOG_PRODUCT_MODEL)
|
| 58 |
+
->getCollection()
|
| 59 |
+
->addAttributeToSelect('*')
|
| 60 |
+
->setPage($options['page'], $options['per_page']);
|
| 61 |
+
|
| 62 |
+
if (array_key_exists('store', $options)) {
|
| 63 |
+
$collection->addStoreFilter($this->_getStoreId($options['store']));
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
// clear options that are not filters
|
| 67 |
+
unset($options['page']);
|
| 68 |
+
unset($options['per_page']);
|
| 69 |
+
unset($options['store']);
|
| 70 |
+
|
| 71 |
+
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
| 72 |
+
$imageBaseURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . self::CATALOG_PRODUCT_MODEL;
|
| 73 |
+
|
| 74 |
+
$this->_loadCategories();
|
| 75 |
+
|
| 76 |
+
/** @var $apiHelper Mage_Api_Helper_Data */
|
| 77 |
+
$apiHelper = Mage::helper('api');
|
| 78 |
+
$filters = $apiHelper->parseFilters($options, $this->_filtersMap);
|
| 79 |
+
try {
|
| 80 |
+
foreach ($filters as $field => $value) {
|
| 81 |
+
$collection->addFieldToFilter($field, $value);
|
| 82 |
+
}
|
| 83 |
+
} catch (Mage_Core_Exception $e) {
|
| 84 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
$result = array();
|
| 88 |
+
$product_cache = array();
|
| 89 |
+
$price_keys = array('price', 'special_price');
|
| 90 |
+
|
| 91 |
+
foreach ($collection as $product) {
|
| 92 |
+
$product_result = array(// Basic product data
|
| 93 |
+
'product_id' => $product->getId(),
|
| 94 |
+
'sku' => $product->getSku()
|
| 95 |
+
);
|
| 96 |
+
|
| 97 |
+
$parent_id = '0';
|
| 98 |
+
$configrable = false;
|
| 99 |
+
|
| 100 |
+
if ($product->getTypeId() == "simple") {
|
| 101 |
+
$parentIds = Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($product->getId());
|
| 102 |
+
if (!$parentIds) {
|
| 103 |
+
$parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
|
| 104 |
+
if (isset($parentIds[0])) {
|
| 105 |
+
$configrable = true;
|
| 106 |
+
}
|
| 107 |
}
|
| 108 |
+
if (isset($parentIds[0])) {
|
| 109 |
+
$parent_id = Mage::getModel('catalog/product')->load($parentIds[0])->getId();
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
$product_result['parent_id'] = $parent_id;
|
| 114 |
+
|
| 115 |
+
foreach ($product->getAttributes() as $attribute) {
|
| 116 |
+
if (!array_key_exists($attribute->getAttributeCode(), $this->_notNeededFields())) {
|
| 117 |
+
$value = $product->getData($attribute->getAttributeCode());
|
| 118 |
+
if (!empty($value)) {
|
| 119 |
+
if (in_array($attribute->getAttributeCode(), $price_keys)) {
|
| 120 |
+
$value = sprintf("%.2f", round(trim($attribute->getFrontend()->getValue($product)), 2));
|
| 121 |
+
} else {
|
| 122 |
+
$value = trim($attribute->getFrontend()->getValue($product));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
}
|
| 124 |
+
}
|
| 125 |
+
$product_result[$attribute->getAttributeCode()] = $value;
|
| 126 |
+
}
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
$product_result['product_url'] = $baseUrl . $product->getUrlPath();
|
| 130 |
+
$product_result['image_url'] = $imageBaseURL . $product->getImage();
|
| 131 |
+
|
| 132 |
+
$tmpPrices = array();
|
| 133 |
+
if($parent_id && $configrable && $product->getVisibility() == 1) {
|
| 134 |
+
$tmpPrices = $this->getDisplayPrice($parent_id);
|
| 135 |
+
|
| 136 |
+
} else {
|
| 137 |
+
$tmpPrices = $this->getDisplayPrice($product->getId());
|
| 138 |
+
}
|
| 139 |
+
if(count($tmpPrices)) {
|
| 140 |
+
$product_result['price'] = $tmpPrices['price'];
|
| 141 |
+
$product_result['price_with_tax'] = $tmpPrices['price_with_tax'];
|
| 142 |
+
$product_result['special_price'] = $tmpPrices['special_price'];
|
| 143 |
+
$product_result['special_price_with_tax'] = $tmpPrices['special_price_with_tax'];
|
| 144 |
+
$product_result['special_from_date'] = $tmpPrices['special_from_date'];
|
| 145 |
+
$product_result['special_to_date'] = $tmpPrices['special_to_date'];
|
| 146 |
+
$product_result['product_url'] = $tmpPrices['product_url'];
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
$inventoryStatus = Mage::getModel(self::STOCK_ITEM_MODEL)->loadByProduct($product);
|
| 151 |
+
if (!empty($inventoryStatus)) {
|
| 152 |
+
$product_result['quantity'] = (int) $inventoryStatus->getQty();
|
| 153 |
+
$product_result['is_in_stock'] = $inventoryStatus->getIsInStock() == '1' ? 1 : 0;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
// categories
|
| 157 |
+
$category_id = $product->getCategoryIds();
|
| 158 |
+
if (empty($category_id)) {
|
| 159 |
+
$product_result['category_name'] = '';
|
| 160 |
+
$product_result['category_parent_name'] = '';
|
| 161 |
+
$product_result['category_path'] = '';
|
| 162 |
+
} else {
|
| 163 |
+
$category = $this->categories[$category_id[0]];
|
| 164 |
+
$product_result['category_name'] = $category['name'];
|
| 165 |
+
$product_result['category_parent_name'] = $this->categories[$category['parent_id']]['name'];
|
| 166 |
+
$product_result['category_path'] = implode(' > ', $this->_buildCategoryPath($category['category_id']));
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
$result[] = $product_result;
|
| 170 |
+
}
|
| 171 |
+
return $result;
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
private function _loadCategories() {
|
| 175 |
+
$parentId = 1;
|
| 176 |
+
|
| 177 |
+
/* @var $tree Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Tree */
|
| 178 |
+
$tree = Mage::getResourceSingleton('catalog/category_tree')->load();
|
| 179 |
+
$root = $tree->getNodeById($parentId);
|
| 180 |
+
|
| 181 |
+
if ($root && $root->getId() == 1) {
|
| 182 |
+
$root->setName(Mage::helper('catalog')->__('Root'));
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
$collection = Mage::getModel('catalog/category')->getCollection()
|
| 186 |
+
->setStoreId($this->_getStoreId(null))
|
| 187 |
+
->addAttributeToSelect('name')
|
| 188 |
+
->addAttributeToSelect('is_active');
|
| 189 |
+
|
| 190 |
+
$tree->addCollectionData($collection, true);
|
| 191 |
+
|
| 192 |
+
return $this->_nodeToArray($root);
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
/**
|
| 196 |
+
* Convert node to array
|
| 197 |
+
*
|
| 198 |
+
* @param Varien_Data_Tree_Node $node
|
| 199 |
+
* @return array
|
| 200 |
+
*/
|
| 201 |
+
private function _nodeToArray(Varien_Data_Tree_Node $node) {
|
| 202 |
+
$children = $node->getChildren();
|
| 203 |
+
if (!empty($children)) {
|
| 204 |
+
foreach ($children as $child) {
|
| 205 |
+
$this->_nodeToArray($child);
|
| 206 |
+
}
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
$this->categories[$node->getId()] = array(
|
| 210 |
+
'category_id' => $node->getId(),
|
| 211 |
+
'parent_id' => $node->getParentId(),
|
| 212 |
+
'name' => $node->getName(),
|
| 213 |
+
'is_active' => $node->getIsActive()
|
| 214 |
+
);
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
private function _buildCategoryPath($category_id, &$path = array()) {
|
| 218 |
+
$category = $this->categories[$category_id];
|
| 219 |
+
|
| 220 |
+
if ($category['parent_id'] != '0') {
|
| 221 |
+
$this->_buildCategoryPath($category['parent_id'], $path);
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
if ($category['is_active'] == '1') {
|
| 225 |
+
$path[] = $category['name'];
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
return $path;
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
private function _notNeededFields() {
|
| 232 |
+
return array(
|
| 233 |
+
'type' => 0,
|
| 234 |
+
'type_id' => 0,
|
| 235 |
+
'set' => 0,
|
| 236 |
+
'categories' => 0,
|
| 237 |
+
'websites' => 0,
|
| 238 |
+
'old_id' => 0,
|
| 239 |
+
'news_from_date' => 0,
|
| 240 |
+
'news_to_date' => 0,
|
| 241 |
+
'category_ids' => 0,
|
| 242 |
+
'required_options' => 0,
|
| 243 |
+
'has_options' => 0,
|
| 244 |
+
'image_label' => 0,
|
| 245 |
+
'small_image_label' => 0,
|
| 246 |
+
'thumbnail_label' => 0,
|
| 247 |
+
'created_at' => 0,
|
| 248 |
+
'updated_at' => 0,
|
| 249 |
+
'group_price' => 0,
|
| 250 |
+
'tier_price' => 0,
|
| 251 |
+
'msrp_enabled' => 0,
|
| 252 |
+
'minimal_price' => 0,
|
| 253 |
+
'msrp_display_actual_price_type' => 0,
|
| 254 |
+
'msrp' => 0,
|
| 255 |
+
'enable_googlecheckout' => 0,
|
| 256 |
+
'is_recurring' => 0,
|
| 257 |
+
'recurring_profile' => 0,
|
| 258 |
+
'custom_design' => 0,
|
| 259 |
+
'custom_design_from' => 0,
|
| 260 |
+
'custom_design_to' => 0,
|
| 261 |
+
'custom_layout_update' => 0,
|
| 262 |
+
'page_layout' => 0,
|
| 263 |
+
'options_container' => 0,
|
| 264 |
+
'gift_message_available' => 0,
|
| 265 |
+
'url_key' => 0,
|
| 266 |
+
'url_path' => 0,
|
| 267 |
+
'conopy_diameter' => 0,
|
| 268 |
+
'image' => 0,
|
| 269 |
+
'small_image' => 0,
|
| 270 |
+
'thumbnail' => 0,
|
| 271 |
+
'media_gallery' => 0,
|
| 272 |
+
'gallery' => 0,
|
| 273 |
+
'entity_type_id' => 0,
|
| 274 |
+
'attribute_set_id' => 0,
|
| 275 |
+
'entity_id' => 0
|
| 276 |
+
);
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
private function getDisplayPrice($product_id = 0) {
|
| 280 |
+
|
| 281 |
+
if ($product_id < 1) {
|
| 282 |
+
return 0;
|
| 283 |
+
}
|
| 284 |
+
$prices = array();
|
| 285 |
+
|
| 286 |
+
$product = Mage::getModel('catalog/product')->load($product_id);
|
| 287 |
+
$store_code = Mage::app()->getStore()->getCode();
|
| 288 |
+
$_taxHelper = Mage::helper('tax');
|
| 289 |
+
// Get Currency Code
|
| 290 |
+
$bas_curncy_code = Mage::app()->getStore()->getBaseCurrencyCode();
|
| 291 |
+
$cur_curncy_code = Mage::app()->getStore($store_code)->getCurrentCurrencyCode();
|
| 292 |
+
|
| 293 |
+
$allowedCurrencies = Mage::getModel('directory/currency')
|
| 294 |
+
->getConfigAllowCurrencies();
|
| 295 |
+
$currencyRates = Mage::getModel('directory/currency')
|
| 296 |
+
->getCurrencyRates($bas_curncy_code, array_values($allowedCurrencies));
|
| 297 |
+
|
| 298 |
+
$prices['price_with_tax'] = $_finalPriceInclTax = $_taxHelper->getPrice($product, $product->getPrice(), 2);//$product['price'];
|
| 299 |
+
$prices['price'] = $_taxHelper->getPrice($product, $product->getPrice(), NULL);
|
| 300 |
+
$prices['special_price'] = 0;
|
| 301 |
+
$prices['special_price_with_tax'] = 0;
|
| 302 |
+
$prices['special_from_date'] = '';
|
| 303 |
+
$prices['special_to_date'] = '';
|
| 304 |
+
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
| 305 |
+
$prices['product_url'] = $baseUrl . $product->getUrlPath();
|
| 306 |
+
|
| 307 |
+
$specialTmpPrice = $product->getSpecialPrice();
|
| 308 |
+
|
| 309 |
+
if ($specialTmpPrice && (strtotime(date('Y-m-d H:i:s')) < strtotime($product['special_to_date'])
|
| 310 |
+
|| empty($product['special_to_date']))) {
|
| 311 |
+
$prices['special_price'] = $_taxHelper->getPrice($product, $product->getSpecialPrice(), NULL);
|
| 312 |
+
$prices['special_price_with_tax'] = $_taxHelper->getPrice($product, $product->getSpecialPrice(), 2);
|
| 313 |
+
$prices['special_from_date'] = $product['special_from_date'];
|
| 314 |
+
$prices['special_to_date'] = $product['special_to_date'];
|
| 315 |
+
//round($product->getSpecialPrice(), 2);
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
if ($bas_curncy_code != $cur_curncy_code
|
| 319 |
+
&& array_key_exists($bas_curncy_code, $currencyRates)
|
| 320 |
+
&& array_key_exists($cur_curncy_code, $currencyRates)
|
| 321 |
+
) {
|
| 322 |
+
if ($prices['special_price'] && (strtotime(date('Y-m-d H:i:s')) < strtotime($product['special_to_date'])
|
| 323 |
+
|| empty($product['special_to_date']))) {
|
| 324 |
+
$prices['special_price_with_tax'] = Mage::helper('directory')->currencyConvert($prices['special_price_with_tax'], $bas_curncy_code, $cur_curncy_code);
|
| 325 |
+
$prices['special_price'] = Mage::helper('directory')->currencyConvert($prices['special_price'], $bas_curncy_code, $cur_curncy_code);
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
$prices['price_with_tax'] = Mage::helper('directory')->currencyConvert($_finalPriceInclTax, $bas_curncy_code, $cur_curncy_code);
|
| 329 |
+
$prices['price'] = Mage::helper('directory')->currencyConvert($prices['price'], $bas_curncy_code, $cur_curncy_code);
|
| 330 |
+
}
|
| 331 |
+
return $prices;
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
}
|
app/code/local/DataFeedWatch/Connector/etc/config.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<DataFeedWatch_Connector>
|
| 5 |
-
<version>0.2.
|
| 6 |
</DataFeedWatch_Connector>
|
| 7 |
</modules>
|
| 8 |
<admin>
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<DataFeedWatch_Connector>
|
| 5 |
+
<version>0.2.1</version>
|
| 6 |
</DataFeedWatch_Connector>
|
| 7 |
</modules>
|
| 8 |
<admin>
|
package.xml
CHANGED
|
@@ -1,18 +1,19 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>DataFeedWatch_Connector</name>
|
| 4 |
-
<version>0.2.
|
| 5 |
<stability>stable</stability>
|
| 6 |
-
<license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
-
<summary>DataFeedWatch</summary>
|
| 10 |
-
<description>DataFeedWatch
|
| 11 |
-
|
| 12 |
-
<
|
| 13 |
-
<
|
| 14 |
-
<
|
| 15 |
-
<
|
|
|
|
| 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>DataFeedWatch_Connector</name>
|
| 4 |
+
<version>0.2.1</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
+
<summary>DataFeedWatch extension for Magento</summary>
|
| 10 |
+
<description>DataFeedWatch enables Magento shops to optimize their product data
|
| 11 |
+
feed for Google Shopping and other channels</description>
|
| 12 |
+
<notes>DataFeedWatch Release version 0.2.1</notes>
|
| 13 |
+
<authors><author><name>DataFeedWatch</name><user>Adeel</user><email>adeel.developer@gmail.com</email></author></authors>
|
| 14 |
+
<date>2013-08-28</date>
|
| 15 |
+
<time>15:01:43</time>
|
| 16 |
+
<contents><target name="magelocal"><dir name="DataFeedWatch"><dir name="Connector"><dir name="Block"><dir name="Adminhtml"><file name="Connectorbackend.php" hash="afe5bd4888768229d5b668f466b770b5"/></dir></dir><dir name="Helper"><file name="Data.php" hash="983d7ad023616b365dce180680e4f9f0"/></dir><dir name="Model"><dir name="Datafeedwatch"><file name="Api.php" hash="200c1a25c2d2044d85298bb38fbbd496"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConnectorbackendController.php" hash="dfa561302ef7eebe656b229fe275a2eb"/></dir></dir><dir name="etc"><file name="api.xml" hash="84e8b97ba0dc25154ff62126640de989"/><file name="config.xml" hash="4ca59e39352913dab25d01df069b62f3"/><file name="system.xml" hash="ab5e8d56d032ba69c930ab7879484212"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="connector.xml" hash="14d59b8e9f66fba5d7c1f8d0f62dfc3c"/></dir><dir name="template"><dir name="connector"><file name="connectorbackend.phtml" hash="87fbcd16a96af52ce352bc45d9aeab4a"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="DataFeedWatch_Connector.xml" hash="d4ef6cebcefd37d5f0546eca344941eb"/></dir></target></contents>
|
| 17 |
<compatible/>
|
| 18 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 19 |
</package>
|
