Version Notes
3.0.3- Added Catalog Project, Sections and Data file support
Download this release
Release Info
| Developer | Magento Core Team |
| Extension | Mage_PDF_per_Product |
| Version | 3.0.3 |
| Comparing to | |
| See all releases | |
Code changes from version 3.0.2 to 3.0.3
- app/code/community/Mage/Codi/Block/Adminhtml/Menu.php +10 -10
- app/code/community/Mage/Codi/Block/Adminhtml/Switcher.php +109 -109
- app/code/community/Mage/Codi/Block/Customer/Codi.php +526 -526
- app/code/community/Mage/Codi/Codi_Process.php +20 -20
- app/code/community/Mage/Codi/Helper/Createzip.php +87 -0
- app/code/community/Mage/Codi/Helper/Data.php +77 -3
- app/code/community/Mage/Codi/Model/Codi.php +342 -75
- app/code/community/Mage/Codi/controllers/Adminhtml/MenuController.php +327 -324
- app/code/community/Mage/Codi/controllers/DeleteController.php +37 -22
- app/code/community/Mage/Codi/controllers/NsyncController.php +55 -18
- app/code/community/Mage/Codi/controllers/SyncController.php +199 -182
- app/code/community/Mage/Codi/etc/config.xml +146 -146
- app/design/adminhtml/default/default/template/codi/index.phtml +153 -50
- package.xml +5 -5
app/code/community/Mage/Codi/Block/Adminhtml/Menu.php
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
class Mage_Codi_Block_Adminhtml_Menu extends Mage_Adminhtml_Block_Template
|
| 4 |
-
{
|
| 5 |
-
public function __construct()
|
| 6 |
-
{
|
| 7 |
-
parent::__construct();
|
| 8 |
-
$this->setTemplate('codi/index.phtml');
|
| 9 |
-
}
|
| 10 |
-
}
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Mage_Codi_Block_Adminhtml_Menu extends Mage_Adminhtml_Block_Template
|
| 4 |
+
{
|
| 5 |
+
public function __construct()
|
| 6 |
+
{
|
| 7 |
+
parent::__construct();
|
| 8 |
+
$this->setTemplate('codi/index.phtml');
|
| 9 |
+
}
|
| 10 |
+
}
|
app/code/community/Mage/Codi/Block/Adminhtml/Switcher.php
CHANGED
|
@@ -1,109 +1,109 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* Magento
|
| 4 |
-
*
|
| 5 |
-
* NOTICE OF LICENSE
|
| 6 |
-
*
|
| 7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
-
* It is also available through the world-wide-web at this URL:
|
| 10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
-
* If you did not receive a copy of the license and are unable to
|
| 12 |
-
* obtain it through the world-wide-web, please send an email
|
| 13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
-
*
|
| 15 |
-
* DISCLAIMER
|
| 16 |
-
*
|
| 17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
-
* versions in the future. If you wish to customize Magento for your
|
| 19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
-
*
|
| 21 |
-
* @category Mage
|
| 22 |
-
* @package Mage_Adminhtml
|
| 23 |
-
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
-
*/
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
class Mage_Codi_Block_Adminhtml_Switcher extends Mage_Adminhtml_Block_Template
|
| 29 |
-
{
|
| 30 |
-
protected function _prepareLayout()
|
| 31 |
-
{
|
| 32 |
-
$this->setTemplate('codi/switcher.phtml');
|
| 33 |
-
return parent::_prepareLayout();
|
| 34 |
-
}
|
| 35 |
-
|
| 36 |
-
/**
|
| 37 |
-
* Enter description here...
|
| 38 |
-
*
|
| 39 |
-
* @return array
|
| 40 |
-
*/
|
| 41 |
-
public function getStoreSelectOptions()
|
| 42 |
-
{
|
| 43 |
-
$section = $this->getRequest()->getParam('section');
|
| 44 |
-
|
| 45 |
-
$curWebsite = $this->getRequest()->getParam('website');
|
| 46 |
-
$curStore = $this->getRequest()->getParam('store');
|
| 47 |
-
|
| 48 |
-
$storeModel = Mage::getSingleton('adminhtml/system_store');
|
| 49 |
-
/* @var $storeModel Mage_Adminhtml_Model_System_Store */
|
| 50 |
-
|
| 51 |
-
$url = Mage::getModel('adminhtml/url');
|
| 52 |
-
|
| 53 |
-
$options = array();
|
| 54 |
-
$options['default'] = array(
|
| 55 |
-
'label' => Mage::helper('adminhtml')->__('Default Config'),
|
| 56 |
-
'url' => $url->getUrl('*/*/*', array('section'=>$section)),
|
| 57 |
-
'selected' => !$curWebsite && !$curStore,
|
| 58 |
-
'style' => 'background:#ccc; font-weight:bold;',
|
| 59 |
-
);
|
| 60 |
-
|
| 61 |
-
foreach ($storeModel->getWebsiteCollection() as $website) {
|
| 62 |
-
$websiteShow = false;
|
| 63 |
-
foreach ($storeModel->getGroupCollection() as $group) {
|
| 64 |
-
if ($group->getWebsiteId() != $website->getId()) {
|
| 65 |
-
continue;
|
| 66 |
-
}
|
| 67 |
-
$groupShow = false;
|
| 68 |
-
foreach ($storeModel->getStoreCollection() as $store) {
|
| 69 |
-
if ($store->getGroupId() != $group->getId()) {
|
| 70 |
-
continue;
|
| 71 |
-
}
|
| 72 |
-
if ($websiteShow) {
|
| 73 |
-
$websiteShow = true;
|
| 74 |
-
$options['website_' . $website->getCode()] = array(
|
| 75 |
-
'label' => $website->getName(),
|
| 76 |
-
'url' => $url->getUrl('*/*/*', array('section'=>$section, 'website'=>$website->getCode())),
|
| 77 |
-
'selected' => !$curStore && $curWebsite == $website->getCode(),
|
| 78 |
-
'style' => 'padding-left:16px; background:#DDD; font-weight:bold;',
|
| 79 |
-
);
|
| 80 |
-
}
|
| 81 |
-
if (!$groupShow) {
|
| 82 |
-
$groupShow = true;
|
| 83 |
-
$options['group_' . $group->getId() . '_open'] = array(
|
| 84 |
-
'is_group' => true,
|
| 85 |
-
'is_close' => false,
|
| 86 |
-
'label' => $group->getName(),
|
| 87 |
-
'style' => 'padding-left:32px;'
|
| 88 |
-
);
|
| 89 |
-
}
|
| 90 |
-
$options['store_' . $store->getCode()] = array(
|
| 91 |
-
'label' => $store->getName(),
|
| 92 |
-
'url' => $url->getUrl('*/*/*', array('section'=>$section, 'website'=>$website->getCode(), 'store'=>$store->getCode())),
|
| 93 |
-
'selected' => $curStore == $store->getCode(),
|
| 94 |
-
'style' => '',
|
| 95 |
-
);
|
| 96 |
-
}
|
| 97 |
-
if ($groupShow) {
|
| 98 |
-
$options['group_' . $group->getId() . '_close'] = array(
|
| 99 |
-
'is_group' => true,
|
| 100 |
-
'is_close' => true,
|
| 101 |
-
);
|
| 102 |
-
}
|
| 103 |
-
}
|
| 104 |
-
}
|
| 105 |
-
|
| 106 |
-
return $options;
|
| 107 |
-
}
|
| 108 |
-
|
| 109 |
-
}
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Adminhtml
|
| 23 |
+
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class Mage_Codi_Block_Adminhtml_Switcher extends Mage_Adminhtml_Block_Template
|
| 29 |
+
{
|
| 30 |
+
protected function _prepareLayout()
|
| 31 |
+
{
|
| 32 |
+
$this->setTemplate('codi/switcher.phtml');
|
| 33 |
+
return parent::_prepareLayout();
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
/**
|
| 37 |
+
* Enter description here...
|
| 38 |
+
*
|
| 39 |
+
* @return array
|
| 40 |
+
*/
|
| 41 |
+
public function getStoreSelectOptions()
|
| 42 |
+
{
|
| 43 |
+
$section = $this->getRequest()->getParam('section');
|
| 44 |
+
|
| 45 |
+
$curWebsite = $this->getRequest()->getParam('website');
|
| 46 |
+
$curStore = $this->getRequest()->getParam('store');
|
| 47 |
+
|
| 48 |
+
$storeModel = Mage::getSingleton('adminhtml/system_store');
|
| 49 |
+
/* @var $storeModel Mage_Adminhtml_Model_System_Store */
|
| 50 |
+
|
| 51 |
+
$url = Mage::getModel('adminhtml/url');
|
| 52 |
+
|
| 53 |
+
$options = array();
|
| 54 |
+
$options['default'] = array(
|
| 55 |
+
'label' => Mage::helper('adminhtml')->__('Default Config'),
|
| 56 |
+
'url' => $url->getUrl('*/*/*', array('section'=>$section)),
|
| 57 |
+
'selected' => !$curWebsite && !$curStore,
|
| 58 |
+
'style' => 'background:#ccc; font-weight:bold;',
|
| 59 |
+
);
|
| 60 |
+
|
| 61 |
+
foreach ($storeModel->getWebsiteCollection() as $website) {
|
| 62 |
+
$websiteShow = false;
|
| 63 |
+
foreach ($storeModel->getGroupCollection() as $group) {
|
| 64 |
+
if ($group->getWebsiteId() != $website->getId()) {
|
| 65 |
+
continue;
|
| 66 |
+
}
|
| 67 |
+
$groupShow = false;
|
| 68 |
+
foreach ($storeModel->getStoreCollection() as $store) {
|
| 69 |
+
if ($store->getGroupId() != $group->getId()) {
|
| 70 |
+
continue;
|
| 71 |
+
}
|
| 72 |
+
if ($websiteShow) {
|
| 73 |
+
$websiteShow = true;
|
| 74 |
+
$options['website_' . $website->getCode()] = array(
|
| 75 |
+
'label' => $website->getName(),
|
| 76 |
+
'url' => $url->getUrl('*/*/*', array('section'=>$section, 'website'=>$website->getCode())),
|
| 77 |
+
'selected' => !$curStore && $curWebsite == $website->getCode(),
|
| 78 |
+
'style' => 'padding-left:16px; background:#DDD; font-weight:bold;',
|
| 79 |
+
);
|
| 80 |
+
}
|
| 81 |
+
if (!$groupShow) {
|
| 82 |
+
$groupShow = true;
|
| 83 |
+
$options['group_' . $group->getId() . '_open'] = array(
|
| 84 |
+
'is_group' => true,
|
| 85 |
+
'is_close' => false,
|
| 86 |
+
'label' => $group->getName(),
|
| 87 |
+
'style' => 'padding-left:32px;'
|
| 88 |
+
);
|
| 89 |
+
}
|
| 90 |
+
$options['store_' . $store->getCode()] = array(
|
| 91 |
+
'label' => $store->getName(),
|
| 92 |
+
'url' => $url->getUrl('*/*/*', array('section'=>$section, 'website'=>$website->getCode(), 'store'=>$store->getCode())),
|
| 93 |
+
'selected' => $curStore == $store->getCode(),
|
| 94 |
+
'style' => '',
|
| 95 |
+
);
|
| 96 |
+
}
|
| 97 |
+
if ($groupShow) {
|
| 98 |
+
$options['group_' . $group->getId() . '_close'] = array(
|
| 99 |
+
'is_group' => true,
|
| 100 |
+
'is_close' => true,
|
| 101 |
+
);
|
| 102 |
+
}
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
return $options;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
}
|
app/code/community/Mage/Codi/Block/Customer/Codi.php
CHANGED
|
@@ -1,526 +1,526 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
ini_set("max_execution_time", 3600);
|
| 3 |
-
ini_set('session.gc_maxlifetime', 3600);
|
| 4 |
-
ini_set("memory_limit","256M");
|
| 5 |
-
|
| 6 |
-
class Mage_Codi_Block_Customer_Codi extends Mage_Wishlist_Block_Customer_Wishlist
|
| 7 |
-
{
|
| 8 |
-
|
| 9 |
-
protected $_wishlistLoaded = false;
|
| 10 |
-
public $m_DataFile = "itemNumber\titemQty\titemUom\titemPrice\titemDescription\titemLink\titemAttributes\titemGraphic\tproductName\tproductMfg\tproductDescription\tproductGraphic\tproductLink\tproductAttributes\tCategory\tReviews\tSupplementalInfo";
|
| 11 |
-
// public $ProductModel ;
|
| 12 |
-
// public $ConfigurableModel ;
|
| 13 |
-
public $mediaurl ;
|
| 14 |
-
public $RootCategories ;
|
| 15 |
-
public $enablereviews ;
|
| 16 |
-
public $StoreId ;
|
| 17 |
-
public $reviewsModel ;
|
| 18 |
-
public $ratingModel ;
|
| 19 |
-
|
| 20 |
-
public function _construct()
|
| 21 |
-
{
|
| 22 |
-
// $this->ProductModel = Mage::getModel('catalog/product') ;
|
| 23 |
-
// $this->ConfigurableModel = Mage::getModel('catalog/product_type_configurable') ;
|
| 24 |
-
$this->mediaurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) ;
|
| 25 |
-
|
| 26 |
-
// Get Root Categories to eliminate them from being send -Start
|
| 27 |
-
$RootCategoriesArray = Mage::getModel('adminhtml/system_config_source_category')->toOptionArray();
|
| 28 |
-
$RootCategories = array();
|
| 29 |
-
foreach($RootCategoriesArray as $RootCategory):
|
| 30 |
-
if($RootCategory['value']) array_push($RootCategories, $RootCategory['value'] );
|
| 31 |
-
endforeach;
|
| 32 |
-
|
| 33 |
-
$this->RootCategories = $RootCategories ;
|
| 34 |
-
// Get Root Categories to eliminate them from being send -End
|
| 35 |
-
|
| 36 |
-
$this->enablereviews = Mage::getStoreConfig('codi/codi/codenablereviews') ;
|
| 37 |
-
$this->fromchild = Mage::getStoreConfig('codi/codi/fromchild') ;
|
| 38 |
-
|
| 39 |
-
// Get StoreID -Start
|
| 40 |
-
foreach (Mage::app()->getWebsites() as $website)
|
| 41 |
-
{
|
| 42 |
-
$defaultGroup = $website->getDefaultGroup();
|
| 43 |
-
$StoreId = $defaultGroup->getDefaultStoreId();
|
| 44 |
-
}
|
| 45 |
-
|
| 46 |
-
$this->StoreId = $StoreId ;
|
| 47 |
-
// Get StoreID -End
|
| 48 |
-
|
| 49 |
-
$this->reviewsModel = Mage::getModel('review/review') ;
|
| 50 |
-
$this->ratingModel = Mage::getModel('rating/rating_option_vote') ;
|
| 51 |
-
|
| 52 |
-
$this->_logFile = "Catalog-on-demand.log";
|
| 53 |
-
}
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
protected function _prepareLayout()
|
| 57 |
-
{
|
| 58 |
-
if ($headBlock = $this->getLayout()->getBlock('head')) {
|
| 59 |
-
$headBlock->setTitle($this->__('My Wishlist'));
|
| 60 |
-
}
|
| 61 |
-
}
|
| 62 |
-
|
| 63 |
-
public function getWishlist()
|
| 64 |
-
{
|
| 65 |
-
if(!$this->_wishlistLoaded) {
|
| 66 |
-
Mage::registry('wishlist')
|
| 67 |
-
->loadByCustomer(Mage::getSingleton('customer/session')->getCustomer());
|
| 68 |
-
|
| 69 |
-
$collection = Mage::registry('wishlist')->getProductCollection()
|
| 70 |
-
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
|
| 71 |
-
->addStoreFilter();
|
| 72 |
-
|
| 73 |
-
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
|
| 74 |
-
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
|
| 75 |
-
|
| 76 |
-
$this->_wishlistLoaded = true;
|
| 77 |
-
}
|
| 78 |
-
return Mage::registry('wishlist')->getProductCollection();
|
| 79 |
-
}
|
| 80 |
-
|
| 81 |
-
public function ProcessDataFileImport($m_DataFile)
|
| 82 |
-
{
|
| 83 |
-
$codimodel = Mage::getSingleton('codi/codi');
|
| 84 |
-
$userid = Mage::getStoreConfig('codi/codi/codusername') ;
|
| 85 |
-
$password = Mage::getStoreConfig('codi/codi/codpassword') ;
|
| 86 |
-
$url = "https://webservices.catalog-on-demand.com/onDemandPublishingProcessor.do" ;
|
| 87 |
-
$paramsarray = array(
|
| 88 |
-
'Operation' => "ProcessDataFileImport" ,
|
| 89 |
-
'UserID' => $userid ,
|
| 90 |
-
'Password' => $password ,
|
| 91 |
-
'ClearDatabase' => "All" ,
|
| 92 |
-
'CatalogProject'=> "Magento" ,
|
| 93 |
-
'DataFileText' => str_replace("'" , "'" , $m_DataFile) );
|
| 94 |
-
|
| 95 |
-
$Responsemsg = $codimodel->Call( $url, $paramsarray );
|
| 96 |
-
if( $Responsemsg )
|
| 97 |
-
{
|
| 98 |
-
if($Responsemsg->Message=="OK")
|
| 99 |
-
{
|
| 100 |
-
echo "Your site data has been posted to the Catalog-On-Demand database and will be available for sharing and/or publishing within 5-10 minutes.";
|
| 101 |
-
}
|
| 102 |
-
}
|
| 103 |
-
else
|
| 104 |
-
echo "*There appears to be some problem in your installation’s ability to communicate with the Catalog-On-Demand server. Please contact Catalog-On-Demand support to report this problem." ;
|
| 105 |
-
}
|
| 106 |
-
|
| 107 |
-
public function LaunchSponsoredCoDSite($m_DataFile)
|
| 108 |
-
{
|
| 109 |
-
$codimodel = Mage::getSingleton('codi/codi');
|
| 110 |
-
$userid = Mage::getStoreConfig('codi/codi/codusername') ;
|
| 111 |
-
$password = Mage::getStoreConfig('codi/codi/codpassword') ;
|
| 112 |
-
|
| 113 |
-
$customerid = "" ;
|
| 114 |
-
$customerdatasourceid = "" ;
|
| 115 |
-
$validateuser = "" ;
|
| 116 |
-
$url = "https://webservices.catalog-on-demand.com/smanager/api.do?Operation=ValidateUser&ResponseGroups=All&FunctionGroups=All" ;
|
| 117 |
-
$paramsarray = array('UserID' => $userid ,
|
| 118 |
-
'Password' => $password );
|
| 119 |
-
$Responsemsg = $codimodel->Call( $url, $paramsarray );
|
| 120 |
-
if( $Responsemsg )
|
| 121 |
-
{
|
| 122 |
-
if($Responsemsg->Message=="OK")
|
| 123 |
-
{
|
| 124 |
-
$customerid = (string)$Responsemsg->ValidateUserResponse->User->Customer->CustomerID ;
|
| 125 |
-
$customername = (string)$Responsemsg->ValidateUserResponse->User->Customer->Name ;
|
| 126 |
-
$customerdatasourceid = (string)$Responsemsg->ValidateUserResponse->User->Customer->DataSource->ID ;
|
| 127 |
-
$validateuser = (string)$Responsemsg->Message;
|
| 128 |
-
}
|
| 129 |
-
|
| 130 |
-
echo "<html><body>" ;
|
| 131 |
-
$form = ""; for ($i=0 ; $i<=100 ; $i++) { $form .= "<br>" ; } echo $form ; //hide tmp characters
|
| 132 |
-
?>
|
| 133 |
-
<FORM name='publishitems' method='POST' enctype='multipart/form-data' action='https://webservices.catalog-on-demand.com/aservices/api.do'>
|
| 134 |
-
<input type='hidden' name='Operation' value='LaunchSponsoredCoDSite'>
|
| 135 |
-
<input type='hidden' name='HideScreens' value='SelectItems'>
|
| 136 |
-
<input type='hidden' name='UserID' value='<?php echo htmlentities($userid) ?>'>
|
| 137 |
-
<input type='hidden' name='Password' value='<?php echo htmlentities($password) ?>'>
|
| 138 |
-
<input type='hidden' name='Sponsor' value='<?php echo htmlentities($customerid) ?>'>
|
| 139 |
-
<input type='hidden' name='DataFileText' value='<?php echo str_replace("'" , "'" , $m_DataFile) ?>'>
|
| 140 |
-
</FORM>
|
| 141 |
-
<SCRIPT language="JavaScript">
|
| 142 |
-
document.publishitems.submit();
|
| 143 |
-
</SCRIPT>
|
| 144 |
-
</body></html>
|
| 145 |
-
<?php
|
| 146 |
-
}
|
| 147 |
-
else
|
| 148 |
-
echo "*There appears to be some problem in your installation’s ability to communicate with the Catalog-On-Demand server. Please contact Catalog-On-Demand support to report this problem." ;
|
| 149 |
-
}
|
| 150 |
-
|
| 151 |
-
public function ProducttoString( $product , $from )
|
| 152 |
-
{
|
| 153 |
-
if( $product->isConfigurable() )
|
| 154 |
-
{
|
| 155 |
-
return $this->ProducttoStringConfigurable( $product , $from ) ;
|
| 156 |
-
}
|
| 157 |
-
else
|
| 158 |
-
{
|
| 159 |
-
return $this->ProducttoStringSimple( $product , $from ) ;
|
| 160 |
-
}
|
| 161 |
-
}
|
| 162 |
-
|
| 163 |
-
public function ProducttoStringConfigurable( $product , $from )
|
| 164 |
-
{
|
| 165 |
-
set_time_limit(0);
|
| 166 |
-
|
| 167 |
-
$ProducttoString = '' ;
|
| 168 |
-
$UsedProductIds = Mage::getModel('catalog/product_type_configurable')->getUsedProductIds($product);
|
| 169 |
-
|
| 170 |
-
if( $from == "wishlist" )
|
| 171 |
-
{
|
| 172 |
-
$myproduct = '';
|
| 173 |
-
$Comment = '' ;
|
| 174 |
-
//Add Comment if exist
|
| 175 |
-
$defaultcomment = $this->helper('wishlist')->defaultCommentString() ;
|
| 176 |
-
if ( $product->getWishlistItemDescription() !== $defaultcomment )
|
| 177 |
-
$Comment = "\\par{\\b Comment}\\par" . $product->getWishlistItemDescription() ;
|
| 178 |
-
//Get Full Product
|
| 179 |
-
$myproduct = Mage::getModel('catalog/product')->load($product->getProductID());
|
| 180 |
-
//Get Product Description
|
| 181 |
-
$ProductDescription = $myproduct->getDescription() ;
|
| 182 |
-
$ProductDescription .= $Comment ;
|
| 183 |
-
}
|
| 184 |
-
else
|
| 185 |
-
{
|
| 186 |
-
$ProductDescription = $product->getDescription() ;
|
| 187 |
-
}
|
| 188 |
-
|
| 189 |
-
//Get Product Attributes Start
|
| 190 |
-
//$excludeAttr = array() ;
|
| 191 |
-
$attributes = $product->getAttributes();
|
| 192 |
-
|
| 193 |
-
$ProductAttributes = "" ;
|
| 194 |
-
foreach ($attributes as $attribute) {
|
| 195 |
-
if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), array() )) {
|
| 196 |
-
$value = $attribute->getFrontend()->getValue($product);
|
| 197 |
-
if (is_string($value))
|
| 198 |
-
{
|
| 199 |
-
if (strlen($value) && $product->hasData($attribute->getAttributeCode()))
|
| 200 |
-
{
|
| 201 |
-
$ProductAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value . "|" ;
|
| 202 |
-
}
|
| 203 |
-
}
|
| 204 |
-
}
|
| 205 |
-
}
|
| 206 |
-
$ProductAttributes = substr($ProductAttributes, 0, strlen($ProductAttributes)-1 ) ;
|
| 207 |
-
//Get Product Attributes End
|
| 208 |
-
|
| 209 |
-
foreach($UsedProductIds as $UsedProductid)
|
| 210 |
-
{
|
| 211 |
-
$UsedProduct = Mage::getModel('catalog/product')->load($UsedProductid);
|
| 212 |
-
if( Mage::getStoreConfig('codi/codi/fromchild') )
|
| 213 |
-
$UsedProductPrice = $UsedProduct->getFinalPrice() ;
|
| 214 |
-
else
|
| 215 |
-
$UsedProductPrice = $product->getFinalPrice() ; //default behavior
|
| 216 |
-
//************************ Get Attributes Start *******************************
|
| 217 |
-
//Extract Attributes
|
| 218 |
-
//$ImageURL = (string)$this->helper('catalog/image')->init($UsedProduct, 'image');
|
| 219 |
-
//$mediaurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
|
| 220 |
-
$ImageURL = $this->mediaurl . "catalog/product" . $product->getImage();
|
| 221 |
-
|
| 222 |
-
//Get Item Attributes Start
|
| 223 |
-
//$excludeAttr = array() ;
|
| 224 |
-
$attributes = $UsedProduct->getAttributes();
|
| 225 |
-
|
| 226 |
-
$ItemitemAttributes = "" ;
|
| 227 |
-
$AllowAttributes = $product->getTypeInstance(true)->getConfigurableAttributes($product);
|
| 228 |
-
foreach ($AllowAttributes as $attribute)
|
| 229 |
-
{
|
| 230 |
-
$AttributeCode = $attribute->getProductAttribute()->getAttributeCode() ;
|
| 231 |
-
$AttributeLabel = $attribute->getProductAttribute()->getFrontend()->getLabel() ;
|
| 232 |
-
$AttribId = $UsedProduct->getData($AttributeCode) ;
|
| 233 |
-
|
| 234 |
-
$AttributeValue = "" ;
|
| 235 |
-
foreach ( $attribute->getProductAttribute()->getSource()->getAllOptions() as $option )
|
| 236 |
-
{
|
| 237 |
-
if( $option['value'] == $AttribId )
|
| 238 |
-
{
|
| 239 |
-
$AttributeValue = $option['label'];
|
| 240 |
-
}
|
| 241 |
-
}
|
| 242 |
-
|
| 243 |
-
$ItemitemAttributes .= $AttributeLabel . "=" . $AttributeValue . "|" ;
|
| 244 |
-
|
| 245 |
-
//Get Delta Price Start
|
| 246 |
-
foreach( $attribute->getPrices() as $addedPrice )
|
| 247 |
-
{
|
| 248 |
-
if ( $AttributeValue == $addedPrice['label'])
|
| 249 |
-
{
|
| 250 |
-
if( $addedPrice['is_percent'] )
|
| 251 |
-
$UsedProductPrice += $UsedProductPrice * $addedPrice['pricing_value'] / 100;
|
| 252 |
-
else
|
| 253 |
-
$UsedProductPrice += $addedPrice['pricing_value'] ;
|
| 254 |
-
}
|
| 255 |
-
}
|
| 256 |
-
//Get Delta Price End
|
| 257 |
-
}
|
| 258 |
-
|
| 259 |
-
$ItemitemAttributes = substr($ItemitemAttributes, 0, strlen($ItemitemAttributes)-1 );
|
| 260 |
-
|
| 261 |
-
//Get Item Attributes End
|
| 262 |
-
//************************ Get Attributes End ************************************
|
| 263 |
-
|
| 264 |
-
//************************* Get Categories names Start ***************************
|
| 265 |
-
|
| 266 |
-
$categories = $product->getCategoryIds();
|
| 267 |
-
|
| 268 |
-
$CategoriesString = "" ;
|
| 269 |
-
foreach($categories as $k => $_category_id){
|
| 270 |
-
|
| 271 |
-
$_category = Mage::getModel('catalog/category')->load($_category_id) ;
|
| 272 |
-
$path = $_category->getPathInStore();
|
| 273 |
-
$pathIds = array_reverse(explode(',', $path));
|
| 274 |
-
|
| 275 |
-
foreach($pathIds as $m => $_cat_id){
|
| 276 |
-
$_cat = Mage::getModel('catalog/category')->load($_cat_id) ;
|
| 277 |
-
// if( $_cat->getName() != '' && (string)$_cat->getLevel() != '1' && !(in_array($_cat_id, $this->RootCategories)) )
|
| 278 |
-
if( ($_cat->getName() != '') && ($_cat->getName() != 'Root Catalog') && ((string)$_cat->getLevel() != '1') && ($_cat->getParentId() > 1 ) )
|
| 279 |
-
$CategoriesString .= $_cat->getName() . "#$#" ;
|
| 280 |
-
}
|
| 281 |
-
|
| 282 |
-
if( substr($CategoriesString, strlen($CategoriesString)-3, 3) == "#$#" )
|
| 283 |
-
{
|
| 284 |
-
$CategoriesString = substr($CategoriesString, 0, strlen($CategoriesString)-3 ) ;
|
| 285 |
-
$CategoriesString .= "|";
|
| 286 |
-
}
|
| 287 |
-
|
| 288 |
-
}
|
| 289 |
-
|
| 290 |
-
$CategoriesString = substr($CategoriesString, 0, strlen($CategoriesString)-1 ) ;
|
| 291 |
-
|
| 292 |
-
if ($CategoriesString=='') $CategoriesString = 'Uncategorized' ;
|
| 293 |
-
|
| 294 |
-
//************************* Get Categories names End ***************************
|
| 295 |
-
|
| 296 |
-
//************************* Get Reviews Start ***********************
|
| 297 |
-
//$enablereviews = Mage::getStoreConfig('codi/codi/codenablereviews') ;
|
| 298 |
-
$Reviews = $this->enablereviews ? $this->getReviews($product->getId()) : '' ;
|
| 299 |
-
//************************* Get Reviews End *************************
|
| 300 |
-
|
| 301 |
-
//************************* Concatenate Product Info Start ***********************
|
| 302 |
-
$ProducttoString .= "\r\n" . $this->cleanStr( $UsedProduct->getSku() ) ; //ItemID
|
| 303 |
-
$ProducttoString .= "\t" . "" ; //ItemQty
|
| 304 |
-
$ProducttoString .= "\t" . "" ; //ItemUom
|
| 305 |
-
// $ProducttoString .= "\t" . $this->cleanStr( $product->getPrice() ) ; //ItemPrice
|
| 306 |
-
$ProducttoString .= "\t" . $this->cleanStr( $UsedProductPrice ) ; //ItemPrice
|
| 307 |
-
$ProducttoString .= "\t" . ""; //ItemDescription
|
| 308 |
-
$ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ); //ItemLink
|
| 309 |
-
$ProducttoString .= "\t" . $this->cleanStr( $ItemitemAttributes ) ; //ItemitemAttributes
|
| 310 |
-
$ProducttoString .= "\t" . ""; //ItemitemGraphic
|
| 311 |
-
$ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName() ); //ProductName
|
| 312 |
-
$ProducttoString .= "\t" . "" ; //ProductMfg
|
| 313 |
-
$ProducttoString .= "\t" . $this->cleanStr( $ProductDescription ) ; //ProductDescription
|
| 314 |
-
$ProducttoString .= "\t" . $this->cleanStr( $ImageURL ); //ProductGraphic
|
| 315 |
-
$ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ) ; //ProductLink
|
| 316 |
-
$ProducttoString .= "\t" . $this->cleanStr( $ProductAttributes ) ; //ProductAttributes
|
| 317 |
-
$ProducttoString .= "\t" . $this->cleanStr( $CategoriesString ); //Category
|
| 318 |
-
$ProducttoString .= "\t" . $this->cleanStr( $Reviews ); //Reviews
|
| 319 |
-
$ProducttoString .= "\t" . $this->cleanStr( $product->getShortDescription() ); //ShortDescription (Quick Overview)
|
| 320 |
-
//************************* Concatenate Product Info End ************************* cleanStr
|
| 321 |
-
}
|
| 322 |
-
|
| 323 |
-
return $ProducttoString ;
|
| 324 |
-
}
|
| 325 |
-
/////////////////////////////////////////// Simple Products ///////////////////////////////////////////////////////////////////
|
| 326 |
-
public function ProducttoStringSimple( $product , $from )
|
| 327 |
-
{
|
| 328 |
-
set_time_limit(0);
|
| 329 |
-
|
| 330 |
-
$ProducttoString = '' ;
|
| 331 |
-
if($from == "wishlist")
|
| 332 |
-
{
|
| 333 |
-
$Comment = '' ;
|
| 334 |
-
//Add Comment if exist
|
| 335 |
-
$defaultcomment = $this->helper('wishlist')->defaultCommentString() ;
|
| 336 |
-
if ( $product->getWishlistItemDescription() !== $defaultcomment )
|
| 337 |
-
$Comment = "\\par{\\b Comment}\\par" . $product->getWishlistItemDescription() ;
|
| 338 |
-
//Get Full Product
|
| 339 |
-
$product = Mage::getModel('catalog/product')->load($product->getProductID());
|
| 340 |
-
//Get Product Description
|
| 341 |
-
$ProductDescription = $product->getDescription() ;
|
| 342 |
-
$ProductDescription .= $Comment ;
|
| 343 |
-
}
|
| 344 |
-
else
|
| 345 |
-
{
|
| 346 |
-
$ProductDescription = $product->getDescription() ;
|
| 347 |
-
}
|
| 348 |
-
|
| 349 |
-
//************************ Get Attributes Start *******************************
|
| 350 |
-
//Extract Attributes
|
| 351 |
-
//$ImageURL = (string)$this->helper('catalog/image')->init($product, 'image');
|
| 352 |
-
//$mediaurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
|
| 353 |
-
$ImageURL = $this->mediaurl . "catalog/product" . $product->getImage();
|
| 354 |
-
|
| 355 |
-
//$excludeAttr = array() ;
|
| 356 |
-
$attributes = $product->getAttributes();
|
| 357 |
-
$ItemitemAttributes = "" ;
|
| 358 |
-
foreach ($attributes as $attribute) {
|
| 359 |
-
if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), array() )) {
|
| 360 |
-
$value = $attribute->getFrontend()->getValue($product);
|
| 361 |
-
if (is_string($value))
|
| 362 |
-
{
|
| 363 |
-
if (strlen($value) && $product->hasData($attribute->getAttributeCode()))
|
| 364 |
-
{
|
| 365 |
-
$ItemitemAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value . "|" ;
|
| 366 |
-
}
|
| 367 |
-
}
|
| 368 |
-
}
|
| 369 |
-
}
|
| 370 |
-
$ItemitemAttributes = substr($ItemitemAttributes, 0, strlen($ItemitemAttributes)-1 ) ;
|
| 371 |
-
//************************ Get Attributes End ************************************
|
| 372 |
-
|
| 373 |
-
//************************* Get Categories names Start ***************************
|
| 374 |
-
|
| 375 |
-
$categories = $product->getCategoryIds();
|
| 376 |
-
$CategoriesString = "" ;
|
| 377 |
-
foreach($categories as $k => $_category_id){
|
| 378 |
-
|
| 379 |
-
$_category = Mage::getModel('catalog/category')->load($_category_id) ;
|
| 380 |
-
$path = $_category->getPathInStore();
|
| 381 |
-
$pathIds = array_reverse(explode(',', $path));
|
| 382 |
-
|
| 383 |
-
foreach($pathIds as $m => $_cat_id){
|
| 384 |
-
$_cat = Mage::getModel('catalog/category')->load($_cat_id) ;
|
| 385 |
-
// if( $_cat->getName() != '' && (string)$_cat->getLevel() != '1' && !(in_array($_cat_id, $this->RootCategories)) )
|
| 386 |
-
if( ($_cat->getName() != '') && ($_cat->getName() != 'Root Catalog') && ((string)$_cat->getLevel() != '1') && ($_cat->getParentId() > 1 ) )
|
| 387 |
-
$CategoriesString .= $_cat->getName() . "#$#" ;
|
| 388 |
-
}
|
| 389 |
-
|
| 390 |
-
if( substr($CategoriesString, strlen($CategoriesString)-3, 3) == "#$#" )
|
| 391 |
-
{
|
| 392 |
-
$CategoriesString = substr($CategoriesString, 0, strlen($CategoriesString)-3 );
|
| 393 |
-
$CategoriesString .= "|";
|
| 394 |
-
}
|
| 395 |
-
}
|
| 396 |
-
|
| 397 |
-
$CategoriesString = substr($CategoriesString, 0, strlen($CategoriesString)-1 ) ;
|
| 398 |
-
if ($CategoriesString == '' ) $CategoriesString = 'Uncategorized' ;
|
| 399 |
-
//************************* Get Categories names End ***************************
|
| 400 |
-
|
| 401 |
-
//************************* Get Reviews Start ***********************
|
| 402 |
-
//$enablereviews = Mage::getStoreConfig('codi/codi/codenablereviews') ;
|
| 403 |
-
//if($enablereviews) { $Reviews = $this->getReviews($product->getId()) ; }
|
| 404 |
-
$Reviews = $this->enablereviews ? $this->getReviews($product->getId()) : '' ;
|
| 405 |
-
//************************* Get Reviews End *************************
|
| 406 |
-
|
| 407 |
-
//************************* Concatenate Product Info Start ***********************
|
| 408 |
-
|
| 409 |
-
$ProducttoString .= "\r\n" . $this->cleanStr( $product->getSku() ) ; //ItemID
|
| 410 |
-
$ProducttoString .= "\t" . "" ; //ItemQty
|
| 411 |
-
$ProducttoString .= "\t" . "" ; //ItemUom
|
| 412 |
-
$ProducttoString .= "\t" . $this->cleanStr( $product->getFinalPrice() ) ; //ItemPrice
|
| 413 |
-
$ProducttoString .= "\t" . ""; //ItemDescription
|
| 414 |
-
$ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ); //ItemLink
|
| 415 |
-
$ProducttoString .= "\t" . ""; //ItemitemAttributes
|
| 416 |
-
$ProducttoString .= "\t" . ""; //ItemitemGraphic
|
| 417 |
-
$ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName() ); //ProductName
|
| 418 |
-
$ProducttoString .= "\t" . "" ; //ProductMfg
|
| 419 |
-
$ProducttoString .= "\t" . $this->cleanStr( $ProductDescription ) ; //ProductDescription
|
| 420 |
-
$ProducttoString .= "\t" . $this->cleanStr( $ImageURL ); //ProductGraphic
|
| 421 |
-
$ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ) ; //ProductLink
|
| 422 |
-
$ProducttoString .= "\t" . $this->cleanStr( $ItemitemAttributes ) ; //ProductAttributes
|
| 423 |
-
$ProducttoString .= "\t" . $this->cleanStr( $CategoriesString ); //Category
|
| 424 |
-
$ProducttoString .= "\t" . $this->cleanStr( $Reviews ); //Reviews
|
| 425 |
-
$ProducttoString .= "\t" . $this->cleanStr( $product->getShortDescription() ); //ShortDescription (Quick Overview)
|
| 426 |
-
//************************* Concatenate Product Info End ************************* cleanStr
|
| 427 |
-
|
| 428 |
-
return $ProducttoString ;
|
| 429 |
-
}
|
| 430 |
-
|
| 431 |
-
public function getReviews( $productid )
|
| 432 |
-
{
|
| 433 |
-
$reviewsCollection = $this->reviewsModel->getCollection()
|
| 434 |
-
->addStoreFilter($this->StoreId)
|
| 435 |
-
->addStatusFilter('approved')
|
| 436 |
-
->addEntityFilter('product', $productid)
|
| 437 |
-
->setDateOrder();
|
| 438 |
-
|
| 439 |
-
$Reviews = "" ;
|
| 440 |
-
foreach($reviewsCollection as $review)
|
| 441 |
-
{
|
| 442 |
-
$ratingCollection = $this->ratingModel
|
| 443 |
-
->getResourceCollection()
|
| 444 |
-
->setReviewFilter($review->getReviewId())
|
| 445 |
-
->setStoreFilter($this->StoreId)
|
| 446 |
-
->addRatingInfo($this->StoreId)
|
| 447 |
-
->load();
|
| 448 |
-
$Reviews .= "<p><b>".$review->getTitle()."(". $review->getNickname() .")</b><br>".$review->getDetail()."</p>" ;
|
| 449 |
-
}
|
| 450 |
-
return $Reviews ;
|
| 451 |
-
}
|
| 452 |
-
|
| 453 |
-
public function getWishListDataFile()
|
| 454 |
-
{
|
| 455 |
-
$m_DataFile = '' ;
|
| 456 |
-
|
| 457 |
-
foreach($this->getWishlist() as $item):
|
| 458 |
-
$m_DataFile .= $this->ProducttoString($item , "wishlist" ) ;
|
| 459 |
-
endforeach ;
|
| 460 |
-
|
| 461 |
-
return $this->m_DataFile . $m_DataFile ;
|
| 462 |
-
}
|
| 463 |
-
|
| 464 |
-
public function getcurrencysign()
|
| 465 |
-
{
|
| 466 |
-
try {
|
| 467 |
-
$currencystr = Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE) ;
|
| 468 |
-
$currency = new Zend_Currency($currencystr);
|
| 469 |
-
Zend_Registry::set('Zend_Currency', $currency);
|
| 470 |
-
return $currency->getSymbol();
|
| 471 |
-
} catch (Exception $e) {
|
| 472 |
-
return "US";
|
| 473 |
-
}
|
| 474 |
-
}
|
| 475 |
-
|
| 476 |
-
public function ProcessBackgroundJob()
|
| 477 |
-
{
|
| 478 |
-
$m_DataFile = $this->getWishListDataFile() ;
|
| 479 |
-
|
| 480 |
-
$codimodel = Mage::getSingleton('codi/codi');
|
| 481 |
-
$userid = Mage::getStoreConfig('codi/codi/codusername') ;
|
| 482 |
-
$password = Mage::getStoreConfig('codi/codi/codpassword') ;
|
| 483 |
-
|
| 484 |
-
//Get Currency Sign
|
| 485 |
-
$currencysign = $this->getcurrencysign() ;
|
| 486 |
-
//Preparing the call
|
| 487 |
-
$UserEmail = $this->getuseremail() ;
|
| 488 |
-
$JobName = $this->getRequest()->getParam('JobName') ;
|
| 489 |
-
|
| 490 |
-
$options = "_JobName=" . $JobName ;
|
| 491 |
-
$options .= "||CurrencySymbol=" . $currencysign ;
|
| 492 |
-
$options .= "||ClientAppVersion=" . "Magento" . Mage::getVersion() . "-Codi" . $codimodel->version ;
|
| 493 |
-
|
| 494 |
-
$url = "https://webservices.catalog-on-demand.com/onDemandPublishingProcessor.do?Operation=ProcessBackgroundJob";
|
| 495 |
-
$paramsarray = array('UserID' => $userid,
|
| 496 |
-
'Password' => $password,
|
| 497 |
-
'Email' => $UserEmail,
|
| 498 |
-
'Options' => $options,
|
| 499 |
-
'DataFileText' => $m_DataFile);
|
| 500 |
-
//Calling
|
| 501 |
-
$UserEmail = Mage::getSingleton('customer/session')->getCustomer()->getEmail() ; //Get User Email
|
| 502 |
-
$Responsemsg = $codimodel->Call( $url, $paramsarray );
|
| 503 |
-
if( $Responsemsg )
|
| 504 |
-
{
|
| 505 |
-
if($Responsemsg->Message=="OK")
|
| 506 |
-
echo "Your Wishlist has been submitted to Catalog-On-Demand for publishing and should be complete within 5-10 minutes. Please monitor your email ($UserEmail) for a link to your PDF publication." ;
|
| 507 |
-
else
|
| 508 |
-
{
|
| 509 |
-
echo "Error No. " . $Responsemsg->Errors->Error->Code . "<br>";
|
| 510 |
-
echo $Responsemsg->Errors->Error->Description . "<br>";
|
| 511 |
-
}
|
| 512 |
-
}
|
| 513 |
-
else
|
| 514 |
-
echo "*There appears to be some problem in your installation’s ability to communicate with the Catalog-On-Demand server. Please contact Catalog-On-Demand support to report this problem." ;
|
| 515 |
-
}
|
| 516 |
-
|
| 517 |
-
public function cleanStr($localstr)
|
| 518 |
-
{
|
| 519 |
-
$localstr = str_replace("\t","", $localstr ) ;
|
| 520 |
-
$localstr = str_replace("\r\n","<br>", $localstr ) ;
|
| 521 |
-
$localstr = str_replace("\r","<br>", $localstr ) ;
|
| 522 |
-
$localstr = str_replace("\n","<br>", $localstr ) ;
|
| 523 |
-
return $localstr ;
|
| 524 |
-
}
|
| 525 |
-
|
| 526 |
-
}// class end
|
| 1 |
+
<?php
|
| 2 |
+
ini_set("max_execution_time", 3600);
|
| 3 |
+
ini_set('session.gc_maxlifetime', 3600);
|
| 4 |
+
ini_set("memory_limit","256M");
|
| 5 |
+
|
| 6 |
+
class Mage_Codi_Block_Customer_Codi extends Mage_Wishlist_Block_Customer_Wishlist
|
| 7 |
+
{
|
| 8 |
+
|
| 9 |
+
protected $_wishlistLoaded = false;
|
| 10 |
+
public $m_DataFile = "itemNumber\titemQty\titemUom\titemPrice\titemDescription\titemLink\titemAttributes\titemGraphic\tproductName\tproductMfg\tproductDescription\tproductGraphic\tproductLink\tproductAttributes\tCategory\tReviews\tSupplementalInfo";
|
| 11 |
+
// public $ProductModel ;
|
| 12 |
+
// public $ConfigurableModel ;
|
| 13 |
+
public $mediaurl ;
|
| 14 |
+
public $RootCategories ;
|
| 15 |
+
public $enablereviews ;
|
| 16 |
+
public $StoreId ;
|
| 17 |
+
public $reviewsModel ;
|
| 18 |
+
public $ratingModel ;
|
| 19 |
+
|
| 20 |
+
public function _construct()
|
| 21 |
+
{
|
| 22 |
+
// $this->ProductModel = Mage::getModel('catalog/product') ;
|
| 23 |
+
// $this->ConfigurableModel = Mage::getModel('catalog/product_type_configurable') ;
|
| 24 |
+
$this->mediaurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) ;
|
| 25 |
+
|
| 26 |
+
// Get Root Categories to eliminate them from being send -Start
|
| 27 |
+
$RootCategoriesArray = Mage::getModel('adminhtml/system_config_source_category')->toOptionArray();
|
| 28 |
+
$RootCategories = array();
|
| 29 |
+
foreach($RootCategoriesArray as $RootCategory):
|
| 30 |
+
if($RootCategory['value']) array_push($RootCategories, $RootCategory['value'] );
|
| 31 |
+
endforeach;
|
| 32 |
+
|
| 33 |
+
$this->RootCategories = $RootCategories ;
|
| 34 |
+
// Get Root Categories to eliminate them from being send -End
|
| 35 |
+
|
| 36 |
+
$this->enablereviews = Mage::getStoreConfig('codi/codi/codenablereviews') ;
|
| 37 |
+
$this->fromchild = Mage::getStoreConfig('codi/codi/fromchild') ;
|
| 38 |
+
|
| 39 |
+
// Get StoreID -Start
|
| 40 |
+
foreach (Mage::app()->getWebsites() as $website)
|
| 41 |
+
{
|
| 42 |
+
$defaultGroup = $website->getDefaultGroup();
|
| 43 |
+
$StoreId = $defaultGroup->getDefaultStoreId();
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
$this->StoreId = $StoreId ;
|
| 47 |
+
// Get StoreID -End
|
| 48 |
+
|
| 49 |
+
$this->reviewsModel = Mage::getModel('review/review') ;
|
| 50 |
+
$this->ratingModel = Mage::getModel('rating/rating_option_vote') ;
|
| 51 |
+
|
| 52 |
+
$this->_logFile = "Catalog-on-demand.log";
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
protected function _prepareLayout()
|
| 57 |
+
{
|
| 58 |
+
if ($headBlock = $this->getLayout()->getBlock('head')) {
|
| 59 |
+
$headBlock->setTitle($this->__('My Wishlist'));
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
public function getWishlist()
|
| 64 |
+
{
|
| 65 |
+
if(!$this->_wishlistLoaded) {
|
| 66 |
+
Mage::registry('wishlist')
|
| 67 |
+
->loadByCustomer(Mage::getSingleton('customer/session')->getCustomer());
|
| 68 |
+
|
| 69 |
+
$collection = Mage::registry('wishlist')->getProductCollection()
|
| 70 |
+
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
|
| 71 |
+
->addStoreFilter();
|
| 72 |
+
|
| 73 |
+
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
|
| 74 |
+
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
|
| 75 |
+
|
| 76 |
+
$this->_wishlistLoaded = true;
|
| 77 |
+
}
|
| 78 |
+
return Mage::registry('wishlist')->getProductCollection();
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
public function ProcessDataFileImport($m_DataFile)
|
| 82 |
+
{
|
| 83 |
+
$codimodel = Mage::getSingleton('codi/codi');
|
| 84 |
+
$userid = Mage::getStoreConfig('codi/codi/codusername') ;
|
| 85 |
+
$password = Mage::getStoreConfig('codi/codi/codpassword') ;
|
| 86 |
+
$url = "https://webservices.catalog-on-demand.com/onDemandPublishingProcessor.do" ;
|
| 87 |
+
$paramsarray = array(
|
| 88 |
+
'Operation' => "ProcessDataFileImport" ,
|
| 89 |
+
'UserID' => $userid ,
|
| 90 |
+
'Password' => $password ,
|
| 91 |
+
'ClearDatabase' => "All" ,
|
| 92 |
+
'CatalogProject'=> "Magento" ,
|
| 93 |
+
'DataFileText' => str_replace("'" , "'" , $m_DataFile) );
|
| 94 |
+
|
| 95 |
+
$Responsemsg = $codimodel->Call( $url, $paramsarray );
|
| 96 |
+
if( $Responsemsg )
|
| 97 |
+
{
|
| 98 |
+
if($Responsemsg->Message=="OK")
|
| 99 |
+
{
|
| 100 |
+
echo "Your site data has been posted to the Catalog-On-Demand database and will be available for sharing and/or publishing within 5-10 minutes.";
|
| 101 |
+
}
|
| 102 |
+
}
|
| 103 |
+
else
|
| 104 |
+
echo "*There appears to be some problem in your installation’s ability to communicate with the Catalog-On-Demand server. Please contact Catalog-On-Demand support to report this problem." ;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
public function LaunchSponsoredCoDSite($m_DataFile)
|
| 108 |
+
{
|
| 109 |
+
$codimodel = Mage::getSingleton('codi/codi');
|
| 110 |
+
$userid = Mage::getStoreConfig('codi/codi/codusername') ;
|
| 111 |
+
$password = Mage::getStoreConfig('codi/codi/codpassword') ;
|
| 112 |
+
|
| 113 |
+
$customerid = "" ;
|
| 114 |
+
$customerdatasourceid = "" ;
|
| 115 |
+
$validateuser = "" ;
|
| 116 |
+
$url = "https://webservices.catalog-on-demand.com/smanager/api.do?Operation=ValidateUser&ResponseGroups=All&FunctionGroups=All" ;
|
| 117 |
+
$paramsarray = array('UserID' => $userid ,
|
| 118 |
+
'Password' => $password );
|
| 119 |
+
$Responsemsg = $codimodel->Call( $url, $paramsarray );
|
| 120 |
+
if( $Responsemsg )
|
| 121 |
+
{
|
| 122 |
+
if($Responsemsg->Message=="OK")
|
| 123 |
+
{
|
| 124 |
+
$customerid = (string)$Responsemsg->ValidateUserResponse->User->Customer->CustomerID ;
|
| 125 |
+
$customername = (string)$Responsemsg->ValidateUserResponse->User->Customer->Name ;
|
| 126 |
+
$customerdatasourceid = (string)$Responsemsg->ValidateUserResponse->User->Customer->DataSource->ID ;
|
| 127 |
+
$validateuser = (string)$Responsemsg->Message;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
echo "<html><body>" ;
|
| 131 |
+
$form = ""; for ($i=0 ; $i<=100 ; $i++) { $form .= "<br>" ; } echo $form ; //hide tmp characters
|
| 132 |
+
?>
|
| 133 |
+
<FORM name='publishitems' method='POST' enctype='multipart/form-data' action='https://webservices.catalog-on-demand.com/aservices/api.do'>
|
| 134 |
+
<input type='hidden' name='Operation' value='LaunchSponsoredCoDSite'>
|
| 135 |
+
<input type='hidden' name='HideScreens' value='SelectItems'>
|
| 136 |
+
<input type='hidden' name='UserID' value='<?php echo htmlentities($userid) ?>'>
|
| 137 |
+
<input type='hidden' name='Password' value='<?php echo htmlentities($password) ?>'>
|
| 138 |
+
<input type='hidden' name='Sponsor' value='<?php echo htmlentities($customerid) ?>'>
|
| 139 |
+
<input type='hidden' name='DataFileText' value='<?php echo str_replace("'" , "'" , $m_DataFile) ?>'>
|
| 140 |
+
</FORM>
|
| 141 |
+
<SCRIPT language="JavaScript">
|
| 142 |
+
document.publishitems.submit();
|
| 143 |
+
</SCRIPT>
|
| 144 |
+
</body></html>
|
| 145 |
+
<?php
|
| 146 |
+
}
|
| 147 |
+
else
|
| 148 |
+
echo "*There appears to be some problem in your installation’s ability to communicate with the Catalog-On-Demand server. Please contact Catalog-On-Demand support to report this problem." ;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
public function ProducttoString( $product , $from )
|
| 152 |
+
{
|
| 153 |
+
if( $product->isConfigurable() )
|
| 154 |
+
{
|
| 155 |
+
return $this->ProducttoStringConfigurable( $product , $from ) ;
|
| 156 |
+
}
|
| 157 |
+
else
|
| 158 |
+
{
|
| 159 |
+
return $this->ProducttoStringSimple( $product , $from ) ;
|
| 160 |
+
}
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
public function ProducttoStringConfigurable( $product , $from )
|
| 164 |
+
{
|
| 165 |
+
set_time_limit(0);
|
| 166 |
+
|
| 167 |
+
$ProducttoString = '' ;
|
| 168 |
+
$UsedProductIds = Mage::getModel('catalog/product_type_configurable')->getUsedProductIds($product);
|
| 169 |
+
|
| 170 |
+
if( $from == "wishlist" )
|
| 171 |
+
{
|
| 172 |
+
$myproduct = '';
|
| 173 |
+
$Comment = '' ;
|
| 174 |
+
//Add Comment if exist
|
| 175 |
+
$defaultcomment = $this->helper('wishlist')->defaultCommentString() ;
|
| 176 |
+
if ( $product->getWishlistItemDescription() !== $defaultcomment )
|
| 177 |
+
$Comment = "\\par{\\b Comment}\\par" . $product->getWishlistItemDescription() ;
|
| 178 |
+
//Get Full Product
|
| 179 |
+
$myproduct = Mage::getModel('catalog/product')->load($product->getProductID());
|
| 180 |
+
//Get Product Description
|
| 181 |
+
$ProductDescription = $myproduct->getDescription() ;
|
| 182 |
+
$ProductDescription .= $Comment ;
|
| 183 |
+
}
|
| 184 |
+
else
|
| 185 |
+
{
|
| 186 |
+
$ProductDescription = $product->getDescription() ;
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
//Get Product Attributes Start
|
| 190 |
+
//$excludeAttr = array() ;
|
| 191 |
+
$attributes = $product->getAttributes();
|
| 192 |
+
|
| 193 |
+
$ProductAttributes = "" ;
|
| 194 |
+
foreach ($attributes as $attribute) {
|
| 195 |
+
if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), array() )) {
|
| 196 |
+
$value = $attribute->getFrontend()->getValue($product);
|
| 197 |
+
if (is_string($value))
|
| 198 |
+
{
|
| 199 |
+
if (strlen($value) && $product->hasData($attribute->getAttributeCode()))
|
| 200 |
+
{
|
| 201 |
+
$ProductAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value . "|" ;
|
| 202 |
+
}
|
| 203 |
+
}
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
$ProductAttributes = substr($ProductAttributes, 0, strlen($ProductAttributes)-1 ) ;
|
| 207 |
+
//Get Product Attributes End
|
| 208 |
+
|
| 209 |
+
foreach($UsedProductIds as $UsedProductid)
|
| 210 |
+
{
|
| 211 |
+
$UsedProduct = Mage::getModel('catalog/product')->load($UsedProductid);
|
| 212 |
+
if( Mage::getStoreConfig('codi/codi/fromchild') )
|
| 213 |
+
$UsedProductPrice = $UsedProduct->getFinalPrice() ;
|
| 214 |
+
else
|
| 215 |
+
$UsedProductPrice = $product->getFinalPrice() ; //default behavior
|
| 216 |
+
//************************ Get Attributes Start *******************************
|
| 217 |
+
//Extract Attributes
|
| 218 |
+
//$ImageURL = (string)$this->helper('catalog/image')->init($UsedProduct, 'image');
|
| 219 |
+
//$mediaurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
|
| 220 |
+
$ImageURL = $this->mediaurl . "catalog/product" . $product->getImage();
|
| 221 |
+
|
| 222 |
+
//Get Item Attributes Start
|
| 223 |
+
//$excludeAttr = array() ;
|
| 224 |
+
$attributes = $UsedProduct->getAttributes();
|
| 225 |
+
|
| 226 |
+
$ItemitemAttributes = "" ;
|
| 227 |
+
$AllowAttributes = $product->getTypeInstance(true)->getConfigurableAttributes($product);
|
| 228 |
+
foreach ($AllowAttributes as $attribute)
|
| 229 |
+
{
|
| 230 |
+
$AttributeCode = $attribute->getProductAttribute()->getAttributeCode() ;
|
| 231 |
+
$AttributeLabel = $attribute->getProductAttribute()->getFrontend()->getLabel() ;
|
| 232 |
+
$AttribId = $UsedProduct->getData($AttributeCode) ;
|
| 233 |
+
|
| 234 |
+
$AttributeValue = "" ;
|
| 235 |
+
foreach ( $attribute->getProductAttribute()->getSource()->getAllOptions() as $option )
|
| 236 |
+
{
|
| 237 |
+
if( $option['value'] == $AttribId )
|
| 238 |
+
{
|
| 239 |
+
$AttributeValue = $option['label'];
|
| 240 |
+
}
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
$ItemitemAttributes .= $AttributeLabel . "=" . $AttributeValue . "|" ;
|
| 244 |
+
|
| 245 |
+
//Get Delta Price Start
|
| 246 |
+
foreach( $attribute->getPrices() as $addedPrice )
|
| 247 |
+
{
|
| 248 |
+
if ( $AttributeValue == $addedPrice['label'])
|
| 249 |
+
{
|
| 250 |
+
if( $addedPrice['is_percent'] )
|
| 251 |
+
$UsedProductPrice += $UsedProductPrice * $addedPrice['pricing_value'] / 100;
|
| 252 |
+
else
|
| 253 |
+
$UsedProductPrice += $addedPrice['pricing_value'] ;
|
| 254 |
+
}
|
| 255 |
+
}
|
| 256 |
+
//Get Delta Price End
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
$ItemitemAttributes = substr($ItemitemAttributes, 0, strlen($ItemitemAttributes)-1 );
|
| 260 |
+
|
| 261 |
+
//Get Item Attributes End
|
| 262 |
+
//************************ Get Attributes End ************************************
|
| 263 |
+
|
| 264 |
+
//************************* Get Categories names Start ***************************
|
| 265 |
+
|
| 266 |
+
$categories = $product->getCategoryIds();
|
| 267 |
+
|
| 268 |
+
$CategoriesString = "" ;
|
| 269 |
+
foreach($categories as $k => $_category_id){
|
| 270 |
+
|
| 271 |
+
$_category = Mage::getModel('catalog/category')->load($_category_id) ;
|
| 272 |
+
$path = $_category->getPathInStore();
|
| 273 |
+
$pathIds = array_reverse(explode(',', $path));
|
| 274 |
+
|
| 275 |
+
foreach($pathIds as $m => $_cat_id){
|
| 276 |
+
$_cat = Mage::getModel('catalog/category')->load($_cat_id) ;
|
| 277 |
+
// if( $_cat->getName() != '' && (string)$_cat->getLevel() != '1' && !(in_array($_cat_id, $this->RootCategories)) )
|
| 278 |
+
if( ($_cat->getName() != '') && ($_cat->getName() != 'Root Catalog') && ((string)$_cat->getLevel() != '1') && ($_cat->getParentId() > 1 ) )
|
| 279 |
+
$CategoriesString .= $_cat->getName() . "#$#" ;
|
| 280 |
+
}
|
| 281 |
+
|
| 282 |
+
if( substr($CategoriesString, strlen($CategoriesString)-3, 3) == "#$#" )
|
| 283 |
+
{
|
| 284 |
+
$CategoriesString = substr($CategoriesString, 0, strlen($CategoriesString)-3 ) ;
|
| 285 |
+
$CategoriesString .= "|";
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
$CategoriesString = substr($CategoriesString, 0, strlen($CategoriesString)-1 ) ;
|
| 291 |
+
|
| 292 |
+
if ($CategoriesString=='') $CategoriesString = 'Uncategorized' ;
|
| 293 |
+
|
| 294 |
+
//************************* Get Categories names End ***************************
|
| 295 |
+
|
| 296 |
+
//************************* Get Reviews Start ***********************
|
| 297 |
+
//$enablereviews = Mage::getStoreConfig('codi/codi/codenablereviews') ;
|
| 298 |
+
$Reviews = $this->enablereviews ? $this->getReviews($product->getId()) : '' ;
|
| 299 |
+
//************************* Get Reviews End *************************
|
| 300 |
+
|
| 301 |
+
//************************* Concatenate Product Info Start ***********************
|
| 302 |
+
$ProducttoString .= "\r\n" . $this->cleanStr( $UsedProduct->getSku() ) ; //ItemID
|
| 303 |
+
$ProducttoString .= "\t" . "" ; //ItemQty
|
| 304 |
+
$ProducttoString .= "\t" . "" ; //ItemUom
|
| 305 |
+
// $ProducttoString .= "\t" . $this->cleanStr( $product->getPrice() ) ; //ItemPrice
|
| 306 |
+
$ProducttoString .= "\t" . $this->cleanStr( $UsedProductPrice ) ; //ItemPrice
|
| 307 |
+
$ProducttoString .= "\t" . ""; //ItemDescription
|
| 308 |
+
$ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ); //ItemLink
|
| 309 |
+
$ProducttoString .= "\t" . $this->cleanStr( $ItemitemAttributes ) ; //ItemitemAttributes
|
| 310 |
+
$ProducttoString .= "\t" . ""; //ItemitemGraphic
|
| 311 |
+
$ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName() ); //ProductName
|
| 312 |
+
$ProducttoString .= "\t" . "" ; //ProductMfg
|
| 313 |
+
$ProducttoString .= "\t" . $this->cleanStr( $ProductDescription ) ; //ProductDescription
|
| 314 |
+
$ProducttoString .= "\t" . $this->cleanStr( $ImageURL ); //ProductGraphic
|
| 315 |
+
$ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ) ; //ProductLink
|
| 316 |
+
$ProducttoString .= "\t" . $this->cleanStr( $ProductAttributes ) ; //ProductAttributes
|
| 317 |
+
$ProducttoString .= "\t" . $this->cleanStr( $CategoriesString ); //Category
|
| 318 |
+
$ProducttoString .= "\t" . $this->cleanStr( $Reviews ); //Reviews
|
| 319 |
+
$ProducttoString .= "\t" . $this->cleanStr( $product->getShortDescription() ); //ShortDescription (Quick Overview)
|
| 320 |
+
//************************* Concatenate Product Info End ************************* cleanStr
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
return $ProducttoString ;
|
| 324 |
+
}
|
| 325 |
+
/////////////////////////////////////////// Simple Products ///////////////////////////////////////////////////////////////////
|
| 326 |
+
public function ProducttoStringSimple( $product , $from )
|
| 327 |
+
{
|
| 328 |
+
set_time_limit(0);
|
| 329 |
+
|
| 330 |
+
$ProducttoString = '' ;
|
| 331 |
+
if($from == "wishlist")
|
| 332 |
+
{
|
| 333 |
+
$Comment = '' ;
|
| 334 |
+
//Add Comment if exist
|
| 335 |
+
$defaultcomment = $this->helper('wishlist')->defaultCommentString() ;
|
| 336 |
+
if ( $product->getWishlistItemDescription() !== $defaultcomment )
|
| 337 |
+
$Comment = "\\par{\\b Comment}\\par" . $product->getWishlistItemDescription() ;
|
| 338 |
+
//Get Full Product
|
| 339 |
+
$product = Mage::getModel('catalog/product')->load($product->getProductID());
|
| 340 |
+
//Get Product Description
|
| 341 |
+
$ProductDescription = $product->getDescription() ;
|
| 342 |
+
$ProductDescription .= $Comment ;
|
| 343 |
+
}
|
| 344 |
+
else
|
| 345 |
+
{
|
| 346 |
+
$ProductDescription = $product->getDescription() ;
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
//************************ Get Attributes Start *******************************
|
| 350 |
+
//Extract Attributes
|
| 351 |
+
//$ImageURL = (string)$this->helper('catalog/image')->init($product, 'image');
|
| 352 |
+
//$mediaurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
|
| 353 |
+
$ImageURL = $this->mediaurl . "catalog/product" . $product->getImage();
|
| 354 |
+
|
| 355 |
+
//$excludeAttr = array() ;
|
| 356 |
+
$attributes = $product->getAttributes();
|
| 357 |
+
$ItemitemAttributes = "" ;
|
| 358 |
+
foreach ($attributes as $attribute) {
|
| 359 |
+
if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), array() )) {
|
| 360 |
+
$value = $attribute->getFrontend()->getValue($product);
|
| 361 |
+
if (is_string($value))
|
| 362 |
+
{
|
| 363 |
+
if (strlen($value) && $product->hasData($attribute->getAttributeCode()))
|
| 364 |
+
{
|
| 365 |
+
$ItemitemAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value . "|" ;
|
| 366 |
+
}
|
| 367 |
+
}
|
| 368 |
+
}
|
| 369 |
+
}
|
| 370 |
+
$ItemitemAttributes = substr($ItemitemAttributes, 0, strlen($ItemitemAttributes)-1 ) ;
|
| 371 |
+
//************************ Get Attributes End ************************************
|
| 372 |
+
|
| 373 |
+
//************************* Get Categories names Start ***************************
|
| 374 |
+
|
| 375 |
+
$categories = $product->getCategoryIds();
|
| 376 |
+
$CategoriesString = "" ;
|
| 377 |
+
foreach($categories as $k => $_category_id){
|
| 378 |
+
|
| 379 |
+
$_category = Mage::getModel('catalog/category')->load($_category_id) ;
|
| 380 |
+
$path = $_category->getPathInStore();
|
| 381 |
+
$pathIds = array_reverse(explode(',', $path));
|
| 382 |
+
|
| 383 |
+
foreach($pathIds as $m => $_cat_id){
|
| 384 |
+
$_cat = Mage::getModel('catalog/category')->load($_cat_id) ;
|
| 385 |
+
// if( $_cat->getName() != '' && (string)$_cat->getLevel() != '1' && !(in_array($_cat_id, $this->RootCategories)) )
|
| 386 |
+
if( ($_cat->getName() != '') && ($_cat->getName() != 'Root Catalog') && ((string)$_cat->getLevel() != '1') && ($_cat->getParentId() > 1 ) )
|
| 387 |
+
$CategoriesString .= $_cat->getName() . "#$#" ;
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
if( substr($CategoriesString, strlen($CategoriesString)-3, 3) == "#$#" )
|
| 391 |
+
{
|
| 392 |
+
$CategoriesString = substr($CategoriesString, 0, strlen($CategoriesString)-3 );
|
| 393 |
+
$CategoriesString .= "|";
|
| 394 |
+
}
|
| 395 |
+
}
|
| 396 |
+
|
| 397 |
+
$CategoriesString = substr($CategoriesString, 0, strlen($CategoriesString)-1 ) ;
|
| 398 |
+
if ($CategoriesString == '' ) $CategoriesString = 'Uncategorized' ;
|
| 399 |
+
//************************* Get Categories names End ***************************
|
| 400 |
+
|
| 401 |
+
//************************* Get Reviews Start ***********************
|
| 402 |
+
//$enablereviews = Mage::getStoreConfig('codi/codi/codenablereviews') ;
|
| 403 |
+
//if($enablereviews) { $Reviews = $this->getReviews($product->getId()) ; }
|
| 404 |
+
$Reviews = $this->enablereviews ? $this->getReviews($product->getId()) : '' ;
|
| 405 |
+
//************************* Get Reviews End *************************
|
| 406 |
+
|
| 407 |
+
//************************* Concatenate Product Info Start ***********************
|
| 408 |
+
|
| 409 |
+
$ProducttoString .= "\r\n" . $this->cleanStr( $product->getSku() ) ; //ItemID
|
| 410 |
+
$ProducttoString .= "\t" . "" ; //ItemQty
|
| 411 |
+
$ProducttoString .= "\t" . "" ; //ItemUom
|
| 412 |
+
$ProducttoString .= "\t" . $this->cleanStr( $product->getFinalPrice() ) ; //ItemPrice
|
| 413 |
+
$ProducttoString .= "\t" . ""; //ItemDescription
|
| 414 |
+
$ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ); //ItemLink
|
| 415 |
+
$ProducttoString .= "\t" . ""; //ItemitemAttributes
|
| 416 |
+
$ProducttoString .= "\t" . ""; //ItemitemGraphic
|
| 417 |
+
$ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName() ); //ProductName
|
| 418 |
+
$ProducttoString .= "\t" . "" ; //ProductMfg
|
| 419 |
+
$ProducttoString .= "\t" . $this->cleanStr( $ProductDescription ) ; //ProductDescription
|
| 420 |
+
$ProducttoString .= "\t" . $this->cleanStr( $ImageURL ); //ProductGraphic
|
| 421 |
+
$ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ) ; //ProductLink
|
| 422 |
+
$ProducttoString .= "\t" . $this->cleanStr( $ItemitemAttributes ) ; //ProductAttributes
|
| 423 |
+
$ProducttoString .= "\t" . $this->cleanStr( $CategoriesString ); //Category
|
| 424 |
+
$ProducttoString .= "\t" . $this->cleanStr( $Reviews ); //Reviews
|
| 425 |
+
$ProducttoString .= "\t" . $this->cleanStr( $product->getShortDescription() ); //ShortDescription (Quick Overview)
|
| 426 |
+
//************************* Concatenate Product Info End ************************* cleanStr
|
| 427 |
+
|
| 428 |
+
return $ProducttoString ;
|
| 429 |
+
}
|
| 430 |
+
|
| 431 |
+
public function getReviews( $productid )
|
| 432 |
+
{
|
| 433 |
+
$reviewsCollection = $this->reviewsModel->getCollection()
|
| 434 |
+
->addStoreFilter($this->StoreId)
|
| 435 |
+
->addStatusFilter('approved')
|
| 436 |
+
->addEntityFilter('product', $productid)
|
| 437 |
+
->setDateOrder();
|
| 438 |
+
|
| 439 |
+
$Reviews = "" ;
|
| 440 |
+
foreach($reviewsCollection as $review)
|
| 441 |
+
{
|
| 442 |
+
$ratingCollection = $this->ratingModel
|
| 443 |
+
->getResourceCollection()
|
| 444 |
+
->setReviewFilter($review->getReviewId())
|
| 445 |
+
->setStoreFilter($this->StoreId)
|
| 446 |
+
->addRatingInfo($this->StoreId)
|
| 447 |
+
->load();
|
| 448 |
+
$Reviews .= "<p><b>".$review->getTitle()."(". $review->getNickname() .")</b><br>".$review->getDetail()."</p>" ;
|
| 449 |
+
}
|
| 450 |
+
return $Reviews ;
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
public function getWishListDataFile()
|
| 454 |
+
{
|
| 455 |
+
$m_DataFile = '' ;
|
| 456 |
+
|
| 457 |
+
foreach($this->getWishlist() as $item):
|
| 458 |
+
$m_DataFile .= $this->ProducttoString($item , "wishlist" ) ;
|
| 459 |
+
endforeach ;
|
| 460 |
+
|
| 461 |
+
return $this->m_DataFile . $m_DataFile ;
|
| 462 |
+
}
|
| 463 |
+
|
| 464 |
+
public function getcurrencysign()
|
| 465 |
+
{
|
| 466 |
+
try {
|
| 467 |
+
$currencystr = Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE) ;
|
| 468 |
+
$currency = new Zend_Currency($currencystr);
|
| 469 |
+
Zend_Registry::set('Zend_Currency', $currency);
|
| 470 |
+
return $currency->getSymbol();
|
| 471 |
+
} catch (Exception $e) {
|
| 472 |
+
return "US";
|
| 473 |
+
}
|
| 474 |
+
}
|
| 475 |
+
|
| 476 |
+
public function ProcessBackgroundJob()
|
| 477 |
+
{
|
| 478 |
+
$m_DataFile = $this->getWishListDataFile() ;
|
| 479 |
+
|
| 480 |
+
$codimodel = Mage::getSingleton('codi/codi');
|
| 481 |
+
$userid = Mage::getStoreConfig('codi/codi/codusername') ;
|
| 482 |
+
$password = Mage::getStoreConfig('codi/codi/codpassword') ;
|
| 483 |
+
|
| 484 |
+
//Get Currency Sign
|
| 485 |
+
$currencysign = $this->getcurrencysign() ;
|
| 486 |
+
//Preparing the call
|
| 487 |
+
$UserEmail = $this->getuseremail() ;
|
| 488 |
+
$JobName = $this->getRequest()->getParam('JobName') ;
|
| 489 |
+
|
| 490 |
+
$options = "_JobName=" . $JobName ;
|
| 491 |
+
$options .= "||CurrencySymbol=" . $currencysign ;
|
| 492 |
+
$options .= "||ClientAppVersion=" . "Magento" . Mage::getVersion() . "-Codi" . $codimodel->version ;
|
| 493 |
+
|
| 494 |
+
$url = "https://webservices.catalog-on-demand.com/onDemandPublishingProcessor.do?Operation=ProcessBackgroundJob";
|
| 495 |
+
$paramsarray = array('UserID' => $userid,
|
| 496 |
+
'Password' => $password,
|
| 497 |
+
'Email' => $UserEmail,
|
| 498 |
+
'Options' => $options,
|
| 499 |
+
'DataFileText' => $m_DataFile);
|
| 500 |
+
//Calling
|
| 501 |
+
$UserEmail = Mage::getSingleton('customer/session')->getCustomer()->getEmail() ; //Get User Email
|
| 502 |
+
$Responsemsg = $codimodel->Call( $url, $paramsarray );
|
| 503 |
+
if( $Responsemsg )
|
| 504 |
+
{
|
| 505 |
+
if($Responsemsg->Message=="OK")
|
| 506 |
+
echo "Your Wishlist has been submitted to Catalog-On-Demand for publishing and should be complete within 5-10 minutes. Please monitor your email ($UserEmail) for a link to your PDF publication." ;
|
| 507 |
+
else
|
| 508 |
+
{
|
| 509 |
+
echo "Error No. " . $Responsemsg->Errors->Error->Code . "<br>";
|
| 510 |
+
echo $Responsemsg->Errors->Error->Description . "<br>";
|
| 511 |
+
}
|
| 512 |
+
}
|
| 513 |
+
else
|
| 514 |
+
echo "*There appears to be some problem in your installation’s ability to communicate with the Catalog-On-Demand server. Please contact Catalog-On-Demand support to report this problem." ;
|
| 515 |
+
}
|
| 516 |
+
|
| 517 |
+
public function cleanStr($localstr)
|
| 518 |
+
{
|
| 519 |
+
$localstr = str_replace("\t","", $localstr ) ;
|
| 520 |
+
$localstr = str_replace("\r\n","<br>", $localstr ) ;
|
| 521 |
+
$localstr = str_replace("\r","<br>", $localstr ) ;
|
| 522 |
+
$localstr = str_replace("\n","<br>", $localstr ) ;
|
| 523 |
+
return $localstr ;
|
| 524 |
+
}
|
| 525 |
+
|
| 526 |
+
}// class end
|
app/code/community/Mage/Codi/Codi_Process.php
CHANGED
|
@@ -1,20 +1,20 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
$baseDir = dirname(__FILE__);
|
| 4 |
-
|
| 5 |
-
$_baseDirArray = explode("app", $baseDir);
|
| 6 |
-
$basePath = $_baseDirArray[0].'/';
|
| 7 |
-
|
| 8 |
-
require $baseDir . '/../../../../../app/Mage.php';
|
| 9 |
-
|
| 10 |
-
Mage::app();
|
| 11 |
-
|
| 12 |
-
Mage::log("Notice: Start Create data file.", null, "Catalog-on-demand.log");
|
| 13 |
-
|
| 14 |
-
$CodiModel = Mage::getModel('codi/codi');
|
| 15 |
-
|
| 16 |
-
$CodiModel->run_codi_import($basePath);
|
| 17 |
-
|
| 18 |
-
Mage::log("Notice: Finish Create data file.", null, "Catalog-on-demand.log");
|
| 19 |
-
|
| 20 |
-
?>
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
$baseDir = dirname(__FILE__);
|
| 4 |
+
|
| 5 |
+
$_baseDirArray = explode("app", $baseDir);
|
| 6 |
+
$basePath = $_baseDirArray[0].'/';
|
| 7 |
+
|
| 8 |
+
require $baseDir . '/../../../../../app/Mage.php';
|
| 9 |
+
|
| 10 |
+
Mage::app();
|
| 11 |
+
|
| 12 |
+
Mage::log("Notice: Start Create data file.", null, "Catalog-on-demand.log");
|
| 13 |
+
|
| 14 |
+
$CodiModel = Mage::getModel('codi/codi');
|
| 15 |
+
|
| 16 |
+
$CodiModel->run_codi_import($basePath);
|
| 17 |
+
|
| 18 |
+
Mage::log("Notice: Finish Create data file.", null, "Catalog-on-demand.log");
|
| 19 |
+
|
| 20 |
+
?>
|
app/code/community/Mage/Codi/Helper/Createzip.php
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/* Create zip of the files */
|
| 3 |
+
|
| 4 |
+
class Mage_Codi_Helper_Createzip extends Mage_Core_Helper_Abstract
|
| 5 |
+
{
|
| 6 |
+
function get_files_from_folder($directory,$filename='',$put_into='') {
|
| 7 |
+
if ($handle = opendir($directory)) {
|
| 8 |
+
while (false !== ($file = readdir($handle))) {
|
| 9 |
+
if (is_file($directory.$file)) {
|
| 10 |
+
$fileContents = file_get_contents($directory.$file);
|
| 11 |
+
$this->addFile($fileContents, $put_into.$file);
|
| 12 |
+
} elseif ($file != '.' and $file != '..' and is_dir($directory.$file)) {
|
| 13 |
+
$this->addDirectory($put_into.$file.'/');
|
| 14 |
+
$this->get_files_from_folder($directory.$file.'/',$filename, $put_into.$file.'/');
|
| 15 |
+
}
|
| 16 |
+
}
|
| 17 |
+
$data = $this->getZippedfile();
|
| 18 |
+
$f = fopen($directory."/".$filename,"wb");
|
| 19 |
+
fwrite($f,$data);
|
| 20 |
+
fclose($f);
|
| 21 |
+
}
|
| 22 |
+
closedir($handle);
|
| 23 |
+
}
|
| 24 |
+
/* creates a compressed zip file */
|
| 25 |
+
function create_zip($files = array(),$destination = '',$overwrite = false,$strreplace='')
|
| 26 |
+
{
|
| 27 |
+
//if the zip file already exists and overwrite is false, return false
|
| 28 |
+
if(file_exists($destination) && !$overwrite) { return false; }
|
| 29 |
+
//vars
|
| 30 |
+
$valid_files = array();
|
| 31 |
+
//if files were passed in...
|
| 32 |
+
if(is_array($files)) {
|
| 33 |
+
//cycle through each file
|
| 34 |
+
foreach($files as $file) {
|
| 35 |
+
//make sure the file exists
|
| 36 |
+
if(file_exists($file)) {
|
| 37 |
+
$valid_files[] = $file;
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
//if we have good files...
|
| 42 |
+
if(count($valid_files)) {
|
| 43 |
+
//create the archive
|
| 44 |
+
$zip = new ZipArchive();
|
| 45 |
+
if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
|
| 46 |
+
return false;
|
| 47 |
+
}
|
| 48 |
+
//add the files
|
| 49 |
+
foreach($valid_files as $file) {
|
| 50 |
+
$newfile=str_replace($strreplace,"",$file);
|
| 51 |
+
$zip->addFile($file,$newfile);
|
| 52 |
+
}
|
| 53 |
+
//debug
|
| 54 |
+
//echo 'The zip archive contains ',$zip->numFiles,' files with a status of ',$zip->status;
|
| 55 |
+
//close the zip -- done!
|
| 56 |
+
$zip->close();
|
| 57 |
+
//check to make sure the file exists
|
| 58 |
+
return file_exists($destination);
|
| 59 |
+
}
|
| 60 |
+
else
|
| 61 |
+
{
|
| 62 |
+
return false;
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
//Fuction to create zip for import the data
|
| 66 |
+
function createimportzip($filename){
|
| 67 |
+
$zipfilename=$filename.'.zip';
|
| 68 |
+
$DataFile = $filename.'.txt';
|
| 69 |
+
$catalogSection='CatalogSection.txt';
|
| 70 |
+
$catalogProject='CatalogProject.txt';
|
| 71 |
+
$helper=Mage::helper('codi');
|
| 72 |
+
//Change for zip
|
| 73 |
+
$files_to_zip = array($basePath.'CoDzip/CoDfiles/'.$filename.'.txt',
|
| 74 |
+
$basePath.'CoDzip/CoDfiles/CatalogSection.txt',
|
| 75 |
+
$basePath.'CoDzip/CoDfiles/CatalogProject.txt');
|
| 76 |
+
//if true, good; if false, zip creation failed
|
| 77 |
+
$result=$this->create_zip($files_to_zip,'CoDzip/'.$zipfilename,true,$basePath.'CoDzip/CoDfiles/');
|
| 78 |
+
|
| 79 |
+
if($result)
|
| 80 |
+
{
|
| 81 |
+
//Deleting files
|
| 82 |
+
if (copy($basePath.'CoDzip/CoDfiles/'.$zipfilename,$basePath.'CoDzip/'.$zipfilename)) {
|
| 83 |
+
unlink($basePath.'CoDzip/CoDfiles/'.$zipfilename);
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
}
|
app/code/community/Mage/Codi/Helper/Data.php
CHANGED
|
@@ -106,7 +106,13 @@ class Mage_Codi_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 106 |
|
| 107 |
function deleteFile($basePath='',$filename='')
|
| 108 |
{
|
| 109 |
-
@unlink($basePath
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
}
|
| 111 |
//function for get the theme
|
| 112 |
function getTheme()
|
|
@@ -238,9 +244,77 @@ class Mage_Codi_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 238 |
return $res.$rightstr;
|
| 239 |
|
| 240 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
|
| 242 |
-
|
| 243 |
-
|
| 244 |
|
| 245 |
}
|
| 246 |
?>
|
| 106 |
|
| 107 |
function deleteFile($basePath='',$filename='')
|
| 108 |
{
|
| 109 |
+
@unlink($basePath.$filename);
|
| 110 |
+
//remove text files
|
| 111 |
+
$filesn = glob($basePath."CoDzip/CoDfiles/*.txt");
|
| 112 |
+
foreach($filesn as $filen)
|
| 113 |
+
{
|
| 114 |
+
unlink($filen);
|
| 115 |
+
}
|
| 116 |
}
|
| 117 |
//function for get the theme
|
| 118 |
function getTheme()
|
| 244 |
return $res.$rightstr;
|
| 245 |
|
| 246 |
}
|
| 247 |
+
//Code for Catalog section code
|
| 248 |
+
function drawItem($category, $level=0,$name='',$i=1,$j=1,$path='')
|
| 249 |
+
{
|
| 250 |
+
$html='';
|
| 251 |
+
|
| 252 |
+
$catalogSectionModel=Mage::getModel('codi/codi');
|
| 253 |
+
//Get Category child
|
| 254 |
+
$childrennew=$category->getChildrenCategories();
|
| 255 |
+
|
| 256 |
+
$id=$category->getId();
|
| 257 |
+
if($level!=1)
|
| 258 |
+
{
|
| 259 |
+
$path.='-'.$j;
|
| 260 |
+
$name=$name.'#$#'.$category->getName();//.' '.$i.$path;
|
| 261 |
+
$sec_path.=str_replace("-",",",$path);
|
| 262 |
+
$seq=$i.$sec_path;
|
| 263 |
+
}
|
| 264 |
+
else
|
| 265 |
+
{
|
| 266 |
+
$name=$category->getName();//.' '.$i;
|
| 267 |
+
$seq=$i;
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
$catalogSectionModel->addCatalogSection($id,$name);
|
| 271 |
+
$html= "Magento\t".$seq."\t".$name."\t". $sec_Flag . "\n";
|
| 272 |
+
|
| 273 |
+
if(count($childrennew))
|
| 274 |
+
{
|
| 275 |
+
$j = 1;
|
| 276 |
+
foreach ($childrennew as $cat)
|
| 277 |
+
{
|
| 278 |
+
//$cat=$this->createCategoryObj($child->getID());
|
| 279 |
+
if($cat!=false)
|
| 280 |
+
$htmlChildren.= $this->drawItem($cat, $level+1,$name,$i,$j,$path);
|
| 281 |
+
$j++;
|
| 282 |
+
}
|
| 283 |
+
}
|
| 284 |
+
return $html.= $htmlChildren;
|
| 285 |
+
}
|
| 286 |
+
//Create category object
|
| 287 |
+
function createCategoryObj($cid)
|
| 288 |
+
{
|
| 289 |
+
$collection = Mage::getModel('catalog/category')->getCollection()
|
| 290 |
+
->setStoreId('1')
|
| 291 |
+
->addAttributeToSelect('name')
|
| 292 |
+
->addAttributeToSelect('is_active')
|
| 293 |
+
->addAttributeToFilter('entity_id', array('eq' => $cid));
|
| 294 |
+
foreach($collection as $category)
|
| 295 |
+
{
|
| 296 |
+
if($category)
|
| 297 |
+
return $category;
|
| 298 |
+
else
|
| 299 |
+
return false;
|
| 300 |
+
}
|
| 301 |
+
}
|
| 302 |
+
//get product Postion
|
| 303 |
+
function productPostion($category_id,$productId)
|
| 304 |
+
{
|
| 305 |
+
|
| 306 |
+
$category = Mage::getModel('catalog/category')
|
| 307 |
+
->setStoreId(1)
|
| 308 |
+
->load($category_id);
|
| 309 |
+
$positions = $category->getProductsPosition();
|
| 310 |
+
if(count($positions)>0)
|
| 311 |
+
$position=$positions[$productId];
|
| 312 |
+
else
|
| 313 |
+
$position='';
|
| 314 |
+
|
| 315 |
+
return $position;
|
| 316 |
|
| 317 |
+
}
|
|
|
|
| 318 |
|
| 319 |
}
|
| 320 |
?>
|
app/code/community/Mage/Codi/Model/Codi.php
CHANGED
|
@@ -7,7 +7,7 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
| 7 |
public $userid ;
|
| 8 |
public $password ;
|
| 9 |
public $disableextension ;
|
| 10 |
-
public $version = "3.0.
|
| 11 |
|
| 12 |
public $customerid ;
|
| 13 |
public $customerdatasourceid ;
|
|
@@ -191,10 +191,10 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
| 191 |
|
| 192 |
return false;
|
| 193 |
}
|
| 194 |
-
|
| 195 |
public function createFile($basePath){
|
| 196 |
|
| 197 |
-
$fh = fopen($basePath.'
|
| 198 |
|
| 199 |
if ( !$fh )
|
| 200 |
{
|
|
@@ -203,7 +203,7 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
| 203 |
|
| 204 |
fclose($fh);
|
| 205 |
|
| 206 |
-
unlink($basePath.'
|
| 207 |
return true;
|
| 208 |
}
|
| 209 |
|
|
@@ -216,11 +216,11 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
| 216 |
{
|
| 217 |
Mage::log("Notice : Codi Import Start", null, $this->_logFile);
|
| 218 |
|
| 219 |
-
ini_set('memory_limit','
|
| 220 |
|
| 221 |
$this->InitImportStatuses();
|
| 222 |
|
| 223 |
-
$fh = fopen($basePath.'
|
| 224 |
|
| 225 |
if ( !$fh )
|
| 226 |
{
|
|
@@ -258,7 +258,10 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
| 258 |
|
| 259 |
fclose($fh);
|
| 260 |
Mage::log("Notice : Codi Import End : ".$status, null, $this->_logFile);
|
| 261 |
-
|
|
|
|
|
|
|
|
|
|
| 262 |
if ( $status == "end" )
|
| 263 |
$this->addImportStatus($status, 1);
|
| 264 |
}
|
|
@@ -322,38 +325,10 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
| 322 |
$ProductAttributes.= $sp.$TierPriceAttributes;
|
| 323 |
}
|
| 324 |
//************End Tier Price option *************//
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
//************************* Get Categories names Start ***************************
|
| 330 |
-
|
| 331 |
-
$categories = $product->getCategoryIds();
|
| 332 |
$CategoriesString = "" ;
|
| 333 |
-
|
| 334 |
-
foreach($categories as $k => $_category_id){
|
| 335 |
-
|
| 336 |
-
$_category = Mage::getModel('catalog/category')->load($_category_id) ;
|
| 337 |
-
$path = $_category->getPathInStore();
|
| 338 |
-
$pathIds = array_reverse(explode(',', $path));
|
| 339 |
-
|
| 340 |
-
foreach($pathIds as $m => $_cat_id){
|
| 341 |
-
|
| 342 |
-
$_cat = Mage::getModel('catalog/category')->load($_cat_id);
|
| 343 |
-
if( ($_cat->getName() != '') && ($_cat->getName() != 'Root Catalog') && ((string)$_cat->getLevel() != '1') && ($_cat->getParentId() > 1 ) )
|
| 344 |
-
$CategoriesString .= $_cat->getName() . "#$#" ;
|
| 345 |
-
}
|
| 346 |
-
|
| 347 |
-
if( substr($CategoriesString, strlen($CategoriesString)-3, 3) == "#$#" )
|
| 348 |
-
{
|
| 349 |
-
$CategoriesString = substr($CategoriesString, 0, strlen($CategoriesString)-3 ) ;
|
| 350 |
-
$CategoriesString .= "|";
|
| 351 |
-
}
|
| 352 |
-
}
|
| 353 |
-
|
| 354 |
-
$CategoriesString = substr($CategoriesString, 0, strlen($CategoriesString)-1 ) ;
|
| 355 |
-
if ($CategoriesString=='') $CategoriesString = 'Uncategorized' ;
|
| 356 |
-
|
| 357 |
//************************* Get Categories names End ***************************
|
| 358 |
|
| 359 |
foreach($UsedProductIds as $UsedProductid)
|
|
@@ -364,13 +339,13 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
| 364 |
else
|
| 365 |
$UsedProductPrice = $product->getFinalPrice() ; //default behavior
|
| 366 |
//************************ Get Attributes Start *******************************
|
|
|
|
| 367 |
//Extract Attributes
|
| 368 |
-
|
| 369 |
-
//$mediaurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
|
| 370 |
$ImageURL = $this->mediaurl . "catalog/product" . $product->getImage();
|
| 371 |
|
| 372 |
//Get Item Attributes Start
|
| 373 |
-
|
| 374 |
$attributes = $UsedProduct->getAttributes();
|
| 375 |
|
| 376 |
$ItemitemAttributes = "" ;
|
|
@@ -438,6 +413,13 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
| 438 |
$ProducttoString .= "\t" . $this->cleanStr( $product->getShortDescription() ); //ShortDescription (Quick Overview)
|
| 439 |
//************************* Concatenate Product Info End ************************* cleanStr
|
| 440 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 441 |
|
| 442 |
return $ProducttoString ;
|
| 443 |
}
|
|
@@ -455,8 +437,7 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
| 455 |
$ProductDescription .= $product->getDescription() ;
|
| 456 |
//************************ Get Attributes Start *******************************
|
| 457 |
//Extract Attributes
|
| 458 |
-
|
| 459 |
-
//$mediaurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
|
| 460 |
$ImageURL = $this->mediaurl . "catalog/product" . $product->getImage();
|
| 461 |
|
| 462 |
//$excludeAttr = array() ;
|
|
@@ -492,37 +473,14 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
| 492 |
|
| 493 |
|
| 494 |
//************************* Get Categories names Start ***************************
|
| 495 |
-
|
| 496 |
-
$categories = $product->getCategoryIds();
|
| 497 |
-
$CategoriesString = "" ;
|
| 498 |
-
foreach($categories as $k => $_category_id){
|
| 499 |
|
| 500 |
-
|
| 501 |
-
$path = $_category->getPathInStore();
|
| 502 |
-
$pathIds = array_reverse(explode(',', $path));
|
| 503 |
-
|
| 504 |
-
foreach($pathIds as $m => $_cat_id){
|
| 505 |
-
$_cat = Mage::getModel('catalog/category')->load($_cat_id) ;
|
| 506 |
-
|
| 507 |
-
if( ($_cat->getName() != '') && ($_cat->getName() != 'Root Catalog') && ((string)$_cat->getLevel() != '1') && ($_cat->getParentId() > 1 ) )
|
| 508 |
-
$CategoriesString .= $_cat->getName() . "#$#" ;
|
| 509 |
-
}
|
| 510 |
|
| 511 |
-
if( substr($CategoriesString, strlen($CategoriesString)-3, 3) == "#$#" )
|
| 512 |
-
{
|
| 513 |
-
$CategoriesString = substr($CategoriesString, 0, strlen($CategoriesString)-3 );
|
| 514 |
-
$CategoriesString .= "|";
|
| 515 |
-
}
|
| 516 |
-
}
|
| 517 |
-
|
| 518 |
-
$CategoriesString = substr($CategoriesString, 0, strlen($CategoriesString)-1 ) ;
|
| 519 |
-
if ($CategoriesString == '' ) $CategoriesString = 'Uncategorized' ;
|
| 520 |
//************************* Get Categories names End ***************************
|
| 521 |
|
| 522 |
//************************* Get Reviews Start ***********************
|
| 523 |
-
|
| 524 |
-
//if($enablereviews) { $Reviews = $this->getReviews($product->getId()) ; }
|
| 525 |
-
$Reviews = $this->enablereviews ? $this->getReviews($product->getId()) : '' ;
|
| 526 |
//************************* Get Reviews End *************************
|
| 527 |
|
| 528 |
//************************* Concatenate Product Info Start ***********************
|
|
@@ -546,6 +504,13 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
| 546 |
$ProducttoString .= "\t" . $this->cleanStr( $product->getShortDescription() ); //ShortDescription (Quick Overview)
|
| 547 |
//************************* Concatenate Product Info End ************************* cleanStr
|
| 548 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 549 |
return $ProducttoString ;
|
| 550 |
}
|
| 551 |
|
|
@@ -734,19 +699,20 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
| 734 |
$Comment .= " Display after OR: ".$codafterOR." \r\n";
|
| 735 |
$Comment .= " Display before Quick Overview: ".$codbeforeoverview." \r\n";
|
| 736 |
$Comment .= " Display after Quick Overview: ".$codafteroverview." \r\n";
|
| 737 |
-
|
| 738 |
-
$datafilelaunch = Mage::getStoreConfig('codi/codi/coddatafilelaunch');
|
| 739 |
-
$Comment .="Data File Launch Mode: ".$datafilelaunch."\r\n";
|
| 740 |
//Change for site url
|
| 741 |
$siteurl = Mage::getUrl('/');
|
| 742 |
$Comment .="Site Url: ".$siteurl."\r\n";
|
| 743 |
-
|
| 744 |
if($datafilelaunch=='magento')
|
| 745 |
{
|
| 746 |
$datafilelaunch='cronjob';
|
| 747 |
|
| 748 |
}
|
| 749 |
|
|
|
|
|
|
|
|
|
|
| 750 |
|
| 751 |
$url = Mage::getUrl('codi/nsync') ;
|
| 752 |
$pos = strrpos ($url , 'key') ;
|
|
@@ -755,7 +721,7 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
| 755 |
else
|
| 756 |
$cronjoburl = $url;
|
| 757 |
|
| 758 |
-
if(($datafilelaunch=='
|
| 759 |
{
|
| 760 |
$Comment .="Cron job command: wget ".$cronjoburl."\r\n";
|
| 761 |
}
|
|
@@ -794,11 +760,11 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
| 794 |
|
| 795 |
Mage::log("Notice : Codi Import Start", null, $this->_logFile);
|
| 796 |
|
| 797 |
-
ini_set('memory_limit','
|
| 798 |
|
| 799 |
$this->InitImportStatuses();
|
| 800 |
|
| 801 |
-
$fh = fopen($basePath.'
|
| 802 |
|
| 803 |
if ( !$fh )
|
| 804 |
{
|
|
@@ -840,6 +806,11 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
| 840 |
{
|
| 841 |
Mage::log("Notice : Codi Import Products Exception :".$e->getMessage(), null, $this->_logFile);
|
| 842 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 843 |
fclose($fh);
|
| 844 |
Mage::log("Notice : Codi Import End : ".$status, null, $this->_logFile);
|
| 845 |
|
|
@@ -847,5 +818,301 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
| 847 |
$this->addImportStatus($status, 1);
|
| 848 |
|
| 849 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 850 |
|
| 851 |
}
|
| 7 |
public $userid ;
|
| 8 |
public $password ;
|
| 9 |
public $disableextension ;
|
| 10 |
+
public $version = "3.0.3";
|
| 11 |
|
| 12 |
public $customerid ;
|
| 13 |
public $customerdatasourceid ;
|
| 191 |
|
| 192 |
return false;
|
| 193 |
}
|
| 194 |
+
//Changed in 3.0.3
|
| 195 |
public function createFile($basePath){
|
| 196 |
|
| 197 |
+
$fh = fopen($basePath.'CoDzip/CoDfiles/temp.txt', 'w');
|
| 198 |
|
| 199 |
if ( !$fh )
|
| 200 |
{
|
| 203 |
|
| 204 |
fclose($fh);
|
| 205 |
|
| 206 |
+
//unlink($basePath.'CoDzip/CoDfiles/temp.txt');
|
| 207 |
return true;
|
| 208 |
}
|
| 209 |
|
| 216 |
{
|
| 217 |
Mage::log("Notice : Codi Import Start", null, $this->_logFile);
|
| 218 |
|
| 219 |
+
ini_set('memory_limit','1024M');
|
| 220 |
|
| 221 |
$this->InitImportStatuses();
|
| 222 |
|
| 223 |
+
$fh = fopen($basePath.'CoDzip/CoDfiles/temp.txt', 'w');
|
| 224 |
|
| 225 |
if ( !$fh )
|
| 226 |
{
|
| 258 |
|
| 259 |
fclose($fh);
|
| 260 |
Mage::log("Notice : Codi Import End : ".$status, null, $this->_logFile);
|
| 261 |
+
//Clean up
|
| 262 |
+
unset($products);
|
| 263 |
+
unset($product);
|
| 264 |
+
|
| 265 |
if ( $status == "end" )
|
| 266 |
$this->addImportStatus($status, 1);
|
| 267 |
}
|
| 325 |
$ProductAttributes.= $sp.$TierPriceAttributes;
|
| 326 |
}
|
| 327 |
//************End Tier Price option *************//
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
//************************* Get Categories names Start ***************************
|
| 329 |
+
//Changed in 3.0.3 removed the category names
|
|
|
|
| 330 |
$CategoriesString = "" ;
|
| 331 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 332 |
//************************* Get Categories names End ***************************
|
| 333 |
|
| 334 |
foreach($UsedProductIds as $UsedProductid)
|
| 339 |
else
|
| 340 |
$UsedProductPrice = $product->getFinalPrice() ; //default behavior
|
| 341 |
//************************ Get Attributes Start *******************************
|
| 342 |
+
|
| 343 |
//Extract Attributes
|
| 344 |
+
|
|
|
|
| 345 |
$ImageURL = $this->mediaurl . "catalog/product" . $product->getImage();
|
| 346 |
|
| 347 |
//Get Item Attributes Start
|
| 348 |
+
|
| 349 |
$attributes = $UsedProduct->getAttributes();
|
| 350 |
|
| 351 |
$ItemitemAttributes = "" ;
|
| 413 |
$ProducttoString .= "\t" . $this->cleanStr( $product->getShortDescription() ); //ShortDescription (Quick Overview)
|
| 414 |
//************************* Concatenate Product Info End ************************* cleanStr
|
| 415 |
}
|
| 416 |
+
unset($ProductDescription);
|
| 417 |
+
unset($ImageURL);
|
| 418 |
+
unset($product);
|
| 419 |
+
unset($ItemitemAttributes);
|
| 420 |
+
unset($CategoriesString);
|
| 421 |
+
unset($Reviews);
|
| 422 |
+
|
| 423 |
|
| 424 |
return $ProducttoString ;
|
| 425 |
}
|
| 437 |
$ProductDescription .= $product->getDescription() ;
|
| 438 |
//************************ Get Attributes Start *******************************
|
| 439 |
//Extract Attributes
|
| 440 |
+
|
|
|
|
| 441 |
$ImageURL = $this->mediaurl . "catalog/product" . $product->getImage();
|
| 442 |
|
| 443 |
//$excludeAttr = array() ;
|
| 473 |
|
| 474 |
|
| 475 |
//************************* Get Categories names Start ***************************
|
| 476 |
+
//Changed into 3.0.3 removed the category name
|
|
|
|
|
|
|
|
|
|
| 477 |
|
| 478 |
+
$CategoriesString = "" ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 479 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 480 |
//************************* Get Categories names End ***************************
|
| 481 |
|
| 482 |
//************************* Get Reviews Start ***********************
|
| 483 |
+
$Reviews = $this->enablereviews ? $this->getReviews($product->getId()) : '' ;
|
|
|
|
|
|
|
| 484 |
//************************* Get Reviews End *************************
|
| 485 |
|
| 486 |
//************************* Concatenate Product Info Start ***********************
|
| 504 |
$ProducttoString .= "\t" . $this->cleanStr( $product->getShortDescription() ); //ShortDescription (Quick Overview)
|
| 505 |
//************************* Concatenate Product Info End ************************* cleanStr
|
| 506 |
|
| 507 |
+
unset($ProductDescription);
|
| 508 |
+
unset($ImageURL);
|
| 509 |
+
unset($product);
|
| 510 |
+
unset($ItemitemAttributes);
|
| 511 |
+
unset($CategoriesString);
|
| 512 |
+
unset($Reviews);
|
| 513 |
+
|
| 514 |
return $ProducttoString ;
|
| 515 |
}
|
| 516 |
|
| 699 |
$Comment .= " Display after OR: ".$codafterOR." \r\n";
|
| 700 |
$Comment .= " Display before Quick Overview: ".$codbeforeoverview." \r\n";
|
| 701 |
$Comment .= " Display after Quick Overview: ".$codafteroverview." \r\n";
|
| 702 |
+
|
|
|
|
|
|
|
| 703 |
//Change for site url
|
| 704 |
$siteurl = Mage::getUrl('/');
|
| 705 |
$Comment .="Site Url: ".$siteurl."\r\n";
|
| 706 |
+
$datafilelaunch = Mage::getStoreConfig('codi/codi/coddatafilelaunch');
|
| 707 |
if($datafilelaunch=='magento')
|
| 708 |
{
|
| 709 |
$datafilelaunch='cronjob';
|
| 710 |
|
| 711 |
}
|
| 712 |
|
| 713 |
+
//code for version 2.2.16
|
| 714 |
+
|
| 715 |
+
$Comment .="Data File Launch Mode: ".$datafilelaunch."\r\n";
|
| 716 |
|
| 717 |
$url = Mage::getUrl('codi/nsync') ;
|
| 718 |
$pos = strrpos ($url , 'key') ;
|
| 721 |
else
|
| 722 |
$cronjoburl = $url;
|
| 723 |
|
| 724 |
+
if(($datafilelaunch=='cronjob') || ($datafilelaunch=='manual'))
|
| 725 |
{
|
| 726 |
$Comment .="Cron job command: wget ".$cronjoburl."\r\n";
|
| 727 |
}
|
| 760 |
|
| 761 |
Mage::log("Notice : Codi Import Start", null, $this->_logFile);
|
| 762 |
|
| 763 |
+
ini_set('memory_limit','1024M');
|
| 764 |
|
| 765 |
$this->InitImportStatuses();
|
| 766 |
|
| 767 |
+
$fh = fopen($basePath.'CoDzip/CoDfiles/temp.txt', 'w');
|
| 768 |
|
| 769 |
if ( !$fh )
|
| 770 |
{
|
| 806 |
{
|
| 807 |
Mage::log("Notice : Codi Import Products Exception :".$e->getMessage(), null, $this->_logFile);
|
| 808 |
}
|
| 809 |
+
//clean up the memory
|
| 810 |
+
unset($product);
|
| 811 |
+
unset($prodIds);
|
| 812 |
+
unset($products);
|
| 813 |
+
|
| 814 |
fclose($fh);
|
| 815 |
Mage::log("Notice : Codi Import End : ".$status, null, $this->_logFile);
|
| 816 |
|
| 818 |
$this->addImportStatus($status, 1);
|
| 819 |
|
| 820 |
}
|
| 821 |
+
//code for create CatalogSection.txt
|
| 822 |
+
public function createCatalogSection()
|
| 823 |
+
{
|
| 824 |
+
Mage::log("Notice : Create Catalog Section Start: ", null, $this->_logFile);
|
| 825 |
+
|
| 826 |
+
$helper=Mage::helper('codi');
|
| 827 |
+
$dir = dirname(__FILE__);
|
| 828 |
+
$_baseDirArray = explode("app", $dir);
|
| 829 |
+
$basePath = $_baseDirArray[0];
|
| 830 |
+
$progress=100;
|
| 831 |
+
/*
|
| 832 |
+
//Create object for Codi Model
|
| 833 |
+
//Create table Codi Catalog Section for insert category hirarchy path
|
| 834 |
+
*/
|
| 835 |
+
$catalogSectionModel=Mage::getModel('codi/codi');
|
| 836 |
+
$catalogSectionModel->InitCatalogSectionTable();
|
| 837 |
+
|
| 838 |
+
$collection = Mage::getModel('catalog/category')->getCollection()
|
| 839 |
+
->setStoreId('1')
|
| 840 |
+
->addAttributeToSelect('name')
|
| 841 |
+
->addAttributeToSelect('is_active')
|
| 842 |
+
->addAttributeToFilter('level', array('eq' => 2))
|
| 843 |
+
->addAttributeToFilter('is_active', array('eq' => 1))
|
| 844 |
+
->addAttributeToSort('position', 'asc');
|
| 845 |
+
//echo $collection->getSelect();
|
| 846 |
+
|
| 847 |
+
|
| 848 |
+
$i=1;
|
| 849 |
+
$count=count($collection);
|
| 850 |
+
if($count>0)
|
| 851 |
+
{
|
| 852 |
+
|
| 853 |
+
foreach($collection as $category)
|
| 854 |
+
{
|
| 855 |
+
$name=$category->getName();
|
| 856 |
+
$id=$category->getId();
|
| 857 |
+
$file = $basePath.'/CoDzip/CoDfiles/CatalogSection.txt';
|
| 858 |
+
file_put_contents($file,"sec_Project\tsec_Sequence\tsec_HierarchyPath\tsec_Flag\n");
|
| 859 |
+
$stringe.=$helper->drawItem($category,1,$name,$i);
|
| 860 |
+
file_put_contents($file,$stringe,FILE_APPEND);
|
| 861 |
+
$i++;
|
| 862 |
+
}
|
| 863 |
+
}
|
| 864 |
+
if($count==0)
|
| 865 |
+
{
|
| 866 |
+
$progress=0;
|
| 867 |
+
}
|
| 868 |
+
|
| 869 |
+
//clean up the memory
|
| 870 |
+
unset($catalogSectionModel);
|
| 871 |
+
unset($collection);
|
| 872 |
+
unset($stringe);
|
| 873 |
+
|
| 874 |
+
Mage::log("Notice : Create Catalog Section End: ", null, $this->_logFile);
|
| 875 |
+
return $progress;
|
| 876 |
+
}
|
| 877 |
+
//code for create Catalog Project
|
| 878 |
+
public function createCatalogProject($fromcron=0)
|
| 879 |
+
{
|
| 880 |
+
$dir = dirname(__FILE__);
|
| 881 |
+
$_baseDirArray = explode("app", $dir);
|
| 882 |
+
$basePath = $_baseDirArray[0];
|
| 883 |
+
Mage::log("Notice : Create Catalog Project Start", null, $this->_logFile);
|
| 884 |
+
|
| 885 |
+
ini_set('memory_limit','1024M');
|
| 886 |
+
|
| 887 |
+
$this->InitImportStatuses();
|
| 888 |
+
|
| 889 |
+
$fh = fopen($basePath.'CoDzip/CoDfiles/CatalogProject.txt', 'w');
|
| 890 |
+
|
| 891 |
+
if ( !$fh )
|
| 892 |
+
{
|
| 893 |
+
Mage::log("ERROR : Cann't open file for building data file:".$basePath, null, $this->_logFile);
|
| 894 |
+
return;
|
| 895 |
+
}
|
| 896 |
+
|
| 897 |
+
fwrite($fh, "proj_Key\tproj_ProdName\tproj_Sequence\tproj_Name\tproj_HierarchyPath\tproj_Flag\tproj_ProdLayout");
|
| 898 |
+
|
| 899 |
+
$products = Mage::getModel('catalog/product')->getCollection();
|
| 900 |
+
$products->addAttributeToFilter('status', 1);//enabled
|
| 901 |
+
$products->addAttributeToFilter('visibility', 4);//catalog, search
|
| 902 |
+
$products->addAttributeToSelect('*');
|
| 903 |
+
|
| 904 |
+
$prodIds = $products->getAllIds();
|
| 905 |
+
$totalproduct=count($prodIds);
|
| 906 |
+
$this->addImportStatus("start");
|
| 907 |
+
|
| 908 |
+
$status = "end";
|
| 909 |
+
$i='0';
|
| 910 |
+
|
| 911 |
+
try{
|
| 912 |
+
|
| 913 |
+
foreach($prodIds as $productId)
|
| 914 |
+
{
|
| 915 |
+
set_time_limit(20);
|
| 916 |
+
$message = $this->getImportStatuses();
|
| 917 |
+
if ( isset($message) && $message['message'] == "cancel") {
|
| 918 |
+
$status = "cancel";
|
| 919 |
+
break;
|
| 920 |
+
}
|
| 921 |
+
$product = Mage::getModel('catalog/product');
|
| 922 |
+
$product->load($productId);
|
| 923 |
+
Mage::log("Notice : Codi Import Products :".$i, null, $this->_logFile);
|
| 924 |
+
fwrite($fh, $this->CatalogProjucttoString($product, "product"));
|
| 925 |
+
$i++;
|
| 926 |
+
|
| 927 |
+
}
|
| 928 |
+
//Change for zip code if not call from cronjob
|
| 929 |
+
if($fromcron==0)
|
| 930 |
+
{
|
| 931 |
+
$DataFile = 'CoDMagento';
|
| 932 |
+
Mage::helper('codi/createzip')->createimportzip($DataFile);
|
| 933 |
+
}
|
| 934 |
+
}
|
| 935 |
+
catch (Exception $e)
|
| 936 |
+
{
|
| 937 |
+
return 'error';
|
| 938 |
+
Mage::log("Notice : Codi Catalog Project Exception :".$e->getMessage(), null, $this->_logFile);
|
| 939 |
+
}
|
| 940 |
+
//clean up the memory
|
| 941 |
+
unset($products);
|
| 942 |
+
unset($prodIds);
|
| 943 |
+
unset($product);
|
| 944 |
+
fclose($fh);
|
| 945 |
+
$progress='10';
|
| 946 |
+
Mage::log("Notice :Codi Catalog Project End : ".$status, null, $this->_logFile);
|
| 947 |
+
|
| 948 |
+
return $progress;
|
| 949 |
+
}
|
| 950 |
+
//Code for Catalog projuct section
|
| 951 |
+
public function CatalogProjucttoString( $product , $from )
|
| 952 |
+
{
|
| 953 |
+
|
| 954 |
+
if( $product->isConfigurable() )
|
| 955 |
+
{
|
| 956 |
+
return $this->ProjucttoStringConfigurable( $product , $from ) ;
|
| 957 |
+
}
|
| 958 |
+
else
|
| 959 |
+
{
|
| 960 |
+
return $this->ProjucttoStringSimple( $product , $from ) ;
|
| 961 |
+
}
|
| 962 |
+
}
|
| 963 |
+
|
| 964 |
+
public function ProjucttoStringConfigurable( $product , $from )
|
| 965 |
+
{
|
| 966 |
+
//get All associated products
|
| 967 |
+
$UsedProductIds = Mage::getModel('catalog/product_type_configurable')->getUsedProductIds($product);
|
| 968 |
+
$countUsedProductIds=count($UsedProductIds);
|
| 969 |
+
if($countUsedProductIds>0)
|
| 970 |
+
{
|
| 971 |
+
ini_set('memory_limit','1024M');
|
| 972 |
+
$ProducttoString = '' ;
|
| 973 |
+
//************************* Get Categories names Start ***************************
|
| 974 |
+
$categories = $product->getCategoryIds();
|
| 975 |
+
$CategoriesString = "" ;
|
| 976 |
+
$helper=Mage::helper('codi');
|
| 977 |
+
$catelogSectionModel=Mage::getModel('codi/codi');
|
| 978 |
+
foreach($categories as $k => $_category_id){
|
| 979 |
+
set_time_limit(20);
|
| 980 |
+
$_cat = Mage::getModel('catalog/category')->load($_category_id);
|
| 981 |
+
if(($_cat->getName() != '') && ($_cat->getIsActive() == 1) && ($_cat->getName() != 'Root Catalog') && ((string)$_cat->getLevel() != '1') && ($_cat->getParentId() > 1 ) )
|
| 982 |
+
{
|
| 983 |
+
$data=$catelogSectionModel->isCatalogSectionStart($_category_id);
|
| 984 |
+
$CategoriesString=$data['category_hirarchy_path'];
|
| 985 |
+
//code for product position
|
| 986 |
+
$position=$helper->productPostion($_category_id,$product->getId());
|
| 987 |
+
if ($CategoriesString==false) $CategoriesString = 'Uncategorized' ;
|
| 988 |
+
//************************* Concatenate Product Info Start ***********************
|
| 989 |
+
$ProducttoString .= "\r\n" . $product->getId().'#$#'. $this->cleanStr( $product->getName()); //ProductKey
|
| 990 |
+
$ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //Product Name
|
| 991 |
+
$ProducttoString .= "\t" . $this->cleanStr( $position ) ; //Prod Sequence
|
| 992 |
+
$ProducttoString .= "\t" . $this->cleanStr('Magento'); //Proj Name
|
| 993 |
+
$ProducttoString .= "\t" . $this->cleanStr( $CategoriesString ); //Hirarachi Path
|
| 994 |
+
$ProducttoString .= "\t" . $this->cleanStr('');//Proj Flag
|
| 995 |
+
$ProducttoString .= "\t" . $this->cleanStr(''); //Proj Prod layout
|
| 996 |
+
//************************* Concatenate Product Info End ************************* cleanStr
|
| 997 |
+
|
| 998 |
+
}
|
| 999 |
+
}
|
| 1000 |
+
//Clean up
|
| 1001 |
+
unset($categories);
|
| 1002 |
+
unset($catelogSectionModel);
|
| 1003 |
+
unset($CategoriesString);
|
| 1004 |
+
unset($position);
|
| 1005 |
+
unset($product);
|
| 1006 |
+
}
|
| 1007 |
+
else
|
| 1008 |
+
{
|
| 1009 |
+
$ProducttoString='';
|
| 1010 |
+
}
|
| 1011 |
+
|
| 1012 |
+
|
| 1013 |
+
return $ProducttoString ;
|
| 1014 |
+
}
|
| 1015 |
+
|
| 1016 |
+
/////////////////////////////////////////// Simple Products ///////////////////////////////////////////////////////////////////
|
| 1017 |
+
public function ProjucttoStringSimple( $product , $from )
|
| 1018 |
+
{
|
| 1019 |
+
ini_set('memory_limit','1024M');
|
| 1020 |
+
$ProducttoString = '' ;
|
| 1021 |
+
//************************* Get Categories names Start ***************************
|
| 1022 |
+
$categories = $product->getCategoryIds();
|
| 1023 |
+
$CategoriesString = "" ;
|
| 1024 |
+
$catelogSectionModel=Mage::getModel('codi/codi');
|
| 1025 |
+
$helper=Mage::helper('codi');
|
| 1026 |
+
foreach($categories as $k => $_category_id){
|
| 1027 |
+
set_time_limit(20);
|
| 1028 |
+
//Code for add category hirarchi_path
|
| 1029 |
+
$_cat = Mage::getModel('catalog/category')->load($_category_id);
|
| 1030 |
+
if(($_cat->getName() != '') && ($_cat->getIsActive() == 1) && ($_cat->getName() != 'Root Catalog') && ((string)$_cat->getLevel() != '1') && ($_cat->getParentId() > 1 ) )
|
| 1031 |
+
{
|
| 1032 |
+
$data=$catelogSectionModel->isCatalogSectionStart($_category_id);
|
| 1033 |
+
$CategoriesString=$data['category_hirarchy_path'];
|
| 1034 |
+
//code for product position
|
| 1035 |
+
$position=$helper->productPostion($_category_id,$product->getId());
|
| 1036 |
+
|
| 1037 |
+
if ($CategoriesString == false ) $CategoriesString = 'Uncategorized' ;
|
| 1038 |
+
//************************* Concatenate Product Info Start ***********************
|
| 1039 |
+
$ProducttoString .= "\r\n" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //ProductKey
|
| 1040 |
+
$ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //Product Name
|
| 1041 |
+
$ProducttoString .= "\t" . $this->cleanStr($position) ; //Prod Sequence
|
| 1042 |
+
$ProducttoString .= "\t" . $this->cleanStr('Magento'); //Proj Name
|
| 1043 |
+
$ProducttoString .= "\t" . $this->cleanStr( $CategoriesString ); //Hirarachi Path
|
| 1044 |
+
$ProducttoString .= "\t" . $this->cleanStr('');//Proj Flag
|
| 1045 |
+
$ProducttoString .= "\t" . $this->cleanStr(''); //Proj Prod layout
|
| 1046 |
+
//************************* Concatenate Product Info End ************************* cleanStr
|
| 1047 |
+
}
|
| 1048 |
+
}
|
| 1049 |
+
//Clean up
|
| 1050 |
+
unset($categories);
|
| 1051 |
+
unset($catelogSectionModel);
|
| 1052 |
+
unset($CategoriesString);
|
| 1053 |
+
unset($position);
|
| 1054 |
+
unset($product);
|
| 1055 |
+
|
| 1056 |
+
return $ProducttoString ;
|
| 1057 |
+
}
|
| 1058 |
+
//Functions for Codi CatalogSection Table
|
| 1059 |
+
public function InitCatalogSectionTable(){
|
| 1060 |
+
|
| 1061 |
+
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 1062 |
+
|
| 1063 |
+
$write->query("DROP TABLE IF EXISTS codi_catalog_section");
|
| 1064 |
+
$write->query("CREATE TABLE codi_catalog_section(
|
| 1065 |
+
category_id int(11) NOT NULL PRIMARY KEY,
|
| 1066 |
+
category_hirarchy_path text)"
|
| 1067 |
+
);
|
| 1068 |
+
}
|
| 1069 |
+
|
| 1070 |
+
public function existCatalogSectionTable(){
|
| 1071 |
+
|
| 1072 |
+
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 1073 |
+
|
| 1074 |
+
$write->query("CREATE TABLE IF NOT EXISTS codi_catalog_section(
|
| 1075 |
+
category_id int(11) NOT NULL PRIMARY KEY,
|
| 1076 |
+
category_hirarchy_path text)"
|
| 1077 |
+
);
|
| 1078 |
+
|
| 1079 |
+
}
|
| 1080 |
+
|
| 1081 |
+
public function addCatalogSection( $category_id=1, $category_hirarchy_path = 'uncategorized' ){
|
| 1082 |
+
|
| 1083 |
+
$this->existCatalogSectionTable();
|
| 1084 |
+
|
| 1085 |
+
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 1086 |
+
$query = "insert into codi_catalog_section (category_id, category_hirarchy_path) values('".$category_id."', '".$category_hirarchy_path."')";
|
| 1087 |
+
$write->query($query);
|
| 1088 |
+
}
|
| 1089 |
+
public function deleteCatalogSectionTable(){
|
| 1090 |
+
|
| 1091 |
+
$this->existCatalogSectionTable();
|
| 1092 |
+
|
| 1093 |
+
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 1094 |
+
$query = "delete from codi_catalog_section";
|
| 1095 |
+
$write->query($query);
|
| 1096 |
+
}
|
| 1097 |
+
|
| 1098 |
+
public function isCatalogSectionStart($category_id=1){
|
| 1099 |
+
|
| 1100 |
+
$this->existCatalogSectionTable();
|
| 1101 |
+
|
| 1102 |
+
$read= Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 1103 |
+
|
| 1104 |
+
$query = "select category_hirarchy_path from codi_catalog_section where category_id = '".$category_id."' order by category_id desc limit 1";
|
| 1105 |
+
|
| 1106 |
+
$result = $read->query($query);
|
| 1107 |
+
|
| 1108 |
+
if($row = $result->fetch() ){
|
| 1109 |
+
|
| 1110 |
+
return $row;
|
| 1111 |
+
}
|
| 1112 |
+
|
| 1113 |
+
return false;
|
| 1114 |
+
}
|
| 1115 |
+
|
| 1116 |
+
|
| 1117 |
|
| 1118 |
}
|
app/code/community/Mage/Codi/controllers/Adminhtml/MenuController.php
CHANGED
|
@@ -1,324 +1,327 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
ini_set("max_execution_time", 3600);
|
| 3 |
-
ini_set('session.gc_maxlifetime', 3600);
|
| 4 |
-
ini_set("memory_limit","512M");
|
| 5 |
-
|
| 6 |
-
class Mage_Codi_Adminhtml_MenuController extends Mage_Adminhtml_Controller_Action
|
| 7 |
-
{
|
| 8 |
-
|
| 9 |
-
public $CodiBlock ;
|
| 10 |
-
|
| 11 |
-
protected function _construct()
|
| 12 |
-
{
|
| 13 |
-
$this->CodiBlock = $this->getLayout()->createBlock('codi/customer_codi');
|
| 14 |
-
$this->_logFile = "Catalog-on-demand.log";
|
| 15 |
-
}
|
| 16 |
-
|
| 17 |
-
public function indexAction()
|
| 18 |
-
{
|
| 19 |
-
$this->loadLayout();
|
| 20 |
-
$this->_setActiveMenu('catalog');
|
| 21 |
-
$this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
|
| 22 |
-
$this->renderLayout();
|
| 23 |
-
}
|
| 24 |
-
|
| 25 |
-
public function authAction()
|
| 26 |
-
{
|
| 27 |
-
$codimodel = Mage::getSingleton('codi/codi');
|
| 28 |
-
$codimodel->target = "auth";
|
| 29 |
-
$this->loadLayout();
|
| 30 |
-
$this->_setActiveMenu('catalog');
|
| 31 |
-
$this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
|
| 32 |
-
$this->renderLayout();
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
public function systemtestAction(){
|
| 36 |
-
|
| 37 |
-
$codimodel = Mage::getSingleton('codi/codi');
|
| 38 |
-
$codimodel->target = "systemtest";
|
| 39 |
-
$this->loadLayout();
|
| 40 |
-
$this->_setActiveMenu('catalog');
|
| 41 |
-
$this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
|
| 42 |
-
$this->renderLayout();
|
| 43 |
-
}
|
| 44 |
-
|
| 45 |
-
public function createAction(){
|
| 46 |
-
|
| 47 |
-
$codimodel = Mage::getSingleton('codi/codi');
|
| 48 |
-
$codimodel->target = "create";
|
| 49 |
-
$this->loadLayout();
|
| 50 |
-
$this->_setActiveMenu('catalog');
|
| 51 |
-
$this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
|
| 52 |
-
$this->renderLayout();
|
| 53 |
-
}
|
| 54 |
-
|
| 55 |
-
public function createfileAction(){
|
| 56 |
-
|
| 57 |
-
$codimodel = Mage::getSingleton('codi/codi');
|
| 58 |
-
|
| 59 |
-
$dir = dirname(__FILE__);
|
| 60 |
-
|
| 61 |
-
$_baseDirArray = explode("app", $dir);
|
| 62 |
-
$basePath = $_baseDirArray[0].'/';
|
| 63 |
-
|
| 64 |
-
if ( !$codimodel->createFile($basePath) ){
|
| 65 |
-
Mage::log("ERROR : Cannot create file : ".$basePath, null, $this->_logFile);
|
| 66 |
-
print '{"error": "1"}';
|
| 67 |
-
return;
|
| 68 |
-
}
|
| 69 |
-
|
| 70 |
-
$is_process = $this->getRequest()->getParam('is_process');
|
| 71 |
-
|
| 72 |
-
Mage::log("Notice: Mage_Codi_MenuController Process : ".$is_process, null, $this->_logFile);
|
| 73 |
-
|
| 74 |
-
if ( $is_process == 1 ){
|
| 75 |
-
|
| 76 |
-
if( false !== strpos(ini_get("disable_functions"), "exec") ) {
|
| 77 |
-
|
| 78 |
-
$this->bgCheckSave();
|
| 79 |
-
|
| 80 |
-
print '{"exec": "1"}';
|
| 81 |
-
|
| 82 |
-
}else if ( false !== strpos(ini_get("disable_functions"), "shell_exec") ){
|
| 83 |
-
|
| 84 |
-
$this->bgCheckSave();
|
| 85 |
-
|
| 86 |
-
print '{"shellexec": "1"}';
|
| 87 |
-
}else{
|
| 88 |
-
|
| 89 |
-
$output = shell_exec("ps ax | grep php");
|
| 90 |
-
|
| 91 |
-
Mage::log("Notice: Mage_Codi_MenuController Process : ".$output, null, $this->_logFile);
|
| 92 |
-
|
| 93 |
-
if ( strpos($output, "php5") !== false ){
|
| 94 |
-
exec("nohup php5 ".$dir."/../../Codi_Process.php > /dev/null & echo $!");
|
| 95 |
-
Mage::log("Notice: Mage_Codi_MenuController Process : php5 ", null, $this->_logFile);
|
| 96 |
-
}else{
|
| 97 |
-
exec("nohup php ".$dir."/../../Codi_Process.php > /dev/null & echo $!");
|
| 98 |
-
Mage::log("Notice: Mage_Codi_MenuController Process : php ", null, $this->_logFile);
|
| 99 |
-
}
|
| 100 |
-
|
| 101 |
-
$codimodel->addImportStatus('auto', 0);
|
| 102 |
-
Mage::log("Notice: Mage_Codi_MenuController Process : auto ", null, $this->_logFile);
|
| 103 |
-
|
| 104 |
-
print '{"success": "1"}';
|
| 105 |
-
}
|
| 106 |
-
}
|
| 107 |
-
else{
|
| 108 |
-
|
| 109 |
-
$codimodel->addImportStatus('manual', 0);
|
| 110 |
-
|
| 111 |
-
print '{"success": "1"}';
|
| 112 |
-
|
| 113 |
-
}
|
| 114 |
-
}
|
| 115 |
-
|
| 116 |
-
public function cancelAction(){
|
| 117 |
-
|
| 118 |
-
$codimodel = Mage::getSingleton('codi/codi');
|
| 119 |
-
$codimodel->addImportStatus('cancel', 1);
|
| 120 |
-
|
| 121 |
-
print "cancel";
|
| 122 |
-
}
|
| 123 |
-
|
| 124 |
-
public function updatestatusAction()
|
| 125 |
-
{
|
| 126 |
-
$codimodel = Mage::getSingleton('codi/codi');
|
| 127 |
-
$message = $codimodel->getImportStatuses();
|
| 128 |
-
|
| 129 |
-
$dir = dirname(__FILE__);
|
| 130 |
-
$_baseDirArray = explode("app", $dir);
|
| 131 |
-
$basePath = $_baseDirArray[0].'/';
|
| 132 |
-
|
| 133 |
-
$status = 0;
|
| 134 |
-
if ( isset($message) ){
|
| 135 |
-
|
| 136 |
-
$status = $message['message'];
|
| 137 |
-
|
| 138 |
-
if ( $status== "end" && $message['finished'] == 1 ){
|
| 139 |
-
|
| 140 |
-
@unlink($basePath."
|
| 141 |
-
$codimodel->deleteTable();
|
| 142 |
-
print '{"finished": "1"}';
|
| 143 |
-
|
| 144 |
-
}else if ( $status== "cancel" && $message['finished'] == 1 ) {
|
| 145 |
-
|
| 146 |
-
@unlink($basePath."
|
| 147 |
-
$codimodel->deleteTable();
|
| 148 |
-
print '{"canceled": "1"}';
|
| 149 |
-
|
| 150 |
-
}else if ( $status== "start" && $message['finished'] == 0 ) {
|
| 151 |
-
|
| 152 |
-
print '{"processed": "1"}';
|
| 153 |
-
|
| 154 |
-
}else if ( $status== "fileerror" && $message['finished'] == 1 ) {
|
| 155 |
-
|
| 156 |
-
@unlink($basePath."
|
| 157 |
-
$codimodel->deleteTable();
|
| 158 |
-
print '{"fileerror": "1"}';
|
| 159 |
-
|
| 160 |
-
}else if ( $status== "manual" && $message['finished'] == 0 ) {
|
| 161 |
-
|
| 162 |
-
print '{"processed": "1"}';
|
| 163 |
-
$codimodel->run_codi_import_manually($basePath);
|
| 164 |
-
|
| 165 |
-
}else if ( $status== "auto" && $message['finished'] == 0 ){
|
| 166 |
-
if ( !$codimodel->isStart() ){
|
| 167 |
-
@unlink($basePath."
|
| 168 |
-
$codimodel->deleteTable();
|
| 169 |
-
print '{"error": "1"}';
|
| 170 |
-
}
|
| 171 |
-
}
|
| 172 |
-
}
|
| 173 |
-
}
|
| 174 |
-
|
| 175 |
-
public function bgcheckAction(){
|
| 176 |
-
|
| 177 |
-
$checked = $this->getRequest()->getParam('check');
|
| 178 |
-
|
| 179 |
-
$this->bgCheckSave($checked);
|
| 180 |
-
}
|
| 181 |
-
|
| 182 |
-
public function bgCheckSave($checked=0){
|
| 183 |
-
|
| 184 |
-
$codimodel = Mage::getSingleton('codi/codi');
|
| 185 |
-
|
| 186 |
-
$codimodel->setStoreConfig(
|
| 187 |
-
array(
|
| 188 |
-
"codbgcheck" => array ('value' => $checked)
|
| 189 |
-
)
|
| 190 |
-
);
|
| 191 |
-
|
| 192 |
-
Mage::app()->getCacheInstance()->cleanType('config');
|
| 193 |
-
}
|
| 194 |
-
|
| 195 |
-
public function authsaveAction()
|
| 196 |
-
{
|
| 197 |
-
$userid = strtolower((string)$this->getRequest()->getParam('userid'));
|
| 198 |
-
$password = (string)$this->getRequest()->getParam('password');
|
| 199 |
-
$secretkey = (string)$this->getRequest()->getParam('secretkey');
|
| 200 |
-
$enablefreshflyers = (string)$this->getRequest()->getParam('enablefreshflyers');
|
| 201 |
-
$enablereviews = (string)$this->getRequest()->getParam('enablereviews');
|
| 202 |
-
$fromchild = (string)$this->getRequest()->getParam('fromchild');
|
| 203 |
-
|
| 204 |
-
$codflyerlinkimg = (string)$this->getRequest()->getParam('codflyerlinkimg');
|
| 205 |
-
$codflyerlinkimgurl = (string)$this->getRequest()->getParam('codflyerlinkimgurl');
|
| 206 |
-
$codflyerlinkimgalt = (string)$this->getRequest()->getParam('codflyerlinkimgalt');
|
| 207 |
-
|
| 208 |
-
$codbeforename = (string)$this->getRequest()->getParam('codbeforename');
|
| 209 |
-
$codaftername = (string)$this->getRequest()->getParam('codaftername');
|
| 210 |
-
|
| 211 |
-
$codbeforeemailto = (string)$this->getRequest()->getParam('codbeforeemailto');
|
| 212 |
-
$codafteremailto = (string)$this->getRequest()->getParam('codafteremailto');
|
| 213 |
-
|
| 214 |
-
$codbeforeOR = (string)$this->getRequest()->getParam('codbeforeOR');
|
| 215 |
-
$codafterOR = (string)$this->getRequest()->getParam('codafterOR');
|
| 216 |
-
|
| 217 |
-
$codbeforeoverview = (string)$this->getRequest()->getParam('codbeforeoverview');
|
| 218 |
-
$codafteroverview = (string)$this->getRequest()->getParam('codafteroverview');
|
| 219 |
-
|
| 220 |
-
//ver 2.2.16
|
| 221 |
-
$coddatafilelaunch = (string)$this->getRequest()->getParam('datafilelaunch');
|
| 222 |
-
//for waitfor minute
|
| 223 |
-
|
| 224 |
-
$waitforminute = (string)$this->getRequest()->getParam('waitforminute');
|
| 225 |
-
$includeshortdescription = (string)$this->getRequest()->getParam('includeshortdescription');
|
| 226 |
-
|
| 227 |
-
//Code for Tier pricing
|
| 228 |
-
$codpublishtieredpricing=(string)$this->getRequest()->getParam('publishtieredpricing');
|
| 229 |
-
$codquantity=(string)$this->getRequest()->getParam('codquantity');
|
| 230 |
-
$codprice=(string)$this->getRequest()->getParam('codprice');
|
| 231 |
-
$codsavings=(string)$this->getRequest()->getParam('codsavings');
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
$codimodel = Mage::getSingleton('codi/codi');
|
| 235 |
-
|
| 236 |
-
$codimodel->setStoreConfig(
|
| 237 |
-
array(
|
| 238 |
-
"codusername" => array ('value' => $userid) ,
|
| 239 |
-
"codpassword" => array ('value' => $password) ,
|
| 240 |
-
"secretkey" => array ('value' => $secretkey) ,
|
| 241 |
-
"enablefreshflyers" => array ('value' => $enablefreshflyers) ,
|
| 242 |
-
"codenablereviews" => array ('value' => $enablereviews) ,
|
| 243 |
-
"fromchild" => array ('value' => $fromchild) ,
|
| 244 |
-
"codflyerlinkimg" => array ('value' => $codflyerlinkimg) ,
|
| 245 |
-
"codflyerlinkimgurl" => array ('value' => $codflyerlinkimgurl) ,
|
| 246 |
-
"codflyerlinkimgalt" => array ('value' => $codflyerlinkimgalt) ,
|
| 247 |
-
"codbeforename" => array ('value' => $codbeforename) ,
|
| 248 |
-
"codaftername" => array ('value' => $codaftername) ,
|
| 249 |
-
"codbeforeemailto" => array ('value' => $codbeforeemailto) ,
|
| 250 |
-
"codafteremailto" => array ('value' => $codafteremailto) ,
|
| 251 |
-
"codbeforeOR" => array ('value' => $codbeforeOR) ,
|
| 252 |
-
"codafterOR" => array ('value' => $codafterOR) ,
|
| 253 |
-
"codbeforeoverview" => array ('value' => $codbeforeoverview) ,
|
| 254 |
-
"codafteroverview" => array ('value' => $codafteroverview) ,
|
| 255 |
-
"coddatafilelaunch" => array ('value' => $coddatafilelaunch) ,
|
| 256 |
-
"codwaitforminute" => array ('value' => $waitforminute),
|
| 257 |
-
"codincludeshortdescription" => array ('value' => $includeshortdescription),
|
| 258 |
-
"codpublishtieredpricing" => array ('value' => $codpublishtieredpricing),
|
| 259 |
-
"codquantity" => array ('value' => $codquantity),
|
| 260 |
-
"codprice" => array ('value' => $codprice),
|
| 261 |
-
"codsavings" => array ('value' => $codsavings),
|
| 262 |
-
)
|
| 263 |
-
);
|
| 264 |
-
|
| 265 |
-
Mage::app()->getCacheInstance()->cleanType('config');
|
| 266 |
-
|
| 267 |
-
$this->_redirect('codi/adminhtml_menu/auth');
|
| 268 |
-
}
|
| 269 |
-
|
| 270 |
-
public function registerAction()
|
| 271 |
-
{
|
| 272 |
-
$codimodel = Mage::getSingleton('codi/codi');
|
| 273 |
-
$codimodel->target = "register";
|
| 274 |
-
$this->loadLayout();
|
| 275 |
-
$this->_setActiveMenu('catalog');
|
| 276 |
-
$this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
|
| 277 |
-
$this->renderLayout();
|
| 278 |
-
}
|
| 279 |
-
|
| 280 |
-
public function documentationAction()
|
| 281 |
-
{
|
| 282 |
-
$codimodel = Mage::getSingleton('codi/codi');
|
| 283 |
-
$codimodel->target = "documentation";
|
| 284 |
-
$this->loadLayout();
|
| 285 |
-
$this->_setActiveMenu('catalog');
|
| 286 |
-
$this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
|
| 287 |
-
$this->renderLayout();
|
| 288 |
-
}
|
| 289 |
-
|
| 290 |
-
//Change for version 2.2.15
|
| 291 |
-
public function downloadtestAction(){
|
| 292 |
-
|
| 293 |
-
$codimodel = Mage::getSingleton('codi/codi');
|
| 294 |
-
$codimodel->target = "auth";
|
| 295 |
-
$helper=Mage::helper('codi');
|
| 296 |
-
$filename='
|
| 297 |
-
|
| 298 |
-
$
|
| 299 |
-
$this->
|
| 300 |
-
$this->
|
| 301 |
-
$this->
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
$
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
$codimodel
|
| 313 |
-
$
|
| 314 |
-
$
|
| 315 |
-
|
| 316 |
-
$
|
| 317 |
-
$
|
| 318 |
-
$this->
|
| 319 |
-
$this->
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
ini_set("max_execution_time", 3600);
|
| 3 |
+
ini_set('session.gc_maxlifetime', 3600);
|
| 4 |
+
ini_set("memory_limit","512M");
|
| 5 |
+
|
| 6 |
+
class Mage_Codi_Adminhtml_MenuController extends Mage_Adminhtml_Controller_Action
|
| 7 |
+
{
|
| 8 |
+
|
| 9 |
+
public $CodiBlock ;
|
| 10 |
+
|
| 11 |
+
protected function _construct()
|
| 12 |
+
{
|
| 13 |
+
$this->CodiBlock = $this->getLayout()->createBlock('codi/customer_codi');
|
| 14 |
+
$this->_logFile = "Catalog-on-demand.log";
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
public function indexAction()
|
| 18 |
+
{
|
| 19 |
+
$this->loadLayout();
|
| 20 |
+
$this->_setActiveMenu('catalog');
|
| 21 |
+
$this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
|
| 22 |
+
$this->renderLayout();
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
public function authAction()
|
| 26 |
+
{
|
| 27 |
+
$codimodel = Mage::getSingleton('codi/codi');
|
| 28 |
+
$codimodel->target = "auth";
|
| 29 |
+
$this->loadLayout();
|
| 30 |
+
$this->_setActiveMenu('catalog');
|
| 31 |
+
$this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
|
| 32 |
+
$this->renderLayout();
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
public function systemtestAction(){
|
| 36 |
+
|
| 37 |
+
$codimodel = Mage::getSingleton('codi/codi');
|
| 38 |
+
$codimodel->target = "systemtest";
|
| 39 |
+
$this->loadLayout();
|
| 40 |
+
$this->_setActiveMenu('catalog');
|
| 41 |
+
$this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
|
| 42 |
+
$this->renderLayout();
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
public function createAction(){
|
| 46 |
+
|
| 47 |
+
$codimodel = Mage::getSingleton('codi/codi');
|
| 48 |
+
$codimodel->target = "create";
|
| 49 |
+
$this->loadLayout();
|
| 50 |
+
$this->_setActiveMenu('catalog');
|
| 51 |
+
$this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
|
| 52 |
+
$this->renderLayout();
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
public function createfileAction(){
|
| 56 |
+
|
| 57 |
+
$codimodel = Mage::getSingleton('codi/codi');
|
| 58 |
+
|
| 59 |
+
$dir = dirname(__FILE__);
|
| 60 |
+
|
| 61 |
+
$_baseDirArray = explode("app", $dir);
|
| 62 |
+
$basePath = $_baseDirArray[0].'/';
|
| 63 |
+
|
| 64 |
+
if ( !$codimodel->createFile($basePath) ){
|
| 65 |
+
Mage::log("ERROR : Cannot create file : ".$basePath, null, $this->_logFile);
|
| 66 |
+
print '{"error": "1"}';
|
| 67 |
+
return;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
$is_process = $this->getRequest()->getParam('is_process');
|
| 71 |
+
|
| 72 |
+
Mage::log("Notice: Mage_Codi_MenuController Process : ".$is_process, null, $this->_logFile);
|
| 73 |
+
|
| 74 |
+
if ( $is_process == 1 ){
|
| 75 |
+
|
| 76 |
+
if( false !== strpos(ini_get("disable_functions"), "exec") ) {
|
| 77 |
+
|
| 78 |
+
$this->bgCheckSave();
|
| 79 |
+
|
| 80 |
+
print '{"exec": "1"}';
|
| 81 |
+
|
| 82 |
+
}else if ( false !== strpos(ini_get("disable_functions"), "shell_exec") ){
|
| 83 |
+
|
| 84 |
+
$this->bgCheckSave();
|
| 85 |
+
|
| 86 |
+
print '{"shellexec": "1"}';
|
| 87 |
+
}else{
|
| 88 |
+
|
| 89 |
+
$output = shell_exec("ps ax | grep php");
|
| 90 |
+
|
| 91 |
+
Mage::log("Notice: Mage_Codi_MenuController Process : ".$output, null, $this->_logFile);
|
| 92 |
+
|
| 93 |
+
if ( strpos($output, "php5") !== false ){
|
| 94 |
+
exec("nohup php5 ".$dir."/../../Codi_Process.php > /dev/null & echo $!");
|
| 95 |
+
Mage::log("Notice: Mage_Codi_MenuController Process : php5 ", null, $this->_logFile);
|
| 96 |
+
}else{
|
| 97 |
+
exec("nohup php ".$dir."/../../Codi_Process.php > /dev/null & echo $!");
|
| 98 |
+
Mage::log("Notice: Mage_Codi_MenuController Process : php ", null, $this->_logFile);
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
$codimodel->addImportStatus('auto', 0);
|
| 102 |
+
Mage::log("Notice: Mage_Codi_MenuController Process : auto ", null, $this->_logFile);
|
| 103 |
+
|
| 104 |
+
print '{"success": "1"}';
|
| 105 |
+
}
|
| 106 |
+
}
|
| 107 |
+
else{
|
| 108 |
+
|
| 109 |
+
$codimodel->addImportStatus('manual', 0);
|
| 110 |
+
|
| 111 |
+
print '{"success": "1"}';
|
| 112 |
+
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
public function cancelAction(){
|
| 117 |
+
|
| 118 |
+
$codimodel = Mage::getSingleton('codi/codi');
|
| 119 |
+
$codimodel->addImportStatus('cancel', 1);
|
| 120 |
+
|
| 121 |
+
print "cancel";
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
public function updatestatusAction()
|
| 125 |
+
{
|
| 126 |
+
$codimodel = Mage::getSingleton('codi/codi');
|
| 127 |
+
$message = $codimodel->getImportStatuses();
|
| 128 |
+
|
| 129 |
+
$dir = dirname(__FILE__);
|
| 130 |
+
$_baseDirArray = explode("app", $dir);
|
| 131 |
+
$basePath = $_baseDirArray[0].'/';
|
| 132 |
+
|
| 133 |
+
$status = 0;
|
| 134 |
+
if ( isset($message) ){
|
| 135 |
+
|
| 136 |
+
$status = $message['message'];
|
| 137 |
+
|
| 138 |
+
if ( $status== "end" && $message['finished'] == 1 ){
|
| 139 |
+
|
| 140 |
+
@unlink($basePath."CoDZip/CoDfiles/temp.txt");
|
| 141 |
+
$codimodel->deleteTable();
|
| 142 |
+
print '{"finished": "1"}';
|
| 143 |
+
|
| 144 |
+
}else if ( $status== "cancel" && $message['finished'] == 1 ) {
|
| 145 |
+
|
| 146 |
+
@unlink($basePath."CoDZip/CoDfiles/temp.txt");
|
| 147 |
+
$codimodel->deleteTable();
|
| 148 |
+
print '{"canceled": "1"}';
|
| 149 |
+
|
| 150 |
+
}else if ( $status== "start" && $message['finished'] == 0 ) {
|
| 151 |
+
|
| 152 |
+
print '{"processed": "1"}';
|
| 153 |
+
|
| 154 |
+
}else if ( $status== "fileerror" && $message['finished'] == 1 ) {
|
| 155 |
+
|
| 156 |
+
@unlink($basePath."CoDZip/CoDfiles/temp.txt");
|
| 157 |
+
$codimodel->deleteTable();
|
| 158 |
+
print '{"fileerror": "1"}';
|
| 159 |
+
|
| 160 |
+
}else if ( $status== "manual" && $message['finished'] == 0 ) {
|
| 161 |
+
|
| 162 |
+
print '{"processed": "1"}';
|
| 163 |
+
$codimodel->run_codi_import_manually($basePath);
|
| 164 |
+
|
| 165 |
+
}else if ( $status== "auto" && $message['finished'] == 0 ){
|
| 166 |
+
if ( !$codimodel->isStart() ){
|
| 167 |
+
@unlink($basePath."CoDZip/CoDfiles/temp.txt");
|
| 168 |
+
$codimodel->deleteTable();
|
| 169 |
+
print '{"error": "1"}';
|
| 170 |
+
}
|
| 171 |
+
}
|
| 172 |
+
}
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
public function bgcheckAction(){
|
| 176 |
+
|
| 177 |
+
$checked = $this->getRequest()->getParam('check');
|
| 178 |
+
|
| 179 |
+
$this->bgCheckSave($checked);
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
public function bgCheckSave($checked=0){
|
| 183 |
+
|
| 184 |
+
$codimodel = Mage::getSingleton('codi/codi');
|
| 185 |
+
|
| 186 |
+
$codimodel->setStoreConfig(
|
| 187 |
+
array(
|
| 188 |
+
"codbgcheck" => array ('value' => $checked)
|
| 189 |
+
)
|
| 190 |
+
);
|
| 191 |
+
|
| 192 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
public function authsaveAction()
|
| 196 |
+
{
|
| 197 |
+
$userid = strtolower((string)$this->getRequest()->getParam('userid'));
|
| 198 |
+
$password = (string)$this->getRequest()->getParam('password');
|
| 199 |
+
$secretkey = (string)$this->getRequest()->getParam('secretkey');
|
| 200 |
+
$enablefreshflyers = (string)$this->getRequest()->getParam('enablefreshflyers');
|
| 201 |
+
$enablereviews = (string)$this->getRequest()->getParam('enablereviews');
|
| 202 |
+
$fromchild = (string)$this->getRequest()->getParam('fromchild');
|
| 203 |
+
|
| 204 |
+
$codflyerlinkimg = (string)$this->getRequest()->getParam('codflyerlinkimg');
|
| 205 |
+
$codflyerlinkimgurl = (string)$this->getRequest()->getParam('codflyerlinkimgurl');
|
| 206 |
+
$codflyerlinkimgalt = (string)$this->getRequest()->getParam('codflyerlinkimgalt');
|
| 207 |
+
|
| 208 |
+
$codbeforename = (string)$this->getRequest()->getParam('codbeforename');
|
| 209 |
+
$codaftername = (string)$this->getRequest()->getParam('codaftername');
|
| 210 |
+
|
| 211 |
+
$codbeforeemailto = (string)$this->getRequest()->getParam('codbeforeemailto');
|
| 212 |
+
$codafteremailto = (string)$this->getRequest()->getParam('codafteremailto');
|
| 213 |
+
|
| 214 |
+
$codbeforeOR = (string)$this->getRequest()->getParam('codbeforeOR');
|
| 215 |
+
$codafterOR = (string)$this->getRequest()->getParam('codafterOR');
|
| 216 |
+
|
| 217 |
+
$codbeforeoverview = (string)$this->getRequest()->getParam('codbeforeoverview');
|
| 218 |
+
$codafteroverview = (string)$this->getRequest()->getParam('codafteroverview');
|
| 219 |
+
|
| 220 |
+
//ver 2.2.16
|
| 221 |
+
$coddatafilelaunch = (string)$this->getRequest()->getParam('datafilelaunch');
|
| 222 |
+
//for waitfor minute
|
| 223 |
+
|
| 224 |
+
$waitforminute = (string)$this->getRequest()->getParam('waitforminute');
|
| 225 |
+
$includeshortdescription = (string)$this->getRequest()->getParam('includeshortdescription');
|
| 226 |
+
|
| 227 |
+
//Code for Tier pricing
|
| 228 |
+
$codpublishtieredpricing=(string)$this->getRequest()->getParam('publishtieredpricing');
|
| 229 |
+
$codquantity=(string)$this->getRequest()->getParam('codquantity');
|
| 230 |
+
$codprice=(string)$this->getRequest()->getParam('codprice');
|
| 231 |
+
$codsavings=(string)$this->getRequest()->getParam('codsavings');
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
$codimodel = Mage::getSingleton('codi/codi');
|
| 235 |
+
|
| 236 |
+
$codimodel->setStoreConfig(
|
| 237 |
+
array(
|
| 238 |
+
"codusername" => array ('value' => $userid) ,
|
| 239 |
+
"codpassword" => array ('value' => $password) ,
|
| 240 |
+
"secretkey" => array ('value' => $secretkey) ,
|
| 241 |
+
"enablefreshflyers" => array ('value' => $enablefreshflyers) ,
|
| 242 |
+
"codenablereviews" => array ('value' => $enablereviews) ,
|
| 243 |
+
"fromchild" => array ('value' => $fromchild) ,
|
| 244 |
+
"codflyerlinkimg" => array ('value' => $codflyerlinkimg) ,
|
| 245 |
+
"codflyerlinkimgurl" => array ('value' => $codflyerlinkimgurl) ,
|
| 246 |
+
"codflyerlinkimgalt" => array ('value' => $codflyerlinkimgalt) ,
|
| 247 |
+
"codbeforename" => array ('value' => $codbeforename) ,
|
| 248 |
+
"codaftername" => array ('value' => $codaftername) ,
|
| 249 |
+
"codbeforeemailto" => array ('value' => $codbeforeemailto) ,
|
| 250 |
+
"codafteremailto" => array ('value' => $codafteremailto) ,
|
| 251 |
+
"codbeforeOR" => array ('value' => $codbeforeOR) ,
|
| 252 |
+
"codafterOR" => array ('value' => $codafterOR) ,
|
| 253 |
+
"codbeforeoverview" => array ('value' => $codbeforeoverview) ,
|
| 254 |
+
"codafteroverview" => array ('value' => $codafteroverview) ,
|
| 255 |
+
"coddatafilelaunch" => array ('value' => $coddatafilelaunch) ,
|
| 256 |
+
"codwaitforminute" => array ('value' => $waitforminute),
|
| 257 |
+
"codincludeshortdescription" => array ('value' => $includeshortdescription),
|
| 258 |
+
"codpublishtieredpricing" => array ('value' => $codpublishtieredpricing),
|
| 259 |
+
"codquantity" => array ('value' => $codquantity),
|
| 260 |
+
"codprice" => array ('value' => $codprice),
|
| 261 |
+
"codsavings" => array ('value' => $codsavings),
|
| 262 |
+
)
|
| 263 |
+
);
|
| 264 |
+
|
| 265 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
| 266 |
+
|
| 267 |
+
$this->_redirect('codi/adminhtml_menu/auth');
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
public function registerAction()
|
| 271 |
+
{
|
| 272 |
+
$codimodel = Mage::getSingleton('codi/codi');
|
| 273 |
+
$codimodel->target = "register";
|
| 274 |
+
$this->loadLayout();
|
| 275 |
+
$this->_setActiveMenu('catalog');
|
| 276 |
+
$this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
|
| 277 |
+
$this->renderLayout();
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
public function documentationAction()
|
| 281 |
+
{
|
| 282 |
+
$codimodel = Mage::getSingleton('codi/codi');
|
| 283 |
+
$codimodel->target = "documentation";
|
| 284 |
+
$this->loadLayout();
|
| 285 |
+
$this->_setActiveMenu('catalog');
|
| 286 |
+
$this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
|
| 287 |
+
$this->renderLayout();
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
//Change for version 2.2.15
|
| 291 |
+
public function downloadtestAction(){
|
| 292 |
+
|
| 293 |
+
$codimodel = Mage::getSingleton('codi/codi');
|
| 294 |
+
$codimodel->target = "auth";
|
| 295 |
+
$helper=Mage::helper('codi');
|
| 296 |
+
$filename='CoDMagento.zip';
|
| 297 |
+
//Change for zip code
|
| 298 |
+
$helper->output_file('CoDzip/CoDMagento.zip',$filename , 'application/zip');
|
| 299 |
+
$this->loadLayout();
|
| 300 |
+
$this->_setActiveMenu('catalog');
|
| 301 |
+
$this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
|
| 302 |
+
$this->renderLayout();
|
| 303 |
+
}
|
| 304 |
+
public function deletetestAction()
|
| 305 |
+
{
|
| 306 |
+
$dir = dirname(__FILE__);
|
| 307 |
+
|
| 308 |
+
$_baseDirArray = explode("app", $dir);
|
| 309 |
+
$basePath = $_baseDirArray[0].'/';
|
| 310 |
+
|
| 311 |
+
|
| 312 |
+
$codimodel = Mage::getSingleton('codi/codi');
|
| 313 |
+
$codimodel->target = "auth";
|
| 314 |
+
$helper=Mage::helper('codi');
|
| 315 |
+
//change for zip file
|
| 316 |
+
$filename='/CoDzip/CoDMagento.zip';
|
| 317 |
+
$helper->deleteFile($basePath,$filename);
|
| 318 |
+
$this->loadLayout();
|
| 319 |
+
$this->_setActiveMenu('catalog');
|
| 320 |
+
$this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
|
| 321 |
+
$this->renderLayout();
|
| 322 |
+
$this->_redirect('codi/adminhtml_menu/auth');
|
| 323 |
+
|
| 324 |
+
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
}
|
app/code/community/Mage/Codi/controllers/DeleteController.php
CHANGED
|
@@ -1,22 +1,37 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
require_once 'Mage/Core/Controller/Front/Action.php';
|
| 3 |
-
class Mage_Codi_DeleteController extends Mage_Core_Controller_Front_Action
|
| 4 |
-
{
|
| 5 |
-
|
| 6 |
-
public function indexAction()
|
| 7 |
-
{
|
| 8 |
-
$this->_logFile = "Catalog-on-demand.log";
|
| 9 |
-
|
| 10 |
-
Mage::log("Notice : Mage_Codi_DeleteController", null, $this->_logFile);
|
| 11 |
-
|
| 12 |
-
$dir = dirname(__FILE__);
|
| 13 |
-
$_baseDirArray = explode("app", $dir);
|
| 14 |
-
$basePath = $_baseDirArray[0]
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
$files = glob($basePath."
|
| 18 |
-
foreach($files as $file)
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
require_once 'Mage/Core/Controller/Front/Action.php';
|
| 3 |
+
class Mage_Codi_DeleteController extends Mage_Core_Controller_Front_Action
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
public function indexAction()
|
| 7 |
+
{
|
| 8 |
+
$this->_logFile = "Catalog-on-demand.log";
|
| 9 |
+
|
| 10 |
+
Mage::log("Notice : Mage_Codi_DeleteController", null, $this->_logFile);
|
| 11 |
+
|
| 12 |
+
$dir = dirname(__FILE__);
|
| 13 |
+
$_baseDirArray = explode("app", $dir);
|
| 14 |
+
$basePath = $_baseDirArray[0];
|
| 15 |
+
|
| 16 |
+
//code for remove zip files
|
| 17 |
+
$files = glob($basePath."CoDzip/*.zip");
|
| 18 |
+
foreach($files as $file)
|
| 19 |
+
{
|
| 20 |
+
//changed for zip file
|
| 21 |
+
if($file!=$basePath."CoDzip/CoDMagento.zip")
|
| 22 |
+
unlink($file);
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
//remove text files
|
| 26 |
+
$filesn = glob($basePath."CoDzip/CoDfiles/*.txt");
|
| 27 |
+
|
| 28 |
+
foreach($filesn as $filen)
|
| 29 |
+
{
|
| 30 |
+
//if(($filen!=$basePath."CoDzip/CoDfiles/CoDMagento.txt")&&($filen!=$basePath."CoDzip/CoDfiles/CatalogProject.txt")&&($filen!=$basePath."CoDzip/CoDfiles/CatalogSection.txt"))
|
| 31 |
+
unlink($filen);
|
| 32 |
+
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
Mage::log("Notice : DeleteindexAction End", null, $this->_logFile);
|
| 36 |
+
}
|
| 37 |
+
}
|
app/code/community/Mage/Codi/controllers/NsyncController.php
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
<?php
|
| 2 |
ini_set("max_execution_time", 3600);
|
| 3 |
-
ini_set("memory_limit","
|
| 4 |
require_once 'Mage/Core/Controller/Front/Action.php';
|
| 5 |
class Mage_Codi_NsyncController extends Mage_Core_Controller_Front_Action
|
| 6 |
{
|
|
@@ -12,7 +12,6 @@ class Mage_Codi_NsyncController extends Mage_Core_Controller_Front_Action
|
|
| 12 |
|
| 13 |
Mage::log("Notice: Mage_Codi_NSyncController", null, $this->_logFile);
|
| 14 |
|
| 15 |
-
|
| 16 |
$error_msg = "";
|
| 17 |
$CodiModel = Mage::getModel('codi/codi');
|
| 18 |
|
|
@@ -21,14 +20,13 @@ class Mage_Codi_NsyncController extends Mage_Core_Controller_Front_Action
|
|
| 21 |
$basePath = $_baseDirArray[0].'/';
|
| 22 |
|
| 23 |
//Create folder if not exist.
|
| 24 |
-
if ( !is_dir($basePath.'
|
| 25 |
-
mkdir($basePath.'
|
| 26 |
-
|
| 27 |
-
|
| 28 |
|
| 29 |
-
|
| 30 |
$CodiModel->new_run_codi_import($basePath);
|
| 31 |
|
|
|
|
| 32 |
$error = "";
|
| 33 |
$message = $CodiModel->getImportStatuses();
|
| 34 |
$mes=implode(',',$message);
|
|
@@ -36,7 +34,7 @@ class Mage_Codi_NsyncController extends Mage_Core_Controller_Front_Action
|
|
| 36 |
if ( isset($message) ){
|
| 37 |
$status = $message['message'];
|
| 38 |
if ( $status== "end" && $message['finished'] == 1 ){
|
| 39 |
-
rename($basePath.'
|
| 40 |
$CodiModel->deleteTable();
|
| 41 |
$CodiModel->addImportStatus('end', 1);
|
| 42 |
print '{"success": "1"}';
|
|
@@ -64,7 +62,12 @@ class Mage_Codi_NsyncController extends Mage_Core_Controller_Front_Action
|
|
| 64 |
$CodiModel->deleteTable();
|
| 65 |
Mage::log("ERROR : Failed to create product file 2", null, $this->_logFile);
|
| 66 |
}
|
| 67 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
}
|
| 69 |
|
| 70 |
// Below function is for the loader
|
|
@@ -74,7 +77,7 @@ class Mage_Codi_NsyncController extends Mage_Core_Controller_Front_Action
|
|
| 74 |
$products = Mage::getModel('catalog/product')->getCollection();
|
| 75 |
$products->addAttributeToFilter('status', 1);//enabled
|
| 76 |
$products->addAttributeToFilter('visibility', 4);//catalog, search
|
| 77 |
-
$products->addAttributeToSelect('
|
| 78 |
$prodIds = $products->getAllIds();
|
| 79 |
|
| 80 |
print Mage::helper('codi')->array2json($prodIds);
|
|
@@ -82,6 +85,8 @@ class Mage_Codi_NsyncController extends Mage_Core_Controller_Front_Action
|
|
| 82 |
//create file
|
| 83 |
public function updatestatusAction()
|
| 84 |
{
|
|
|
|
|
|
|
| 85 |
$this->_logFile = "Catalog-on-demand.log";
|
| 86 |
Mage::log("Notice: Mage_Codi_NSyncController", null, $this->_logFile);
|
| 87 |
|
|
@@ -95,7 +100,7 @@ class Mage_Codi_NsyncController extends Mage_Core_Controller_Front_Action
|
|
| 95 |
$total=$this->getRequest()->getParam('total');
|
| 96 |
//basepath
|
| 97 |
$basepath=$this->getRequest()->getParam('basepath');
|
| 98 |
-
$fh = fopen($basepath.'
|
| 99 |
try{
|
| 100 |
// below condition is for the write all heading only first time after that it will not write.
|
| 101 |
if($counter==1){
|
|
@@ -105,8 +110,9 @@ class Mage_Codi_NsyncController extends Mage_Core_Controller_Front_Action
|
|
| 105 |
}
|
| 106 |
|
| 107 |
$product = Mage::getModel('catalog/product');
|
| 108 |
-
$product->load($productid);
|
| 109 |
-
|
|
|
|
| 110 |
fwrite($fh, $CodiModel->ProducttoString($product, "product"));
|
| 111 |
}catch(Exception $e)
|
| 112 |
{
|
|
@@ -114,14 +120,45 @@ class Mage_Codi_NsyncController extends Mage_Core_Controller_Front_Action
|
|
| 114 |
return;
|
| 115 |
}
|
| 116 |
fclose($fh);
|
| 117 |
-
|
| 118 |
if($progress=='100'){
|
| 119 |
-
$DataFile = '
|
| 120 |
-
rename($basePath.'
|
|
|
|
| 121 |
}
|
| 122 |
-
|
|
|
|
|
|
|
| 123 |
|
| 124 |
|
| 125 |
}
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
}
|
| 1 |
<?php
|
| 2 |
ini_set("max_execution_time", 3600);
|
| 3 |
+
ini_set("memory_limit","1024M");
|
| 4 |
require_once 'Mage/Core/Controller/Front/Action.php';
|
| 5 |
class Mage_Codi_NsyncController extends Mage_Core_Controller_Front_Action
|
| 6 |
{
|
| 12 |
|
| 13 |
Mage::log("Notice: Mage_Codi_NSyncController", null, $this->_logFile);
|
| 14 |
|
|
|
|
| 15 |
$error_msg = "";
|
| 16 |
$CodiModel = Mage::getModel('codi/codi');
|
| 17 |
|
| 20 |
$basePath = $_baseDirArray[0].'/';
|
| 21 |
|
| 22 |
//Create folder if not exist.
|
| 23 |
+
if ( !is_dir($basePath.'CoDzip/CoDfiles/') )
|
| 24 |
+
mkdir($basePath.'CoDzip/CoDfiles/');
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
$DataFile = 'CoDMagento.txt';
|
| 27 |
$CodiModel->new_run_codi_import($basePath);
|
| 28 |
|
| 29 |
+
|
| 30 |
$error = "";
|
| 31 |
$message = $CodiModel->getImportStatuses();
|
| 32 |
$mes=implode(',',$message);
|
| 34 |
if ( isset($message) ){
|
| 35 |
$status = $message['message'];
|
| 36 |
if ( $status== "end" && $message['finished'] == 1 ){
|
| 37 |
+
rename($basePath.'CoDzip/CoDfiles/temp.txt', $basePath.'CoDzip/CoDfiles/'.$DataFile);
|
| 38 |
$CodiModel->deleteTable();
|
| 39 |
$CodiModel->addImportStatus('end', 1);
|
| 40 |
print '{"success": "1"}';
|
| 62 |
$CodiModel->deleteTable();
|
| 63 |
Mage::log("ERROR : Failed to create product file 2", null, $this->_logFile);
|
| 64 |
}
|
| 65 |
+
// Calling function to create Catalog Section
|
| 66 |
+
$CodiModel->createCatalogSection();
|
| 67 |
+
//Calling function to create Catalog Project
|
| 68 |
+
$CodiModel->createCatalogProject('1');
|
| 69 |
+
|
| 70 |
+
|
| 71 |
}
|
| 72 |
|
| 73 |
// Below function is for the loader
|
| 77 |
$products = Mage::getModel('catalog/product')->getCollection();
|
| 78 |
$products->addAttributeToFilter('status', 1);//enabled
|
| 79 |
$products->addAttributeToFilter('visibility', 4);//catalog, search
|
| 80 |
+
$products->addAttributeToSelect('sku');
|
| 81 |
$prodIds = $products->getAllIds();
|
| 82 |
|
| 83 |
print Mage::helper('codi')->array2json($prodIds);
|
| 85 |
//create file
|
| 86 |
public function updatestatusAction()
|
| 87 |
{
|
| 88 |
+
ini_set('memory_limit','1024M');
|
| 89 |
+
set_time_limit(0);
|
| 90 |
$this->_logFile = "Catalog-on-demand.log";
|
| 91 |
Mage::log("Notice: Mage_Codi_NSyncController", null, $this->_logFile);
|
| 92 |
|
| 100 |
$total=$this->getRequest()->getParam('total');
|
| 101 |
//basepath
|
| 102 |
$basepath=$this->getRequest()->getParam('basepath');
|
| 103 |
+
$fh = fopen($basepath.'CoDzip/CoDfiles/temp.txt', 'a');
|
| 104 |
try{
|
| 105 |
// below condition is for the write all heading only first time after that it will not write.
|
| 106 |
if($counter==1){
|
| 110 |
}
|
| 111 |
|
| 112 |
$product = Mage::getModel('catalog/product');
|
| 113 |
+
$product->load($productid);
|
| 114 |
+
|
| 115 |
+
Mage::log("Notice : Codi Import Products :".$productid, null, $this->_logFile);
|
| 116 |
fwrite($fh, $CodiModel->ProducttoString($product, "product"));
|
| 117 |
}catch(Exception $e)
|
| 118 |
{
|
| 120 |
return;
|
| 121 |
}
|
| 122 |
fclose($fh);
|
| 123 |
+
$progress=(string)(($counter/$total)*100);
|
| 124 |
if($progress=='100'){
|
| 125 |
+
$DataFile = 'CoDMagento.txt';
|
| 126 |
+
rename($basePath.'CoDzip/CoDfiles/temp.txt', $basePath.'CoDzip/CoDfiles/'.$DataFile);
|
| 127 |
+
//die();
|
| 128 |
}
|
| 129 |
+
unset($product);
|
| 130 |
+
echo floor($progress);
|
| 131 |
+
|
| 132 |
|
| 133 |
|
| 134 |
}
|
| 135 |
+
//Create Catalog section file
|
| 136 |
+
public function createcatalogsectionAction()
|
| 137 |
+
{
|
| 138 |
+
ini_set('memory_limit','1024M');
|
| 139 |
+
set_time_limit(0);
|
| 140 |
+
//create object of Codi Model
|
| 141 |
+
$CodiModel = Mage::getModel('codi/codi');
|
| 142 |
+
// Calling function to create CatalogSection
|
| 143 |
+
$progress=$CodiModel->createCatalogSection();
|
| 144 |
+
|
| 145 |
+
echo $progress;
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
//Create Catalog section file
|
| 149 |
+
public function createcatalogprojectAction()
|
| 150 |
+
{
|
| 151 |
+
ini_set('memory_limit','1024M');
|
| 152 |
+
set_time_limit(0);
|
| 153 |
+
//create object of Codi Model
|
| 154 |
+
$CodiModel = Mage::getModel('codi/codi');
|
| 155 |
+
// Calling function to create CatalogProject
|
| 156 |
+
$progress=$CodiModel->createCatalogProject();
|
| 157 |
+
echo $progress;
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
|
| 164 |
}
|
app/code/community/Mage/Codi/controllers/SyncController.php
CHANGED
|
@@ -1,182 +1,199 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
ini_set("max_execution_time", 3600);
|
| 3 |
-
ini_set("memory_limit","512M");
|
| 4 |
-
require_once 'Mage/Core/Controller/Front/Action.php';
|
| 5 |
-
class Mage_Codi_SyncController extends Mage_Core_Controller_Front_Action
|
| 6 |
-
{
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
$
|
| 25 |
-
$
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
mkdir($basePath.'
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
$
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
@ob_end_clean();
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
$
|
| 78 |
-
|
| 79 |
-
if (
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
$
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
}
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
Mage::log("Notice:
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
$
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
$
|
| 120 |
-
$CodiModel->
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
$
|
| 125 |
-
|
| 126 |
-
Mage::log("ERROR :
|
| 127 |
-
|
| 128 |
-
}else{
|
| 129 |
-
|
| 130 |
-
$
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
'
|
| 171 |
-
'
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
ini_set("max_execution_time", 3600);
|
| 3 |
+
ini_set("memory_limit","512M");
|
| 4 |
+
require_once 'Mage/Core/Controller/Front/Action.php';
|
| 5 |
+
class Mage_Codi_SyncController extends Mage_Core_Controller_Front_Action
|
| 6 |
+
{
|
| 7 |
+
public function indexAction()
|
| 8 |
+
{
|
| 9 |
+
$this->_logFile = "Catalog-on-demand.log";
|
| 10 |
+
|
| 11 |
+
Mage::log("Notice: Mage_Codi_SyncController", null, $this->_logFile);
|
| 12 |
+
|
| 13 |
+
$error_msg = "";
|
| 14 |
+
//Check validity of Secret Key
|
| 15 |
+
if ( $this->getRequest()->getParam('SecretKey') != Mage::getStoreConfig('codi/codi/secretkey') )
|
| 16 |
+
{
|
| 17 |
+
Mage::log("ERROR : Secret Key Not accepted", null, $this->_logFile);
|
| 18 |
+
$error_msg = "ERROR\nSecret Key Not accepted.";
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
$CodiModel = Mage::getModel('codi/codi');
|
| 22 |
+
|
| 23 |
+
$dir = dirname(__FILE__);
|
| 24 |
+
$_baseDirArray = explode("app", $dir);
|
| 25 |
+
$basePath = $_baseDirArray[0];
|
| 26 |
+
|
| 27 |
+
//Create folder if not exist. change for zip
|
| 28 |
+
if ( !is_dir($basePath.'CoDzip/') )
|
| 29 |
+
{
|
| 30 |
+
mkdir($basePath.'CoDzip/');
|
| 31 |
+
chmod($basePath.'CoDzip/',777);
|
| 32 |
+
if ( !is_dir($basePath.'CoDzip/CoDfiles/') )
|
| 33 |
+
{
|
| 34 |
+
mkdir($basePath.'CoDzip/CoDfiles/');
|
| 35 |
+
chmod($basePath.'CoDzip/CoDfiles/',777);
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
/*
|
| 39 |
+
if ( !is_dir($basePath.'CoDzip/') )
|
| 40 |
+
mkdir($basePath.'CODdataFiles/');
|
| 41 |
+
*/
|
| 42 |
+
|
| 43 |
+
if ( !$CodiModel->createFile($basePath) ){
|
| 44 |
+
Mage::log("ERROR : Cannot create file : ".$basePath, null, $this->_logFile);
|
| 45 |
+
$error_msg = "ERROR\nThe Magento extension was prevented from creating a file in the folder CoDzip/CoDfiles. The import has been cancelled. Please notify your Magento administrator.";
|
| 46 |
+
}
|
| 47 |
+
$url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
|
| 48 |
+
if ( $url == "http://" || $url == "https://" ){
|
| 49 |
+
|
| 50 |
+
Mage::log("ERROR : Cannot prepare the callback link : ".$url, null, $this->_logFile);
|
| 51 |
+
$error_msg = "ERROR\nCannot prepare the callback link.";
|
| 52 |
+
}
|
| 53 |
+
if ( $error_msg == "" )
|
| 54 |
+
{
|
| 55 |
+
$error_msg = "OK";
|
| 56 |
+
//respond immediately
|
| 57 |
+
$datafilelaunch = Mage::getStoreConfig('codi/codi/coddatafilelaunch');
|
| 58 |
+
$wait='';
|
| 59 |
+
if($datafilelaunch=='cod')
|
| 60 |
+
{
|
| 61 |
+
|
| 62 |
+
$waitforminute=Mage::getStoreConfig('codi/codi/codwaitforminute')/60;
|
| 63 |
+
$wait="\r\nWaitFor=".number_format($waitforminute,2,'.','');
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
@ob_end_clean();
|
| 67 |
+
header("Connection: close\r\n");
|
| 68 |
+
header("Content-Encoding: none\r\n");
|
| 69 |
+
ignore_user_abort(true);
|
| 70 |
+
ob_start();
|
| 71 |
+
echo $error_msg.$wait;
|
| 72 |
+
header("Content-Length: ".ob_get_length());
|
| 73 |
+
ob_end_flush();
|
| 74 |
+
flush();
|
| 75 |
+
@ob_end_clean();
|
| 76 |
+
|
| 77 |
+
Mage::log("Notice: Response ". $error_msg, null, $this->_logFile);
|
| 78 |
+
|
| 79 |
+
if ( $error_msg != "OK" ){
|
| 80 |
+
exit(0);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
$DataFile = (string)$this->getRequest()->getParam('FileName');
|
| 84 |
+
$filename = $basePath.'CoDzip/CoDfiles/CoDMagento.txt';
|
| 85 |
+
//Check code for file is exists or not
|
| 86 |
+
$fExist=0;
|
| 87 |
+
$modifie='';
|
| 88 |
+
if (file_exists($filename)) {
|
| 89 |
+
$fExist=1;
|
| 90 |
+
$modifie=date("M d, Y H:i:s.", filemtime($filename));
|
| 91 |
+
copy($filename, $basePath.'CoDzip/CoDfiles/'.$DataFile.'.txt');
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
Mage::log("Notice: Response ". $DataFile, null, $this->_logFile);
|
| 96 |
+
$datafilelaunch = Mage::getStoreConfig('codi/codi/coddatafilelaunch');
|
| 97 |
+
|
| 98 |
+
if((($datafilelaunch=="magento") || ($datafilelaunch=="manual") ) && ($fExist==1))
|
| 99 |
+
{
|
| 100 |
+
Mage::helper('codi/createzip')->createimportzip($DataFile);
|
| 101 |
+
Mage::log("Notice: Import Products using Magento Cron job: ".$datafilelaunch, null, $this->_logFile);
|
| 102 |
+
|
| 103 |
+
}
|
| 104 |
+
else
|
| 105 |
+
{
|
| 106 |
+
Mage::log("Notice: Import Products using Catalog on demand: ".$datafilelaunch, null, $this->_logFile);
|
| 107 |
+
$CodiModel->run_codi_import($basePath);
|
| 108 |
+
$error = "";
|
| 109 |
+
$message = $CodiModel->getImportStatuses();
|
| 110 |
+
|
| 111 |
+
$status = 0;
|
| 112 |
+
if ( isset($message) ){
|
| 113 |
+
$status = $message['message'];
|
| 114 |
+
|
| 115 |
+
if ( $status== "end" && $message['finished'] == 1 ){
|
| 116 |
+
$modifie=date("M d, Y H:i:s.", filemtime($basePath.'CoDzip/CoDfiles/temp.txt'));
|
| 117 |
+
|
| 118 |
+
// Calling function to create Catalog Section
|
| 119 |
+
$progress=$CodiModel->createCatalogSection();
|
| 120 |
+
$progress=$CodiModel->createCatalogProject(1);
|
| 121 |
+
copy($basePath.'CoDzip/CoDfiles/temp.txt', $basePath.'CoDzip/CoDfiles/CoDMagento.txt');
|
| 122 |
+
rename($basePath.'CoDzip/CoDfiles/temp.txt', $basePath.'CoDzip/CoDfiles/'.$DataFile.'.txt');
|
| 123 |
+
Mage::helper('codi/createzip')->createimportzip($DataFile);
|
| 124 |
+
$CodiModel->deleteTable();
|
| 125 |
+
|
| 126 |
+
Mage::log("ERROR : Finished to create product file", null, $this->_logFile);
|
| 127 |
+
|
| 128 |
+
}else if ( $status== "cancel" && $message['finished'] == 1 ) {
|
| 129 |
+
|
| 130 |
+
$error = "ERROR\nCanceled to create product file";
|
| 131 |
+
$CodiModel->deleteTable();
|
| 132 |
+
Mage::log("ERROR : Canceled to create product file", null, $this->_logFile);
|
| 133 |
+
|
| 134 |
+
}else if ( $status== "fileerror" && $message['finished'] == 1 ) {
|
| 135 |
+
|
| 136 |
+
$error = "ERROR\nFailed to create product file";
|
| 137 |
+
$CodiModel->deleteTable();
|
| 138 |
+
Mage::log("ERROR : Failed to create product file", null, $this->_logFile);
|
| 139 |
+
|
| 140 |
+
}else{
|
| 141 |
+
$error = "ERROR\nFailed to create product file";
|
| 142 |
+
$CodiModel->deleteTable();
|
| 143 |
+
Mage::log("ERROR : Failed to create product file 1", null, $this->_logFile);
|
| 144 |
+
}
|
| 145 |
+
}else{
|
| 146 |
+
$error = "ERROR\nFailed to create product file";
|
| 147 |
+
$CodiModel->deleteTable();
|
| 148 |
+
Mage::log("ERROR : Failed to create product file 2", null, $this->_logFile);
|
| 149 |
+
}
|
| 150 |
+
}
|
| 151 |
+
//Prepare the callback parameters
|
| 152 |
+
|
| 153 |
+
$pos = strpos($url, 'index.php');
|
| 154 |
+
$DataFileLink = substr($url, 0, $pos ) . 'CoDzip/' . $DataFile.'.zip';
|
| 155 |
+
|
| 156 |
+
Mage::log("Notice: Prepare the callback parameters link: ". $DataFileLink, null, $this->_logFile);
|
| 157 |
+
|
| 158 |
+
$ProcessID = (string)$this->getRequest()->getParam('ProcessID');
|
| 159 |
+
$url = (string)$this->getRequest()->getParam('CallbackURL');
|
| 160 |
+
$DeleteDataFileURL = (string)Mage::getUrl('codi/delete') ;
|
| 161 |
+
|
| 162 |
+
$Comment = $CodiModel->getComment($modifie);
|
| 163 |
+
Mage::log("Notice: Prepare the Comment : ". $Comment, null, $this->_logFile);
|
| 164 |
+
//code for getTheme
|
| 165 |
+
$helper=Mage::helper('codi');
|
| 166 |
+
$TemplateName=(string)$helper->getTheme();
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
$paramsarray = array( 'ProcessID' => $ProcessID,
|
| 170 |
+
'TemplateName' => $TemplateName,
|
| 171 |
+
'DataFileLink' => $DataFileLink ,
|
| 172 |
+
'DeleteDataFileURL' => $DeleteDataFileURL ,
|
| 173 |
+
'Encoding' => 'utf-8' ,
|
| 174 |
+
'ClearDatabase' => 'MissingOnly' ,
|
| 175 |
+
'PartnerID' => 'CoDMagento' ,
|
| 176 |
+
'CatalogProject' => 'magento',
|
| 177 |
+
'Comment' => $Comment);
|
| 178 |
+
if ( $error != "" ) {
|
| 179 |
+
$paramsarray = array('ProcessID' => $ProcessID,
|
| 180 |
+
'TemplateName' => $TemplateName,
|
| 181 |
+
'DataFileLink' => $DataFileLink ,
|
| 182 |
+
'DeleteDataFileURL' => $DeleteDataFileURL ,
|
| 183 |
+
'Encoding' => 'utf-8' ,
|
| 184 |
+
'ClearDatabase' => 'MissingOnly' ,
|
| 185 |
+
'PartnerID' => 'CoDMagento' ,
|
| 186 |
+
'CatalogProject' => 'magento',
|
| 187 |
+
'Comment' => $Comment,
|
| 188 |
+
'Error' => $error);
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
Mage::log("Notice: Prepare the DataFileLink : ". $DataFileLink, null, $this->_logFile);
|
| 192 |
+
Mage::log("Notice: Prepare the process ID : ". $ProcessID, null, $this->_logFile);
|
| 193 |
+
Mage::log("Notice: Prepare the delete url : ". $DeleteDataFileURL, null, $this->_logFile);
|
| 194 |
+
Mage::log("Notice: Prepare the callback url : ". $url, null, $this->_logFile);
|
| 195 |
+
Mage::log("Notice: Prepare the template theme : ". $TemplateName, null, $this->_logFile);
|
| 196 |
+
$Responsemsg = $CodiModel->Call( $url, $paramsarray );
|
| 197 |
+
Mage::log("Notice: Prepare the callback response message ". $Responsemsg, null, $this->_logFile);
|
| 198 |
+
}
|
| 199 |
+
}
|
app/code/community/Mage/Codi/etc/config.xml
CHANGED
|
@@ -1,146 +1,146 @@
|
|
| 1 |
-
<?xml version="1.0"?>
|
| 2 |
-
<config>
|
| 3 |
-
<modules>
|
| 4 |
-
<Mage_Codi>
|
| 5 |
-
<version>3.0.
|
| 6 |
-
</Mage_Codi>
|
| 7 |
-
</modules>
|
| 8 |
-
<adminhtml>
|
| 9 |
-
<menu>
|
| 10 |
-
<catalog translate="title" module="catalog">
|
| 11 |
-
<title>Catalog</title>
|
| 12 |
-
<depends>
|
| 13 |
-
<module>Mage_Catalog</module>
|
| 14 |
-
</depends>
|
| 15 |
-
<children>
|
| 16 |
-
<codi translate="title" module="catalog">
|
| 17 |
-
<sort_order>-1</sort_order>
|
| 18 |
-
<title>Catalog-On-Demand</title>
|
| 19 |
-
<action>codi/adminhtml_menu/</action>
|
| 20 |
-
</codi>
|
| 21 |
-
</children>
|
| 22 |
-
</catalog>
|
| 23 |
-
</menu>
|
| 24 |
-
</adminhtml>
|
| 25 |
-
<global>
|
| 26 |
-
<!--
|
| 27 |
-
<fieldsets>
|
| 28 |
-
<customer_account>
|
| 29 |
-
<codinternaluser><create>1</create><update>1</update></codinternaluser>
|
| 30 |
-
</customer_account>
|
| 31 |
-
</fieldsets>
|
| 32 |
-
-->
|
| 33 |
-
|
| 34 |
-
<!--
|
| 35 |
-
<blocks>
|
| 36 |
-
<adminhtml>
|
| 37 |
-
<rewrite>
|
| 38 |
-
<widget_grid>Mage_Codi_Block_Widget_Grid</widget_grid>
|
| 39 |
-
</rewrite>
|
| 40 |
-
</adminhtml>
|
| 41 |
-
</blocks>
|
| 42 |
-
<blocks>
|
| 43 |
-
<adminhtml>
|
| 44 |
-
<rewrite>
|
| 45 |
-
<widget_grid_massaction>Mage_Codi_Block_Widget_Grid_Massaction</widget_grid_massaction>
|
| 46 |
-
</rewrite>
|
| 47 |
-
</adminhtml>
|
| 48 |
-
</blocks>
|
| 49 |
-
<blocks>
|
| 50 |
-
<adminhtml>
|
| 51 |
-
<rewrite>
|
| 52 |
-
<catalog_product_grid>Mage_Codi_Block_Adminhtml_Catalog_Product_Grid</catalog_product_grid>
|
| 53 |
-
</rewrite>
|
| 54 |
-
</adminhtml>
|
| 55 |
-
</blocks>
|
| 56 |
-
<blocks>
|
| 57 |
-
<adminhtml>
|
| 58 |
-
<rewrite>
|
| 59 |
-
<catalog_product>Mage_Codi_Block_Adminhtml_Catalog_Product</catalog_product>
|
| 60 |
-
</rewrite>
|
| 61 |
-
</adminhtml>
|
| 62 |
-
</blocks>
|
| 63 |
-
-->
|
| 64 |
-
<!-- V2 Start-->
|
| 65 |
-
<models>
|
| 66 |
-
<codi>
|
| 67 |
-
<class>Mage_Codi_Model</class>
|
| 68 |
-
</codi>
|
| 69 |
-
</models>
|
| 70 |
-
<blocks>
|
| 71 |
-
<codi>
|
| 72 |
-
<class>Mage_Codi_Block</class>
|
| 73 |
-
</codi>
|
| 74 |
-
</blocks>
|
| 75 |
-
<!--
|
| 76 |
-
<events>
|
| 77 |
-
<adminhtml_controller_action_predispatch_start>
|
| 78 |
-
<observers>
|
| 79 |
-
<mage_codi_codi>
|
| 80 |
-
<type>singleton</type>
|
| 81 |
-
<class>mage_codi_model_codi</class>
|
| 82 |
-
<method>adminstart</method>
|
| 83 |
-
</mage_codi_codi>
|
| 84 |
-
</observers>
|
| 85 |
-
</adminhtml_controller_action_predispatch_start>
|
| 86 |
-
</events>
|
| 87 |
-
<rewrite>
|
| 88 |
-
<codi_index_update>
|
| 89 |
-
<from><![CDATA[#^/wishlist/index/update/#]]></from>
|
| 90 |
-
<to>codi/index/update</to>
|
| 91 |
-
</codi_index_update>
|
| 92 |
-
|
| 93 |
-
<codi_index_index>
|
| 94 |
-
<from><![CDATA[#^/wishlist/$#]]></from>
|
| 95 |
-
<to>codi/codifront/index</to>
|
| 96 |
-
</codi_index_index>
|
| 97 |
-
|
| 98 |
-
<codi_codifront_index1>
|
| 99 |
-
<from><![CDATA[#^/wishlist/codifront#]]></from>
|
| 100 |
-
<to>codi/codifront/index</to>
|
| 101 |
-
</codi_codifront_index1>
|
| 102 |
-
</rewrite>
|
| 103 |
-
-->
|
| 104 |
-
</global>
|
| 105 |
-
<frontend>
|
| 106 |
-
<routers>
|
| 107 |
-
<codi>
|
| 108 |
-
<use>standard</use>
|
| 109 |
-
<args>
|
| 110 |
-
<module>Mage_Codi</module>
|
| 111 |
-
<frontName>codi</frontName>
|
| 112 |
-
</args>
|
| 113 |
-
</codi>
|
| 114 |
-
</routers>
|
| 115 |
-
<!--
|
| 116 |
-
<layout>
|
| 117 |
-
<updates>
|
| 118 |
-
<codi>
|
| 119 |
-
<file>codi.xml</file>
|
| 120 |
-
</codi>
|
| 121 |
-
</updates>
|
| 122 |
-
</layout>
|
| 123 |
-
-->
|
| 124 |
-
</frontend>
|
| 125 |
-
<admin>
|
| 126 |
-
<routers>
|
| 127 |
-
<codi>
|
| 128 |
-
<use>admin</use>
|
| 129 |
-
<args>
|
| 130 |
-
<module>Mage_Codi</module>
|
| 131 |
-
<frontName>codi</frontName>
|
| 132 |
-
</args>
|
| 133 |
-
</codi>
|
| 134 |
-
</routers>
|
| 135 |
-
</admin>
|
| 136 |
-
<adminhtml>
|
| 137 |
-
<layout>
|
| 138 |
-
<updates>
|
| 139 |
-
<codi>
|
| 140 |
-
<file>codi.xml</file>
|
| 141 |
-
</codi>
|
| 142 |
-
</updates>
|
| 143 |
-
</layout>
|
| 144 |
-
</adminhtml>
|
| 145 |
-
<!-- V2 End-->
|
| 146 |
-
</config>
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Mage_Codi>
|
| 5 |
+
<version>3.0.3</version>
|
| 6 |
+
</Mage_Codi>
|
| 7 |
+
</modules>
|
| 8 |
+
<adminhtml>
|
| 9 |
+
<menu>
|
| 10 |
+
<catalog translate="title" module="catalog">
|
| 11 |
+
<title>Catalog</title>
|
| 12 |
+
<depends>
|
| 13 |
+
<module>Mage_Catalog</module>
|
| 14 |
+
</depends>
|
| 15 |
+
<children>
|
| 16 |
+
<codi translate="title" module="catalog">
|
| 17 |
+
<sort_order>-1</sort_order>
|
| 18 |
+
<title>Catalog-On-Demand</title>
|
| 19 |
+
<action>codi/adminhtml_menu/</action>
|
| 20 |
+
</codi>
|
| 21 |
+
</children>
|
| 22 |
+
</catalog>
|
| 23 |
+
</menu>
|
| 24 |
+
</adminhtml>
|
| 25 |
+
<global>
|
| 26 |
+
<!--
|
| 27 |
+
<fieldsets>
|
| 28 |
+
<customer_account>
|
| 29 |
+
<codinternaluser><create>1</create><update>1</update></codinternaluser>
|
| 30 |
+
</customer_account>
|
| 31 |
+
</fieldsets>
|
| 32 |
+
-->
|
| 33 |
+
|
| 34 |
+
<!--
|
| 35 |
+
<blocks>
|
| 36 |
+
<adminhtml>
|
| 37 |
+
<rewrite>
|
| 38 |
+
<widget_grid>Mage_Codi_Block_Widget_Grid</widget_grid>
|
| 39 |
+
</rewrite>
|
| 40 |
+
</adminhtml>
|
| 41 |
+
</blocks>
|
| 42 |
+
<blocks>
|
| 43 |
+
<adminhtml>
|
| 44 |
+
<rewrite>
|
| 45 |
+
<widget_grid_massaction>Mage_Codi_Block_Widget_Grid_Massaction</widget_grid_massaction>
|
| 46 |
+
</rewrite>
|
| 47 |
+
</adminhtml>
|
| 48 |
+
</blocks>
|
| 49 |
+
<blocks>
|
| 50 |
+
<adminhtml>
|
| 51 |
+
<rewrite>
|
| 52 |
+
<catalog_product_grid>Mage_Codi_Block_Adminhtml_Catalog_Product_Grid</catalog_product_grid>
|
| 53 |
+
</rewrite>
|
| 54 |
+
</adminhtml>
|
| 55 |
+
</blocks>
|
| 56 |
+
<blocks>
|
| 57 |
+
<adminhtml>
|
| 58 |
+
<rewrite>
|
| 59 |
+
<catalog_product>Mage_Codi_Block_Adminhtml_Catalog_Product</catalog_product>
|
| 60 |
+
</rewrite>
|
| 61 |
+
</adminhtml>
|
| 62 |
+
</blocks>
|
| 63 |
+
-->
|
| 64 |
+
<!-- V2 Start-->
|
| 65 |
+
<models>
|
| 66 |
+
<codi>
|
| 67 |
+
<class>Mage_Codi_Model</class>
|
| 68 |
+
</codi>
|
| 69 |
+
</models>
|
| 70 |
+
<blocks>
|
| 71 |
+
<codi>
|
| 72 |
+
<class>Mage_Codi_Block</class>
|
| 73 |
+
</codi>
|
| 74 |
+
</blocks>
|
| 75 |
+
<!--
|
| 76 |
+
<events>
|
| 77 |
+
<adminhtml_controller_action_predispatch_start>
|
| 78 |
+
<observers>
|
| 79 |
+
<mage_codi_codi>
|
| 80 |
+
<type>singleton</type>
|
| 81 |
+
<class>mage_codi_model_codi</class>
|
| 82 |
+
<method>adminstart</method>
|
| 83 |
+
</mage_codi_codi>
|
| 84 |
+
</observers>
|
| 85 |
+
</adminhtml_controller_action_predispatch_start>
|
| 86 |
+
</events>
|
| 87 |
+
<rewrite>
|
| 88 |
+
<codi_index_update>
|
| 89 |
+
<from><![CDATA[#^/wishlist/index/update/#]]></from>
|
| 90 |
+
<to>codi/index/update</to>
|
| 91 |
+
</codi_index_update>
|
| 92 |
+
|
| 93 |
+
<codi_index_index>
|
| 94 |
+
<from><![CDATA[#^/wishlist/$#]]></from>
|
| 95 |
+
<to>codi/codifront/index</to>
|
| 96 |
+
</codi_index_index>
|
| 97 |
+
|
| 98 |
+
<codi_codifront_index1>
|
| 99 |
+
<from><![CDATA[#^/wishlist/codifront#]]></from>
|
| 100 |
+
<to>codi/codifront/index</to>
|
| 101 |
+
</codi_codifront_index1>
|
| 102 |
+
</rewrite>
|
| 103 |
+
-->
|
| 104 |
+
</global>
|
| 105 |
+
<frontend>
|
| 106 |
+
<routers>
|
| 107 |
+
<codi>
|
| 108 |
+
<use>standard</use>
|
| 109 |
+
<args>
|
| 110 |
+
<module>Mage_Codi</module>
|
| 111 |
+
<frontName>codi</frontName>
|
| 112 |
+
</args>
|
| 113 |
+
</codi>
|
| 114 |
+
</routers>
|
| 115 |
+
<!--
|
| 116 |
+
<layout>
|
| 117 |
+
<updates>
|
| 118 |
+
<codi>
|
| 119 |
+
<file>codi.xml</file>
|
| 120 |
+
</codi>
|
| 121 |
+
</updates>
|
| 122 |
+
</layout>
|
| 123 |
+
-->
|
| 124 |
+
</frontend>
|
| 125 |
+
<admin>
|
| 126 |
+
<routers>
|
| 127 |
+
<codi>
|
| 128 |
+
<use>admin</use>
|
| 129 |
+
<args>
|
| 130 |
+
<module>Mage_Codi</module>
|
| 131 |
+
<frontName>codi</frontName>
|
| 132 |
+
</args>
|
| 133 |
+
</codi>
|
| 134 |
+
</routers>
|
| 135 |
+
</admin>
|
| 136 |
+
<adminhtml>
|
| 137 |
+
<layout>
|
| 138 |
+
<updates>
|
| 139 |
+
<codi>
|
| 140 |
+
<file>codi.xml</file>
|
| 141 |
+
</codi>
|
| 142 |
+
</updates>
|
| 143 |
+
</layout>
|
| 144 |
+
</adminhtml>
|
| 145 |
+
<!-- V2 End-->
|
| 146 |
+
</config>
|
app/design/adminhtml/default/default/template/codi/index.phtml
CHANGED
|
@@ -32,6 +32,11 @@ $post_url_cancel = $this->getUrl('codi/adminhtml_menu/cancel');
|
|
| 32 |
$post_bgprocess_check = $this->getUrl('codi/adminhtml_menu/bgcheck');
|
| 33 |
//chagned ver 3.0.1
|
| 34 |
$newpostupdate = $this->getUrl('codi/nsync/updatestatus');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
//Changed ver 2.2.15
|
| 37 |
$download_url = $this->getUrl('codi/adminhtml_menu/downloadtest');
|
|
@@ -45,6 +50,7 @@ if ( $codbgcheck == 1 ) $codbg_checked = "checked";
|
|
| 45 |
|
| 46 |
$extensionName="Mage_PDF_per_Product";
|
| 47 |
$currentVer = Mage::getConfig()->getModuleConfig('Mage_Codi')->version;
|
|
|
|
| 48 |
//Changed ver 3.0.1 Added wait for minute parameter
|
| 49 |
$waitforminute=Mage::getStoreConfig('codi/codi/codwaitforminute');
|
| 50 |
$includeshortdescription = Mage::getStoreConfig('codi/codi/codincludeshortdescription');
|
|
@@ -55,6 +61,15 @@ $codquantity=Mage::getStoreConfig('codi/codi/codquantity');
|
|
| 55 |
$codprice=Mage::getStoreConfig('codi/codi/codprice');
|
| 56 |
$codsavings=Mage::getStoreConfig('codi/codi/codsavings');
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
?>
|
| 60 |
<style>
|
|
@@ -125,23 +140,14 @@ $codsavings=Mage::getStoreConfig('codi/codi/codsavings');
|
|
| 125 |
|
| 126 |
$fail = '';
|
| 127 |
$pass = '';
|
| 128 |
-
//$baseDir = dirname(__FILE__);
|
| 129 |
|
| 130 |
-
//$_baseDirArray = explode("app", $baseDir);
|
| 131 |
-
//$basePath = $_baseDirArray[0];
|
| 132 |
-
//echo "<li>Could not create <strong>CODdataFiles</strong> folder.</li>";
|
| 133 |
-
//echo "<li>Please create <strong>CODdataFiles manually</strong> in ".$basePath."</li>";
|
| 134 |
if(version_compare(phpversion(), '5.2.0', '<')) {
|
| 135 |
$fail .= '<li>You need<strong> PHP 5.2.0</strong> (or greater). Your current version is '.phpversion().'</li>';
|
| 136 |
}
|
| 137 |
else {
|
| 138 |
$pass .='<li>You have<strong> PHP '.phpversion().'</strong></li>';
|
| 139 |
}
|
| 140 |
-
|
| 141 |
-
/*$allow_url_fopen = ini_get('allow_url_fopen');
|
| 142 |
-
if ( $allow_url_fopen != '1' )
|
| 143 |
-
$fail .= '<li> You are missing the <strong>allow_url_fopen</strong> configuration option</li>';
|
| 144 |
-
*/
|
| 145 |
if( !ini_get('safe_mode') ) {
|
| 146 |
$pass .='<li>Safe Mode is <strong>off</strong></li>';
|
| 147 |
}
|
|
@@ -161,19 +167,40 @@ $codsavings=Mage::getStoreConfig('codi/codi/codsavings');
|
|
| 161 |
|
| 162 |
$_baseDirArray = explode("app", $baseDir);
|
| 163 |
$basePath = $_baseDirArray[0];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
|
| 165 |
-
|
| 166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
|
| 168 |
-
$fail .= "<li>Could not create <strong>
|
| 169 |
-
$fail .= "<li>Please create <strong>
|
| 170 |
}
|
| 171 |
-
}
|
| 172 |
|
| 173 |
$is_file = true;
|
| 174 |
|
| 175 |
if ( !$codimodel->createFile($basePath) ){
|
| 176 |
-
$fail .= "<li>The Magento extension was prevented from creating a file in the folder
|
| 177 |
$is_file = false;
|
| 178 |
}
|
| 179 |
|
|
@@ -297,7 +324,7 @@ switch ($target)
|
|
| 297 |
$text = "<p id='codi_status_template_button'>Your test data file was created successfully. <img src='".$this->getSkinUrl($this->__('images/codimport_yes.gif'))."' /> <button type='button' onclick='download_codi_file();' class='scalable add' style='margin-left:25px;' ><span>Download Data File</span></button> <button type='button' onclick='delete_codi_file();' class='scalable add' style='margin-left:25px;' ><span>Delete Data File</span></button></p>";
|
| 298 |
$codimodel->deleteTable();
|
| 299 |
}else if ( $status== "start" && $message['finished'] == 0 ) {
|
| 300 |
-
$text = "<p>A test data file is now being created. <span style='margin-left:15px;'><img src='".$this->getSkinUrl($this->__('images/codimport_run.gif'))."' /></span>  
|
| 301 |
}else if ( $status== "fileerror" && $message['finished'] == 0 ) {
|
| 302 |
$text = "<p>Your test data file was not created. Please contact your administrator.</p>";
|
| 303 |
$codimodel->deleteTable();
|
|
@@ -310,17 +337,9 @@ switch ($target)
|
|
| 310 |
//Changed on version 2.2.15
|
| 311 |
//$text .= "<a href='#datafilebackground_tooltip'><img src='".$this->getSkinUrl($this->__('images/preview_field_help.png'))."' /></a><input type='checkbox' id='background_process' name='background_process' ".$codbg_checked." style='margin:0px 5px 0px 15px;cursor:pointer' onclick='onBackgroundProcess(this)' />Create data file using background process<br /><br />";
|
| 312 |
$text .= "<button type='button' class='scalable add' onclick='start_codi_import()' style='margin-left:25px;' ><span>Test</span></button>";
|
| 313 |
-
//echo $basePath.'CODdataFiles/temp.txt';
|
| 314 |
-
// @unlink($basePath.'CODdataFiles/temp.txt');
|
| 315 |
}
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
<div class='entry-edit-head'>
|
| 319 |
-
<h4 class='icon-head head-edit-form fieldset-legend'>Data File Creation</h4>
|
| 320 |
-
<div> </div>
|
| 321 |
-
</div>
|
| 322 |
-
<div class='fieldset' id='codi_status_template' name='codi_status_template'>".$text."</div>
|
| 323 |
-
";*/
|
| 324 |
}
|
| 325 |
break;
|
| 326 |
case "auth":
|
|
@@ -378,14 +397,24 @@ switch ($target)
|
|
| 378 |
<input type="radio" value="manual" id="manual" name="datafilelaunch" <?php if ($datafilelaunch =="manual") echo "checked" ?> onclick="displayBlock('codi_status_template','cronjob','0');"/> <label for="manual">Manual <a href="#manual_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></label><br>
|
| 379 |
<p id="codi_status_template" name="codi_status_template" style="display:<?php if ($datafilelaunch =="manual") echo 'block'; else echo 'none';?>;">
|
| 380 |
<?php
|
| 381 |
-
$filename = $basePath.'
|
| 382 |
if (file_exists($filename)) {
|
| 383 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 384 |
echo $modifie." <button type='button' onclick='download_codi_file();' class='scalable add' style='margin-left:25px;' ><span>Download Data File</span></button> <button type='button' onclick='delete_codi_file();' class='scalable add' style='margin-left:25px;' ><span>Delete Data File</span></button>";
|
| 385 |
}
|
| 386 |
else{
|
| 387 |
?>
|
| 388 |
-
|
| 389 |
<?php }?>
|
| 390 |
</p>
|
| 391 |
|
|
@@ -703,27 +732,31 @@ Codi.prototype = {
|
|
| 703 |
requestTimeout: 100,
|
| 704 |
|
| 705 |
onSuccess: function(transport) {
|
| 706 |
-
//var ret_msg = transport.responseText.evalJSON();
|
| 707 |
-
//var status_div = document.getElementById('codi_status_template');
|
| 708 |
var ret_msg = transport.responseText.evalJSON();
|
| 709 |
-
|
| 710 |
var v;
|
| 711 |
-
var totalproduct=ret_msg.length;
|
| 712 |
-
|
| 713 |
-
|
| 714 |
-
|
| 715 |
-
|
| 716 |
-
v=createfilenew(productid,j,totalproduct);
|
| 717 |
-
|
| 718 |
}
|
| 719 |
-
|
| 720 |
-
|
| 721 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 722 |
if ( ret_msg.success == 1 ){
|
| 723 |
-
status_div.innerHTML = "<p>A test data file is now being created. <span style='margin-left:15px;'><img src=\"<?=$this->getSkinUrl($this->__('images/codimport_run.gif'))?>\" ></span>  
|
| 724 |
_this.updateTimer = setInterval(function(){_this.updateEvent();}, 10000);
|
| 725 |
}else if ( ret_msg.error == 1 ){
|
| 726 |
-
status_div.innerHTML = "<p>The Magento extension was prevented from creating a file in the folder
|
| 727 |
}else if ( ret_msg.exec == 1 || ret_msg.shellexec == 1 ) {
|
| 728 |
status_div.innerHTML = "<p>The <strong>exec</strong> and/or <strong>shell_exec</strong> functions are disabled in your php.ini. See the line starting with <strong>'disable_functions ='</strong>. Unless you remove both <strong>'exec'</strong> and <strong>'shell_exec'</strong> from this line, you may not use the background process to create data files. This may be a problem if you have a large product database.</p>";
|
| 729 |
}
|
|
@@ -900,11 +933,13 @@ function createfilenew(productid,i,totalproduct)
|
|
| 900 |
onSuccess: function(transport) {
|
| 901 |
r= transport.responseText;
|
| 902 |
if(r=='100'){
|
| 903 |
-
|
|
|
|
|
|
|
| 904 |
}
|
| 905 |
else{
|
| 906 |
if(r!="error"){
|
| 907 |
-
status_div.innerHTML="<p id='codi_status_template_button'>"+transport.responseText+"% </p><p>A test data file is now being created. <span style='margin-left:15px;'><img src=\"<?=$this->getSkinUrl($this->__('images/codimport_run.gif'))?>\" ></span>  
|
| 908 |
}
|
| 909 |
}
|
| 910 |
if(r=="error")
|
|
@@ -916,11 +951,79 @@ function createfilenew(productid,i,totalproduct)
|
|
| 916 |
|
| 917 |
//onFailure: this.ajaxFailure.bind(),
|
| 918 |
});
|
| 919 |
-
return r;
|
| 920 |
-
|
| 921 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 922 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 923 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 924 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 925 |
}
|
|
|
|
|
|
|
| 926 |
</script>
|
| 32 |
$post_bgprocess_check = $this->getUrl('codi/adminhtml_menu/bgcheck');
|
| 33 |
//chagned ver 3.0.1
|
| 34 |
$newpostupdate = $this->getUrl('codi/nsync/updatestatus');
|
| 35 |
+
//Changed for category section file
|
| 36 |
+
$createCatalogSection = $this->getUrl('codi/nsync/createcatalogsection');
|
| 37 |
+
|
| 38 |
+
//Changed for Category project section
|
| 39 |
+
$createCatalogProject = $this->getUrl('codi/nsync/createcatalogproject');
|
| 40 |
|
| 41 |
//Changed ver 2.2.15
|
| 42 |
$download_url = $this->getUrl('codi/adminhtml_menu/downloadtest');
|
| 50 |
|
| 51 |
$extensionName="Mage_PDF_per_Product";
|
| 52 |
$currentVer = Mage::getConfig()->getModuleConfig('Mage_Codi')->version;
|
| 53 |
+
|
| 54 |
//Changed ver 3.0.1 Added wait for minute parameter
|
| 55 |
$waitforminute=Mage::getStoreConfig('codi/codi/codwaitforminute');
|
| 56 |
$includeshortdescription = Mage::getStoreConfig('codi/codi/codincludeshortdescription');
|
| 61 |
$codprice=Mage::getStoreConfig('codi/codi/codprice');
|
| 62 |
$codsavings=Mage::getStoreConfig('codi/codi/codsavings');
|
| 63 |
|
| 64 |
+
//Changed for show download zip file url
|
| 65 |
+
$zipurl = $this->getUrl('CoDzip/') ;
|
| 66 |
+
$pos = strrpos ($zipurl , 'key') ;
|
| 67 |
+
if ( $pos != 0 )
|
| 68 |
+
$zipurl = substr( $zipurl , 0 , $pos ) ;
|
| 69 |
+
else
|
| 70 |
+
$zipurl = $zipurl;
|
| 71 |
+
|
| 72 |
+
$zipurl=str_replace("index.php/CoDzip/index/index/", "CoDzip/",$zipurl);
|
| 73 |
|
| 74 |
?>
|
| 75 |
<style>
|
| 140 |
|
| 141 |
$fail = '';
|
| 142 |
$pass = '';
|
|
|
|
| 143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
if(version_compare(phpversion(), '5.2.0', '<')) {
|
| 145 |
$fail .= '<li>You need<strong> PHP 5.2.0</strong> (or greater). Your current version is '.phpversion().'</li>';
|
| 146 |
}
|
| 147 |
else {
|
| 148 |
$pass .='<li>You have<strong> PHP '.phpversion().'</strong></li>';
|
| 149 |
}
|
| 150 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
if( !ini_get('safe_mode') ) {
|
| 152 |
$pass .='<li>Safe Mode is <strong>off</strong></li>';
|
| 153 |
}
|
| 167 |
|
| 168 |
$_baseDirArray = explode("app", $baseDir);
|
| 169 |
$basePath = $_baseDirArray[0];
|
| 170 |
+
|
| 171 |
+
//Create folder if not exist. change for zip
|
| 172 |
+
if (!is_dir($basePath.'CoDzip/') )
|
| 173 |
+
{
|
| 174 |
+
if (!mkdir($basePath.'CoDzip/'))
|
| 175 |
+
{
|
| 176 |
+
$fail .= "<li>Could not create <strong>CoDzip</strong> folder.</li>";
|
| 177 |
+
$fail .= "<li>Please create <strong>CoDzip manually</strong> in ".$basePath."</li>";
|
| 178 |
|
| 179 |
+
}
|
| 180 |
+
}
|
| 181 |
+
if (is_dir($basePath.'CoDzip/') )
|
| 182 |
+
{
|
| 183 |
+
if (!is_dir($basePath.'CoDzip/CoDfiles/') )
|
| 184 |
+
{
|
| 185 |
+
if (!mkdir($basePath.'CoDzip/CoDfiles/'))
|
| 186 |
+
{
|
| 187 |
+
$fail .= "<li>Could not create <strong>CoDzip/CoDfiles</strong> folder.</li>";
|
| 188 |
+
$fail .= "<li>Please create <strong>CoDzip/CoDfiles manually</strong> in ".$basePath."</li>";
|
| 189 |
+
}
|
| 190 |
+
}
|
| 191 |
+
}
|
| 192 |
+
/*if ( !is_dir($basePath.'CoDzip/CoDfiles/') ){
|
| 193 |
+
if ( !mkdir($basePath.'CoDzip/CoDFiles/') ){
|
| 194 |
|
| 195 |
+
$fail .= "<li>Could not create <strong>CoDzip</strong> folder.</li>";
|
| 196 |
+
$fail .= "<li>Please create <strong>CoDzip manually</strong> in ".$basePath."</li>";
|
| 197 |
}
|
| 198 |
+
}*/
|
| 199 |
|
| 200 |
$is_file = true;
|
| 201 |
|
| 202 |
if ( !$codimodel->createFile($basePath) ){
|
| 203 |
+
$fail .= "<li>The Magento extension was prevented from creating a file in the folder CoDzip. Please notify your Magento administrator.</li>";
|
| 204 |
$is_file = false;
|
| 205 |
}
|
| 206 |
|
| 324 |
$text = "<p id='codi_status_template_button'>Your test data file was created successfully. <img src='".$this->getSkinUrl($this->__('images/codimport_yes.gif'))."' /> <button type='button' onclick='download_codi_file();' class='scalable add' style='margin-left:25px;' ><span>Download Data File</span></button> <button type='button' onclick='delete_codi_file();' class='scalable add' style='margin-left:25px;' ><span>Delete Data File</span></button></p>";
|
| 325 |
$codimodel->deleteTable();
|
| 326 |
}else if ( $status== "start" && $message['finished'] == 0 ) {
|
| 327 |
+
$text = "<p>A test data file is now being created. <span style='margin-left:15px;'><img src='".$this->getSkinUrl($this->__('images/codimport_run.gif'))."' /></span> </p>" ;
|
| 328 |
}else if ( $status== "fileerror" && $message['finished'] == 0 ) {
|
| 329 |
$text = "<p>Your test data file was not created. Please contact your administrator.</p>";
|
| 330 |
$codimodel->deleteTable();
|
| 337 |
//Changed on version 2.2.15
|
| 338 |
//$text .= "<a href='#datafilebackground_tooltip'><img src='".$this->getSkinUrl($this->__('images/preview_field_help.png'))."' /></a><input type='checkbox' id='background_process' name='background_process' ".$codbg_checked." style='margin:0px 5px 0px 15px;cursor:pointer' onclick='onBackgroundProcess(this)' />Create data file using background process<br /><br />";
|
| 339 |
$text .= "<button type='button' class='scalable add' onclick='start_codi_import()' style='margin-left:25px;' ><span>Test</span></button>";
|
|
|
|
|
|
|
| 340 |
}
|
| 341 |
+
|
| 342 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 343 |
}
|
| 344 |
break;
|
| 345 |
case "auth":
|
| 397 |
<input type="radio" value="manual" id="manual" name="datafilelaunch" <?php if ($datafilelaunch =="manual") echo "checked" ?> onclick="displayBlock('codi_status_template','cronjob','0');"/> <label for="manual">Manual <a href="#manual_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></label><br>
|
| 398 |
<p id="codi_status_template" name="codi_status_template" style="display:<?php if ($datafilelaunch =="manual") echo 'block'; else echo 'none';?>;">
|
| 399 |
<?php
|
| 400 |
+
$filename = $basePath.'CoDzip/CoDMagento.zip';
|
| 401 |
if (file_exists($filename)) {
|
| 402 |
+
|
| 403 |
+
$url = $this->getUrl('CoDzip/CoDMagento.zip') ;
|
| 404 |
+
$pos = strrpos ($url , 'key') ;
|
| 405 |
+
if ( $pos != 0 )
|
| 406 |
+
$url = substr( $url , 0 , $pos ) ;
|
| 407 |
+
else
|
| 408 |
+
$url = $url;
|
| 409 |
+
|
| 410 |
+
$zipfileurl=str_replace("index.php/CoDzip/CoDMagento.zip/index/", "CoDzip/CoDMagento.zip",$url);
|
| 411 |
+
$modifie="<input class='input-text' type='text' name='zipfileurl' value='".$zipfileurl."'><br/>" ;
|
| 412 |
+
$modifie.="Last Created Date: " . date("M d, Y H:i:s.", filemtime($filename));
|
| 413 |
echo $modifie." <button type='button' onclick='download_codi_file();' class='scalable add' style='margin-left:25px;' ><span>Download Data File</span></button> <button type='button' onclick='delete_codi_file();' class='scalable add' style='margin-left:25px;' ><span>Delete Data File</span></button>";
|
| 414 |
}
|
| 415 |
else{
|
| 416 |
?>
|
| 417 |
+
<button type='button' class='scalable add' onclick='start_codi_import()' style='margin-left:25px;' ><span>Create Data File</span></button>
|
| 418 |
<?php }?>
|
| 419 |
</p>
|
| 420 |
|
| 732 |
requestTimeout: 100,
|
| 733 |
|
| 734 |
onSuccess: function(transport) {
|
|
|
|
|
|
|
| 735 |
var ret_msg = transport.responseText.evalJSON();
|
| 736 |
+
var status_div = document.getElementById('codi_status_template');
|
| 737 |
var v;
|
| 738 |
+
var totalproduct=ret_msg.length;
|
| 739 |
+
//check total products
|
| 740 |
+
if(totalproduct==0)
|
| 741 |
+
{
|
| 742 |
+
status_div.innerHTML = "<p>Your test data file was not created. Please contact your administrator.</p>";
|
|
|
|
|
|
|
| 743 |
}
|
| 744 |
+
else
|
| 745 |
+
{
|
| 746 |
+
for (var i=0;i<ret_msg.length;i++)
|
| 747 |
+
{
|
| 748 |
+
//alert(ret_msg[i]);
|
| 749 |
+
productid=ret_msg[i];
|
| 750 |
+
var j=i+1;
|
| 751 |
+
v=createfilenew(productid,j,totalproduct);
|
| 752 |
+
}
|
| 753 |
+
}
|
| 754 |
+
|
| 755 |
if ( ret_msg.success == 1 ){
|
| 756 |
+
status_div.innerHTML = "<p>A test data file is now being created. <span style='margin-left:15px;'><img src=\"<?=$this->getSkinUrl($this->__('images/codimport_run.gif'))?>\" ></span> </p>";
|
| 757 |
_this.updateTimer = setInterval(function(){_this.updateEvent();}, 10000);
|
| 758 |
}else if ( ret_msg.error == 1 ){
|
| 759 |
+
status_div.innerHTML = "<p>The Magento extension was prevented from creating a file in the folder CoDDataFile. Please notify your Magento administrator.</p>";
|
| 760 |
}else if ( ret_msg.exec == 1 || ret_msg.shellexec == 1 ) {
|
| 761 |
status_div.innerHTML = "<p>The <strong>exec</strong> and/or <strong>shell_exec</strong> functions are disabled in your php.ini. See the line starting with <strong>'disable_functions ='</strong>. Unless you remove both <strong>'exec'</strong> and <strong>'shell_exec'</strong> from this line, you may not use the background process to create data files. This may be a problem if you have a large product database.</p>";
|
| 762 |
}
|
| 933 |
onSuccess: function(transport) {
|
| 934 |
r= transport.responseText;
|
| 935 |
if(r=='100'){
|
| 936 |
+
//alert(r+'create');
|
| 937 |
+
status_div.innerHTML="Building Hierarchy";
|
| 938 |
+
createfileCatalogSection();
|
| 939 |
}
|
| 940 |
else{
|
| 941 |
if(r!="error"){
|
| 942 |
+
status_div.innerHTML="<p id='codi_status_template_button'>"+transport.responseText+"% </p><p>A test data file is now being created. <span style='margin-left:15px;'><img src=\"<?=$this->getSkinUrl($this->__('images/codimport_run.gif'))?>\" ></span> </p>";
|
| 943 |
}
|
| 944 |
}
|
| 945 |
if(r=="error")
|
| 951 |
|
| 952 |
//onFailure: this.ajaxFailure.bind(),
|
| 953 |
});
|
| 954 |
+
return r;
|
| 955 |
+
}
|
| 956 |
+
function createfileCatalogSection()
|
| 957 |
+
{
|
| 958 |
+
var img_url = "<?php echo $this->getSkinUrl($this->__('images/codimport_yes.gif')) ?>";
|
| 959 |
+
var r;
|
| 960 |
+
var base = "<?php echo $basePath ?>";
|
| 961 |
+
var status_div = document.getElementById('codi_status_template');
|
| 962 |
+
status_div.innerHTML='Building Hierarchy';
|
| 963 |
+
var a = new Ajax.Request("<?php echo $createCatalogSection; ?>",
|
| 964 |
+
{ asynchronous:false,
|
| 965 |
+
method: 'post',
|
| 966 |
+
parameters: "basepath="+base,
|
| 967 |
+
onSuccess: function(transport) {
|
| 968 |
+
r= transport.responseText;
|
| 969 |
+
//alert(r+'section');
|
| 970 |
+
if(r=='100'){
|
| 971 |
+
t=createfileCatalogProject();
|
| 972 |
+
if(t=='10'){
|
| 973 |
+
status_div.innerHTML="<p id='codi_status_template_button'>"+transport.responseText+"% </p> <input class='input-text' type='text' name='zipfileurl' value='<?php echo $zipurl?>CoDMagento.zip'><br/> Your test data file was created successfully.<img src='" + img_url + "' /><button type='button' class='scalable add' style='margin-left:25px;' onclick='download_codi_file();' ><span>Download Data File</span></button><button type='button' class='scalable add' style='margin-left:25px;' onclick='delete_codi_file();' ><span>Delete Data File</span></button> ";
|
| 974 |
+
}
|
| 975 |
+
|
| 976 |
+
}
|
| 977 |
+
else{
|
| 978 |
+
if(r!="error"){
|
| 979 |
+
status_div.innerHTML="<p id='codi_status_template_button'>"+transport.responseText+"% </p><p>A test data file is now being created. <span style='margin-left:15px;'><img src=\"<?=$this->getSkinUrl($this->__('images/codimport_run.gif'))?>\" ></span> </p>";
|
| 980 |
+
}
|
| 981 |
+
}
|
| 982 |
+
if(r=="0")
|
| 983 |
+
{
|
| 984 |
+
status_div.innerHTML="<p>Your test data file was not created. Please contact your administrator( File Error ).</p>";
|
| 985 |
+
}
|
| 986 |
|
| 987 |
+
}
|
| 988 |
+
|
| 989 |
+
//onFailure: this.ajaxFailure.bind(),
|
| 990 |
+
});
|
| 991 |
+
return r;
|
| 992 |
+
}
|
| 993 |
|
| 994 |
+
function createfileCatalogProject()
|
| 995 |
+
{
|
| 996 |
+
var img_url = "<?php echo $this->getSkinUrl($this->__('images/codimport_yes.gif')) ?>";
|
| 997 |
+
var r;
|
| 998 |
+
var base = "<?php echo $basePath ?>";
|
| 999 |
+
var status_div = document.getElementById('codi_status_template');
|
| 1000 |
+
status_div.innerHTML='Merging with Hierarchy';
|
| 1001 |
+
var a = new Ajax.Request("<?php echo $createCatalogProject; ?>",
|
| 1002 |
+
{ asynchronous:false,
|
| 1003 |
+
method: 'post',
|
| 1004 |
+
parameters: "basepath="+base,
|
| 1005 |
+
onSuccess: function(transport) {
|
| 1006 |
+
r= transport.responseText;
|
| 1007 |
+
if(r=='10'){
|
| 1008 |
+
status_div.innerHTML="<p id='codi_status_template_button'>"+transport.responseText+"% </p> Your test data file was created successfully.<img src='" + img_url + "' /><button type='button' class='scalable add' style='margin-left:25px;' onclick='download_codi_file();' ><span>Download Data File</span></button><button type='button' class='scalable add' style='margin-left:25px;' onclick='delete_codi_file();' ><span>Delete Data File</span></button> ";
|
| 1009 |
+
|
| 1010 |
+
}
|
| 1011 |
+
else{
|
| 1012 |
+
if(r!="error"){
|
| 1013 |
+
status_div.innerHTML="<p id='codi_status_template_button'>"+transport.responseText+"% </p><p>A test data file is now being created. <span style='margin-left:15px;'><img src=\"<?=$this->getSkinUrl($this->__('images/codimport_run.gif'))?>\" ></span> </p>";
|
| 1014 |
+
}
|
| 1015 |
+
}
|
| 1016 |
+
if(r=="error")
|
| 1017 |
+
{
|
| 1018 |
+
status_div.innerHTML="<p>Your test data file was not created. Please contact your administrator( File Error ).</p>";
|
| 1019 |
+
}
|
| 1020 |
|
| 1021 |
+
}
|
| 1022 |
+
|
| 1023 |
+
//onFailure: this.ajaxFailure.bind(),
|
| 1024 |
+
});
|
| 1025 |
+
return r;
|
| 1026 |
}
|
| 1027 |
+
|
| 1028 |
+
|
| 1029 |
</script>
|
package.xml
CHANGED
|
@@ -1,18 +1,18 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Mage_PDF_per_Product</name>
|
| 4 |
-
<version>3.0.
|
| 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>Catalog-On-Demand</summary>
|
| 10 |
<description>Catalog-On-Demand</description>
|
| 11 |
-
<notes>3.0.
|
| 12 |
<authors><author><name>catalogondemand</name><user>auto-converted</user><email>timh@catalog-on-demand.com</email></author></authors>
|
| 13 |
-
<date>2011-11-
|
| 14 |
-
<time>
|
| 15 |
-
<contents><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><file name="codimport_run.gif" hash="e805ea7eca1f34c75ba0f93780d32d38"/><file name="codimport_yes.gif" hash="0afb20898a704a106cb4c598868abf32"/><file name="preview_field_help.png" hash="1b1601459d25e8b1a6b1d109782078d2"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="codi"><file name="index.phtml" hash="
|
| 16 |
<compatible/>
|
| 17 |
<dependencies/>
|
| 18 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Mage_PDF_per_Product</name>
|
| 4 |
+
<version>3.0.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>Catalog-On-Demand</summary>
|
| 10 |
<description>Catalog-On-Demand</description>
|
| 11 |
+
<notes>3.0.3- Added Catalog Project, Sections and Data file support</notes>
|
| 12 |
<authors><author><name>catalogondemand</name><user>auto-converted</user><email>timh@catalog-on-demand.com</email></author></authors>
|
| 13 |
+
<date>2011-11-30</date>
|
| 14 |
+
<time>13:11:34</time>
|
| 15 |
+
<contents><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><file name="codimport_run.gif" hash="e805ea7eca1f34c75ba0f93780d32d38"/><file name="codimport_yes.gif" hash="0afb20898a704a106cb4c598868abf32"/><file name="preview_field_help.png" hash="1b1601459d25e8b1a6b1d109782078d2"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="codi"><file name="index.phtml" hash="e204d0039245b924dbd3aee76b1fbe24"/></dir></dir><dir name="layout"><file name="codi.xml" hash="9407985f30403744eb4e758312d62aef"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="catalog"><dir name="product"><file name="view.phtml" hash="de6b3d9d0787a3f96955b8089898b441"/></dir></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="jquery"><file name="jquery-1.2.6.noConflict.min.js" hash="090fdb3fbcb4727c0ca20cca87e7e12d"/><file name="jquery.tooltip.js" hash="d17cc8af1b8a595bd597084232be87e0"/></dir></dir></target><target name="magecommunity"><dir name="Mage"><dir name="Codi"><dir name="Block"><dir name="Adminhtml"><file name="Menu.php" hash="f1f1858f0d5b9ce563e45781dbf6f633"/><file name="Switcher.php" hash="2a8001fa18ff263d6c4a05353e131825"/></dir><dir name="Customer"><file name="Codi.php" hash="a2769ec72db46ce58ceb28823c3dc1a0"/></dir></dir><dir name="Helper"><file name="Createzip.php" hash="e8b8b3e49977be20e127971231988f0c"/><file name="Data.php" hash="aa377a808ccc8dab324f4af7455f7266"/></dir><dir name="Model"><file name="Codi.php" hash="b1780275d73ad81efef4d80e94841672"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="MenuController.php" hash="00301b123b460d9b9ac58382701e5806"/></dir><file name="DeleteController.php" hash="7267c76bf9575d0d905d19e281b89905"/><file name="NsyncController.php" hash="8456908a4239529c39f897f07a40b9bc"/><file name="SyncController.php" hash="9c6efa00791d96ec4d10880973975f58"/></dir><dir name="etc"><file name="config.xml" hash="990ef657eb05edec176759ca36d21e56"/></dir><file name="Codi_Process.php" hash="543456357988f8f8301f959fa75f9bb6"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mage_Codi.xml" hash="5d635cd2a0d415b67f095bda0298445d"/></dir></target></contents>
|
| 16 |
<compatible/>
|
| 17 |
<dependencies/>
|
| 18 |
</package>
|
