Version Notes
First Release
Download this release
Release Info
| Developer | Sigi Eisenreich |
| Extension | atipsosync |
| Version | 0.1.0 |
| Comparing to | |
| See all releases | |
Version 0.1.0
- app/code/local/Atipso/.DS_Store +0 -0
- app/code/local/Atipso/Atipsosync/.DS_Store +0 -0
- app/code/local/Atipso/Atipsosync/Helper/.DS_Store +0 -0
- app/code/local/Atipso/Atipsosync/Helper/Data.php +6 -0
- app/code/local/Atipso/Atipsosync/Model/.DS_Store +0 -0
- app/code/local/Atipso/Atipsosync/Model/Category/.DS_Store +0 -0
- app/code/local/Atipso/Atipsosync/Model/Category/Api.php +585 -0
- app/code/local/Atipso/Atipsosync/Model/Core/.DS_Store +0 -0
- app/code/local/Atipso/Atipsosync/Model/Core/Api.php +107 -0
- app/code/local/Atipso/Atipsosync/Model/Mysql4/.DS_Store +0 -0
- app/code/local/Atipso/Atipsosync/Model/Mysql4/Setup.php +5 -0
- app/code/local/Atipso/Atipsosync/Model/Product/.DS_Store +0 -0
- app/code/local/Atipso/Atipsosync/Model/Product/Api.php +275 -0
- app/code/local/Atipso/Atipsosync/Model/Product/Attribute/.DS_Store +0 -0
- app/code/local/Atipso/Atipsosync/Model/Product/Attribute/Media/.DS_Store +0 -0
- app/code/local/Atipso/Atipsosync/Model/Product/Attribute/Media/Api.php +64 -0
- app/code/local/Atipso/Atipsosync/etc/.DS_Store +0 -0
- app/code/local/Atipso/Atipsosync/etc/api.xml +95 -0
- app/code/local/Atipso/Atipsosync/etc/config.xml +34 -0
- app/etc/modules/Atipso_Atipsosync.xml +9 -0
- atipsoAddMultipleProducts.php +179 -0
- package.xml +29 -0
app/code/local/Atipso/.DS_Store
ADDED
|
Binary file
|
app/code/local/Atipso/Atipsosync/.DS_Store
ADDED
|
Binary file
|
app/code/local/Atipso/Atipsosync/Helper/.DS_Store
ADDED
|
Binary file
|
app/code/local/Atipso/Atipsosync/Helper/Data.php
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Atipso_Atipsosync_Helper_Data extends Mage_Core_Helper_Abstract
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
}
|
app/code/local/Atipso/Atipsosync/Model/.DS_Store
ADDED
|
Binary file
|
app/code/local/Atipso/Atipsosync/Model/Category/.DS_Store
ADDED
|
Binary file
|
app/code/local/Atipso/Atipsosync/Model/Category/Api.php
ADDED
|
@@ -0,0 +1,585 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Catalog category api - overrides Mage_Catalog_Model_Category_Api
|
| 4 |
+
*
|
| 5 |
+
* @category Atipso
|
| 6 |
+
* @package Atipso_Atipsosync
|
| 7 |
+
* @author Sigi Eisenreich
|
| 8 |
+
*/
|
| 9 |
+
class Atipso_Atipsosync_Model_Category_Api extends Mage_Catalog_Model_Category_Api
|
| 10 |
+
{
|
| 11 |
+
protected $_filtersMap = array(
|
| 12 |
+
'product_id' => 'entity_id',
|
| 13 |
+
'set' => 'attribute_set_id',
|
| 14 |
+
'type' => 'type_id'
|
| 15 |
+
);
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* Retrieve list of assigned products to category
|
| 19 |
+
*
|
| 20 |
+
* @param int $categoryId
|
| 21 |
+
* @param string|int $store
|
| 22 |
+
* @param Array $filters
|
| 23 |
+
* @return array
|
| 24 |
+
*/
|
| 25 |
+
public function assignedProductsDetail($categoryId, $store = null, $filters = null)
|
| 26 |
+
{
|
| 27 |
+
// $visibility = array(
|
| 28 |
+
// Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
|
| 29 |
+
// Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
|
| 30 |
+
// );
|
| 31 |
+
|
| 32 |
+
// // Filter by products types if specified
|
| 33 |
+
$excludeProductTypes = array();
|
| 34 |
+
if (isset($filters['exclude_product_types']) && !empty($filters['exclude_product_types'])) {
|
| 35 |
+
$excludeProductTypes = $filters['exclude_product_types'];
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
$category = $this->_initCategory($categoryId);
|
| 39 |
+
|
| 40 |
+
$collection = Mage::getModel('catalog/product')->getCollection()
|
| 41 |
+
// ->addStoreFilter($store)
|
| 42 |
+
// ->addStoreFilter($this->_getStoreId($store))
|
| 43 |
+
->setStoreId($this->_getStoreId($store))
|
| 44 |
+
->addCategoryFilter($category);
|
| 45 |
+
|
| 46 |
+
if (!empty($excludeProductTypes)) {
|
| 47 |
+
$collection->addAttributeToFilter('type_id', array( 'nin' => $excludeProductTypes ));
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
$collection->addAttributeToFilter('visibility', array('neq' => 1))
|
| 51 |
+
// ->addAttributeToFilter('type_id', array( 'nin' => array('grouped', 'configurable') ))
|
| 52 |
+
->addAttributeToSelect('*')
|
| 53 |
+
// ->addAttributeToSelect('minimal_price')
|
| 54 |
+
// ->addAttributeToSelect('price')
|
| 55 |
+
// ->addMinimalPrice()
|
| 56 |
+
// ->addFinalPrice()
|
| 57 |
+
->addTaxPercents()
|
| 58 |
+
// // Next line prevents items from showing up with price '0' in the list
|
| 59 |
+
->applyFrontendPriceLimitations();
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
// // Before we add paging values, clone the 'collection'
|
| 66 |
+
// // which will be used in getting the record count.
|
| 67 |
+
$kollection = Mage::getModel('catalog/product')->getCollection()
|
| 68 |
+
// ->addStoreFilter($store)
|
| 69 |
+
// ->addStoreFilter($this->_getStoreId($store))
|
| 70 |
+
->setStoreId($this->_getStoreId($store))
|
| 71 |
+
->addCategoryFilter($category);
|
| 72 |
+
|
| 73 |
+
if (!empty($excludeProductTypes)) {
|
| 74 |
+
$kollection->addAttributeToFilter('type_id', array( 'nin' => $excludeProductTypes ));
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
$kollection->addAttributeToFilter('visibility', array('neq' => 1))
|
| 78 |
+
// ->addAttributeToFilter('type_id', array( 'nin' => array('grouped', 'configurable') ))
|
| 79 |
+
->addAttributeToSelect('entity_id');
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
$excludeFromFilterLogic = array('page_size', 'page_number', 'exclude_product_types');
|
| 84 |
+
if (is_array($filters)) {
|
| 85 |
+
try {
|
| 86 |
+
foreach ($filters as $field => $value) {
|
| 87 |
+
if (in_array($field, $excludeFromFilterLogic)) {
|
| 88 |
+
continue;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
if (isset($this->_filtersMap[$field])) {
|
| 92 |
+
$field = $this->_filtersMap[$field];
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
$collection->addFieldToFilter($field, $value);
|
| 96 |
+
$kollection->addFieldToFilter($field, $value);
|
| 97 |
+
}
|
| 98 |
+
} catch (Mage_Core_Exception $e) {
|
| 99 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
// // The next code block sets up paging parameters
|
| 105 |
+
$pageNumber = -1;
|
| 106 |
+
$pageSize = -1;
|
| 107 |
+
if (is_array($filters)) {
|
| 108 |
+
if (isset($filters['page_number'])) {
|
| 109 |
+
$pageNumber = $filters['page_number'];
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
if (isset($filters['page_size'])) {
|
| 113 |
+
$pageSize = $filters['page_size'];
|
| 114 |
+
}
|
| 115 |
+
}
|
| 116 |
+
if ($pageNumber != -1) {
|
| 117 |
+
$collection->setPage($pageNumber);
|
| 118 |
+
}
|
| 119 |
+
if ($pageSize != -1) {
|
| 120 |
+
$collection->setPageSize($pageSize);
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
// // The next line ensures pagination takes place
|
| 124 |
+
if ($pageNumber != -1 || $pageSize != -1) {
|
| 125 |
+
$collection->load();
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
// // Since our result expects:
|
| 129 |
+
// // 'product_id' => 'entity_id'
|
| 130 |
+
// // amongst others, we'll do that remap here
|
| 131 |
+
$flippedFiltersMap = array_flip($this->_filtersMap);
|
| 132 |
+
$result = array();
|
| 133 |
+
foreach ($collection as $product) {
|
| 134 |
+
// $result[] = $product->toArray();
|
| 135 |
+
|
| 136 |
+
// error_log( 'getImageUrl : [' . $product->getImageUrl() . ']');
|
| 137 |
+
// error_log( 'getSmallImageUrl : [' . $product->getSmallImageUrl() . ']');
|
| 138 |
+
// error_log( 'getThumbnailUrl : [' . $product->getThumbnailUrl() . ']');
|
| 139 |
+
// error_log( 'getTaxPercent : [' . $product->getTaxPercent() . ']');
|
| 140 |
+
|
| 141 |
+
// // Switch back to our preferred product property names
|
| 142 |
+
$arrayedProduct = $product->toArray();
|
| 143 |
+
foreach ($flippedFiltersMap as $field => $value) {
|
| 144 |
+
$arrayedProduct[$value] = $arrayedProduct[$field];
|
| 145 |
+
unset($arrayedProduct[$field]);
|
| 146 |
+
}
|
| 147 |
+
$result[] = $arrayedProduct;
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
// // Just to be safe, load the kollection up to
|
| 151 |
+
// // ascertain that we get the correct record count.
|
| 152 |
+
$kollection->load();
|
| 153 |
+
$recordCount = count($kollection);
|
| 154 |
+
|
| 155 |
+
// // Get incendiary info here
|
| 156 |
+
$currency_symbol = Mage::app()->getLocale()->currency(Mage::app()->getStore($store)->getCurrentCurrencyCode())->getSymbol();
|
| 157 |
+
$price_includes_tax = Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX, $store);
|
| 158 |
+
|
| 159 |
+
// return $result;
|
| 160 |
+
return array(
|
| 161 |
+
'products' => $result,
|
| 162 |
+
'record_count' => $recordCount,
|
| 163 |
+
'currency_symbol' => $currency_symbol,
|
| 164 |
+
'price_includes_tax' => $price_includes_tax);
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
/**
|
| 168 |
+
* Retrieves:
|
| 169 |
+
* 1) id & name of main categories
|
| 170 |
+
* 2) id & name of 5 products in each category in (1)
|
| 171 |
+
* 3) image url for a random item within (2) above
|
| 172 |
+
*
|
| 173 |
+
* @param string|int $store
|
| 174 |
+
* @param Array $filters
|
| 175 |
+
* @return array
|
| 176 |
+
*/
|
| 177 |
+
public function randomProductsForCategories($store = null, $filters = null)
|
| 178 |
+
{
|
| 179 |
+
/*
|
| 180 |
+
// // ATTEMPT 1
|
| 181 |
+
// // Returns a flatened list of the category tree
|
| 182 |
+
$category = Mage::getModel('catalog/category');
|
| 183 |
+
$tree = $category->getTreeModel();
|
| 184 |
+
$tree->load();
|
| 185 |
+
|
| 186 |
+
$ids = $tree->getCollection()->getAllIds();
|
| 187 |
+
$result = array();
|
| 188 |
+
|
| 189 |
+
if ($ids){
|
| 190 |
+
foreach ($ids as $id){
|
| 191 |
+
$cat = Mage::getModel('catalog/category');
|
| 192 |
+
$cat->load($id);
|
| 193 |
+
// array_push($result, $cat);
|
| 194 |
+
array_push($result, array(
|
| 195 |
+
'id' => $cat['entity_id'],
|
| 196 |
+
'name' => $cat['name'],
|
| 197 |
+
'parent_id' => $cat['parent_id']
|
| 198 |
+
));
|
| 199 |
+
}
|
| 200 |
+
}
|
| 201 |
+
*/
|
| 202 |
+
|
| 203 |
+
/*
|
| 204 |
+
// // ATTEMPT 2
|
| 205 |
+
// // Returns empty. Why ? Whatever ...
|
| 206 |
+
$helper = Mage::helper('catalog/category');
|
| 207 |
+
// sorted by name, fetched as collection
|
| 208 |
+
$categories = $helper->getStoreCategories('name', true, false);
|
| 209 |
+
*/
|
| 210 |
+
|
| 211 |
+
/*
|
| 212 |
+
// // ATTEMPT 3
|
| 213 |
+
// // This will only work if the store has 'featured' attribute defined.
|
| 214 |
+
// // Otherwise, there'll be a nasty error.
|
| 215 |
+
$layer = Mage::getSingleton('catalog/layer');
|
| 216 |
+
$collection = Mage::getResourceModel('catalog/product_collection')
|
| 217 |
+
->addAttributeToFilter('featured', 1);
|
| 218 |
+
$layer->prepareProductCollection($collection);
|
| 219 |
+
$result = $collection;
|
| 220 |
+
*/
|
| 221 |
+
|
| 222 |
+
// // ATTEMPT 4
|
| 223 |
+
// // Dumnp list of stores this server has
|
| 224 |
+
// $stores = Mage::app()->getStores(false, true);
|
| 225 |
+
// foreach ($stores as $store) {
|
| 226 |
+
// $storeDump = '[' . $store->getCode() . '];[' . $store->getId() .']';
|
| 227 |
+
// error_log($storeDump);
|
| 228 |
+
// }
|
| 229 |
+
|
| 230 |
+
// // Fetches products from the immediate sub categories of the main categories.
|
| 231 |
+
// // Why ? Normally main categories do not have products.
|
| 232 |
+
$categories = Mage::getModel('catalog/category')->getCollection()
|
| 233 |
+
// ->addStoreFilter($store)
|
| 234 |
+
// ->addStoreFilter($this->_getStoreId($store))
|
| 235 |
+
->setStoreId($this->_getStoreId($store))
|
| 236 |
+
// ->addAttributeToSelect('url_path')
|
| 237 |
+
->addAttributeToSelect('entity_id')
|
| 238 |
+
->addAttributeToSelect('name')
|
| 239 |
+
->addAttributeToSelect('parent_id')
|
| 240 |
+
->addAttributeToSelect('level');
|
| 241 |
+
|
| 242 |
+
// // Filter by category if ids were specified
|
| 243 |
+
if (isset($filters['category_ids']) && !empty($filters['category_ids'])) {
|
| 244 |
+
// error_log('category_ids => ' . print_r($filters['category_ids'], true));
|
| 245 |
+
$categories->addAttributeToFilter('entity_id', array('in' => $filters['category_ids']));
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
$categories->addAttributeToFilter('level', array('eq' => 2))
|
| 249 |
+
// ->addAttributeToFilter('is_active', array('eq' => 1))
|
| 250 |
+
->addIsActiveFilter()
|
| 251 |
+
// // What if the root is not 3 ?
|
| 252 |
+
// ->addAttributeToFilter('parent_id', array('eq' => 3))
|
| 253 |
+
// // This includes empty & root categories too. Weird ...
|
| 254 |
+
// ->addLevelFilter(2)
|
| 255 |
+
->addOrderField('name');
|
| 256 |
+
|
| 257 |
+
$categories->load();
|
| 258 |
+
// error_log('Got ' . count($categories) . ' categories');
|
| 259 |
+
|
| 260 |
+
// // This first iteration gets the root category.
|
| 261 |
+
// // The id is normally 3 in most stores but lets not take that chance :)
|
| 262 |
+
// // Note that the default category names isn't so easily
|
| 263 |
+
// // altered from the Magento backend by store owners.
|
| 264 |
+
// $rootId = -1;
|
| 265 |
+
// $needle = 'efault Category';
|
| 266 |
+
// foreach ($categories as $category) {
|
| 267 |
+
// $haystack = $category['name'];
|
| 268 |
+
// $pos = strpos($haystack, $needle);
|
| 269 |
+
// if ($pos !== false) {
|
| 270 |
+
// $rootId = $category['entity_id'];
|
| 271 |
+
// break;
|
| 272 |
+
// }
|
| 273 |
+
// }
|
| 274 |
+
// if ($rootId == -1) {
|
| 275 |
+
// $needle = 'oot Catalog';
|
| 276 |
+
// foreach ($categories as $category) {
|
| 277 |
+
// $haystack = $category['name'];
|
| 278 |
+
// $pos = strpos($haystack, $needle);
|
| 279 |
+
// if ($pos !== false) {
|
| 280 |
+
// $rootId = $category['entity_id'];
|
| 281 |
+
// break;
|
| 282 |
+
// }
|
| 283 |
+
// }
|
| 284 |
+
// }
|
| 285 |
+
|
| 286 |
+
|
| 287 |
+
$catalogImageHelper = Mage::helper('catalog/image');
|
| 288 |
+
|
| 289 |
+
// // Filter by products types if specified
|
| 290 |
+
$excludeProductTypes = array();
|
| 291 |
+
if (isset($filters['exclude_product_types']) && !empty($filters['exclude_product_types'])) {
|
| 292 |
+
$excludeProductTypes = $filters['exclude_product_types'];
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
$imageWidth = 100;
|
| 296 |
+
if (isset($filters['image_width']) && !empty($filters['image_width'])) {
|
| 297 |
+
$imageWidth = $filters['image_width'];
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
$imageHeight = 100;
|
| 301 |
+
if (isset($filters['image_height']) && !empty($filters['image_height'])) {
|
| 302 |
+
$imageHeight = $filters['image_height'];
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
$result = array();
|
| 306 |
+
|
| 307 |
+
foreach ($categories as $category) {
|
| 308 |
+
// // If its not the main category, skip
|
| 309 |
+
// if ($category['parent_id'] != $rootId) { continue; }
|
| 310 |
+
// if ($category['level'] != 2) { continue; }
|
| 311 |
+
|
| 312 |
+
// // Get random products from the category itself
|
| 313 |
+
$products = Mage::getModel('catalog/product')->getCollection()
|
| 314 |
+
// ->addStoreFilter($store)
|
| 315 |
+
->addStoreFilter($this->_getStoreId($store))
|
| 316 |
+
->addAttributeToSelect('id')
|
| 317 |
+
->addAttributeToSelect('name')
|
| 318 |
+
->addAttributeToSelect('image')
|
| 319 |
+
->addCategoryFilter($category);
|
| 320 |
+
|
| 321 |
+
if (!empty($excludeProductTypes)) {
|
| 322 |
+
$products->addAttributeToFilter('type_id', array( 'nin' => $excludeProductTypes));
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
$products->addAttributeToFilter('visibility', array('neq' => 1))
|
| 326 |
+
// ->addAttributeToFilter('type_id', array( 'nin' => array('grouped', 'configurable') ))
|
| 327 |
+
->addAttributeToSort('news_from_date', 'desc')
|
| 328 |
+
->setPageSize(5);
|
| 329 |
+
|
| 330 |
+
// error_log('Got ' . count($products) . ' products for category ' . $category['name']);
|
| 331 |
+
|
| 332 |
+
// // If there are results, then use them.
|
| 333 |
+
// // If not get products from immediate child categories.
|
| 334 |
+
if (count($products) > 0) {
|
| 335 |
+
|
| 336 |
+
$resultProducts = array();
|
| 337 |
+
foreach ($products as $product) {
|
| 338 |
+
array_push($resultProducts, array(
|
| 339 |
+
'id' => $product->getId(),
|
| 340 |
+
'name' => $product->getName(),
|
| 341 |
+
// 'image' => $product->getImageUrl()
|
| 342 |
+
'image' => (string)$catalogImageHelper->init($product, 'image')->resize($imageWidth, $imageHeight)
|
| 343 |
+
));
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
array_push($result, array(
|
| 347 |
+
'id' => $category['entity_id'],
|
| 348 |
+
'name' => $category['name'],
|
| 349 |
+
'products' => $resultProducts
|
| 350 |
+
));
|
| 351 |
+
|
| 352 |
+
} else {
|
| 353 |
+
|
| 354 |
+
// // Array consisting of all child categories id
|
| 355 |
+
$allSubCategoryIds = explode(',', $category->getChildren());
|
| 356 |
+
|
| 357 |
+
// // Filter by category if ids were specified
|
| 358 |
+
$subCategoryIds = array();
|
| 359 |
+
if (isset($filters['category_ids']) && !empty($filters['category_ids'])) {
|
| 360 |
+
$subCategoryIds = array_intersect($allSubCategoryIds, $filters['category_ids']);
|
| 361 |
+
} else {
|
| 362 |
+
$subCategoryIds = $allSubCategoryIds;
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
// error_log('subCategoryIds = ' . print_r($subCategoryIds, true));
|
| 366 |
+
|
| 367 |
+
foreach ($subCategoryIds as $subCategoryId) {
|
| 368 |
+
$subCategory = Mage::getModel('catalog/category')->load($subCategoryId);
|
| 369 |
+
|
| 370 |
+
// // Get 5 random products from it
|
| 371 |
+
$products = Mage::getModel('catalog/product')->getCollection()
|
| 372 |
+
// ->addStoreFilter($store)
|
| 373 |
+
->addStoreFilter($this->_getStoreId($store))
|
| 374 |
+
->addAttributeToSelect('id')
|
| 375 |
+
->addAttributeToSelect('name')
|
| 376 |
+
->addAttributeToSelect('image')
|
| 377 |
+
// ->addCategoryFilter($subCategoryId)
|
| 378 |
+
->addCategoryFilter($subCategory);
|
| 379 |
+
|
| 380 |
+
if (!empty($excludeProductTypes)) {
|
| 381 |
+
$products->addAttributeToFilter('type_id', array( 'nin' => $excludeProductTypes));
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
$products->addAttributeToFilter('visibility', array('neq' => 1))
|
| 385 |
+
// ->addAttributeToFilter('type_id', array( 'nin' => array('grouped', 'configurable') ))
|
| 386 |
+
->addAttributeToSort('news_from_date', 'desc')
|
| 387 |
+
->setPageSize(5);
|
| 388 |
+
|
| 389 |
+
// error_log('Got ' . count($products) . ' products for sub category ' . $subCategory['name']);
|
| 390 |
+
|
| 391 |
+
// // Only add to result if there's any products
|
| 392 |
+
if (count($products) == 0) { continue; }
|
| 393 |
+
|
| 394 |
+
$resultProducts = array();
|
| 395 |
+
foreach ($products as $product) {
|
| 396 |
+
array_push($resultProducts, array(
|
| 397 |
+
'id' => $product->getId(),
|
| 398 |
+
'name' => $product->getName(),
|
| 399 |
+
// 'image' => $product->getImageUrl()
|
| 400 |
+
'image' => (string)$catalogImageHelper->init($product, 'image')->resize($imageWidth, $imageHeight)
|
| 401 |
+
));
|
| 402 |
+
}
|
| 403 |
+
|
| 404 |
+
array_push($result, array(
|
| 405 |
+
'id' => $subCategory['entity_id'],
|
| 406 |
+
'name' => $subCategory['name'],
|
| 407 |
+
'products' => $resultProducts
|
| 408 |
+
));
|
| 409 |
+
} // // end : foreach ($subCategoryIds as $subCategoryId)
|
| 410 |
+
|
| 411 |
+
} // // end : if (count($products) > 0)
|
| 412 |
+
|
| 413 |
+
} // // end : foreach ($categories as $category)
|
| 414 |
+
|
| 415 |
+
/*
|
| 416 |
+
// // ATTEMPT 5
|
| 417 |
+
// // Returns products from the flatened list of the category tree
|
| 418 |
+
$tree = Mage::getModel('catalog/category')->getTreeModel();
|
| 419 |
+
$tree->load();
|
| 420 |
+
$ids = $tree->getCollection()->getAllIds();
|
| 421 |
+
|
| 422 |
+
$result = array();
|
| 423 |
+
|
| 424 |
+
foreach ($ids as $id) {
|
| 425 |
+
$category = Mage::getModel('catalog/category')->load($id);
|
| 426 |
+
|
| 427 |
+
// // Get 5 random products from it
|
| 428 |
+
$products = Mage::getModel('catalog/product')->getCollection()
|
| 429 |
+
->addAttributeToSelect('id')
|
| 430 |
+
->addAttributeToSelect('name')
|
| 431 |
+
->addAttributeToSelect('image')
|
| 432 |
+
// ->addCategoryFilter(Mage::getModel('catalog/category')->load($id))
|
| 433 |
+
->addCategoryFilter($category)
|
| 434 |
+
->addAttributeToFilter('visibility', array('neq' => 1))
|
| 435 |
+
->addAttributeToSort('news_from_date', 'desc')
|
| 436 |
+
->setPageSize(5);
|
| 437 |
+
|
| 438 |
+
// $products->load();
|
| 439 |
+
|
| 440 |
+
// // only add to result if there's any products
|
| 441 |
+
if (count($products) == 0) { continue; }
|
| 442 |
+
|
| 443 |
+
$resultProducts = array();
|
| 444 |
+
foreach ($products as $product) {
|
| 445 |
+
array_push($resultProducts, array(
|
| 446 |
+
'id' => $product->getId(),
|
| 447 |
+
'name' => $product->getName(),
|
| 448 |
+
'image' => $product->getImageUrl()
|
| 449 |
+
));
|
| 450 |
+
}
|
| 451 |
+
|
| 452 |
+
array_push($result, array(
|
| 453 |
+
'id' => $category['entity_id'],
|
| 454 |
+
// 'parent_id' => $category['parent_id'],
|
| 455 |
+
'name' => $category['name'],
|
| 456 |
+
'products' => $resultProducts
|
| 457 |
+
));
|
| 458 |
+
}
|
| 459 |
+
*/
|
| 460 |
+
|
| 461 |
+
|
| 462 |
+
// // Get incendiary info here
|
| 463 |
+
$currency_symbol = Mage::app()->getLocale()->currency(Mage::app()->getStore($store)->getCurrentCurrencyCode())->getSymbol();
|
| 464 |
+
|
| 465 |
+
// return $result;
|
| 466 |
+
return array(
|
| 467 |
+
'categories' => $result,
|
| 468 |
+
'currency_symbol' => $currency_symbol);
|
| 469 |
+
}
|
| 470 |
+
|
| 471 |
+
|
| 472 |
+
/**
|
| 473 |
+
* Retrieve category tree
|
| 474 |
+
*
|
| 475 |
+
* @param int $parent
|
| 476 |
+
* @param string|int $store
|
| 477 |
+
* @return array
|
| 478 |
+
*/
|
| 479 |
+
public function activeCategories($parentId = null, $store = null, $filters = null)
|
| 480 |
+
{
|
| 481 |
+
if (is_null($parentId) && !is_null($store)) {
|
| 482 |
+
$parentId = Mage::app()->getStore($this->_getStoreId($store))->getRootCategoryId();
|
| 483 |
+
} elseif (is_null($parentId)) {
|
| 484 |
+
$parentId = 1;
|
| 485 |
+
}
|
| 486 |
+
|
| 487 |
+
/* @var $tree Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Tree */
|
| 488 |
+
$tree = Mage::getResourceSingleton('catalog/category_tree')
|
| 489 |
+
->load();
|
| 490 |
+
|
| 491 |
+
$root = $tree->getNodeById($parentId);
|
| 492 |
+
|
| 493 |
+
if($root && $root->getId() == 1) {
|
| 494 |
+
$root->setName(Mage::helper('catalog')->__('Root'));
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
$collection = Mage::getModel('catalog/category')->getCollection()
|
| 498 |
+
// ->addStoreFilter($store)
|
| 499 |
+
// ->addStoreFilter($this->_getStoreId($store))
|
| 500 |
+
->setStoreId($this->_getStoreId($store))
|
| 501 |
+
->addIsActiveFilter()
|
| 502 |
+
->addFieldToFilter('include_in_menu', 1)
|
| 503 |
+
->addAttributeToSelect('name')
|
| 504 |
+
->addAttributeToSelect('is_active')
|
| 505 |
+
->addAttributeToSelect('children_count')
|
| 506 |
+
->addAttributeToSelect('include_in_menu')
|
| 507 |
+
->addAttributeToSelect('is_anchor');
|
| 508 |
+
|
| 509 |
+
$tree->addCollectionData($collection, true);
|
| 510 |
+
|
| 511 |
+
// // Filter by products types if specified
|
| 512 |
+
$excludeProductTypes = array();
|
| 513 |
+
if (isset($filters['exclude_product_types']) && !empty($filters['exclude_product_types'])) {
|
| 514 |
+
$excludeProductTypes = $filters['exclude_product_types'];
|
| 515 |
+
}
|
| 516 |
+
|
| 517 |
+
return $this->_nodeToArray($root, $store, $excludeProductTypes);
|
| 518 |
+
//return $collection->getSize();
|
| 519 |
+
|
| 520 |
+
}
|
| 521 |
+
|
| 522 |
+
/**
|
| 523 |
+
* Convert node to array
|
| 524 |
+
*
|
| 525 |
+
* @param Varien_Data_Tree_Node $node
|
| 526 |
+
* @return array
|
| 527 |
+
*/
|
| 528 |
+
protected function _nodeToArray(Varien_Data_Tree_Node $node, $store, $excludeProductTypes)
|
| 529 |
+
{
|
| 530 |
+
// Only basic category data
|
| 531 |
+
$result = array();
|
| 532 |
+
$result['category_id'] = $node->getId();
|
| 533 |
+
$result['parent_id'] = $node->getParentId();
|
| 534 |
+
$result['name'] = $node->getName();
|
| 535 |
+
$result['is_active'] = $node->getIsActive();
|
| 536 |
+
$result['include_in_menu'] = $node->getIncludeInMenu();
|
| 537 |
+
$result['position'] = $node->getPosition();
|
| 538 |
+
$result['level'] = $node->getLevel();
|
| 539 |
+
$result['is_anchor'] = $node->getIsAnchor();
|
| 540 |
+
$result['products_count'] = $this->countProducts($node->getId(), $store, $excludeProductTypes);
|
| 541 |
+
$result['children_products_count'] = $result['products_count'];
|
| 542 |
+
$result['children'] = array();
|
| 543 |
+
|
| 544 |
+
foreach ($node->getChildren() as $child) {
|
| 545 |
+
$result['children'][] = $this->_nodeToArray($child, $store, $excludeProductTypes);
|
| 546 |
+
|
| 547 |
+
$sum = 0;
|
| 548 |
+
foreach ($result['children'] as $sub) {
|
| 549 |
+
$sum += $sub['products_count'];
|
| 550 |
+
}
|
| 551 |
+
$result['children_products_count'] = $sum;
|
| 552 |
+
}
|
| 553 |
+
|
| 554 |
+
return $result;
|
| 555 |
+
}
|
| 556 |
+
|
| 557 |
+
/**
|
| 558 |
+
* Retrieve number of assigned products to category
|
| 559 |
+
*
|
| 560 |
+
* @param int $categoryId
|
| 561 |
+
* @param string|int $store
|
| 562 |
+
* @return string
|
| 563 |
+
*/
|
| 564 |
+
protected function countProducts($categoryId, $store = null, $excludeProductTypes)
|
| 565 |
+
{
|
| 566 |
+
// // Remarked as it has caused so many issues where hidden products are
|
| 567 |
+
// // still considered in the product count even after we tell it not to.
|
| 568 |
+
|
| 569 |
+
$category = $this->_initCategory($categoryId);
|
| 570 |
+
$storeId = $this->_getStoreId($store);
|
| 571 |
+
$collection = $category
|
| 572 |
+
->setStoreId($storeId)
|
| 573 |
+
->getProductCollection()
|
| 574 |
+
->addAttributeToFilter('visibility', array('neq' => 1));
|
| 575 |
+
|
| 576 |
+
if (!empty($excludeProductTypes)) {
|
| 577 |
+
// $collection->addAttributeToFilter('type_id', array( 'nin' => array('grouped', 'configurable') ));
|
| 578 |
+
$collection->addAttributeToFilter('type_id', array( 'nin' => $excludeProductTypes ));
|
| 579 |
+
}
|
| 580 |
+
|
| 581 |
+
($storeId == 0)? $collection->addOrder('position', 'asc') : $collection->setOrder('position', 'asc');
|
| 582 |
+
|
| 583 |
+
return $collection->getSize();
|
| 584 |
+
}
|
| 585 |
+
}
|
app/code/local/Atipso/Atipsosync/Model/Core/.DS_Store
ADDED
|
Binary file
|
app/code/local/Atipso/Atipsosync/Model/Core/Api.php
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Catalog category api - overrides Mage_Catalog_Model_Category_Api
|
| 4 |
+
*
|
| 5 |
+
* @category Atipso
|
| 6 |
+
* @package Atipso_Atipsosync
|
| 7 |
+
* @author Sigi Eisenreich
|
| 8 |
+
*/
|
| 9 |
+
class Atipso_Atipsosync_Model_Core_Api extends Mage_Catalog_Model_Category_Api
|
| 10 |
+
{
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* Retrieve info array of all existing storeviews
|
| 14 |
+
*
|
| 15 |
+
* @return Mage_Core_Model_Config
|
| 16 |
+
*/
|
| 17 |
+
public function getStores(){
|
| 18 |
+
$data = Mage::getModel('core/store/views')->getCollection()->toArray();
|
| 19 |
+
$stores = $data['items'];
|
| 20 |
+
$modified_stores = array();
|
| 21 |
+
foreach ($stores as $store) {
|
| 22 |
+
$store_locale = Mage::getStoreConfig('general/locale/code', $store['store_id']);
|
| 23 |
+
$store['locale'] = $store_locale;
|
| 24 |
+
array_push($modified_stores, $store);
|
| 25 |
+
}
|
| 26 |
+
return $modified_stores;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* Retrieve config value for store by path
|
| 31 |
+
*
|
| 32 |
+
* @param string $path for Example 'design/header/logo_src', 'general/locale/code',
|
| 33 |
+
* @param mixed $store
|
| 34 |
+
* @return mixed
|
| 35 |
+
*/
|
| 36 |
+
public function getStoreConfig($path, $store = null){
|
| 37 |
+
return Mage::getStoreConfig($path, $store);
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
*
|
| 42 |
+
* Retrieve the version of Magento.
|
| 43 |
+
* @param string $asType Should be 'array' if we want the method to return array
|
| 44 |
+
* @return mixed Either string or array (if the passed param is 'array')
|
| 45 |
+
*/
|
| 46 |
+
public function currentVersion($asType = '')
|
| 47 |
+
{
|
| 48 |
+
if($asType == 'array') {
|
| 49 |
+
return Mage::getVersionInfo();
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
return Mage::getVersion();
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
*
|
| 57 |
+
* Retrieve the version of Atipso Extension.
|
| 58 |
+
* @return mixed Either string or array (if the passed param is 'array')
|
| 59 |
+
*/
|
| 60 |
+
public function currentAtipsoVersion()
|
| 61 |
+
{
|
| 62 |
+
|
| 63 |
+
$data = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 64 |
+
$data = $data->fetchAll("SELECT * FROM core_resource WHERE code = 'atipsosync_setup';");
|
| 65 |
+
|
| 66 |
+
return $data;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
/**
|
| 70 |
+
* Get root category id
|
| 71 |
+
*
|
| 72 |
+
* @return int Zero if none
|
| 73 |
+
*/
|
| 74 |
+
public function getRootCategoryId($storeId=NULL)
|
| 75 |
+
{
|
| 76 |
+
try {
|
| 77 |
+
$s = Mage::getModel('core/store')->load($storeId);
|
| 78 |
+
|
| 79 |
+
return $s->getRootCategoryId();
|
| 80 |
+
}
|
| 81 |
+
catch (Exception $e) {
|
| 82 |
+
return 0;
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
/**
|
| 87 |
+
* Mage log facility
|
| 88 |
+
*
|
| 89 |
+
* @param string $message
|
| 90 |
+
* @param integer $level
|
| 91 |
+
* @param string $file
|
| 92 |
+
* @param bool $forceLog
|
| 93 |
+
* @return string Returns string, 'true' if OK, or exception message if exception
|
| 94 |
+
*/
|
| 95 |
+
public function log($message, $level = null, $file = '', $forceLog = false)
|
| 96 |
+
{
|
| 97 |
+
try {
|
| 98 |
+
Mage::log($message, $level, $file, $forceLog);
|
| 99 |
+
return 'true';
|
| 100 |
+
}
|
| 101 |
+
catch (Exception $e) {
|
| 102 |
+
return $e->getMessage();
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
}
|
app/code/local/Atipso/Atipsosync/Model/Mysql4/.DS_Store
ADDED
|
Binary file
|
app/code/local/Atipso/Atipsosync/Model/Mysql4/Setup.php
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Atipso_Atipsosync_Model_Mysql4_Setup extends Mage_Core_Model_Resource_Setup //Mage_Sales_Model_Mysql4_Setup
|
| 4 |
+
{
|
| 5 |
+
}
|
app/code/local/Atipso/Atipsosync/Model/Product/.DS_Store
ADDED
|
Binary file
|
app/code/local/Atipso/Atipsosync/Model/Product/Api.php
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Catalog product api - overrides Mage_Catalog_Model_Product_Api
|
| 4 |
+
*
|
| 5 |
+
* @category Atipso
|
| 6 |
+
* @package Atipso_Atipsosync
|
| 7 |
+
* @author Sigi Eisenreich
|
| 8 |
+
*/
|
| 9 |
+
class Atipso_Atipsosync_Model_Product_Api extends Mage_Catalog_Model_Product_Api
|
| 10 |
+
{
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* Retrieve product info with options
|
| 14 |
+
*
|
| 15 |
+
* @param int|string $productId
|
| 16 |
+
* @param string|int $store
|
| 17 |
+
* @param array $attributes
|
| 18 |
+
* @return array
|
| 19 |
+
*/
|
| 20 |
+
public function infoEnhanced($productId, $store = null, $attributes = null, $identifierType = null)
|
| 21 |
+
{
|
| 22 |
+
$product = $this->_getProduct($productId, $store, $identifierType);
|
| 23 |
+
|
| 24 |
+
if (!$product->getId()) {
|
| 25 |
+
$this->_fault('not_exists');
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
// // Set tax percent (its always percent right ? right ?)
|
| 29 |
+
// // Inspired by Magento's app\code\core\Mage\Tax\Model\Observer.php.
|
| 30 |
+
// // Please note that this value must be manually added into the 'result'
|
| 31 |
+
// // array as Magento considers it as a non-allowed attribute.
|
| 32 |
+
if (null === $product->getTaxClassId()) {
|
| 33 |
+
$product->setTaxClassId($product->getMinimalTaxClassId());
|
| 34 |
+
}
|
| 35 |
+
if (!isset($classToRate[$product->getTaxClassId()])) {
|
| 36 |
+
$request = Mage::getSingleton('tax/calculation')->getRateRequest();
|
| 37 |
+
$request->setProductClassId($product->getTaxClassId());
|
| 38 |
+
$classToRate[$product->getTaxClassId()] = Mage::getSingleton('tax/calculation')->getRate($request);
|
| 39 |
+
}
|
| 40 |
+
$product->setTaxPercent($classToRate[$product->getTaxClassId()]);
|
| 41 |
+
|
| 42 |
+
// // START : tests
|
| 43 |
+
// // The following applies to configurable products such as
|
| 44 |
+
// // Coalesce: Functioning On Impatience T-Shirt (Shirts, page 1)
|
| 45 |
+
|
| 46 |
+
// // Get configurable type product instance and get configurable attributes collection.
|
| 47 |
+
// // Sample uri to add a configurable product via query string:
|
| 48 |
+
// // http://www.your_domain.com/checkout/cart/add?product=68&qty=1&super_attribute[528]=55&super_attribute[525]=56
|
| 49 |
+
$configurable_attributes = array();
|
| 50 |
+
$used_products = array();
|
| 51 |
+
if (method_exists($product->getTypeInstance(), 'getConfigurableAttributes') == true) {
|
| 52 |
+
$configurableAttributeCollection=$product->getTypeInstance()->getConfigurableAttributes();
|
| 53 |
+
// // Use the collection to get the designated values of each configurable attribute
|
| 54 |
+
$index = 0;
|
| 55 |
+
foreach($configurableAttributeCollection as $attribute){
|
| 56 |
+
// error_log( 'attribute['. $index . '] print_r:['.print_r($attribute->getProductAttribute(), true).']' );
|
| 57 |
+
|
| 58 |
+
$productAttribute = $attribute->getProductAttribute();
|
| 59 |
+
|
| 60 |
+
$att = array(
|
| 61 |
+
'id' => $productAttribute->getId(),
|
| 62 |
+
'code' => $productAttribute->getAttributeCode(),
|
| 63 |
+
// // Magento sets this to 1 even for non required attributes. See the store detail view for
|
| 64 |
+
// // 'Zolof The Rock And Roll Destroyer: LOL Cat T-shirt' from the Magento sample database.
|
| 65 |
+
'required' => 1,
|
| 66 |
+
// 'required' => $attribute->getIsRequired(), // KO. Returns empty
|
| 67 |
+
// 'required' => $productAttribute->getIsRequire(), // KO. Returns empty
|
| 68 |
+
// 'required' => $productAttribute->getRequired(), // KO. Returns empty
|
| 69 |
+
// 'required' => $productAttribute->getData('required'), // KO. Returns empty
|
| 70 |
+
// 'required' => $productAttribute->getData('is_required'), // Does not match those at the store 100%
|
| 71 |
+
'get_is_required' => $productAttribute->getIsRequired(), // Does not match those at the store 100%
|
| 72 |
+
'label' => $productAttribute->getFrontend()->getLabel(),
|
| 73 |
+
// // Next one from function 'getConfigurableAttributesAsArray' in app\code\core\Mage\Catalog\Model\Product\Type\Configurable.php
|
| 74 |
+
'options' => $attribute->getPrices()
|
| 75 |
+
// 'options' => $productAttribute->getSource()->getAllOptions() // OK but does not match store
|
| 76 |
+
// 'options' => $productAttribute->getSource()->getSelectableOptions() // KO
|
| 77 |
+
// 'options' => $productAttribute->getSource()->getOptions() // KO
|
| 78 |
+
// 'options' => $productAttribute->getSource()->getVisibleOptions() // KO
|
| 79 |
+
);
|
| 80 |
+
array_push($configurable_attributes, $att);
|
| 81 |
+
|
| 82 |
+
$index++;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
// // START : used products ?
|
| 86 |
+
// // The next one returns the id of the used products
|
| 87 |
+
$usedProductIds = $product->getTypeInstance(true)->getUsedProductIds($product);
|
| 88 |
+
|
| 89 |
+
$usedProductCollection = $product->getCollection()
|
| 90 |
+
// ->addAttributeToSelect('name')
|
| 91 |
+
->addAttributeToSelect('sku')
|
| 92 |
+
// ->addAttributeToSelect('attribute_set_id')
|
| 93 |
+
// ->addAttributeToSelect('type_id')
|
| 94 |
+
// ->addAttributeToSelect('price')
|
| 95 |
+
->addFieldToFilter('attribute_set_id',$product->getAttributeSetId())
|
| 96 |
+
->addFieldToFilter('entity_id', array('in' => $usedProductIds ))
|
| 97 |
+
// ->addFieldToFilter('type_id', $allowProductTypes)
|
| 98 |
+
->addFilterByRequiredOptions();
|
| 99 |
+
|
| 100 |
+
// // The next line includes inventory count
|
| 101 |
+
// Mage::getModel('cataloginventory/stock_item')->addCatalogInventoryToProductCollection($associatedProductCollection);
|
| 102 |
+
|
| 103 |
+
// // The next block includes the super attribute i.e. size & color
|
| 104 |
+
foreach ($product->getTypeInstance(true)->getUsedProductAttributes($product) as $attribute) {
|
| 105 |
+
$usedProductCollection->addAttributeToSelect($attribute->getAttributeCode());
|
| 106 |
+
$usedProductCollection->addAttributeToFilter($attribute->getAttributeCode(), array('nin'=>array(null)));
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
$used_products = array();
|
| 110 |
+
foreach ($usedProductCollection as $rp) {
|
| 111 |
+
$rpraw = $rp->getData();
|
| 112 |
+
|
| 113 |
+
// // Remove fields we don't want which we're unable to filter when fetching the collection.
|
| 114 |
+
unset($rpraw['stock_item']);
|
| 115 |
+
unset($rpraw['created_at']);
|
| 116 |
+
unset($rpraw['updated_at']);
|
| 117 |
+
unset($rpraw['has_options']);
|
| 118 |
+
unset($rpraw['required_options']);
|
| 119 |
+
unset($rpraw['entity_type_id']);
|
| 120 |
+
unset($rpraw['attribute_set_id']);
|
| 121 |
+
// unset($rpraw['type_id']);
|
| 122 |
+
|
| 123 |
+
array_push($used_products,
|
| 124 |
+
// $rp->getData()
|
| 125 |
+
$rpraw
|
| 126 |
+
);
|
| 127 |
+
}
|
| 128 |
+
// // END : used products ?
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
// // The following applies to simple products with
|
| 132 |
+
// // custom options such as (page 8 under 'Computers'):
|
| 133 |
+
// // Apple MacBook Pro MA464LL/A 15.4" Notebook PC (i.e. product_id 25)
|
| 134 |
+
$custom_options = array();
|
| 135 |
+
// if (method_exists($product, 'getAllOptions') == true) {
|
| 136 |
+
// $options = $product->getAllOptions();
|
| 137 |
+
if (method_exists($product, 'getOptions') == true) {
|
| 138 |
+
$options = $product->getOptions();
|
| 139 |
+
|
| 140 |
+
if (count($options) > 0) {
|
| 141 |
+
error_log( 'info : [' . $product->getName() . '] of type [' . $product->getTypeId() . '] has [' . count($options) . '] options.' );
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
$index = 0;
|
| 145 |
+
foreach ($options as $o) {
|
| 146 |
+
// error_log('o = [' . print_r($o, true) . ']');
|
| 147 |
+
$ov = array();
|
| 148 |
+
$values = $o->getValues();
|
| 149 |
+
foreach ($values as $v) {
|
| 150 |
+
// // The next line has 'option_id', 'title', 'default_price' etc
|
| 151 |
+
array_push($ov, $v->getData());
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
$att = array(
|
| 155 |
+
'id' => $o->getId(),
|
| 156 |
+
'type' => $o->getType(),
|
| 157 |
+
'label' => $o->getTitle(),
|
| 158 |
+
// 'required' => $o->getRequired(),
|
| 159 |
+
// 'required' => $o->getData('required'),
|
| 160 |
+
// 'required' => $o->getData('is_required'),
|
| 161 |
+
// 'required' => $o->getIsRequired(),
|
| 162 |
+
'required' => $o->getIsRequire(),
|
| 163 |
+
// 'options' => array()
|
| 164 |
+
'options' => $ov
|
| 165 |
+
);
|
| 166 |
+
array_push($custom_options, $att);
|
| 167 |
+
|
| 168 |
+
$index++;
|
| 169 |
+
}
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
// // The following applies to bundle products
|
| 173 |
+
// // Sony VAIO 11.1" Notebook PC (psge 1 under 'Computers')
|
| 174 |
+
// // Never realized how complicated it is to get bundle options until now.
|
| 175 |
+
if (method_exists($product->getTypeInstance(true), 'getSelectionsCollection') == true) {
|
| 176 |
+
// // From app\code\core\Mage\Bundle\Model\Observer.php
|
| 177 |
+
$product->getTypeInstance(true)->setStoreFilter($product->getStoreId(), $product);
|
| 178 |
+
$optionCollection = $product->getTypeInstance(true)->getOptionsCollection($product);
|
| 179 |
+
$selectionCollection = $product->getTypeInstance(true)->getSelectionsCollection(
|
| 180 |
+
$product->getTypeInstance(true)->getOptionsIds($product),
|
| 181 |
+
$product
|
| 182 |
+
);
|
| 183 |
+
$optionCollection->appendSelections($selectionCollection);
|
| 184 |
+
|
| 185 |
+
$bundle_options = array();
|
| 186 |
+
// $selectionRawData = array();
|
| 187 |
+
|
| 188 |
+
$i = 0;
|
| 189 |
+
foreach ($optionCollection as $option) {
|
| 190 |
+
// error_log('option = [' . print_r($option, true) . ']');
|
| 191 |
+
$tmpSelectionData = array();
|
| 192 |
+
foreach ($option->getSelections() as $selection) {
|
| 193 |
+
// error_log('selection = [' . print_r($selection, true) . ']');
|
| 194 |
+
// $selectionRawData[$i][] = array(
|
| 195 |
+
$tmpSelectionData[] = array(
|
| 196 |
+
// 'option_id' => $selection->getOptionId(),
|
| 197 |
+
// 'option_id' => $selection->getOption()->getId(),
|
| 198 |
+
// 'option_label' => $selection->getOption()->getTitle(),
|
| 199 |
+
'name' => $selection->getName(),
|
| 200 |
+
'selection_id' => $selection->getSelectionId(),
|
| 201 |
+
'id' => $selection->getId(),
|
| 202 |
+
'product_id' => $selection->getProductId(),
|
| 203 |
+
// 'price' => $selection->getSelectionPrice(), // KO
|
| 204 |
+
// 'price' => $selection->getData('price'), // OK
|
| 205 |
+
'price' => $selection->getPrice(),
|
| 206 |
+
'position' => $selection->getPosition(),
|
| 207 |
+
'is_default' => $selection->getIsDefault(),
|
| 208 |
+
'selection_price_type' => $selection->getSelectionPriceType(),
|
| 209 |
+
'selection_price_value' => $selection->getSelectionPriceValue(),
|
| 210 |
+
'selection_qty' => $selection->getSelectionQty(),
|
| 211 |
+
'selection_can_change_qty' => $selection->getSelectionCanChangeQty(),
|
| 212 |
+
'delete' => ''
|
| 213 |
+
);
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
$bundle_options[$i] = array(
|
| 217 |
+
'id' => $option->getData('option_id'),
|
| 218 |
+
'required' => $option->getData('required'),
|
| 219 |
+
'position' => $option->getData('position'),
|
| 220 |
+
'type' => $option->getData('type'),
|
| 221 |
+
'title' => $option->getData('title')?$option->getData('title'):$option->getData('default_title'),
|
| 222 |
+
'delete' => '',
|
| 223 |
+
'options' => $tmpSelectionData
|
| 224 |
+
);
|
| 225 |
+
|
| 226 |
+
$i++;
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
// $newProduct->setBundleOptionsData($bundle_options);
|
| 230 |
+
// $newProduct->setBundleSelectionsData($selectionRawData);
|
| 231 |
+
}
|
| 232 |
+
// // END : tests
|
| 233 |
+
|
| 234 |
+
$result = array( // Basic product data
|
| 235 |
+
'product_id' => $product->getId(),
|
| 236 |
+
'sku' => $product->getSku(),
|
| 237 |
+
'set' => $product->getAttributeSetId(),
|
| 238 |
+
'type' => $product->getTypeId(),
|
| 239 |
+
'categories' => $product->getCategoryIds(),
|
| 240 |
+
// 'websites' => $product->getWebsiteIds(),
|
| 241 |
+
// // The next one is required for display but strangely is skipped by the foreach loop below.
|
| 242 |
+
'tax_percent' => $product->getTaxPercent(),
|
| 243 |
+
'price_includes_tax' => Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX, $store),
|
| 244 |
+
'product_collection' => $filteredProducts,
|
| 245 |
+
'currency_symbol' => Mage::app()->getLocale()->currency(Mage::app()->getStore($store)->getCurrentCurrencyCode())->getSymbol()
|
| 246 |
+
);
|
| 247 |
+
|
| 248 |
+
foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) {
|
| 249 |
+
if ($this->_isAllowedAttribute($attribute, $attributes)) {
|
| 250 |
+
$result[$attribute->getAttributeCode()] = $product->getData($attribute->getAttributeCode());
|
| 251 |
+
}
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
// // START : tests
|
| 255 |
+
// // Add configurable attributes here.
|
| 256 |
+
if (!empty($configurable_attributes)) {
|
| 257 |
+
$result['configurable_attributes'] = $configurable_attributes;
|
| 258 |
+
$result['used_products'] = $used_products;
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
// // Add custom options here.
|
| 262 |
+
if (!empty($custom_options)) {
|
| 263 |
+
$result['custom_options'] = $custom_options;
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
// // Add bundle options here.
|
| 267 |
+
if (!empty($bundle_options)) {
|
| 268 |
+
$result['bundle_options'] = $bundle_options;
|
| 269 |
+
}
|
| 270 |
+
// // END : tests
|
| 271 |
+
|
| 272 |
+
return $result;
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
} // Class Atipso_Catalog_Model_Product_Api End
|
app/code/local/Atipso/Atipsosync/Model/Product/Attribute/.DS_Store
ADDED
|
Binary file
|
app/code/local/Atipso/Atipsosync/Model/Product/Attribute/Media/.DS_Store
ADDED
|
Binary file
|
app/code/local/Atipso/Atipsosync/Model/Product/Attribute/Media/Api.php
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Catalog model product attribute media api - overrides Mage_Catalog_Model_Product_Attribute_Media_Api
|
| 4 |
+
*
|
| 5 |
+
* @category Atipso
|
| 6 |
+
* @package Atipso_Atipsosync
|
| 7 |
+
* @author Sigi Eisenreich
|
| 8 |
+
*/
|
| 9 |
+
class Atipso_Atipsosync_Model_Product_Attribute_Media_Api extends Mage_Catalog_Model_Product_Attribute_Media_Api
|
| 10 |
+
{
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* Retrieve images for product
|
| 14 |
+
*
|
| 15 |
+
* @param int|string $productId
|
| 16 |
+
* @param string|int $store
|
| 17 |
+
* @param any (?) $identifierType
|
| 18 |
+
* @param Array $filters
|
| 19 |
+
* @return array
|
| 20 |
+
*/
|
| 21 |
+
public function itemsWithResized($productId, $store = null, $identifierType = null, $filters = null)
|
| 22 |
+
{
|
| 23 |
+
// error_log('itemsWithResized');
|
| 24 |
+
|
| 25 |
+
$product = $this->_initProduct($productId, $store, $identifierType);
|
| 26 |
+
|
| 27 |
+
$gallery = $this->_getGalleryAttribute($product);
|
| 28 |
+
|
| 29 |
+
$galleryData = $product->getData(self::ATTRIBUTE_CODE);
|
| 30 |
+
|
| 31 |
+
if (!isset($galleryData['images']) || !is_array($galleryData['images'])) {
|
| 32 |
+
return array();
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
$imageWidth = 100;
|
| 36 |
+
if (isset($filters['image_width']) && !empty($filters['image_width'])) {
|
| 37 |
+
$imageWidth = $filters['image_width'];
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
$imageHeight = 100;
|
| 41 |
+
if (isset($filters['image_height']) && !empty($filters['image_height'])) {
|
| 42 |
+
$imageHeight = $filters['image_height'];
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
$catalogImageHelper = Mage::helper('catalog/image');
|
| 46 |
+
|
| 47 |
+
$result = array();
|
| 48 |
+
|
| 49 |
+
foreach ($galleryData['images'] as &$image) {
|
| 50 |
+
// $result[] = $this->_imageToArray($image, $product);
|
| 51 |
+
|
| 52 |
+
$arr = $this->_imageToArray($image, $product);
|
| 53 |
+
|
| 54 |
+
// // Get & set the url for the resized image
|
| 55 |
+
$arr['url'] = (string)$catalogImageHelper->init($product, 'image')->resize($imageWidth, $imageHeight);
|
| 56 |
+
// error_log('itemsWithResized::url=['.$arr['url'].']');
|
| 57 |
+
|
| 58 |
+
$result[] = $arr;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
return $result;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
}
|
app/code/local/Atipso/Atipsosync/etc/.DS_Store
ADDED
|
Binary file
|
app/code/local/Atipso/Atipsosync/etc/api.xml
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
|
| 3 |
+
<config>
|
| 4 |
+
<api>
|
| 5 |
+
<resources>
|
| 6 |
+
<atipsosync_core translate="title" module="atipsosync">
|
| 7 |
+
<model>atipsosync/core_api</model>
|
| 8 |
+
<title>Core API</title>
|
| 9 |
+
<acl>atipsosync/core</acl>
|
| 10 |
+
<methods>
|
| 11 |
+
<getStores translate="title" module="atipsosync">
|
| 12 |
+
<title>Get Stores</title>
|
| 13 |
+
<method>getStores</method>
|
| 14 |
+
<acl>atipsosync/core</acl>
|
| 15 |
+
</getStores>
|
| 16 |
+
<getStoreConfig translate="title" module="atipsosync">
|
| 17 |
+
<title>Get Store Config</title>
|
| 18 |
+
<method>getStoreConfig</method>
|
| 19 |
+
<acl>atipsosync/core</acl>
|
| 20 |
+
</getStoreConfig>
|
| 21 |
+
<currentVersion translate="title" module="atipsosync">
|
| 22 |
+
<title>currentVersion</title>
|
| 23 |
+
<method>currentVersion</method>
|
| 24 |
+
<acl>atipsosync/core/currentVersion</acl>
|
| 25 |
+
</currentVersion>
|
| 26 |
+
<currentAtipsoVersion translate="title" module="atipsosync">
|
| 27 |
+
<title>currentAtipsoVersion</title>
|
| 28 |
+
<method>currentAtipsoVersion</method>
|
| 29 |
+
<acl>atipsosync/core</acl>
|
| 30 |
+
</currentAtipsoVersion>
|
| 31 |
+
<getRootCategoryId translate="title" module="atipsosync">
|
| 32 |
+
<title>getRootCategoryId</title>
|
| 33 |
+
<method>getRootCategoryId</method>
|
| 34 |
+
<acl>atipsosync/core</acl>
|
| 35 |
+
</getRootCategoryId>
|
| 36 |
+
</methods>
|
| 37 |
+
</atipsosync_core>
|
| 38 |
+
<atipsosync_category translate="title" module="catalog">
|
| 39 |
+
<model>atipsosync/category_api</model>
|
| 40 |
+
<title>Category API</title>
|
| 41 |
+
<acl>catalog</acl>
|
| 42 |
+
<methods>
|
| 43 |
+
<assignedProductsDetail translate="title" module="catalog">
|
| 44 |
+
<title>Retrieve detailed list of assigned products to category</title>
|
| 45 |
+
<acl>catalog/category/product</acl>
|
| 46 |
+
</assignedProductsDetail>
|
| 47 |
+
<randomProductsForCategories translate="title" module="catalog">
|
| 48 |
+
<title>Retrieve random products for each main category</title>
|
| 49 |
+
<acl>catalog/category/product</acl>
|
| 50 |
+
</randomProductsForCategories>
|
| 51 |
+
<activeCategories translate="title" module="catalog">
|
| 52 |
+
<title>Get Active Categories</title>
|
| 53 |
+
<acl>catalog/category/product</acl>
|
| 54 |
+
</activeCategories>
|
| 55 |
+
</methods>
|
| 56 |
+
</atipsosync_category>
|
| 57 |
+
<atipsosync_product translate="title" module="catalog">
|
| 58 |
+
<title>Product API</title>
|
| 59 |
+
<model>atipsosync/product_api</model>
|
| 60 |
+
<acl>catalog/product</acl>
|
| 61 |
+
<methods>
|
| 62 |
+
<infoEnhanced translate="title" module="catalog">
|
| 63 |
+
<title>Get more Info on Product</title>
|
| 64 |
+
<acl>catalog/category/product</acl>
|
| 65 |
+
</infoEnhanced>
|
| 66 |
+
</methods>
|
| 67 |
+
</atipsosync_product>
|
| 68 |
+
|
| 69 |
+
<atipsosync_product_attribute_media translate="title" module="catalog">
|
| 70 |
+
<title>Product Images API</title>
|
| 71 |
+
<model>atipsosync/product_attribute_media_api</model>
|
| 72 |
+
<acl>catalog/product/media</acl>
|
| 73 |
+
<methods>
|
| 74 |
+
<itemsWithResized translate="title" module="catalog">
|
| 75 |
+
<title>Resize Product Images for Atipso</title>
|
| 76 |
+
<acl>catalog/category/product</acl>
|
| 77 |
+
</itemsWithResized>
|
| 78 |
+
</methods>
|
| 79 |
+
</atipsosync_product_attribute_media>
|
| 80 |
+
</resources>
|
| 81 |
+
<acl>
|
| 82 |
+
<resources>
|
| 83 |
+
<atipsosync translate="title" module="atipsosync">
|
| 84 |
+
<title>Atipso Sync API</title>
|
| 85 |
+
<sort_order>1</sort_order>
|
| 86 |
+
<core translate="title" module="atipsosync">
|
| 87 |
+
<title>Core</title>
|
| 88 |
+
<sort_order>100</sort_order>
|
| 89 |
+
<all></all>
|
| 90 |
+
</core>
|
| 91 |
+
</atipsosync>
|
| 92 |
+
</resources>
|
| 93 |
+
</acl>
|
| 94 |
+
</api>
|
| 95 |
+
</config>
|
app/code/local/Atipso/Atipsosync/etc/config.xml
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Atipso_Atipsosync>
|
| 5 |
+
<version>0.1.0</version>
|
| 6 |
+
</Atipso_Atipsosync>
|
| 7 |
+
</modules>
|
| 8 |
+
<global>
|
| 9 |
+
<models>
|
| 10 |
+
<atipsosync>
|
| 11 |
+
<class>Atipso_Atipsosync_Model</class>
|
| 12 |
+
<category_api>Atipso_Atipsosync_Model_Category_Api</category_api>
|
| 13 |
+
<product_api>Atipso_Atipsosync_Model_Product_Api</product_api>
|
| 14 |
+
<product_attribute_media_api>Atipso_Atipsosync_Model_Product_Attribute_Media_Api</product_attribute_media_api>
|
| 15 |
+
</atipsosync>
|
| 16 |
+
</models>
|
| 17 |
+
<resources>
|
| 18 |
+
<atipsosync_setup>
|
| 19 |
+
<setup>
|
| 20 |
+
<module>Atipso_Atipsosync</module>
|
| 21 |
+
<class>Atipso_Atipsosync_Model_Mysql4_Setup</class>
|
| 22 |
+
</setup>
|
| 23 |
+
<connection>
|
| 24 |
+
<use>core_setup</use>
|
| 25 |
+
</connection>
|
| 26 |
+
</atipsosync_setup>
|
| 27 |
+
</resources>
|
| 28 |
+
<helpers>
|
| 29 |
+
<atipsosync>
|
| 30 |
+
<class>Atipso_Atipsosync_Helper</class>
|
| 31 |
+
</atipsosync>
|
| 32 |
+
</helpers>
|
| 33 |
+
</global>
|
| 34 |
+
</config>
|
app/etc/modules/Atipso_Atipsosync.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Atipso_Atipsosync>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>local</codePool>
|
| 7 |
+
</Atipso_Atipsosync>
|
| 8 |
+
</modules>
|
| 9 |
+
</config>
|
atipsoAddMultipleProducts.php
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
require_once ('app/Mage.php');
|
| 3 |
+
Mage::app();
|
| 4 |
+
$session = Mage::getModel('core/session', array('name' => 'frontend'));
|
| 5 |
+
|
| 6 |
+
/*
|
| 7 |
+
// // Simple products test. Works :)
|
| 8 |
+
$productIds = array(51, 52);
|
| 9 |
+
|
| 10 |
+
$cart = Mage::getModel('checkout/cart');
|
| 11 |
+
$cart->addProductsByIds($productIds);
|
| 12 |
+
$cart->save();
|
| 13 |
+
*/
|
| 14 |
+
|
| 15 |
+
// // TODO : Now figure out products with configurable attributes, custom options and bundle options. Ok ...
|
| 16 |
+
|
| 17 |
+
// // Product id & options
|
| 18 |
+
/*
|
| 19 |
+
// // These were tested OK
|
| 20 |
+
|
| 21 |
+
// // TEST 1. Simple products
|
| 22 |
+
$productIds = array(51, 52);
|
| 23 |
+
|
| 24 |
+
// // TEST 2. Configurable product
|
| 25 |
+
$productIds = array(119);
|
| 26 |
+
$params = array(
|
| 27 |
+
'qty' => 1,
|
| 28 |
+
'super_attribute' => array(
|
| 29 |
+
525 => 100
|
| 30 |
+
)
|
| 31 |
+
);
|
| 32 |
+
|
| 33 |
+
// // TEST 3. (Simple ?) products with custom options
|
| 34 |
+
$productIds = array(25);
|
| 35 |
+
$params = array(
|
| 36 |
+
'qty' => 1,
|
| 37 |
+
'options' => array(
|
| 38 |
+
1 => 3
|
| 39 |
+
)
|
| 40 |
+
);
|
| 41 |
+
|
| 42 |
+
// // TEST 4. Bundle product. Magento will report these products as NOT configurable.
|
| 43 |
+
$productIds = array(164);
|
| 44 |
+
$params = array(
|
| 45 |
+
'product' => 164,
|
| 46 |
+
// 'related_product' => null,
|
| 47 |
+
'bundle_option' => array(
|
| 48 |
+
21 => 58, // NZXT Lexa Silver Aluminum ATX Mid-Tower Case (Default)
|
| 49 |
+
20 => 55, // Intel C2D E8400 3.0GHz Retail
|
| 50 |
+
11 => 29, // Crucial 2GB PC4200 DDR2 533MHz Memory
|
| 51 |
+
12 => array(
|
| 52 |
+
0 => 30 // Western Digital - 1TB HD - 7200RPM
|
| 53 |
+
),
|
| 54 |
+
13 => array(
|
| 55 |
+
0 => 34, // Microsoft Wireless Optical Mouse 5000
|
| 56 |
+
1 => 35 // Microsoft Natural Ergonomic Keyboard 4000
|
| 57 |
+
)
|
| 58 |
+
),
|
| 59 |
+
// 'options' => array(),
|
| 60 |
+
'qty' => 1
|
| 61 |
+
);
|
| 62 |
+
*/
|
| 63 |
+
|
| 64 |
+
// // TEST 5. This is a variation of TEST 4.
|
| 65 |
+
// // Here we get 'params' from a JSON string which is the
|
| 66 |
+
// // same string from the Superstorefront widget's cookie.
|
| 67 |
+
$json_string = '{"items":[{"product":"119","name":"Coalesce: Functioning On Impatience T-Shirt","price":"15.00","cart_url":"http://pmg.webhop.org/magento/checkout/cart/add?product=119&qty=1","qty":"1","options":{},"super_attribute":{"525":"100"},"bundle_option":{}},{"product":"164","name":"Gaming Computer","price":"4999.95","cart_url":"http://pmg.webhop.org/magento/checkout/cart/add?product=164&qty=1","qty":"1","options":{},"super_attribute":{},"bundle_option":{"21":["58"],"20":["56"],"13":["32","33"],"11":"29","12":["31"]}},{"product":"25","name":"Apple MacBook Pro MA464LL/A 15.4\" Notebook PC","price":"2299.99","cart_url":"http://pmg.webhop.org/magento/checkout/cart/add?product=25&qty=1","qty":"1","options":{"1":"2"},"super_attribute":{},"bundle_option":{}},{"product":"51","name":"Ottoman","price":"299.99","cart_url":"http://pmg.webhop.org/magento/checkout/cart/add?product=51&qty=1","qty":"1","options":{},"super_attribute":{},"bundle_option":{}}]}';
|
| 68 |
+
if (isset($_POST['cart_string'])) {
|
| 69 |
+
$json_string = $_POST['cart_string'];
|
| 70 |
+
}
|
| 71 |
+
error_log('json_string = ' . $json_string);
|
| 72 |
+
$qartObject = json_decode($json_string);
|
| 73 |
+
$items = $qartObject->items;
|
| 74 |
+
// $item0 = $items[0];
|
| 75 |
+
// // The next line KO
|
| 76 |
+
// $params = $item0;
|
| 77 |
+
|
| 78 |
+
$cart = Mage::getModel('checkout/cart');
|
| 79 |
+
try {
|
| 80 |
+
// foreach( $productIds as $productId) {
|
| 81 |
+
foreach( $items as $item) {
|
| 82 |
+
$productId = $item->product;
|
| 83 |
+
|
| 84 |
+
// $qty = $this->getRequest()->getParam('qty' . $productId, 0);
|
| 85 |
+
// $qty = 1;
|
| 86 |
+
$qty = $item->qty;
|
| 87 |
+
|
| 88 |
+
if ($qty <= 0) continue; // nothing to add
|
| 89 |
+
|
| 90 |
+
// $cart = $this->_getCart();
|
| 91 |
+
$product = Mage::getModel('catalog/product')
|
| 92 |
+
->setStoreId(Mage::app()->getStore()->getId())
|
| 93 |
+
->load($productId);
|
| 94 |
+
// ->setConfiguredAttributes($this->getRequest()->getParam('super_attribute'));
|
| 95 |
+
// ->setGroupedProducts($this->getRequest()->getParam('super_group', array())); // might need this later ...
|
| 96 |
+
|
| 97 |
+
/*
|
| 98 |
+
$eventArgs = array(
|
| 99 |
+
'product' => $product,
|
| 100 |
+
'qty' => $qty,
|
| 101 |
+
// 'request' => $this->getRequest(),
|
| 102 |
+
// 'request' => Mage::app()->getRequest(),
|
| 103 |
+
'request' => new Mage_Core_Controller_Request_Http(),
|
| 104 |
+
// 'request' => $this->getResponse()
|
| 105 |
+
// 'response' => Mage::app()->getResponse()
|
| 106 |
+
'response' => new Mage_Core_Controller_Response_Http(),
|
| 107 |
+
'additional_ids' => array()
|
| 108 |
+
);
|
| 109 |
+
|
| 110 |
+
Mage::dispatchEvent('checkout_cart_before_add', $eventArgs);
|
| 111 |
+
|
| 112 |
+
$cart->addProduct($product, $qty);
|
| 113 |
+
*/
|
| 114 |
+
|
| 115 |
+
// // Convert 'option' objects to arrays as Magento accepts the latter.
|
| 116 |
+
// // The irregular variable naming convention below is deliberate
|
| 117 |
+
// // in order to be in sync with the one used by Magento.
|
| 118 |
+
$selectedMap = array(
|
| 119 |
+
'bundle_option' => array(),
|
| 120 |
+
'super_attribute' => array(),
|
| 121 |
+
'options' => array()
|
| 122 |
+
|
| 123 |
+
);
|
| 124 |
+
foreach ($selectedMap as $kkey => $vvalue) {
|
| 125 |
+
if ( is_array($item->{$kkey}) ) {
|
| 126 |
+
$vvalue = $item->{$kkey};
|
| 127 |
+
} else {
|
| 128 |
+
foreach($item->{$kkey} as $key => $value) {
|
| 129 |
+
$vvalue[$key] = $value;
|
| 130 |
+
}
|
| 131 |
+
}
|
| 132 |
+
// // Remember to overwrite the value for this key.
|
| 133 |
+
$selectedMap[$kkey] = $vvalue;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
$params = array(
|
| 137 |
+
// 'product' => $item->product,
|
| 138 |
+
'product' => $productId,
|
| 139 |
+
'bundle_option' => $selectedMap['bundle_option'],
|
| 140 |
+
'super_attribute' => $selectedMap['super_attribute'],
|
| 141 |
+
'options' => $selectedMap['options'],
|
| 142 |
+
// 'qty' => $item->qty
|
| 143 |
+
'qty' => $qty
|
| 144 |
+
);
|
| 145 |
+
|
| 146 |
+
$cart->addProduct($product, $params);
|
| 147 |
+
|
| 148 |
+
// Mage::dispatchEvent('checkout_cart_after_add', $eventArgs);
|
| 149 |
+
|
| 150 |
+
$productNames[] = $product->getName();
|
| 151 |
+
} // // end : foreach( $items as $item
|
| 152 |
+
|
| 153 |
+
$cart->save();
|
| 154 |
+
|
| 155 |
+
// Mage::dispatchEvent('checkout_cart_add_product', array('product'=>$product));
|
| 156 |
+
|
| 157 |
+
// $message = $this->__('%s was successfully added to your shopping cart.', $product->getName());
|
| 158 |
+
$message = sprintf('%s was successfully added to your shopping cart.', implode($productNames, ', '));
|
| 159 |
+
|
| 160 |
+
Mage::getSingleton('checkout/session')->addSuccess($message);
|
| 161 |
+
}
|
| 162 |
+
catch (Mage_Core_Exception $e) {
|
| 163 |
+
error_log('Mage_Core_Exception : ' . $e->getMessage());
|
| 164 |
+
if (Mage::getSingleton('checkout/session')->getUseNotice(true)) {
|
| 165 |
+
Mage::getSingleton('checkout/session')->addNotice($product->getName() . ': ' . $e->getMessage());
|
| 166 |
+
}
|
| 167 |
+
else {
|
| 168 |
+
Mage::getSingleton('checkout/session')->addError($product->getName() . ': ' . $e->getMessage());
|
| 169 |
+
}
|
| 170 |
+
}
|
| 171 |
+
catch (Exception $e) {
|
| 172 |
+
error_log('Exception : ' . $e->getMessage());
|
| 173 |
+
// Mage::getSingleton('checkout/session')->addException($e, $this->__('Can not add item to shopping cart'));
|
| 174 |
+
Mage::getSingleton('checkout/session')->addException($e, 'Can not add item to shopping cart');
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
// change to relevant URL for your store!
|
| 178 |
+
// header("location: http://pmg.webhop.org/magento/checkout/cart/");
|
| 179 |
+
header("location: checkout/cart/");
|
package.xml
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>atipsosync</name>
|
| 4 |
+
<version>0.1.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://creativecommons.org/licenses/by-nd/3.0/">Creative Commons Attribution-NoDerivs 3.0 Unported (CC BY-ND 3.0)</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Sell your Products on Facebook with Atipso! Works via Drag & Drop!</summary>
|
| 10 |
+
<description><p>AtipApi extends the Magento API to display your shop on Facebook via Atipso. 
|
| 11 |
+
<strong>Create your Facebook shop in 5min! </strong> </p>
|
| 12 |
+
<p><img alt="Atipso" src="http://www.atipso.com/wp-content/themes/Accent/cache/1314451865_atipso-logo.png" />
|
| 13 |
+
Atipso is a easy to use Page-builder in which you can create Facebook Tabs, Facebook Pages and embed your pages on any other Webpage. <a href="http://www.atipso.com" target="_blank">Learn more</a></p>
|
| 14 |
+
<p>The current version of Atipso supports: <br /><ul>
|
| 15 |
+
<li>Simple Products</li>
|
| 16 |
+
<li>Custom Product Options</li>
|
| 17 |
+
<li>Special Prices</li>
|
| 18 |
+
<li>Magento Checkout</li>
|
| 19 |
+
<li>Select Store View & Categories to display</li>
|
| 20 |
+
</ul>
|
| 21 |
+
</p></description>
|
| 22 |
+
<notes>First Release</notes>
|
| 23 |
+
<authors><author><name>Sigi Eisenreich</name><user>arve</user><email>sigi@nnpro.at</email></author></authors>
|
| 24 |
+
<date>2011-11-10</date>
|
| 25 |
+
<time>13:02:53</time>
|
| 26 |
+
<contents><target name="mage"><dir><dir><file name="atipsoAddMultipleProducts.php" hash="9585558cb0d8419467c70021101aba03"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Atipso_Atipsosync.xml" hash="f671a4671d39e6b652d036302e0ef75d"/></dir></target><target name="magelocal"><dir name="Atipso"><dir name="Atipsosync"><dir name="Helper"><file name="Data.php" hash="8bba76adf3300a0ac24974d4b2623974"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Model"><dir name="Category"><file name="Api.php" hash="87e189a99ce688cf70dc8303e1732061"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Core"><file name="Api.php" hash="55df00f9bf2647869990285ccb3b2553"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Mysql4"><file name="Setup.php" hash="7b58689f7d69683ec473adff25dc7ff0"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Product"><file name="Api.php" hash="bd40a956314ed600b47133fab05e22f2"/><dir name="Attribute"><dir name="Media"><file name="Api.php" hash="afc5588379b0b8cf2fd753fabe72be5c"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="cbdcc3cfd1433c742dd218534d76dc51"/></dir><dir name="etc"><file name="api.xml" hash="3493cbe1b961faed2923a7f37b1aacec"/><file name="config.xml" hash="3300dc07b946f458e7c79298b8b2462e"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="0988f05caf9483b3b3fe782def6d425d"/></dir><file name=".DS_Store" hash="7a24f5557216556d7ebe1c623da53c15"/></dir></target></contents>
|
| 27 |
+
<compatible/>
|
| 28 |
+
<dependencies><required><php><min>5.2.3</min><max>5.2.9</max></php></required></dependencies>
|
| 29 |
+
</package>
|
