Version Notes
Version 1.1.2
-gestion des attributs
Version 1.1.1
-Fix Bug with XML cdata
Version 1.1.0
-Fix Bug with setHeader
Version 1.0.0
-1st release
Download this release
Release Info
Developer | Magento Core Team |
Extension | Lengow_Export |
Version | 1.1.3 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.1.3
app/code/local/Lengow/Export/controllers/IndexController.php
CHANGED
@@ -1,25 +1,29 @@
|
|
1 |
<?php
|
|
|
2 |
class Lengow_Export_IndexController extends Mage_Core_Controller_Front_Action
|
3 |
{
|
4 |
public function IndexAction()
|
5 |
{
|
6 |
-
|
|
|
|
|
|
|
|
|
7 |
}
|
8 |
|
9 |
protected function GetHeader($content, $format = 'csv', $contentType = 'text/plain', $contentLength = null)
|
10 |
{
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
else
|
16 |
-
|
17 |
$this->getResponse()
|
18 |
->setHttpResponseCode(200)
|
19 |
->setHeader('Pragma', 'public', true)
|
20 |
->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
|
21 |
->setHeader('Content-type', $contentType, true)
|
22 |
-
// ->setHeader('Content-Disposition', 'attachment; filename=test.xml')
|
23 |
->setHeader('Content-Length', strlen($content))
|
24 |
->setBody($content);
|
25 |
}
|
@@ -34,7 +38,6 @@ class Lengow_Export_IndexController extends Mage_Core_Controller_Front_Action
|
|
34 |
Mage::app('default');
|
35 |
try
|
36 |
{
|
37 |
-
//---------------------- GET THE PRODUCTS
|
38 |
$products = Mage::getModel('catalog/product')->getCollection();
|
39 |
// $products
|
40 |
if($storeID != 0)
|
@@ -47,24 +50,48 @@ class Lengow_Export_IndexController extends Mage_Core_Controller_Front_Action
|
|
47 |
$products->addAttributeToSelect('*');
|
48 |
$prodIds=$products->getAllIds();
|
49 |
|
50 |
-
|
51 |
-
|
52 |
$heading = array('ID','WEIGHT','MANUFACTURER','NAME','DESCRIPTION','PRICE','PRICE_PROMO','PROMO_FROM','PROMO_TO','STOCK','QUANTITY','URL','IMAGE','FDP','CATEGORY');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
if( ($contentType =='csv') || ($contentType =='txt'))
|
|
|
54 |
$feed_line=implode("|", $heading)."\r\n";
|
|
|
55 |
elseif($contentType =='xml')
|
|
|
56 |
$feed_line='<?xml version="1.0" encoding="utf-8"?>'.PHP_EOL.'<catalog>'.PHP_EOL;
|
|
|
57 |
else
|
|
|
58 |
exit();
|
|
|
59 |
$buffer = $feed_line;
|
60 |
|
61 |
foreach($prodIds as $productId)
|
62 |
{
|
|
|
63 |
$product->load($productId);
|
64 |
-
|
65 |
$product_data = array();
|
66 |
$product_data['sku']=$product->getSku();
|
67 |
-
$product_data['weight']=$
|
68 |
$product_data['brand']=$product->getResource()->getAttribute('manufacturer')->getFrontend()->getValue($product);
|
69 |
$product_data['title']=$product->getName();
|
70 |
$product_data['description']=$product->getDescription();
|
@@ -77,14 +104,26 @@ class Lengow_Export_IndexController extends Mage_Core_Controller_Front_Action
|
|
77 |
$product_data['link']=$product->getProductUrl();
|
78 |
$product_data['image_link']=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product'.$product->getImage();
|
79 |
$product_data['shipping_rate']='voir site';
|
80 |
-
|
81 |
$product_type = '';
|
82 |
foreach($product->getCategoryIds() as $_categoryId)
|
83 |
{
|
84 |
$category = Mage::getModel('catalog/category')->load($_categoryId);
|
85 |
$product_type .= $category->getName().' > ';
|
86 |
}
|
87 |
-
$product_data['
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
foreach($product_data as $k=>$val)
|
90 |
{
|
@@ -94,23 +133,27 @@ class Lengow_Export_IndexController extends Mage_Core_Controller_Front_Action
|
|
94 |
}
|
95 |
|
96 |
if( ($contentType =='csv') || ($contentType =='txt'))
|
|
|
97 |
$feed_line = implode("|", $product_data)."\r\n";
|
|
|
98 |
elseif($contentType =='xml')
|
99 |
{
|
100 |
$feed_line = '<product> ';
|
101 |
-
|
102 |
-
|
103 |
-
$feed_line .= '<'.$k.'
|
104 |
-
|
105 |
$feed_line .= '</product>'.PHP_EOL;
|
106 |
}
|
107 |
else
|
108 |
-
|
109 |
$buffer .= $feed_line;
|
|
|
|
|
110 |
}
|
111 |
if($contentType == 'xml')
|
112 |
-
|
113 |
-
|
114 |
}
|
115 |
catch(Exception $e)
|
116 |
{
|
1 |
<?php
|
2 |
+
|
3 |
class Lengow_Export_IndexController extends Mage_Core_Controller_Front_Action
|
4 |
{
|
5 |
public function IndexAction()
|
6 |
{
|
7 |
+
if(@!isset($_GET['storeID']))
|
8 |
+
$store= 0;
|
9 |
+
else
|
10 |
+
$store=$_GET['storeID'];
|
11 |
+
$this->GetHeader($this->getContent($_GET['format'],$store),$_GET['format']);
|
12 |
}
|
13 |
|
14 |
protected function GetHeader($content, $format = 'csv', $contentType = 'text/plain', $contentLength = null)
|
15 |
{
|
16 |
+
if( ($format =='csv') || ($format =='txt'))
|
17 |
+
$contentType='text/plain';
|
18 |
+
elseif($format =='xml')
|
19 |
+
$contentType='text/xml';
|
20 |
else
|
21 |
+
exit();
|
22 |
$this->getResponse()
|
23 |
->setHttpResponseCode(200)
|
24 |
->setHeader('Pragma', 'public', true)
|
25 |
->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
|
26 |
->setHeader('Content-type', $contentType, true)
|
|
|
27 |
->setHeader('Content-Length', strlen($content))
|
28 |
->setBody($content);
|
29 |
}
|
38 |
Mage::app('default');
|
39 |
try
|
40 |
{
|
|
|
41 |
$products = Mage::getModel('catalog/product')->getCollection();
|
42 |
// $products
|
43 |
if($storeID != 0)
|
50 |
$products->addAttributeToSelect('*');
|
51 |
$prodIds=$products->getAllIds();
|
52 |
|
53 |
+
//$product = Mage::getModel('catalog/product');
|
|
|
54 |
$heading = array('ID','WEIGHT','MANUFACTURER','NAME','DESCRIPTION','PRICE','PRICE_PROMO','PROMO_FROM','PROMO_TO','STOCK','QUANTITY','URL','IMAGE','FDP','CATEGORY');
|
55 |
+
|
56 |
+
//setEntityTypeFilter(4) => Product Entity
|
57 |
+
$attributesInfo = Mage::getResourceModel('eav/entity_attribute_collection')
|
58 |
+
->setEntityTypeFilter(4)
|
59 |
+
->addSetInfo()
|
60 |
+
->getData();
|
61 |
+
foreach($attributesInfo as $attribute)
|
62 |
+
{
|
63 |
+
$code = $attribute['attribute_code'];
|
64 |
+
$is_user_defined = $attribute['is_user_defined'];
|
65 |
+
if($is_user_defined==1)
|
66 |
+
{
|
67 |
+
if(!in_array('ATT_'.strtoupper($code), $heading))
|
68 |
+
{
|
69 |
+
array_push($heading, 'ATT_'.strtoupper($code));
|
70 |
+
}
|
71 |
+
}
|
72 |
+
}
|
73 |
if( ($contentType =='csv') || ($contentType =='txt'))
|
74 |
+
{
|
75 |
$feed_line=implode("|", $heading)."\r\n";
|
76 |
+
}
|
77 |
elseif($contentType =='xml')
|
78 |
+
{
|
79 |
$feed_line='<?xml version="1.0" encoding="utf-8"?>'.PHP_EOL.'<catalog>'.PHP_EOL;
|
80 |
+
}
|
81 |
else
|
82 |
+
{
|
83 |
exit();
|
84 |
+
}
|
85 |
$buffer = $feed_line;
|
86 |
|
87 |
foreach($prodIds as $productId)
|
88 |
{
|
89 |
+
$product = Mage::getModel('catalog/product');
|
90 |
$product->load($productId);
|
91 |
+
|
92 |
$product_data = array();
|
93 |
$product_data['sku']=$product->getSku();
|
94 |
+
$product_data['weight']=$product->getWeight();
|
95 |
$product_data['brand']=$product->getResource()->getAttribute('manufacturer')->getFrontend()->getValue($product);
|
96 |
$product_data['title']=$product->getName();
|
97 |
$product_data['description']=$product->getDescription();
|
104 |
$product_data['link']=$product->getProductUrl();
|
105 |
$product_data['image_link']=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product'.$product->getImage();
|
106 |
$product_data['shipping_rate']='voir site';
|
107 |
+
//GESTION DE LA CATEGORIE
|
108 |
$product_type = '';
|
109 |
foreach($product->getCategoryIds() as $_categoryId)
|
110 |
{
|
111 |
$category = Mage::getModel('catalog/category')->load($_categoryId);
|
112 |
$product_type .= $category->getName().' > ';
|
113 |
}
|
114 |
+
$product_data['category']=rtrim($product_type,' > ');
|
115 |
+
|
116 |
+
foreach($attributesInfo as $attribute)
|
117 |
+
{
|
118 |
+
$code = $attribute['attribute_code'];
|
119 |
+
$is_user_defined = $attribute['is_user_defined'];
|
120 |
+
$value = $product->getResource()->getAttribute($code)->getFrontend()->getValue($product);
|
121 |
+
if($is_user_defined==1)
|
122 |
+
{
|
123 |
+
// echo "code:".($code)." - value:".$value."\n";
|
124 |
+
$product_data[$code]=$value;
|
125 |
+
}
|
126 |
+
}
|
127 |
|
128 |
foreach($product_data as $k=>$val)
|
129 |
{
|
133 |
}
|
134 |
|
135 |
if( ($contentType =='csv') || ($contentType =='txt'))
|
136 |
+
{
|
137 |
$feed_line = implode("|", $product_data)."\r\n";
|
138 |
+
}
|
139 |
elseif($contentType =='xml')
|
140 |
{
|
141 |
$feed_line = '<product> ';
|
142 |
+
foreach($product_data as $k=>$val)
|
143 |
+
{
|
144 |
+
$feed_line .= '<'.$k.'><![CDATA['.$val.']]></'.$k.'>'.PHP_EOL;
|
145 |
+
}
|
146 |
$feed_line .= '</product>'.PHP_EOL;
|
147 |
}
|
148 |
else
|
149 |
+
exit();
|
150 |
$buffer .= $feed_line;
|
151 |
+
unset($product_data);
|
152 |
+
unset($product);
|
153 |
}
|
154 |
if($contentType == 'xml')
|
155 |
+
$buffer .='</catalog>';
|
156 |
+
return $buffer;
|
157 |
}
|
158 |
catch(Exception $e)
|
159 |
{
|
package.xml
CHANGED
@@ -1,21 +1,31 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Lengow_Export</name>
|
4 |
-
<version>1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>Ce module vous permettra d
|
10 |
-
<description>Lengow est une solution SaaS permettant
|
11 |
|
12 |
-
Le principe est que la solution r
|
13 |
-
Ce processus permet aux e-commer
|
14 |
-
<notes>Version 1.
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
<compatible/>
|
20 |
<dependencies/>
|
21 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Lengow_Export</name>
|
4 |
+
<version>1.1.3</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Ce module vous permettra d&apos;exporter votre catalogue produits au format CSV ou XML &agrave; destination de la solution Lengow afin de diffuser votre catalogue produits vers quelques 120 canaux possible.</summary>
|
10 |
+
<description>Lengow est une solution SaaS permettant &agrave; un e-commer&ccedil;ant d&apos;optimiser ses catalogues produits vers les comparateurs de prix, r&eacute;gies d&apos;affiliation mais aussi marketplaces et sites de Cashback.
|
11 |
|
12 |
+
Le principe est que la solution r&eacute;cup&egrave;re le catalogue produits du marchand, configure, optimise et tracke les informations des campagnes marchandes afin de restituer &agrave; l&apos;e-commer&ccedil;ant les statistiques sous forme de tableaux de bords et graphiques.
|
13 |
+
Ce processus permet aux e-commer&ccedil;ants d&apos;optimiser leurs flux et leurs co&ucirc;ts d&apos;acquisition sur chaque support de diffusion.</description>
|
14 |
+
<notes>Version 1.1.2
|
15 |
+
-gestion des attributs
|
16 |
+
|
17 |
+
Version 1.1.1
|
18 |
+
-Fix Bug with XML cdata
|
19 |
+
|
20 |
+
Version 1.1.0
|
21 |
+
-Fix Bug with setHeader
|
22 |
+
|
23 |
+
Version 1.0.0
|
24 |
+
-1st release</notes>
|
25 |
+
<authors><author><name>Lengow</name><user>auto-converted</user><email>technique@lengow.com</email></author></authors>
|
26 |
+
<date>2010-08-25</date>
|
27 |
+
<time>17:04:00</time>
|
28 |
+
<contents><target name="magelocale"><dir name="en_US"><file name="Lengow_Export.csv" hash="abeaea80f731b4fa350091e0807cdbee"/><file name="Lengow_Information.csv" hash="86986a0717caed093e4178acf407f26c"/></dir><dir name="fr_FR"><file name="Lengow_Export.csv" hash="0bc75b767e6a51b07748f2362ff3f6f2"/><file name="Lengow_Information.csv" hash="cab993c6e862f67cef4a05229cbb2026"/></dir></target><target name="magelocal"><dir name="Lengow"><dir name="Export"><dir name="controllers"><file name="IndexController.php" hash="75e34a60107d73e985842bd7d50556af"/></dir><dir name="etc"><file name="config.xml" hash="8210a1ad7fd08092b95a55de0498092c"/><file name="system.xml" hash="da7eb0bc7e16b26bae938a79fe4f5e05"/></dir><dir name="Helper"><file name="Data.php" hash="9bb8759af094885106efb1a53fe98b07"/></dir></dir><dir name="Information"><dir name="etc"><file name="config.xml" hash="c83d19a3acd4186b7b2ea4f92abc8104"/><file name="system.xml" hash="e16fa28f8249be84adf447c099adeb95"/></dir><dir name="Helper"><file name="Data.php" hash="8063a9cfe2cf944b1d1a6ac65a6b57d0"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Lengow_All.xml" hash="d212244e63e3d5dd55d33981a9d725bf"/></dir></target></contents>
|
29 |
<compatible/>
|
30 |
<dependencies/>
|
31 |
</package>
|