Version Notes
If you wish to integrate Magento with eSellerPro, then please contact your account manager at eSellelrPro.
Download this release
Release Info
Developer | eSellerPro |
Extension | eSellerProPlugin |
Version | 1.1.0.1 |
Comparing to | |
See all releases |
Code changes from version 1.1.0.0 to 1.1.0.1
app/code/local/Sandbourne/BulkApi/Helper/Attribute.php
CHANGED
@@ -50,9 +50,7 @@ class Sandbourne_BulkApi_Helper_Attribute extends Mage_Core_Helper_Abstract
|
|
50 |
{
|
51 |
foreach ($productData->CustomGroups->CustomGroup as $customGroup)
|
52 |
{
|
53 |
-
//
|
54 |
-
// What Customfield Groups do we want to use, or all of them if field is blank?
|
55 |
-
// (JC) - Change this approach, if blank use the default "Magento" group.
|
56 |
if ($this->canProcessCustomFieldGroup($productData->UseCustomGroups, $customGroup['groupName']))
|
57 |
{
|
58 |
$this->setCustomFieldValues($magentoProduct, $customGroup, $attributeCache);
|
@@ -74,8 +72,8 @@ class Sandbourne_BulkApi_Helper_Attribute extends Mage_Core_Helper_Abstract
|
|
74 |
// Check the custom field name about to be added is valid
|
75 |
if ($productUtils->isCustomFieldValid($nameValueList->Name) === true)
|
76 |
{
|
77 |
-
$replacedChars = $productUtils->replaceInvalidChars($nameValueList->Name);
|
78 |
-
$this->setCustomFieldValue($magentoProduct, $replacedChars, $nameValueList->Value, $attributeCache);
|
79 |
}
|
80 |
}
|
81 |
}
|
@@ -87,12 +85,12 @@ class Sandbourne_BulkApi_Helper_Attribute extends Mage_Core_Helper_Abstract
|
|
87 |
$FieldsToUse = trim((string)$customFieldGroupToUse);
|
88 |
$FieldGroupName = trim((string)$customFieldGroupName);
|
89 |
|
90 |
-
//
|
91 |
if (empty($FieldsToUse))
|
92 |
{
|
93 |
$FieldsToUse = "Magento";
|
94 |
}
|
95 |
-
|
96 |
//if ((strpos((string)$customFieldGroupToUse, (string)$customFieldGroupName) !== false) || strlen(trim($customFieldGroupToUse)) === 0)
|
97 |
if (strpos($FieldsToUse, $FieldGroupName) !== false)
|
98 |
{
|
@@ -102,39 +100,60 @@ class Sandbourne_BulkApi_Helper_Attribute extends Mage_Core_Helper_Abstract
|
|
102 |
}
|
103 |
|
104 |
private function setCustomFieldValue($magentoProduct, $attributeName, $attributeValue, $attributeCache)
|
105 |
-
{
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
108 |
{
|
109 |
-
|
110 |
-
$
|
111 |
}
|
112 |
-
|
113 |
-
//in sets if the customer has organised it differently
|
114 |
if ($attribute->isInSet($magentoProduct->getAttributeSetId()))
|
115 |
{
|
|
|
116 |
$this->getDefaultAttributeGroupId($magentoProduct->getAttributeSetId());
|
117 |
if (!is_null($attribute))
|
118 |
{
|
119 |
-
|
120 |
-
{
|
121 |
-
$attributeOption = $attributeCache->getAttributeOption($attributeName, $attributeValue);
|
122 |
-
//$attributeValueId = $this->findAttributeValueId($attributeValue, $attribute->getSource()->getAllOptions());
|
123 |
-
//$this->_debug('attribute value id:'.$attributeValueId);
|
124 |
-
if (is_null($attributeOption))
|
125 |
-
{
|
126 |
-
$attributeOption = $this->addAttributeOption($attributeValue, $attribute, $attributeCache);
|
127 |
-
}
|
128 |
-
//$this->_debug('setting attribute: '.$attribute->getAttributeCode().' to: '.$attributeOption['value']);
|
129 |
-
//$this->_debug('previous attribute value: '.$attribute->getAttributeCode().' to: '.$magentoProduct->getData($attribute->getAttributeCode()));
|
130 |
-
|
131 |
-
$magentoProduct->setData($attribute->getAttributeCode(), $attributeOption['value']);
|
132 |
-
}
|
133 |
-
else
|
134 |
{
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
}
|
137 |
-
//$this->_debug($attribute->getFrontendLabel().':'.$attribute->getBackendType());
|
138 |
}
|
139 |
}
|
140 |
}
|
@@ -147,8 +166,6 @@ class Sandbourne_BulkApi_Helper_Attribute extends Mage_Core_Helper_Abstract
|
|
147 |
|
148 |
$attributeCode = strtolower($attributeName);
|
149 |
//$attributeCode = str_replace(' ', '_', $attributeCode);
|
150 |
-
//$this->_debug($attributeCode);
|
151 |
-
//$this->_debug($attributeName);
|
152 |
|
153 |
$data['attribute_code'] = $attributeCode;
|
154 |
$data['frontend_label'] = array($attributeName, '','','','');
|
@@ -165,12 +182,10 @@ class Sandbourne_BulkApi_Helper_Attribute extends Mage_Core_Helper_Abstract
|
|
165 |
$defaultGroupId = $this->getDefaultAttributeGroupId($attributeSetId);
|
166 |
$attribute->setAttributeGroupId($defaultGroupId);
|
167 |
|
168 |
-
//$this->_debug('going to create attribute with set id: '.$attribute->getAttributeSetId().' and group id: '.$attribute->getAttributeGroupId());
|
169 |
$entityTypeID = Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId();
|
170 |
$attribute->setEntityTypeId($entityTypeID);
|
171 |
$attribute->setIsUserDefined(1);
|
172 |
-
$attribute->save();
|
173 |
-
//$this->_debug('created attribute with id'.$attribute->getId());
|
174 |
return $attribute;
|
175 |
}
|
176 |
|
@@ -219,7 +234,55 @@ class Sandbourne_BulkApi_Helper_Attribute extends Mage_Core_Helper_Abstract
|
|
219 |
|
220 |
return $attributeOption;
|
221 |
}
|
222 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
public function _debug($message)
|
224 |
{
|
225 |
Mage::log($message);
|
50 |
{
|
51 |
foreach ($productData->CustomGroups->CustomGroup as $customGroup)
|
52 |
{
|
53 |
+
// What Customfield Groups do we want to use, if field is blank then use the default "Magento" group.
|
|
|
|
|
54 |
if ($this->canProcessCustomFieldGroup($productData->UseCustomGroups, $customGroup['groupName']))
|
55 |
{
|
56 |
$this->setCustomFieldValues($magentoProduct, $customGroup, $attributeCache);
|
72 |
// Check the custom field name about to be added is valid
|
73 |
if ($productUtils->isCustomFieldValid($nameValueList->Name) === true)
|
74 |
{
|
75 |
+
$replacedChars = $productUtils->replaceInvalidChars($nameValueList->Name);
|
76 |
+
$this->setCustomFieldValue($magentoProduct, $replacedChars, (string)$nameValueList->Value, $attributeCache);
|
77 |
}
|
78 |
}
|
79 |
}
|
85 |
$FieldsToUse = trim((string)$customFieldGroupToUse);
|
86 |
$FieldGroupName = trim((string)$customFieldGroupName);
|
87 |
|
88 |
+
// If blank use the default "Magento" group if it exists.
|
89 |
if (empty($FieldsToUse))
|
90 |
{
|
91 |
$FieldsToUse = "Magento";
|
92 |
}
|
93 |
+
|
94 |
//if ((strpos((string)$customFieldGroupToUse, (string)$customFieldGroupName) !== false) || strlen(trim($customFieldGroupToUse)) === 0)
|
95 |
if (strpos($FieldsToUse, $FieldGroupName) !== false)
|
96 |
{
|
100 |
}
|
101 |
|
102 |
private function setCustomFieldValue($magentoProduct, $attributeName, $attributeValue, $attributeCache)
|
103 |
+
{
|
104 |
+
// Get the attribute collection
|
105 |
+
$attribute = $magentoProduct->getResource()->getAttribute($attributeName);
|
106 |
+
|
107 |
+
// Does the attribute exist?
|
108 |
+
if (empty($attribute))
|
109 |
{
|
110 |
+
// Create new attribute
|
111 |
+
$attribute = $this->createAttribute($attributeName, $magentoProduct->getAttributeSetId()); // TODO: Optimise the createAttribute method
|
112 |
}
|
113 |
+
|
114 |
+
// We are not going to mess about with putting attributes in sets if the customer has organised it differently
|
115 |
if ($attribute->isInSet($magentoProduct->getAttributeSetId()))
|
116 |
{
|
117 |
+
|
118 |
$this->getDefaultAttributeGroupId($magentoProduct->getAttributeSetId());
|
119 |
if (!is_null($attribute))
|
120 |
{
|
121 |
+
switch ($attribute->getFrontendInput())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
{
|
123 |
+
case "select":
|
124 |
+
$this->setOrAddOptionAttribute($magentoProduct, $attributeName, $attributeValue);
|
125 |
+
break;
|
126 |
+
|
127 |
+
case "date":
|
128 |
+
// Dates need to be in the format of dd/mm/yyyy
|
129 |
+
$dateField = trim(str_replace("-", "/", str_replace(".", "/", $attributeValue)));
|
130 |
+
$findLast = strrpos($dateField, "/");
|
131 |
+
$dateDayMonth = substr($dateField, 0, $findLast);
|
132 |
+
$dateYear = substr($dateField, $findLast + 1);
|
133 |
+
|
134 |
+
if (strlen($dateYear) < 4)
|
135 |
+
{
|
136 |
+
// This means we need to prefix the year with the century
|
137 |
+
$dateField = $dateDayMonth . "/20" . $dateYear;
|
138 |
+
}
|
139 |
+
$magentoProduct->setData($attributeName, $dateField);
|
140 |
+
break;
|
141 |
+
|
142 |
+
case "boolean":
|
143 |
+
$booleanValue = false;
|
144 |
+
$testString = trim(strtolower($attributeValue));
|
145 |
+
if ($testString == "y" or $testString == "yes" or $testString == "on" or $testString == "true")
|
146 |
+
{
|
147 |
+
$booleanValue = true;
|
148 |
+
}
|
149 |
+
$magentoProduct->setData($attributeName, $booleanValue);
|
150 |
+
break;
|
151 |
+
|
152 |
+
// For "text" and "textarea"
|
153 |
+
default:
|
154 |
+
$magentoProduct->setData($attributeName, $attributeValue);
|
155 |
+
break;
|
156 |
}
|
|
|
157 |
}
|
158 |
}
|
159 |
}
|
166 |
|
167 |
$attributeCode = strtolower($attributeName);
|
168 |
//$attributeCode = str_replace(' ', '_', $attributeCode);
|
|
|
|
|
169 |
|
170 |
$data['attribute_code'] = $attributeCode;
|
171 |
$data['frontend_label'] = array($attributeName, '','','','');
|
182 |
$defaultGroupId = $this->getDefaultAttributeGroupId($attributeSetId);
|
183 |
$attribute->setAttributeGroupId($defaultGroupId);
|
184 |
|
|
|
185 |
$entityTypeID = Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId();
|
186 |
$attribute->setEntityTypeId($entityTypeID);
|
187 |
$attribute->setIsUserDefined(1);
|
188 |
+
$attribute->save();
|
|
|
189 |
return $attribute;
|
190 |
}
|
191 |
|
234 |
|
235 |
return $attributeOption;
|
236 |
}
|
237 |
+
|
238 |
+
private function setOrAddOptionAttribute($product, $argAttribute, $argValue)
|
239 |
+
{
|
240 |
+
// If we have added a new attribute, or are adding a new option, then we will need to reload the collections and retrieve the new option
|
241 |
+
$reload = true;
|
242 |
+
$valueExists = false;
|
243 |
+
|
244 |
+
while ($reload)
|
245 |
+
{
|
246 |
+
$attributeModel = Mage::getModel('eav/entity_attribute');
|
247 |
+
$attributeOptionsModel = Mage::getModel('eav/entity_attribute_source_table');
|
248 |
+
|
249 |
+
$attributeCode = $attributeModel->getIdByCode('catalog_product', $argAttribute);
|
250 |
+
$attribute = $attributeModel->load($attributeCode);
|
251 |
+
|
252 |
+
$attributeOptionsModel->setAttribute($attribute);
|
253 |
+
$options = $attributeOptionsModel->getAllOptions(false);
|
254 |
+
|
255 |
+
$reload = false;
|
256 |
+
|
257 |
+
foreach($options as $option)
|
258 |
+
{
|
259 |
+
if ($option['label'] == $argValue)
|
260 |
+
{
|
261 |
+
$valueExists = true;
|
262 |
+
break;
|
263 |
+
}
|
264 |
+
}
|
265 |
+
|
266 |
+
// If this option does not exist, add it
|
267 |
+
if (!$valueExists)
|
268 |
+
{
|
269 |
+
$attribute->setData('option', array(
|
270 |
+
'value' => array(
|
271 |
+
'option' => array($argValue),
|
272 |
+
)
|
273 |
+
));
|
274 |
+
$attribute->save();
|
275 |
+
$valueExists = true;
|
276 |
+
$reload = true;
|
277 |
+
}
|
278 |
+
}
|
279 |
+
|
280 |
+
if (!empty($option))
|
281 |
+
{
|
282 |
+
$product->setData($attribute['attribute_code'], $option['value']);
|
283 |
+
}
|
284 |
+
}
|
285 |
+
|
286 |
public function _debug($message)
|
287 |
{
|
288 |
Mage::log($message);
|
app/code/local/Sandbourne/BulkApi/Model/FullProduct/Api.php
CHANGED
@@ -9,9 +9,10 @@ class Sandbourne_BulkApi_Model_FullProduct_Api extends Mage_Api_Model_Resource_A
|
|
9 |
|
10 |
public function version()
|
11 |
{
|
12 |
-
//return "1.0.0.6";
|
13 |
-
//return "1.0.0.7";
|
14 |
-
return "1.1.0.0";
|
|
|
15 |
}
|
16 |
|
17 |
public function update($productXML)
|
@@ -156,6 +157,11 @@ class Sandbourne_BulkApi_Model_FullProduct_Api extends Mage_Api_Model_Resource_A
|
|
156 |
// Include the RRP price
|
157 |
$magentoProduct->setMsrp($productData->RRP);
|
158 |
|
|
|
|
|
|
|
|
|
|
|
159 |
// Include sales price info
|
160 |
if (((string)$productData->OnSale === 'Y') && ((string)$productData->SalePrice > '0'))
|
161 |
{
|
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 |
}
|
17 |
|
18 |
public function update($productXML)
|
157 |
// Include the RRP price
|
158 |
$magentoProduct->setMsrp($productData->RRP);
|
159 |
|
160 |
+
// Include the UPC (barcode)
|
161 |
+
// Make sure the customer has an attribute with the Attribute Code of "upc" or "barcode"
|
162 |
+
$magentoProduct->setData("upc", $productData->UPC);
|
163 |
+
$magentoProduct->setData("barcode", $productData->UPC);
|
164 |
+
|
165 |
// Include sales price info
|
166 |
if (((string)$productData->OnSale === 'Y') && ((string)$productData->SalePrice > '0'))
|
167 |
{
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>eSellerProPlugin</name>
|
4 |
-
<version>1.1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
|
7 |
<channel>community</channel>
|
@@ -17,11 +17,11 @@
|
|
17 |
</ul>
|
18 |
<p>The plugin is free to download, however, there is a small fee required to link this to your <b>eSellerPro</b> account. Please contact your <b>eSellerPro</b> account manager for more details.</p>
|
19 |
<p>For more information about how <a href="http://www.esellerpro.com">eSellerPro</a> and Magento can help you and your business achieve its full potential, please contact <a href="mailto:sales_uk@esellerpro.com">sales_uk@esellerpro.com</a> or visit <a href="http://www.esellerpro.com">www.esellerpro.com</a></p></description>
|
20 |
-
<notes>
|
21 |
<authors><author><name>eSellerPro</name><user>eSellerPro</user><email>magento@esellerpro.com</email></author></authors>
|
22 |
-
<date>2014-
|
23 |
-
<time>10:
|
24 |
-
<contents><target name="magelocal"><dir name="Sandbourne"><dir name="BulkApi"><dir name="Helper"><file name="Array.php" hash="0a04d7af6b6d84fed6d1a0097a558abf"/><file name="Attribute.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>
|
27 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>eSellerProPlugin</name>
|
4 |
+
<version>1.1.0.1</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
|
7 |
<channel>community</channel>
|
17 |
</ul>
|
18 |
<p>The plugin is free to download, however, there is a small fee required to link this to your <b>eSellerPro</b> account. Please contact your <b>eSellerPro</b> account manager for more details.</p>
|
19 |
<p>For more information about how <a href="http://www.esellerpro.com">eSellerPro</a> and Magento can help you and your business achieve its full potential, please contact <a href="mailto:sales_uk@esellerpro.com">sales_uk@esellerpro.com</a> or visit <a href="http://www.esellerpro.com">www.esellerpro.com</a></p></description>
|
20 |
+
<notes>If you wish to integrate Magento with eSellerPro, then please contact your account manager at eSellelrPro.</notes>
|
21 |
<authors><author><name>eSellerPro</name><user>eSellerPro</user><email>magento@esellerpro.com</email></author></authors>
|
22 |
+
<date>2014-11-24</date>
|
23 |
+
<time>10:04:09</time>
|
24 |
+
<contents><target name="magelocal"><dir name="Sandbourne"><dir name="BulkApi"><dir name="Helper"><file name="Array.php" hash="0a04d7af6b6d84fed6d1a0097a558abf"/><file name="Attribute.php" hash="b237bb93ad98ccceb66992670474ba33"/><file name="AttributeCache.php" hash="258e7fd95a78ff62ff121f4a4776a3a8"/><file name="AttributeOptionCache.php" hash="be30b904d71df0f46f62ed77d6e2fc93"/><file name="Category.php" hash="7d4a391c9c748255ce639f836f3a00b4"/><file name="CategoryCache.php" hash="9201e35bd5e461e5483ea9b66b1306d0"/><file name="ConfigurableProduct.php" hash="6127acd0c0d96a864ed6294ef5445ebd"/><file name="Data.php" hash="7aa739540136122fdba1fa12c72a9cad"/><file name="Image.php" hash="1753b2b15ed4e7c4930c1603c44711e2"/><file name="RelatedProducts.php" hash="e927612b277080a5c835d0ceebd8598c"/><file name="TestData.php" hash="aa72f88ab2ee8cf218e43f59a846da56"/><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="91aaffd435b8c7406fc0f95f4b808617"/></dir><dir name="PartialProduct"><dir name="Api"><file name="V2.php" hash="5e9375e74f6ba74bb79f20cce7574ba7"/></dir><file name="Api.php" hash="e0a2cff6023e16755bca2fc56630a316"/></dir><file name="testatts.php" hash="c519db8a12356abfc81a84148809291a"/></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></target><target name="mageetc"><dir name="modules"><file name="Sandbourne_BulkApi.xml" hash="4418f8514205d4d52a309e83d5050c0d"/></dir></target></contents>
|
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/><max/></package></required></dependencies>
|
27 |
</package>
|