Version Notes
* Added support for configurable products
Download this release
Release Info
Developer | Christiaan de Ridder |
Extension | Tritac_ChannelEngine |
Version | 2.3.0 |
Comparing to | |
See all releases |
Code changes from version 2.2.1 to 2.3.0
app/code/community/Tritac/ChannelEngine/Model/Observer.php
CHANGED
@@ -470,6 +470,17 @@ class Tritac_ChannelEngine_Model_Observer
|
|
470 |
}
|
471 |
}
|
472 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
473 |
/**
|
474 |
* Export products from each store.
|
475 |
* Note: products with undefined website id will not be export.
|
@@ -521,7 +532,20 @@ class Tritac_ChannelEngine_Model_Observer
|
|
521 |
$collection->getEntity()->setStoreId($storeId);
|
522 |
}
|
523 |
|
524 |
-
$systemAttributes = $attributesToSelect = array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
525 |
$visibleAttributes = array();
|
526 |
$attributes = Mage::getSingleton('eav/config')
|
527 |
->getEntityType(Mage_Catalog_Model_Product::ENTITY)->getAttributeCollection();
|
@@ -554,9 +578,10 @@ class Tritac_ChannelEngine_Model_Observer
|
|
554 |
}
|
555 |
|
556 |
$collection->addAttributeToSelect($attributesToSelect, 'left')
|
557 |
-
->addFieldToFilter('type_id', 'simple')
|
558 |
->addStoreFilter($_store)
|
559 |
->addAttributeToFilter('status', 1)
|
|
|
560 |
->addAttributeToSort('entity_id', 'DESC');
|
561 |
|
562 |
// Add qty and category fields to select
|
@@ -573,7 +598,6 @@ class Tritac_ChannelEngine_Model_Observer
|
|
573 |
)
|
574 |
->group('e.entity_id');
|
575 |
|
576 |
-
//die();
|
577 |
Mage::getSingleton('core/resource_iterator')->walk(
|
578 |
$collection->getSelect(),
|
579 |
array(array($this, 'callbackGenerateFeed')),
|
@@ -588,6 +612,70 @@ class Tritac_ChannelEngine_Model_Observer
|
|
588 |
)
|
589 |
);
|
590 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
591 |
$io->streamWrite('</Products>');
|
592 |
$io->streamUnlock();
|
593 |
$io->streamClose();
|
@@ -616,6 +704,18 @@ class Tritac_ChannelEngine_Model_Observer
|
|
616 |
$product['gtin'] = $product[$this->_config[$storeId]['feed']['gtin']];
|
617 |
}
|
618 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
619 |
/**
|
620 |
* Add product custom options to feed.
|
621 |
* Each option value will generate new product row
|
@@ -656,6 +756,10 @@ class Tritac_ChannelEngine_Model_Observer
|
|
656 |
if(isset($product['group_code'])) {
|
657 |
$xml .= "<GroupCode><![CDATA[".$product['group_code']."]]></GroupCode>";
|
658 |
}
|
|
|
|
|
|
|
|
|
659 |
$xml .= "<Name><![CDATA[".$product['name']."]]></Name>";
|
660 |
$xml .= "<Description><![CDATA[".$product['description']."]]></Description>";
|
661 |
$xml .= "<Price><![CDATA[".$product['price']."]]></Price>";
|
@@ -682,13 +786,7 @@ class Tritac_ChannelEngine_Model_Observer
|
|
682 |
$xml .= "<ShippingTime><![CDATA[".$shippingTime."]]></ShippingTime>";
|
683 |
}
|
684 |
|
685 |
-
|
686 |
-
$productModel = Mage::getModel('catalog/product');
|
687 |
-
$productModel->setData('entity_id', $product['entity_id']);
|
688 |
-
$productModel->setData('url_key', $product['url_key']);
|
689 |
-
$productModel->setData('store_id', $product['store_id']);
|
690 |
-
$url = $productModel->getProductUrl();
|
691 |
-
$xml .= "<Url><![CDATA[".$url."]]></Url>";
|
692 |
|
693 |
if(isset($product['image']) && $product['image'] != 'no_selection') {
|
694 |
$imgUrl = Mage::getSingleton('catalog/product_media_config')->getMediaUrl($product['image']);
|
@@ -749,6 +847,11 @@ class Tritac_ChannelEngine_Model_Observer
|
|
749 |
return $xml;
|
750 |
}
|
751 |
|
|
|
|
|
|
|
|
|
|
|
752 |
/**
|
753 |
* Join channelengine order fields to adminhtml order grid
|
754 |
*
|
470 |
}
|
471 |
}
|
472 |
|
473 |
+
/**
|
474 |
+
* Prepare products relation
|
475 |
+
*/
|
476 |
+
// $productsRelation = array();
|
477 |
+
// $_resource = Mage::getSingleton('core/resource');
|
478 |
+
// $_connection = $_resource->getConnection('core_read');
|
479 |
+
// $relations = $_connection->fetchAll("SELECT * FROM " . $_resource->getTableName('catalog/product_relation'));
|
480 |
+
// foreach($relations as $relation) {
|
481 |
+
// $productsRelation[$relation['child_id']] = $relation['parent_id'];
|
482 |
+
// }
|
483 |
+
|
484 |
/**
|
485 |
* Export products from each store.
|
486 |
* Note: products with undefined website id will not be export.
|
532 |
$collection->getEntity()->setStoreId($storeId);
|
533 |
}
|
534 |
|
535 |
+
$systemAttributes = $attributesToSelect = array(
|
536 |
+
'name',
|
537 |
+
'description',
|
538 |
+
'image',
|
539 |
+
'url_key',
|
540 |
+
'price',
|
541 |
+
'cost',
|
542 |
+
'special_price',
|
543 |
+
'special_from_date',
|
544 |
+
'special_to_date',
|
545 |
+
'visibility',
|
546 |
+
'msrp'
|
547 |
+
);
|
548 |
+
|
549 |
$visibleAttributes = array();
|
550 |
$attributes = Mage::getSingleton('eav/config')
|
551 |
->getEntityType(Mage_Catalog_Model_Product::ENTITY)->getAttributeCollection();
|
578 |
}
|
579 |
|
580 |
$collection->addAttributeToSelect($attributesToSelect, 'left')
|
581 |
+
->addFieldToFilter('type_id', array('in' => array('simple')))
|
582 |
->addStoreFilter($_store)
|
583 |
->addAttributeToFilter('status', 1)
|
584 |
+
->addAttributeToFilter('visibility', array('in' => array('2', '3', '4')))
|
585 |
->addAttributeToSort('entity_id', 'DESC');
|
586 |
|
587 |
// Add qty and category fields to select
|
598 |
)
|
599 |
->group('e.entity_id');
|
600 |
|
|
|
601 |
Mage::getSingleton('core/resource_iterator')->walk(
|
602 |
$collection->getSelect(),
|
603 |
array(array($this, 'callbackGenerateFeed')),
|
612 |
)
|
613 |
);
|
614 |
|
615 |
+
$collection->clear()->getSelect()->reset('where');
|
616 |
+
$collection->addFieldToFilter('type_id', array('in' => array('configurable')))
|
617 |
+
->addStoreFilter($_store)
|
618 |
+
->addAttributeToFilter('status', 1)
|
619 |
+
->addAttributeToSort('entity_id', 'DESC');
|
620 |
+
|
621 |
+
foreach($collection as $_product) {
|
622 |
+
$productAttributeOptions = $_product->getTypeInstance(true)->getConfigurableAttributesAsArray($_product);
|
623 |
+
$superAttributes = array();
|
624 |
+
|
625 |
+
foreach($productAttributeOptions as $superAttribute) {
|
626 |
+
foreach($superAttribute['values'] as $value) {
|
627 |
+
$superAttributes[$superAttribute['attribute_code']][$value['value_index']] = $value;
|
628 |
+
}
|
629 |
+
}
|
630 |
+
|
631 |
+
$parentData = $_product->getData();
|
632 |
+
$parentData['id'] = $parentData['entity_id'];
|
633 |
+
|
634 |
+
$productModel = Mage::getModel('catalog/product');
|
635 |
+
$productModel->setData('entity_id', $parentData['entity_id']);
|
636 |
+
$productModel->setData('url_key', $parentData['url_key']);
|
637 |
+
$productModel->setData('store_id', $parentData['store_id']);
|
638 |
+
$parentData['url'] = $productModel->getProductUrl();
|
639 |
+
|
640 |
+
$specialPrice = $parentData['special_price'];
|
641 |
+
$specialFrom = $parentData['special_from_date'];
|
642 |
+
$specialTo = $parentData['special_to_date'];
|
643 |
+
$parentData['price'] = Mage::getModel('catalog/product_type_price')
|
644 |
+
->calculateSpecialPrice($parentData['price'], $specialPrice, $specialFrom, $specialTo, $storeId);
|
645 |
+
|
646 |
+
$xml = $this->_getProductXml($parentData, $categoryArray, array('systemAttributes' => $systemAttributes, 'attributes' => $visibleAttributes));
|
647 |
+
$_childProducts = Mage::getModel('catalog/product_type_configurable')
|
648 |
+
->getUsedProducts(null, $_product);
|
649 |
+
|
650 |
+
foreach($_childProducts as $_child) {
|
651 |
+
$childData = $_child->getData();
|
652 |
+
$childData['id'] = $childData['entity_id'];
|
653 |
+
$childData['parent_id'] = $parentData['id'];
|
654 |
+
$childData['price'] = $parentData['price'];
|
655 |
+
$childData['url'] = $parentData['url'];
|
656 |
+
$childData['description'] = $parentData['description'];
|
657 |
+
|
658 |
+
if(!isset($childData['image']) || $childData['image'] == 'no_slection') {
|
659 |
+
$childData['image'] = $parentData['image'];
|
660 |
+
}
|
661 |
+
|
662 |
+
foreach($superAttributes as $code => $superAttribute) {
|
663 |
+
if(isset($childData[$code])) {
|
664 |
+
$priceValue = $superAttribute[$childData[$code]]['pricing_value'];
|
665 |
+
if($superAttribute[$childData[$code]]['is_percent']) {
|
666 |
+
$newPrice = $childData['price'] + $childData['price'] * $priceValue / 100;
|
667 |
+
} else {
|
668 |
+
$newPrice = $childData['price'] + $priceValue;
|
669 |
+
}
|
670 |
+
$childData['price'] = $newPrice;
|
671 |
+
}
|
672 |
+
}
|
673 |
+
$xml .= $this->_getProductXml($childData, $categoryArray, array('systemAttributes' => $systemAttributes, 'attributes' => $visibleAttributes));
|
674 |
+
}
|
675 |
+
$io->streamWrite($xml);
|
676 |
+
}
|
677 |
+
|
678 |
+
|
679 |
$io->streamWrite('</Products>');
|
680 |
$io->streamUnlock();
|
681 |
$io->streamClose();
|
704 |
$product['gtin'] = $product[$this->_config[$storeId]['feed']['gtin']];
|
705 |
}
|
706 |
|
707 |
+
$specialPrice = $product['special_price'];
|
708 |
+
$specialFrom = $product['special_from_date'];
|
709 |
+
$specialTo = $product['special_to_date'];
|
710 |
+
$product['price'] = Mage::getModel('catalog/product_type_price')
|
711 |
+
->calculateSpecialPrice($product['price'], $specialPrice, $specialFrom, $specialTo, $storeId);
|
712 |
+
|
713 |
+
$productModel = Mage::getModel('catalog/product');
|
714 |
+
$productModel->setData('entity_id', $product['entity_id']);
|
715 |
+
$productModel->setData('url_key', $product['url_key']);
|
716 |
+
$productModel->setData('store_id', $product['store_id']);
|
717 |
+
$product['url'] = $productModel->getProductUrl();
|
718 |
+
|
719 |
/**
|
720 |
* Add product custom options to feed.
|
721 |
* Each option value will generate new product row
|
756 |
if(isset($product['group_code'])) {
|
757 |
$xml .= "<GroupCode><![CDATA[".$product['group_code']."]]></GroupCode>";
|
758 |
}
|
759 |
+
if(isset($product['parent_id'])) {
|
760 |
+
$xml .= "<ParentId><![CDATA[".$product['parent_id']."]]></ParentId>";
|
761 |
+
}
|
762 |
+
$xml .= "<Type><![CDATA[".$product['type_id']."]]></Type>";
|
763 |
$xml .= "<Name><![CDATA[".$product['name']."]]></Name>";
|
764 |
$xml .= "<Description><![CDATA[".$product['description']."]]></Description>";
|
765 |
$xml .= "<Price><![CDATA[".$product['price']."]]></Price>";
|
786 |
$xml .= "<ShippingTime><![CDATA[".$shippingTime."]]></ShippingTime>";
|
787 |
}
|
788 |
|
789 |
+
$xml .= "<Url><![CDATA[".$product['url']."]]></Url>";
|
|
|
|
|
|
|
|
|
|
|
|
|
790 |
|
791 |
if(isset($product['image']) && $product['image'] != 'no_selection') {
|
792 |
$imgUrl = Mage::getSingleton('catalog/product_media_config')->getMediaUrl($product['image']);
|
847 |
return $xml;
|
848 |
}
|
849 |
|
850 |
+
public function addConfigurableProducts($collection)
|
851 |
+
{
|
852 |
+
|
853 |
+
}
|
854 |
+
|
855 |
/**
|
856 |
* Join channelengine order fields to adminhtml order grid
|
857 |
*
|
app/code/community/Tritac/ChannelEngine/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Tritac_ChannelEngine>
|
5 |
-
<version>2.
|
6 |
</Tritac_ChannelEngine>
|
7 |
</modules>
|
8 |
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Tritac_ChannelEngine>
|
5 |
+
<version>2.3.0</version>
|
6 |
</Tritac_ChannelEngine>
|
7 |
</modules>
|
8 |
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Tritac_ChannelEngine</name>
|
4 |
-
<version>2.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Connect your Magento shop to the ChannelEngine platform.</summary>
|
10 |
<description>Easily offer your products on comparison websites and marketplaces using the ChannelEngine platform.</description>
|
11 |
-
<notes>*
|
12 |
<authors><author><name>ChannelEngine</name><user>christiaander</user><email>christiaan@tritac.com</email></author></authors>
|
13 |
-
<date>2014-
|
14 |
-
<time>
|
15 |
-
<contents><target name="mageetc"><dir name="modules"><file name="Tritac_ChannelEngine.xml" hash="014b02d581d1039764cdc422e8f86643"/></dir></target><target name="magecommunity"><dir name="Tritac"><dir name="ChannelEngine"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><file name="Feed.php" hash="cbc5bf15ab9cd9bb5b2bc97375db3eb2"/></dir></dir></dir><file name="Head.php" hash="98a65067f1ae6074f2c276624164c183"/><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="097e10d1e9e6dd8c5aee66124376cae4"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="bf1203d5f080b340404f02c51967f328"/></dir><dir name="Model"><dir name="Carrier"><file name="Channelengine.php" hash="d93ca824330b2e0eff034009c7e333c2"/></dir><file name="Observer.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Tritac_ChannelEngine</name>
|
4 |
+
<version>2.3.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Connect your Magento shop to the ChannelEngine platform.</summary>
|
10 |
<description>Easily offer your products on comparison websites and marketplaces using the ChannelEngine platform.</description>
|
11 |
+
<notes>* Added support for configurable products</notes>
|
12 |
<authors><author><name>ChannelEngine</name><user>christiaander</user><email>christiaan@tritac.com</email></author></authors>
|
13 |
+
<date>2014-06-03</date>
|
14 |
+
<time>10:07:21</time>
|
15 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Tritac_ChannelEngine.xml" hash="014b02d581d1039764cdc422e8f86643"/></dir></target><target name="magecommunity"><dir name="Tritac"><dir name="ChannelEngine"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><file name="Feed.php" hash="cbc5bf15ab9cd9bb5b2bc97375db3eb2"/></dir></dir></dir><file name="Head.php" hash="98a65067f1ae6074f2c276624164c183"/><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="097e10d1e9e6dd8c5aee66124376cae4"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="bf1203d5f080b340404f02c51967f328"/></dir><dir name="Model"><dir name="Carrier"><file name="Channelengine.php" hash="d93ca824330b2e0eff034009c7e333c2"/></dir><file name="Observer.php" hash="8833a9432be6a91c6de6f29d15dded9e"/><file name="Order.php" hash="66c8e7c0ac47f9dbabb156eaa8c97f1e"/><dir name="Payment"><dir name="Method"><file name="Channelengine.php" hash="49ef02953b486cfbf813d37e681172a3"/></dir></dir><dir name="Resource"><dir name="Order"><file name="Collection.php" hash="989bbd95481d2954d7813e19d8c27d18"/></dir><file name="Order.php" hash="3813fe3ad637daf069d79bca1feea540"/><file name="Setup.php" hash="24934fe022e3bb93331fcbfb7a116d37"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Gtin.php" hash="d182d37bc836ef718858c985c27b3c3c"/><file name="Shipping.php" hash="103486f575dcd6205fc9cfd40f2fa5ea"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="GenerateController.php" hash="edde582db1fbb091e14396b247cd0d45"/></dir><file name="TestController.php" hash="1f579ff8fd8ffeb9a8ce25dde0d0fc11"/></dir><dir name="etc"><file name="adminhtml.xml" hash="5a976b638c6ad66287ba3084fdbfc157"/><file name="config.xml" hash="a920397f4d537eeeae66694b016ed749"/><file name="system.xml" hash="de0e1158e239833891707739313ac8c6"/></dir><dir name="sql"><dir name="channelengine_setup"><file name="mysql4-install-0.1.0.0.php" hash="312e7c69f98c8d13d251b8ed1ca93448"/><file name="mysql4-install-1.0.0.php" hash="3664f3c5b6e01db69cbea8b4b0beb9ab"/></dir></dir></dir></dir></target><target name="magelib"><dir name="Tritac"><dir name="ChannelEngineApiClient"><file name="AddTrustExternalCARoot.crt" hash="f85d1ff17b0079709f131f3ce3f288d2"/><file name="Client.php" hash="6b17bfb6a9c9f8af6086cd46fda24106"/><dir name="Enums"><file name="CancellationLineStatus.php" hash="0fe455ad75e49b2796d4bcd1230a3c0d"/><file name="CancellationStatus.php" hash="e4a26c1a29afe02d92320187277f5d03"/><file name="Gender.php" hash="49645506c67b6ad530e1463da256d403"/><file name="MancoReason.php" hash="80388c0545fa091fd9e651fc1284b77d"/><file name="OrderStatus.php" hash="855341235149ff3c9d3a36a5a23f8db0"/><file name="ReturnAcceptStatus.php" hash="de4252a8f9d7b94493b470cccd9feaec"/><file name="ReturnReason.php" hash="05d5fd5b23af84508b8bec92137c421d"/><file name="ReturnStatus.php" hash="ba9350e9ba015ec9cac4b1ab7702333c"/><file name="ShipmentLineStatus.php" hash="8329dce7182fc7705bb8008da6a7e26f"/><file name="ShipmentStatus.php" hash="d73e4a5b58487c7b0c80b114601d3279"/></dir><dir name="Helpers"><file name="Collection.php" hash="2278a5e6d8d65ebca92ba1e968680315"/><file name="HttpMethod.php" hash="4949b2cfe4a309a54b1642fa09bda53b"/><file name="JsonMapper.php" hash="f8e30cab83a2f2ccfdb2a64636c2346b"/></dir><dir name="Models"><file name="Address.php" hash="543aff76425e3335cbba2a1cdd25564d"/><file name="BaseModel.php" hash="65f09d298baa6496807a2f71ea93a8f8"/><file name="Cancellation.php" hash="4e845b4bd2076a5426f13e6763b41271"/><file name="CancellationLine.php" hash="e8820be847e77d5f77a2de8cb551a8a0"/><file name="Message.php" hash="e0cea12494684d58abea051958082036"/><file name="Order.php" hash="db5ecd35bf5e2158ac27565bd1c95a8a"/><file name="OrderExtraDataItem.php" hash="eaf59ef83070360c4c7bb2c3f5c5633a"/><file name="OrderLine.php" hash="11372030afba1ed751e5a99ccf14d7c9"/><file name="ReturnLine.php" hash="c1cbf7c45a85280782955be400c478e6"/><file name="ReturnObject.php" hash="6cf979eb91ce737464620575ada1c8e9"/><file name="Shipment.php" hash="246d699692e4fd9bad5db370648f717f"/><file name="ShipmentLine.php" hash="5c738023584cd6513940be54b8f8dc60"/></dir><file name="loader.php" hash="3daea8be627858c27383a79a29663c82"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="channelengine"><dir name="system"><dir name="config"><dir name="feed"><file name="generate_button.phtml" hash="11f261e8aee3ddfe2cd611bb8eae573e"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="channelengine.xml" hash="d4019283d7ff05708cfac73363f598b8"/></dir><dir name="template"><dir name="channelengine"><dir name="checkout"><file name="success.phtml" hash="eea5605084a179e06c8ea922bfcdd55c"/></dir><file name="head.phtml" hash="638dd695feb9aeaf343183cc3c5d77e1"/></dir></dir></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|