Version Notes
- Original release
Download this release
Release Info
| Developer | Digital Pianism |
| Extension | DigitalPianism_ProductExport |
| Version | 1.1.0 |
| Comparing to | |
| See all releases | |
Version 1.1.0
- app/code/community/DigitalPianism/ProductExport/Model/Observer.php +18 -0
- app/code/community/DigitalPianism/ProductExport/Test/Config/Main.php +24 -0
- app/code/community/DigitalPianism/ProductExport/controllers/Adminhtml/IndexController.php +34 -0
- app/code/community/DigitalPianism/ProductExport/etc/config.xml +47 -0
- app/etc/modules/DigitalPianism_ProductExport.xml +12 -0
- package.xml +34 -0
app/code/community/DigitalPianism/ProductExport/Model/Observer.php
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class DigitalPianism_ProductExport_Model_Observer
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* Add a new massaction to export products to CSV
|
| 7 |
+
* @param Varien_Event_Observer $observer
|
| 8 |
+
*/
|
| 9 |
+
public function addMassExport(Varien_Event_Observer $observer)
|
| 10 |
+
{
|
| 11 |
+
$block = $observer->getEvent()->getBlock();
|
| 12 |
+
|
| 13 |
+
$block->getMassactionBlock()->addItem('productexport', array(
|
| 14 |
+
'label' => 'Export to CSV',
|
| 15 |
+
'url' => $block->getUrl('productexport/adminhtml_index/massExport')
|
| 16 |
+
));
|
| 17 |
+
}
|
| 18 |
+
}
|
app/code/community/DigitalPianism/ProductExport/Test/Config/Main.php
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Created by PhpStorm.
|
| 4 |
+
* User: Raph
|
| 5 |
+
* Date: 28/11/2014
|
| 6 |
+
* Time: 11:10
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
class DigitalPianism_ProductExport_Test_Config_Main extends EcomDev_PHPUnit_Test_Case_Config
|
| 10 |
+
{
|
| 11 |
+
public function testModuleVersion()
|
| 12 |
+
{
|
| 13 |
+
// Testing configuration
|
| 14 |
+
$this->assertModuleCodePool('local');
|
| 15 |
+
$this->assertModuleVersion("1.1.0");
|
| 16 |
+
$this->assertModuleDepends('Mage_Adminhtml');
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
public function testClassAliasDefinitions()
|
| 20 |
+
{
|
| 21 |
+
// Models
|
| 22 |
+
$this->assertModelAlias('productexport/observer','DigitalPianism_ProductExport_Model_Observer');
|
| 23 |
+
}
|
| 24 |
+
}
|
app/code/community/DigitalPianism/ProductExport/controllers/Adminhtml/IndexController.php
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Class DigitalPianism_ProductExport_Adminhtml_IndexController
|
| 4 |
+
*/
|
| 5 |
+
class DigitalPianism_ProductExport_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
|
| 6 |
+
{
|
| 7 |
+
public function massExportAction()
|
| 8 |
+
{
|
| 9 |
+
$productIds = $this->getRequest()->getParam('product');
|
| 10 |
+
if (!is_array($productIds)) {
|
| 11 |
+
$this->_getSession()->addError($this->__('Please select product(s).'));
|
| 12 |
+
$this->_redirect('adminhtml/catalog_product/index');
|
| 13 |
+
}
|
| 14 |
+
else {
|
| 15 |
+
//write headers to the csv file
|
| 16 |
+
$content = "id,name,url,sku,price,special_price\n";
|
| 17 |
+
try {
|
| 18 |
+
|
| 19 |
+
$collection = Mage::getResourceModel('catalog/product_collection')
|
| 20 |
+
->addFieldToFilter('entity_id', array($productIds))
|
| 21 |
+
->addAttributeToSelect(array('entity_id','name','product_url','sku','price','special_price'));
|
| 22 |
+
|
| 23 |
+
foreach ($collection as $product) {
|
| 24 |
+
$content .= "\"{$product->getId()}\",\"{$product->getName()}\",\"{$product->getProductUrl()}\",\"{$product->getSku()}\",\"{$product->getPrice()}\",\"{$product->getSpecialPrice()}\"\n";
|
| 25 |
+
}
|
| 26 |
+
} catch (Exception $e) {
|
| 27 |
+
$this->_getSession()->addError($e->getMessage());
|
| 28 |
+
$this->_redirect('adminhtml/catalog_product/index');
|
| 29 |
+
}
|
| 30 |
+
$this->_prepareDownloadResponse('export.csv', $content, 'text/csv');
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
}
|
| 34 |
+
}
|
app/code/community/DigitalPianism/ProductExport/etc/config.xml
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<DigitalPianism_ProductExport>
|
| 5 |
+
<version>1.1.0</version>
|
| 6 |
+
</DigitalPianism_ProductExport>
|
| 7 |
+
</modules>
|
| 8 |
+
<global>
|
| 9 |
+
<models>
|
| 10 |
+
<productexport>
|
| 11 |
+
<class>DigitalPianism_ProductExport_Model</class>
|
| 12 |
+
</productexport>
|
| 13 |
+
</models>
|
| 14 |
+
</global>
|
| 15 |
+
<admin>
|
| 16 |
+
<routers>
|
| 17 |
+
<productexport>
|
| 18 |
+
<use>admin</use>
|
| 19 |
+
<args>
|
| 20 |
+
<module>DigitalPianism_ProductExport</module>
|
| 21 |
+
<frontName>productexport</frontName>
|
| 22 |
+
</args>
|
| 23 |
+
</productexport>
|
| 24 |
+
</routers>
|
| 25 |
+
</admin>
|
| 26 |
+
<adminhtml>
|
| 27 |
+
<events>
|
| 28 |
+
<!-- event triggered after the original massaction items are added -->
|
| 29 |
+
<adminhtml_catalog_product_grid_prepare_massaction>
|
| 30 |
+
<observers>
|
| 31 |
+
<digitalpianism_productexport_add>
|
| 32 |
+
<type>singleton</type>
|
| 33 |
+
<class>productexport/observer</class>
|
| 34 |
+
<method>addMassExport</method>
|
| 35 |
+
</digitalpianism_productexport_add>
|
| 36 |
+
</observers>
|
| 37 |
+
</adminhtml_catalog_product_grid_prepare_massaction>
|
| 38 |
+
</events>
|
| 39 |
+
</adminhtml>
|
| 40 |
+
<phpunit>
|
| 41 |
+
<suite>
|
| 42 |
+
<modules>
|
| 43 |
+
<DigitalPianism_ProductExport/>
|
| 44 |
+
</modules>
|
| 45 |
+
</suite>
|
| 46 |
+
</phpunit>
|
| 47 |
+
</config>
|
app/etc/modules/DigitalPianism_ProductExport.xml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<DigitalPianism_ProductExport>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>community</codePool>
|
| 7 |
+
<depends>
|
| 8 |
+
<Mage_Adminhtml/>
|
| 9 |
+
</depends>
|
| 10 |
+
</DigitalPianism_ProductExport>
|
| 11 |
+
</modules>
|
| 12 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>DigitalPianism_ProductExport</name>
|
| 4 |
+
<version>1.1.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>This module adds a new mass action to the Magento admin catalog grid to mass export products to CSV.</summary>
|
| 10 |
+
<description><h2>Description</h2>
|
| 11 |
+

|
| 12 |
+
<p>This module adds a new mass action to the Magento admin catalog grid to let the managers export products to CSV.</p>
|
| 13 |
+
<p>The CSV includes the following product information:</p>
|
| 14 |
+
<ul>
|
| 15 |
+
<li>ID</li>
|
| 16 |
+
<li>Name</li>
|
| 17 |
+
<li>URL</li>
|
| 18 |
+
<li>Sku</li>
|
| 19 |
+
<li>Price</li>
|
| 20 |
+
<li>Special Price</li>
|
| 21 |
+
</ul>
|
| 22 |
+

|
| 23 |
+
<h2>Installation</h2>
|
| 24 |
+

|
| 25 |
+
<p>Install the module manually or via Magento Connect</p>
|
| 26 |
+
<p>Then login to the backend and flush your cache</p></description>
|
| 27 |
+
<notes>- Original release</notes>
|
| 28 |
+
<authors><author><name>Digital Pianism</name><user>digitalpianism</user><email>contact@digital-pianism.com</email></author></authors>
|
| 29 |
+
<date>2015-08-06</date>
|
| 30 |
+
<time>14:46:59</time>
|
| 31 |
+
<contents><target name="magecommunity"><dir name="DigitalPianism"><dir name="ProductExport"><dir name="Model"><file name="Observer.php" hash="60c6150cd05a76d0c6909db9b26dcea1"/></dir><dir name="Test"><dir name="Config"><file name="Main.php" hash="c6319b41e434f96795ffc3111529540d"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="32c08372f0c7d1c822b21fcceae572ef"/></dir></dir><dir name="etc"><file name="config.xml" hash="6cf66c6c887fab8c202293ffb2182eb7"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="DigitalPianism_ProductExport.xml" hash="6cdbc2897d42c0d1d4d682ad613e244f"/></dir></target></contents>
|
| 32 |
+
<compatible/>
|
| 33 |
+
<dependencies><required><php><min>4.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 34 |
+
</package>
|
