Version Notes
Notes in here
Download this release
Release Info
Developer | Volo |
Extension | eSellerProPlugin |
Version | 1.1.2.2 |
Comparing to | |
See all releases |
Code changes from version 1.1.2.1 to 1.1.2.2
app/code/local/Sandbourne/BulkApi/Model/FullProduct/Api.php
CHANGED
@@ -1,298 +1,298 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Sandbourne_BulkApi_Model_FullProduct_Api extends Mage_Api_Model_Resource_Abstract
|
4 |
-
{
|
5 |
-
public function __construct()
|
6 |
-
{
|
7 |
-
//$this->_debug('FullProduct constructed');
|
8 |
-
}
|
9 |
-
|
10 |
-
public function version()
|
11 |
-
{
|
12 |
-
//return "1.0.0.6"; // 20140604 (Beta)
|
13 |
-
//return "1.0.0.7"; // 20140702 (Beta)
|
14 |
-
//return "1.1.0.0"; // 20141017 (First Stable release)
|
15 |
-
//return "1.1.0.1"; // 20141121
|
16 |
-
//return "1.1.0.2"; // 20150421
|
17 |
-
//return "1.1.0.3"; // 20150618
|
18 |
-
//return "1.1.1.0"; // 20150724 (enhancements 88826, 88828)
|
19 |
-
//return "1.1.1.1"; // 20150730 (improvement 88168)
|
20 |
-
//return "1.1.1.2"; // 20151125 (Change request be Creative)
|
21 |
-
//return "1.1.2.0"; // 20151012 (scale prices 92003 - Needs Testing)
|
22 |
-
return "1.1.2.1"; // 201500209 (duplicated images on Website- request from Creative)
|
23 |
-
}
|
24 |
-
|
25 |
-
public function update($productXML)
|
26 |
-
{
|
27 |
-
$resultXMLData = new DOMDocument();
|
28 |
-
$productResultsXMLData = $resultXMLData->createElement('ProductResults');
|
29 |
-
$resultXMLData->appendChild($productResultsXMLData);
|
30 |
-
$productXMLData = simplexml_load_string($productXML);
|
31 |
-
|
32 |
-
$attributeHelper = Mage::helper('bulkapi/attribute');
|
33 |
-
$defaultAttributeSetId = $attributeHelper->getDefaultAttributeSetId();
|
34 |
-
$magentoAttributeList = Mage::getResourceModel('catalog/product_attribute_collection')->addVisibleFilter();
|
35 |
-
|
36 |
-
$attributeCache = Mage::helper('bulkapi/attributeCache');
|
37 |
-
$attributeCache->resetCache($magentoAttributeList);
|
38 |
-
|
39 |
-
foreach ($productXMLData as $productData)
|
40 |
-
{
|
41 |
-
$productResultXMLData = new DOMElement('ProductResult');
|
42 |
-
$productResultsXMLData->appendChild($productResultXMLData);
|
43 |
-
$this->updateOrCreateProduct($productData, $defaultAttributeSetId, $productResultXMLData, $attributeCache);
|
44 |
-
}
|
45 |
-
return $resultXMLData->saveXML();
|
46 |
-
}
|
47 |
-
|
48 |
-
private function updateOrCreateProduct($productData, $defaultAttributeSetId, $productResultXMLData, $attributeCache)
|
49 |
-
{
|
50 |
-
$productResultXMLData->appendChild(new DOMElement('StockNumber', $productData->StockNumber));
|
51 |
-
$productID = Mage::getModel('catalog/product')->getIdBySku($productData->StockNumber);
|
52 |
-
$addUpdateProduct = false;
|
53 |
-
|
54 |
-
// If the following SKUType is a SubSKU, we need to ignore the Variations node, as we do not want any attached listing SKU's.
|
55 |
-
if ((string)$productData->SKUType == "Sub")
|
56 |
-
{
|
57 |
-
$configurableDataSentFlag = 0;
|
58 |
-
}
|
59 |
-
else
|
60 |
-
{
|
61 |
-
$configurableDataSentFlag = (strcmp($productData->UseVariations,'Y') == 0);
|
62 |
-
}
|
63 |
-
|
64 |
-
if ($productID > 0)
|
65 |
-
{
|
66 |
-
// Product exists.
|
67 |
-
$addUpdateProduct = true;
|
68 |
-
$product = Mage::getModel('catalog/product')->load($productID);
|
69 |
-
}
|
70 |
-
else
|
71 |
-
{
|
72 |
-
// Product doesn't exist, but we only want to create it, if it is active.
|
73 |
-
if ((string)$productData->IsActive === 'Y')
|
74 |
-
{
|
75 |
-
$addUpdateProduct = true;
|
76 |
-
}
|
77 |
-
|
78 |
-
if ($addUpdateProduct)
|
79 |
-
{
|
80 |
-
$product = Mage::getModel('catalog/product');
|
81 |
-
$product->setSku($productData->StockNumber);
|
82 |
-
|
83 |
-
// Before setting the Product Type we need to know what the SKU type is, as only the "Master" can be configurable.
|
84 |
-
// SKUTypes = "Master", "Sub" or "Listing".
|
85 |
-
if ($configurableDataSentFlag && (string)$productData->SKUType == "Master")
|
86 |
-
{
|
87 |
-
$product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE);
|
88 |
-
}
|
89 |
-
else
|
90 |
-
{
|
91 |
-
$product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE);
|
92 |
-
}
|
93 |
-
|
94 |
-
$product->setAttributeSetId($defaultAttributeSetId);
|
95 |
-
$product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
|
96 |
-
}
|
97 |
-
}
|
98 |
-
|
99 |
-
if ($addUpdateProduct)
|
100 |
-
{
|
101 |
-
// Define the websites to use for the product
|
102 |
-
$productWebsites = Mage::helper('bulkapi/website');
|
103 |
-
$product->setWebsiteIds($productWebsites->getProductWebsiteIDs($productData));
|
104 |
-
|
105 |
-
// Assign any related products associated for the product
|
106 |
-
$productRelatedProducts = Mage::helper('bulkapi/relatedProducts');
|
107 |
-
$product->setRelatedLinkData($productRelatedProducts->getRelatedProducts($productData));
|
108 |
-
|
109 |
-
// Check to see if we have been asked to ignore categories
|
110 |
-
$this->setProductProperties($product,$productData);
|
111 |
-
if (strcmp($productData->IgnoreCategories,'Y') != 0)
|
112 |
-
{
|
113 |
-
$categoryHelper = Mage::helper('bulkapi/category');
|
114 |
-
$categoryHelper->setProductCategories($product,$productData);
|
115 |
-
}
|
116 |
-
|
117 |
-
// Check to see if we have been asked to ignore custom fields
|
118 |
-
if (strcmp($productData->IgnoreCustomFields,'Y') != 0)
|
119 |
-
{
|
120 |
-
$attributeHelper = Mage::helper('bulkapi/attribute');
|
121 |
-
$attributeHelper->setCustomFieldGroupValues($product,$productData, $attributeCache);
|
122 |
-
}
|
123 |
-
|
124 |
-
// Check to see if we have been asked to ignore images
|
125 |
-
if (strcmp($productData->IgnoreImages,'Y') != 0)
|
126 |
-
{
|
127 |
-
$imageHelper = Mage::helper('bulkapi/image');
|
128 |
-
$imageHelper->setImageList($product, $productData, $productResultXMLData); //$magentoAttributeList);
|
129 |
-
}
|
130 |
-
|
131 |
-
if ($configurableDataSentFlag)
|
132 |
-
{
|
133 |
-
$configurableHelper = Mage::helper('bulkapi/configurableProduct');
|
134 |
-
$configurableHelper->setConfigurableProducts($product, $productData, $attributeCache);
|
135 |
-
}
|
136 |
-
$product->save();
|
137 |
-
|
138 |
-
// After we have saved all the details, lets check to see if we need to update variation scale prices.
|
139 |
-
if (strcmp($productData->ScalePricing,'Y') == 0)
|
140 |
-
{
|
141 |
-
|
142 |
-
|
143 |
-
}
|
144 |
-
}
|
145 |
-
}
|
146 |
-
|
147 |
-
private function setProductProperties($magentoProduct, $productData)
|
148 |
-
{
|
149 |
-
$title = $this->getTitle($productData);
|
150 |
-
$magentoProduct->setName($title);
|
151 |
-
$magentoProduct->setMetaTitle($title);
|
152 |
-
|
153 |
-
// Change request be Creative.
|
154 |
-
// Set release date
|
155 |
-
if ((string)$productData->NewRelease == "Y" && $date = (string)$productData->ReleaseDate)
|
156 |
-
{
|
157 |
-
$magentoProduct->setData('news_from_date', $date);
|
158 |
-
$magentoProduct->setData('news_to_date', date("Y-m-d", strtotime("+2 weeks",strtotime($date))));
|
159 |
-
}
|
160 |
-
else
|
161 |
-
{
|
162 |
-
$magentoProduct->setData('news_from_date', "");
|
163 |
-
$magentoProduct->setData('news_to_date', "");
|
164 |
-
}
|
165 |
-
|
166 |
-
// Make a double check we have the visibility of the product correct
|
167 |
-
if ((string)$productData->SKUType == "Sub")
|
168 |
-
{
|
169 |
-
$magentoProduct->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
|
170 |
-
}
|
171 |
-
else // SKUType is "Master" or "Listing" so should be visable
|
172 |
-
{
|
173 |
-
$magentoProduct->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
|
174 |
-
}
|
175 |
-
|
176 |
-
// Should we be ignoring any changes to the description
|
177 |
-
if (strcmp($productData->IgnoreDescription,'Y') != 0)
|
178 |
-
{
|
179 |
-
$magentoProduct->setDescription($productData->Description);
|
180 |
-
}
|
181 |
-
|
182 |
-
$magentoProduct->setShortDescription($productData->ShortDescription);
|
183 |
-
$magentoProduct->setPrice($productData->SellPrice);
|
184 |
-
|
185 |
-
// Include the CostPrice
|
186 |
-
$magentoProduct->setCost($productData->CostEach);
|
187 |
-
|
188 |
-
// Include the RRP price
|
189 |
-
$magentoProduct->setMsrp($productData->RRP);
|
190 |
-
|
191 |
-
// Include the UPC (barcode)
|
192 |
-
// Make sure the customer has an attribute with the Attribute Code of "upc" or "barcode"
|
193 |
-
$magentoProduct->setData("upc", $productData->UPC);
|
194 |
-
$magentoProduct->setData("barcode", $productData->UPC);
|
195 |
-
|
196 |
-
// Include sales price info
|
197 |
-
if (((string)$productData->OnSale === 'Y') && ((string)$productData->SalePrice > '0'))
|
198 |
-
{
|
199 |
-
$magentoProduct->setSpecialPrice($productData->SalePrice);
|
200 |
-
$magentoProduct->setSpecialFromDate($productData->OnSaleStartDate);
|
201 |
-
$magentoProduct->setSpecialToDate($productData->OnSaleEndDate);
|
202 |
-
}
|
203 |
-
else
|
204 |
-
{
|
205 |
-
$magentoProduct->setSpecialPrice('');
|
206 |
-
$magentoProduct->setSpecialFromDate('');
|
207 |
-
$magentoProduct->setSpecialToDate('');
|
208 |
-
}
|
209 |
-
|
210 |
-
// Include Meta Data
|
211 |
-
$magentoProduct->setMetaKeyword($productData->Keywords);
|
212 |
-
$magentoProduct->setMetaDescription($productData->MetaDescription);
|
213 |
-
|
214 |
-
$active = ((string)$productData->IsActive === 'Y' ?
|
215 |
-
Mage_Catalog_Model_Product_Status::STATUS_ENABLED :
|
216 |
-
Mage_Catalog_Model_Product_Status::STATUS_DISABLED);
|
217 |
-
|
218 |
-
$magentoProduct->setStatus($active);
|
219 |
-
$magentoProduct->setWeight($productData->Weight);
|
220 |
-
|
221 |
-
// Set the TaxCodeId integer from the TaxCode string
|
222 |
-
//$magentoProduct->setTaxClassId(2);
|
223 |
-
$magentoProduct->setTaxClassId($this->setTaxCodeClass($productData->TaxCode));
|
224 |
-
|
225 |
-
$stockData = array();
|
226 |
-
$stockData['qty'] = $productData->StockLevel;
|
227 |
-
//$this->_debug('stock level for product:'.$productData->StockLevel);
|
228 |
-
|
229 |
-
// Set the 'is_in_stock' to true incase this is a master,
|
230 |
-
// if it is a subsku and the StockLevel is 0, this will automatically get set to false anyhow.
|
231 |
-
$stockData['is_in_stock'] = 1;
|
232 |
-
$magentoProduct->setStockData($stockData);
|
233 |
-
}
|
234 |
-
|
235 |
-
private function getTitle($productData)
|
236 |
-
{
|
237 |
-
$title = $productData->WebsiteTitle;
|
238 |
-
if (strlen($title) == 0)
|
239 |
-
{
|
240 |
-
$title = $productData->ListingTitle;
|
241 |
-
}
|
242 |
-
if (strlen($title) == 0)
|
243 |
-
{
|
244 |
-
$title = $productData->Title;
|
245 |
-
}
|
246 |
-
return $title;
|
247 |
-
}
|
248 |
-
|
249 |
-
private function setTaxCodeClass($taxCode)
|
250 |
-
{
|
251 |
-
$retVal = 2;
|
252 |
-
|
253 |
-
// Magento Product Tax Class standard definitions.
|
254 |
-
// 0 - None
|
255 |
-
// 1 - Default
|
256 |
-
// 2 - Taxable Goods
|
257 |
-
// 3 - Retail Customer
|
258 |
-
// 4 - Shipping
|
259 |
-
// 5 - VAT Standard
|
260 |
-
// 6 - VAT Reduced
|
261 |
-
// 7 - VAT Zero
|
262 |
-
|
263 |
-
// As a standard default, we set the $taxCode to; 2 - Taxable Goods
|
264 |
-
// To change this, create a new tax code in Volo under "Value Added Tax" and and with a pipe and the required code, i.e. "Shipping|4".
|
265 |
-
|
266 |
-
if (stripos($taxCode, "|"))
|
267 |
-
{
|
268 |
-
list($strIgnore, $strNumber) = array_pad(explode("|", $taxCode, 2), 2, "2");
|
269 |
-
$retVal = intval($strNumber);
|
270 |
-
}
|
271 |
-
else
|
272 |
-
{
|
273 |
-
switch ($taxCode)
|
274 |
-
{
|
275 |
-
case "E":
|
276 |
-
$retVal = 0;
|
277 |
-
break;
|
278 |
-
|
279 |
-
case "Z":
|
280 |
-
$retVal = 7;
|
281 |
-
break;
|
282 |
-
|
283 |
-
case "S":
|
284 |
-
$retVal = 5;
|
285 |
-
break;
|
286 |
-
|
287 |
-
default:
|
288 |
-
$retVal = 2;
|
289 |
-
}
|
290 |
-
}
|
291 |
-
return $retVal;
|
292 |
-
}
|
293 |
-
|
294 |
-
public function _debug($message)
|
295 |
-
{
|
296 |
-
Mage::log($message);
|
297 |
-
}
|
298 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Sandbourne_BulkApi_Model_FullProduct_Api extends Mage_Api_Model_Resource_Abstract
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
//$this->_debug('FullProduct constructed');
|
8 |
+
}
|
9 |
+
|
10 |
+
public function version()
|
11 |
+
{
|
12 |
+
//return "1.0.0.6"; // 20140604 (Beta)
|
13 |
+
//return "1.0.0.7"; // 20140702 (Beta)
|
14 |
+
//return "1.1.0.0"; // 20141017 (First Stable release)
|
15 |
+
//return "1.1.0.1"; // 20141121
|
16 |
+
//return "1.1.0.2"; // 20150421
|
17 |
+
//return "1.1.0.3"; // 20150618
|
18 |
+
//return "1.1.1.0"; // 20150724 (enhancements 88826, 88828)
|
19 |
+
//return "1.1.1.1"; // 20150730 (improvement 88168)
|
20 |
+
//return "1.1.1.2"; // 20151125 (Change request be Creative)
|
21 |
+
//return "1.1.2.0"; // 20151012 (scale prices 92003 - Needs Testing)
|
22 |
+
return "1.1.2.1"; // 201500209 (duplicated images on Website- request from Creative)
|
23 |
+
}
|
24 |
+
|
25 |
+
public function update($productXML)
|
26 |
+
{
|
27 |
+
$resultXMLData = new DOMDocument();
|
28 |
+
$productResultsXMLData = $resultXMLData->createElement('ProductResults');
|
29 |
+
$resultXMLData->appendChild($productResultsXMLData);
|
30 |
+
$productXMLData = simplexml_load_string($productXML);
|
31 |
+
|
32 |
+
$attributeHelper = Mage::helper('bulkapi/attribute');
|
33 |
+
$defaultAttributeSetId = $attributeHelper->getDefaultAttributeSetId();
|
34 |
+
$magentoAttributeList = Mage::getResourceModel('catalog/product_attribute_collection')->addVisibleFilter();
|
35 |
+
|
36 |
+
$attributeCache = Mage::helper('bulkapi/attributeCache');
|
37 |
+
$attributeCache->resetCache($magentoAttributeList);
|
38 |
+
|
39 |
+
foreach ($productXMLData as $productData)
|
40 |
+
{
|
41 |
+
$productResultXMLData = new DOMElement('ProductResult');
|
42 |
+
$productResultsXMLData->appendChild($productResultXMLData);
|
43 |
+
$this->updateOrCreateProduct($productData, $defaultAttributeSetId, $productResultXMLData, $attributeCache);
|
44 |
+
}
|
45 |
+
return $resultXMLData->saveXML();
|
46 |
+
}
|
47 |
+
|
48 |
+
private function updateOrCreateProduct($productData, $defaultAttributeSetId, $productResultXMLData, $attributeCache)
|
49 |
+
{
|
50 |
+
$productResultXMLData->appendChild(new DOMElement('StockNumber', $productData->StockNumber));
|
51 |
+
$productID = Mage::getModel('catalog/product')->getIdBySku($productData->StockNumber);
|
52 |
+
$addUpdateProduct = false;
|
53 |
+
|
54 |
+
// If the following SKUType is a SubSKU, we need to ignore the Variations node, as we do not want any attached listing SKU's.
|
55 |
+
if ((string)$productData->SKUType == "Sub")
|
56 |
+
{
|
57 |
+
$configurableDataSentFlag = 0;
|
58 |
+
}
|
59 |
+
else
|
60 |
+
{
|
61 |
+
$configurableDataSentFlag = (strcmp($productData->UseVariations,'Y') == 0);
|
62 |
+
}
|
63 |
+
|
64 |
+
if ($productID > 0)
|
65 |
+
{
|
66 |
+
// Product exists.
|
67 |
+
$addUpdateProduct = true;
|
68 |
+
$product = Mage::getModel('catalog/product')->load($productID);
|
69 |
+
}
|
70 |
+
else
|
71 |
+
{
|
72 |
+
// Product doesn't exist, but we only want to create it, if it is active.
|
73 |
+
if ((string)$productData->IsActive === 'Y')
|
74 |
+
{
|
75 |
+
$addUpdateProduct = true;
|
76 |
+
}
|
77 |
+
|
78 |
+
if ($addUpdateProduct)
|
79 |
+
{
|
80 |
+
$product = Mage::getModel('catalog/product');
|
81 |
+
$product->setSku($productData->StockNumber);
|
82 |
+
|
83 |
+
// Before setting the Product Type we need to know what the SKU type is, as only the "Master" can be configurable.
|
84 |
+
// SKUTypes = "Master", "Sub" or "Listing".
|
85 |
+
if ($configurableDataSentFlag && (string)$productData->SKUType == "Master")
|
86 |
+
{
|
87 |
+
$product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE);
|
88 |
+
}
|
89 |
+
else
|
90 |
+
{
|
91 |
+
$product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE);
|
92 |
+
}
|
93 |
+
|
94 |
+
$product->setAttributeSetId($defaultAttributeSetId);
|
95 |
+
$product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
if ($addUpdateProduct)
|
100 |
+
{
|
101 |
+
// Define the websites to use for the product
|
102 |
+
$productWebsites = Mage::helper('bulkapi/website');
|
103 |
+
$product->setWebsiteIds($productWebsites->getProductWebsiteIDs($productData));
|
104 |
+
|
105 |
+
// Assign any related products associated for the product
|
106 |
+
$productRelatedProducts = Mage::helper('bulkapi/relatedProducts');
|
107 |
+
$product->setRelatedLinkData($productRelatedProducts->getRelatedProducts($productData));
|
108 |
+
|
109 |
+
// Check to see if we have been asked to ignore categories
|
110 |
+
$this->setProductProperties($product,$productData);
|
111 |
+
if (strcmp($productData->IgnoreCategories,'Y') != 0)
|
112 |
+
{
|
113 |
+
$categoryHelper = Mage::helper('bulkapi/category');
|
114 |
+
$categoryHelper->setProductCategories($product,$productData);
|
115 |
+
}
|
116 |
+
|
117 |
+
// Check to see if we have been asked to ignore custom fields
|
118 |
+
if (strcmp($productData->IgnoreCustomFields,'Y') != 0)
|
119 |
+
{
|
120 |
+
$attributeHelper = Mage::helper('bulkapi/attribute');
|
121 |
+
$attributeHelper->setCustomFieldGroupValues($product,$productData, $attributeCache);
|
122 |
+
}
|
123 |
+
|
124 |
+
// Check to see if we have been asked to ignore images
|
125 |
+
if (strcmp($productData->IgnoreImages,'Y') != 0)
|
126 |
+
{
|
127 |
+
$imageHelper = Mage::helper('bulkapi/image');
|
128 |
+
$imageHelper->setImageList($product, $productData, $productResultXMLData); //$magentoAttributeList);
|
129 |
+
}
|
130 |
+
|
131 |
+
if ($configurableDataSentFlag)
|
132 |
+
{
|
133 |
+
$configurableHelper = Mage::helper('bulkapi/configurableProduct');
|
134 |
+
$configurableHelper->setConfigurableProducts($product, $productData, $attributeCache);
|
135 |
+
}
|
136 |
+
$product->save();
|
137 |
+
|
138 |
+
// After we have saved all the details, lets check to see if we need to update variation scale prices.
|
139 |
+
if (strcmp($productData->ScalePricing,'Y') == 0)
|
140 |
+
{
|
141 |
+
$pricesHelper = Mage::helper('bulkapi/prices');
|
142 |
+
$pricesHelper->scalePrices($product);
|
143 |
+
}
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
private function setProductProperties($magentoProduct, $productData)
|
148 |
+
{
|
149 |
+
$title = $this->getTitle($productData);
|
150 |
+
$magentoProduct->setName($title);
|
151 |
+
$magentoProduct->setMetaTitle($title);
|
152 |
+
|
153 |
+
// Change request be Creative.
|
154 |
+
// Set release date
|
155 |
+
if ((string)$productData->NewRelease == "Y" && $date = (string)$productData->ReleaseDate)
|
156 |
+
{
|
157 |
+
$magentoProduct->setData('news_from_date', $date);
|
158 |
+
$magentoProduct->setData('news_to_date', date("Y-m-d", strtotime("+2 weeks",strtotime($date))));
|
159 |
+
}
|
160 |
+
else
|
161 |
+
{
|
162 |
+
$magentoProduct->setData('news_from_date', "");
|
163 |
+
$magentoProduct->setData('news_to_date', "");
|
164 |
+
}
|
165 |
+
|
166 |
+
// Make a double check we have the visibility of the product correct
|
167 |
+
if ((string)$productData->SKUType == "Sub")
|
168 |
+
{
|
169 |
+
$magentoProduct->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
|
170 |
+
}
|
171 |
+
else // SKUType is "Master" or "Listing" so should be visable
|
172 |
+
{
|
173 |
+
$magentoProduct->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
|
174 |
+
}
|
175 |
+
|
176 |
+
// Should we be ignoring any changes to the description
|
177 |
+
if (strcmp($productData->IgnoreDescription,'Y') != 0)
|
178 |
+
{
|
179 |
+
$magentoProduct->setDescription($productData->Description);
|
180 |
+
}
|
181 |
+
|
182 |
+
$magentoProduct->setShortDescription($productData->ShortDescription);
|
183 |
+
$magentoProduct->setPrice($productData->SellPrice);
|
184 |
+
|
185 |
+
// Include the CostPrice
|
186 |
+
$magentoProduct->setCost($productData->CostEach);
|
187 |
+
|
188 |
+
// Include the RRP price
|
189 |
+
$magentoProduct->setMsrp($productData->RRP);
|
190 |
+
|
191 |
+
// Include the UPC (barcode)
|
192 |
+
// Make sure the customer has an attribute with the Attribute Code of "upc" or "barcode"
|
193 |
+
$magentoProduct->setData("upc", $productData->UPC);
|
194 |
+
$magentoProduct->setData("barcode", $productData->UPC);
|
195 |
+
|
196 |
+
// Include sales price info
|
197 |
+
if (((string)$productData->OnSale === 'Y') && ((string)$productData->SalePrice > '0'))
|
198 |
+
{
|
199 |
+
$magentoProduct->setSpecialPrice($productData->SalePrice);
|
200 |
+
$magentoProduct->setSpecialFromDate($productData->OnSaleStartDate);
|
201 |
+
$magentoProduct->setSpecialToDate($productData->OnSaleEndDate);
|
202 |
+
}
|
203 |
+
else
|
204 |
+
{
|
205 |
+
$magentoProduct->setSpecialPrice('');
|
206 |
+
$magentoProduct->setSpecialFromDate('');
|
207 |
+
$magentoProduct->setSpecialToDate('');
|
208 |
+
}
|
209 |
+
|
210 |
+
// Include Meta Data
|
211 |
+
$magentoProduct->setMetaKeyword($productData->Keywords);
|
212 |
+
$magentoProduct->setMetaDescription($productData->MetaDescription);
|
213 |
+
|
214 |
+
$active = ((string)$productData->IsActive === 'Y' ?
|
215 |
+
Mage_Catalog_Model_Product_Status::STATUS_ENABLED :
|
216 |
+
Mage_Catalog_Model_Product_Status::STATUS_DISABLED);
|
217 |
+
|
218 |
+
$magentoProduct->setStatus($active);
|
219 |
+
$magentoProduct->setWeight($productData->Weight);
|
220 |
+
|
221 |
+
// Set the TaxCodeId integer from the TaxCode string
|
222 |
+
//$magentoProduct->setTaxClassId(2);
|
223 |
+
$magentoProduct->setTaxClassId($this->setTaxCodeClass($productData->TaxCode));
|
224 |
+
|
225 |
+
$stockData = array();
|
226 |
+
$stockData['qty'] = $productData->StockLevel;
|
227 |
+
//$this->_debug('stock level for product:'.$productData->StockLevel);
|
228 |
+
|
229 |
+
// Set the 'is_in_stock' to true incase this is a master,
|
230 |
+
// if it is a subsku and the StockLevel is 0, this will automatically get set to false anyhow.
|
231 |
+
$stockData['is_in_stock'] = 1;
|
232 |
+
$magentoProduct->setStockData($stockData);
|
233 |
+
}
|
234 |
+
|
235 |
+
private function getTitle($productData)
|
236 |
+
{
|
237 |
+
$title = $productData->WebsiteTitle;
|
238 |
+
if (strlen($title) == 0)
|
239 |
+
{
|
240 |
+
$title = $productData->ListingTitle;
|
241 |
+
}
|
242 |
+
if (strlen($title) == 0)
|
243 |
+
{
|
244 |
+
$title = $productData->Title;
|
245 |
+
}
|
246 |
+
return $title;
|
247 |
+
}
|
248 |
+
|
249 |
+
private function setTaxCodeClass($taxCode)
|
250 |
+
{
|
251 |
+
$retVal = 2;
|
252 |
+
|
253 |
+
// Magento Product Tax Class standard definitions.
|
254 |
+
// 0 - None
|
255 |
+
// 1 - Default
|
256 |
+
// 2 - Taxable Goods
|
257 |
+
// 3 - Retail Customer
|
258 |
+
// 4 - Shipping
|
259 |
+
// 5 - VAT Standard
|
260 |
+
// 6 - VAT Reduced
|
261 |
+
// 7 - VAT Zero
|
262 |
+
|
263 |
+
// As a standard default, we set the $taxCode to; 2 - Taxable Goods
|
264 |
+
// To change this, create a new tax code in Volo under "Value Added Tax" and and with a pipe and the required code, i.e. "Shipping|4".
|
265 |
+
|
266 |
+
if (stripos($taxCode, "|"))
|
267 |
+
{
|
268 |
+
list($strIgnore, $strNumber) = array_pad(explode("|", $taxCode, 2), 2, "2");
|
269 |
+
$retVal = intval($strNumber);
|
270 |
+
}
|
271 |
+
else
|
272 |
+
{
|
273 |
+
switch ($taxCode)
|
274 |
+
{
|
275 |
+
case "E":
|
276 |
+
$retVal = 0;
|
277 |
+
break;
|
278 |
+
|
279 |
+
case "Z":
|
280 |
+
$retVal = 7;
|
281 |
+
break;
|
282 |
+
|
283 |
+
case "S":
|
284 |
+
$retVal = 5;
|
285 |
+
break;
|
286 |
+
|
287 |
+
default:
|
288 |
+
$retVal = 2;
|
289 |
+
}
|
290 |
+
}
|
291 |
+
return $retVal;
|
292 |
+
}
|
293 |
+
|
294 |
+
public function _debug($message)
|
295 |
+
{
|
296 |
+
Mage::log($message);
|
297 |
+
}
|
298 |
+
}
|
app/code/local/Sandbourne/BulkApi/Model/PartialProduct/Api.php
CHANGED
@@ -1,77 +1,77 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Sandbourne_BulkApi_Model_PartialProduct_Api extends Mage_Api_Model_Resource_Abstract
|
4 |
-
{
|
5 |
-
public function __construct()
|
6 |
-
{
|
7 |
-
//$this->_debug('PartialProduct constructed');
|
8 |
-
}
|
9 |
-
|
10 |
-
public function update($productXML)
|
11 |
-
{
|
12 |
-
$resultXMLData = new DOMDocument();
|
13 |
-
$productResultsXMLData = $resultXMLData->createElement('ProductResults');
|
14 |
-
$resultXMLData->appendChild($productResultsXMLData);
|
15 |
-
|
16 |
-
$productXMLData = simplexml_load_string($productXML);
|
17 |
-
|
18 |
-
foreach ($productXMLData as $productData)
|
19 |
-
{
|
20 |
-
$productResultXMLData = new DOMElement('ProductResult');
|
21 |
-
$productResultsXMLData->appendChild($productResultXMLData);
|
22 |
-
$this->updateProduct($productData, $productResultXMLData);
|
23 |
-
}
|
24 |
-
}
|
25 |
-
|
26 |
-
private function updateProduct($productData, $productResultXMLData)
|
27 |
-
{
|
28 |
-
$productID = Mage::getModel('catalog/product')->getIdBySku($productData->StockNumber);
|
29 |
-
if ($productID > 0)
|
30 |
-
{
|
31 |
-
$product = Mage::getModel('catalog/product')->load($productID);
|
32 |
-
|
33 |
-
$active = ((string)$productData->IsActive === 'Y' ?
|
34 |
-
Mage_Catalog_Model_Product_Status::STATUS_ENABLED :
|
35 |
-
Mage_Catalog_Model_Product_Status::STATUS_DISABLED);
|
36 |
-
|
37 |
-
$product->setStatus($active);
|
38 |
-
$product->setPrice($productData->Price);
|
39 |
-
|
40 |
-
// Include sales price info
|
41 |
-
// 20150730 - Currently on a partial update, only SalePrice is sent via the XML if the OnSale flag is set
|
42 |
-
if ((string)$productData->SalePrice > '0')
|
43 |
-
{
|
44 |
-
$product->setSpecialPrice($productData->SalePrice);
|
45 |
-
}
|
46 |
-
else
|
47 |
-
{
|
48 |
-
$product->setSpecialPrice('');
|
49 |
-
$product->setSpecialFromDate('');
|
50 |
-
$product->setSpecialToDate('');
|
51 |
-
}
|
52 |
-
|
53 |
-
$stockData = array();
|
54 |
-
$stockData['qty'] = $productData->StockLevel;
|
55 |
-
// Set the 'is_in_stock' to true incase this is a master,
|
56 |
-
// if it is a subsku and the StockLevel is 0, this will automatically get set to false anyhow.
|
57 |
-
//$inStock = ($productData->StockLevel > 0 ? 1 : 0);
|
58 |
-
//$stockData['is_in_stock'] = $inStock;
|
59 |
-
$stockData['is_in_stock'] = 1;
|
60 |
-
|
61 |
-
$product->setStockData($stockData);
|
62 |
-
$product->save();
|
63 |
-
|
64 |
-
// After we have saved all the details, lets check to see if we need to update variation scale prices.
|
65 |
-
if (strcmp($productData->ScalePricing,'Y') == 0)
|
66 |
-
{
|
67 |
-
|
68 |
-
|
69 |
-
}
|
70 |
-
}
|
71 |
-
}
|
72 |
-
|
73 |
-
public function _debug($message)
|
74 |
-
{
|
75 |
-
Mage::log($message);
|
76 |
-
}
|
77 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Sandbourne_BulkApi_Model_PartialProduct_Api extends Mage_Api_Model_Resource_Abstract
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
//$this->_debug('PartialProduct constructed');
|
8 |
+
}
|
9 |
+
|
10 |
+
public function update($productXML)
|
11 |
+
{
|
12 |
+
$resultXMLData = new DOMDocument();
|
13 |
+
$productResultsXMLData = $resultXMLData->createElement('ProductResults');
|
14 |
+
$resultXMLData->appendChild($productResultsXMLData);
|
15 |
+
|
16 |
+
$productXMLData = simplexml_load_string($productXML);
|
17 |
+
|
18 |
+
foreach ($productXMLData as $productData)
|
19 |
+
{
|
20 |
+
$productResultXMLData = new DOMElement('ProductResult');
|
21 |
+
$productResultsXMLData->appendChild($productResultXMLData);
|
22 |
+
$this->updateProduct($productData, $productResultXMLData);
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
private function updateProduct($productData, $productResultXMLData)
|
27 |
+
{
|
28 |
+
$productID = Mage::getModel('catalog/product')->getIdBySku($productData->StockNumber);
|
29 |
+
if ($productID > 0)
|
30 |
+
{
|
31 |
+
$product = Mage::getModel('catalog/product')->load($productID);
|
32 |
+
|
33 |
+
$active = ((string)$productData->IsActive === 'Y' ?
|
34 |
+
Mage_Catalog_Model_Product_Status::STATUS_ENABLED :
|
35 |
+
Mage_Catalog_Model_Product_Status::STATUS_DISABLED);
|
36 |
+
|
37 |
+
$product->setStatus($active);
|
38 |
+
$product->setPrice($productData->Price);
|
39 |
+
|
40 |
+
// Include sales price info
|
41 |
+
// 20150730 - Currently on a partial update, only SalePrice is sent via the XML if the OnSale flag is set
|
42 |
+
if ((string)$productData->SalePrice > '0')
|
43 |
+
{
|
44 |
+
$product->setSpecialPrice($productData->SalePrice);
|
45 |
+
}
|
46 |
+
else
|
47 |
+
{
|
48 |
+
$product->setSpecialPrice('');
|
49 |
+
$product->setSpecialFromDate('');
|
50 |
+
$product->setSpecialToDate('');
|
51 |
+
}
|
52 |
+
|
53 |
+
$stockData = array();
|
54 |
+
$stockData['qty'] = $productData->StockLevel;
|
55 |
+
// Set the 'is_in_stock' to true incase this is a master,
|
56 |
+
// if it is a subsku and the StockLevel is 0, this will automatically get set to false anyhow.
|
57 |
+
//$inStock = ($productData->StockLevel > 0 ? 1 : 0);
|
58 |
+
//$stockData['is_in_stock'] = $inStock;
|
59 |
+
$stockData['is_in_stock'] = 1;
|
60 |
+
|
61 |
+
$product->setStockData($stockData);
|
62 |
+
$product->save();
|
63 |
+
|
64 |
+
// After we have saved all the details, lets check to see if we need to update variation scale prices.
|
65 |
+
if (strcmp($productData->ScalePricing,'Y') == 0)
|
66 |
+
{
|
67 |
+
$pricesHelper = Mage::helper('bulkapi/prices');
|
68 |
+
$pricesHelper->scalePrices($product);
|
69 |
+
}
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
public function _debug($message)
|
74 |
+
{
|
75 |
+
Mage::log($message);
|
76 |
+
}
|
77 |
+
}
|
package.xml
CHANGED
@@ -1,27 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>eSellerProPlugin</name>
|
4 |
-
<version>1.1.2.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>
|
10 |
-
<description
|
11 |
-
|
12 |
-
<ul>
|
13 |
-
<li>Simple and configurable product creation</li>
|
14 |
-
<li>Manage your stock and product information in one central application</li>
|
15 |
-
<li>Automated stock sync between channels</li>
|
16 |
-
<li>Efficent order management using Volo</li>
|
17 |
-
</ul>
|
18 |
-
<p>The plugin is free to download, however, there is a small fee required to link this to your <b>Volo</b> account. Please contact your <b>Volo</b> account manager for more details.</p>
|
19 |
-
<p>For more information about how <a href="http://www.volocommerce.com/">Volo</a> and Magento can help you and your business achieve its full potential, please contact <a href="mailto:sales_uk@volocommerce.com">sales_uk@volocommerce.com</a> or visit <a href="http://www.volocommerce.com/">www.volocommerce.com</a></p></description>
|
20 |
-
<notes>If you wish to integrate Magento with Volo, then please contact your account manager at Volo.</notes>
|
21 |
<authors><author><name>Volo</name><user>Volo</user><email>magento@volocommerce.com</email></author></authors>
|
22 |
-
<date>2016-03-
|
23 |
-
<time>
|
24 |
-
<contents><target name="mage"><dir name="."><dir name="app"><dir name="code"><dir name="local"><dir name="Sandbourne"><dir name="BulkApi"><dir name="Helper"><file name="Array.php" hash="0a04d7af6b6d84fed6d1a0097a558abf"/><file name="Attribute.php" hash="b02d50e3f8a69a90e9d44026febfc4bf"/><file name="AttributeCache.php" hash="258e7fd95a78ff62ff121f4a4776a3a8"/><file name="AttributeOptionCache.php" hash="be30b904d71df0f46f62ed77d6e2fc93"/><file name="Category.php" hash="8d35ba24b7d4d4650d711b61c373cc6e"/><file name="CategoryCache.php" hash="9201e35bd5e461e5483ea9b66b1306d0"/><file name="ConfigurableProduct.php" hash="6127acd0c0d96a864ed6294ef5445ebd"/><file name="Data.php" hash="7aa739540136122fdba1fa12c72a9cad"/><file name="Image.php" hash="f349ee75605adb3afdbd1a15eb823f27"/><file name="Prices.php" hash="a1a1772279a05cd7bdfe981439cac7bd"/><file name="RelatedProducts.php" hash="e927612b277080a5c835d0ceebd8598c"/><file name="Utils.php" hash="29beb209f25ab4a462051be7fa6c681b"/><file name="Website.php" hash="0e67b9ba7cd1bbfe8c840991d0aa3079"/></dir><dir name="Model"><dir name="FullImage"><dir name="Api"><file name="V2.php" hash="d998bacd61159399567d1c46e63507a2"/></dir><file name="Api.php" hash="fcff5388032e5cde7485314c6a1d3bf2"/></dir><dir name="FullProduct"><dir name="Api"><file name="V2.php" hash="3cfb906b7c4c72906e3baccb4fdeee40"/></dir><file name="Api.php" hash="
|
25 |
<compatible/>
|
26 |
-
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min
|
27 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>eSellerProPlugin</name>
|
4 |
+
<version>1.1.2.2</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Summary in here</summary>
|
10 |
+
<description>Description in here</description>
|
11 |
+
<notes>Notes in here</notes>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
<authors><author><name>Volo</name><user>Volo</user><email>magento@volocommerce.com</email></author></authors>
|
13 |
+
<date>2016-03-14</date>
|
14 |
+
<time>21:36:32</time>
|
15 |
+
<contents><target name="mage"><dir name="."><dir name="app"><dir name="code"><dir name="local"><dir name="Sandbourne"><dir name="BulkApi"><dir name="Helper"><file name="Array.php" hash="0a04d7af6b6d84fed6d1a0097a558abf"/><file name="Attribute.php" hash="b02d50e3f8a69a90e9d44026febfc4bf"/><file name="AttributeCache.php" hash="258e7fd95a78ff62ff121f4a4776a3a8"/><file name="AttributeOptionCache.php" hash="be30b904d71df0f46f62ed77d6e2fc93"/><file name="Category.php" hash="8d35ba24b7d4d4650d711b61c373cc6e"/><file name="CategoryCache.php" hash="9201e35bd5e461e5483ea9b66b1306d0"/><file name="ConfigurableProduct.php" hash="6127acd0c0d96a864ed6294ef5445ebd"/><file name="Data.php" hash="7aa739540136122fdba1fa12c72a9cad"/><file name="Image.php" hash="f349ee75605adb3afdbd1a15eb823f27"/><file name="Prices.php" hash="a1a1772279a05cd7bdfe981439cac7bd"/><file name="RelatedProducts.php" hash="e927612b277080a5c835d0ceebd8598c"/><file name="Utils.php" hash="29beb209f25ab4a462051be7fa6c681b"/><file name="Website.php" hash="0e67b9ba7cd1bbfe8c840991d0aa3079"/></dir><dir name="Model"><dir name="FullImage"><dir name="Api"><file name="V2.php" hash="d998bacd61159399567d1c46e63507a2"/></dir><file name="Api.php" hash="fcff5388032e5cde7485314c6a1d3bf2"/></dir><dir name="FullProduct"><dir name="Api"><file name="V2.php" hash="3cfb906b7c4c72906e3baccb4fdeee40"/></dir><file name="Api.php" hash="3f730da57e4e49e572c07d6ef9db3d98"/></dir><dir name="PartialProduct"><dir name="Api"><file name="V2.php" hash="5e9375e74f6ba74bb79f20cce7574ba7"/></dir><file name="Api.php" hash="7c1e68b4dc0c20b2af212c503c53cea7"/></dir></dir><dir name="etc"><file name="api.xml" hash="ee96f5255bb710f934c2dcef8e35cd89"/><file name="config.xml" hash="5ec4835b59d63ec52206204e81903bb7"/><file name="wsdl.xml" hash="9e291f850362a99b265645a978e45b09"/></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Sandbourne_BulkApi.xml" hash="4418f8514205d4d52a309e83d5050c0d"/></dir></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min></min><max></max></package></required></dependencies>
|
18 |
</package>
|