Version Notes
Version 2.1.1
Download this release
Release Info
Developer | Celebros LTD |
Extension | Celebros_Salesperson_Site_Search |
Version | 2.1.1 |
Comparing to | |
See all releases |
Code changes from version 2.0.0 to 2.1.1
- app/code/{local → community}/Celebros/Salesperson/Block/Adminhtml/Mapping.php +27 -29
- app/code/community/Celebros/Salesperson/Block/Analytics/View.php +61 -0
- app/code/community/Celebros/Salesperson/Block/Checkout/Cart/Crosssell.php +86 -0
- app/code/community/Celebros/Salesperson/Block/Giftfinder/View.php +305 -0
- app/code/{local → community}/Celebros/Salesperson/Block/Layer.php +58 -58
- app/code/{local → community}/Celebros/Salesperson/Block/Layer/State.php +112 -107
- app/code/community/Celebros/Salesperson/Block/Layer/View.php +490 -0
- app/code/community/Celebros/Salesperson/Block/Layer/Widget/RadioButtonQuestion.php +39 -0
- app/code/community/Celebros/Salesperson/Block/Navigation.php +36 -0
- app/code/{local → community}/Celebros/Salesperson/Block/Product/Abstract.php +313 -440
- app/code/{local → community}/Celebros/Salesperson/Block/Product/List.php +138 -137
- app/code/{local → community}/Celebros/Salesperson/Block/Product/List/Toolbar.php +886 -909
- app/code/{local → community}/Celebros/Salesperson/Block/Product/List/Toolbar/Pager.php +559 -559
- app/code/{local → community}/Celebros/Salesperson/Block/Result.php +266 -265
- app/code/{local → community}/Celebros/Salesperson/Block/Review/Helper.php +52 -52
- app/code/{local → community}/Celebros/Salesperson/Block/System/Convert/Profile/Edit/Tab/Run.php +74 -59
- app/code/{local → community}/Celebros/Salesperson/Helper/Checkout/Cart.php +46 -46
- app/code/community/Celebros/Salesperson/Helper/Data.php +723 -0
- app/code/{local → community}/Celebros/Salesperson/Helper/Mapping.php +28 -28
- app/code/{local → community}/Celebros/Salesperson/Helper/Product/Compare.php +40 -40
- app/code/{local → community}/Celebros/Salesperson/Helper/Wishlist/Data.php +58 -58
- app/code/{local/Celebros/Salesperson/Model/Api/domxml-php4-to-php5.php → community/Celebros/Salesperson/Model/Api/DomXMLPhp4ToPhp5.php} +334 -316
- app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserAnswer.php +38 -29
- app/code/community/Celebros/Salesperson/Model/Api/QwiserAnsweredAnswer.php +25 -0
- app/code/community/Celebros/Salesperson/Model/Api/QwiserAnsweredAnswers.php +77 -0
- app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserAnswers.php +100 -91
- app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserConcept.php +30 -21
- app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserConcepts.php +32 -23
- app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserProduct.php +52 -43
- app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserProductAnswer.php +29 -20
- app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserProductAnswers.php +31 -21
- app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserProductField.php +25 -16
- app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserProductFields.php +31 -22
- app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserProducts.php +35 -26
- app/code/community/Celebros/Salesperson/Model/Api/QwiserQuestion.php +52 -0
- app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserQuestions.php +100 -90
- app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserSearchPath.php +31 -22
- app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserSearchPathEntry.php +26 -17
- app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserSearchResults.php +119 -110
- app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserSpellerInformation.php +26 -17
- app/code/community/Celebros/Salesperson/Model/Api/SearchInformation.php +228 -0
- app/code/community/Celebros/Salesperson/Model/Api/SortingOptions.php +64 -0
- app/code/community/Celebros/Salesperson/Model/Api/SpecialCasesDetectedInThisSession.php +35 -0
- app/code/community/Celebros/Salesperson/Model/Catalog/Category.php +91 -0
- app/code/community/Celebros/Salesperson/Model/Catalog/Url.php +126 -0
- app/code/{local → community}/Celebros/Salesperson/Model/Convert/Adapter/Io.php +157 -157
- app/code/{local → community}/Celebros/Salesperson/Model/Convert/Mapper/Column.php +175 -175
- app/code/{local → community}/Celebros/Salesperson/Model/Convert/Parser/Product.php +217 -217
- app/code/{local → community}/Celebros/Salesperson/Model/Layer.php +65 -65
- app/code/{local → community}/Celebros/Salesperson/Model/Layer/State.php +66 -66
- app/code/{local → community}/Celebros/Salesperson/Model/Layout.php +129 -129
- app/code/{local → community}/Celebros/Salesperson/Model/Mapping.php +31 -31
- app/code/{local → community}/Celebros/Salesperson/Model/Mysql4/Mapping.php +6 -6
- app/code/{local → community}/Celebros/Salesperson/Model/Mysql4/Mapping/Collection.php +7 -7
- app/code/{local → community}/Celebros/Salesperson/Model/Mysql4/Qwiser.php +30 -30
- app/code/{local → community}/Celebros/Salesperson/Model/Observer.php +1265 -1065
- app/code/community/Celebros/Salesperson/Model/ObserverLarge.php +649 -0
- app/code/{local → community}/Celebros/Salesperson/Model/Product.php +212 -216
- app/code/community/Celebros/Salesperson/Model/SalespersonCrossSellApi.php +80 -0
- app/code/{local → community}/Celebros/Salesperson/Model/SalespersonSearchApi.php +592 -566
- app/code/{local → community}/Celebros/Salesperson/Model/Session.php +22 -22
- app/code/{local → community}/Celebros/Salesperson/Model/System/Config/Backend/Export/Cron.php +42 -42
- app/code/community/Celebros/Salesperson/Model/System/Config/Backend/Navigationtosearch/Enable.php +65 -0
- app/code/{local → community}/Celebros/Salesperson/Model/System/Config/Source/Fileftp.php +18 -18
- app/code/community/Celebros/Salesperson/Model/System/Config/Source/Giftfindertypes.php +25 -0
- app/code/{local → community}/Celebros/Salesperson/Model/System/Config/Source/Layouts.php +26 -26
- app/code/{local → community}/Celebros/Salesperson/Model/System/Config/Source/Lead.php +18 -18
- app/code/community/Celebros/Salesperson/Model/System/Config/Source/Navigationtosearch.php +21 -0
- app/code/{local → community}/Celebros/Salesperson/Model/System/Config/Source/Nonlead.php +19 -19
- app/code/{local → community}/Celebros/Salesperson/Model/System/Config/Source/Pagenavtype.php +18 -18
- app/code/community/Celebros/Salesperson/Model/System/Config/Source/Pricetype.php +19 -0
- app/code/{local → community}/Celebros/Salesperson/Model/System/Config/Source/Selectortype.php +18 -18
- app/code/{local → community}/Celebros/Salesperson/controllers/Adminhtml/MappingController.php +40 -40
- app/code/community/Celebros/Salesperson/controllers/ExportController.php +95 -0
- app/code/community/Celebros/Salesperson/controllers/GiftfinderController.php +301 -0
- app/code/{local → community}/Celebros/Salesperson/controllers/IndexController.php +10 -10
- app/code/{local → community}/Celebros/Salesperson/controllers/ResultController.php +462 -376
- app/code/community/Celebros/Salesperson/controllers/TestController.php +13 -0
- app/code/community/Celebros/Salesperson/docs/Celebros Salesperson - Magento plugin configuration manual 2011 extension.pdf +0 -0
- app/code/community/Celebros/Salesperson/docs/Release_notes.txt +70 -0
- app/code/community/Celebros/Salesperson/etc/config.xml +317 -0
- app/code/community/Celebros/Salesperson/etc/config.xml.gpg +0 -0
- app/code/{local → community}/Celebros/Salesperson/etc/system.xml +654 -389
- app/code/{local → community}/Celebros/Salesperson/sql/salesperson_setup/mysql4-install-0.1.0.php +67 -73
- app/code/{local → community}/Celebros/Salesperson/sql/salesperson_setup/mysql4-upgrade-0.1.0-0.1.1.php +43 -44
- app/code/community/Celebros/Salesperson/sql/salesperson_setup/mysql4-upgrade-0.1.1-0.1.2.php +42 -0
- app/code/local/Celebros/Salesperson/Block/Layer/View.php +0 -183
- app/code/local/Celebros/Salesperson/Helper/Data.php +0 -380
- app/code/local/Celebros/Salesperson/Model/Api/Anlx/AnalyticsFunctions.php +0 -355
- app/code/local/Celebros/Salesperson/Model/Api/Anlx/DataStructure.php +0 -58
- app/code/local/Celebros/Salesperson/Model/Api/Anlx/DynamicProperty.php +0 -179
- app/code/local/Celebros/Salesperson/Model/Api/Anlx/Holders.php +0 -225
- app/code/local/Celebros/Salesperson/Model/Api/Anlx/LogRequest.php +0 -637
- app/code/local/Celebros/Salesperson/Model/Api/Anlx/RunLogReq.php +0 -28
- app/code/local/Celebros/Salesperson/Model/Api/Anlx/StringEncoder.php +0 -42
- app/code/local/Celebros/Salesperson/Model/Api/Anlx/ValidateResult.php +0 -69
- app/code/local/Celebros/Salesperson/Model/Api/Anlx/packetizer.php +0 -53
- app/code/local/Celebros/Salesperson/Model/Api/QwiserQuestion.php +0 -30
- app/code/local/Celebros/Salesperson/Model/Api/SearchInformation.php +0 -44
- app/code/local/Celebros/Salesperson/Model/Api/SortingOptions.php +0 -20
- app/code/local/Celebros/Salesperson/Model/Convert/Parser/Csv.php +0 -287
- app/code/local/Celebros/Salesperson/Model/SalespersonAnalyticsApi.php +0 -118
- app/code/local/Celebros/Salesperson/Model/createZip.php +0 -181
- app/code/local/Celebros/Salesperson/controllers/ExportController.php +0 -426
- app/code/local/Celebros/Salesperson/etc/config.xml +0 -258
- app/design/adminhtml/default/default/layout/salesperson.xml +3 -3
- app/etc/modules/Celebros_Salesperson.xml +1 -1
- package.xml +59 -10
app/code/{local → community}/Celebros/Salesperson/Block/Adminhtml/Mapping.php
RENAMED
@@ -1,30 +1,28 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Celebros_Salesperson_Block_Adminhtml_Mapping extends
|
4 |
-
|
5 |
-
private $_fieldsCollection;
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Load fields collection
|
9 |
-
*
|
10 |
-
* @return Celebros_Salesperson_Model_Mysql4_Mapping_Collection
|
11 |
-
*/
|
12 |
-
protected function _loadFieldsCollection(){
|
13 |
-
if(!$this->_fieldsCollection){
|
14 |
-
$this->_fieldsCollection = Mage::getSingleton("salesperson/mapping")->getCollection();
|
15 |
-
}
|
16 |
-
return $this->_fieldsCollection;
|
17 |
-
}
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Get fields collection
|
21 |
-
*
|
22 |
-
* @return Celebros_Salesperson_Model_Mysql4_Mapping_Collection
|
23 |
-
*
|
24 |
-
*/
|
25 |
-
public function getFields(){
|
26 |
-
$this->_loadFieldsCollection();
|
27 |
-
|
28 |
-
return $this->_fieldsCollection;
|
29 |
-
}
|
30 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Celebros_Salesperson_Block_Adminhtml_Mapping extends Mage_Adminhtml_Block_Widget{
|
4 |
+
|
5 |
+
private $_fieldsCollection;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Load fields collection
|
9 |
+
*
|
10 |
+
* @return Celebros_Salesperson_Model_Mysql4_Mapping_Collection
|
11 |
+
*/
|
12 |
+
protected function _loadFieldsCollection(){
|
13 |
+
if(!$this->_fieldsCollection){
|
14 |
+
$this->_fieldsCollection = Mage::getSingleton("salesperson/mapping")->getCollection();
|
15 |
+
}
|
16 |
+
return $this->_fieldsCollection;
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Get fields collection
|
21 |
+
*
|
22 |
+
* @return Celebros_Salesperson_Model_Mysql4_Mapping_Collection
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
public function getFields(){
|
26 |
+
return $this->_loadFieldsCollection();
|
27 |
+
}
|
|
|
|
|
28 |
}
|
app/code/community/Celebros/Salesperson/Block/Analytics/View.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
* @category Celebros
|
11 |
+
* @package Celebros_Salesperson
|
12 |
+
* @author Celebros - Pavel Feldman (email: MagentoSupport@celebros.com)
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
class Celebros_Salesperson_Block_Analytics_View extends Celebros_Salesperson_Block_Layer_View
|
16 |
+
{
|
17 |
+
const CATALOG_CATEGORY_ATTRIBUTE_ENTITY_TYPE = '9';
|
18 |
+
const CATALOG_PRODUCT_ATTRIBUTE_ENTITY_TYPE = '10';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Sets parameters for tempalte
|
22 |
+
*
|
23 |
+
* @return Celebros_Salesperson_Block_Analytics_View
|
24 |
+
*/
|
25 |
+
protected function _prepareLayout()
|
26 |
+
{
|
27 |
+
$this->setCustomerId(Mage::getStoreConfig('salesperson/anlx_settings/cid'));
|
28 |
+
$this->setHost(Mage::getStoreConfig('salesperson/anlx_settings/host'));
|
29 |
+
|
30 |
+
$product = $this->getProduct();
|
31 |
+
//Set product click tracking params
|
32 |
+
if(isset($product)){
|
33 |
+
$this->setProductId($product->getId());
|
34 |
+
$this->setProductName(str_replace("'", "\'", $product->getName()));
|
35 |
+
$this->setProductPrice($product->getFinalPrice());
|
36 |
+
$webSessionId = isset($_SESSION['core']['visitor_data']['session_id']) ? $_SESSION['core']['visitor_data']['session_id'] : session_id();
|
37 |
+
$this->setWebsessionId($webSessionId);
|
38 |
+
}
|
39 |
+
//Set search tracking params
|
40 |
+
else {
|
41 |
+
$pageReferrer = Mage::getModel('core/url')->getBaseUrl() . $_SERVER['PHP_SELF'];
|
42 |
+
$this->setPageReferrer($pageReferrer);
|
43 |
+
$this->setQwiserSearchSessionId(Mage::getSingleton('salesperson/session')->getSearchSessionId());
|
44 |
+
$webSessionId = isset($_SESSION['core']['visitor_data']['session_id']) ? $_SESSION['core']['visitor_data']['session_id'] : session_id();
|
45 |
+
$this->setWebsessionId($webSessionId);
|
46 |
+
$this->setQwiserSearchLogHandle(Mage::Helper('salesperson')->getSalespersonApi()->results->GetLogHandle());
|
47 |
+
}
|
48 |
+
|
49 |
+
return parent::_prepareLayout();
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Retrieve current product model
|
54 |
+
*
|
55 |
+
* @return Mage_Catalog_Model_Product
|
56 |
+
*/
|
57 |
+
public function getProduct()
|
58 |
+
{
|
59 |
+
return Mage::registry('product');
|
60 |
+
}
|
61 |
+
}
|
app/code/community/Celebros/Salesperson/Block/Checkout/Cart/Crosssell.php
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
* @category Celebros
|
11 |
+
* @package Celebros_Salesperson
|
12 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Celebros_Salesperson_Block_Checkout_Cart_Crosssell extends Mage_Checkout_Block_Cart_Crosssell {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Get crosssell items
|
20 |
+
*
|
21 |
+
* @return array
|
22 |
+
*/
|
23 |
+
public function getItems()
|
24 |
+
{
|
25 |
+
$items = $this->getData('items');
|
26 |
+
if (is_null($items)) {
|
27 |
+
|
28 |
+
$lastAdded = null;
|
29 |
+
|
30 |
+
//This code path covers the 2 cases - product page and shoping cart
|
31 |
+
if($this->getProduct()!=null){
|
32 |
+
$lastAdded = $this->getProduct()->getId();
|
33 |
+
}
|
34 |
+
else{
|
35 |
+
$cartProductIds = $this->_getCartProductIds();
|
36 |
+
$lastAdded = null;
|
37 |
+
for($i=count($cartProductIds) -1; $i >=0 ; $i--){
|
38 |
+
$id = $cartProductIds[$i];
|
39 |
+
$parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($id);
|
40 |
+
if(empty($parentIds)){
|
41 |
+
$lastAdded = $id;
|
42 |
+
break;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
|
48 |
+
|
49 |
+
$crossSellIds = Mage::helper('salesperson')->getSalespersonCrossSellApi()->getRecommendationsIds($lastAdded);
|
50 |
+
|
51 |
+
$items = $this->_getCollection()
|
52 |
+
->addAttributeToFilter('entity_id', array('in' => $crossSellIds,));
|
53 |
+
}
|
54 |
+
|
55 |
+
$this->setData('items', $items);
|
56 |
+
return $items;
|
57 |
+
}
|
58 |
+
|
59 |
+
public function getItemCollection() {
|
60 |
+
return $this->getItems();
|
61 |
+
}
|
62 |
+
|
63 |
+
public function getItemCount()
|
64 |
+
{
|
65 |
+
return count($this->getItems());
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Get crosssell products collection
|
70 |
+
*/
|
71 |
+
protected function _getCollection()
|
72 |
+
{
|
73 |
+
$collection = Mage::getModel('catalog/product')
|
74 |
+
->getCollection()
|
75 |
+
->setStoreId(Mage::app()->getStore()->getId())
|
76 |
+
->addStoreFilter()
|
77 |
+
->setPageSize($this->_maxItemCount);
|
78 |
+
$this->_addProductAttributesAndPrices($collection);
|
79 |
+
|
80 |
+
Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($collection);
|
81 |
+
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
|
82 |
+
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection);
|
83 |
+
|
84 |
+
return $collection;
|
85 |
+
}
|
86 |
+
}
|
app/code/community/Celebros/Salesperson/Block/Giftfinder/View.php
ADDED
@@ -0,0 +1,305 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
* @category Celebros
|
11 |
+
* @package Celebros_Salesperson
|
12 |
+
* @author Celebros - Pavel Feldman (email: MagentoSupport@celebros.com)
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
class Celebros_Salesperson_Block_Giftfinder_View extends Celebros_Salesperson_Block_Layer_View
|
16 |
+
{
|
17 |
+
const CATALOG_CATEGORY_ATTRIBUTE_ENTITY_TYPE = '9';
|
18 |
+
const CATALOG_PRODUCT_ATTRIBUTE_ENTITY_TYPE = '10';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Runs empty query search if it has not ran yet
|
22 |
+
*
|
23 |
+
* @return Celebros_Salesperson_Block_Giftfinder_View
|
24 |
+
*/
|
25 |
+
protected function _prepareLayout()
|
26 |
+
{
|
27 |
+
$defaultSortBy = $this->getDefaultSortBy();
|
28 |
+
$bNumericsort = $this->getIsNumericSort($defaultSortBy);
|
29 |
+
|
30 |
+
if(!$this->getQwiserSearchResults()) {
|
31 |
+
$salesperson = Mage::helper('salesperson')->getSalespersonApi();
|
32 |
+
$salesperson->SearchAdvance(
|
33 |
+
"", //Query
|
34 |
+
Mage::Helper('salesperson')->getStoreGiftfinderProfile(),//SearchProfile
|
35 |
+
'',//AnswerId
|
36 |
+
'',//EffectOnSearchPath
|
37 |
+
'price',//PriceColumn
|
38 |
+
Mage::Helper('salesperson')->getDefaultPageSize(),//PageSize
|
39 |
+
$defaultSortBy,//Sortingfield
|
40 |
+
$bNumericsort,
|
41 |
+
true
|
42 |
+
);
|
43 |
+
}
|
44 |
+
|
45 |
+
if(!$this->getQwiserSearchResults()) return;
|
46 |
+
|
47 |
+
//$this->saveToSessionFiltersSideText();
|
48 |
+
$this->saveToSessionInitialFilters();
|
49 |
+
|
50 |
+
return parent::_prepareLayout();
|
51 |
+
}
|
52 |
+
|
53 |
+
protected function getDefaultSortBy()
|
54 |
+
{
|
55 |
+
return Mage::helper('salesperson')->getDefaultSortBy();
|
56 |
+
}
|
57 |
+
|
58 |
+
protected function getIsNumericSort($sortBy)
|
59 |
+
{
|
60 |
+
$bNumericsort = 1;
|
61 |
+
|
62 |
+
if($sortBy == 'price') {
|
63 |
+
$bNumericsort = 1;
|
64 |
+
}
|
65 |
+
else {
|
66 |
+
$sortableAttribute = Mage::getModel('eav/entity_attribute')->loadByCode(self::CATALOG_PRODUCT_ATTRIBUTE_ENTITY_TYPE,$sortBy);
|
67 |
+
|
68 |
+
if ($sortableAttribute->getBackendType() != 'int'){
|
69 |
+
$bNumericsort = 0;
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
return $bNumericsort;
|
74 |
+
}
|
75 |
+
|
76 |
+
/*public function getFilters() {
|
77 |
+
$filters = Mage::registry('giftfinder_filters');
|
78 |
+
if(!isset($filters))
|
79 |
+
{
|
80 |
+
$filters = array();
|
81 |
+
$tmpFilters = parent::getFilters();
|
82 |
+
|
83 |
+
|
84 |
+
|
85 |
+
foreach ($tmpFilters as $filter) {
|
86 |
+
if ($this->isAnsweredQuestion($filter))
|
87 |
+
continue;
|
88 |
+
$filters[$filter->Id] = $filter;
|
89 |
+
}
|
90 |
+
|
91 |
+
Mage::register('giftfinder_filters', $filters);
|
92 |
+
}
|
93 |
+
|
94 |
+
return $filters;
|
95 |
+
}*/
|
96 |
+
|
97 |
+
public function getMissingInitialFilters(){
|
98 |
+
return Mage::registry('missingInitialFilters');
|
99 |
+
}
|
100 |
+
|
101 |
+
public function setMissingInitialFilters($missingInitialFilters){
|
102 |
+
Mage::register('missingInitialFilters', $missingInitialFilters);
|
103 |
+
}
|
104 |
+
|
105 |
+
public function isDisabledFilter($filter)
|
106 |
+
{
|
107 |
+
$missingInitialFilters = $this->getMissingInitialFilters();
|
108 |
+
return isset($missingInitialFilters[$filter->Id]);
|
109 |
+
}
|
110 |
+
|
111 |
+
public function getOrderedFilters()
|
112 |
+
{
|
113 |
+
$filters = $this->getFilters();
|
114 |
+
|
115 |
+
if(!count($filters)) return array();
|
116 |
+
$initialFilters = Mage::getSingleton('salesperson/session')->getInitialFilters();
|
117 |
+
|
118 |
+
|
119 |
+
$missingInitialFilters = array();
|
120 |
+
foreach ($initialFilters as $filter)
|
121 |
+
{
|
122 |
+
if(!isset($filters[$filter->Id]))
|
123 |
+
{
|
124 |
+
$missingInitialFilters[$filter->Id] = $filter;
|
125 |
+
}
|
126 |
+
}
|
127 |
+
$this->setMissingInitialFilters($missingInitialFilters);
|
128 |
+
|
129 |
+
foreach ($filters as $filter)
|
130 |
+
{
|
131 |
+
$initialFilters[$filter->Id] = $filter;
|
132 |
+
}
|
133 |
+
|
134 |
+
//Updates the price question if requuires
|
135 |
+
//e.g. when price slider is set and this is not a first search stage
|
136 |
+
//$results = $this->getQwiserSearchResults();
|
137 |
+
//$filters = $this->handlePriceQuestion($initialFilters, $results->SearchInformation->Stage);
|
138 |
+
|
139 |
+
Mage::getSingleton('salesperson/session')->setInitialFilters($initialFilters);
|
140 |
+
return $initialFilters;
|
141 |
+
}
|
142 |
+
|
143 |
+
protected function saveToSessionFiltersSideText(){
|
144 |
+
$filters = parent::getFilters();
|
145 |
+
if(isset($filters)){
|
146 |
+
foreach ($filters as $filter) {
|
147 |
+
$questionId = $filter->Id;
|
148 |
+
$setFunc = "set" . $questionId . "SideText";
|
149 |
+
Mage::getSingleton('salesperson/session')->$setFunc($filter->SideText);
|
150 |
+
}
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
protected function saveToSessionInitialFilters(){
|
155 |
+
$results = $this->getQwiserSearchResults();
|
156 |
+
if($results->SearchInformation->Stage == 1) {
|
157 |
+
Mage::getSingleton('salesperson/session')->setInitialFilters(parent::getFilters());
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
protected function getFromSessionFilterSideText($questionId){
|
162 |
+
$getFunc = "get" . $questionId . "SideText";
|
163 |
+
return Mage::getSingleton('salesperson/session')->$getFunc();
|
164 |
+
}
|
165 |
+
|
166 |
+
protected function getFilterOptions($filter)
|
167 |
+
{
|
168 |
+
$options = array();
|
169 |
+
|
170 |
+
if(!$this->isAnsweredQuestion($filter)) {
|
171 |
+
$options[] = array(
|
172 |
+
'label' => 'Select ' . $filter->SideText,
|
173 |
+
'value' => '',
|
174 |
+
'params' => array("disabled"=>"disabled")
|
175 |
+
);
|
176 |
+
}
|
177 |
+
|
178 |
+
foreach ($filter->Answers->Items as $answer) {
|
179 |
+
$value = (Mage::helper('salesperson')->isGiftfinderStandardTemplate()) ? $answer->Id : $this->answerQuestionUrl($answer->Id) ;
|
180 |
+
$options[] = array(
|
181 |
+
'label' => $answer->Text,
|
182 |
+
'value' => $value
|
183 |
+
);
|
184 |
+
}
|
185 |
+
|
186 |
+
if(isset($filter->ExtraAnswers->Items)) {
|
187 |
+
foreach ($filter->ExtraAnswers->Items as $answer) {
|
188 |
+
$value = (Mage::helper('salesperson')->isGiftfinderStandardTemplate()) ? $answer->Id : $this->answerQuestionUrl($answer->Id) ;
|
189 |
+
$options[] = array(
|
190 |
+
'label' => $answer->Text,
|
191 |
+
'value' => $value
|
192 |
+
);
|
193 |
+
}
|
194 |
+
}
|
195 |
+
|
196 |
+
return $options;
|
197 |
+
}
|
198 |
+
|
199 |
+
public function getDisabledFilterHtmlSelect ($sideText) {
|
200 |
+
$options[] = array(
|
201 |
+
'label' => 'Select ' . $sideText,
|
202 |
+
'value' => '',
|
203 |
+
'params' => array("disabled"=>"disabled")
|
204 |
+
);
|
205 |
+
|
206 |
+
$extraParams = 'disabled="disabled"';
|
207 |
+
|
208 |
+
$select = Mage::app()->getLayout()->createBlock('core/html_select')
|
209 |
+
->setClass('validate-select')
|
210 |
+
->setExtraParams($extraParams)
|
211 |
+
->setValue('')
|
212 |
+
->setOptions($options);
|
213 |
+
return $select->getHtml();
|
214 |
+
}
|
215 |
+
|
216 |
+
public function getFilterHtmlSelect($filter)
|
217 |
+
{
|
218 |
+
$extraParams = (Mage::helper('salesperson')->isGiftfinderStandardTemplate()) ? null : 'onchange="celebrosSetLocation(this.options[this.selectedIndex].value)"' ;
|
219 |
+
|
220 |
+
$bDisabled = $this->isDisabledFilter($filter);
|
221 |
+
$disabledOptions[] = array(
|
222 |
+
'label' => 'Select ' . $filter->SideText,
|
223 |
+
'value' => '',
|
224 |
+
'params' => array("disabled"=>"disabled")
|
225 |
+
);
|
226 |
+
|
227 |
+
|
228 |
+
if($this->isAnsweredQuestion($filter) || $bDisabled) {
|
229 |
+
$extraParams = 'disabled="disabled"';
|
230 |
+
}
|
231 |
+
|
232 |
+
$options = $bDisabled ? $disabledOptions : $this->getFilterOptions($filter);
|
233 |
+
|
234 |
+
$select = Mage::app()->getLayout()->createBlock('core/html_select')
|
235 |
+
->setName('filter_' . $filter->Id)
|
236 |
+
->setId('filter_' . $filter->Id)
|
237 |
+
->setClass('validate-select')
|
238 |
+
->setExtraParams($extraParams)
|
239 |
+
->setValue('')
|
240 |
+
->setOptions($options);
|
241 |
+
return $select->getHtml();
|
242 |
+
}
|
243 |
+
|
244 |
+
public function getAnsweredAnswerHtmlSelect($searchPathAnsweredAnswer) {
|
245 |
+
$options = array();
|
246 |
+
$options[] = array(
|
247 |
+
'label' => $searchPathAnsweredAnswer->Text,
|
248 |
+
'value' => '',
|
249 |
+
'params' => array("disabled"=>"disabled")
|
250 |
+
);
|
251 |
+
|
252 |
+
$select = Mage::app()->getLayout()->createBlock('core/html_select')
|
253 |
+
->setName('answer_' . $searchPathAnsweredAnswer->Id)
|
254 |
+
->setId('answer_' . $searchPathAnsweredAnswer->Id)
|
255 |
+
->setClass('validate-select')
|
256 |
+
->setExtraParams('disabled="disabled"')
|
257 |
+
->setValue('')
|
258 |
+
->setOptions($options);
|
259 |
+
|
260 |
+
return $select->getHtml();
|
261 |
+
}
|
262 |
+
|
263 |
+
public function getSearchPathAnsweredAnswer($_filter){
|
264 |
+
$searchPathEntries = $this->getSearchPathEntries();
|
265 |
+
$searchPathEntry = $searchPathEntries[$_filter->Id];
|
266 |
+
return $searchPathEntry->Answers->Items[0];
|
267 |
+
}
|
268 |
+
|
269 |
+
public function getClearAllFiltersUrl(){
|
270 |
+
|
271 |
+
$answeredAnswers = Mage::helper('salesperson')->getAnsweredAnswers();
|
272 |
+
|
273 |
+
$answersIds = array_keys($answeredAnswers);
|
274 |
+
|
275 |
+
$answersIds = join(',', $answersIds);
|
276 |
+
$params['_current'] = true;
|
277 |
+
$params['_use_rewrite'] = false;
|
278 |
+
$params['_escape'] = true;
|
279 |
+
$params['_query'] = array(
|
280 |
+
'salespersonaction' => 'removeAllAnswers',
|
281 |
+
'searchHandle' => $this->getQwiserSearchResults()->GetSearchHandle(),
|
282 |
+
'answerIds' => $answersIds,
|
283 |
+
);
|
284 |
+
|
285 |
+
$url = Mage::getUrl('*/*/change', $params);
|
286 |
+
|
287 |
+
$page = (int)$this->getQwiserSearchResults()->SearchInformation->CurrentPage+1;
|
288 |
+
$url = preg_replace("/p=*\d/",'p='.$page, $url);
|
289 |
+
return $url;
|
290 |
+
}
|
291 |
+
|
292 |
+
public function answerQuestionsUrl(){
|
293 |
+
if(!$this->getQwiserSearchResults()) return "";
|
294 |
+
$url = parent::answerQuestionsUrl() . '&trigger=gf';
|
295 |
+
return $url;
|
296 |
+
}
|
297 |
+
|
298 |
+
public function answerQuestionUrl($answerId){
|
299 |
+
return parent::answerQuestionUrl($answerId) . "&trigger=gf";
|
300 |
+
}
|
301 |
+
|
302 |
+
public function isGiftfinderStandardTemplate(){
|
303 |
+
return Mage::helper('salesperson')->isGiftfinderStandardTemplate();
|
304 |
+
}
|
305 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Block/Layer.php
RENAMED
@@ -1,58 +1,58 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Block_Layer extends Mage_Catalog_Block_Layer_View
|
11 |
-
{
|
12 |
-
/**
|
13 |
-
* Retrieve salesperson search results object
|
14 |
-
*
|
15 |
-
* @return Celebros_Salesperson_Model_Api_QwiserSearchResults
|
16 |
-
*/
|
17 |
-
protected function getQwiserSearchResults(){
|
18 |
-
if(Mage::helper('salesperson')->getSalespersonApi()->results)
|
19 |
-
return Mage::helper('salesperson')->getSalespersonApi()->results;
|
20 |
-
}
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Retrieve relevant products count
|
24 |
-
*
|
25 |
-
* @return string
|
26 |
-
*/
|
27 |
-
public function getResultCount()
|
28 |
-
{
|
29 |
-
return $this->getQwiserSearchResults()->GetRelevantProductsCount();
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Get layer object
|
34 |
-
*
|
35 |
-
* @return Mage_Catalog_Model_Layer
|
36 |
-
*/
|
37 |
-
public function getLayer()
|
38 |
-
{
|
39 |
-
return Mage::getModel('salesperson/layer');
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Check availability display layer block
|
44 |
-
*
|
45 |
-
* @return bool
|
46 |
-
*/
|
47 |
-
public function canShowBlock()
|
48 |
-
{
|
49 |
-
$availableResCount = (int) Mage::app()->getStore()
|
50 |
-
->getConfig(Mage_CatalogSearch_Model_Layer::XML_PATH_DISPLAY_LAYER_COUNT );
|
51 |
-
|
52 |
-
if (!$availableResCount
|
53 |
-
|| ($availableResCount>=$this->getResultCount())) {
|
54 |
-
return parent::canShowBlock();
|
55 |
-
}
|
56 |
-
return false;
|
57 |
-
}
|
58 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Block_Layer extends Mage_Catalog_Block_Layer_View
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Retrieve salesperson search results object
|
14 |
+
*
|
15 |
+
* @return Celebros_Salesperson_Model_Api_QwiserSearchResults
|
16 |
+
*/
|
17 |
+
protected function getQwiserSearchResults(){
|
18 |
+
if(Mage::helper('salesperson')->getSalespersonApi()->results)
|
19 |
+
return Mage::helper('salesperson')->getSalespersonApi()->results;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Retrieve relevant products count
|
24 |
+
*
|
25 |
+
* @return string
|
26 |
+
*/
|
27 |
+
public function getResultCount()
|
28 |
+
{
|
29 |
+
return $this->getQwiserSearchResults()->GetRelevantProductsCount();
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Get layer object
|
34 |
+
*
|
35 |
+
* @return Mage_Catalog_Model_Layer
|
36 |
+
*/
|
37 |
+
public function getLayer()
|
38 |
+
{
|
39 |
+
return Mage::getModel('salesperson/layer');
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Check availability display layer block
|
44 |
+
*
|
45 |
+
* @return bool
|
46 |
+
*/
|
47 |
+
public function canShowBlock()
|
48 |
+
{
|
49 |
+
$availableResCount = (int) Mage::app()->getStore()
|
50 |
+
->getConfig(Mage_CatalogSearch_Model_Layer::XML_PATH_DISPLAY_LAYER_COUNT );
|
51 |
+
|
52 |
+
if (!$availableResCount
|
53 |
+
|| ($availableResCount>=$this->getResultCount())) {
|
54 |
+
return parent::canShowBlock();
|
55 |
+
}
|
56 |
+
return false;
|
57 |
+
}
|
58 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Block/Layer/State.php
RENAMED
@@ -1,107 +1,112 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Celebros Qwiser - Magento Extension
|
5 |
-
*
|
6 |
-
* @category Celebros
|
7 |
-
* @package Celebros_Salesperson
|
8 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
9 |
-
*
|
10 |
-
*/
|
11 |
-
|
12 |
-
class Celebros_Salesperson_Block_Layer_State extends Mage_Core_Block_Template
|
13 |
-
{
|
14 |
-
protected function getQwiserSearchResults(){
|
15 |
-
if(Mage::helper('salesperson')->getSalespersonApi()->results)
|
16 |
-
return Mage::helper('salesperson')->getSalespersonApi()->results;
|
17 |
-
}
|
18 |
-
/**
|
19 |
-
* Initialize Layer State template
|
20 |
-
*
|
21 |
-
*/
|
22 |
-
public function __construct()
|
23 |
-
{
|
24 |
-
parent::__construct();
|
25 |
-
$this->setTemplate('salesperson/layer/state.phtml');
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Retrieve active filters
|
30 |
-
*
|
31 |
-
* @return array
|
32 |
-
*/
|
33 |
-
public function getActiveFilters()
|
34 |
-
{
|
35 |
-
$filters = $this->getLayer()->getState()->getFilters();
|
36 |
-
if (!is_array($filters)) {
|
37 |
-
$filters = array();
|
38 |
-
}
|
39 |
-
return $filters;
|
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 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Celebros Qwiser - Magento Extension
|
5 |
+
*
|
6 |
+
* @category Celebros
|
7 |
+
* @package Celebros_Salesperson
|
8 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
|
12 |
+
class Celebros_Salesperson_Block_Layer_State extends Mage_Core_Block_Template
|
13 |
+
{
|
14 |
+
protected function getQwiserSearchResults(){
|
15 |
+
if(Mage::helper('salesperson')->getSalespersonApi()->results)
|
16 |
+
return Mage::helper('salesperson')->getSalespersonApi()->results;
|
17 |
+
}
|
18 |
+
/**
|
19 |
+
* Initialize Layer State template
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
public function __construct()
|
23 |
+
{
|
24 |
+
parent::__construct();
|
25 |
+
$this->setTemplate('salesperson/layer/state.phtml');
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Retrieve active filters
|
30 |
+
*
|
31 |
+
* @return array
|
32 |
+
*/
|
33 |
+
public function getActiveFilters()
|
34 |
+
{
|
35 |
+
$filters = $this->getLayer()->getState()->getFilters();
|
36 |
+
if (!is_array($filters)) {
|
37 |
+
$filters = array();
|
38 |
+
}
|
39 |
+
return $filters;
|
40 |
+
}
|
41 |
+
|
42 |
+
public function isMultiSelect() {
|
43 |
+
return Mage::getStoreConfigFlag('salesperson/display_settings/enable_non_lead_answers_multiselect');
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Retrieve Layer object
|
48 |
+
*
|
49 |
+
* @return Celebros_Salesperson_Model_Layer
|
50 |
+
*/
|
51 |
+
public function getLayer()
|
52 |
+
{
|
53 |
+
if (!$this->hasData('layer')) {
|
54 |
+
$this->setLayer(Mage::getSingleton('salesperson/layer'));
|
55 |
+
}
|
56 |
+
return $this->_getData('layer');
|
57 |
+
}
|
58 |
+
|
59 |
+
public function getStateRemoveUrl($answerId){
|
60 |
+
$params['_current'] = true;
|
61 |
+
$params['_use_rewrite'] = false;
|
62 |
+
$params['_escape'] = true;
|
63 |
+
$params['_query'] = array(
|
64 |
+
'salespersonaction' => 'removeAnswer',
|
65 |
+
'searchHandle' => $this->getQwiserSearchResults()->GetSearchHandle(),
|
66 |
+
'answerId' => $answerId,
|
67 |
+
);
|
68 |
+
$url = Mage::getUrl('*/*/change', $params);
|
69 |
+
$page = (int)$this->getQwiserSearchResults()->SearchInformation->CurrentPage+1;
|
70 |
+
$url = preg_replace("/p=*\d/",'p='.$page, $url);
|
71 |
+
return $url;
|
72 |
+
}
|
73 |
+
public function getClearAllFiltersUrl(){
|
74 |
+
$filters = $this->getLayer()->getState()->getFilters();
|
75 |
+
$answersIds = array();
|
76 |
+
if(!empty($filters)){
|
77 |
+
foreach($filters as $filter){
|
78 |
+
$answersIds[] = $filter['answers']->Items[0]->Id;
|
79 |
+
}
|
80 |
+
}
|
81 |
+
$answersIds = join(',', $answersIds);
|
82 |
+
$params['_current'] = true;
|
83 |
+
$params['_use_rewrite'] = false;
|
84 |
+
$params['_escape'] = true;
|
85 |
+
$params['_query'] = array(
|
86 |
+
'salespersonaction' => 'removeAllAnswers',
|
87 |
+
'searchHandle' => $this->getQwiserSearchResults()->GetSearchHandle(),
|
88 |
+
'answerIds' => $answersIds,
|
89 |
+
);
|
90 |
+
$url = Mage::getUrl('*/*/change', $params);
|
91 |
+
$page = (int)$this->getQwiserSearchResults()->SearchInformation->CurrentPage+1;
|
92 |
+
$url = preg_replace("/p=*\d/",'p='.$page, $url);
|
93 |
+
return $url;
|
94 |
+
}
|
95 |
+
|
96 |
+
public function getRemoveAnswersFromBredcrumbsUrl($answersIds){
|
97 |
+
$answersIds = join(',', $answersIds);
|
98 |
+
$params['_current'] = true;
|
99 |
+
$params['_use_rewrite'] = false;
|
100 |
+
$params['_escape'] = true;
|
101 |
+
$params['_query'] = array(
|
102 |
+
'salespersonaction' => 'removeAllAnswers',
|
103 |
+
'searchHandle' => $this->getQwiserSearchResults()->GetSearchHandle(),
|
104 |
+
'answerIds' => $answersIds,
|
105 |
+
);
|
106 |
+
$url = Mage::getUrl('*/*/change', $params);
|
107 |
+
$page = (int)$this->getQwiserSearchResults()->SearchInformation->CurrentPage+1;
|
108 |
+
$url = preg_replace("/p=*\d/",'p='.$page, $url);
|
109 |
+
$url = preg_replace("/renderAjax=*\d/",'', $url);
|
110 |
+
return $url;
|
111 |
+
}
|
112 |
+
}
|
app/code/community/Celebros/Salesperson/Block/Layer/View.php
ADDED
@@ -0,0 +1,490 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Block_Layer_View extends Mage_Core_Block_Template
|
11 |
+
{
|
12 |
+
protected $_radioButtonsQuestions = array();
|
13 |
+
|
14 |
+
protected function getQwiserSearchResults(){
|
15 |
+
if(Mage::helper('salesperson')->getSalespersonApi()->results)
|
16 |
+
return Mage::helper('salesperson')->getSalespersonApi()->results;
|
17 |
+
}
|
18 |
+
/**
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Prepare child blocks
|
22 |
+
*
|
23 |
+
* @return Celebros_Salesperson_Block_Layer_View
|
24 |
+
*/
|
25 |
+
protected function _prepareLayout()
|
26 |
+
{
|
27 |
+
$stateBlock = $this->getLayout()->createBlock('salesperson/layer_state')
|
28 |
+
->setLayer($this->getLayer());
|
29 |
+
$this->setChild('layer_state', $stateBlock);
|
30 |
+
|
31 |
+
$this->_setRadioButtonsQuestions();
|
32 |
+
|
33 |
+
return parent::_prepareLayout();
|
34 |
+
}
|
35 |
+
|
36 |
+
protected function _setRadioButtonsQuestions(){
|
37 |
+
$arrSideText = explode(',',Mage::getStoreConfig('salesperson/display_settings/radiobuttons_questions'));
|
38 |
+
for($i = 0; $i < count($arrSideText) ; $i++) {
|
39 |
+
$sideText = $arrSideText[$i];
|
40 |
+
$this->_radioButtonsQuestions[$sideText] = $sideText;
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Get layer object
|
46 |
+
*
|
47 |
+
* @return Celebros_Salesperson_Model_Layer
|
48 |
+
*/
|
49 |
+
public function getLayer()
|
50 |
+
{
|
51 |
+
return Mage::getSingleton('salesperson/layer');
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Get layered navigation state html
|
56 |
+
*
|
57 |
+
* @return string
|
58 |
+
*/
|
59 |
+
public function getStateHtml()
|
60 |
+
{
|
61 |
+
return $this->getChildHtml('layer_state');
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Get all layer filters
|
66 |
+
*
|
67 |
+
* @return array
|
68 |
+
*/
|
69 |
+
public function getFilters()
|
70 |
+
{
|
71 |
+
$filters = Mage::registry('layer_filters');
|
72 |
+
|
73 |
+
if(!isset($filters)){
|
74 |
+
$results = $this->getQwiserSearchResults();
|
75 |
+
if(!isset($results)) return array();
|
76 |
+
$filters = $results->Questions->GetAllQuestions();
|
77 |
+
//Updates the price question if requuires
|
78 |
+
//e.g. when price slider is set and this is not a first search stage
|
79 |
+
$filters = $this->handlePriceQuestion($filters, $results->SearchInformation->Stage);
|
80 |
+
|
81 |
+
Mage::register('layer_filters', $filters);
|
82 |
+
}
|
83 |
+
return $filters;
|
84 |
+
}
|
85 |
+
|
86 |
+
public function handlePriceQuestion($filters, $searchStage){
|
87 |
+
$priceQuestion = null;
|
88 |
+
|
89 |
+
//Adds price slider question to the session
|
90 |
+
if( $this->isPriceSlider() &&
|
91 |
+
$searchStage == "1" &&
|
92 |
+
isset($filters["PriceQuestion"])
|
93 |
+
) Mage::getSingleton('salesperson/session')->setPriceQuestion($filters["PriceQuestion"]);
|
94 |
+
|
95 |
+
//Gets price slider question from the session
|
96 |
+
if( $this->isPriceSlider() && $searchStage != "1"){
|
97 |
+
$priceQuestion = Mage::getSingleton('salesperson/session')->getPriceQuestion();
|
98 |
+
//Remove price question if it was not answered yet
|
99 |
+
if(isset($priceQuestion) && !$this->isAnsweredQuestion($priceQuestion)) $priceQuestion = null;
|
100 |
+
}
|
101 |
+
|
102 |
+
if(isset($priceQuestion)) $filters["PriceQuestion"] = $priceQuestion;
|
103 |
+
|
104 |
+
if(isset($filters["PriceQuestion"])) $this->setPriceQuestion($filters["PriceQuestion"]);
|
105 |
+
|
106 |
+
return $filters;
|
107 |
+
}
|
108 |
+
|
109 |
+
public function setPriceQuestion($priceQuestion){
|
110 |
+
Mage::register('PriceQuestion', $priceQuestion);
|
111 |
+
}
|
112 |
+
|
113 |
+
public function getPriceQuestion(){
|
114 |
+
return Mage::registry('PriceQuestion');
|
115 |
+
}
|
116 |
+
|
117 |
+
public function getAnsweredPriceRange($priceQuestion){
|
118 |
+
$answeredPriceRange = array();
|
119 |
+
$results = $this->getQwiserSearchResults();
|
120 |
+
if(isset($results) && isset($results->SearchPath->Items)) {
|
121 |
+
foreach($results->SearchPath->Items as $searchPathEntry) {
|
122 |
+
if($searchPathEntry->QuestionId == $priceQuestion->Id) {
|
123 |
+
$answerId = $searchPathEntry->Answers->Items[0]->Id;
|
124 |
+
$tmp = preg_replace( '/_P/', "" ,$answerId);
|
125 |
+
$answeredPriceRange[0] = (int) preg_replace( '/_\d*/', "" ,$tmp);
|
126 |
+
$answeredPriceRange[1] = (int) preg_replace( '/_P\d*_/', "" ,$answerId);
|
127 |
+
}
|
128 |
+
}
|
129 |
+
}
|
130 |
+
if(count($answeredPriceRange) == 0) {
|
131 |
+
$answeredPriceRange[0] = 0;
|
132 |
+
$answeredPriceRange[1] = $this->getMaxPrice($priceQuestion);
|
133 |
+
}
|
134 |
+
return $answeredPriceRange;
|
135 |
+
}
|
136 |
+
|
137 |
+
public function isMultiSelect() {
|
138 |
+
return Mage::getStoreConfigFlag('salesperson/display_settings/enable_non_lead_answers_multiselect');
|
139 |
+
}
|
140 |
+
|
141 |
+
public function isHierarchical($filter){
|
142 |
+
$isHierarchical = true;
|
143 |
+
if(isset($filter->DynamicProperties["IsHierarchical"]) && $filter->DynamicProperties["IsHierarchical"]=="False" ) $isHierarchical = false;
|
144 |
+
return $isHierarchical;
|
145 |
+
}
|
146 |
+
|
147 |
+
public function isPriceQuestion($filter){
|
148 |
+
return ($filter->Type == "Price");
|
149 |
+
}
|
150 |
+
|
151 |
+
public function isRadioButtonsQuestion($filter){
|
152 |
+
return isset($this->_radioButtonsQuestions[$filter->SideText]);
|
153 |
+
}
|
154 |
+
|
155 |
+
public function getFilterHtmlRadioButtons($filter){
|
156 |
+
|
157 |
+
$html = "";
|
158 |
+
|
159 |
+
if((int)$filter->Answers->Count > 0){
|
160 |
+
foreach ($filter->Answers->Items as $answer){
|
161 |
+
$checked = $this->isAnsweredAnswer($answer) ? 'checked="checked"' : '';
|
162 |
+
$answerUrl = $this->isAnsweredAnswer($answer) ? '' : $this->answerQuestionUrl($answer->Id);
|
163 |
+
$html .= "<input type=\"radio\" onclick=\"celebrosSetLocation('{$answerUrl}')\" name=\"filter_{$filter->Id}\" value=\"{$answer->Id}\" {$checked}> {$answer->Text}";
|
164 |
+
}
|
165 |
+
$html .="<input type=\"radio\" name=\"filter_{$filter->Id}\" value=\"\"> All </input>";
|
166 |
+
}
|
167 |
+
|
168 |
+
return $html;
|
169 |
+
}
|
170 |
+
|
171 |
+
public function isPriceSlider(){
|
172 |
+
return (Mage::getStoreConfig('salesperson/display_settings/price_selector') == "slider");
|
173 |
+
}
|
174 |
+
|
175 |
+
public function getMinPrice($priceQuestion){
|
176 |
+
$answerId = $priceQuestion->Answers->Items[0]->Id;
|
177 |
+
$tmp = preg_replace( '/_P/', "" ,$answerId);
|
178 |
+
$min = (int) preg_replace( '/_\d*/', "" ,$tmp);
|
179 |
+
return $min;
|
180 |
+
}
|
181 |
+
|
182 |
+
public function getMaxPrice($priceQuestion){
|
183 |
+
$answerId = end($priceQuestion->Answers->Items)->Id;
|
184 |
+
$max = (int) preg_replace( '/_P\d*_/', "" ,$answerId);
|
185 |
+
return $max;
|
186 |
+
}
|
187 |
+
|
188 |
+
public function getStateRemoveUrl($answerId) {
|
189 |
+
$stateBlock = $this->getLayout()->createBlock('salesperson/layer_state');
|
190 |
+
return $stateBlock->getStateRemoveUrl($answerId);
|
191 |
+
}
|
192 |
+
|
193 |
+
public function answerQuestionUrl($answerId){
|
194 |
+
$urlParams = array();
|
195 |
+
$urlParams['_current'] = true;
|
196 |
+
$urlParams['_escape'] = true;
|
197 |
+
$urlParams['_use_rewrite'] = false;
|
198 |
+
$urlParams['_query'] = array(
|
199 |
+
'searchHandle' => $this->getQwiserSearchResults()->GetSearchHandle(),
|
200 |
+
'salespersonaction' => 'answerQuestion',
|
201 |
+
'answerId' => $answerId,
|
202 |
+
);
|
203 |
+
|
204 |
+
$url = Mage::getUrl('*/*/change', $urlParams);
|
205 |
+
if (preg_match("/p==*\d/", $url)){
|
206 |
+
$url = preg_replace("/p==*\d/",'p=1', $url);
|
207 |
+
}
|
208 |
+
else {
|
209 |
+
$url .= "&p=1";
|
210 |
+
}
|
211 |
+
|
212 |
+
$url = str_replace("&", '&', $url);
|
213 |
+
|
214 |
+
return $url;
|
215 |
+
}
|
216 |
+
|
217 |
+
public function answerQuestionsUrl(){
|
218 |
+
if(!$this->getQwiserSearchResults()) return "";
|
219 |
+
$urlParams = array();
|
220 |
+
$urlParams['_current'] = true;
|
221 |
+
$urlParams['_escape'] = true;
|
222 |
+
$urlParams['_use_rewrite'] = false;
|
223 |
+
$urlParams['_query'] = array(
|
224 |
+
'searchHandle' => $this->getQwiserSearchResults()->GetSearchHandle(),
|
225 |
+
'salespersonaction' => 'answerQuestions',
|
226 |
+
);
|
227 |
+
$url = Mage::getUrl('salesperson/result/change', $urlParams);
|
228 |
+
if (preg_match("/p==*\d/", $url)){
|
229 |
+
$url = preg_replace("/p==*\d/",'p=1', $url);
|
230 |
+
}
|
231 |
+
else {
|
232 |
+
$url .= "&p=1";
|
233 |
+
}
|
234 |
+
return $url;
|
235 |
+
}
|
236 |
+
|
237 |
+
public function getFilterText($filter,$type){
|
238 |
+
if ($type == "nonlead" && Mage::Helper('salesperson')->getNonLeadQuestionsPosition() != 'top'){
|
239 |
+
return $filter->SideText;
|
240 |
+
}
|
241 |
+
elseif ($type == "lead"){
|
242 |
+
return $filter->SideText;
|
243 |
+
}
|
244 |
+
return $filter->Text;
|
245 |
+
}
|
246 |
+
|
247 |
+
public function getLeadQuestion() {
|
248 |
+
$filters = $this->getFilters();
|
249 |
+
|
250 |
+
$leadQuestion = Mage::registry('leadQuestion');
|
251 |
+
|
252 |
+
if(!isset($leadQuestion)){
|
253 |
+
|
254 |
+
foreach($filters as $filter)
|
255 |
+
{
|
256 |
+
if($this->isHierarchical($filter)){
|
257 |
+
$leadQuestion = $filter;
|
258 |
+
break;
|
259 |
+
}
|
260 |
+
}
|
261 |
+
Mage::register('leadQuestion', $leadQuestion);
|
262 |
+
}
|
263 |
+
|
264 |
+
return $leadQuestion;
|
265 |
+
|
266 |
+
}
|
267 |
+
|
268 |
+
public function getLeadAnswers($question){
|
269 |
+
$answers = array_merge($question->Answers->Items, $question->ExtraAnswers->Items);
|
270 |
+
$count = count($answers);
|
271 |
+
$max = $this->getMaxLeadAnswers();
|
272 |
+
if($count > $max) $answers = array_slice($answers, 0, $max, true);
|
273 |
+
return $answers;
|
274 |
+
}
|
275 |
+
|
276 |
+
public function getMoreLeadAnswers($question){
|
277 |
+
$answers = array_merge($question->Answers->Items, $question->ExtraAnswers->Items);
|
278 |
+
$count = count($answers);
|
279 |
+
$max = $this->getMaxLeadAnswers();
|
280 |
+
if($count > $max) $answers = array_slice($answers, $max, $count - $max, true);
|
281 |
+
else $answers = array();
|
282 |
+
return $answers;
|
283 |
+
}
|
284 |
+
|
285 |
+
public function getMaxLeadAnswers(){
|
286 |
+
return (int)Mage::getStoreConfig('salesperson/display_settings/max_lead_answers');
|
287 |
+
}
|
288 |
+
|
289 |
+
public function getMaxNonLeadAnswers(){
|
290 |
+
return (int)Mage::getStoreConfig('salesperson/display_settings/max_non_lead_answers');
|
291 |
+
}
|
292 |
+
|
293 |
+
public function getNonLeadQuestions(){
|
294 |
+
$questions = $this->getFilters();
|
295 |
+
$priceQuestion = isset($questions["PriceQuestion"]) ? $questions["PriceQuestion"] : null;
|
296 |
+
|
297 |
+
if($this->canShowLeadQuestion()){
|
298 |
+
$leadQuestion = $this->getLeadQuestion();
|
299 |
+
if(isset($leadQuestion)) unset($questions[$leadQuestion->Id]);
|
300 |
+
}
|
301 |
+
|
302 |
+
//Remove more questions
|
303 |
+
$count = count($questions);
|
304 |
+
$max = $this->getMaxNonLeadQuestions();
|
305 |
+
|
306 |
+
if($count > $max) $questions = array_slice($questions, 0, $max, true);
|
307 |
+
//Replace last question with the price question if the question came back in the search results but it sliced to more questions
|
308 |
+
if($priceQuestion && !isset($questions["PriceQuestion"]))
|
309 |
+
{
|
310 |
+
$replacement = array($priceQuestion->Id=>$priceQuestion);
|
311 |
+
array_splice($questions, $max-1, 1, $replacement);
|
312 |
+
}
|
313 |
+
|
314 |
+
return $questions;
|
315 |
+
}
|
316 |
+
|
317 |
+
public function getMoreNonLeadQuestions(){
|
318 |
+
$questions = $this->getFilters();
|
319 |
+
|
320 |
+
if($this->canShowLeadQuestion()){
|
321 |
+
$leadQuestion = $this->getLeadQuestion();
|
322 |
+
if(isset($leadQuestion)) unset($questions[$leadQuestion->Id]);
|
323 |
+
}
|
324 |
+
|
325 |
+
//Remove more questions
|
326 |
+
$count = count($questions);
|
327 |
+
$max = $this->getMaxNonLeadQuestions();
|
328 |
+
$lastBeforeMoreQuestion = array_slice($questions, $max-1, 1, true);
|
329 |
+
if($count > $max) $questions = array_slice($questions, $max, $count - $max, true);
|
330 |
+
else $questions = array();
|
331 |
+
|
332 |
+
//Add first question with removed question in getNonLeadQuestions and unset Price question
|
333 |
+
if(isset($questions["PriceQuestion"]))
|
334 |
+
{
|
335 |
+
unset($questions["PriceQuestion"]);
|
336 |
+
$replacement = $lastBeforeMoreQuestion;
|
337 |
+
array_splice($questions, 0,0, $replacement);
|
338 |
+
}
|
339 |
+
|
340 |
+
return $questions;
|
341 |
+
}
|
342 |
+
|
343 |
+
public function getNonLeadAnswers($question){
|
344 |
+
$answers = array_merge($question->Answers->Items, $question->ExtraAnswers->Items);
|
345 |
+
$count = count($answers);
|
346 |
+
$max = $this->getMaxNonLeadAnswers();
|
347 |
+
if($count > $max) $answers = array_slice($answers, 0, $max, true);
|
348 |
+
return $answers;
|
349 |
+
}
|
350 |
+
|
351 |
+
public function getMoreNonLeadAnswers($question){
|
352 |
+
$answers = array_merge($question->Answers->Items, $question->ExtraAnswers->Items);
|
353 |
+
$count = count($answers);
|
354 |
+
$max = $this->getMaxNonLeadAnswers();
|
355 |
+
if($count > $max) $answers = array_slice($answers, $max, $count - $max, true);
|
356 |
+
else $answers = array();
|
357 |
+
return $answers;
|
358 |
+
}
|
359 |
+
|
360 |
+
public function getMaxNonLeadQuestions(){
|
361 |
+
return (int)Mage::getStoreConfig('salesperson/display_settings/max_non_lead_questions');
|
362 |
+
}
|
363 |
+
|
364 |
+
public function showProductCountInLeadAnswers(){
|
365 |
+
return Mage::getStoreConfigFlag('salesperson/display_settings/show_product_count_in_lead_answers');
|
366 |
+
}
|
367 |
+
|
368 |
+
public function showProductCountInNonLeadAnswers(){
|
369 |
+
return Mage::getStoreConfigFlag('salesperson/display_settings/show_product_count_in_non_lead_answers');
|
370 |
+
}
|
371 |
+
|
372 |
+
/**
|
373 |
+
* Check availability display layer block
|
374 |
+
*
|
375 |
+
* @return bool
|
376 |
+
*/
|
377 |
+
public function canShowNoneLeadSideBlock()
|
378 |
+
{
|
379 |
+
return Mage::Helper('salesperson')->getNonLeadQuestionsPosition() == 'left' || Mage::Helper('salesperson')->getNonLeadQuestionsPosition() == 'right';
|
380 |
+
}
|
381 |
+
|
382 |
+
public function canShowLeadQuestion(){
|
383 |
+
return Mage::getStoreConfigFlag('salesperson/display_settings/display_lead');
|
384 |
+
}
|
385 |
+
|
386 |
+
public function forceLeadQuestion($questionId){
|
387 |
+
$urlParams = array();
|
388 |
+
$urlParams['_current'] = true;
|
389 |
+
$urlParams['_escape'] = true;
|
390 |
+
$urlParams['_use_rewrite'] = false;
|
391 |
+
$urlParams['_query'] = array(
|
392 |
+
'searchHandle' => $this->getQwiserSearchResults()->GetSearchHandle(),
|
393 |
+
'salespersonaction' => 'forceQuestion',
|
394 |
+
'questionId' => $questionId,
|
395 |
+
);
|
396 |
+
return Mage::getUrl('*/*/change', $urlParams);
|
397 |
+
}
|
398 |
+
|
399 |
+
public function stateHasFilters(){
|
400 |
+
return count($this->getLayer()->getState()->getFilters()) > 0;
|
401 |
+
}
|
402 |
+
|
403 |
+
public function getCustomPriceAnswerUrl(){
|
404 |
+
$urlParams = array();
|
405 |
+
$urlParams['_current'] = true;
|
406 |
+
$urlParams['_escape'] = false;
|
407 |
+
$urlParams['_use_rewrite'] = false;
|
408 |
+
$urlParams['_query'] = array(
|
409 |
+
'searchHandle' => $this->getQwiserSearchResults()->GetSearchHandle(),
|
410 |
+
'salespersonaction' => 'answerQuestion',
|
411 |
+
);
|
412 |
+
$url = Mage::getUrl('*/*/change', $urlParams);
|
413 |
+
if(strpos($url, "answerId=")){
|
414 |
+
$replace_string = substr($url,strpos($url, "answerId="),strpos($url, '&',strpos($url, "answerId=")) - strpos($url, "answerId="));
|
415 |
+
$url = str_replace($replace_string, '', $url);
|
416 |
+
}
|
417 |
+
if (preg_match("/p=*\d/", $url)){
|
418 |
+
$url = preg_replace("/p=*\d/",'p=1', $url);
|
419 |
+
}
|
420 |
+
else {
|
421 |
+
$url .= "&p=1";
|
422 |
+
}
|
423 |
+
return $url;
|
424 |
+
}
|
425 |
+
|
426 |
+
public function getDisplayImageInLeadQuestion(){
|
427 |
+
return Mage::getStoreConfigFlag('salesperson/display_settings/display_image_lead_question');
|
428 |
+
}
|
429 |
+
|
430 |
+
public function isAnsweredQuestion($question){
|
431 |
+
$searchPathEntries = Mage::helper('salesperson')->getSearchPathEntries();
|
432 |
+
return isset($searchPathEntries[$question->Id]);
|
433 |
+
}
|
434 |
+
|
435 |
+
public function isAnsweredAnswer($answer){
|
436 |
+
$answeredAnswers = Mage::helper('salesperson')->getAnsweredAnswers();
|
437 |
+
return isset($answeredAnswers[$answer->Id]);
|
438 |
+
}
|
439 |
+
|
440 |
+
public function getSearchPathEntries(){
|
441 |
+
return Mage::helper('salesperson')->getSearchPathEntries();
|
442 |
+
}
|
443 |
+
|
444 |
+
public function getAnswerHtml($answer, $bIsHierarchical){
|
445 |
+
$html = "";
|
446 |
+
$bMultiSelect=$this->isMultiSelect();
|
447 |
+
|
448 |
+
if($bMultiSelect && !$bIsHierarchical){
|
449 |
+
$answerUrl = $this->isAnsweredAnswer($answer) ? $this->getStateRemoveUrl($answer->Id) : $this->answerQuestionUrl($answer->Id);
|
450 |
+
$strChecked = $this->isAnsweredAnswer($answer) ? 'checked="checked"' : "";
|
451 |
+
$strDisabled = ($answer->ProductCount == 0) ? 'disabled="disabled"' : "";
|
452 |
+
|
453 |
+
$html .=
|
454 |
+
"<input type=checkbox {$strChecked} {$strDisabled}
|
455 |
+
onclick=\"celebrosSetLocation('{$answerUrl}');\"
|
456 |
+
name=\"{$answer->Id}\" id=\"{$answer->Id}\" />";
|
457 |
+
|
458 |
+
$href = Mage::helper('salesperson')->getHref($answerUrl);
|
459 |
+
$html .= "<a {$href}>$answer->Text</a>";
|
460 |
+
}
|
461 |
+
else{
|
462 |
+
$href = Mage::helper('salesperson')->getHref($this->answerQuestionUrl($answer->Id));
|
463 |
+
$html .= "<a {$href}>$answer->Text</a>";
|
464 |
+
}
|
465 |
+
if ($this->showProductCountInNonLeadAnswers()) $html .= " ({$answer->ProductCount})";
|
466 |
+
return $html;
|
467 |
+
}
|
468 |
+
|
469 |
+
public function getMoreAnswersHtml($moreAnswers){
|
470 |
+
$html = "";
|
471 |
+
|
472 |
+
$html .= "<select id='answersList' class='cel_moreAnswers'
|
473 |
+
onchange='celebrosSetLocation(this.value)'>";
|
474 |
+
|
475 |
+
foreach ($moreAnswers as $answer){
|
476 |
+
$html .= "<option value='{$this->answerQuestionUrl($answer->Id)}'> {$answer->Text}";
|
477 |
+
if ($this->showProductCountInNonLeadAnswers())$html .= " ({$answer->ProductCount})";
|
478 |
+
$html .= "</option>";
|
479 |
+
}
|
480 |
+
|
481 |
+
$html .= "</select>";
|
482 |
+
return $html;
|
483 |
+
}
|
484 |
+
|
485 |
+
public function hasSearchResults(){
|
486 |
+
$results = $this->getQwiserSearchResults();
|
487 |
+
return isset($results);
|
488 |
+
}
|
489 |
+
|
490 |
+
}
|
app/code/community/Celebros/Salesperson/Block/Layer/Widget/RadioButtonQuestion.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Celebros - Pavel Feldman (email: MagentoSupport@celebros.com)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
|
11 |
+
|
12 |
+
class Celebros_Salesperson_Block_Layer_Widget_RadioButtonQuestion extends Mage_Customer_Block_Widget_Abstract
|
13 |
+
{
|
14 |
+
protected $_question;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Initialize block
|
18 |
+
*/
|
19 |
+
public function _construct()
|
20 |
+
{
|
21 |
+
parent::_construct();
|
22 |
+
$this->setTemplate('salesperson/layer/widget/radiobuttonquestion.phtml');
|
23 |
+
return $this;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function setQuestion($question){
|
27 |
+
$this->_question = $question;
|
28 |
+
return $this;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getQuestion(){
|
32 |
+
return $this->_question;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function isAnsweredAnswer($answer){
|
36 |
+
$answeredAnswers = Mage::helper('salesperson')->getAnsweredAnswers();
|
37 |
+
return isset($answeredAnswers[$answer->Id]);
|
38 |
+
}
|
39 |
+
}
|
app/code/community/Celebros/Salesperson/Block/Navigation.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Salesperson navigation
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
* @category Celebros
|
11 |
+
* @package Celebros_Salesperson
|
12 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
|
16 |
+
|
17 |
+
class Celebros_Salesperson_Block_Navigation extends Mage_Catalog_Block_Navigation
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Get url for category data
|
21 |
+
*
|
22 |
+
* @param Mage_Catalog_Model_Category $category
|
23 |
+
* @return string
|
24 |
+
*/
|
25 |
+
public function getCategoryUrl($category)
|
26 |
+
{
|
27 |
+
if (!($category instanceof Mage_Catalog_Model_Category)) {
|
28 |
+
$category = $this->_getCategoryInstance()
|
29 |
+
->setData($category->getData());
|
30 |
+
}
|
31 |
+
|
32 |
+
$url = $this->helper('salesperson')->getResultUrl($category->getName());
|
33 |
+
|
34 |
+
return $url;
|
35 |
+
}
|
36 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Block/Product/Abstract.php
RENAMED
@@ -1,440 +1,313 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
abstract class Celebros_Salesperson_Block_Product_Abstract extends
|
11 |
-
{
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
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 |
-
*
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
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 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
*
|
125 |
-
*
|
126 |
-
* @param string $
|
127 |
-
* @param string $template
|
128 |
-
*/
|
129 |
-
public function
|
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 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
$
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
*
|
257 |
-
*
|
258 |
-
* @param
|
259 |
-
* @return
|
260 |
-
*/
|
261 |
-
|
262 |
-
{
|
263 |
-
|
264 |
-
->
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
}
|
269 |
-
|
270 |
-
/**
|
271 |
-
* Retrieve
|
272 |
-
*
|
273 |
-
* @param
|
274 |
-
* @
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
public function hasProductUrl($product)
|
315 |
-
{
|
316 |
-
if ($product->getVisibleInSiteVisibilities()) {
|
317 |
-
return true;
|
318 |
-
}
|
319 |
-
if ($product->hasUrlDataObject()) {
|
320 |
-
if (in_array($product->hasUrlDataObject()->getVisibility(), $product->getVisibleInSiteVisibilities())) {
|
321 |
-
return true;
|
322 |
-
}
|
323 |
-
}
|
324 |
-
|
325 |
-
return false;
|
326 |
-
}
|
327 |
-
|
328 |
-
/**
|
329 |
-
* Retrieve product amount per row
|
330 |
-
*
|
331 |
-
* @return int
|
332 |
-
*/
|
333 |
-
public function getColumnCount()
|
334 |
-
{
|
335 |
-
if (!$this->_getData('column_count')) {
|
336 |
-
$pageLayout = $this->getPageLayout();
|
337 |
-
if ($pageLayout && $this->getColumnCountLayoutDepend($pageLayout)) {
|
338 |
-
$this->setData(
|
339 |
-
'column_count',
|
340 |
-
$this->getColumnCountLayoutDepend($pageLayout)
|
341 |
-
);
|
342 |
-
} else {
|
343 |
-
$this->setData('column_count', $this->_defaultColumnCount);
|
344 |
-
}
|
345 |
-
}
|
346 |
-
|
347 |
-
return (int)$this->_getData('column_count');
|
348 |
-
}
|
349 |
-
|
350 |
-
/**
|
351 |
-
* Add row size depends on page layout
|
352 |
-
*
|
353 |
-
* @param string $pageLayout
|
354 |
-
* @param int $rowSize
|
355 |
-
* @return Mage_Catalog_Block_Product_List
|
356 |
-
*/
|
357 |
-
public function addColumnCountLayoutDepend($pageLayout, $columnCount)
|
358 |
-
{
|
359 |
-
$this->_columnCountLayoutDepend[$pageLayout] = $columnCount;
|
360 |
-
return $this;
|
361 |
-
}
|
362 |
-
|
363 |
-
/**
|
364 |
-
* Remove row size depends on page layout
|
365 |
-
*
|
366 |
-
* @param string $pageLayout
|
367 |
-
* @return Mage_Catalog_Block_Product_List
|
368 |
-
*/
|
369 |
-
public function removeColumnCountLayoutDepend($pageLayout)
|
370 |
-
{
|
371 |
-
if (isset($this->_columnCountLayoutDepend[$pageLayout])) {
|
372 |
-
unset($this->_columnCountLayoutDepend[$pageLayout]);
|
373 |
-
}
|
374 |
-
|
375 |
-
return $this;
|
376 |
-
}
|
377 |
-
|
378 |
-
/**
|
379 |
-
* Retrieve row size depends on page layout
|
380 |
-
*
|
381 |
-
* @param string $pageLayout
|
382 |
-
* @return int|boolean
|
383 |
-
*/
|
384 |
-
public function getColumnCountLayoutDepend($pageLayout)
|
385 |
-
{
|
386 |
-
if (isset($this->_columnCountLayoutDepend[$pageLayout])) {
|
387 |
-
return $this->_columnCountLayoutDepend[$pageLayout];
|
388 |
-
}
|
389 |
-
|
390 |
-
return false;
|
391 |
-
}
|
392 |
-
|
393 |
-
/**
|
394 |
-
* Retrieve current page layout
|
395 |
-
*
|
396 |
-
* @return Varien_Object
|
397 |
-
*/
|
398 |
-
public function getPageLayout()
|
399 |
-
{
|
400 |
-
$pageLayoutHandles = Mage::getSingleton('page/config')->getPageLayoutHandles();
|
401 |
-
$pageLayoutHandleskeys = array_keys($pageLayoutHandles);
|
402 |
-
// return false;
|
403 |
-
switch(Mage::getStoreConfig('salesperson/display_settings/layout')){
|
404 |
-
case "salesperson/1column.phtml":
|
405 |
-
return $pageLayoutHandleskeys[1];
|
406 |
-
break;
|
407 |
-
case "salesperson/2columns-left.phtml":
|
408 |
-
return $pageLayoutHandleskeys[2];
|
409 |
-
break;
|
410 |
-
case "salesperson/2columns-right.phtml":
|
411 |
-
return $pageLayoutHandleskeys[3];
|
412 |
-
break;
|
413 |
-
case "salesperson/3columns.phtml":
|
414 |
-
return $pageLayoutHandleskeys[4];
|
415 |
-
break;
|
416 |
-
|
417 |
-
}
|
418 |
-
//return $this->helper('page/layout')->getCurrentPageLayout();
|
419 |
-
}
|
420 |
-
|
421 |
-
/**
|
422 |
-
* If exists price template block, retrieve price blocks from it
|
423 |
-
*
|
424 |
-
* @return Mage_Catalog_Block_Product_Abstract
|
425 |
-
*/
|
426 |
-
protected function _prepareLayout()
|
427 |
-
{
|
428 |
-
parent::_prepareLayout();
|
429 |
-
|
430 |
-
/* @var $block Mage_Catalog_Block_Product_Price_Template */
|
431 |
-
$block = $this->getLayout()->getBlock('salesperson_product_price_template');
|
432 |
-
if ($block) {
|
433 |
-
foreach ($block->getPriceBlockTypes() as $type => $priceBlock) {
|
434 |
-
$this->addPriceBlockType($type, $priceBlock['block'], $priceBlock['template']);
|
435 |
-
}
|
436 |
-
}
|
437 |
-
|
438 |
-
return $this;
|
439 |
-
}
|
440 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
abstract class Celebros_Salesperson_Block_Product_Abstract extends Mage_Catalog_Block_Product_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Flag which allow/disallow to use link for as low as price
|
15 |
+
*
|
16 |
+
* @var bool
|
17 |
+
*/
|
18 |
+
protected $_useLinkForAsLowAs = true;
|
19 |
+
|
20 |
+
protected $_reviewsHelperBlock;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Default product amount per row
|
24 |
+
*
|
25 |
+
* @var int
|
26 |
+
*/
|
27 |
+
protected $_defaultColumnCount = 3;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Product amount per row depending on custom page layout of category
|
31 |
+
*
|
32 |
+
* @var array
|
33 |
+
*/
|
34 |
+
protected $_columnCountLayoutDepend = array();
|
35 |
+
|
36 |
+
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Retrieve url for add product to cart
|
40 |
+
* Will return product view page URL if product has required options
|
41 |
+
*
|
42 |
+
* @param Celebros_Salesperson_Model_Product $product
|
43 |
+
* @param array $additional
|
44 |
+
* @return string
|
45 |
+
*/
|
46 |
+
public function getAddToCartUrl($product, $additional = array())
|
47 |
+
{
|
48 |
+
return $this->helper('salesperson/checkout_cart')->getAddUrl($product, $additional);
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Retrieve url for add product to wishlist
|
53 |
+
*
|
54 |
+
* @param Celebros_Salesperson_Model_Product $product
|
55 |
+
* @return string
|
56 |
+
*/
|
57 |
+
public function getAddToWishlistUrl($product)
|
58 |
+
{
|
59 |
+
return $this->helper('salesperson/wishlist')->getAddUrl($product);
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Retrieve Add Product to Compare Products List URL
|
64 |
+
*
|
65 |
+
* @param Celebros_Salesperson_Model_Product $product
|
66 |
+
* @return string
|
67 |
+
*/
|
68 |
+
public function getAddToCompareUrl($product)
|
69 |
+
{
|
70 |
+
return $this->helper('salesperson/product_compare')->getAddUrl($product);
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Returns product price block html
|
75 |
+
*
|
76 |
+
* @param Mage_Catalog_Model_Product $product
|
77 |
+
* @param boolean $displayMinimalPrice
|
78 |
+
*/
|
79 |
+
public function getPriceHtml($product, $displayMinimalPrice = false, $idSuffix='')
|
80 |
+
{
|
81 |
+
$id = $product->Field['id'];
|
82 |
+
if(key_exists('magento_id',$product->Field))
|
83 |
+
$id = $product->Field['magento_id'];
|
84 |
+
|
85 |
+
$realProduct = Mage::getModel('catalog/product')->load($id);
|
86 |
+
|
87 |
+
|
88 |
+
if($realProduct)
|
89 |
+
{
|
90 |
+
|
91 |
+
$realProduct=
|
92 |
+
Mage::getModel("catalog/product")->getCollection()
|
93 |
+
->addAttributeToSelect(Mage::getSingleton("catalog/config")->getProductAttributes())
|
94 |
+
->addAttributeToFilter("entity_id", $realProduct->getId())
|
95 |
+
->setPage(1, 1)
|
96 |
+
->addMinimalPrice()
|
97 |
+
->addFinalPrice()
|
98 |
+
->addTaxPercents()
|
99 |
+
->load()
|
100 |
+
->getFirstItem();
|
101 |
+
|
102 |
+
return parent::getPriceHtml($realProduct, $displayMinimalPrice, $idSuffix);
|
103 |
+
}
|
104 |
+
else return $product->Field['price'];
|
105 |
+
}
|
106 |
+
|
107 |
+
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Get product reviews summary
|
111 |
+
*
|
112 |
+
* @param Mage_Catalog_Model_Product $product
|
113 |
+
* @param bool $templateType
|
114 |
+
* @param bool $displayIfNoReviews
|
115 |
+
* @return string
|
116 |
+
*/
|
117 |
+
public function getSalespersonReviewsSummaryHtml($product, $templateType = false, $displayIfNoReviews = false)
|
118 |
+
{
|
119 |
+
$this->_initReviewsHelperBlock();
|
120 |
+
return $this->_reviewsHelperBlock->getSummaryHtml($product, $templateType, $displayIfNoReviews);
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Add/replace reviews summary template by type
|
125 |
+
*
|
126 |
+
* @param string $type
|
127 |
+
* @param string $template
|
128 |
+
*/
|
129 |
+
public function addReviewSummaryTemplate($type, $template)
|
130 |
+
{
|
131 |
+
$this->_initReviewsHelperBlock();
|
132 |
+
$this->_reviewsHelperBlock->addTemplate($type, $template);
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Create reviews summary helper block once
|
137 |
+
*
|
138 |
+
*/
|
139 |
+
protected function _initReviewsHelperBlock()
|
140 |
+
{
|
141 |
+
if (!$this->_reviewsHelperBlock) {
|
142 |
+
$this->_reviewsHelperBlock = $this->getLayout()->createBlock('salesperson/review_helper');
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Retrieve currently viewed product object
|
148 |
+
*
|
149 |
+
* @return Mage_Catalog_Model_Product
|
150 |
+
*/
|
151 |
+
public function getProduct()
|
152 |
+
{
|
153 |
+
if (!$this->hasData('product')) {
|
154 |
+
$this->setData('product', Mage::registry('product'));
|
155 |
+
}
|
156 |
+
return $this->getData('product');
|
157 |
+
}
|
158 |
+
|
159 |
+
|
160 |
+
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Retrieve given media attribute label or product name if no label
|
164 |
+
*
|
165 |
+
* @param Mage_Catalog_Model_Product $product
|
166 |
+
* @param string $mediaAttributeCode
|
167 |
+
*
|
168 |
+
* @return string
|
169 |
+
*/
|
170 |
+
public function getImageLabel($product=null, $mediaAttributeCode='image')
|
171 |
+
{
|
172 |
+
if (is_null($product)) {
|
173 |
+
$product = $this->getProduct();
|
174 |
+
}
|
175 |
+
|
176 |
+
$label = $product->getData($mediaAttributeCode.'_label');
|
177 |
+
if (empty($label)) {
|
178 |
+
$label = $product->getName();
|
179 |
+
}
|
180 |
+
|
181 |
+
return $label;
|
182 |
+
}
|
183 |
+
|
184 |
+
public function getMapping($code_field = ""){
|
185 |
+
return $this->helper('salesperson/mapping')->getMapping($code_field);
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* Retrieve Product URL using UrlDataObject
|
190 |
+
*
|
191 |
+
* @param Mage_Catalog_Model_Product $product
|
192 |
+
* @param array $additional the route params
|
193 |
+
* @return string
|
194 |
+
*/
|
195 |
+
public function getSalespersonProductUrl($product)
|
196 |
+
{
|
197 |
+
return $product->Field[$this->getMapping('link')];
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Check Product has URL
|
202 |
+
*
|
203 |
+
* @param Mage_Catalog_Model_Product $product
|
204 |
+
* @return bool
|
205 |
+
*/
|
206 |
+
public function hasProductUrl($product)
|
207 |
+
{
|
208 |
+
if ($product->getVisibleInSiteVisibilities()) {
|
209 |
+
return true;
|
210 |
+
}
|
211 |
+
if ($product->hasUrlDataObject()) {
|
212 |
+
if (in_array($product->hasUrlDataObject()->getVisibility(), $product->getVisibleInSiteVisibilities())) {
|
213 |
+
return true;
|
214 |
+
}
|
215 |
+
}
|
216 |
+
|
217 |
+
return false;
|
218 |
+
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Retrieve product amount per row
|
222 |
+
*
|
223 |
+
* @return int
|
224 |
+
*/
|
225 |
+
public function getColumnCount()
|
226 |
+
{
|
227 |
+
if (!$this->_getData('column_count')) {
|
228 |
+
$pageLayout = $this->getPageLayout();
|
229 |
+
if ($pageLayout && $this->getColumnCountLayoutDepend($pageLayout)) {
|
230 |
+
$this->setData(
|
231 |
+
'column_count',
|
232 |
+
$this->getColumnCountLayoutDepend($pageLayout)
|
233 |
+
);
|
234 |
+
} else {
|
235 |
+
$this->setData('column_count', $this->_defaultColumnCount);
|
236 |
+
}
|
237 |
+
}
|
238 |
+
|
239 |
+
return (int)$this->_getData('column_count');
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Add row size depends on page layout
|
244 |
+
*
|
245 |
+
* @param string $pageLayout
|
246 |
+
* @param int $rowSize
|
247 |
+
* @return Mage_Catalog_Block_Product_List
|
248 |
+
*/
|
249 |
+
public function addColumnCountLayoutDepend($pageLayout, $columnCount)
|
250 |
+
{
|
251 |
+
$this->_columnCountLayoutDepend[$pageLayout] = $columnCount;
|
252 |
+
return $this;
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Remove row size depends on page layout
|
257 |
+
*
|
258 |
+
* @param string $pageLayout
|
259 |
+
* @return Mage_Catalog_Block_Product_List
|
260 |
+
*/
|
261 |
+
public function removeColumnCountLayoutDepend($pageLayout)
|
262 |
+
{
|
263 |
+
if (isset($this->_columnCountLayoutDepend[$pageLayout])) {
|
264 |
+
unset($this->_columnCountLayoutDepend[$pageLayout]);
|
265 |
+
}
|
266 |
+
|
267 |
+
return $this;
|
268 |
+
}
|
269 |
+
|
270 |
+
/**
|
271 |
+
* Retrieve row size depends on page layout
|
272 |
+
*
|
273 |
+
* @param string $pageLayout
|
274 |
+
* @return int|boolean
|
275 |
+
*/
|
276 |
+
public function getColumnCountLayoutDepend($pageLayout)
|
277 |
+
{
|
278 |
+
if (isset($this->_columnCountLayoutDepend[$pageLayout])) {
|
279 |
+
return $this->_columnCountLayoutDepend[$pageLayout];
|
280 |
+
}
|
281 |
+
|
282 |
+
return false;
|
283 |
+
}
|
284 |
+
|
285 |
+
/**
|
286 |
+
* Retrieve current page layout
|
287 |
+
*
|
288 |
+
* @return Varien_Object
|
289 |
+
*/
|
290 |
+
public function getPageLayout()
|
291 |
+
{
|
292 |
+
$pageLayoutHandles = Mage::getSingleton('page/config')->getPageLayoutHandles();
|
293 |
+
$pageLayoutHandleskeys = array_keys($pageLayoutHandles);
|
294 |
+
// return false;
|
295 |
+
switch(Mage::getStoreConfig('salesperson/display_settings/layout')){
|
296 |
+
case "salesperson/1column.phtml":
|
297 |
+
return $pageLayoutHandleskeys[1];
|
298 |
+
break;
|
299 |
+
case "salesperson/2columns-left.phtml":
|
300 |
+
return $pageLayoutHandleskeys[2];
|
301 |
+
break;
|
302 |
+
case "salesperson/2columns-right.phtml":
|
303 |
+
return $pageLayoutHandleskeys[3];
|
304 |
+
break;
|
305 |
+
case "salesperson/3columns.phtml":
|
306 |
+
return $pageLayoutHandleskeys[4];
|
307 |
+
break;
|
308 |
+
|
309 |
+
}
|
310 |
+
//return $this->helper('page/layout')->getCurrentPageLayout();
|
311 |
+
}
|
312 |
+
|
313 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/{local → community}/Celebros/Salesperson/Block/Product/List.php
RENAMED
@@ -1,137 +1,138 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Block_Product_List extends Celebros_Salesperson_Block_Product_Abstract
|
11 |
-
{
|
12 |
-
/**
|
13 |
-
* Default toolbar block name
|
14 |
-
*
|
15 |
-
* @var string
|
16 |
-
*/
|
17 |
-
protected $_defaultToolbarBlock = 'salesperson/product_list_toolbar';
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Product Collection
|
21 |
-
*
|
22 |
-
* @var Celebros_Salesperson_Model_Api_QwiserProducts->Items
|
23 |
-
*/
|
24 |
-
protected $_productCollection;
|
25 |
-
|
26 |
-
public function getQwiserSearchResults(){
|
27 |
-
if(Mage::helper('salesperson')->getSalespersonApi()->results)
|
28 |
-
return Mage::helper('salesperson')->getSalespersonApi()->results;
|
29 |
-
}
|
30 |
-
|
31 |
-
public function getStoreId(){
|
32 |
-
return Mage::Helper('core')->getStoreId();
|
33 |
-
}
|
34 |
-
|
35 |
-
protected function _getProductCollection()
|
36 |
-
{
|
37 |
-
if (is_null($this->_productCollection)) {
|
38 |
-
$this->_productCollection = $this->getQwiserSearchResults()->Products->Items;
|
39 |
-
}
|
40 |
-
return $this->_productCollection;
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Retrieve search result count
|
45 |
-
*
|
46 |
-
* @return string
|
47 |
-
*/
|
48 |
-
public function getResultCount()
|
49 |
-
{
|
50 |
-
return $this->getQwiserSearchResults()->GetRelevantProductsCount();
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Retrieve loaded category collection
|
55 |
-
*
|
56 |
-
* @return Celebros_Salesperson_Model_Api_QwiserProducts
|
57 |
-
*/
|
58 |
-
public function getLoadedProductCollection()
|
59 |
-
{
|
60 |
-
return $this->_getProductCollection();
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Retrieve current view mode
|
65 |
-
*
|
66 |
-
* @return string
|
67 |
-
*/
|
68 |
-
public function getMode()
|
69 |
-
{
|
70 |
-
return $this->getChild('toolbar')->getCurrentMode();
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Need use as _prepareLayout - but problem in declaring collection from
|
75 |
-
* another block (was problem with search result)
|
76 |
-
*/
|
77 |
-
protected function _beforeToHtml()
|
78 |
-
{
|
79 |
-
$toolbar = $this->getToolbarBlock();
|
80 |
-
|
81 |
-
// called prepare sortable parameters
|
82 |
-
$collection = $this->_getProductCollection();
|
83 |
-
|
84 |
-
// use sortable parameters
|
85 |
-
if ($orders =
|
86 |
-
$toolbar->setAvailableOrders($orders);
|
87 |
-
}
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
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 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Block_Product_List extends Celebros_Salesperson_Block_Product_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Default toolbar block name
|
14 |
+
*
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
protected $_defaultToolbarBlock = 'salesperson/product_list_toolbar';
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Product Collection
|
21 |
+
*
|
22 |
+
* @var Celebros_Salesperson_Model_Api_QwiserProducts->Items
|
23 |
+
*/
|
24 |
+
protected $_productCollection;
|
25 |
+
|
26 |
+
public function getQwiserSearchResults(){
|
27 |
+
if(Mage::helper('salesperson')->getSalespersonApi()->results)
|
28 |
+
return Mage::helper('salesperson')->getSalespersonApi()->results;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getStoreId(){
|
32 |
+
return Mage::Helper('core')->getStoreId();
|
33 |
+
}
|
34 |
+
|
35 |
+
protected function _getProductCollection()
|
36 |
+
{
|
37 |
+
if (is_null($this->_productCollection)) {
|
38 |
+
$this->_productCollection = $this->getQwiserSearchResults()->Products->Items;
|
39 |
+
}
|
40 |
+
return $this->_productCollection;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Retrieve search result count
|
45 |
+
*
|
46 |
+
* @return string
|
47 |
+
*/
|
48 |
+
public function getResultCount()
|
49 |
+
{
|
50 |
+
return $this->getQwiserSearchResults()->GetRelevantProductsCount();
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Retrieve loaded category collection
|
55 |
+
*
|
56 |
+
* @return Celebros_Salesperson_Model_Api_QwiserProducts
|
57 |
+
*/
|
58 |
+
public function getLoadedProductCollection()
|
59 |
+
{
|
60 |
+
return $this->_getProductCollection();
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Retrieve current view mode
|
65 |
+
*
|
66 |
+
* @return string
|
67 |
+
*/
|
68 |
+
public function getMode()
|
69 |
+
{
|
70 |
+
return $this->getChild('toolbar')->getCurrentMode();
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Need use as _prepareLayout - but problem in declaring collection from
|
75 |
+
* another block (was problem with search result)
|
76 |
+
*/
|
77 |
+
protected function _beforeToHtml()
|
78 |
+
{
|
79 |
+
$toolbar = $this->getToolbarBlock();
|
80 |
+
|
81 |
+
// called prepare sortable parameters
|
82 |
+
$collection = $this->_getProductCollection();
|
83 |
+
|
84 |
+
// use sortable parameters
|
85 |
+
if ($orders = Mage::helper('salesperson')->getAvailableOrders()) {
|
86 |
+
$toolbar->setAvailableOrders($orders);
|
87 |
+
}
|
88 |
+
|
89 |
+
if ($sort = Mage::helper('salesperson')->getDefaultSortBy()) {
|
90 |
+
$toolbar->setDefaultOrder($sort);
|
91 |
+
}
|
92 |
+
|
93 |
+
if ($direction = Mage::helper('salesperson')->getSortDirection($sort)) {
|
94 |
+
$toolbar->setDefaultDirection($direction);
|
95 |
+
}
|
96 |
+
|
97 |
+
if ($modes = $this->getModes()) {
|
98 |
+
$toolbar->setModes($modes);
|
99 |
+
}
|
100 |
+
|
101 |
+
$this->setChild('toolbar', $toolbar);
|
102 |
+
|
103 |
+
return parent::_beforeToHtml();
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Retrieve Toolbar block
|
108 |
+
*
|
109 |
+
* @return Celebros_Salesperson_Block_Product_List_Toolbar
|
110 |
+
*/
|
111 |
+
public function getToolbarBlock()
|
112 |
+
{
|
113 |
+
if ($blockName = $this->getToolbarBlockName()) {
|
114 |
+
if ($block = $this->getLayout()->getBlock($blockName)) {
|
115 |
+
return $block;
|
116 |
+
}
|
117 |
+
}
|
118 |
+
$block = $this->getLayout()->createBlock($this->_defaultToolbarBlock, microtime());
|
119 |
+
return $block;
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Retrieve list toolbar HTML
|
124 |
+
*
|
125 |
+
* @return string
|
126 |
+
*/
|
127 |
+
public function getToolbarHtml()
|
128 |
+
{
|
129 |
+
return $this->getChildHtml('toolbar');
|
130 |
+
}
|
131 |
+
|
132 |
+
public function getPriceBlockTemplate()
|
133 |
+
{
|
134 |
+
return $this->_getData('price_block_template');
|
135 |
+
}
|
136 |
+
|
137 |
+
|
138 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Block/Product/List/Toolbar.php
RENAMED
@@ -1,909 +1,886 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Block_Product_List_Toolbar extends Mage_Core_Block_Template
|
11 |
-
{
|
12 |
-
/**
|
13 |
-
* Products collection
|
14 |
-
*
|
15 |
-
* @var Mage_Core_Model_Mysql4_Collection_Abstract
|
16 |
-
*/
|
17 |
-
protected $_collection = null;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* GET parameter page variable
|
21 |
-
*
|
22 |
-
* @var string
|
23 |
-
*/
|
24 |
-
protected $_pageVarName = 'p';
|
25 |
-
|
26 |
-
/**
|
27 |
-
* GET parameter order variable
|
28 |
-
*
|
29 |
-
* @var string
|
30 |
-
*/
|
31 |
-
protected $_orderVarName = 'order';
|
32 |
-
|
33 |
-
/**
|
34 |
-
* GET parameter direction variable
|
35 |
-
*
|
36 |
-
* @var string
|
37 |
-
*/
|
38 |
-
protected $_directionVarName = 'dir';
|
39 |
-
|
40 |
-
/**
|
41 |
-
* GET parameter mode variable
|
42 |
-
*
|
43 |
-
* @var string
|
44 |
-
*/
|
45 |
-
protected $_modeVarName = 'mode';
|
46 |
-
|
47 |
-
/**
|
48 |
-
* GET parameter limit variable
|
49 |
-
*
|
50 |
-
* @var string
|
51 |
-
*/
|
52 |
-
protected $_limitVarName = 'size';
|
53 |
-
|
54 |
-
/**
|
55 |
-
* GET parameter search handle variable
|
56 |
-
*
|
57 |
-
* @var string
|
58 |
-
*/
|
59 |
-
protected $_searchHandleVarName = 'sh';
|
60 |
-
|
61 |
-
/**
|
62 |
-
* List of available order fields
|
63 |
-
*
|
64 |
-
* @var array
|
65 |
-
*/
|
66 |
-
protected $_availableOrder = array();
|
67 |
-
|
68 |
-
/**
|
69 |
-
* List of available view types
|
70 |
-
*
|
71 |
-
* @var string
|
72 |
-
*/
|
73 |
-
protected $_availableMode = array();
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Is enable View switcher
|
77 |
-
*
|
78 |
-
* @var bool
|
79 |
-
*/
|
80 |
-
protected $_enableViewSwitcher = true;
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Is Expanded
|
84 |
-
*
|
85 |
-
* @var bool
|
86 |
-
*/
|
87 |
-
protected $_isExpanded = true;
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Default Order field
|
91 |
-
*
|
92 |
-
* @var string
|
93 |
-
*/
|
94 |
-
protected $_orderField = null;
|
95 |
-
|
96 |
-
/**
|
97 |
-
* Default direction
|
98 |
-
*
|
99 |
-
* @var string
|
100 |
-
*/
|
101 |
-
protected $_direction = 'asc';
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Default View mode
|
105 |
-
*
|
106 |
-
* @var string
|
107 |
-
*/
|
108 |
-
protected $_viewMode = null;
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Available page limits for different list modes
|
112 |
-
*
|
113 |
-
* @var array
|
114 |
-
*/
|
115 |
-
protected $_availableLimit = array();
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Default limits per page
|
119 |
-
*
|
120 |
-
* @var array
|
121 |
-
*/
|
122 |
-
protected $_defaultAvailableLimit = array(10=>10,20=>20,50=>50);
|
123 |
-
|
124 |
-
/**
|
125 |
-
* @var bool $_paramsMemorizeAllowed
|
126 |
-
*/
|
127 |
-
protected $_paramsMemorizeAllowed = true;
|
128 |
-
|
129 |
-
/**
|
130 |
-
* Retrieve salesperson session
|
131 |
-
*
|
132 |
-
* @return Mage_Catalog_Model_Session
|
133 |
-
*/
|
134 |
-
protected function _getSession()
|
135 |
-
{
|
136 |
-
return Mage::getSingleton('salesperson/session');
|
137 |
-
}
|
138 |
-
/**
|
139 |
-
* Retrieve Catalog Config object
|
140 |
-
*
|
141 |
-
* @return Mage_Catalog_Model_Config
|
142 |
-
*/
|
143 |
-
protected function _getConfig()
|
144 |
-
{
|
145 |
-
return Mage::getSingleton('catalog/config');
|
146 |
-
}
|
147 |
-
|
148 |
-
/**
|
149 |
-
* Init Toolbar
|
150 |
-
*
|
151 |
-
*/
|
152 |
-
protected function _construct()
|
153 |
-
{
|
154 |
-
parent::_construct();
|
155 |
-
$this->_orderField = Mage::getStoreConfig(
|
156 |
-
Mage_Catalog_Model_Config::XML_PATH_LIST_DEFAULT_SORT_BY
|
157 |
-
);
|
158 |
-
|
159 |
-
$this->_availableOrder = $this->_getConfig()->getAttributeUsedForSortByArray();
|
160 |
-
|
161 |
-
switch (Mage::getStoreConfig('catalog/frontend/list_mode')) {
|
162 |
-
case 'grid':
|
163 |
-
$this->_availableMode = array('grid' => $this->__('Grid'));
|
164 |
-
break;
|
165 |
-
|
166 |
-
case 'list':
|
167 |
-
$this->_availableMode = array('list' => $this->__('List'));
|
168 |
-
break;
|
169 |
-
|
170 |
-
case 'grid-list':
|
171 |
-
$this->_availableMode = array('grid' => $this->__('Grid'), 'list' => $this->__('List'));
|
172 |
-
break;
|
173 |
-
|
174 |
-
case 'list-grid':
|
175 |
-
$this->_availableMode = array('list' => $this->__('List'), 'grid' => $this->__('Grid'));
|
176 |
-
break;
|
177 |
-
}
|
178 |
-
$this->setTemplate('catalog/product/list/toolbar.phtml');
|
179 |
-
}
|
180 |
-
|
181 |
-
/**
|
182 |
-
* Disable list state params memorizing
|
183 |
-
*/
|
184 |
-
public function disableParamsMemorizing()
|
185 |
-
{
|
186 |
-
$this->_paramsMemorizeAllowed = false;
|
187 |
-
return $this;
|
188 |
-
}
|
189 |
-
|
190 |
-
/**
|
191 |
-
* Memorize parameter value for session
|
192 |
-
*
|
193 |
-
* @param string $param parameter name
|
194 |
-
* @param mixed $value parameter value
|
195 |
-
* @return Mage_Catalog_Block_Product_List_Toolbar
|
196 |
-
*/
|
197 |
-
protected function _memorizeParam($param, $value)
|
198 |
-
{
|
199 |
-
$session = Mage::getSingleton('salesperson/session');
|
200 |
-
if ($this->_paramsMemorizeAllowed && !$session->getParamsMemorizeDisabled()) {
|
201 |
-
$session->setData($param, $value);
|
202 |
-
}
|
203 |
-
return $this;
|
204 |
-
}
|
205 |
-
|
206 |
-
/**
|
207 |
-
*
|
208 |
-
*
|
209 |
-
* @
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
*
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
*
|
306 |
-
*
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
$
|
339 |
-
$
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
*
|
413 |
-
*
|
414 |
-
* @
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
*
|
426 |
-
*
|
427 |
-
* @
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
*
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
$this
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
*
|
452 |
-
*
|
453 |
-
* @
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
*
|
464 |
-
*
|
465 |
-
* @
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
*
|
511 |
-
*
|
512 |
-
* @return string
|
513 |
-
*/
|
514 |
-
public function
|
515 |
-
{
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
$
|
521 |
-
$
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
if ($mode) {
|
534 |
-
|
535 |
-
}
|
536 |
-
$
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
*
|
579 |
-
*
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
return $this;
|
589 |
-
}
|
590 |
-
|
591 |
-
/**
|
592 |
-
*
|
593 |
-
*
|
594 |
-
* @
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
}
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
*
|
696 |
-
*
|
697 |
-
* @
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
*
|
713 |
-
*
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
$
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
}
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
if (!$
|
763 |
-
$
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
}
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
public function
|
841 |
-
{
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
public function getSortingSelectorType() {
|
888 |
-
return Mage::getStoreConfig('salesperson/display_settings/sorting_selector');
|
889 |
-
}
|
890 |
-
public function getPageNavType() {
|
891 |
-
return Mage::getStoreConfig('salesperson/display_settings/page_nav_type');
|
892 |
-
}
|
893 |
-
|
894 |
-
public function getPageUrl($page)
|
895 |
-
{
|
896 |
-
return $this->getPagerUrl(array("salespersonaction"=>"page",$this->getPageVarName()=>$page));
|
897 |
-
}
|
898 |
-
|
899 |
-
public function getNextPageUrl()
|
900 |
-
{
|
901 |
-
return $this->getPageUrl($this->getCurrentPage() + 1);
|
902 |
-
}
|
903 |
-
|
904 |
-
public function getPreviousPageUrl()
|
905 |
-
{
|
906 |
-
return $this->getPageUrl($this->getCurrentPage() - 1);
|
907 |
-
}
|
908 |
-
|
909 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Block_Product_List_Toolbar extends Mage_Core_Block_Template
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Products collection
|
14 |
+
*
|
15 |
+
* @var Mage_Core_Model_Mysql4_Collection_Abstract
|
16 |
+
*/
|
17 |
+
protected $_collection = null;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* GET parameter page variable
|
21 |
+
*
|
22 |
+
* @var string
|
23 |
+
*/
|
24 |
+
protected $_pageVarName = 'p';
|
25 |
+
|
26 |
+
/**
|
27 |
+
* GET parameter order variable
|
28 |
+
*
|
29 |
+
* @var string
|
30 |
+
*/
|
31 |
+
protected $_orderVarName = 'order';
|
32 |
+
|
33 |
+
/**
|
34 |
+
* GET parameter direction variable
|
35 |
+
*
|
36 |
+
* @var string
|
37 |
+
*/
|
38 |
+
protected $_directionVarName = 'dir';
|
39 |
+
|
40 |
+
/**
|
41 |
+
* GET parameter mode variable
|
42 |
+
*
|
43 |
+
* @var string
|
44 |
+
*/
|
45 |
+
protected $_modeVarName = 'mode';
|
46 |
+
|
47 |
+
/**
|
48 |
+
* GET parameter limit variable
|
49 |
+
*
|
50 |
+
* @var string
|
51 |
+
*/
|
52 |
+
protected $_limitVarName = 'size';
|
53 |
+
|
54 |
+
/**
|
55 |
+
* GET parameter search handle variable
|
56 |
+
*
|
57 |
+
* @var string
|
58 |
+
*/
|
59 |
+
protected $_searchHandleVarName = 'sh';
|
60 |
+
|
61 |
+
/**
|
62 |
+
* List of available order fields
|
63 |
+
*
|
64 |
+
* @var array
|
65 |
+
*/
|
66 |
+
protected $_availableOrder = array();
|
67 |
+
|
68 |
+
/**
|
69 |
+
* List of available view types
|
70 |
+
*
|
71 |
+
* @var string
|
72 |
+
*/
|
73 |
+
protected $_availableMode = array();
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Is enable View switcher
|
77 |
+
*
|
78 |
+
* @var bool
|
79 |
+
*/
|
80 |
+
protected $_enableViewSwitcher = true;
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Is Expanded
|
84 |
+
*
|
85 |
+
* @var bool
|
86 |
+
*/
|
87 |
+
protected $_isExpanded = true;
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Default Order field
|
91 |
+
*
|
92 |
+
* @var string
|
93 |
+
*/
|
94 |
+
protected $_orderField = null;
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Default direction
|
98 |
+
*
|
99 |
+
* @var string
|
100 |
+
*/
|
101 |
+
protected $_direction = 'asc';
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Default View mode
|
105 |
+
*
|
106 |
+
* @var string
|
107 |
+
*/
|
108 |
+
protected $_viewMode = null;
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Available page limits for different list modes
|
112 |
+
*
|
113 |
+
* @var array
|
114 |
+
*/
|
115 |
+
protected $_availableLimit = array();
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Default limits per page
|
119 |
+
*
|
120 |
+
* @var array
|
121 |
+
*/
|
122 |
+
protected $_defaultAvailableLimit = array(10=>10,20=>20,50=>50);
|
123 |
+
|
124 |
+
/**
|
125 |
+
* @var bool $_paramsMemorizeAllowed
|
126 |
+
*/
|
127 |
+
protected $_paramsMemorizeAllowed = true;
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Retrieve salesperson session
|
131 |
+
*
|
132 |
+
* @return Mage_Catalog_Model_Session
|
133 |
+
*/
|
134 |
+
protected function _getSession()
|
135 |
+
{
|
136 |
+
return Mage::getSingleton('salesperson/session');
|
137 |
+
}
|
138 |
+
/**
|
139 |
+
* Retrieve Catalog Config object
|
140 |
+
*
|
141 |
+
* @return Mage_Catalog_Model_Config
|
142 |
+
*/
|
143 |
+
protected function _getConfig()
|
144 |
+
{
|
145 |
+
return Mage::getSingleton('catalog/config');
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Init Toolbar
|
150 |
+
*
|
151 |
+
*/
|
152 |
+
protected function _construct()
|
153 |
+
{
|
154 |
+
parent::_construct();
|
155 |
+
$this->_orderField = Mage::getStoreConfig(
|
156 |
+
Mage_Catalog_Model_Config::XML_PATH_LIST_DEFAULT_SORT_BY
|
157 |
+
);
|
158 |
+
|
159 |
+
$this->_availableOrder = $this->_getConfig()->getAttributeUsedForSortByArray();
|
160 |
+
|
161 |
+
switch (Mage::getStoreConfig('catalog/frontend/list_mode')) {
|
162 |
+
case 'grid':
|
163 |
+
$this->_availableMode = array('grid' => $this->__('Grid'));
|
164 |
+
break;
|
165 |
+
|
166 |
+
case 'list':
|
167 |
+
$this->_availableMode = array('list' => $this->__('List'));
|
168 |
+
break;
|
169 |
+
|
170 |
+
case 'grid-list':
|
171 |
+
$this->_availableMode = array('grid' => $this->__('Grid'), 'list' => $this->__('List'));
|
172 |
+
break;
|
173 |
+
|
174 |
+
case 'list-grid':
|
175 |
+
$this->_availableMode = array('list' => $this->__('List'), 'grid' => $this->__('Grid'));
|
176 |
+
break;
|
177 |
+
}
|
178 |
+
$this->setTemplate('catalog/product/list/toolbar.phtml');
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Disable list state params memorizing
|
183 |
+
*/
|
184 |
+
public function disableParamsMemorizing()
|
185 |
+
{
|
186 |
+
$this->_paramsMemorizeAllowed = false;
|
187 |
+
return $this;
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Memorize parameter value for session
|
192 |
+
*
|
193 |
+
* @param string $param parameter name
|
194 |
+
* @param mixed $value parameter value
|
195 |
+
* @return Mage_Catalog_Block_Product_List_Toolbar
|
196 |
+
*/
|
197 |
+
protected function _memorizeParam($param, $value)
|
198 |
+
{
|
199 |
+
$session = Mage::getSingleton('salesperson/session');
|
200 |
+
if ($this->_paramsMemorizeAllowed && !$session->getParamsMemorizeDisabled()) {
|
201 |
+
$session->setData($param, $value);
|
202 |
+
}
|
203 |
+
return $this;
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Return products collection instance
|
208 |
+
*
|
209 |
+
* @return Mage_Core_Model_Mysql4_Collection_Abstract
|
210 |
+
*/
|
211 |
+
public function getCollection()
|
212 |
+
{
|
213 |
+
return $this->_collection;
|
214 |
+
}
|
215 |
+
|
216 |
+
protected function getQwiserSearchResults(){
|
217 |
+
if(Mage::helper('salesperson')->getSalespersonApi()->results)
|
218 |
+
return Mage::helper('salesperson')->getSalespersonApi()->results;
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Retrieve search result count
|
223 |
+
*
|
224 |
+
* @return string
|
225 |
+
*/
|
226 |
+
public function getResultCount()
|
227 |
+
{
|
228 |
+
return $this->getQwiserSearchResults()->GetRelevantProductsCount();
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Getter for $_pageVarName
|
233 |
+
*
|
234 |
+
* @return string
|
235 |
+
*/
|
236 |
+
public function getPageVarName()
|
237 |
+
{
|
238 |
+
return $this->_pageVarName;
|
239 |
+
}
|
240 |
+
|
241 |
+
/**
|
242 |
+
* Retrieve order field GET var name
|
243 |
+
*
|
244 |
+
* @return string
|
245 |
+
*/
|
246 |
+
public function getOrderVarName()
|
247 |
+
{
|
248 |
+
return $this->_orderVarName;
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Retrieve sort direction GET var name
|
253 |
+
*
|
254 |
+
* @return string
|
255 |
+
*/
|
256 |
+
public function getDirectionVarName()
|
257 |
+
{
|
258 |
+
return $this->_directionVarName;
|
259 |
+
}
|
260 |
+
|
261 |
+
/**
|
262 |
+
* Retrieve view mode GET var name
|
263 |
+
*
|
264 |
+
* @return string
|
265 |
+
*/
|
266 |
+
public function getModeVarName()
|
267 |
+
{
|
268 |
+
return $this->_modeVarName;
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Getter for $_limitVarName
|
273 |
+
*
|
274 |
+
* @return string
|
275 |
+
*/
|
276 |
+
public function getLimitVarName()
|
277 |
+
{
|
278 |
+
return $this->_limitVarName;
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Getter for $_searchHandleVarName
|
283 |
+
*
|
284 |
+
* @return string
|
285 |
+
*/
|
286 |
+
public function getSearchHandleVarName(){
|
287 |
+
return $this->_searchHandleVarName;
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* Return current page from request
|
292 |
+
*
|
293 |
+
* @return int
|
294 |
+
*/
|
295 |
+
public function getCurrentPage()
|
296 |
+
{
|
297 |
+
if ($page = (int) $this->getRequest()->getParam($this->getPageVarName())) {
|
298 |
+
return $page;
|
299 |
+
}
|
300 |
+
return 1;
|
301 |
+
}
|
302 |
+
|
303 |
+
/**
|
304 |
+
* Get grit products sort order field
|
305 |
+
*
|
306 |
+
* @return string
|
307 |
+
*/
|
308 |
+
public function getCurrentOrder()
|
309 |
+
{
|
310 |
+
$order = $this->_getData('_current_grid_order');
|
311 |
+
if ($order) {
|
312 |
+
return $order;
|
313 |
+
}
|
314 |
+
|
315 |
+
$orders = $this->getAvailableOrders();
|
316 |
+
$defaultOrder = Mage::helper('salesperson')->getDefaultSortBy();
|
317 |
+
|
318 |
+
if (!isset($orders[$defaultOrder])) {
|
319 |
+
$keys = array_keys($orders);
|
320 |
+
$defaultOrder = $keys[0];
|
321 |
+
}
|
322 |
+
|
323 |
+
$order = $this->getRequest()->getParam($this->getOrderVarName());
|
324 |
+
if ($order && isset($orders[$order])) {
|
325 |
+
if ($order == $defaultOrder) {
|
326 |
+
Mage::getSingleton('salesperson/session')->unsSortOrder();
|
327 |
+
} else {
|
328 |
+
$this->_memorizeParam('sort_order', $order);
|
329 |
+
//Mage::Helper('salesperson')->getQuery()->qsr = Mage::Helper('salesperson/salespersonSearchApi')->SortByField($this->getQwiserSearchResults()->GetSearchHandle(), $order, true, true);
|
330 |
+
}
|
331 |
+
} else {
|
332 |
+
$order = Mage::getSingleton('salesperson/session')->getSortOrder();// Removed by Eli Sagy
|
333 |
+
}
|
334 |
+
// validate session value
|
335 |
+
if (!$order || !isset($orders[$order])) {
|
336 |
+
$order = $defaultOrder;
|
337 |
+
}
|
338 |
+
$this->setData('_current_grid_order', $order);
|
339 |
+
return $order;
|
340 |
+
}
|
341 |
+
|
342 |
+
/**
|
343 |
+
* Retrieve current direction
|
344 |
+
*
|
345 |
+
* @return string
|
346 |
+
*/
|
347 |
+
public function getCurrentDirection()
|
348 |
+
{
|
349 |
+
$dir = $this->_getData('_current_grid_direction');
|
350 |
+
if ($dir) {
|
351 |
+
return $dir;
|
352 |
+
}
|
353 |
+
|
354 |
+
$directions = array('asc', 'desc');
|
355 |
+
$dir = strtolower($this->getRequest()->getParam($this->getDirectionVarName()));
|
356 |
+
if ($dir && in_array($dir, $directions)) {
|
357 |
+
if ($dir == $this->_direction) {
|
358 |
+
Mage::getSingleton('catalog/session')->unsSortDirection();
|
359 |
+
} else {
|
360 |
+
$this->_memorizeParam('sort_direction', $dir);
|
361 |
+
}
|
362 |
+
} else {
|
363 |
+
$dir = Mage::getSingleton('catalog/session')->getSortDirection();
|
364 |
+
}
|
365 |
+
// validate direction
|
366 |
+
if (!$dir || !in_array($dir, $directions)) {
|
367 |
+
$dir = $this->_direction;
|
368 |
+
}
|
369 |
+
$this->setData('_current_grid_direction', $dir);
|
370 |
+
return $dir;
|
371 |
+
}
|
372 |
+
|
373 |
+
/**
|
374 |
+
* Set default Order field
|
375 |
+
*
|
376 |
+
* @param string $field
|
377 |
+
* @return Mage_Catalog_Block_Product_List_Toolbar
|
378 |
+
*/
|
379 |
+
public function setDefaultOrder($field)
|
380 |
+
{
|
381 |
+
if (isset($this->_availableOrder[$field])) {
|
382 |
+
$this->_orderField = $field;
|
383 |
+
}
|
384 |
+
return $this;
|
385 |
+
}
|
386 |
+
|
387 |
+
/**
|
388 |
+
* Set default sort direction
|
389 |
+
*
|
390 |
+
* @param string $dir
|
391 |
+
* @return Mage_Catalog_Block_Product_List_Toolbar
|
392 |
+
*/
|
393 |
+
public function setDefaultDirection($dir)
|
394 |
+
{
|
395 |
+
if (in_array(strtolower($dir), array('asc', 'desc'))) {
|
396 |
+
$this->_direction = strtolower($dir);
|
397 |
+
}
|
398 |
+
return $this;
|
399 |
+
}
|
400 |
+
|
401 |
+
/**
|
402 |
+
* Retrieve available Order fields list
|
403 |
+
*
|
404 |
+
* @return array
|
405 |
+
*/
|
406 |
+
public function getAvailableOrders()
|
407 |
+
{
|
408 |
+
return $this->_availableOrder;
|
409 |
+
}
|
410 |
+
|
411 |
+
/**
|
412 |
+
* Set Available order fields list
|
413 |
+
*
|
414 |
+
* @param array $orders
|
415 |
+
* @return Mage_Catalog_Block_Product_List_Toolbar
|
416 |
+
*/
|
417 |
+
public function setAvailableOrders($orders)
|
418 |
+
{
|
419 |
+
$this->_availableOrder = $orders;
|
420 |
+
return $this;
|
421 |
+
}
|
422 |
+
|
423 |
+
/**
|
424 |
+
* Add order to available orders
|
425 |
+
*
|
426 |
+
* @param string $order
|
427 |
+
* @param string $value
|
428 |
+
* @return Mage_Catalog_Block_Product_List_Toolbar
|
429 |
+
*/
|
430 |
+
public function addOrderToAvailableOrders($order, $value)
|
431 |
+
{
|
432 |
+
$this->_availableOrder[$order] = $value;
|
433 |
+
return $this;
|
434 |
+
}
|
435 |
+
/**
|
436 |
+
* Remove order from available orders if exists
|
437 |
+
*
|
438 |
+
* @param string $order
|
439 |
+
* @param Mage_Catalog_Block_Product_List_Toolbar
|
440 |
+
*/
|
441 |
+
public function removeOrderFromAvailableOrders($order)
|
442 |
+
{
|
443 |
+
if (isset($this->_availableOrder[$order])) {
|
444 |
+
unset($this->_availableOrder[$order]);
|
445 |
+
}
|
446 |
+
return $this;
|
447 |
+
}
|
448 |
+
|
449 |
+
/**
|
450 |
+
* Compare defined order field vith current order field
|
451 |
+
*
|
452 |
+
* @param string $order
|
453 |
+
* @return bool
|
454 |
+
*/
|
455 |
+
public function isOrderCurrent($order)
|
456 |
+
{
|
457 |
+
return $order == $this->getCurrentOrder();
|
458 |
+
}
|
459 |
+
|
460 |
+
/**
|
461 |
+
* Retrieve Pager URL
|
462 |
+
*
|
463 |
+
* @param string $order
|
464 |
+
* @param string $direction
|
465 |
+
* @return string
|
466 |
+
*/
|
467 |
+
public function getOrderUrl($order, $direction)
|
468 |
+
{
|
469 |
+
if (is_null($order)) {
|
470 |
+
$order = $this->getCurrentOrder() ? $this->getCurrentOrder() : $this->_availableOrder[0];
|
471 |
+
}
|
472 |
+
$params = array(
|
473 |
+
"salespersonaction"=>"sort",
|
474 |
+
$this->getOrderVarName()=>$order,
|
475 |
+
$this->getDirectionVarName()=>$direction,
|
476 |
+
$this->getPageVarName() => null
|
477 |
+
);
|
478 |
+
return $this->getPagerUrl($params);
|
479 |
+
}
|
480 |
+
|
481 |
+
/**
|
482 |
+
* Retrieve Order direction
|
483 |
+
*
|
484 |
+
* @param string $order
|
485 |
+
* @return string
|
486 |
+
*/
|
487 |
+
public function getOrderDirection($order)
|
488 |
+
{
|
489 |
+
return Mage::helper('salesperson')->getSortDirection($order);
|
490 |
+
}
|
491 |
+
|
492 |
+
/**
|
493 |
+
* Return current URL with rewrites and additional parameters
|
494 |
+
*
|
495 |
+
* @param array $params Query parameters
|
496 |
+
* @return string
|
497 |
+
*/
|
498 |
+
public function getPagerUrl($params=array())
|
499 |
+
{
|
500 |
+
$params['searchHandle'] = $this->getQwiserSearchResults()->GetSearchHandle();
|
501 |
+
$urlParams = array();
|
502 |
+
$urlParams['_current'] = true;
|
503 |
+
$urlParams['_escape'] = true;
|
504 |
+
$urlParams['_use_rewrite'] = false;
|
505 |
+
$urlParams['_query'] = $params;
|
506 |
+
return $this->getUrl('*/*/change', $urlParams);
|
507 |
+
}
|
508 |
+
|
509 |
+
/**
|
510 |
+
* Retrieve current View mode
|
511 |
+
*
|
512 |
+
* @return string
|
513 |
+
*/
|
514 |
+
public function getCurrentMode()
|
515 |
+
{
|
516 |
+
$mode = $this->_getData('_current_grid_mode');
|
517 |
+
if ($mode) {
|
518 |
+
return $mode;
|
519 |
+
}
|
520 |
+
$modes = array_keys($this->_availableMode);
|
521 |
+
$defaultMode = current($modes);
|
522 |
+
$mode = $this->getRequest()->getParam($this->getModeVarName());
|
523 |
+
if ($mode) {
|
524 |
+
if ($mode == $defaultMode) {
|
525 |
+
Mage::getSingleton('catalog/session')->unsDisplayMode();
|
526 |
+
} else {
|
527 |
+
$this->_memorizeParam('display_mode', $mode);
|
528 |
+
}
|
529 |
+
} else {
|
530 |
+
$mode = Mage::getSingleton('catalog/session')->getDisplayMode();
|
531 |
+
}
|
532 |
+
|
533 |
+
if (!$mode || !isset($this->_availableMode[$mode])) {
|
534 |
+
$mode = $defaultMode;
|
535 |
+
}
|
536 |
+
$this->setData('_current_grid_mode', $mode);
|
537 |
+
return $mode;
|
538 |
+
}
|
539 |
+
|
540 |
+
/**
|
541 |
+
* Compare defined view mode with current active mode
|
542 |
+
*
|
543 |
+
* @param string $mode
|
544 |
+
* @return bool
|
545 |
+
*/
|
546 |
+
public function isModeActive($mode)
|
547 |
+
{
|
548 |
+
return $this->getCurrentMode() == $mode;
|
549 |
+
}
|
550 |
+
|
551 |
+
/**
|
552 |
+
* Retrieve availables view modes
|
553 |
+
*
|
554 |
+
* @return array
|
555 |
+
*/
|
556 |
+
public function getModes()
|
557 |
+
{
|
558 |
+
return $this->_availableMode;
|
559 |
+
}
|
560 |
+
|
561 |
+
/**
|
562 |
+
* Set available view modes list
|
563 |
+
*
|
564 |
+
* @param array $modes
|
565 |
+
* @return Mage_Catalog_Block_Product_List_Toolbar
|
566 |
+
*/
|
567 |
+
public function setModes($modes)
|
568 |
+
{
|
569 |
+
if(!isset($this->_availableMode)){
|
570 |
+
$this->_availableMode = $modes;
|
571 |
+
}
|
572 |
+
return $this;
|
573 |
+
}
|
574 |
+
|
575 |
+
/**
|
576 |
+
* Retrive URL for view mode
|
577 |
+
*
|
578 |
+
* @param string $mode
|
579 |
+
* @return string
|
580 |
+
*/
|
581 |
+
public function getModeUrl($mode)
|
582 |
+
{
|
583 |
+
$urlParams = array();
|
584 |
+
$urlParams['_current'] = true;
|
585 |
+
$urlParams['_escape'] = true;
|
586 |
+
$urlParams['_use_rewrite'] = false;
|
587 |
+
$urlParams['_query'] = array($this->getModeVarName()=>$mode, $this->getPageVarName() => null);
|
588 |
+
return $this->getUrl('*/*/*', $urlParams);
|
589 |
+
}
|
590 |
+
|
591 |
+
/**
|
592 |
+
* Disable view switcher
|
593 |
+
*
|
594 |
+
* @return Mage_Catalog_Block_Product_List_Toolbar
|
595 |
+
*/
|
596 |
+
public function disableViewSwitcher()
|
597 |
+
{
|
598 |
+
$this->_enableViewSwitcher = false;
|
599 |
+
return $this;
|
600 |
+
}
|
601 |
+
|
602 |
+
/**
|
603 |
+
* Enable view switcher
|
604 |
+
*
|
605 |
+
* @return Mage_Catalog_Block_Product_List_Toolbar
|
606 |
+
*/
|
607 |
+
public function enableViewSwitcher()
|
608 |
+
{
|
609 |
+
$this->_enableViewSwitcher = true;
|
610 |
+
return $this;
|
611 |
+
}
|
612 |
+
|
613 |
+
/**
|
614 |
+
* Is a enabled view switcher
|
615 |
+
*
|
616 |
+
* @return bool
|
617 |
+
*/
|
618 |
+
public function isEnabledViewSwitcher()
|
619 |
+
{
|
620 |
+
return $this->_enableViewSwitcher;
|
621 |
+
}
|
622 |
+
|
623 |
+
/**
|
624 |
+
* Disable Expanded
|
625 |
+
*
|
626 |
+
* @return Mage_Catalog_Block_Product_List_Toolbar
|
627 |
+
*/
|
628 |
+
public function disableExpanded()
|
629 |
+
{
|
630 |
+
$this->_isExpanded = false;
|
631 |
+
return $this;
|
632 |
+
}
|
633 |
+
|
634 |
+
/**
|
635 |
+
* Enable Expanded
|
636 |
+
*
|
637 |
+
* @return Mage_Catalog_Block_Product_List_Toolbar
|
638 |
+
*/
|
639 |
+
public function enableExpanded()
|
640 |
+
{
|
641 |
+
$this->_isExpanded = true;
|
642 |
+
return $this;
|
643 |
+
}
|
644 |
+
|
645 |
+
/**
|
646 |
+
* Check is Expanded
|
647 |
+
*
|
648 |
+
* @return bool
|
649 |
+
*/
|
650 |
+
public function isExpanded()
|
651 |
+
{
|
652 |
+
return $this->_isExpanded;
|
653 |
+
}
|
654 |
+
|
655 |
+
/**
|
656 |
+
* Retrieve default per page values
|
657 |
+
*
|
658 |
+
* @return string (comma separated)
|
659 |
+
*/
|
660 |
+
public function getDefaultPerPageValue()
|
661 |
+
{
|
662 |
+
if ($this->getCurrentMode() == 'list') {
|
663 |
+
if ($default = $this->getDefaultListPerPage()) {
|
664 |
+
return $default;
|
665 |
+
}
|
666 |
+
return Mage::getStoreConfig('catalog/frontend/list_per_page');
|
667 |
+
}
|
668 |
+
elseif ($this->getCurrentMode() == 'grid') {
|
669 |
+
if ($default = $this->getDefaultGridPerPage()) {
|
670 |
+
return $default;
|
671 |
+
}
|
672 |
+
return Mage::getStoreConfig('catalog/frontend/grid_per_page');
|
673 |
+
}
|
674 |
+
return 0;
|
675 |
+
}
|
676 |
+
|
677 |
+
/**
|
678 |
+
* Add new limit to pager for mode
|
679 |
+
*
|
680 |
+
* @param string $mode
|
681 |
+
* @param string $value
|
682 |
+
* @param string $label
|
683 |
+
* @return Mage_Catalog_Block_Product_List_Toolbar
|
684 |
+
*/
|
685 |
+
public function addPagerLimit($mode, $value, $label='')
|
686 |
+
{
|
687 |
+
if (!isset($this->_availableLimit[$mode])) {
|
688 |
+
$this->_availableLimit[$mode] = array();
|
689 |
+
}
|
690 |
+
$this->_availableLimit[$mode][$value] = empty($label) ? $value : $label;
|
691 |
+
return $this;
|
692 |
+
}
|
693 |
+
|
694 |
+
/**
|
695 |
+
* Retrieve available limits for current view mode
|
696 |
+
*
|
697 |
+
* @return array
|
698 |
+
*/
|
699 |
+
public function getAvailableLimit()
|
700 |
+
{
|
701 |
+
//return array(9=>'9',15=>'15',21=>'21');
|
702 |
+
|
703 |
+
$currentMode = $this->getCurrentMode();
|
704 |
+
if (in_array($currentMode, array('list', 'grid'))) {
|
705 |
+
return $this->_getAvailableLimit($currentMode);
|
706 |
+
} else {
|
707 |
+
return $this->_defaultAvailableLimit;
|
708 |
+
}
|
709 |
+
}
|
710 |
+
|
711 |
+
/**
|
712 |
+
* Retrieve available limits for specified view mode
|
713 |
+
*
|
714 |
+
* @return array
|
715 |
+
*/
|
716 |
+
protected function _getAvailableLimit($mode)
|
717 |
+
{
|
718 |
+
if (isset($this->_availableLimit[$mode])) {
|
719 |
+
return $this->_availableLimit[$mode];
|
720 |
+
}
|
721 |
+
$perPageConfigKey = 'catalog/frontend/' . $mode . '_per_page_values';
|
722 |
+
$perPageValues = (string)Mage::getStoreConfig($perPageConfigKey);
|
723 |
+
$perPageValues = explode(',', $perPageValues);
|
724 |
+
$perPageValues = array_combine($perPageValues, $perPageValues);
|
725 |
+
if (Mage::getStoreConfigFlag('catalog/frontend/list_allow_all')) {
|
726 |
+
return ($perPageValues + array('all'=>$this->__('All')));
|
727 |
+
} else {
|
728 |
+
return $perPageValues;
|
729 |
+
}
|
730 |
+
}
|
731 |
+
|
732 |
+
/**
|
733 |
+
* Get specified products limit display per page
|
734 |
+
*
|
735 |
+
* @return string
|
736 |
+
*/
|
737 |
+
public function getLimit()
|
738 |
+
{
|
739 |
+
$limit = $this->_getData('_current_limit');
|
740 |
+
if ($limit) {
|
741 |
+
return $limit;
|
742 |
+
}
|
743 |
+
|
744 |
+
$limits = $this->getAvailableLimit();
|
745 |
+
$defaultLimit = $this->getDefaultPerPageValue();
|
746 |
+
if (!$defaultLimit || !isset($limits[$defaultLimit])) {
|
747 |
+
$keys = array_keys($limits);
|
748 |
+
$defaultLimit = $keys[0];
|
749 |
+
}
|
750 |
+
|
751 |
+
$limit = $this->getRequest()->getParam($this->getLimitVarName());
|
752 |
+
if ($limit && isset($limits[$limit])) {
|
753 |
+
if ($limit == $defaultLimit) {
|
754 |
+
Mage::getSingleton('catalog/session')->unsLimitPage();
|
755 |
+
} else {
|
756 |
+
$this->_memorizeParam('limit_page', $limit);
|
757 |
+
}
|
758 |
+
} else {
|
759 |
+
$limit = Mage::helper('salesperson')->getDefaultPageSize();
|
760 |
+
//$limit = Mage::getSingleton('catalog/session')->getLimitPage();
|
761 |
+
}
|
762 |
+
if (!$limit || !isset($limits[$limit])) {
|
763 |
+
$limit = $defaultLimit;
|
764 |
+
}
|
765 |
+
|
766 |
+
$this->setData('_current_limit', $limit);
|
767 |
+
|
768 |
+
return $limit;
|
769 |
+
}
|
770 |
+
|
771 |
+
/**
|
772 |
+
* Retrieve Limit Pager URL
|
773 |
+
*
|
774 |
+
* @param int $limit
|
775 |
+
* @return string
|
776 |
+
*/
|
777 |
+
public function getLimitUrl($limit)
|
778 |
+
{
|
779 |
+
return $this->getPagerUrl(array(
|
780 |
+
"salespersonaction"=>"limit",
|
781 |
+
$this->getLimitVarName() => $limit,
|
782 |
+
$this->getPageVarName() => null,
|
783 |
+
));
|
784 |
+
}
|
785 |
+
|
786 |
+
public function isLimitCurrent($limit)
|
787 |
+
{
|
788 |
+
return $limit == $this->getLimit();
|
789 |
+
}
|
790 |
+
|
791 |
+
public function getFirstNum()
|
792 |
+
{
|
793 |
+
return $this->getQwiserSearchResults()->SearchInformation->PageSize * ($this->getQwiserSearchResults()->SearchInformation->CurrentPage) + 1;
|
794 |
+
}
|
795 |
+
|
796 |
+
public function getLastNum()
|
797 |
+
{
|
798 |
+
if($this->getLimit() == 'all') return Mage::Helper('salesperson')->getAllPageSize();
|
799 |
+
|
800 |
+
$lastNum = $this->getFirstNum() + $this->getLimit() - 1;
|
801 |
+
$totalNum = $this->getTotalNum();
|
802 |
+
|
803 |
+
if($lastNum > $totalNum) $lastNum = $totalNum;
|
804 |
+
return $lastNum;
|
805 |
+
}
|
806 |
+
|
807 |
+
public function getTotalNum()
|
808 |
+
{
|
809 |
+
return (int)$this->getResultCount();
|
810 |
+
}
|
811 |
+
|
812 |
+
public function isFirstPage()
|
813 |
+
{
|
814 |
+
return $this->getQwiserSearchResults()->SearchInformation->CurrentPage == 0;
|
815 |
+
}
|
816 |
+
|
817 |
+
public function isLastPage()
|
818 |
+
{
|
819 |
+
return $this->getCurrentPage() >= $this->getLastPageNum();
|
820 |
+
}
|
821 |
+
|
822 |
+
public function getLastPageNum()
|
823 |
+
{
|
824 |
+
if (0 === $this->getResultCount()) {
|
825 |
+
return 1;
|
826 |
+
}
|
827 |
+
elseif($this->getQwiserSearchResults()->SearchInformation->PageSize) {
|
828 |
+
return ceil($this->getResultCount()/$this->getQwiserSearchResults()->SearchInformation->PageSize);
|
829 |
+
}
|
830 |
+
else{
|
831 |
+
return 1;
|
832 |
+
}
|
833 |
+
}
|
834 |
+
|
835 |
+
/**
|
836 |
+
* Render pagination HTML
|
837 |
+
*
|
838 |
+
* @return string
|
839 |
+
*/
|
840 |
+
public function getPagerHtml()
|
841 |
+
{
|
842 |
+
$pagerBlock = $this->getLayout()->getBlock('product_list_toolbar_pager');
|
843 |
+
|
844 |
+
/* @var $pagerBlock Mage_Page_Block_Html_Pager */
|
845 |
+
$pagerBlock->setAvailableLimit($this->getAvailableLimit());
|
846 |
+
|
847 |
+
$pagerBlock->setUseContainer(false)
|
848 |
+
->setShowPerPage(false)
|
849 |
+
->setShowAmounts(false)
|
850 |
+
->setLimitVarName($this->getLimitVarName())
|
851 |
+
->setPageVarName($this->getPageVarName())
|
852 |
+
->setLimit($this->getLimit())
|
853 |
+
->setFrameLength(Mage::getStoreConfig('design/pagination/pagination_frame'))
|
854 |
+
->setJump(Mage::getStoreConfig('design/pagination/pagination_frame_skip'));
|
855 |
+
|
856 |
+
return $pagerBlock->toHtml();
|
857 |
+
|
858 |
+
}
|
859 |
+
|
860 |
+
public function getPageSizeSelectorType() {
|
861 |
+
return Mage::getStoreConfig('salesperson/display_settings/page_size_selector');
|
862 |
+
}
|
863 |
+
|
864 |
+
public function getSortingSelectorType() {
|
865 |
+
return Mage::getStoreConfig('salesperson/display_settings/sorting_selector');
|
866 |
+
}
|
867 |
+
public function getPageNavType() {
|
868 |
+
return Mage::getStoreConfig('salesperson/display_settings/page_nav_type');
|
869 |
+
}
|
870 |
+
|
871 |
+
public function getPageUrl($page)
|
872 |
+
{
|
873 |
+
return $this->getPagerUrl(array("salespersonaction"=>"page",$this->getPageVarName()=>$page));
|
874 |
+
}
|
875 |
+
|
876 |
+
public function getNextPageUrl()
|
877 |
+
{
|
878 |
+
return $this->getPageUrl($this->getCurrentPage() + 1);
|
879 |
+
}
|
880 |
+
|
881 |
+
public function getPreviousPageUrl()
|
882 |
+
{
|
883 |
+
return $this->getPageUrl($this->getCurrentPage() - 1);
|
884 |
+
}
|
885 |
+
|
886 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/{local → community}/Celebros/Salesperson/Block/Product/List/Toolbar/Pager.php
RENAMED
@@ -1,559 +1,559 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Block_Product_List_Toolbar_Pager extends Mage_Core_Block_Template
|
11 |
-
{
|
12 |
-
protected $_pageVarName = 'p';
|
13 |
-
protected $_limitVarName = 'size';
|
14 |
-
protected $_availableLimit = array(10=>10,20=>20,50=>50);
|
15 |
-
protected $_dispersion = 3;
|
16 |
-
protected $_displayPages = 5;
|
17 |
-
protected $_showPerPage = true;
|
18 |
-
protected $_limit = null;
|
19 |
-
protected $_outputRequired = true;
|
20 |
-
/**
|
21 |
-
* Pages quantity per frame
|
22 |
-
* @var int
|
23 |
-
*/
|
24 |
-
protected $_frameLength = 5;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Next/previous page position relatively to the current frame
|
28 |
-
* @var int
|
29 |
-
*/
|
30 |
-
protected $_jump = 5;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Frame initialization flag
|
34 |
-
* @var bool
|
35 |
-
*/
|
36 |
-
protected $_frameInitialized = false;
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Start page position in frame
|
40 |
-
* @var int
|
41 |
-
*/
|
42 |
-
protected $_frameStart;
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Finish page position in frame
|
46 |
-
* @var int
|
47 |
-
*/
|
48 |
-
protected $_frameEnd;
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Retrieve salesperson session
|
52 |
-
*
|
53 |
-
* @return Mage_Catalog_Model_Session
|
54 |
-
*/
|
55 |
-
protected function _getSession()
|
56 |
-
{
|
57 |
-
return Mage::getSingleton('salesperson/session');
|
58 |
-
}
|
59 |
-
|
60 |
-
protected function _construct()
|
61 |
-
{
|
62 |
-
parent::_construct();
|
63 |
-
$this->setData('show_amounts', true);
|
64 |
-
$this->setData('use_container', true);
|
65 |
-
$this->setTemplate('salesperson/product/list/toolbar/pager.phtml');
|
66 |
-
}
|
67 |
-
|
68 |
-
public function getCurrentPage()
|
69 |
-
{
|
70 |
-
if ($page = (int) $this->getRequest()->getParam($this->getPageVarName())) {
|
71 |
-
return $page;
|
72 |
-
}
|
73 |
-
return 1;
|
74 |
-
}
|
75 |
-
|
76 |
-
public function getQwiserSearchResults(){
|
77 |
-
if(Mage::helper('salesperson')->getSalespersonApi()->results)
|
78 |
-
return Mage::helper('salesperson')->getSalespersonApi()->results;
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Return pager limitation from request or as assigned value
|
83 |
-
*
|
84 |
-
* @return int
|
85 |
-
*/
|
86 |
-
public function getLimit()
|
87 |
-
{
|
88 |
-
if ($this->_limit !== null) {
|
89 |
-
return $this->_limit;
|
90 |
-
}
|
91 |
-
return parent::getLimit();
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Setter for $_limit
|
96 |
-
*
|
97 |
-
* @param int $limit
|
98 |
-
* @return Mage_Catalog_Block_Product_List_Toolbar_Pager
|
99 |
-
*/
|
100 |
-
public function setLimit($limit)
|
101 |
-
{
|
102 |
-
$this->_limit = abs(intval($limit));
|
103 |
-
return $this;
|
104 |
-
}
|
105 |
-
|
106 |
-
public function getPageVarName()
|
107 |
-
{
|
108 |
-
return $this->_pageVarName;
|
109 |
-
}
|
110 |
-
|
111 |
-
public function setPageVarName($varName)
|
112 |
-
{
|
113 |
-
$this->_pageVarName = $varName;
|
114 |
-
return $this;
|
115 |
-
}
|
116 |
-
|
117 |
-
public function getShowPerPage()
|
118 |
-
{
|
119 |
-
if(sizeof($this->getAvailableLimit())<=1) {
|
120 |
-
return false;
|
121 |
-
}
|
122 |
-
return $this->_showPerPage;
|
123 |
-
}
|
124 |
-
|
125 |
-
public function setShowPerPage($varName)
|
126 |
-
{
|
127 |
-
$this->_showPerPage=$varName;
|
128 |
-
return $this;
|
129 |
-
}
|
130 |
-
|
131 |
-
public function setLimitVarName($varName)
|
132 |
-
{
|
133 |
-
$this->_limitVarName = $varName;
|
134 |
-
return $this;
|
135 |
-
}
|
136 |
-
|
137 |
-
public function getLimitVarName()
|
138 |
-
{
|
139 |
-
return $this->_limitVarName;
|
140 |
-
}
|
141 |
-
|
142 |
-
public function setAvailableLimit(array $limits)
|
143 |
-
{
|
144 |
-
$this->_availableLimit = $limits;
|
145 |
-
}
|
146 |
-
|
147 |
-
public function getAvailableLimit()
|
148 |
-
{
|
149 |
-
return $this->_availableLimit;
|
150 |
-
}
|
151 |
-
|
152 |
-
public function getTotalNum()
|
153 |
-
{
|
154 |
-
return $this->getQwiserSearchResults()->GetRelevantProductsCount();
|
155 |
-
}
|
156 |
-
|
157 |
-
/**
|
158 |
-
* Retrieve search result count
|
159 |
-
*
|
160 |
-
* @return string
|
161 |
-
*/
|
162 |
-
public function getResultCount()
|
163 |
-
{
|
164 |
-
return $this->getQwiserSearchResults()->GetRelevantProductsCount();
|
165 |
-
}
|
166 |
-
|
167 |
-
/**
|
168 |
-
* Getter for $_frameStart
|
169 |
-
*
|
170 |
-
* @return int
|
171 |
-
*/
|
172 |
-
public function getFrameStart()
|
173 |
-
{
|
174 |
-
$this->_initFrame();
|
175 |
-
return $this->_frameStart;
|
176 |
-
}
|
177 |
-
|
178 |
-
/**
|
179 |
-
* Getter for $_frameEnd
|
180 |
-
*
|
181 |
-
* @return int
|
182 |
-
*/
|
183 |
-
public function getFrameEnd()
|
184 |
-
{
|
185 |
-
$this->_initFrame();
|
186 |
-
return $this->_frameEnd;
|
187 |
-
}
|
188 |
-
|
189 |
-
/**
|
190 |
-
* Return array of pages in frame
|
191 |
-
*
|
192 |
-
* @return array
|
193 |
-
*/
|
194 |
-
public function getFramePages()
|
195 |
-
{
|
196 |
-
$start = $this->getFrameStart();
|
197 |
-
$end = $this->getFrameEnd();
|
198 |
-
return range($start, $end);
|
199 |
-
}
|
200 |
-
|
201 |
-
/**
|
202 |
-
* Return page number of Previous jump
|
203 |
-
*
|
204 |
-
* @return int
|
205 |
-
*/
|
206 |
-
public function getPreviousJumpPage()
|
207 |
-
{
|
208 |
-
if (!$this->getJump()) {
|
209 |
-
return null;
|
210 |
-
}
|
211 |
-
$frameStart = $this->getFrameStart();
|
212 |
-
if ($frameStart - 1 > 1) {
|
213 |
-
return max(2, $frameStart - $this->getJump());
|
214 |
-
}
|
215 |
-
|
216 |
-
return null;
|
217 |
-
}
|
218 |
-
|
219 |
-
/**
|
220 |
-
* Prepare URL for Previous Jump
|
221 |
-
*
|
222 |
-
* @return string
|
223 |
-
*/
|
224 |
-
public function getPreviousJumpUrl()
|
225 |
-
{
|
226 |
-
return $this->getPageUrl($this->getPreviousJumpPage());
|
227 |
-
}
|
228 |
-
|
229 |
-
public function getPageUrl($page)
|
230 |
-
{
|
231 |
-
return $this->getPagerUrl(array("salespersonaction"=>"page",$this->getPageVarName()=>$page));
|
232 |
-
}
|
233 |
-
|
234 |
-
public function isFirstPage()
|
235 |
-
{
|
236 |
-
return $this->getCurrentPage() == 1;
|
237 |
-
}
|
238 |
-
|
239 |
-
public function getLastPageNum()
|
240 |
-
{
|
241 |
-
return $this->getQwiserSearchResults()->SearchInformation->NumberOfPages;
|
242 |
-
}
|
243 |
-
|
244 |
-
public function isLastPage()
|
245 |
-
{
|
246 |
-
return $this->getCurrentPage() >= $this->getLastPageNum();
|
247 |
-
}
|
248 |
-
|
249 |
-
public function isLimitCurrent($limit)
|
250 |
-
{
|
251 |
-
return $limit == $this->getLimit();
|
252 |
-
}
|
253 |
-
|
254 |
-
public function isPageCurrent($page)
|
255 |
-
{
|
256 |
-
return $page == $this->getCurrentPage();
|
257 |
-
}
|
258 |
-
|
259 |
-
public function getPages()
|
260 |
-
{
|
261 |
-
$pages = array();
|
262 |
-
if ($this->getLastPageNum() <= $this->_displayPages) {
|
263 |
-
$pages = range(1, $this->getLastPageNum());
|
264 |
-
}
|
265 |
-
else {
|
266 |
-
$half = ceil($this->_displayPages / 2);
|
267 |
-
if ($this->getCurrentPage() >= $half && $this->getCurrentPage() <= $this->getLastPageNum() - $half) {
|
268 |
-
$start = ($this->getCurrentPage() - $half) + 1;
|
269 |
-
$finish = ($start + $this->_displayPages) - 1;
|
270 |
-
}
|
271 |
-
elseif ($this->getCurerentPage() < $half) {
|
272 |
-
$start = 1;
|
273 |
-
$finish = $this->_displayPages;
|
274 |
-
}
|
275 |
-
elseif ($this->getCurrentPage() > ($this->getLastPageNum() - $half)) {
|
276 |
-
$finish = $this->getLastPageNum();
|
277 |
-
$start = $finish - $this->_displayPages + 1;
|
278 |
-
}
|
279 |
-
|
280 |
-
$pages = range($start, $finish);
|
281 |
-
}
|
282 |
-
return $pages;
|
283 |
-
}
|
284 |
-
|
285 |
-
public function getFirstPageUrl()
|
286 |
-
{
|
287 |
-
return $this->getPageUrl(1);
|
288 |
-
}
|
289 |
-
|
290 |
-
public function getPreviousPageUrl()
|
291 |
-
{
|
292 |
-
return $this->getPageUrl($this->getCurrentPage() - 1);
|
293 |
-
}
|
294 |
-
|
295 |
-
public function getNextPageUrl()
|
296 |
-
{
|
297 |
-
return $this->getPageUrl($this->getCurrentPage() + 1);
|
298 |
-
}
|
299 |
-
|
300 |
-
public function getLastPageUrl()
|
301 |
-
{
|
302 |
-
return $this->getPageUrl($this->getLastPageNum());
|
303 |
-
}
|
304 |
-
|
305 |
-
public function getLimitUrl($limit)
|
306 |
-
{
|
307 |
-
return $this->getPagerUrl(array("salespersonaction"=>"limit",$this->getLimitVarName()=>$limit));
|
308 |
-
}
|
309 |
-
|
310 |
-
public function getPagerUrl($params=array())
|
311 |
-
{
|
312 |
-
$params['searchHandle'] = $this->getQwiserSearchResults()->GetSearchHandle();
|
313 |
-
$urlParams = array();
|
314 |
-
$urlParams['_current'] = true;
|
315 |
-
$urlParams['_escape'] = true;
|
316 |
-
$urlParams['_use_rewrite'] =
|
317 |
-
$urlParams['_query'] = $params;
|
318 |
-
return $this->getUrl('*/*/change', $urlParams);
|
319 |
-
}
|
320 |
-
|
321 |
-
|
322 |
-
/**
|
323 |
-
* Return page number of Next jump
|
324 |
-
*
|
325 |
-
* @return int
|
326 |
-
*/
|
327 |
-
public function getNextJumpPage()
|
328 |
-
{
|
329 |
-
if (!$this->getJump()) {
|
330 |
-
return null;
|
331 |
-
}
|
332 |
-
$frameEnd = $this->getFrameEnd();
|
333 |
-
if ($this->getLastPageNum() - $frameEnd > 1) {
|
334 |
-
return min($this->getLastPageNum() - 1, $frameEnd + $this->getJump());
|
335 |
-
}
|
336 |
-
|
337 |
-
return null;
|
338 |
-
}
|
339 |
-
|
340 |
-
/**
|
341 |
-
* Prepare URL for Next Jump
|
342 |
-
*
|
343 |
-
* @return string
|
344 |
-
*/
|
345 |
-
public function getNextJumpUrl()
|
346 |
-
{
|
347 |
-
return $this->getPageUrl($this->getNextJumpPage());
|
348 |
-
}
|
349 |
-
|
350 |
-
/**
|
351 |
-
* Getter for $_frameLength
|
352 |
-
*
|
353 |
-
* @return int
|
354 |
-
*/
|
355 |
-
public function getFrameLength()
|
356 |
-
{
|
357 |
-
return $this->_frameLength;
|
358 |
-
}
|
359 |
-
|
360 |
-
/**
|
361 |
-
* Getter for $_jump
|
362 |
-
*
|
363 |
-
* @return int
|
364 |
-
*/
|
365 |
-
public function getJump()
|
366 |
-
{
|
367 |
-
return $this->_jump;
|
368 |
-
}
|
369 |
-
|
370 |
-
/**
|
371 |
-
* Setter for $_frameLength
|
372 |
-
*
|
373 |
-
* @param int $frame
|
374 |
-
* @return Mage_Page_Block_Html_Pager
|
375 |
-
*/
|
376 |
-
public function setFrameLength($frame)
|
377 |
-
{
|
378 |
-
$frame = abs(intval($frame));
|
379 |
-
if ($frame == 0) {
|
380 |
-
$frame = $this->_frameLength;
|
381 |
-
}
|
382 |
-
if ($this->getFrameLength() != $frame) {
|
383 |
-
$this->_setFrameInitialized(false);
|
384 |
-
$this->_frameLength = $frame;
|
385 |
-
}
|
386 |
-
|
387 |
-
return $this;
|
388 |
-
}
|
389 |
-
|
390 |
-
/**
|
391 |
-
* Setter for $_jump
|
392 |
-
*
|
393 |
-
* @param int $jump
|
394 |
-
* @return Mage_Page_Block_Html_Pager
|
395 |
-
*/
|
396 |
-
public function setJump($jump)
|
397 |
-
{
|
398 |
-
$jump = abs(intval($jump));
|
399 |
-
if ($this->getJump() != $jump) {
|
400 |
-
$this->_setFrameInitialized(false);
|
401 |
-
$this->_jump = $jump;
|
402 |
-
}
|
403 |
-
|
404 |
-
return $this;
|
405 |
-
}
|
406 |
-
|
407 |
-
/**
|
408 |
-
* Whether to show first page in pagination or not
|
409 |
-
*
|
410 |
-
* @return bool
|
411 |
-
*/
|
412 |
-
public function canShowFirst()
|
413 |
-
{
|
414 |
-
return $this->getJump() > 1 && $this->getFrameStart() > 1;
|
415 |
-
}
|
416 |
-
|
417 |
-
/**
|
418 |
-
* Whether to show last page in pagination or not
|
419 |
-
*
|
420 |
-
* @return bool
|
421 |
-
*/
|
422 |
-
public function canShowLast()
|
423 |
-
{
|
424 |
-
return $this->getJump() > 1 && $this->getFrameEnd() < $this->getLastPageNum();
|
425 |
-
}
|
426 |
-
|
427 |
-
/**
|
428 |
-
* Whether to show link to Previous Jump
|
429 |
-
*
|
430 |
-
* @return bool
|
431 |
-
*/
|
432 |
-
public function canShowPreviousJump()
|
433 |
-
{
|
434 |
-
return $this->getPreviousJumpPage() !== null;
|
435 |
-
}
|
436 |
-
|
437 |
-
/**
|
438 |
-
* Whether to show link to Next Jump
|
439 |
-
*
|
440 |
-
* @return bool
|
441 |
-
*/
|
442 |
-
public function canShowNextJump()
|
443 |
-
{
|
444 |
-
return $this->getNextJumpPage() !== null;
|
445 |
-
}
|
446 |
-
|
447 |
-
/**
|
448 |
-
* Initialize frame data, such as frame start, frame start etc.
|
449 |
-
*
|
450 |
-
* @return Mage_Page_Block_Html_Pager
|
451 |
-
*/
|
452 |
-
protected function _initFrame()
|
453 |
-
{
|
454 |
-
if (!$this->isFrameInitialized()) {
|
455 |
-
$start = 0;
|
456 |
-
$end = 0;
|
457 |
-
|
458 |
-
if ($this->getLastPageNum() <= $this->getFrameLength()) {
|
459 |
-
$start = 1;
|
460 |
-
$end = $this->getLastPageNum();
|
461 |
-
}
|
462 |
-
else {
|
463 |
-
$half = ceil($this->getFrameLength() / 2);
|
464 |
-
if ($this->getCurrentPage() >= $half && $this->getCurrentPage() <= $this->getLastPageNum() - $half) {
|
465 |
-
$start = ($this->getCurrentPage() - $half) + 1;
|
466 |
-
$end = ($start + $this->getFrameLength()) - 1;
|
467 |
-
}
|
468 |
-
elseif ($this->
|
469 |
-
$start = 1;
|
470 |
-
$end = $this->getFrameLength();
|
471 |
-
}
|
472 |
-
elseif ($this->getCurrentPage() > ($this->getLastPageNum() - $half)) {
|
473 |
-
$end = $this->getLastPageNum();
|
474 |
-
$start = $end - $this->getFrameLength() + 1;
|
475 |
-
}
|
476 |
-
}
|
477 |
-
$this->_frameStart = $start;
|
478 |
-
$this->_frameEnd = $end;
|
479 |
-
|
480 |
-
$this->_setFrameInitialized(true);
|
481 |
-
}
|
482 |
-
|
483 |
-
return $this;
|
484 |
-
}
|
485 |
-
|
486 |
-
/**
|
487 |
-
* Setter for flag _frameInitialized
|
488 |
-
*
|
489 |
-
* @param bool $flag
|
490 |
-
* @return Mage_Page_Block_Html_Pager
|
491 |
-
*/
|
492 |
-
protected function _setFrameInitialized($flag)
|
493 |
-
{
|
494 |
-
$this->_frameInitialized = (bool)$flag;
|
495 |
-
return $this;
|
496 |
-
}
|
497 |
-
|
498 |
-
/**
|
499 |
-
* Check if frame data was initialized
|
500 |
-
*
|
501 |
-
* @return Mage_Page_Block_Html_Pager
|
502 |
-
*/
|
503 |
-
public function isFrameInitialized()
|
504 |
-
{
|
505 |
-
return $this->_frameInitialized;
|
506 |
-
}
|
507 |
-
|
508 |
-
/**
|
509 |
-
* Getter for alternative text for Previous link in pagination frame
|
510 |
-
*
|
511 |
-
* @return string
|
512 |
-
*/
|
513 |
-
public function getAnchorTextForPrevious()
|
514 |
-
{
|
515 |
-
return Mage::getStoreConfig('design/pagination/anchor_text_for_previous');
|
516 |
-
}
|
517 |
-
|
518 |
-
/**
|
519 |
-
* Getter for alternative text for Next link in pagination frame
|
520 |
-
*
|
521 |
-
* @return string
|
522 |
-
*/
|
523 |
-
public function getAnchorTextForNext()
|
524 |
-
{
|
525 |
-
return Mage::getStoreConfig('design/pagination/anchor_text_for_next');
|
526 |
-
}
|
527 |
-
|
528 |
-
/**
|
529 |
-
* Set whether output of the pager is mandatory
|
530 |
-
*
|
531 |
-
* @param bool $isRequired
|
532 |
-
* @return Mage_Page_Block_Html_Pager
|
533 |
-
*/
|
534 |
-
public function setIsOutputRequired($isRequired)
|
535 |
-
{
|
536 |
-
$this->_outputRequired = (bool)$isRequired;
|
537 |
-
return $this;
|
538 |
-
}
|
539 |
-
|
540 |
-
/**
|
541 |
-
* Render block HTML
|
542 |
-
*
|
543 |
-
* @return string
|
544 |
-
*/
|
545 |
-
protected function _toHtml()
|
546 |
-
{
|
547 |
-
if ($this->getQwiserSearchResults()->SearchInformation->NumberOfPages > 1) {
|
548 |
-
if ($this->_outputRequired || $this->getTotalNum() > $this->getLimit()) {
|
549 |
-
return Mage_Core_Block_Template::_toHtml();
|
550 |
-
}
|
551 |
-
} else {
|
552 |
-
return '';
|
553 |
-
}
|
554 |
-
}
|
555 |
-
|
556 |
-
public function getPageNavType() {
|
557 |
-
return Mage::getStoreConfig('salesperson/display_settings/page_nav_type');
|
558 |
-
}
|
559 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Block_Product_List_Toolbar_Pager extends Mage_Core_Block_Template
|
11 |
+
{
|
12 |
+
protected $_pageVarName = 'p';
|
13 |
+
protected $_limitVarName = 'size';
|
14 |
+
protected $_availableLimit = array(10=>10,20=>20,50=>50);
|
15 |
+
protected $_dispersion = 3;
|
16 |
+
protected $_displayPages = 5;
|
17 |
+
protected $_showPerPage = true;
|
18 |
+
protected $_limit = null;
|
19 |
+
protected $_outputRequired = true;
|
20 |
+
/**
|
21 |
+
* Pages quantity per frame
|
22 |
+
* @var int
|
23 |
+
*/
|
24 |
+
protected $_frameLength = 5;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Next/previous page position relatively to the current frame
|
28 |
+
* @var int
|
29 |
+
*/
|
30 |
+
protected $_jump = 5;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Frame initialization flag
|
34 |
+
* @var bool
|
35 |
+
*/
|
36 |
+
protected $_frameInitialized = false;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Start page position in frame
|
40 |
+
* @var int
|
41 |
+
*/
|
42 |
+
protected $_frameStart;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Finish page position in frame
|
46 |
+
* @var int
|
47 |
+
*/
|
48 |
+
protected $_frameEnd;
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Retrieve salesperson session
|
52 |
+
*
|
53 |
+
* @return Mage_Catalog_Model_Session
|
54 |
+
*/
|
55 |
+
protected function _getSession()
|
56 |
+
{
|
57 |
+
return Mage::getSingleton('salesperson/session');
|
58 |
+
}
|
59 |
+
|
60 |
+
protected function _construct()
|
61 |
+
{
|
62 |
+
parent::_construct();
|
63 |
+
$this->setData('show_amounts', true);
|
64 |
+
$this->setData('use_container', true);
|
65 |
+
$this->setTemplate('salesperson/product/list/toolbar/pager.phtml');
|
66 |
+
}
|
67 |
+
|
68 |
+
public function getCurrentPage()
|
69 |
+
{
|
70 |
+
if ($page = (int) $this->getRequest()->getParam($this->getPageVarName())) {
|
71 |
+
return $page;
|
72 |
+
}
|
73 |
+
return 1;
|
74 |
+
}
|
75 |
+
|
76 |
+
public function getQwiserSearchResults(){
|
77 |
+
if(Mage::helper('salesperson')->getSalespersonApi()->results)
|
78 |
+
return Mage::helper('salesperson')->getSalespersonApi()->results;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Return pager limitation from request or as assigned value
|
83 |
+
*
|
84 |
+
* @return int
|
85 |
+
*/
|
86 |
+
public function getLimit()
|
87 |
+
{
|
88 |
+
if ($this->_limit !== null) {
|
89 |
+
return $this->_limit;
|
90 |
+
}
|
91 |
+
return parent::getLimit();
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Setter for $_limit
|
96 |
+
*
|
97 |
+
* @param int $limit
|
98 |
+
* @return Mage_Catalog_Block_Product_List_Toolbar_Pager
|
99 |
+
*/
|
100 |
+
public function setLimit($limit)
|
101 |
+
{
|
102 |
+
$this->_limit = abs(intval($limit));
|
103 |
+
return $this;
|
104 |
+
}
|
105 |
+
|
106 |
+
public function getPageVarName()
|
107 |
+
{
|
108 |
+
return $this->_pageVarName;
|
109 |
+
}
|
110 |
+
|
111 |
+
public function setPageVarName($varName)
|
112 |
+
{
|
113 |
+
$this->_pageVarName = $varName;
|
114 |
+
return $this;
|
115 |
+
}
|
116 |
+
|
117 |
+
public function getShowPerPage()
|
118 |
+
{
|
119 |
+
if(sizeof($this->getAvailableLimit())<=1) {
|
120 |
+
return false;
|
121 |
+
}
|
122 |
+
return $this->_showPerPage;
|
123 |
+
}
|
124 |
+
|
125 |
+
public function setShowPerPage($varName)
|
126 |
+
{
|
127 |
+
$this->_showPerPage=$varName;
|
128 |
+
return $this;
|
129 |
+
}
|
130 |
+
|
131 |
+
public function setLimitVarName($varName)
|
132 |
+
{
|
133 |
+
$this->_limitVarName = $varName;
|
134 |
+
return $this;
|
135 |
+
}
|
136 |
+
|
137 |
+
public function getLimitVarName()
|
138 |
+
{
|
139 |
+
return $this->_limitVarName;
|
140 |
+
}
|
141 |
+
|
142 |
+
public function setAvailableLimit(array $limits)
|
143 |
+
{
|
144 |
+
$this->_availableLimit = $limits;
|
145 |
+
}
|
146 |
+
|
147 |
+
public function getAvailableLimit()
|
148 |
+
{
|
149 |
+
return $this->_availableLimit;
|
150 |
+
}
|
151 |
+
|
152 |
+
public function getTotalNum()
|
153 |
+
{
|
154 |
+
return $this->getQwiserSearchResults()->GetRelevantProductsCount();
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Retrieve search result count
|
159 |
+
*
|
160 |
+
* @return string
|
161 |
+
*/
|
162 |
+
public function getResultCount()
|
163 |
+
{
|
164 |
+
return $this->getQwiserSearchResults()->GetRelevantProductsCount();
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Getter for $_frameStart
|
169 |
+
*
|
170 |
+
* @return int
|
171 |
+
*/
|
172 |
+
public function getFrameStart()
|
173 |
+
{
|
174 |
+
$this->_initFrame();
|
175 |
+
return $this->_frameStart;
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Getter for $_frameEnd
|
180 |
+
*
|
181 |
+
* @return int
|
182 |
+
*/
|
183 |
+
public function getFrameEnd()
|
184 |
+
{
|
185 |
+
$this->_initFrame();
|
186 |
+
return $this->_frameEnd;
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Return array of pages in frame
|
191 |
+
*
|
192 |
+
* @return array
|
193 |
+
*/
|
194 |
+
public function getFramePages()
|
195 |
+
{
|
196 |
+
$start = $this->getFrameStart();
|
197 |
+
$end = $this->getFrameEnd();
|
198 |
+
return range($start, $end);
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Return page number of Previous jump
|
203 |
+
*
|
204 |
+
* @return int
|
205 |
+
*/
|
206 |
+
public function getPreviousJumpPage()
|
207 |
+
{
|
208 |
+
if (!$this->getJump()) {
|
209 |
+
return null;
|
210 |
+
}
|
211 |
+
$frameStart = $this->getFrameStart();
|
212 |
+
if ($frameStart - 1 > 1) {
|
213 |
+
return max(2, $frameStart - $this->getJump());
|
214 |
+
}
|
215 |
+
|
216 |
+
return null;
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Prepare URL for Previous Jump
|
221 |
+
*
|
222 |
+
* @return string
|
223 |
+
*/
|
224 |
+
public function getPreviousJumpUrl()
|
225 |
+
{
|
226 |
+
return $this->getPageUrl($this->getPreviousJumpPage());
|
227 |
+
}
|
228 |
+
|
229 |
+
public function getPageUrl($page)
|
230 |
+
{
|
231 |
+
return $this->getPagerUrl(array("salespersonaction"=>"page",$this->getPageVarName()=>$page));
|
232 |
+
}
|
233 |
+
|
234 |
+
public function isFirstPage()
|
235 |
+
{
|
236 |
+
return $this->getCurrentPage() == 1;
|
237 |
+
}
|
238 |
+
|
239 |
+
public function getLastPageNum()
|
240 |
+
{
|
241 |
+
return $this->getQwiserSearchResults()->SearchInformation->NumberOfPages;
|
242 |
+
}
|
243 |
+
|
244 |
+
public function isLastPage()
|
245 |
+
{
|
246 |
+
return $this->getCurrentPage() >= $this->getLastPageNum();
|
247 |
+
}
|
248 |
+
|
249 |
+
public function isLimitCurrent($limit)
|
250 |
+
{
|
251 |
+
return $limit == $this->getLimit();
|
252 |
+
}
|
253 |
+
|
254 |
+
public function isPageCurrent($page)
|
255 |
+
{
|
256 |
+
return $page == $this->getCurrentPage();
|
257 |
+
}
|
258 |
+
|
259 |
+
public function getPages()
|
260 |
+
{
|
261 |
+
$pages = array();
|
262 |
+
if ($this->getLastPageNum() <= $this->_displayPages) {
|
263 |
+
$pages = range(1, $this->getLastPageNum());
|
264 |
+
}
|
265 |
+
else {
|
266 |
+
$half = ceil($this->_displayPages / 2);
|
267 |
+
if ($this->getCurrentPage() >= $half && $this->getCurrentPage() <= $this->getLastPageNum() - $half) {
|
268 |
+
$start = ($this->getCurrentPage() - $half) + 1;
|
269 |
+
$finish = ($start + $this->_displayPages) - 1;
|
270 |
+
}
|
271 |
+
elseif ($this->getCurerentPage() < $half) {
|
272 |
+
$start = 1;
|
273 |
+
$finish = $this->_displayPages;
|
274 |
+
}
|
275 |
+
elseif ($this->getCurrentPage() > ($this->getLastPageNum() - $half)) {
|
276 |
+
$finish = $this->getLastPageNum();
|
277 |
+
$start = $finish - $this->_displayPages + 1;
|
278 |
+
}
|
279 |
+
|
280 |
+
$pages = range($start, $finish);
|
281 |
+
}
|
282 |
+
return $pages;
|
283 |
+
}
|
284 |
+
|
285 |
+
public function getFirstPageUrl()
|
286 |
+
{
|
287 |
+
return $this->getPageUrl(1);
|
288 |
+
}
|
289 |
+
|
290 |
+
public function getPreviousPageUrl()
|
291 |
+
{
|
292 |
+
return $this->getPageUrl($this->getCurrentPage() - 1);
|
293 |
+
}
|
294 |
+
|
295 |
+
public function getNextPageUrl()
|
296 |
+
{
|
297 |
+
return $this->getPageUrl($this->getCurrentPage() + 1);
|
298 |
+
}
|
299 |
+
|
300 |
+
public function getLastPageUrl()
|
301 |
+
{
|
302 |
+
return $this->getPageUrl($this->getLastPageNum());
|
303 |
+
}
|
304 |
+
|
305 |
+
public function getLimitUrl($limit)
|
306 |
+
{
|
307 |
+
return $this->getPagerUrl(array("salespersonaction"=>"limit",$this->getLimitVarName()=>$limit));
|
308 |
+
}
|
309 |
+
|
310 |
+
public function getPagerUrl($params=array())
|
311 |
+
{
|
312 |
+
$params['searchHandle'] = $this->getQwiserSearchResults()->GetSearchHandle();
|
313 |
+
$urlParams = array();
|
314 |
+
$urlParams['_current'] = true;
|
315 |
+
$urlParams['_escape'] = true;
|
316 |
+
$urlParams['_use_rewrite'] = false;
|
317 |
+
$urlParams['_query'] = $params;
|
318 |
+
return $this->getUrl('*/*/change', $urlParams);
|
319 |
+
}
|
320 |
+
|
321 |
+
|
322 |
+
/**
|
323 |
+
* Return page number of Next jump
|
324 |
+
*
|
325 |
+
* @return int
|
326 |
+
*/
|
327 |
+
public function getNextJumpPage()
|
328 |
+
{
|
329 |
+
if (!$this->getJump()) {
|
330 |
+
return null;
|
331 |
+
}
|
332 |
+
$frameEnd = $this->getFrameEnd();
|
333 |
+
if ($this->getLastPageNum() - $frameEnd > 1) {
|
334 |
+
return min($this->getLastPageNum() - 1, $frameEnd + $this->getJump());
|
335 |
+
}
|
336 |
+
|
337 |
+
return null;
|
338 |
+
}
|
339 |
+
|
340 |
+
/**
|
341 |
+
* Prepare URL for Next Jump
|
342 |
+
*
|
343 |
+
* @return string
|
344 |
+
*/
|
345 |
+
public function getNextJumpUrl()
|
346 |
+
{
|
347 |
+
return $this->getPageUrl($this->getNextJumpPage());
|
348 |
+
}
|
349 |
+
|
350 |
+
/**
|
351 |
+
* Getter for $_frameLength
|
352 |
+
*
|
353 |
+
* @return int
|
354 |
+
*/
|
355 |
+
public function getFrameLength()
|
356 |
+
{
|
357 |
+
return $this->_frameLength;
|
358 |
+
}
|
359 |
+
|
360 |
+
/**
|
361 |
+
* Getter for $_jump
|
362 |
+
*
|
363 |
+
* @return int
|
364 |
+
*/
|
365 |
+
public function getJump()
|
366 |
+
{
|
367 |
+
return $this->_jump;
|
368 |
+
}
|
369 |
+
|
370 |
+
/**
|
371 |
+
* Setter for $_frameLength
|
372 |
+
*
|
373 |
+
* @param int $frame
|
374 |
+
* @return Mage_Page_Block_Html_Pager
|
375 |
+
*/
|
376 |
+
public function setFrameLength($frame)
|
377 |
+
{
|
378 |
+
$frame = abs(intval($frame));
|
379 |
+
if ($frame == 0) {
|
380 |
+
$frame = $this->_frameLength;
|
381 |
+
}
|
382 |
+
if ($this->getFrameLength() != $frame) {
|
383 |
+
$this->_setFrameInitialized(false);
|
384 |
+
$this->_frameLength = $frame;
|
385 |
+
}
|
386 |
+
|
387 |
+
return $this;
|
388 |
+
}
|
389 |
+
|
390 |
+
/**
|
391 |
+
* Setter for $_jump
|
392 |
+
*
|
393 |
+
* @param int $jump
|
394 |
+
* @return Mage_Page_Block_Html_Pager
|
395 |
+
*/
|
396 |
+
public function setJump($jump)
|
397 |
+
{
|
398 |
+
$jump = abs(intval($jump));
|
399 |
+
if ($this->getJump() != $jump) {
|
400 |
+
$this->_setFrameInitialized(false);
|
401 |
+
$this->_jump = $jump;
|
402 |
+
}
|
403 |
+
|
404 |
+
return $this;
|
405 |
+
}
|
406 |
+
|
407 |
+
/**
|
408 |
+
* Whether to show first page in pagination or not
|
409 |
+
*
|
410 |
+
* @return bool
|
411 |
+
*/
|
412 |
+
public function canShowFirst()
|
413 |
+
{
|
414 |
+
return $this->getJump() > 1 && $this->getFrameStart() > 1;
|
415 |
+
}
|
416 |
+
|
417 |
+
/**
|
418 |
+
* Whether to show last page in pagination or not
|
419 |
+
*
|
420 |
+
* @return bool
|
421 |
+
*/
|
422 |
+
public function canShowLast()
|
423 |
+
{
|
424 |
+
return $this->getJump() > 1 && $this->getFrameEnd() < $this->getLastPageNum();
|
425 |
+
}
|
426 |
+
|
427 |
+
/**
|
428 |
+
* Whether to show link to Previous Jump
|
429 |
+
*
|
430 |
+
* @return bool
|
431 |
+
*/
|
432 |
+
public function canShowPreviousJump()
|
433 |
+
{
|
434 |
+
return $this->getPreviousJumpPage() !== null;
|
435 |
+
}
|
436 |
+
|
437 |
+
/**
|
438 |
+
* Whether to show link to Next Jump
|
439 |
+
*
|
440 |
+
* @return bool
|
441 |
+
*/
|
442 |
+
public function canShowNextJump()
|
443 |
+
{
|
444 |
+
return $this->getNextJumpPage() !== null;
|
445 |
+
}
|
446 |
+
|
447 |
+
/**
|
448 |
+
* Initialize frame data, such as frame start, frame start etc.
|
449 |
+
*
|
450 |
+
* @return Mage_Page_Block_Html_Pager
|
451 |
+
*/
|
452 |
+
protected function _initFrame()
|
453 |
+
{
|
454 |
+
if (!$this->isFrameInitialized()) {
|
455 |
+
$start = 0;
|
456 |
+
$end = 0;
|
457 |
+
|
458 |
+
if ($this->getLastPageNum() <= $this->getFrameLength()) {
|
459 |
+
$start = 1;
|
460 |
+
$end = $this->getLastPageNum();
|
461 |
+
}
|
462 |
+
else {
|
463 |
+
$half = ceil($this->getFrameLength() / 2);
|
464 |
+
if ($this->getCurrentPage() >= $half && $this->getCurrentPage() <= $this->getLastPageNum() - $half) {
|
465 |
+
$start = ($this->getCurrentPage() - $half) + 1;
|
466 |
+
$end = ($start + $this->getFrameLength()) - 1;
|
467 |
+
}
|
468 |
+
elseif ($this->getCurrentPage() < $half) {
|
469 |
+
$start = 1;
|
470 |
+
$end = $this->getFrameLength();
|
471 |
+
}
|
472 |
+
elseif ($this->getCurrentPage() > ($this->getLastPageNum() - $half)) {
|
473 |
+
$end = $this->getLastPageNum();
|
474 |
+
$start = $end - $this->getFrameLength() + 1;
|
475 |
+
}
|
476 |
+
}
|
477 |
+
$this->_frameStart = $start;
|
478 |
+
$this->_frameEnd = $end;
|
479 |
+
|
480 |
+
$this->_setFrameInitialized(true);
|
481 |
+
}
|
482 |
+
|
483 |
+
return $this;
|
484 |
+
}
|
485 |
+
|
486 |
+
/**
|
487 |
+
* Setter for flag _frameInitialized
|
488 |
+
*
|
489 |
+
* @param bool $flag
|
490 |
+
* @return Mage_Page_Block_Html_Pager
|
491 |
+
*/
|
492 |
+
protected function _setFrameInitialized($flag)
|
493 |
+
{
|
494 |
+
$this->_frameInitialized = (bool)$flag;
|
495 |
+
return $this;
|
496 |
+
}
|
497 |
+
|
498 |
+
/**
|
499 |
+
* Check if frame data was initialized
|
500 |
+
*
|
501 |
+
* @return Mage_Page_Block_Html_Pager
|
502 |
+
*/
|
503 |
+
public function isFrameInitialized()
|
504 |
+
{
|
505 |
+
return $this->_frameInitialized;
|
506 |
+
}
|
507 |
+
|
508 |
+
/**
|
509 |
+
* Getter for alternative text for Previous link in pagination frame
|
510 |
+
*
|
511 |
+
* @return string
|
512 |
+
*/
|
513 |
+
public function getAnchorTextForPrevious()
|
514 |
+
{
|
515 |
+
return Mage::getStoreConfig('design/pagination/anchor_text_for_previous');
|
516 |
+
}
|
517 |
+
|
518 |
+
/**
|
519 |
+
* Getter for alternative text for Next link in pagination frame
|
520 |
+
*
|
521 |
+
* @return string
|
522 |
+
*/
|
523 |
+
public function getAnchorTextForNext()
|
524 |
+
{
|
525 |
+
return Mage::getStoreConfig('design/pagination/anchor_text_for_next');
|
526 |
+
}
|
527 |
+
|
528 |
+
/**
|
529 |
+
* Set whether output of the pager is mandatory
|
530 |
+
*
|
531 |
+
* @param bool $isRequired
|
532 |
+
* @return Mage_Page_Block_Html_Pager
|
533 |
+
*/
|
534 |
+
public function setIsOutputRequired($isRequired)
|
535 |
+
{
|
536 |
+
$this->_outputRequired = (bool)$isRequired;
|
537 |
+
return $this;
|
538 |
+
}
|
539 |
+
|
540 |
+
/**
|
541 |
+
* Render block HTML
|
542 |
+
*
|
543 |
+
* @return string
|
544 |
+
*/
|
545 |
+
protected function _toHtml()
|
546 |
+
{
|
547 |
+
if ($this->getQwiserSearchResults()->SearchInformation->NumberOfPages > 1) {
|
548 |
+
if ($this->_outputRequired || $this->getTotalNum() > $this->getLimit()) {
|
549 |
+
return Mage_Core_Block_Template::_toHtml();
|
550 |
+
}
|
551 |
+
} else {
|
552 |
+
return '';
|
553 |
+
}
|
554 |
+
}
|
555 |
+
|
556 |
+
public function getPageNavType() {
|
557 |
+
return Mage::getStoreConfig('salesperson/display_settings/page_nav_type');
|
558 |
+
}
|
559 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Block/Result.php
RENAMED
@@ -1,265 +1,266 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Block_Result extends Mage_Core_Block_Template
|
11 |
-
{
|
12 |
-
/**
|
13 |
-
* Catalog Product collection
|
14 |
-
*
|
15 |
-
* @var Mage_CatalogSearch_Model_Mysql4_Fulltext_Collection
|
16 |
-
*/
|
17 |
-
protected $_productCollection;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Retrieve salesperson session
|
21 |
-
*
|
22 |
-
* @return Mage_Catalog_Model_Session
|
23 |
-
*/
|
24 |
-
|
25 |
-
var $helper;
|
26 |
-
|
27 |
-
protected function _getSession()
|
28 |
-
{
|
29 |
-
return Mage::getSingleton('salesperson/session');
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Retrieve QwiserSearchApi model object
|
34 |
-
*
|
35 |
-
* @return Mage_CatalogSearch_Model_Query
|
36 |
-
*/
|
37 |
-
protected function _getSalespersonApi()
|
38 |
-
{
|
39 |
-
if(!$this->helper)
|
40 |
-
$this->helper = $this->helper('salesperson');
|
41 |
-
|
42 |
-
return $this->helper->getSalespersonApi();
|
43 |
-
}
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
)
|
76 |
-
$
|
77 |
-
|
78 |
-
|
79 |
-
$
|
80 |
-
|
81 |
-
$
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
$
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
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 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
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 |
-
return $this
|
175 |
-
}
|
176 |
-
|
177 |
-
/**
|
178 |
-
*
|
179 |
-
*
|
180 |
-
* @return
|
181 |
-
*/
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
if(
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
return $
|
235 |
-
}
|
236 |
-
return
|
237 |
-
}
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
}
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Block_Result extends Mage_Core_Block_Template
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Catalog Product collection
|
14 |
+
*
|
15 |
+
* @var Mage_CatalogSearch_Model_Mysql4_Fulltext_Collection
|
16 |
+
*/
|
17 |
+
protected $_productCollection;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Retrieve salesperson session
|
21 |
+
*
|
22 |
+
* @return Mage_Catalog_Model_Session
|
23 |
+
*/
|
24 |
+
|
25 |
+
var $helper;
|
26 |
+
|
27 |
+
protected function _getSession()
|
28 |
+
{
|
29 |
+
return Mage::getSingleton('salesperson/session');
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Retrieve QwiserSearchApi model object
|
34 |
+
*
|
35 |
+
* @return Mage_CatalogSearch_Model_Query
|
36 |
+
*/
|
37 |
+
protected function _getSalespersonApi()
|
38 |
+
{
|
39 |
+
if(!$this->helper)
|
40 |
+
$this->helper = $this->helper('salesperson');
|
41 |
+
|
42 |
+
return $this->helper->getSalespersonApi();
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Prepare layout
|
47 |
+
*
|
48 |
+
* @return Mage_CatalogSearch_Block_Result
|
49 |
+
*/
|
50 |
+
protected function _prepareLayout()
|
51 |
+
{
|
52 |
+
// add Home breadcrumb
|
53 |
+
$breadcrumbs = $this->getLayout()->getBlock('breadcrumbs');
|
54 |
+
if ($breadcrumbs) {
|
55 |
+
$title = "";
|
56 |
+
if($this->helper('salesperson')->getQueryText()!='') $title = $this->__("Search results for: '%s'", $this->helper('salesperson')->getQueryText());
|
57 |
+
$breadcrumbs->addCrumb('home', array(
|
58 |
+
'label' => $this->__('Home'),
|
59 |
+
'title' => $this->__('Go to Home Page'),
|
60 |
+
'link' => Mage::getBaseUrl()
|
61 |
+
));
|
62 |
+
if(Mage::getStoreConfigFlag('salesperson/display_settings/breadcrumbs') && isset($this->_getSalespersonApi()->results) && count($this->_getSalespersonApi()->results->SearchPath->Items) > 0){
|
63 |
+
$query = $this->helper('salesperson')->getQueryText();
|
64 |
+
if(! empty($query)) {
|
65 |
+
$breadcrumbs->addCrumb('search', array(
|
66 |
+
'label' => $title,
|
67 |
+
'title' => $title,
|
68 |
+
'link' => Mage::Helper('salesperson')->getResultUrl($this->helper('salesperson')->getQueryText())
|
69 |
+
));
|
70 |
+
}
|
71 |
+
|
72 |
+
$searchPathEntry = 0;
|
73 |
+
$paths = array();
|
74 |
+
$totalEntries = $this->_getSalespersonApi()->results->SearchPath->Count;
|
75 |
+
$searchPaths = $this->_getSalespersonApi()->results->SearchPath->Items;
|
76 |
+
for($i = 0; $i < $totalEntries; $i++){
|
77 |
+
$paths[] = $searchPaths[($totalEntries - 1) - $i]->Answers->Items[0]->Id;
|
78 |
+
}
|
79 |
+
array_pop($paths);
|
80 |
+
foreach($searchPaths as $key => $searchPath){
|
81 |
+
$crumb = array(
|
82 |
+
'label' => $searchPath->Answers->Items[0]->Text,
|
83 |
+
'title' => $searchPath->Answers->Items[0]->Text,
|
84 |
+
);
|
85 |
+
$searchPathEntry++;
|
86 |
+
if($searchPathEntry < $totalEntries){
|
87 |
+
$crumb['link'] = Mage::getBlockSingleton('salesperson/layer_state')->getRemoveAnswersFromBredcrumbsUrl($paths);
|
88 |
+
array_pop($paths);
|
89 |
+
}
|
90 |
+
|
91 |
+
$breadcrumbs->addCrumb($searchPath->Answers->Items[0]->Id, $crumb);
|
92 |
+
}
|
93 |
+
}
|
94 |
+
else {
|
95 |
+
$breadcrumbs->addCrumb('search', array(
|
96 |
+
'label' => $title,
|
97 |
+
'title' => $title,
|
98 |
+
));
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
// modify page title
|
103 |
+
$pageTitle = $this->__("Search results for: '%s'", $this->helper('salesperson')->getEscapedQueryText());
|
104 |
+
if($this->helper('salesperson')->getEscapedQueryText()=='') $pageTitle = $this->__("Search results");
|
105 |
+
$this->getLayout()->getBlock('head')->setTitle($pageTitle);
|
106 |
+
|
107 |
+
Mage::Helper('salesperson')->setRelatedSearches($this->hasRelatedSearches());
|
108 |
+
|
109 |
+
/*if ($headBlock = $this->getLayout()->getBlock('head')) {
|
110 |
+
$category = $this->getCurrentCategory();
|
111 |
+
if ($title = $category->getMetaTitle()) {
|
112 |
+
$headBlock->setTitle($title);
|
113 |
+
}
|
114 |
+
if ($description = $category->getMetaDescription()) {
|
115 |
+
$headBlock->setDescription($description);
|
116 |
+
}
|
117 |
+
if ($keywords = $category->getMetaKeywords()) {
|
118 |
+
$headBlock->setKeywords($keywords);
|
119 |
+
}
|
120 |
+
if ($this->helper('catalog/category')->canUseCanonicalTag()) {
|
121 |
+
$headBlock->addLinkRel('canonical', $category->getUrl());
|
122 |
+
}
|
123 |
+
|
124 |
+
if ($this->IsRssCatalogEnable() && $this->IsTopCategory()) {
|
125 |
+
$title = $this->helper('rss')->__('%s RSS Feed',$this->getCurrentCategory()->getName());
|
126 |
+
$headBlock->addItem('rss', $this->getRssLink(), 'title="'.$title.'"');
|
127 |
+
}
|
128 |
+
}*/
|
129 |
+
|
130 |
+
return parent::_prepareLayout();
|
131 |
+
}
|
132 |
+
|
133 |
+
protected function getCurrentCategory(){
|
134 |
+
$q = Mage::helper('salesperson')->getQueryText();
|
135 |
+
|
136 |
+
$categories = Mage::getModel('catalog/category')
|
137 |
+
->getCollection()
|
138 |
+
->addAttributeToFilter("name",$q)
|
139 |
+
->addIsActiveFilter();
|
140 |
+
|
141 |
+
return reset($categories);
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Retrieve search list toolbar block
|
146 |
+
*
|
147 |
+
* @return Mage_Catalog_Block_Product_List
|
148 |
+
*/
|
149 |
+
public function getListBlock()
|
150 |
+
{
|
151 |
+
return $this->getChild('search_result_list');
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Set search available list orders
|
156 |
+
*
|
157 |
+
* @return Mage_CatalogSearch_Block_Result
|
158 |
+
*/
|
159 |
+
public function setListOrders() {
|
160 |
+
return $this;
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Set available view mode
|
165 |
+
*
|
166 |
+
* @return Mage_CatalogSearch_Block_Result
|
167 |
+
*/
|
168 |
+
public function setListModes() {
|
169 |
+
$this->getListBlock()
|
170 |
+
->setModes(array(
|
171 |
+
'grid' => $this->__('Grid'),
|
172 |
+
'list' => $this->__('List'))
|
173 |
+
);
|
174 |
+
return $this;
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Set Search Result collection
|
179 |
+
*
|
180 |
+
* @return Mage_CatalogSearch_Block_Result
|
181 |
+
*/
|
182 |
+
public function setListCollection() {
|
183 |
+
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Retrieve Search result list HTML output
|
188 |
+
*
|
189 |
+
* @return string
|
190 |
+
*/
|
191 |
+
public function getProductListHtml()
|
192 |
+
{
|
193 |
+
|
194 |
+
return $this->getChildHtml('search_result_list');
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Retrieve loaded category collection
|
199 |
+
*
|
200 |
+
* @return Celebros_Helper_QwiserApi_QwiserProduct
|
201 |
+
*/
|
202 |
+
protected function getProductCollection()
|
203 |
+
{
|
204 |
+
if (is_null($this->_productCollection)) {
|
205 |
+
$query = $this->_getSalespersonApi();
|
206 |
+
if(count($query->qsr->Products)>0){
|
207 |
+
$this->_productCollection = $query->qsr->Products->Items;
|
208 |
+
}
|
209 |
+
}
|
210 |
+
|
211 |
+
return $this->_productCollection;
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Retrieve search result count
|
216 |
+
*
|
217 |
+
* @return string
|
218 |
+
*/
|
219 |
+
public function getResultCount()
|
220 |
+
{
|
221 |
+
if($this->_getSalespersonApi()->results){
|
222 |
+
return $this->_getSalespersonApi()->results->GetRelevantProductsCount();
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Retrieve no Minimum query length Text
|
228 |
+
*
|
229 |
+
* @return string
|
230 |
+
*/
|
231 |
+
public function getNoMinQueryLengthText()
|
232 |
+
{
|
233 |
+
if (Mage::helper('salesperson')->isMinQueryLength()) {
|
234 |
+
return Mage::helper('salesperson')->__('Minimum Search query length is %s', $this->_getSalespersonApi()->getMinQueryLength());
|
235 |
+
}
|
236 |
+
return $this->_getData('no_result_text');
|
237 |
+
}
|
238 |
+
|
239 |
+
|
240 |
+
public function hasRelatedSearches(){
|
241 |
+
if(!empty($this->_getSalespersonApi()->results->RelatedSearches)){
|
242 |
+
$relatedSearches = $this->_getSalespersonApi()->results->RelatedSearches;
|
243 |
+
$out = array();
|
244 |
+
foreach ($relatedSearches as $key => $relatedSearch){
|
245 |
+
$urlParams = array();
|
246 |
+
$urlParams['_current'] = false;
|
247 |
+
$urlParams['_escape'] = true;
|
248 |
+
$urlParams['_use_rewrite'] = false;
|
249 |
+
$urlParams['_query'] = array(
|
250 |
+
'q' => $relatedSearch,
|
251 |
+
);
|
252 |
+
$out[$relatedSearch] = Mage::getUrl('*/*/index', $urlParams);
|
253 |
+
}
|
254 |
+
return $out;
|
255 |
+
}
|
256 |
+
return false;
|
257 |
+
}
|
258 |
+
|
259 |
+
public function getBannerImage(){
|
260 |
+
return $this->bannerImage != '' ? $this->bannerImage : false;
|
261 |
+
}
|
262 |
+
|
263 |
+
public function getCustomMessage(){
|
264 |
+
return $this->customMessage != '' ? $this->customMessage : false;
|
265 |
+
}
|
266 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Block/Review/Helper.php
RENAMED
@@ -1,52 +1,52 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Block_Review_Helper extends Mage_Review_Block_Helper
|
11 |
-
{
|
12 |
-
protected $_availableTemplates = array(
|
13 |
-
'default' => 'review/helper/summary.phtml',
|
14 |
-
'short' => 'review/helper/summary_short.phtml'
|
15 |
-
);
|
16 |
-
|
17 |
-
public function getSummaryHtml($product, $templateType, $displayIfNoReviews)
|
18 |
-
{
|
19 |
-
// pick template among available
|
20 |
-
if (empty($this->_availableTemplates[$templateType])) {
|
21 |
-
$templateType = 'default';
|
22 |
-
}
|
23 |
-
$this->setTemplate($this->_availableTemplates[$templateType]);
|
24 |
-
|
25 |
-
$this->setDisplayIfEmpty($displayIfNoReviews);
|
26 |
-
|
27 |
-
$this->setProduct($product);
|
28 |
-
|
29 |
-
return $this->toHtml();
|
30 |
-
}
|
31 |
-
|
32 |
-
public function getRatingSummary()
|
33 |
-
{
|
34 |
-
return $this->getProduct()->Field[$this->helper('salesperson/mapping')->getMapping('
|
35 |
-
}
|
36 |
-
|
37 |
-
public function getReviewsCount()
|
38 |
-
{
|
39 |
-
return key_exists(
|
40 |
-
$this->helper('salesperson/mapping')->getMapping('
|
41 |
-
,$this->getProduct()->Field
|
42 |
-
)
|
43 |
-
&& (int)$this->getProduct()->Field[$this->helper('salesperson/mapping')->getMapping('
|
44 |
-
}
|
45 |
-
|
46 |
-
public function getReviewsUrl()
|
47 |
-
{
|
48 |
-
return Mage::getUrl('review/product/list', array(
|
49 |
-
'id' => $this->getProduct()->Field[$this->helper('salesperson/mapping')->getMapping('id')],
|
50 |
-
));
|
51 |
-
}
|
52 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Block_Review_Helper extends Mage_Review_Block_Helper
|
11 |
+
{
|
12 |
+
protected $_availableTemplates = array(
|
13 |
+
'default' => 'review/helper/summary.phtml',
|
14 |
+
'short' => 'review/helper/summary_short.phtml'
|
15 |
+
);
|
16 |
+
|
17 |
+
public function getSummaryHtml($product, $templateType, $displayIfNoReviews)
|
18 |
+
{
|
19 |
+
// pick template among available
|
20 |
+
if (empty($this->_availableTemplates[$templateType])) {
|
21 |
+
$templateType = 'default';
|
22 |
+
}
|
23 |
+
$this->setTemplate($this->_availableTemplates[$templateType]);
|
24 |
+
|
25 |
+
$this->setDisplayIfEmpty($displayIfNoReviews);
|
26 |
+
|
27 |
+
$this->setProduct($product);
|
28 |
+
|
29 |
+
return $this->toHtml();
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getRatingSummary()
|
33 |
+
{
|
34 |
+
return $this->getProduct()->Field[$this->helper('salesperson/mapping')->getMapping('rating_summary')];
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getReviewsCount()
|
38 |
+
{
|
39 |
+
return key_exists(
|
40 |
+
$this->helper('salesperson/mapping')->getMapping('reviews_count')
|
41 |
+
,$this->getProduct()->Field
|
42 |
+
)
|
43 |
+
&& (int)$this->getProduct()->Field[$this->helper('salesperson/mapping')->getMapping('reviews_count')] > 0;
|
44 |
+
}
|
45 |
+
|
46 |
+
public function getReviewsUrl()
|
47 |
+
{
|
48 |
+
return Mage::getUrl('review/product/list', array(
|
49 |
+
'id' => $this->getProduct()->Field[$this->helper('salesperson/mapping')->getMapping('id')],
|
50 |
+
));
|
51 |
+
}
|
52 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Block/System/Convert/Profile/Edit/Tab/Run.php
RENAMED
@@ -1,59 +1,74 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento Enterprise Edition
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Magento Enterprise Edition License
|
8 |
-
* that is bundled with this package in the file LICENSE_EE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://www.magentocommerce.com/license/enterprise-edition
|
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) 2010 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://www.magentocommerce.com/license/enterprise-edition
|
25 |
-
*/
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Convert profile edit tab
|
29 |
-
*
|
30 |
-
* @category Mage
|
31 |
-
* @package Mage_Adminhtml
|
32 |
-
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
-
*/
|
34 |
-
class Celebros_Salesperson_Block_System_Convert_Profile_Edit_Tab_Run extends Mage_Adminhtml_Block_System_Convert_Profile_Edit_Tab_Run
|
35 |
-
{
|
36 |
-
|
37 |
-
{
|
38 |
-
$profile_name=Mage::registry('current_convert_profile')->getName();
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
->
|
53 |
-
->
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento Enterprise Edition
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Magento Enterprise Edition License
|
8 |
+
* that is bundled with this package in the file LICENSE_EE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.magentocommerce.com/license/enterprise-edition
|
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) 2010 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://www.magentocommerce.com/license/enterprise-edition
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Convert profile edit tab
|
29 |
+
*
|
30 |
+
* @category Mage
|
31 |
+
* @package Mage_Adminhtml
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
class Celebros_Salesperson_Block_System_Convert_Profile_Edit_Tab_Run extends Mage_Adminhtml_Block_System_Convert_Profile_Edit_Tab_Run
|
35 |
+
{
|
36 |
+
public function getRunButtonHtml()
|
37 |
+
{
|
38 |
+
$profile_name=Mage::registry('current_convert_profile')->getName();
|
39 |
+
|
40 |
+
|
41 |
+
$html = '';
|
42 |
+
if ($profile_name == "Salesperson Exporter")
|
43 |
+
{
|
44 |
+
$export_URL = Mage::helper("adminhtml")->getUrl
|
45 |
+
("salesperson_admin/export/export_celebros/");
|
46 |
+
|
47 |
+
$schedule_URL = Mage::helper("adminhtml")->getUrl
|
48 |
+
("salesperson_admin/export/schedule_export/");
|
49 |
+
|
50 |
+
|
51 |
+
$html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setType('button')
|
52 |
+
->setLabel($this->__('Celebros Export Products'))
|
53 |
+
->setOnClick('window.open(\''.$export_URL.'\')')
|
54 |
+
->toHtml();
|
55 |
+
|
56 |
+
$html .= '<br/><br/>';
|
57 |
+
$html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setType('button')
|
58 |
+
->setLabel($this->__('Celebros Schedule Cron Export'))
|
59 |
+
->setOnClick('window.open(\''.$schedule_URL.'\')')
|
60 |
+
->toHtml();
|
61 |
+
}
|
62 |
+
else
|
63 |
+
{
|
64 |
+
/* old button*/
|
65 |
+
$html.=$this->getLayout()->createBlock('adminhtml/widget_button')->setType('button')
|
66 |
+
->setClass('save')->setLabel($this->__('Run Profile in Popup'))
|
67 |
+
->setOnClick('runProfile(true)')
|
68 |
+
->toHtml();
|
69 |
+
/*end old button*/
|
70 |
+
}
|
71 |
+
return $html;
|
72 |
+
|
73 |
+
}
|
74 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Helper/Checkout/Cart.php
RENAMED
@@ -1,46 +1,46 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Helper_Checkout_Cart extends Mage_Core_Helper_Url
|
11 |
-
{
|
12 |
-
/**
|
13 |
-
* Retrieve url for add product to cart
|
14 |
-
*
|
15 |
-
* @param Mage_Catalog_Model_Product $product
|
16 |
-
* @return string
|
17 |
-
*/
|
18 |
-
public function getAddUrl($product, $additional = array())
|
19 |
-
{
|
20 |
-
$continueUrl = Mage::helper('core')->urlEncode($this->getCurrentUrl());
|
21 |
-
$urlParamName = Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED;
|
22 |
-
|
23 |
-
if(key_exists(Mage::Helper('salesperson/mapping')->getMapping('id'), $product->Field)){
|
24 |
-
$routeParams = array(
|
25 |
-
$urlParamName => $continueUrl,
|
26 |
-
'product' => $product->Field[Mage::Helper('salesperson/mapping')->getMapping('id')]
|
27 |
-
);
|
28 |
-
}
|
29 |
-
|
30 |
-
if (!empty($additional)) {
|
31 |
-
$routeParams = array_merge($routeParams, $additional);
|
32 |
-
}
|
33 |
-
|
34 |
-
// if ($product->hasUrlDataObject()) {
|
35 |
-
// $routeParams['_store'] = $product->getUrlDataObject()->getStoreId();
|
36 |
-
// $routeParams['_store_to_url'] = true;
|
37 |
-
// }
|
38 |
-
|
39 |
-
if ($this->_getRequest()->getRouteName() == 'checkout'
|
40 |
-
&& $this->_getRequest()->getControllerName() == 'cart') {
|
41 |
-
$routeParams['in_cart'] = 1;
|
42 |
-
}
|
43 |
-
|
44 |
-
return $this->_getUrl('checkout/cart/add', $routeParams);
|
45 |
-
}
|
46 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Helper_Checkout_Cart extends Mage_Core_Helper_Url
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Retrieve url for add product to cart
|
14 |
+
*
|
15 |
+
* @param Mage_Catalog_Model_Product $product
|
16 |
+
* @return string
|
17 |
+
*/
|
18 |
+
public function getAddUrl($product, $additional = array())
|
19 |
+
{
|
20 |
+
$continueUrl = Mage::helper('core')->urlEncode($this->getCurrentUrl());
|
21 |
+
$urlParamName = Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED;
|
22 |
+
|
23 |
+
if(key_exists(Mage::Helper('salesperson/mapping')->getMapping('id'), $product->Field)){
|
24 |
+
$routeParams = array(
|
25 |
+
$urlParamName => $continueUrl,
|
26 |
+
'product' => $product->Field[Mage::Helper('salesperson/mapping')->getMapping('id')]
|
27 |
+
);
|
28 |
+
}
|
29 |
+
|
30 |
+
if (!empty($additional)) {
|
31 |
+
$routeParams = array_merge($routeParams, $additional);
|
32 |
+
}
|
33 |
+
|
34 |
+
// if ($product->hasUrlDataObject()) {
|
35 |
+
// $routeParams['_store'] = $product->getUrlDataObject()->getStoreId();
|
36 |
+
// $routeParams['_store_to_url'] = true;
|
37 |
+
// }
|
38 |
+
|
39 |
+
if ($this->_getRequest()->getRouteName() == 'checkout'
|
40 |
+
&& $this->_getRequest()->getControllerName() == 'cart') {
|
41 |
+
$routeParams['in_cart'] = 1;
|
42 |
+
}
|
43 |
+
|
44 |
+
return $this->_getUrl('checkout/cart/add', $routeParams);
|
45 |
+
}
|
46 |
+
}
|
app/code/community/Celebros/Salesperson/Helper/Data.php
ADDED
@@ -0,0 +1,723 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Helper_Data extends Mage_CatalogSearch_Helper_Data
|
11 |
+
{
|
12 |
+
const QUERY_VAR_NAME = 'q';
|
13 |
+
const MAX_QUERY_LEN = 200;
|
14 |
+
const ICONV_CHARSET = 'UTF-8';
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Query object
|
18 |
+
*
|
19 |
+
* @var Mage_CatalogSearch_Model_Query
|
20 |
+
*/
|
21 |
+
protected $_query;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* QwiserSearchApi object
|
25 |
+
*
|
26 |
+
* @var Mage_CatalogSearch_Model_Query
|
27 |
+
*/
|
28 |
+
protected $_api;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Query string
|
32 |
+
*
|
33 |
+
* @var string
|
34 |
+
*/
|
35 |
+
protected $_queryText;
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Note messages
|
39 |
+
*
|
40 |
+
* @var array
|
41 |
+
*/
|
42 |
+
protected $_messages = array();
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Is a maximum length cut
|
46 |
+
*
|
47 |
+
* @var bool
|
48 |
+
*/
|
49 |
+
protected $_isMaxLength = false;
|
50 |
+
|
51 |
+
protected $_gmessages;
|
52 |
+
|
53 |
+
protected $_bannerImage;
|
54 |
+
|
55 |
+
protected $_bannerFlash;
|
56 |
+
|
57 |
+
protected $_customMessage;
|
58 |
+
|
59 |
+
protected $_relatedSearches;
|
60 |
+
|
61 |
+
protected $_sortingFieldsSettings;
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Retrieve salesperson session
|
65 |
+
*
|
66 |
+
* @return Mage_Catalog_Model_Session
|
67 |
+
*/
|
68 |
+
protected function _getSession()
|
69 |
+
{
|
70 |
+
return Mage::getSingleton('salesperson/session');
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Retrieve search query parameter name
|
75 |
+
*
|
76 |
+
* @return string
|
77 |
+
*/
|
78 |
+
public function getQueryParamName()
|
79 |
+
{
|
80 |
+
return self::QUERY_VAR_NAME;
|
81 |
+
}
|
82 |
+
|
83 |
+
public function getSalespersonApi()
|
84 |
+
{
|
85 |
+
if (!$this->_api) {
|
86 |
+
$this->_api = Mage::getModel('salesperson/salespersonSearchApi');
|
87 |
+
}
|
88 |
+
return $this->_api;
|
89 |
+
}
|
90 |
+
|
91 |
+
public function getSalespersonCrossSellApi()
|
92 |
+
{
|
93 |
+
return Mage::getModel('salesperson/salespersonCrossSellApi');
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
*
|
98 |
+
* Clean non UTF-8 characters
|
99 |
+
*
|
100 |
+
* @param string $string
|
101 |
+
* @return string
|
102 |
+
* @author Sveta Oksen copied from Magento v1.5
|
103 |
+
* @since 31/03/2011
|
104 |
+
*/
|
105 |
+
public function cleanString($string)
|
106 |
+
{
|
107 |
+
return '"libiconv"' == ICONV_IMPL ? iconv(self::ICONV_CHARSET, self::ICONV_CHARSET . '//IGNORE', $string) : $string;
|
108 |
+
}
|
109 |
+
|
110 |
+
public function getQueryText()
|
111 |
+
{
|
112 |
+
if (is_null($this->_queryText)) {
|
113 |
+
$this->_queryText = $this->_getRequest()->getParam($this->getQueryParamName());
|
114 |
+
if ($this->_queryText === null) {
|
115 |
+
$this->_queryText = '';
|
116 |
+
} else {
|
117 |
+
if (is_array($this->_queryText)) {
|
118 |
+
$this->_queryText = null;
|
119 |
+
}
|
120 |
+
$this->_queryText = trim($this->_queryText);
|
121 |
+
$this->_queryText = $this->cleanString($this->_queryText);
|
122 |
+
|
123 |
+
if (Mage::helper('core/string')->strlen($this->_queryText) > $this->getMaxQueryLength()) {
|
124 |
+
$this->_queryText = Mage::helper('core/string')->substr(
|
125 |
+
$this->_queryText,
|
126 |
+
0,
|
127 |
+
$this->getMaxQueryLength()
|
128 |
+
);
|
129 |
+
$this->_isMaxLength = true;
|
130 |
+
}
|
131 |
+
}
|
132 |
+
}
|
133 |
+
return $this->_queryText;
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Retrieve HTML escaped search query
|
138 |
+
*
|
139 |
+
* @return string
|
140 |
+
*/
|
141 |
+
public function getEscapedQueryText()
|
142 |
+
{
|
143 |
+
return $this->htmlEscape($this->getQueryText());
|
144 |
+
}
|
145 |
+
|
146 |
+
public function getDefaultPageSize(){
|
147 |
+
if (substr(Mage::getStoreConfig('catalog/frontend/list_mode'),0,4) == 'grid'){
|
148 |
+
return Mage::getStoreConfig('catalog/frontend/grid_per_page');
|
149 |
+
}
|
150 |
+
else {
|
151 |
+
return Mage::getStoreConfig('catalog/frontend/list_per_page');
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
public function getAllPageSize(){
|
156 |
+
return Mage::getStoreConfig('salesperson/display_settings/all_per_page');
|
157 |
+
}
|
158 |
+
|
159 |
+
public function getStoreSearchProfile(){
|
160 |
+
return Mage::getStoreConfig('salesperson/display_settings/search_profile');
|
161 |
+
}
|
162 |
+
|
163 |
+
public function getStoreGiftfinderProfile(){
|
164 |
+
return Mage::getStoreConfig('salesperson/giftfinder_settings/giftfinder_profile');
|
165 |
+
}
|
166 |
+
|
167 |
+
public function getGiftfinderTemplate(){
|
168 |
+
return Mage::getStoreConfig('salesperson/giftfinder_settings/giftfinder_type');
|
169 |
+
}
|
170 |
+
|
171 |
+
public function isGiftfinderStandardTemplate(){
|
172 |
+
return ($this->getGiftfinderTemplate()=='salesperson/giftfinder/view.phtml');
|
173 |
+
}
|
174 |
+
|
175 |
+
public function isGiftfinderDynamicAjaxTemplate(){
|
176 |
+
return ($this->getGiftfinderTemplate()=='salesperson/giftfinder/viewajaxdynamic.phtml');
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Is a minimum query length
|
181 |
+
*
|
182 |
+
* @return bool
|
183 |
+
*/
|
184 |
+
public function isMinQueryLength()
|
185 |
+
{
|
186 |
+
if (Mage::helper('core/string')->strlen($this->getQueryText()) < $this->getMinQueryLength()) {
|
187 |
+
return true;
|
188 |
+
}
|
189 |
+
return false;
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Retrieve minimum query length
|
194 |
+
*
|
195 |
+
* @param mixed $store
|
196 |
+
* @return int
|
197 |
+
*/
|
198 |
+
public function getMinQueryLength($store = null)
|
199 |
+
{
|
200 |
+
return Mage::getStoreConfig(Mage_CatalogSearch_Model_Query::XML_PATH_MIN_QUERY_LENGTH, $store);
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Retrieve result page url and set "secure" param to avoid confirm
|
205 |
+
* message when we submit form from secure page to unsecure
|
206 |
+
*
|
207 |
+
* @param string $query
|
208 |
+
* @return string
|
209 |
+
*/
|
210 |
+
public function getResultUrl($query = null, $bAddIndexSuffix = false, $bRelativePath = false)
|
211 |
+
{
|
212 |
+
$store_id = Mage::app()->getStore()->getId();
|
213 |
+
$module_disabled = Mage::app()->getStore($store_id)->getConfig('advanced/modules_disable_output/Celebros_Salesperson');
|
214 |
+
|
215 |
+
$helperPath = $module_disabled ? 'catalogsearch/result' : 'salesperson/result';
|
216 |
+
|
217 |
+
if($bAddIndexSuffix) $helperPath .= '/index/';
|
218 |
+
|
219 |
+
$relativePath = $helperPath . '?' . self::QUERY_VAR_NAME . '=' . urlencode($query);
|
220 |
+
$absolutePath = $this->_getUrl($helperPath, array(
|
221 |
+
'_query' => array(self::QUERY_VAR_NAME => $query),
|
222 |
+
'_secure' => Mage::app()->getFrontController()->getRequest()->isSecure()
|
223 |
+
));
|
224 |
+
|
225 |
+
return $bRelativePath ? $relativePath : $absolutePath;
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Prepare save query for result
|
230 |
+
*
|
231 |
+
* @return Mage_CatalogSearch_Model_Query
|
232 |
+
*/
|
233 |
+
public function prepare(Mage_CatalogSearch_Model_Query $query, $num_result)
|
234 |
+
{
|
235 |
+
if (!$query->getId()) {
|
236 |
+
$query->setIsActive(0);
|
237 |
+
$query->setIsProcessed(0);
|
238 |
+
$query->setNumResults($num_result);
|
239 |
+
$query->save();
|
240 |
+
$query->setIsActive(1);
|
241 |
+
}
|
242 |
+
|
243 |
+
return $this;
|
244 |
+
}
|
245 |
+
|
246 |
+
/**
|
247 |
+
* Retrieve suggest url
|
248 |
+
*
|
249 |
+
* @return string
|
250 |
+
*/
|
251 |
+
public function getSuggestUrl()
|
252 |
+
{
|
253 |
+
return $this->_getUrl('catalogsearch/ajax/suggest');
|
254 |
+
}
|
255 |
+
|
256 |
+
/**
|
257 |
+
* Retrieve search term url
|
258 |
+
*
|
259 |
+
* @return string
|
260 |
+
*/
|
261 |
+
public function getSearchTermUrl()
|
262 |
+
{
|
263 |
+
return $this->_getUrl('catalogsearch/term/popular');
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* Retrieve advanced search URL
|
268 |
+
*
|
269 |
+
* @return string
|
270 |
+
*/
|
271 |
+
public function getAdvancedSearchUrl()
|
272 |
+
{
|
273 |
+
return $this->_getUrl('catalogsearch/advanced');
|
274 |
+
}
|
275 |
+
|
276 |
+
/**
|
277 |
+
* Retrieve maximum query words count for like search
|
278 |
+
*
|
279 |
+
* @param mixed $store
|
280 |
+
* @return int
|
281 |
+
*/
|
282 |
+
public function getMaxQueryWords($store = null)
|
283 |
+
{
|
284 |
+
return Mage::getStoreConfig(Mage_CatalogSearch_Model_Query::XML_PATH_MAX_QUERY_WORDS, $store);
|
285 |
+
}
|
286 |
+
|
287 |
+
/**
|
288 |
+
* Retrieve maximum query length
|
289 |
+
*
|
290 |
+
* @param mixed $store
|
291 |
+
* @return int
|
292 |
+
*/
|
293 |
+
public function getMaxQueryLength($store = null)
|
294 |
+
{
|
295 |
+
return Mage::getStoreConfig(Mage_CatalogSearch_Model_Query::XML_PATH_MAX_QUERY_LENGTH, $store);
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* Add Note message
|
300 |
+
*
|
301 |
+
* @param string $message
|
302 |
+
* @return Mage_CatalogSearch_Helper_Data
|
303 |
+
*/
|
304 |
+
public function addNoteMessage($message)
|
305 |
+
{
|
306 |
+
$this->_messages[] = $message;
|
307 |
+
return $this;
|
308 |
+
}
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Set Note messages
|
312 |
+
*
|
313 |
+
* @param array $messages
|
314 |
+
* @return Mage_CatalogSearch_Helper_Data
|
315 |
+
*/
|
316 |
+
public function setNoteMessages(array $messages)
|
317 |
+
{
|
318 |
+
$this->_messages = $messages;
|
319 |
+
return $this;
|
320 |
+
}
|
321 |
+
|
322 |
+
/**
|
323 |
+
* Get the recommended attribute from salesperson API and add it to NoteMessages
|
324 |
+
*
|
325 |
+
*/
|
326 |
+
public function getRecommendedMessages(){
|
327 |
+
if($this->getSalespersonApi()->results->GetRecommendedMessage() != ''){
|
328 |
+
$message = preg_replace('/#%/', '', $this->getSalespersonApi()->results->GetRecommendedMessage());
|
329 |
+
$message = preg_replace('/%#/', '', $message);
|
330 |
+
$this->addNoteMessage($this->__($message));
|
331 |
+
}
|
332 |
+
}
|
333 |
+
|
334 |
+
/**
|
335 |
+
* Retrieve Current Note messages
|
336 |
+
*
|
337 |
+
* @return array
|
338 |
+
*/
|
339 |
+
public function getNoteMessages()
|
340 |
+
{
|
341 |
+
return $this->_messages;
|
342 |
+
}
|
343 |
+
|
344 |
+
/**
|
345 |
+
* Check query of a warnings
|
346 |
+
*
|
347 |
+
* @param mixed $store
|
348 |
+
* @return Celebros_Salesperson_Helper_Data
|
349 |
+
*/
|
350 |
+
public function checkNotes($store = null)
|
351 |
+
{
|
352 |
+
if ($this->_isMaxLength) {
|
353 |
+
$this->addNoteMessage($this->__('Maximum Search query length is %s. Your query was cut.', $this->getMaxQueryLength()));
|
354 |
+
}
|
355 |
+
|
356 |
+
$stringHelper = Mage::helper('core/string');
|
357 |
+
/* @var $stringHelper Mage_Core_Helper_String */
|
358 |
+
|
359 |
+
}
|
360 |
+
|
361 |
+
|
362 |
+
public function getNonLeadQuestionsPosition(){
|
363 |
+
if (Mage::getStoreConfig('salesperson/display_settings/display_non_lead_top'))
|
364 |
+
return 'top';
|
365 |
+
elseif (Mage::getStoreConfig('salesperson/display_settings/display_non_lead_left'))
|
366 |
+
return 'left';
|
367 |
+
elseif (Mage::getStoreConfig('salesperson/display_settings/display_non_lead_right'))
|
368 |
+
return 'right';
|
369 |
+
}
|
370 |
+
public function goToProductOnOneResult(){
|
371 |
+
return Mage::getStoreConfigFlag('salesperson/display_settings/go_to_product_on_one_result');
|
372 |
+
}
|
373 |
+
|
374 |
+
public function getResultCount()
|
375 |
+
{
|
376 |
+
if($this->getSalespersonApi()->results){
|
377 |
+
return $this->getSalespersonApi()->results->GetRelevantProductsCount();
|
378 |
+
}
|
379 |
+
}
|
380 |
+
|
381 |
+
public function getNoteHelperMessages() {
|
382 |
+
return $this->_gmessages;
|
383 |
+
}
|
384 |
+
|
385 |
+
public function setNoteHelperMessages($messages) {
|
386 |
+
$this->_gmessages = $messages;
|
387 |
+
}
|
388 |
+
|
389 |
+
public function setRelatedSearches($relatedSearches){
|
390 |
+
return $this->_relatedSearches = $relatedSearches;
|
391 |
+
}
|
392 |
+
|
393 |
+
public function setBannerImage($img){
|
394 |
+
$this->_bannerImage = $img;
|
395 |
+
}
|
396 |
+
|
397 |
+
public function setBannerFlash($url){
|
398 |
+
$this->_bannerFlash = $url;
|
399 |
+
}
|
400 |
+
|
401 |
+
public function setCustomMessage($msg){
|
402 |
+
$this->_customMessage = $msg;
|
403 |
+
}
|
404 |
+
|
405 |
+
public function getBannerImage(){
|
406 |
+
return $this->_bannerImage != '' ? $this->_bannerImage : false;
|
407 |
+
}
|
408 |
+
|
409 |
+
public function getBannerFlash(){
|
410 |
+
return $this->_bannerFlash != '' ? $this->_bannerFlash : false;
|
411 |
+
}
|
412 |
+
|
413 |
+
public function getCustomMessage(){
|
414 |
+
return $this->_customMessage != '' ? $this->_customMessage : false;
|
415 |
+
}
|
416 |
+
|
417 |
+
public function getRelatedSearches(){
|
418 |
+
return $this->_relatedSearches;
|
419 |
+
}
|
420 |
+
|
421 |
+
public function isAutoComplete() {
|
422 |
+
$res = $this->getACFrontServerAddress()!="" &&
|
423 |
+
$this->getACScriptServerAddress()!="" &&
|
424 |
+
$this->getACCustomerName()!="";
|
425 |
+
return $res;
|
426 |
+
}
|
427 |
+
|
428 |
+
public function getSiteKey() {
|
429 |
+
return Mage::getStoreConfig('salesperson/general_settings/sitekey');
|
430 |
+
}
|
431 |
+
|
432 |
+
public function getACFrontServerAddress() {
|
433 |
+
return Mage::getStoreConfig('salesperson/autocomplete_settings/ac_frontend_address');
|
434 |
+
}
|
435 |
+
|
436 |
+
public function getACScriptServerAddress() {
|
437 |
+
return Mage::getStoreConfig('salesperson/autocomplete_settings/ac_scriptserver_address');
|
438 |
+
}
|
439 |
+
|
440 |
+
public function getACCustomerName() {
|
441 |
+
return Mage::getStoreConfig('salesperson/autocomplete_settings/ac_customer_name');
|
442 |
+
}
|
443 |
+
|
444 |
+
public function is_EE() {
|
445 |
+
|
446 |
+
/*
|
447 |
+
* determine Magento Edition
|
448 |
+
*/
|
449 |
+
return file_exists('LICENSE_EE.txt');
|
450 |
+
}
|
451 |
+
|
452 |
+
public function is_PE() {
|
453 |
+
return file_exists('LICENSE_PRO.html');
|
454 |
+
}
|
455 |
+
|
456 |
+
public function is_CE() {
|
457 |
+
return !$this->is_EE() && !$this->is_PE();
|
458 |
+
}
|
459 |
+
|
460 |
+
public function is_1_3() {
|
461 |
+
$aVersionInfo = Mage::getVersionInfo();
|
462 |
+
return $aVersionInfo["major"] == '1' and $aVersionInfo["minor"] == '3';
|
463 |
+
}
|
464 |
+
|
465 |
+
public function array_implode( $glue, $separator, $array ) {
|
466 |
+
if ( ! is_array( $array ) ) return $array;
|
467 |
+
$string = array();
|
468 |
+
foreach ( $array as $key => $val ) {
|
469 |
+
if ( is_array( $val ) )
|
470 |
+
$val = implode( ',', $val );
|
471 |
+
$string[] = "{$key}{$glue}{$val}";
|
472 |
+
|
473 |
+
}
|
474 |
+
return implode( $separator, $string );
|
475 |
+
}
|
476 |
+
|
477 |
+
public function getSearchPathEntries()
|
478 |
+
{
|
479 |
+
$searchPathEntries = Mage::registry('searchPathEntries');
|
480 |
+
|
481 |
+
if(!isset($searchPathEntries))
|
482 |
+
{
|
483 |
+
$searchPathEntries = array();
|
484 |
+
$results = $this->getSalespersonApi()->results;
|
485 |
+
if($results && isset($results->SearchPath->Items)){
|
486 |
+
foreach($results->SearchPath->Items as $searchPathEntry) {
|
487 |
+
$searchPathEntries[$searchPathEntry->QuestionId] = $searchPathEntry;
|
488 |
+
}
|
489 |
+
}
|
490 |
+
|
491 |
+
Mage::register('searchPathEntries', $searchPathEntries);
|
492 |
+
}
|
493 |
+
return Mage::registry('searchPathEntries');
|
494 |
+
}
|
495 |
+
|
496 |
+
public function getAnsweredAnswers()
|
497 |
+
{
|
498 |
+
$answeredAnswers = Mage::registry('answeredAnswers');
|
499 |
+
|
500 |
+
if(!isset($answeredAnswers))
|
501 |
+
{
|
502 |
+
$answeredAnswers = array();
|
503 |
+
|
504 |
+
$results = $this->getSalespersonApi()->results;
|
505 |
+
if($results && isset($results->SearchPath->Items)){
|
506 |
+
foreach($results->SearchPath->Items as $searchPathEntry) {
|
507 |
+
foreach($searchPathEntry->Answers->Items as $answer) {
|
508 |
+
$answeredAnswers[$answer->Id] = $answer;
|
509 |
+
}
|
510 |
+
}
|
511 |
+
}
|
512 |
+
Mage::register('answeredAnswers', $answeredAnswers);
|
513 |
+
}
|
514 |
+
return Mage::registry('answeredAnswers');
|
515 |
+
}
|
516 |
+
|
517 |
+
public function updateCategoriesUrlRewrites($store_id=null) {
|
518 |
+
$pattern = 'category/';
|
519 |
+
|
520 |
+
$categories = Mage::getModel('catalog/category')->getCollection()
|
521 |
+
->addNameToResult()
|
522 |
+
->addAttributeToSelect(array('salesperson_search_phrase'))->setStoreId($store_id)->load();
|
523 |
+
|
524 |
+
|
525 |
+
$categoryLookup = array();
|
526 |
+
foreach($categories as $category)
|
527 |
+
{
|
528 |
+
$categoryLookup[$category->getId()] = $category;
|
529 |
+
}
|
530 |
+
|
531 |
+
// update the url rewrite table (categories might have changed)
|
532 |
+
$rewrites = Mage::helper('salesperson')->getCategoriesRewrites($store_id);
|
533 |
+
foreach($rewrites as $rewrite)
|
534 |
+
{
|
535 |
+
$rewrite->delete();
|
536 |
+
$rewrite->getResource()->commit();
|
537 |
+
}
|
538 |
+
|
539 |
+
$model = Mage::getModel('catalog/url');
|
540 |
+
|
541 |
+
$store = Mage::app()->getStore($store_id);
|
542 |
+
$model->refreshCategoryRewrite($store->getRootCategoryId(), $store_id, false);
|
543 |
+
// update -end
|
544 |
+
|
545 |
+
$rewrites = $this->getCategoriesRewrites($store_id);
|
546 |
+
|
547 |
+
foreach($rewrites as $rewrite)
|
548 |
+
{
|
549 |
+
$idPath = $rewrite->getIdPath();
|
550 |
+
$categoryId = substr($idPath, strlen($pattern), strlen($idPath) - strlen($pattern));
|
551 |
+
|
552 |
+
if(is_numeric($categoryId) && isset($categoryLookup[$categoryId]))
|
553 |
+
{
|
554 |
+
$category = $categoryLookup[$categoryId];
|
555 |
+
$query = $this->getCategoryRewriteQuery($category);
|
556 |
+
$targetPath = Mage::helper('salesperson')->getResultUrl($query, $bAddIndexSuffix = true, $bRelativePath = true);
|
557 |
+
$rewrite->setTargetPath($targetPath);
|
558 |
+
$rewrite->save();
|
559 |
+
}
|
560 |
+
}
|
561 |
+
}
|
562 |
+
|
563 |
+
public function getCategoriesRewrites($store_id=null){
|
564 |
+
$pattern = 'category/';
|
565 |
+
|
566 |
+
$rewrites = Mage::getModel('core/url_rewrite')
|
567 |
+
->getCollection()
|
568 |
+
->addFieldToFilter('id_path', array('like' => $pattern . '%'));
|
569 |
+
|
570 |
+
if ($store_id!=null)
|
571 |
+
{
|
572 |
+
$rewrites->addFieldToFilter('store_id',array('='=>$store_id));
|
573 |
+
}
|
574 |
+
|
575 |
+
return $rewrites;
|
576 |
+
}
|
577 |
+
|
578 |
+
public function getCategoryRewriteQuery($category){
|
579 |
+
|
580 |
+
$query = $this->getCategorySearchPhrase($category);
|
581 |
+
if(empty($query)) $query = $category->getName();
|
582 |
+
|
583 |
+
switch(Mage::getStoreConfig('salesperson/nav_to_search_settings/nav_to_search_use_full_category_path')) {
|
584 |
+
|
585 |
+
case "category":
|
586 |
+
break;
|
587 |
+
|
588 |
+
case "full_path":
|
589 |
+
|
590 |
+
$categories = $category->getParentCategories();
|
591 |
+
$aParentIds = $category->getParentIds();
|
592 |
+
$aParentIds = array_reverse($aParentIds);
|
593 |
+
|
594 |
+
for($i=0; $i < count($aParentIds) - 2; $i++) {
|
595 |
+
$parentId = $aParentIds[$i];
|
596 |
+
$category = $categories[$parentId];
|
597 |
+
|
598 |
+
if (!isset($category))
|
599 |
+
continue;
|
600 |
+
|
601 |
+
$categorySearchPhrase = $this->getCategorySearchPhrase($category);
|
602 |
+
if(empty($categorySearchPhrase)) $categorySearchPhrase = $category->getName();
|
603 |
+
$query = $categorySearchPhrase . " " . $query;
|
604 |
+
}
|
605 |
+
|
606 |
+
break;
|
607 |
+
|
608 |
+
case "category_and_parent":
|
609 |
+
|
610 |
+
$categories = $category->getParentCategories();
|
611 |
+
|
612 |
+
if(count($categories) < 3) break;
|
613 |
+
|
614 |
+
$parentId = $category->getParentId();
|
615 |
+
$category = $categories[$parentId];
|
616 |
+
$categorySearchPhrase = $this->getCategorySearchPhrase($category);
|
617 |
+
if(empty($categorySearchPhrase)) $categorySearchPhrase = $category->getName();
|
618 |
+
$query = $categorySearchPhrase . " " . $query;
|
619 |
+
|
620 |
+
break;
|
621 |
+
|
622 |
+
case "category_and_root":
|
623 |
+
|
624 |
+
$aParentIds = $category->getParentIds();
|
625 |
+
|
626 |
+
if(count($aParentIds ) < 2) break;
|
627 |
+
|
628 |
+
$branchRootId = $aParentIds[1];
|
629 |
+
$category = Mage::getModel('catalog/category')->load($branchRootId);
|
630 |
+
$categorySearchPhrase = $this->getCategorySearchPhrase($category);
|
631 |
+
if(empty($categorySearchPhrase)) $categorySearchPhrase = $category->getName();
|
632 |
+
$query = $categorySearchPhrase . " " . $query;
|
633 |
+
|
634 |
+
break;
|
635 |
+
}
|
636 |
+
|
637 |
+
return $query;
|
638 |
+
}
|
639 |
+
|
640 |
+
public function getCurrentCategory(){
|
641 |
+
$category = Mage::registry('rewriteCategory');
|
642 |
+
|
643 |
+
if(!isset($category))
|
644 |
+
{
|
645 |
+
$categoryId = Mage::app()->getRequest()->getParam('categoryId','');
|
646 |
+
$category = Mage::getModel('catalog/category')->load($categoryId);
|
647 |
+
Mage::register('rewriteCategory', $category);
|
648 |
+
}
|
649 |
+
return $category;
|
650 |
+
}
|
651 |
+
|
652 |
+
public function getCategorySearchPhrase($category){
|
653 |
+
$att_code = 'salesperson_search_phrase';
|
654 |
+
return $category->getData($att_code);
|
655 |
+
}
|
656 |
+
|
657 |
+
public function getHref($url){
|
658 |
+
$str = "";
|
659 |
+
if($this->getAjaxMode())
|
660 |
+
$str = ' href="javascript:void(0)"' . 'onclick="celebrosSetLocation(' . "'" . $url . "'" . ')" ';
|
661 |
+
else
|
662 |
+
$str = ' href="' . $url . '" ';
|
663 |
+
return $str;
|
664 |
+
}
|
665 |
+
|
666 |
+
public function useAjaxOnSearchPage(){
|
667 |
+
return Mage::getStoreConfigFlag('salesperson/display_settings/search_page_ajax_enabled');
|
668 |
+
}
|
669 |
+
|
670 |
+
public function isPriceAnswerId($answerId){
|
671 |
+
return substr($answerId, 0, 2) == '_P';
|
672 |
+
}
|
673 |
+
|
674 |
+
public function getAvailableOrders() {
|
675 |
+
$availableOrders = array();
|
676 |
+
|
677 |
+
$sortingFieldsSettings = $this->_getSortingFieldsSettings();
|
678 |
+
foreach($sortingFieldsSettings as $key =>$setting ) {
|
679 |
+
$availableOrders[$key] = $setting["display_name"];
|
680 |
+
}
|
681 |
+
|
682 |
+
return $availableOrders;
|
683 |
+
}
|
684 |
+
|
685 |
+
private function _getSortingFieldsSettings(){
|
686 |
+
if(!$this->_sortingFieldsSettings){
|
687 |
+
$this->_sortingFieldsSettings = array();
|
688 |
+
$rows = explode(PHP_EOL, Mage::getStoreConfig('salesperson/display_settings/sorting_fields'));
|
689 |
+
for($i = 0; $i < count($rows); $i++) {
|
690 |
+
$values = explode("~", $rows[$i]);
|
691 |
+
$key = $values[0];
|
692 |
+
$setting["xml_field_name"] = $key;
|
693 |
+
$setting["direction"] = $values[1];
|
694 |
+
$setting["display_name"] = $values[2];
|
695 |
+
$this->_sortingFieldsSettings[$i.'~'.$key] = $setting;
|
696 |
+
}
|
697 |
+
}
|
698 |
+
return $this->_sortingFieldsSettings;
|
699 |
+
}
|
700 |
+
|
701 |
+
public function getDefaultSortBy() {
|
702 |
+
$defaultSortBy = Mage::getStoreConfig('salesperson/display_settings/default_sort_by');
|
703 |
+
if(empty($defaultSortBy)) $defaultSortBy = "relevancy";
|
704 |
+
return $defaultSortBy;
|
705 |
+
}
|
706 |
+
|
707 |
+
public function getSortDirection($fieldName) {
|
708 |
+
$sortingFieldsSettings = $this->_getSortingFieldsSettings();
|
709 |
+
return isset($sortingFieldsSettings[$fieldName]["direction"]) ? $sortingFieldsSettings[$fieldName]["direction"] : "asc";
|
710 |
+
}
|
711 |
+
|
712 |
+
public function setAjaxMode($bUseAjax) {
|
713 |
+
Mage::register('useAjax', $bUseAjax);
|
714 |
+
}
|
715 |
+
|
716 |
+
public function getAjaxMode() {
|
717 |
+
return Mage::registry('useAjax');
|
718 |
+
}
|
719 |
+
|
720 |
+
public function isGoogleAnalyticsEnabled() {
|
721 |
+
return Mage::getStoreConfigFlag('google/analytics/active');
|
722 |
+
}
|
723 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Helper/Mapping.php
RENAMED
@@ -1,29 +1,29 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Celebros_Salesperson_Helper_Mapping extends Mage_CatalogSearch_Helper_Data
|
4 |
-
{
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Retrieve Mapping array
|
8 |
-
*
|
9 |
-
* @return array
|
10 |
-
*/
|
11 |
-
|
12 |
-
public function getMappingFieldsArray(){
|
13 |
-
return Mage::getSingleton("salesperson/mapping")->getFieldsArray();
|
14 |
-
}
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Retrieve a mapping for a field
|
18 |
-
*
|
19 |
-
* @return string
|
20 |
-
*
|
21 |
-
*/
|
22 |
-
public function getMapping($code_field = ""){
|
23 |
-
$mappingArray = $this->getMappingFieldsArray();
|
24 |
-
if(!key_exists($code_field, $mappingArray)){
|
25 |
-
return $code_field;
|
26 |
-
}
|
27 |
-
return strtolower($mappingArray[$code_field]);
|
28 |
-
}
|
29 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Celebros_Salesperson_Helper_Mapping extends Mage_CatalogSearch_Helper_Data
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Retrieve Mapping array
|
8 |
+
*
|
9 |
+
* @return array
|
10 |
+
*/
|
11 |
+
|
12 |
+
public function getMappingFieldsArray(){
|
13 |
+
return Mage::getSingleton("salesperson/mapping")->getFieldsArray();
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Retrieve a mapping for a field
|
18 |
+
*
|
19 |
+
* @return string
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
public function getMapping($code_field = ""){
|
23 |
+
$mappingArray = $this->getMappingFieldsArray();
|
24 |
+
if(!key_exists($code_field, $mappingArray)){
|
25 |
+
return $code_field;
|
26 |
+
}
|
27 |
+
return strtolower($mappingArray[$code_field]);
|
28 |
+
}
|
29 |
}
|
app/code/{local → community}/Celebros/Salesperson/Helper/Product/Compare.php
RENAMED
@@ -1,40 +1,40 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Helper_Product_Compare extends Mage_Core_Helper_Url
|
11 |
-
{
|
12 |
-
/**
|
13 |
-
* Get parameters used for build add product to compare list urls
|
14 |
-
*
|
15 |
-
* @param Mage_Catalog_Model_Product $product
|
16 |
-
* @return array
|
17 |
-
*/
|
18 |
-
protected function _getUrlParams($product)
|
19 |
-
{
|
20 |
-
if(key_exists(Mage::Helper('salesperson/mapping')->getMapping('id'),$product->Field)){
|
21 |
-
$productId = $product->Field[Mage::Helper('salesperson/mapping')->getMapping('id')];
|
22 |
-
}
|
23 |
-
return array(
|
24 |
-
'product' => $productId,
|
25 |
-
Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl()
|
26 |
-
);
|
27 |
-
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Retrieve url for adding product to conpare list
|
32 |
-
*
|
33 |
-
* @param Mage_Catalog_Model_Product $product
|
34 |
-
* @return string
|
35 |
-
*/
|
36 |
-
public function getAddUrl($product)
|
37 |
-
{
|
38 |
-
return $this->_getUrl('catalog/product_compare/add', $this->_getUrlParams($product));
|
39 |
-
}
|
40 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Helper_Product_Compare extends Mage_Core_Helper_Url
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Get parameters used for build add product to compare list urls
|
14 |
+
*
|
15 |
+
* @param Mage_Catalog_Model_Product $product
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
protected function _getUrlParams($product)
|
19 |
+
{
|
20 |
+
if(key_exists(Mage::Helper('salesperson/mapping')->getMapping('id'),$product->Field)){
|
21 |
+
$productId = $product->Field[Mage::Helper('salesperson/mapping')->getMapping('id')];
|
22 |
+
}
|
23 |
+
return array(
|
24 |
+
'product' => $productId,
|
25 |
+
Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl()
|
26 |
+
);
|
27 |
+
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Retrieve url for adding product to conpare list
|
32 |
+
*
|
33 |
+
* @param Mage_Catalog_Model_Product $product
|
34 |
+
* @return string
|
35 |
+
*/
|
36 |
+
public function getAddUrl($product)
|
37 |
+
{
|
38 |
+
return $this->_getUrl('catalog/product_compare/add', $this->_getUrlParams($product));
|
39 |
+
}
|
40 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Helper/Wishlist/Data.php
RENAMED
@@ -1,58 +1,58 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Helper_Wishlist_Data extends Mage_Core_Helper_Abstract
|
11 |
-
{
|
12 |
-
/**
|
13 |
-
* Retrieve Item Store for URL
|
14 |
-
*
|
15 |
-
* @param Celebros_Salesperson_Model_Api_QwiserProduct|Mage_Wishlist_Model_Item $item
|
16 |
-
* @return Mage_Core_Model_Store
|
17 |
-
*/
|
18 |
-
protected function _getUrlStore($item)
|
19 |
-
{
|
20 |
-
Mage::log("wishlist");
|
21 |
-
$storeId = null;
|
22 |
-
if ($item instanceof Celebros_Salesperson_Model_Api_QwiserProduct) {
|
23 |
-
if(key_exists(Mage::Helper('salesperson/mapping')->getMapping('visible'),$item->Field) && key_exists(Mage::Helper('salesperson/mapping')->getMapping('store_id'),$item->Field)){
|
24 |
-
if ($item->Field[Mage::Helper('salesperson/mapping')->getMapping('visible')] == '1' ) {
|
25 |
-
$storeId = $item->Field[Mage::Helper('salesperson/mapping')->getMapping('store_id')];
|
26 |
-
}
|
27 |
-
}
|
28 |
-
}
|
29 |
-
return Mage::app()->getStore($storeId);
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Retrieve url for adding product to wishlist with params
|
34 |
-
*
|
35 |
-
* @param Celebros_Salesperson_Model_Api_QwiserProduct|Mage_Wishlist_Model_Item $product
|
36 |
-
* @param array $param
|
37 |
-
* @return string|boolean
|
38 |
-
*/
|
39 |
-
public function getAddUrlWithParams($item, array $params = array())
|
40 |
-
{Mage::log("wishlist");
|
41 |
-
$productId = null;
|
42 |
-
if ($item instanceof Celebros_Salesperson_Model_Api_QwiserProduct) {
|
43 |
-
if(key_exists(Mage::Helper('salesperson/mapping')->getMapping('id'),$item->Field)){
|
44 |
-
$productId = $item->Field[Mage::Helper('salesperson/mapping')->getMapping('id')];
|
45 |
-
}
|
46 |
-
}
|
47 |
-
if ($item instanceof Mage_Wishlist_Model_Item) {
|
48 |
-
$productId = $item->getProductId();
|
49 |
-
}
|
50 |
-
|
51 |
-
if ($productId) {
|
52 |
-
$params['product'] = $productId;
|
53 |
-
return $this->_getUrlStore($item)->getUrl('wishlist/index/add', $params);
|
54 |
-
}
|
55 |
-
|
56 |
-
return false;
|
57 |
-
}
|
58 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Helper_Wishlist_Data extends Mage_Core_Helper_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Retrieve Item Store for URL
|
14 |
+
*
|
15 |
+
* @param Celebros_Salesperson_Model_Api_QwiserProduct|Mage_Wishlist_Model_Item $item
|
16 |
+
* @return Mage_Core_Model_Store
|
17 |
+
*/
|
18 |
+
protected function _getUrlStore($item)
|
19 |
+
{
|
20 |
+
Mage::log("wishlist");
|
21 |
+
$storeId = null;
|
22 |
+
if ($item instanceof Celebros_Salesperson_Model_Api_QwiserProduct) {
|
23 |
+
if(key_exists(Mage::Helper('salesperson/mapping')->getMapping('visible'),$item->Field) && key_exists(Mage::Helper('salesperson/mapping')->getMapping('store_id'),$item->Field)){
|
24 |
+
if ($item->Field[Mage::Helper('salesperson/mapping')->getMapping('visible')] == '1' ) {
|
25 |
+
$storeId = $item->Field[Mage::Helper('salesperson/mapping')->getMapping('store_id')];
|
26 |
+
}
|
27 |
+
}
|
28 |
+
}
|
29 |
+
return Mage::app()->getStore($storeId);
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Retrieve url for adding product to wishlist with params
|
34 |
+
*
|
35 |
+
* @param Celebros_Salesperson_Model_Api_QwiserProduct|Mage_Wishlist_Model_Item $product
|
36 |
+
* @param array $param
|
37 |
+
* @return string|boolean
|
38 |
+
*/
|
39 |
+
public function getAddUrlWithParams($item, array $params = array())
|
40 |
+
{Mage::log("wishlist");
|
41 |
+
$productId = null;
|
42 |
+
if ($item instanceof Celebros_Salesperson_Model_Api_QwiserProduct) {
|
43 |
+
if(key_exists(Mage::Helper('salesperson/mapping')->getMapping('id'),$item->Field)){
|
44 |
+
$productId = $item->Field[Mage::Helper('salesperson/mapping')->getMapping('id')];
|
45 |
+
}
|
46 |
+
}
|
47 |
+
if ($item instanceof Mage_Wishlist_Model_Item) {
|
48 |
+
$productId = $item->getProductId();
|
49 |
+
}
|
50 |
+
|
51 |
+
if ($productId) {
|
52 |
+
$params['product'] = $productId;
|
53 |
+
return $this->_getUrlStore($item)->getUrl('wishlist/index/add', $params);
|
54 |
+
}
|
55 |
+
|
56 |
+
return false;
|
57 |
+
}
|
58 |
+
}
|
app/code/{local/Celebros/Salesperson/Model/Api/domxml-php4-to-php5.php → community/Celebros/Salesperson/Model/Api/DomXMLPhp4ToPhp5.php}
RENAMED
@@ -1,316 +1,334 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
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 |
-
|
31 |
-
function
|
32 |
-
function
|
33 |
-
function
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
}
|
57 |
-
function
|
58 |
-
{
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
function
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
$this->myDOMNode->
|
74 |
-
return $
|
75 |
-
}
|
76 |
-
function
|
77 |
-
{
|
78 |
-
$
|
79 |
-
$
|
80 |
-
$
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
}
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
$this->myDOMNode
|
92 |
-
$this->
|
93 |
-
|
94 |
-
|
95 |
-
function
|
96 |
-
{
|
97 |
-
$
|
98 |
-
$
|
99 |
-
$
|
100 |
-
if (
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
function
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
{
|
114 |
-
|
115 |
-
|
116 |
-
$
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
function
|
124 |
-
function
|
125 |
-
{
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
$
|
135 |
-
|
136 |
-
|
137 |
-
$
|
138 |
-
$
|
139 |
-
|
140 |
-
}
|
141 |
-
function
|
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 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
}
|
188 |
-
function
|
189 |
-
function
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
function
|
199 |
-
{
|
200 |
-
$
|
201 |
-
$
|
202 |
-
$
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
function
|
208 |
-
function
|
209 |
-
function
|
210 |
-
function
|
211 |
-
function
|
212 |
-
function
|
213 |
-
function
|
214 |
-
function
|
215 |
-
function
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
}
|
229 |
-
}
|
230 |
-
|
231 |
-
|
232 |
-
{
|
233 |
-
function
|
234 |
-
{
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
{
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
}
|
273 |
-
|
274 |
-
class
|
275 |
-
{
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
/*
|
12 |
+
Requires PHP5, uses built-in DOM extension.
|
13 |
+
To be used in PHP4 scripts using DOMXML extension.
|
14 |
+
Allows PHP4/DOMXML scripts to run on PHP5/DOM.
|
15 |
+
(Requires PHP5/XSL extension for domxml_xslt functions)
|
16 |
+
|
17 |
+
Typical use:
|
18 |
+
{
|
19 |
+
if (version_compare(PHP_VERSION,'5','>='))
|
20 |
+
require_once('domxml-php4-to-php5.php');
|
21 |
+
}
|
22 |
+
*/
|
23 |
+
|
24 |
+
class Celebros_Salesperson_Model_Api_DomXMLPhp4ToPhp5{
|
25 |
+
|
26 |
+
Function Celebros_Salesperson_Model_Api_DomXMLPhp4ToPhp5()
|
27 |
+
{
|
28 |
+
|
29 |
+
}
|
30 |
+
|
31 |
+
function domxml_new_doc($version) {return new php4DOMDocument('');}
|
32 |
+
function domxml_open_file($filename) {return new php4DOMDocument($filename);}
|
33 |
+
function domxml_open_mem($str)
|
34 |
+
{
|
35 |
+
$dom=new php4DOMDocument('');
|
36 |
+
if(!$dom->myDOMNode->loadXML($str))
|
37 |
+
throw new Exception("Could not parse XML!");
|
38 |
+
return $dom;
|
39 |
+
}
|
40 |
+
function html_doc($html_doc,$from_file=false)
|
41 |
+
{
|
42 |
+
$dom=new php4DOMDocument('');
|
43 |
+
if ($from_file) $dom->myDOMNode->loadHTMLFile($html_doc);
|
44 |
+
else $dom->myDOMNode->loadHTML($html_doc);
|
45 |
+
return $dom;
|
46 |
+
}
|
47 |
+
function html_doc_file($filename) {return html_doc($filename,true);}
|
48 |
+
function xpath_eval($xpath_context,$eval_str,$contextnode=null) {return $xpath_context->xpath_eval($eval_str,$contextnode);}
|
49 |
+
function xpath_new_context($dom_document) {return new php4DOMXPath($dom_document);}
|
50 |
+
function xpath_register_ns($xpath_context,$prefix,$namespaceURI) {return $xpath_context->myDOMXPath->registerNamespace($prefix,$namespaceURI);}
|
51 |
+
|
52 |
+
}
|
53 |
+
|
54 |
+
class php4DOMAttr extends php4DOMNode
|
55 |
+
{
|
56 |
+
function php4DOMAttr($aDOMAttr) {$this->myDOMNode=$aDOMAttr;}
|
57 |
+
function name() {return $this->myDOMNode->name;}
|
58 |
+
function set_value($content) {return $this->myDOMNode->value=$content;}
|
59 |
+
function specified() {return $this->myDOMNode->specified;}
|
60 |
+
function value() {return $this->myDOMNode->value;}
|
61 |
+
}
|
62 |
+
|
63 |
+
class php4DOMDocument extends php4DOMNode
|
64 |
+
{
|
65 |
+
function php4DOMDocument($filename='')
|
66 |
+
{
|
67 |
+
$this->myDOMNode=new DOMDocument();
|
68 |
+
$this->myOwnerDocument=$this;
|
69 |
+
if ($filename!='') $this->myDOMNode->load($filename);
|
70 |
+
}
|
71 |
+
function add_root($name)
|
72 |
+
{
|
73 |
+
if ($this->myDOMNode->hasChildNodes()) $this->myDOMNode->removeChild($this->myDOMNode->firstChild);
|
74 |
+
return new php4DOMElement($this->myDOMNode->appendChild($this->myDOMNode->createElement($name)),$this->myOwnerDocument);
|
75 |
+
}
|
76 |
+
function create_attribute($name,$value)
|
77 |
+
{
|
78 |
+
$myAttr=$this->myDOMNode->createAttribute($name);
|
79 |
+
$myAttr->value=$value;
|
80 |
+
return new php4DOMAttr($myAttr,$this);
|
81 |
+
}
|
82 |
+
function create_cdata_section($content) {return new php4DOMNode($this->myDOMNode->createCDATASection($content),$this);}
|
83 |
+
function create_comment($data) {return new php4DOMNode($this->myDOMNode->createComment($data),$this);}
|
84 |
+
function create_element($name) {return new php4DOMElement($this->myDOMNode->createElement($name),$this);}
|
85 |
+
function create_text_node($content) {return new php4DOMText($this->myDOMNode->createTextNode($content),$this);}
|
86 |
+
function document_element() {return parent::_newDOMElement($this->myDOMNode->documentElement,$this);}
|
87 |
+
function dump_file($filename,$compressionmode=false,$format=false)
|
88 |
+
{
|
89 |
+
$format0=$this->myDOMNode->formatOutput;
|
90 |
+
$this->myDOMNode->formatOutput=$format;
|
91 |
+
$res=$this->myDOMNode->save($filename);
|
92 |
+
$this->myDOMNode->formatOutput=$format0;
|
93 |
+
return $res;
|
94 |
+
}
|
95 |
+
function dump_mem($format=false,$encoding=false)
|
96 |
+
{
|
97 |
+
$format0=$this->myDOMNode->formatOutput;
|
98 |
+
$this->myDOMNode->formatOutput=$format;
|
99 |
+
$encoding0=$this->myDOMNode->encoding;
|
100 |
+
if ($encoding) $this->myDOMNode->encoding=$encoding;
|
101 |
+
$dump=$this->myDOMNode->saveXML();
|
102 |
+
$this->myDOMNode->formatOutput=$format0;
|
103 |
+
if ($encoding) $this->myDOMNode->encoding= $encoding0=='' ? 'UTF-8' : $encoding0; //UTF-8 is XML default encoding
|
104 |
+
return $dump;
|
105 |
+
}
|
106 |
+
// function dump_node($node) {return $this->myDOMNode->saveXML($node->myDOMNode);}
|
107 |
+
function free()
|
108 |
+
{
|
109 |
+
if ($this->myDOMNode->hasChildNodes()) $this->myDOMNode->removeChild($this->myDOMNode->firstChild);
|
110 |
+
$this->myDOMNode=null;
|
111 |
+
$this->myOwnerDocument=null;
|
112 |
+
}
|
113 |
+
function get_element_by_id($id) {return parent::_newDOMElement($this->myDOMNode->getElementById($id),$this);}
|
114 |
+
function get_elements_by_tagname($name)
|
115 |
+
{
|
116 |
+
$myDOMNodeList=$this->myDOMNode->getElementsByTagName($name);
|
117 |
+
$nodeSet=array();
|
118 |
+
$i=0;
|
119 |
+
if (isset($myDOMNodeList))
|
120 |
+
while ($node=$myDOMNodeList->item($i++)) $nodeSet[]=new php4DOMElement($node,$this);
|
121 |
+
return $nodeSet;
|
122 |
+
}
|
123 |
+
function html_dump_mem() {return $this->myDOMNode->saveHTML();}
|
124 |
+
function root() {return parent::_newDOMElement($this->myDOMNode->documentElement,$this);}
|
125 |
+
function xpath_new_context() {return new php4DOMXPath($this);}
|
126 |
+
}
|
127 |
+
|
128 |
+
class php4DOMElement extends php4DOMNode
|
129 |
+
{
|
130 |
+
function get_attribute($name) {return $this->myDOMNode->getAttribute($name);}
|
131 |
+
function get_elements_by_tagname($name)
|
132 |
+
{
|
133 |
+
$myDOMNodeList=$this->myDOMNode->getElementsByTagName($name);
|
134 |
+
$nodeSet=array();
|
135 |
+
$i=0;
|
136 |
+
if (isset($myDOMNodeList))
|
137 |
+
while ($node=$myDOMNodeList->item($i++)) $nodeSet[]=new php4DOMElement($node,$this->myOwnerDocument);
|
138 |
+
return $nodeSet;
|
139 |
+
}
|
140 |
+
function has_attribute($name) {return $this->myDOMNode->hasAttribute($name);}
|
141 |
+
function remove_attribute($name) {return $this->myDOMNode->removeAttribute($name);}
|
142 |
+
function set_attribute($name,$value) {return $this->myDOMNode->setAttribute($name,$value);}
|
143 |
+
function set_name($name)
|
144 |
+
{
|
145 |
+
if ($this->myDOMNode->prefix=='') $newNode=$this->myDOMNode->ownerDocument->createElement($name);
|
146 |
+
else $newNode=$this->myDOMNode->ownerDocument->createElementNS($this->myDOMNode->namespaceURI,$this->myDOMNode->prefix.':'.$name);
|
147 |
+
$myDOMNodeList=$this->myDOMNode->attributes;
|
148 |
+
$i=0;
|
149 |
+
if (isset($myDOMNodeList))
|
150 |
+
while ($node=$myDOMNodeList->item($i++))
|
151 |
+
if ($node->namespaceURI=='') $newNode->setAttribute($node->name,$node->value);
|
152 |
+
else $newNode->setAttributeNS($node->namespaceURI,$node->nodeName,$node->value);
|
153 |
+
$myDOMNodeList=$this->myDOMNode->childNodes;
|
154 |
+
if (isset($myDOMNodeList))
|
155 |
+
while ($node=$myDOMNodeList->item(0)) $newNode->appendChild($node);
|
156 |
+
$this->myDOMNode->parentNode->replaceChild($newNode,$this->myDOMNode);
|
157 |
+
$this->myDOMNode=$newNode;
|
158 |
+
return true;
|
159 |
+
}
|
160 |
+
function tagname() {return $this->myDOMNode->tagName;}
|
161 |
+
}
|
162 |
+
|
163 |
+
class php4DOMNode
|
164 |
+
{
|
165 |
+
var $myDOMNode;
|
166 |
+
var $myOwnerDocument;
|
167 |
+
function php4DOMNode($aDomNode,$aOwnerDocument)
|
168 |
+
{
|
169 |
+
$this->myDOMNode=$aDomNode;
|
170 |
+
$this->myOwnerDocument=$aOwnerDocument;
|
171 |
+
}
|
172 |
+
function __get($name)
|
173 |
+
{
|
174 |
+
switch ($name)
|
175 |
+
{
|
176 |
+
case 'type': return $this->myDOMNode->nodeType;
|
177 |
+
case 'tagname': return $this->myDOMNode->tagName;
|
178 |
+
case 'content': return $this->myDOMNode->textContent;
|
179 |
+
case 'name': return $this->myDOMNode->name;
|
180 |
+
case 'value': return $this->myDOMNode->value;
|
181 |
+
default:
|
182 |
+
$myErrors=debug_backtrace();
|
183 |
+
trigger_error('Undefined property: '.get_class($this).'::$'.$name.' ['.$myErrors[0]['file'].':'.$myErrors[0]['line'].']',E_USER_NOTICE);
|
184 |
+
return false;
|
185 |
+
}
|
186 |
+
}
|
187 |
+
function append_child($newnode) {return self::_newDOMElement($this->myDOMNode->appendChild($this->_importNode($newnode)),$this->myOwnerDocument);}
|
188 |
+
function append_sibling($newnode) {return self::_newDOMElement($this->myDOMNode->parentNode->appendChild($this->_importNode($newnode)),$this->myOwnerDocument);}
|
189 |
+
function attributes()
|
190 |
+
{
|
191 |
+
$myDOMNodeList=$this->myDOMNode->attributes;
|
192 |
+
$nodeSet=array();
|
193 |
+
$i=0;
|
194 |
+
if (isset($myDOMNodeList))
|
195 |
+
while ($node=$myDOMNodeList->item($i++)) $nodeSet[]=new php4DOMAttr($node,$this->myOwnerDocument);
|
196 |
+
return $nodeSet;
|
197 |
+
}
|
198 |
+
function child_nodes()
|
199 |
+
{
|
200 |
+
$myDOMNodeList=$this->myDOMNode->childNodes;
|
201 |
+
$nodeSet=array();
|
202 |
+
$i=0;
|
203 |
+
if (isset($myDOMNodeList))
|
204 |
+
while ($node=$myDOMNodeList->item($i++)) $nodeSet[]=self::_newDOMElement($node,$this->myOwnerDocument);
|
205 |
+
return $nodeSet;
|
206 |
+
}
|
207 |
+
function children() {return $this->child_nodes();}
|
208 |
+
function clone_node($deep=false) {return self::_newDOMElement($this->myDOMNode->cloneNode($deep),$this->myOwnerDocument);}
|
209 |
+
function dump_node() {return $this->myOwnerDocument->myDOMNode->saveXML($this->myDOMNode);}
|
210 |
+
function first_child() {return self::_newDOMElement($this->myDOMNode->firstChild,$this->myOwnerDocument);}
|
211 |
+
function get_content() {return $this->myDOMNode->textContent;}
|
212 |
+
function has_attributes() {return $this->myDOMNode->hasAttributes();}
|
213 |
+
function has_child_nodes() {return $this->myDOMNode->hasChildNodes();}
|
214 |
+
function insert_before($newnode,$refnode) {return self::_newDOMElement($this->myDOMNode->insertBefore($newnode->myDOMNode,$refnode->myDOMNode),$this->myOwnerDocument);}
|
215 |
+
function is_blank_node() {return ($this->myDOMNode->nodeType==XML_TEXT_NODE)&&preg_match('%^\s*$%',$this->myDOMNode->nodeValue);}
|
216 |
+
function last_child() {return self::_newDOMElement($this->myDOMNode->lastChild,$this->myOwnerDocument);}
|
217 |
+
function new_child($name,$content)
|
218 |
+
{
|
219 |
+
$mySubNode=$this->myDOMNode->ownerDocument->createElement($name);
|
220 |
+
$mySubNode->appendChild($this->myDOMNode->ownerDocument->createTextNode(html_entity_decode($content,ENT_QUOTES)));
|
221 |
+
$this->myDOMNode->appendChild($mySubNode);
|
222 |
+
return new php4DOMElement($mySubNode,$this->myOwnerDocument);
|
223 |
+
}
|
224 |
+
function next_sibling() {return self::_newDOMElement($this->myDOMNode->nextSibling,$this->myOwnerDocument);}
|
225 |
+
function node_name() {return ($this->myDOMNode->nodeType==XML_ELEMENT_NODE) ? $this->myDOMNode->localName : $this->myDOMNode->nodeName;} //avoid namespace prefix for DOMElement
|
226 |
+
function node_type() {return $this->myDOMNode->nodeType;}
|
227 |
+
function node_value() {return $this->myDOMNode->nodeValue;}
|
228 |
+
function owner_document() {return $this->myOwnerDocument;}
|
229 |
+
function parent_node() {return self::_newDOMElement($this->myDOMNode->parentNode,$this->myOwnerDocument);}
|
230 |
+
function prefix() {return $this->myDOMNode->prefix;}
|
231 |
+
function previous_sibling() {return self::_newDOMElement($this->myDOMNode->previousSibling,$this->myOwnerDocument);}
|
232 |
+
function remove_child($oldchild) {return self::_newDOMElement($this->myDOMNode->removeChild($oldchild->myDOMNode),$this->myOwnerDocument);}
|
233 |
+
function replace_child($oldnode,$newnode) {return self::_newDOMElement($this->myDOMNode->replaceChild($oldnode->myDOMNode,$this->_importNode($newnode)),$this->myOwnerDocument);}
|
234 |
+
function set_content($text) {return $this->myDOMNode->appendChild($this->myDOMNode->ownerDocument->createTextNode($text));}
|
235 |
+
//function set_name($name) {return $this->myOwnerDocument->renameNode($this->myDOMNode,$this->myDOMNode->namespaceURI,$name);}
|
236 |
+
protected function _importNode($newnode) {return $this->myOwnerDocument===$newnode->myOwnerDocument ? $newnode->myDOMNode : $this->myOwnerDocument->myDOMNode->importNode($newnode->myDOMNode,true);} //to import DOMNode from another DOMDocument
|
237 |
+
static function _newDOMElement($aDOMNode,$aOwnerDocument)
|
238 |
+
{//to check the PHP5 DOMNode before creating a new associated PHP4 DOMNode wrapper
|
239 |
+
if ($aDOMNode==null) return null;
|
240 |
+
switch ($aDOMNode->nodeType)
|
241 |
+
{
|
242 |
+
case XML_ELEMENT_NODE: return new php4DOMElement($aDOMNode,$aOwnerDocument);
|
243 |
+
case XML_TEXT_NODE: return new php4DOMText($aDOMNode,$aOwnerDocument);
|
244 |
+
case XML_ATTRIBUTE_NODE: return new php4DOMAttr($aDOMNode,$aOwnerDocument);
|
245 |
+
default: return new php4DOMNode($aDOMNode,$aOwnerDocument);
|
246 |
+
}
|
247 |
+
}
|
248 |
+
}
|
249 |
+
|
250 |
+
class php4DOMText extends php4DOMNode
|
251 |
+
{
|
252 |
+
function __get($name)
|
253 |
+
{
|
254 |
+
if ($name=='tagname') return '#text';
|
255 |
+
else return parent::__get($name);
|
256 |
+
}
|
257 |
+
function tagname() {return '#text';}
|
258 |
+
}
|
259 |
+
|
260 |
+
if (!defined('XPATH_NODESET'))
|
261 |
+
{
|
262 |
+
define('XPATH_UNDEFINED',0);
|
263 |
+
define('XPATH_NODESET',1);
|
264 |
+
/*define('XPATH_BOOLEAN',2);
|
265 |
+
define('XPATH_NUMBER',3);
|
266 |
+
define('XPATH_STRING',4);
|
267 |
+
define('XPATH_POINT',5);
|
268 |
+
define('XPATH_RANGE',6);
|
269 |
+
define('XPATH_LOCATIONSET',7);
|
270 |
+
define('XPATH_USERS',8);
|
271 |
+
define('XPATH_XSLT_TREE',9);*/
|
272 |
+
}
|
273 |
+
|
274 |
+
class php4DOMNodelist
|
275 |
+
{//TODO: To be updated for PHP/5.1 to allow XPath boolean expressions etc. DOMXPath->evaluate()
|
276 |
+
var $myDOMNodelist;
|
277 |
+
var $nodeset;
|
278 |
+
var $type;
|
279 |
+
function php4DOMNodelist($aDOMNodelist,$aOwnerDocument)
|
280 |
+
{
|
281 |
+
$this->myDOMNodelist=$aDOMNodelist;
|
282 |
+
$this->nodeset=array();
|
283 |
+
$i=0;
|
284 |
+
if (isset($this->myDOMNodelist))
|
285 |
+
{
|
286 |
+
$this->type=XPATH_NODESET;
|
287 |
+
while ($node=$this->myDOMNodelist->item($i++)) $this->nodeset[]=php4DOMNode::_newDOMElement($node,$aOwnerDocument);
|
288 |
+
}
|
289 |
+
else $this->type=XPATH_UNDEFINED;
|
290 |
+
}
|
291 |
+
}
|
292 |
+
|
293 |
+
class php4DOMXPath
|
294 |
+
{
|
295 |
+
var $myDOMXPath;
|
296 |
+
var $myOwnerDocument;
|
297 |
+
function php4DOMXPath($dom_document)
|
298 |
+
{
|
299 |
+
$this->myOwnerDocument=$dom_document;
|
300 |
+
$this->myDOMXPath=new DOMXPath($dom_document->myDOMNode);
|
301 |
+
}
|
302 |
+
function xpath_eval($eval_str,$contextnode=null) {return isset($contextnode) ? new php4DOMNodelist($this->myDOMXPath->query($eval_str,$contextnode->myDOMNode),$this->myOwnerDocument) : new php4DOMNodelist($this->myDOMXPath->query($eval_str),$this->myOwnerDocument);}
|
303 |
+
function xpath_register_ns($prefix,$namespaceURI) {return $this->myDOMXPath->registerNamespace($prefix,$namespaceURI);}
|
304 |
+
}
|
305 |
+
|
306 |
+
if (extension_loaded('xsl'))
|
307 |
+
{//See also: http://alexandre.alapetite.net/doc-alex/xslt-php4-php5/
|
308 |
+
function domxml_xslt_stylesheet($xslstring) {return new php4DomXsltStylesheet(DOMDocument::loadXML($xslstring));}
|
309 |
+
function domxml_xslt_stylesheet_doc($dom_document) {return new php4DomXsltStylesheet($dom_document);}
|
310 |
+
function domxml_xslt_stylesheet_file($xslfile) {return new php4DomXsltStylesheet(DOMDocument::load($xslfile));}
|
311 |
+
class php4DomXsltStylesheet
|
312 |
+
{
|
313 |
+
var $myxsltProcessor;
|
314 |
+
function php4DomXsltStylesheet($dom_document)
|
315 |
+
{
|
316 |
+
$this->myxsltProcessor=new xsltProcessor();
|
317 |
+
$this->myxsltProcessor->importStyleSheet($dom_document);
|
318 |
+
}
|
319 |
+
function process($dom_document,$xslt_parameters=array(),$param_is_xpath=false)
|
320 |
+
{
|
321 |
+
foreach ($xslt_parameters as $param=>$value) $this->myxsltProcessor->setParameter('',$param,$value);
|
322 |
+
$myphp4DOMDocument=new php4DOMDocument();
|
323 |
+
$myphp4DOMDocument->myDOMNode=$this->myxsltProcessor->transformToDoc($dom_document->myDOMNode);
|
324 |
+
return $myphp4DOMDocument;
|
325 |
+
}
|
326 |
+
function result_dump_file($dom_document,$filename)
|
327 |
+
{
|
328 |
+
$html=$dom_document->myDOMNode->saveHTML();
|
329 |
+
file_put_contents($filename,$html);
|
330 |
+
return $html;
|
331 |
+
}
|
332 |
+
function result_dump_mem($dom_document) {return $dom_document->myDOMNode->saveHTML();}
|
333 |
+
}
|
334 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserAnswer.php
RENAMED
@@ -1,30 +1,39 @@
|
|
1 |
-
<?
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
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 |
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
Class Celebros_Salesperson_Model_Api_QwiserAnswer
|
12 |
+
{
|
13 |
+
var $Id;
|
14 |
+
var $ImageHeight;
|
15 |
+
var $ImageSku;
|
16 |
+
var $ImageUrl;
|
17 |
+
var $ImageWidth;
|
18 |
+
var $ProductCount;
|
19 |
+
var $Text;
|
20 |
+
var $Type;
|
21 |
+
var $DynamicProperties;
|
22 |
+
|
23 |
+
Function Celebros_Salesperson_Model_Api_QwiserAnswer($AnswerNode)
|
24 |
+
{
|
25 |
+
if(is_object($AnswerNode))
|
26 |
+
{
|
27 |
+
$this->Id = $AnswerNode->get_attribute("Id");
|
28 |
+
$this->ImageHeight = $AnswerNode->get_attribute("ImageHeight");
|
29 |
+
$this->ImageSku = $AnswerNode->get_attribute("ImageSku");
|
30 |
+
$this->ImageUrl = $AnswerNode->get_attribute("ImageUrl");
|
31 |
+
$this->ImageWidth = $AnswerNode->get_attribute("ImageWidth");
|
32 |
+
$this->ProductCount = $AnswerNode->get_attribute("ProductCount");
|
33 |
+
$this->Text = $AnswerNode->get_attribute("Text");
|
34 |
+
$this->Type = $AnswerNode->get_attribute("Type");
|
35 |
+
$this->DynamicProperties = GetQwiserSimpleStringDictionary(current($AnswerNode->get_elements_by_tagname("DynamicProperties")));
|
36 |
+
}
|
37 |
+
}
|
38 |
+
}
|
39 |
?>
|
app/code/community/Celebros/Salesperson/Model/Api/QwiserAnsweredAnswer.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
Class Celebros_Salesperson_Model_Api_QwiserAnsweredAnswer
|
12 |
+
{
|
13 |
+
var $AnswerId;
|
14 |
+
var $EffectOnSearchPath;
|
15 |
+
|
16 |
+
Function Celebros_Salesperson_Model_Api_QwiserAnsweredAnswer($AnsweredAnswerNode)
|
17 |
+
{
|
18 |
+
if(is_object($AnsweredAnswerNode))
|
19 |
+
{
|
20 |
+
$this->AnswerId = $AnsweredAnswerNode->get_attribute("AnswerID");
|
21 |
+
$this->EffectOnSearchPath = $AnsweredAnswerNode->get_attribute("EffectOnSearchPath");
|
22 |
+
}
|
23 |
+
}
|
24 |
+
}
|
25 |
+
?>
|
app/code/community/Celebros/Salesperson/Model/Api/QwiserAnsweredAnswers.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
Class Celebros_Salesperson_Model_Api_QwiserAnsweredAnswers
|
12 |
+
{
|
13 |
+
var $Count = 0;
|
14 |
+
var $Items = array();
|
15 |
+
|
16 |
+
Function Celebros_Salesperson_Model_Api_QwiserAnsweredAnswers($xml_AnsweredAnswers)
|
17 |
+
{
|
18 |
+
//if we got an array of QwiserAnswer
|
19 |
+
if(is_array($xml_AnsweredAnswers))
|
20 |
+
{
|
21 |
+
$this->Items = $xml_AnsweredAnswers;
|
22 |
+
$this->Count = count($xml_AnsweredAnswers);
|
23 |
+
}
|
24 |
+
//if we got a node of QwiserAnsweredAnswers
|
25 |
+
else
|
26 |
+
{
|
27 |
+
if(is_object($xml_AnsweredAnswers))
|
28 |
+
{
|
29 |
+
$xml_AnsweredAnswersNodes = $xml_AnsweredAnswers->child_nodes();
|
30 |
+
$xml_AnsweredAnswersNodes = getDomElements($xml_AnsweredAnswersNodes);
|
31 |
+
$this->Count = count($xml_AnsweredAnswersNodes);
|
32 |
+
|
33 |
+
for ($i = 0 ; $i <= $this->Count - 1;$i++)
|
34 |
+
{
|
35 |
+
$AnsweredAnswerNode = $xml_AnsweredAnswersNodes[$i];
|
36 |
+
$key = $AnsweredAnswerNode->get_attribute("AnswerID");
|
37 |
+
$this->Items[$key] = Mage::getModel('salesperson/Api_QwiserAnsweredAnswer', $AnsweredAnswerNode);
|
38 |
+
}
|
39 |
+
}
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
public function ToSimpleString(){
|
44 |
+
$builder = "";
|
45 |
+
|
46 |
+
for ($i = 0 ; $i <= $this->Count - 1;$i++)
|
47 |
+
{
|
48 |
+
$answer = $this->Items[$i];
|
49 |
+
$builder .= $answer->AnswerId;
|
50 |
+
$builder .= "^";
|
51 |
+
$builder .= $this->_effectOnSearchPathToInt($answer->EffectOnSearchPath);
|
52 |
+
}
|
53 |
+
|
54 |
+
$builder = substr($builder,0,-1);
|
55 |
+
return $builder;
|
56 |
+
}
|
57 |
+
|
58 |
+
private function _effectOnSearchPathToInt($strEffectOnSearchPath)
|
59 |
+
{
|
60 |
+
switch ($strEffectOnSearchPath) {
|
61 |
+
case "Exclude":
|
62 |
+
return 0;
|
63 |
+
break;
|
64 |
+
case "ExactAnswerNode":
|
65 |
+
return 1;
|
66 |
+
break;
|
67 |
+
case "EntireAnswerPath":
|
68 |
+
return 2;
|
69 |
+
break;
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
|
74 |
+
|
75 |
+
|
76 |
+
}
|
77 |
+
?>
|
app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserAnswers.php
RENAMED
@@ -1,92 +1,101 @@
|
|
1 |
-
<?
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
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 |
-
|
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 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
Class Celebros_Salesperson_Model_Api_QwiserAnswers
|
12 |
+
{
|
13 |
+
var $Count = 0; //the number of products
|
14 |
+
var $Items = array(); //indexer .
|
15 |
+
|
16 |
+
Function Celebros_Salesperson_Model_Api_QwiserAnswers($xml_Answers)
|
17 |
+
{
|
18 |
+
//if we got an array of QwiserAnswer
|
19 |
+
if(is_array($xml_Answers))
|
20 |
+
{
|
21 |
+
$this->Items = $xml_Answers;
|
22 |
+
$this->Count = count($xml_Answers);
|
23 |
+
}
|
24 |
+
//if we got a node of QwiserAnswers
|
25 |
+
else
|
26 |
+
{
|
27 |
+
if(is_object($xml_Answers))
|
28 |
+
{
|
29 |
+
$xml_AnswersNodes = $xml_Answers->child_nodes();
|
30 |
+
$xml_AnswersNodes = getDomElements($xml_AnswersNodes);
|
31 |
+
$this->Count = count($xml_AnswersNodes);
|
32 |
+
|
33 |
+
for ($i = 0 ; $i <= $this->Count - 1;$i++)
|
34 |
+
{
|
35 |
+
$AnswerNode = $xml_AnswersNodes[$i];
|
36 |
+
$this->Items[$i] = Mage::getModel('salesperson/Api_QwiserAnswer', $AnswerNode);
|
37 |
+
}
|
38 |
+
}
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
//Return Answer By Id.
|
43 |
+
Function GetAnswerById($ID)
|
44 |
+
{
|
45 |
+
foreach ($this->Items as $Ans)
|
46 |
+
{
|
47 |
+
if($Ans->Id==$ID)
|
48 |
+
{
|
49 |
+
return $Ans;
|
50 |
+
}
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
//Gets a QwiserAnswers object of all answers in this collection that have the specified text
|
55 |
+
Function GetAnswersByText($Text)
|
56 |
+
{
|
57 |
+
$ansArray = array();
|
58 |
+
foreach ($this->Items as $Ans)
|
59 |
+
{
|
60 |
+
if($Ans->Text = $Text)
|
61 |
+
{
|
62 |
+
$ansArray[] = $Ans;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
return Mage::getModel('salesperson/Api_QwiserAnswer', $ansArray);
|
66 |
+
}
|
67 |
+
|
68 |
+
//Gets a QwiserAnswers object of all answers in this collection that are of the specified type
|
69 |
+
Function GetAnswersByType($Type)
|
70 |
+
{
|
71 |
+
$ansArray = array();
|
72 |
+
foreach ($this->Items as $Ans)
|
73 |
+
{
|
74 |
+
if($Ans->Type = $Type)
|
75 |
+
{
|
76 |
+
$ansArray[] = $Ans;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
return Mage::getModel('salesperson/Api_QwiserAnswer', $ansArray);
|
80 |
+
}
|
81 |
+
|
82 |
+
//Sorts This QwiserAnswers collection with CompareTo method.
|
83 |
+
Function SortByAnswerText()
|
84 |
+
{
|
85 |
+
usort($this->Items,array("QwiserAnswers","CompareTo"));
|
86 |
+
}
|
87 |
+
|
88 |
+
Function CompareTo($a,$b)
|
89 |
+
{
|
90 |
+
$al = strtolower($a->Text);
|
91 |
+
$bl = strtolower($b->Text);
|
92 |
+
if ($al == $bl) {
|
93 |
+
return 0;
|
94 |
+
}
|
95 |
+
return ($al > $bl) ? +1 : -1;
|
96 |
+
//return strcmp($a1,$b1);
|
97 |
+
}
|
98 |
+
|
99 |
+
|
100 |
+
}
|
101 |
?>
|
app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserConcept.php
RENAMED
@@ -1,22 +1,31 @@
|
|
1 |
-
<?
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class Celebros_Salesperson_Model_Api_QwiserConcept
|
12 |
+
{
|
13 |
+
var $Id; //the concept id.
|
14 |
+
var $Name; //the concept name.
|
15 |
+
var $Rank; //the concept rank.
|
16 |
+
var $Type; //the concept type(attribute,commodity,temathic).
|
17 |
+
var $DynamicProperties; //the concept dynamic properties.
|
18 |
+
|
19 |
+
function Celebros_Salesperson_Model_Api_QwiserConcept($ConceptNode)
|
20 |
+
{
|
21 |
+
if(is_object($ConceptNode))
|
22 |
+
{
|
23 |
+
$this->Id = $ConceptNode->get_attribute("Id");
|
24 |
+
$this->Name = $ConceptNode->get_attribute("Name");
|
25 |
+
$this->Rank = $ConceptNode->get_attribute("Rank");
|
26 |
+
$this->Type = $ConceptNode->get_attribute("Type");
|
27 |
+
$this->DynamicProperties = GetQwiserSimpleStringDictionary(current($ConceptNode->get_elements_by_tagname("DynamicProperties")));
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
?>
|
app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserConcepts.php
RENAMED
@@ -1,24 +1,33 @@
|
|
1 |
-
<?
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class Celebros_Salesperson_Model_Api_QwiserConcepts
|
12 |
+
{
|
13 |
+
var $Count = 0; //number of concepts.
|
14 |
+
var $Items; //QwiserConcept array
|
15 |
+
|
16 |
+
function Celebros_Salesperson_Model_Api_QwiserConcepts($xml_Concepts)
|
17 |
+
{
|
18 |
+
if(is_object($xml_Concepts))
|
19 |
+
{
|
20 |
+
$xml_ConceptsNodes = $xml_Concepts->child_nodes();
|
21 |
+
$xml_ConceptsNodes = getDomElements($xml_ConceptsNodes);
|
22 |
+
$this->Count = count($xml_ConceptsNodes);
|
23 |
+
|
24 |
+
for ($i = 0 ; $i <= $this->Count - 1;$i++)
|
25 |
+
{
|
26 |
+
$ConceptNode = $xml_ConceptsNodes[$i];
|
27 |
+
$this->Items[$i] = Mage::getModel('salesperson/Api_QwiserConcept', $ConceptNode);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
?>
|
app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserProduct.php
RENAMED
@@ -1,44 +1,53 @@
|
|
1 |
-
<?
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
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 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class Celebros_Salesperson_Model_Api_QwiserProduct
|
12 |
+
{
|
13 |
+
var $Field;
|
14 |
+
var $FoundInAnswerId;
|
15 |
+
var $FoundInAnswerPath;
|
16 |
+
var $IsBestSeller;
|
17 |
+
var $MatchClassFound;
|
18 |
+
var $Price;
|
19 |
+
var $Sku;
|
20 |
+
|
21 |
+
function Celebros_Salesperson_Model_Api_QwiserProduct($ProdNode)
|
22 |
+
{
|
23 |
+
if(is_object($ProdNode))
|
24 |
+
{
|
25 |
+
$this->Field = $this->GetProductCommonInformation($ProdNode);
|
26 |
+
$this->FoundInAnswerId = $ProdNode->get_attribute("FoundInAnswerId");
|
27 |
+
$this->FoundInAnswerPath = $ProdNode->get_attribute("FoundInAnswerPath");
|
28 |
+
$this->IsBestSeller = $ProdNode->get_attribute("IsBestSeller");
|
29 |
+
$this->MatchClassFound = $ProdNode->get_attribute("MatchClassFound");
|
30 |
+
$this->Price = $ProdNode->get_attribute("Price");
|
31 |
+
$this->Sku = $ProdNode->get_attribute("Sku");
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
function GetProductCommonInformation($ProdNode)
|
36 |
+
{
|
37 |
+
$ProductFields=current(getDomElements($ProdNode->child_nodes()));
|
38 |
+
$ProductFieldsArray=getDomElements($ProductFields->child_nodes());
|
39 |
+
foreach ($ProductFieldsArray as $Pfield)
|
40 |
+
{
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Make Fields keys lowercase
|
44 |
+
*
|
45 |
+
* @modifyed by Sveta Oksen - sveta.oksen@gmail.com
|
46 |
+
* @since 28/03/2011
|
47 |
+
*/
|
48 |
+
$ProdField[strtolower($Pfield->get_attribute("name"))] = $Pfield->get_attribute("value");
|
49 |
+
}
|
50 |
+
return $ProdField;
|
51 |
+
}
|
52 |
+
}
|
53 |
?>
|
app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserProductAnswer.php
RENAMED
@@ -1,21 +1,30 @@
|
|
1 |
-
<?
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class Celebros_Salesperson_Model_Api_QwiserProductAnswer
|
12 |
+
{
|
13 |
+
var $Id;
|
14 |
+
var $Name;
|
15 |
+
var $QuestionId;
|
16 |
+
var $Sku;
|
17 |
+
|
18 |
+
Function Celebros_Salesperson_Model_Api_QwiserProductAnswer($ProductAnswerNode)
|
19 |
+
{
|
20 |
+
if(is_object($ProductAnswerNode))
|
21 |
+
{
|
22 |
+
$this->Id = $ProductAnswerNode->get_attribute("Id");
|
23 |
+
$this->Name = $ProductAnswerNode->get_attribute("Name");
|
24 |
+
$this->QuestionId = $ProductAnswerNode->get_attribute("QuestionId");
|
25 |
+
$this->Sku = $ProductAnswerNode->get_attribute("Sku");
|
26 |
+
}
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
?>
|
app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserProductAnswers.php
RENAMED
@@ -1,22 +1,32 @@
|
|
1 |
-
<?
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class Celebros_Salesperson_Model_Api_QwiserProductAnswers
|
12 |
+
{
|
13 |
+
var $Count = 0;
|
14 |
+
var $Items = array();
|
15 |
+
Function Celebros_Salesperson_Model_Api_QwiserProductAnswers($xml_ProductAnswers)
|
16 |
+
{
|
17 |
+
if(is_object($xml_ProductAnswers))
|
18 |
+
{
|
19 |
+
$xml_ProductAnswersNodes = $xml_ProductAnswers->child_nodes();
|
20 |
+
$xml_ProductAnswersNodes = getDomElements($xml_ProductAnswersNodes);
|
21 |
+
$this->Count = count($xml_ProductAnswersNodes);
|
22 |
+
|
23 |
+
for ($i = 0 ; $i <= $this->Count - 1;$i++)
|
24 |
+
{
|
25 |
+
$ProductAnswerNode = $xml_ProductAnswersNodes[$i];
|
26 |
+
$key = $ProductAnswerNode->$AnsweredAnswerNode->get_attribute("Id");
|
27 |
+
$this->Items[$key] = Mage::getModel('salesperson/Api_QwiserProductAnswer', $ProductAnswerNode);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
?>
|
app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserProductField.php
RENAMED
@@ -1,17 +1,26 @@
|
|
1 |
-
<?
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class Celebros_Salesperson_Model_Api_QwiserProductField
|
12 |
+
{
|
13 |
+
var $FieldType;
|
14 |
+
var $Name;
|
15 |
+
|
16 |
+
|
17 |
+
Function Celebros_Salesperson_Model_Api_QwiserProductField($ProductFieldNode)
|
18 |
+
{
|
19 |
+
if(is_object($ProductFieldNode))
|
20 |
+
{
|
21 |
+
$this->FieldType = $ProductFieldNode->get_attribute("FieldType");
|
22 |
+
$this->Name = $ProductFieldNode->get_attribute("Name");
|
23 |
+
}
|
24 |
+
}
|
25 |
+
}
|
26 |
?>
|
app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserProductFields.php
RENAMED
@@ -1,23 +1,32 @@
|
|
1 |
-
<?
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class Celebros_Salesperson_Model_Api_QwiserProductFields
|
12 |
+
{
|
13 |
+
var $Count;
|
14 |
+
var $Items;
|
15 |
+
|
16 |
+
Function Celebros_Salesperson_Model_Api_QwiserProductFields($xml_ProductFields)
|
17 |
+
{
|
18 |
+
if(is_object($xml_ProductFields))
|
19 |
+
{
|
20 |
+
$xml_ProductFieldsNodes = $xml_ProductFields->child_nodes();
|
21 |
+
$xml_ProductFieldsNodes = getDomElements($xml_ProductFieldsNodes);
|
22 |
+
$this->Count = count($xml_ProductFieldsNodes);
|
23 |
+
|
24 |
+
for ($i = 0 ; $i <= $this->Count - 1;$i++)
|
25 |
+
{
|
26 |
+
$ProductFieldNode = $xml_ProductFieldsNodes[$i];
|
27 |
+
$this->Items[$i] = Mage::getModel('salesperson/Api_QwiserProductField', $ProductFieldNode);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
?>
|
app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserProducts.php
RENAMED
@@ -1,27 +1,36 @@
|
|
1 |
-
<?
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class Celebros_Salesperson_Model_Api_QwiserProducts
|
12 |
+
{
|
13 |
+
var $Count = 0; //the number of products.
|
14 |
+
var $Items; //indexer .
|
15 |
+
|
16 |
+
Function Celebros_Salesperson_Model_Api_QwiserProducts($xml_Products)
|
17 |
+
{
|
18 |
+
if(is_object($xml_Products))
|
19 |
+
{
|
20 |
+
$xml_productsNodes = $xml_Products->child_nodes();
|
21 |
+
$xml_productsNodes = getDomElements($xml_productsNodes);
|
22 |
+
$this->Count = count($xml_productsNodes);
|
23 |
+
|
24 |
+
for ($i = 0 ; $i <= $this->Count - 1;$i++)
|
25 |
+
{
|
26 |
+
$ProdNode = $xml_productsNodes[$i];
|
27 |
+
|
28 |
+
$this->Items[$i] = Mage::getModel('salesperson/Product', $ProdNode);
|
29 |
+
|
30 |
+
}
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
|
35 |
+
}
|
36 |
?>
|
app/code/community/Celebros/Salesperson/Model/Api/QwiserQuestion.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class Celebros_Salesperson_Model_Api_QwiserQuestion
|
12 |
+
{
|
13 |
+
var $Id;
|
14 |
+
var $Rank;
|
15 |
+
var $SideText;
|
16 |
+
var $Text;
|
17 |
+
var $Type;
|
18 |
+
var $HasMoreAnswers;
|
19 |
+
var $ExtraAnswers;
|
20 |
+
var $DynamicProperties;
|
21 |
+
var $Answers;
|
22 |
+
|
23 |
+
Function Celebros_Salesperson_Model_Api_QwiserQuestion($QuestionNode)
|
24 |
+
{
|
25 |
+
if(is_object($QuestionNode))
|
26 |
+
{
|
27 |
+
$this->Id = $QuestionNode->get_attribute("Id");
|
28 |
+
$this->Rank = $QuestionNode->get_attribute("Rank");
|
29 |
+
$this->SideText = $QuestionNode->get_attribute("SideText");
|
30 |
+
$this->Text = $QuestionNode->get_attribute("Text");
|
31 |
+
$this->Type = $QuestionNode->get_attribute("Type");
|
32 |
+
$this->Answers = Mage::getModel('salesperson/Api_QwiserAnswers', current($QuestionNode->get_elements_by_tagname("Answers")));
|
33 |
+
$this->ExtraAnswers = Mage::getModel('salesperson/Api_QwiserAnswers', current($QuestionNode->get_elements_by_tagname("ExtraAnswers")));
|
34 |
+
$this->HasMoreAnswers = ($this->ExtraAnswers->Count > 0) ? true : false;
|
35 |
+
|
36 |
+
//Question dynamic properties
|
37 |
+
$QuestionDynamicProperties = null;
|
38 |
+
$childNodes = $QuestionNode->child_nodes();
|
39 |
+
$childNodes = getDomElements($childNodes);
|
40 |
+
for ($i = 0 ; $i <= count($childNodes) - 1;$i++)
|
41 |
+
{
|
42 |
+
$childNode = $childNodes[$i];
|
43 |
+
if($childNode->node_name() == "DynamicProperties") {
|
44 |
+
$QuestionDynamicProperties = $childNode;
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
$this->DynamicProperties = GetQwiserSimpleStringDictionary($QuestionDynamicProperties);
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}
|
52 |
+
?>
|
app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserQuestions.php
RENAMED
@@ -1,91 +1,101 @@
|
|
1 |
-
<?
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
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 |
-
|
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 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class Celebros_Salesperson_Model_Api_QwiserQuestions
|
12 |
+
{
|
13 |
+
var $Count = 0;
|
14 |
+
var $Items = array();
|
15 |
+
|
16 |
+
Function Celebros_Salesperson_Model_Api_QwiserQuestions($xml_Questions)
|
17 |
+
{
|
18 |
+
if(is_array($xml_Questions))
|
19 |
+
{
|
20 |
+
$this->Items = $xml_Questions;
|
21 |
+
$this->Count = count($xml_Questions);
|
22 |
+
}
|
23 |
+
else
|
24 |
+
{
|
25 |
+
if(is_object($xml_Questions))
|
26 |
+
{
|
27 |
+
$xml_questionsNodes = $xml_Questions->child_nodes();
|
28 |
+
$xml_questionsNodes = getDomElements($xml_questionsNodes);
|
29 |
+
$this->Count = count($xml_questionsNodes);
|
30 |
+
|
31 |
+
for ($i = 0 ; $i <= $this->Count - 1;$i++)
|
32 |
+
{
|
33 |
+
$QuestionNode = $xml_questionsNodes[$i];
|
34 |
+
$key = $QuestionNode->get_attribute("Id");
|
35 |
+
$this->Items[$key] = Mage::getModel('salesperson/Api_QwiserQuestion', $QuestionNode);
|
36 |
+
}
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
}
|
41 |
+
|
42 |
+
Function GetAllQuestions(){
|
43 |
+
return $this->Items;
|
44 |
+
}
|
45 |
+
|
46 |
+
//get a question by its id .
|
47 |
+
Function GetQuestionById($ID)
|
48 |
+
{
|
49 |
+
foreach ($this->Items as $q)
|
50 |
+
{
|
51 |
+
if($q->Id=$ID)
|
52 |
+
{
|
53 |
+
return $q;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
//get all questions with the given side text
|
59 |
+
Function GetQuestionsBySideText($SideText)
|
60 |
+
{
|
61 |
+
$qArray = array();
|
62 |
+
foreach ($this->Items as $q)
|
63 |
+
{
|
64 |
+
if($q->SideText=$SideText)
|
65 |
+
{
|
66 |
+
$qArray[] = $q;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
return $qArray;
|
70 |
+
}
|
71 |
+
|
72 |
+
//get all question with the given text .
|
73 |
+
Function GetQuestionsByText($QuestionText)
|
74 |
+
{
|
75 |
+
$qArray = array();
|
76 |
+
foreach ($this->Items as $q)
|
77 |
+
{
|
78 |
+
if($q->Text=$QuestionText)
|
79 |
+
{
|
80 |
+
$qArray[] = $q;
|
81 |
+
}
|
82 |
+
}
|
83 |
+
return $qArray;
|
84 |
+
}
|
85 |
+
|
86 |
+
//get all question with the given type .
|
87 |
+
Function GetQuestionsByType($Type)
|
88 |
+
{
|
89 |
+
$qArray = array();
|
90 |
+
foreach ($this->Items as $q)
|
91 |
+
{
|
92 |
+
if($q->Type=$Type)
|
93 |
+
{
|
94 |
+
$qArray[] = $q;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
return $qArray;
|
98 |
+
|
99 |
+
}
|
100 |
+
}
|
101 |
?>
|
app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserSearchPath.php
RENAMED
@@ -1,23 +1,32 @@
|
|
1 |
-
<?
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class Celebros_Salesperson_Model_Api_QwiserSearchPath
|
12 |
+
{
|
13 |
+
var $Count = 0;
|
14 |
+
var $Items;
|
15 |
+
|
16 |
+
Function Celebros_Salesperson_Model_Api_QwiserSearchPath($xml_SearchPath)
|
17 |
+
{
|
18 |
+
if(is_object($xml_SearchPath))
|
19 |
+
{
|
20 |
+
$xml_SearchPathNodes = $xml_SearchPath->child_nodes();
|
21 |
+
$xml_SearchPathNodes = getDomElements($xml_SearchPathNodes);
|
22 |
+
$this->Count = count($xml_SearchPathNodes);
|
23 |
+
|
24 |
+
for ($i = 0 ; $i < $this->Count;$i++)
|
25 |
+
{
|
26 |
+
$SearchPathNode = $xml_SearchPathNodes[$i];
|
27 |
+
$this->Items[$i] = Mage::getModel('salesperson/Api_QwiserSearchPathEntry', $SearchPathNode);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
?>
|
app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserSearchPathEntry.php
RENAMED
@@ -1,18 +1,27 @@
|
|
1 |
-
<?
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class Celebros_Salesperson_Model_Api_QwiserSearchPathEntry
|
12 |
+
{
|
13 |
+
var $AnswerIndex;
|
14 |
+
var $Answers;
|
15 |
+
var $QuestionId;
|
16 |
+
|
17 |
+
Function Celebros_Salesperson_Model_Api_QwiserSearchPathEntry($EntryNode)
|
18 |
+
{
|
19 |
+
if(is_object($EntryNode))
|
20 |
+
{
|
21 |
+
$this->AnswerIndex = $EntryNode->get_attribute("AnswerIndex");
|
22 |
+
$this->QuestionId = $EntryNode->get_attribute("QuestionID");
|
23 |
+
$this->Answers = Mage::getModel('salesperson/Api_QwiserAnswers', current(getDomElements($EntryNode->child_nodes())));
|
24 |
+
}
|
25 |
+
}
|
26 |
+
}
|
27 |
?>
|
app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserSearchResults.php
RENAMED
@@ -1,111 +1,120 @@
|
|
1 |
-
<?
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
var $
|
14 |
-
var $
|
15 |
-
var $
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
$this->
|
29 |
-
$this->
|
30 |
-
$this->
|
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 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class Celebros_Salesperson_Model_Api_QwiserSearchResults
|
12 |
+
{
|
13 |
+
var $xml_root;
|
14 |
+
var $QwiserSearchResults;
|
15 |
+
var $QwiserErrorOccurred;
|
16 |
+
var $QwiserErrorMessage;
|
17 |
+
var $SearchInformation;
|
18 |
+
var $Questions;
|
19 |
+
var $SearchPath;
|
20 |
+
var $Products;
|
21 |
+
var $QueryConcepts;
|
22 |
+
var $SpellerInformation ;
|
23 |
+
var $RelatedSearches;
|
24 |
+
var $SpecialCasesDetectedInThisSearch;
|
25 |
+
|
26 |
+
Function Celebros_Salesperson_Model_Api_QwiserSearchResults($root)
|
27 |
+
{
|
28 |
+
$this->xml_root = $root;
|
29 |
+
$this->QwiserSearchResults = current($this->xml_root->get_elements_by_tagname("QwiserSearchResults"));
|
30 |
+
$this->QwiserErrorOccurred = (bool)$this->xml_root->get_attribute("ErrorOccurred");
|
31 |
+
$this->QwiserErrorMessage = current($this->xml_root->get_elements_by_tagname("QwiserError"));
|
32 |
+
$this->SearchInformation = Mage::getModel('salesperson/Api_SearchInformation', current($this->xml_root->get_elements_by_tagname("SearchInformation")));
|
33 |
+
$this->Questions = Mage::getModel('salesperson/Api_QwiserQuestions', current($this->xml_root->get_elements_by_tagname("Questions")));
|
34 |
+
$this->SearchPath = Mage::getModel('salesperson/Api_QwiserSearchPath', current($this->xml_root->get_elements_by_tagname("SearchPath")));
|
35 |
+
$this->Products = Mage::getModel('salesperson/Api_QwiserProducts', current($this->xml_root->get_elements_by_tagname("Products")));
|
36 |
+
$this->QueryConcepts = Mage::getModel('salesperson/Api_QwiserConcepts', current($this->xml_root->get_elements_by_tagname("QueryConcepts")));
|
37 |
+
$this->SpellerInformation = Mage::getModel('salesperson/Api_QwiserSpellerInformation', current($this->xml_root->get_elements_by_tagname("SpellerInformation")));
|
38 |
+
$this->RelatedSearches = GetQwiserSimpleStringCollection(current($this->xml_root->get_elements_by_tagname("RelatedSearches")));
|
39 |
+
$this->SpecialCasesDetectedInThisSearch = current($this->xml_root->get_elements_by_tagname("SpecialCasesDetectedInThisSearch"));
|
40 |
+
}
|
41 |
+
|
42 |
+
Function GetErrorOccurred(){
|
43 |
+
return $this->QwiserErrorOccurred;
|
44 |
+
}
|
45 |
+
|
46 |
+
Function GetErrorMessage(){
|
47 |
+
if ($this->GetErrorOccurred()){
|
48 |
+
return $this->QwiserErrorMessage->get_attribute("ErrorMessage");
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
Function GetExactMatchFound()
|
53 |
+
{
|
54 |
+
return $this->QwiserSearchResults->get_attribute("ExactMatchFound");
|
55 |
+
}
|
56 |
+
|
57 |
+
Function GetLogHandle()
|
58 |
+
{
|
59 |
+
return $this->QwiserSearchResults->get_attribute("LogHandle");
|
60 |
+
}
|
61 |
+
|
62 |
+
Function GetSearchHandle()
|
63 |
+
{
|
64 |
+
return $this->QwiserSearchResults->get_attribute("SearchHandle");
|
65 |
+
}
|
66 |
+
|
67 |
+
Function GetMaxMatchClassFound()
|
68 |
+
{
|
69 |
+
return $this->QwiserSearchResults->get_attribute("MaxMatchClassFound");
|
70 |
+
}
|
71 |
+
|
72 |
+
Function GetMinMatchClassFound()
|
73 |
+
{
|
74 |
+
return $this->QwiserSearchResults->get_attribute("MinMatchClassFound");
|
75 |
+
}
|
76 |
+
|
77 |
+
Function GetRecommendedMessage()
|
78 |
+
{
|
79 |
+
return $this->QwiserSearchResults->get_attribute("RecommendedMessage");
|
80 |
+
}
|
81 |
+
|
82 |
+
Function GetRedirectionUrl()
|
83 |
+
{
|
84 |
+
return $this->QwiserSearchResults->get_attribute("RedirectionUrl");
|
85 |
+
}
|
86 |
+
|
87 |
+
Function GetRelevantProductsCount()
|
88 |
+
{
|
89 |
+
return $this->QwiserSearchResults->get_attribute("RelevantProductsCount");
|
90 |
+
}
|
91 |
+
|
92 |
+
Function GetSearchDataVersion()
|
93 |
+
{
|
94 |
+
return $this->QwiserSearchResults->get_attribute("SearchDataVersion");
|
95 |
+
}
|
96 |
+
|
97 |
+
Function GetSearchEngineTimeDuration()
|
98 |
+
{
|
99 |
+
return $this->QwiserSearchResults->get_attribute("SearchEngineTimeDuration");
|
100 |
+
}
|
101 |
+
|
102 |
+
Function GetSearchTimeDuration()
|
103 |
+
{
|
104 |
+
return $this->QwiserSearchResults->get_attribute("SearchTimeDuration");
|
105 |
+
}
|
106 |
+
|
107 |
+
Function GetSearchStatus()
|
108 |
+
{
|
109 |
+
return $this->QwiserSearchResults->get_attribute("SearchStatus");
|
110 |
+
}
|
111 |
+
|
112 |
+
/*Function GetLogHandle()
|
113 |
+
{
|
114 |
+
return $this->QwiserSearchResults->get_attribute("LogHandle");
|
115 |
+
}*/
|
116 |
+
|
117 |
+
}
|
118 |
+
|
119 |
+
|
120 |
?>
|
app/code/{local → community}/Celebros/Salesperson/Model/Api/QwiserSpellerInformation.php
RENAMED
@@ -1,18 +1,27 @@
|
|
1 |
-
<?
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class Celebros_Salesperson_Model_Api_QwiserSpellerInformation
|
12 |
+
{
|
13 |
+
var $AdditionalSuggestions;
|
14 |
+
var $SpellerAutoCorrection;
|
15 |
+
var $SpellingErrorDetected = "false";
|
16 |
+
|
17 |
+
function Celebros_Salesperson_Model_Api_QwiserSpellerInformation($xml_SpellerInformation)
|
18 |
+
{
|
19 |
+
if(is_object($xml_SpellerInformation))
|
20 |
+
{
|
21 |
+
$this->SpellingErrorDetected = $xml_SpellerInformation->get_attribute("SpellingErrorDetected");
|
22 |
+
$this->SpellerAutoCorrection = $xml_SpellerInformation->get_attribute("SpellerAutoCorrection");
|
23 |
+
$this->AdditionalSuggestions = GetQwiserSimpleStringCollection(current(getDomElements($xml_SpellerInformation->child_nodes())));
|
24 |
+
}
|
25 |
+
}
|
26 |
+
}
|
27 |
?>
|
app/code/community/Celebros/Salesperson/Model/Api/SearchInformation.php
ADDED
@@ -0,0 +1,228 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class Celebros_Salesperson_Model_Api_SearchInformation
|
12 |
+
{
|
13 |
+
var $Query;
|
14 |
+
var $OriginalQuery;
|
15 |
+
var $SearchProfileName;
|
16 |
+
var $PriceFieldName;
|
17 |
+
var $NumberOfPages;
|
18 |
+
var $CurrentPage;
|
19 |
+
var $PageSize;
|
20 |
+
var $IsDefaultPageSize;
|
21 |
+
var $IsDefaultSearchProfileName;
|
22 |
+
var $SkuSearchOccured;
|
23 |
+
var $DeadEndOccurred;
|
24 |
+
var $FirstQuestionId;
|
25 |
+
var $SessionId;
|
26 |
+
var $Stage;
|
27 |
+
var $SortingOptions;
|
28 |
+
var $AnsweredAnswers;
|
29 |
+
var $SpecialCasesDetectedInThisSession;
|
30 |
+
var $MinMatchClassFound= 0;
|
31 |
+
var $MaxMatchClassFound = 5;
|
32 |
+
|
33 |
+
Function Celebros_Salesperson_Model_Api_SearchInformation($xml_SearchInformation)
|
34 |
+
{
|
35 |
+
if(is_object($xml_SearchInformation))
|
36 |
+
{
|
37 |
+
$this->Query = $xml_SearchInformation->get_attribute("Query");
|
38 |
+
$this->OriginalQuery = $xml_SearchInformation->get_attribute("OriginalQuery");
|
39 |
+
$this->SearchProfileName = $xml_SearchInformation->get_attribute("SearchProfileName");
|
40 |
+
$this->PriceFieldName = $xml_SearchInformation->get_attribute("PriceFieldName");
|
41 |
+
$this->NumberOfPages = $xml_SearchInformation->get_attribute("NumberOfPages");
|
42 |
+
$this->CurrentPage = $xml_SearchInformation->get_attribute("CurrentPage");
|
43 |
+
$this->PageSize = $xml_SearchInformation->get_attribute("PageSize");
|
44 |
+
$this->IsDefaultPageSize = $xml_SearchInformation->get_attribute("IsDefaultPageSize");
|
45 |
+
$this->SkuSearchOccured = $xml_SearchInformation->get_attribute("SkuSearchOccured");
|
46 |
+
$this->DeadEndOccurred = $xml_SearchInformation->get_attribute("DeadEndOccurred");
|
47 |
+
$this->FirstQuestionId = $xml_SearchInformation->get_attribute("FirstQuestionId");
|
48 |
+
$this->SessionId = $xml_SearchInformation->get_attribute("SessionId");
|
49 |
+
$this->Stage = $xml_SearchInformation->get_attribute("Stage");
|
50 |
+
$this->SortingOptions = Mage::getModel('salesperson/Api_SortingOptions', current($xml_SearchInformation->get_elements_by_tagname("SortingOptions")));
|
51 |
+
$this->AnsweredAnswers = Mage::getModel('salesperson/Api_QwiserAnsweredAnswers', current($xml_SearchInformation->get_elements_by_tagname("AnsweredAnswers")));
|
52 |
+
$this->SpecialCasesDetectedInThisSession = Mage::getModel('salesperson/Api_SpecialCasesDetectedInThisSession', current($xml_SearchInformation->get_elements_by_tagname("SpecialCasesDetectedInThisSession")));
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
public function ToSearchHandle() {
|
57 |
+
$builder = "";
|
58 |
+
|
59 |
+
if (strlen($this->Query > 0))
|
60 |
+
{
|
61 |
+
$builder.= "A=" . str_replace("~", "~~", $this->Query) . "~";
|
62 |
+
}
|
63 |
+
if (strlen($this->OriginalQuery > 0))
|
64 |
+
{
|
65 |
+
$builder.= "B=" . str_replace("~", "~~", $this->OriginalQuery) . "~";
|
66 |
+
}
|
67 |
+
if ($this->CurrentPage != "0")
|
68 |
+
{
|
69 |
+
$builder.= "C=" . $this->CurrentPage . "~";
|
70 |
+
}
|
71 |
+
if ($this->IsDefaultPageSize != "true")
|
72 |
+
{
|
73 |
+
$builder.= "D=" . $this->PageSize . "~";
|
74 |
+
}
|
75 |
+
if (!$this->SortingOptions->IsDefault())
|
76 |
+
{
|
77 |
+
$builder.= "E=" . str_replace("~", "~~", $this->SortingOptions.ToString()) . "~";
|
78 |
+
}
|
79 |
+
if (strlen($this->FirstQuestionId) > 0)
|
80 |
+
{
|
81 |
+
$builder.= "F=" . str_replace("~", "~~", $this->FirstQuestionId) . "~";
|
82 |
+
}
|
83 |
+
if ($this->AnsweredAnswers->Count > 0)
|
84 |
+
{
|
85 |
+
$builder.= "G=" . str_replace("~", "~~", $this->AnsweredAnswersToString()) . "~";
|
86 |
+
}
|
87 |
+
if ($this->IsDefaultSearchProfileName!="true")
|
88 |
+
{
|
89 |
+
$builder.= "H=" . str_replace("~", "~~", $this->SearchProfileName) . "~";
|
90 |
+
}
|
91 |
+
if (strlen($this->PriceFieldName) > 0)
|
92 |
+
{
|
93 |
+
$builder.= "I=" . str_replace("~", "~~", $this->PriceFieldName) . "~";
|
94 |
+
}
|
95 |
+
if ($this->SpecialCasesDetectedInThisSession->Count > 0)
|
96 |
+
{
|
97 |
+
$builder.= "J=" . str_replace("~", "~~", $this->SpecialCasesDetectedInThisSessionToString());
|
98 |
+
}
|
99 |
+
if ($this->MaxMatchClassFound != 0)
|
100 |
+
{
|
101 |
+
$builder.= "K=" . $this->MaxMatchClassFound . "~";
|
102 |
+
}
|
103 |
+
if ($this->MinMatchClassFound != 0)
|
104 |
+
{
|
105 |
+
$builder.= "L=" . $this->MinMatchClassFound . "~";
|
106 |
+
}
|
107 |
+
if (!$this->IsDefaultNumberOfPages())
|
108 |
+
{
|
109 |
+
$builder.= "M=" . $this->NumberOfPages . "~";
|
110 |
+
}
|
111 |
+
if (!$this->IsDefaultStage())
|
112 |
+
{
|
113 |
+
$builder.= "N=" . $this->Stage . "~";
|
114 |
+
}
|
115 |
+
return $this->UUEncode6Bit($builder);
|
116 |
+
}
|
117 |
+
|
118 |
+
private function AnsweredAnswersToString() {
|
119 |
+
return $this->AnsweredAnswers->ToSimpleString();
|
120 |
+
}
|
121 |
+
|
122 |
+
private function SpecialCasesDetectedInThisSessionToString()
|
123 |
+
{
|
124 |
+
return $this->SpecialCasesDetectedInThisSession->ToSimpleString();
|
125 |
+
}
|
126 |
+
|
127 |
+
private function IsDefaultNumberOfPages() {
|
128 |
+
return $this->NumberOfPages == "0";
|
129 |
+
}
|
130 |
+
|
131 |
+
private function IsDefaultStage() {
|
132 |
+
return $this->Stage == "1";
|
133 |
+
}
|
134 |
+
|
135 |
+
private function GetCharCode($intCode) {
|
136 |
+
if($intCode >= 0 && $intCode <= 25)
|
137 |
+
{
|
138 |
+
$intCode += 65;//ASCII of A
|
139 |
+
}
|
140 |
+
else if($intCode >= 26 && $intCode <= 51)
|
141 |
+
{
|
142 |
+
$intCode += 97 - 26;//ASCII of a
|
143 |
+
}
|
144 |
+
else if($intCode >= 52 && $intCode <= 61)
|
145 |
+
{
|
146 |
+
$intCode += 48 - 52;
|
147 |
+
}
|
148 |
+
else if ($intCode == 62)
|
149 |
+
{
|
150 |
+
$intCode = 95;//ASCII of _
|
151 |
+
}
|
152 |
+
else
|
153 |
+
{
|
154 |
+
$intCode = 45;//ASCII of -
|
155 |
+
}
|
156 |
+
return chr($intCode);
|
157 |
+
|
158 |
+
}
|
159 |
+
|
160 |
+
private function UUEncode6Bit($strInput) {
|
161 |
+
$sbCodedString = "";
|
162 |
+
|
163 |
+
if(empty($strInput)) return $sbCodedString;
|
164 |
+
|
165 |
+
$arrInput = str_split($strInput);
|
166 |
+
$arrByteInput = array();
|
167 |
+
for($i=0; $i < count($arrInput) ; $i++) {
|
168 |
+
$arrByteInput[] = ord($arrInput[$i]);
|
169 |
+
}
|
170 |
+
|
171 |
+
$iGroupsNum = (int)ceil(count($arrByteInput)/3);
|
172 |
+
$intCode = 0;
|
173 |
+
$intReminder = 0;
|
174 |
+
$b = 0;
|
175 |
+
$iOffset = 0;
|
176 |
+
|
177 |
+
for($i=0; $i <$iGroupsNum ; $i++)
|
178 |
+
{
|
179 |
+
$iOffset = 3*$i;
|
180 |
+
$b = $arrByteInput[$iOffset];
|
181 |
+
$intCode = (128 + 64 + 32 + 16 + 8 +4) & $b; //gets the upper 6 bites of the byte
|
182 |
+
$intCode = $intCode>>2; // shift 2 times right
|
183 |
+
$sbCodedString .= $this->GetCharCode($intCode);// this will be our first char
|
184 |
+
$intReminder = (2 + 1)& $b;// take the 2 reminded bits
|
185 |
+
$intReminder = $intReminder << 4;//shift them 4 bits right (those bits will be the upper 4 bits of the constructed char code)
|
186 |
+
if($iOffset + 1 < count($arrByteInput))//check if there is another byte in the array
|
187 |
+
{
|
188 |
+
$b = $arrByteInput[$iOffset + 1];//take the next byte
|
189 |
+
$intCode = (128 + 64 + 32 + 16) & $b;//get it's 4 upper bits
|
190 |
+
$intCode = $intCode >> 4;//and shift them so they will be the 4 lowest bits
|
191 |
+
//the next char code will be constructed from the 2 bits of the former byte
|
192 |
+
//and the 4 first of the current.
|
193 |
+
$sbCodedString .= $this->GetCharCode($intCode + $intReminder);
|
194 |
+
//Get the 4 last bits of the current byte
|
195 |
+
$intReminder = (8 + 4 + 2 + 1)& $b;
|
196 |
+
//shift them 2 bits left
|
197 |
+
$intReminder = $intReminder << 2;
|
198 |
+
//check if there is another byte in the array
|
199 |
+
if($iOffset + 2 < count($arrByteInput))
|
200 |
+
{
|
201 |
+
$b = $arrByteInput[$iOffset + 2];//take the next byte
|
202 |
+
$intCode = (128 + 64) & $b;//get it's 2 upper bits
|
203 |
+
$intCode = $intCode >> 6;//and shift them 6 bits left
|
204 |
+
//the next char code will be constructed from the 4 bits of the former byte and the 2 upper bits
|
205 |
+
//of the current byte.
|
206 |
+
$sbCodedString .= $this->GetCharCode($intCode + $intReminder);
|
207 |
+
//Take the 6 reminded bits of the current byte. They will construct the last char code
|
208 |
+
$intReminder = (32 + 16 + 8 + 4 + 2 + 1) & $b;
|
209 |
+
$sbCodedString .= $this->GetCharCode($intReminder);
|
210 |
+
}
|
211 |
+
else
|
212 |
+
{
|
213 |
+
$sbCodedString .= $this->GetCharCode($intReminder);
|
214 |
+
break;
|
215 |
+
|
216 |
+
}
|
217 |
+
}
|
218 |
+
else
|
219 |
+
{
|
220 |
+
$sbCodedString .= $this->GetCharCode($intReminder);
|
221 |
+
break;
|
222 |
+
}
|
223 |
+
}
|
224 |
+
return $sbCodedString;
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
?>
|
app/code/community/Celebros/Salesperson/Model/Api/SortingOptions.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class Celebros_Salesperson_Model_Api_SortingOptions
|
12 |
+
{
|
13 |
+
var $Ascending;
|
14 |
+
var $FieldName;
|
15 |
+
var $NumericSort;
|
16 |
+
var $Method;
|
17 |
+
|
18 |
+
Function Celebros_Salesperson_Model_Api_SortingOptions($xml_SortingOptions)
|
19 |
+
{
|
20 |
+
if(is_object($xml_SortingOptions))
|
21 |
+
{
|
22 |
+
$this->Ascending = $xml_SortingOptions->get_attribute("Ascending");
|
23 |
+
$this->FieldName = $xml_SortingOptions->get_attribute("FieldName");
|
24 |
+
$this->NumericSort = $xml_SortingOptions->get_attribute("NumericSort");
|
25 |
+
$this->Method = $xml_SortingOptions->get_attribute("Method");
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
public function ToString(){
|
30 |
+
$builder = "";
|
31 |
+
if($this->Ascending == "true") $builder .= "1";
|
32 |
+
else $builder .= "0";
|
33 |
+
$builder .= "^";
|
34 |
+
if($this->NumericSort == "true") $builder .= "1";
|
35 |
+
else $builder .= "0";
|
36 |
+
$builder .= "^";
|
37 |
+
$builder .= $this->_sortMethodToInt($this->Method);
|
38 |
+
$builder .= "^";
|
39 |
+
$builder .= $this->FieldName;
|
40 |
+
|
41 |
+
return $builder;
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
public function IsDefault()
|
46 |
+
{
|
47 |
+
return (($this->Ascending != "true" && $this->NumericSort != "true") && ((strlen($this->FieldName) == 0) && ($this->Method == "Relevancy")));
|
48 |
+
}
|
49 |
+
|
50 |
+
private function _sortMethodToInt($strSortMethod){
|
51 |
+
switch ($strSortMethod) {
|
52 |
+
case "Price":
|
53 |
+
return 0;
|
54 |
+
break;
|
55 |
+
case "Relevancy":
|
56 |
+
return 1;
|
57 |
+
break;
|
58 |
+
case "SpecifiedField":
|
59 |
+
return 2;
|
60 |
+
break;
|
61 |
+
}
|
62 |
+
}
|
63 |
+
}
|
64 |
+
?>
|
app/code/community/Celebros/Salesperson/Model/Api/SpecialCasesDetectedInThisSession.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class Celebros_Salesperson_Model_Api_SpecialCasesDetectedInThisSession
|
12 |
+
{
|
13 |
+
var $Count = 0; //the number of values.
|
14 |
+
var $Items; //indexer
|
15 |
+
|
16 |
+
Function Celebros_Salesperson_Model_Api_SpecialCasesDetectedInThisSession($xml_SpecialCasesDetectedInThisSession)
|
17 |
+
{
|
18 |
+
if(is_object($xml_SpecialCasesDetectedInThisSession))
|
19 |
+
{
|
20 |
+
$xml_valuesNodes = $xml_SpecialCasesDetectedInThisSession->child_nodes();
|
21 |
+
$xml_valuesNodes = getDomElements($xml_valuesNodes);
|
22 |
+
$this->Count = count($xml_valuesNodes);
|
23 |
+
|
24 |
+
for ($i = 0 ; $i <= $this->Count - 1;$i++)
|
25 |
+
{
|
26 |
+
$ValueNode = $xml_valuesNodes[$i];
|
27 |
+
$this->Items[$i] = $ValueNode->node_value();
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
public function ToSimpleString() {
|
33 |
+
return implode("^", $this->Items);
|
34 |
+
}
|
35 |
+
}
|
app/code/community/Celebros/Salesperson/Model/Catalog/Category.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Model_Category extends Mage_Catalog_Model_Category
|
11 |
+
{
|
12 |
+
|
13 |
+
public function getUrl()
|
14 |
+
{
|
15 |
+
if(!Mage::getStoreConfigFlag('salesperson/nav_to_search_settings/nav_to_search')) return parent::getUrl();
|
16 |
+
|
17 |
+
$url = $this->_getData('url');
|
18 |
+
if (is_null($url)) {
|
19 |
+
$query = $this->salesperson_get_query();
|
20 |
+
$url = Mage::helper('salesperson')->getResultUrl($query);
|
21 |
+
$this->setData('url', $url);
|
22 |
+
}
|
23 |
+
|
24 |
+
return $url;
|
25 |
+
}
|
26 |
+
|
27 |
+
private function salesperson_get_query(){
|
28 |
+
|
29 |
+
$query = $this->salesperson_get_search_phrase($this);
|
30 |
+
|
31 |
+
switch(Mage::getStoreConfig('salesperson/nav_to_search_settings/nav_to_search_use_full_category_path')) {
|
32 |
+
|
33 |
+
case "category":
|
34 |
+
break;
|
35 |
+
|
36 |
+
case "full_path":
|
37 |
+
|
38 |
+
$categories = $this->getParentCategories();
|
39 |
+
$aParentIds = $this->getParentIds();
|
40 |
+
$aParentIds = array_reverse($aParentIds);
|
41 |
+
|
42 |
+
for($i=0; $i < count($aParentIds) - 2; $i++) {
|
43 |
+
$parentId = $aParentIds[$i];
|
44 |
+
$category = $categories[$parentId];
|
45 |
+
$searchPhraseAttributeValue = $this->salesperson_get_search_phrase($category);
|
46 |
+
$query = $searchPhraseAttributeValue . " " . $query;
|
47 |
+
}
|
48 |
+
|
49 |
+
break;
|
50 |
+
|
51 |
+
case "category_and_parent":
|
52 |
+
|
53 |
+
$categories = $this->getParentCategories();
|
54 |
+
|
55 |
+
if(count($categories) < 3) break;
|
56 |
+
|
57 |
+
$parentId = $this->getParentId();
|
58 |
+
$category = $categories[$parentId];
|
59 |
+
$searchPhraseAttributeValue = $this->salesperson_get_search_phrase($category);
|
60 |
+
$query = $searchPhraseAttributeValue . " " . $query;
|
61 |
+
|
62 |
+
break;
|
63 |
+
|
64 |
+
case "category_and_root":
|
65 |
+
|
66 |
+
$categories = $this->getParentCategories();
|
67 |
+
|
68 |
+
if(count($categories) < 3) break;
|
69 |
+
|
70 |
+
$aParentIds = $this->getParentIds();
|
71 |
+
$branchRootId = $aParentIds[2];
|
72 |
+
$category = $categories[$branchRootId];
|
73 |
+
$searchPhraseAttributeValue = $this->salesperson_get_search_phrase($category);
|
74 |
+
$query = $searchPhraseAttributeValue . " " . $query;
|
75 |
+
|
76 |
+
break;
|
77 |
+
}
|
78 |
+
|
79 |
+
return $query;
|
80 |
+
}
|
81 |
+
|
82 |
+
private function salesperson_get_search_phrase($category){
|
83 |
+
$category->load($category->getId());
|
84 |
+
$att_code = 'salesperson_search_phrase';
|
85 |
+
$att_value = $category->getData($att_code);
|
86 |
+
|
87 |
+
if($att_value=='') return $category->getName();
|
88 |
+
else return $att_value;
|
89 |
+
}
|
90 |
+
|
91 |
+
}
|
app/code/community/Celebros/Salesperson/Model/Catalog/Url.php
ADDED
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Model_Catalog_Url extends Mage_Catalog_Model_Url
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Generate either id path, request path or target path for product and/or category
|
15 |
+
*
|
16 |
+
* For generating id or system path, either product or category is required
|
17 |
+
* For generating request path - category is required
|
18 |
+
* $parentPath used only for generating category path
|
19 |
+
*
|
20 |
+
* @param string $type
|
21 |
+
* @param Varien_Object $product
|
22 |
+
* @param Varien_Object $category
|
23 |
+
* @param string $parentPath
|
24 |
+
* @return string
|
25 |
+
* @throws Mage_Core_Exception
|
26 |
+
*/
|
27 |
+
|
28 |
+
/*protected function _refreshCategoryRewrites(Varien_Object $category, $parentPath = null, $refreshProducts = true)
|
29 |
+
{
|
30 |
+
$res = parent::_refreshCategoryRewrites($category, $parentPath, $refreshProducts);
|
31 |
+
|
32 |
+
//Check if we need to overide the category rewrite behaviour
|
33 |
+
$navToSearchEnabled = Mage::getStoreConfigFlag('salesperson/nav_to_search_settings/nav_to_search');
|
34 |
+
if($navToSearchEnabled) {
|
35 |
+
$query = $this->_getSalespersonQuery($category);
|
36 |
+
$targetPath = Mage::helper('salesperson')->getResultUrl($query, $bAddIndexSuffix = true, $bRelativePath = true);
|
37 |
+
|
38 |
+
$rewrite = Mage::getModel('core/url_rewrite')->load($this->_rewrite->getId());
|
39 |
+
$rewrite->setTargetPath($targetPath)
|
40 |
+
->save();
|
41 |
+
}
|
42 |
+
|
43 |
+
return $res;
|
44 |
+
}
|
45 |
+
|
46 |
+
protected function _saveRewriteHistory($rewriteData, $rewrite)
|
47 |
+
{
|
48 |
+
if ($rewrite instanceof Varien_Object && $rewrite->getId()
|
49 |
+
&& trim($rewriteData['request_path']) == trim($rewrite->getRequestPath()))
|
50 |
+
return $this;
|
51 |
+
else
|
52 |
+
return parent::_saveRewriteHistory($rewriteData, $rewrite);
|
53 |
+
}
|
54 |
+
|
55 |
+
public function generatePath($type = 'target', $product = null, $category = null, $parentPath = null)
|
56 |
+
{
|
57 |
+
//Check if we need to overide the category rewrite behaviour
|
58 |
+
$bOverride = !$product && $category && Mage::getStoreConfigFlag('salesperson/nav_to_search_settings/nav_to_search');
|
59 |
+
if($bOverride)
|
60 |
+
return $this->_generateCelebrosCategoryPath($type, $product, $category, $parentPath);
|
61 |
+
else
|
62 |
+
return parent::generatePath($type, $product, $category, $parentPath);
|
63 |
+
}
|
64 |
+
|
65 |
+
private function _generateCelebrosCategoryPath($type = 'target', $product = null, $category = null, $parentPath = null)
|
66 |
+
{
|
67 |
+
$path = "";
|
68 |
+
|
69 |
+
switch($type){
|
70 |
+
case 'target':
|
71 |
+
$query = $this->_getSalespersonQuery($category);
|
72 |
+
$path = Mage::helper('salesperson')->getResultUrl($query, $bAddIndexSuffix = true, $bRelativePath = true);
|
73 |
+
break;
|
74 |
+
case 'request':
|
75 |
+
$path = parent::generatePath($type, $product, $category, $parentPath);
|
76 |
+
//Zend_Debug::dump($path);
|
77 |
+
$pathWithSpace = $path . " ";
|
78 |
+
$oldPath = $this->_rewrite->getRequestPath();
|
79 |
+
//Add space to request path so it will be persisted
|
80 |
+
if($path == $oldPath) $path = $pathWithSpace;
|
81 |
+
|
82 |
+
//$path = substr($path,strlen($path)-1, 1) == " " ? substr($path,0, strlen($path)-1) : $path . " ";
|
83 |
+
break;
|
84 |
+
default:
|
85 |
+
$path = parent::generatePath($type, $product, $category, $parentPath);
|
86 |
+
}
|
87 |
+
|
88 |
+
return $path;
|
89 |
+
}*/
|
90 |
+
|
91 |
+
/*public function refreshRewrites($storeId = null)
|
92 |
+
{
|
93 |
+
parent::refreshRewrites($storeId);
|
94 |
+
Mage::helper('salesperson')->updateCategoriesUrlRewrites();
|
95 |
+
}*/
|
96 |
+
|
97 |
+
public function generatePath($type = 'target', $product = null, $category = null, $parentPath = null)
|
98 |
+
{
|
99 |
+
if($this->_isNeedTargetPathOverrideByCelebros($type, $product, $category, $parentPath))
|
100 |
+
return $this->_generateCelebrosCategoryTargetPath($category);
|
101 |
+
else
|
102 |
+
return parent::generatePath($type, $product, $category, $parentPath);
|
103 |
+
}
|
104 |
+
|
105 |
+
private function _generateCelebrosCategoryTargetPath($category)
|
106 |
+
{
|
107 |
+
$query = Mage::helper('salesperson')->getCategoryRewriteQuery($category);
|
108 |
+
$targetPath = Mage::helper('salesperson')->getResultUrl($query, $bAddIndexSuffix = true, $bRelativePath = true);
|
109 |
+
return $targetPath;
|
110 |
+
}
|
111 |
+
|
112 |
+
private function _isNeedTargetPathOverrideByCelebros($type = 'target', $product = null, $category = null, $parentPath = null) {
|
113 |
+
//Check if we need to overide the category rewrite behaviour
|
114 |
+
$bOverrideTargetPath = ($type == 'target') && !$product && $category && Mage::getStoreConfigFlag('salesperson/nav_to_search_settings/nav_to_search');
|
115 |
+
|
116 |
+
if(!$bOverrideTargetPath) return $bOverrideTargetPath;
|
117 |
+
|
118 |
+
$rewrite = $this->_rewrite;
|
119 |
+
if ($rewrite && $rewrite->getId() && $this->generatePath('request', $product, $category, $parentPath) == $rewrite->getRequestPath()) {
|
120 |
+
$bOverrideTargetPath = false;
|
121 |
+
}
|
122 |
+
|
123 |
+
return $bOverrideTargetPath;
|
124 |
+
}
|
125 |
+
|
126 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Model/Convert/Adapter/Io.php
RENAMED
@@ -1,157 +1,157 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Model_Convert_Adapter_Io extends Mage_Dataflow_Model_Convert_Adapter_Abstract
|
11 |
-
{
|
12 |
-
/**
|
13 |
-
* @return Varien_Io_Abstract
|
14 |
-
*/
|
15 |
-
public function getResource($forWrite = false)
|
16 |
-
{
|
17 |
-
if (!$this->_resource) {
|
18 |
-
$type = Mage::getStoreConfig('salesperson/export_settings/type');
|
19 |
-
if ($type == ''){
|
20 |
-
$type = $this->getVar('type', 'file');
|
21 |
-
}
|
22 |
-
$className = 'Varien_Io_'.ucwords($type);
|
23 |
-
$this->_resource = new $className();
|
24 |
-
|
25 |
-
$isError = false;
|
26 |
-
|
27 |
-
$ioConfig = $this->getVars();
|
28 |
-
if (Mage::getStoreConfig('salesperson/export_settings/type')!= ''){
|
29 |
-
$ioConfig['type'] = Mage::getStoreConfig('salesperson/export_settings/type');
|
30 |
-
}
|
31 |
-
if (Mage::getStoreConfig('salesperson/export_settings/ftp_host')!= ''){
|
32 |
-
$ioConfig['host'] = Mage::getStoreConfig('salesperson/export_settings/ftp_host');
|
33 |
-
}
|
34 |
-
if (Mage::getStoreConfig('salesperson/export_settings/ftp_port')!= ''){
|
35 |
-
$ioConfig['port'] = Mage::getStoreConfig('salesperson/export_settings/ftp_port');
|
36 |
-
}
|
37 |
-
if (Mage::getStoreConfig('salesperson/export_settings/ftp_user')!= ''){
|
38 |
-
$ioConfig['user'] = Mage::getStoreConfig('salesperson/export_settings/ftp_user');
|
39 |
-
}
|
40 |
-
if (Mage::getStoreConfig('salesperson/export_settings/ftp_password')!= ''){
|
41 |
-
$ioConfig['password'] = Mage::getStoreConfig('salesperson/export_settings/ftp_password');
|
42 |
-
}
|
43 |
-
if (Mage::getStoreConfig('salesperson/export_settings/passive')!= ''){
|
44 |
-
$ioConfig['passive'] = Mage::getStoreConfig('salesperson/export_settings/passive');
|
45 |
-
}
|
46 |
-
switch ($type) {
|
47 |
-
case 'file':
|
48 |
-
$t_path = Mage::getStoreConfig('salesperson/export_settings/path');
|
49 |
-
if (preg_match('#^'.preg_quote(DS, '#').'#', $t_path) ||
|
50 |
-
preg_match('#^[a-z]:'.preg_quote(DS, '#') .'#i', $t_path)) {
|
51 |
-
|
52 |
-
$path = $this->_resource->getCleanPath($t_path);
|
53 |
-
}
|
54 |
-
else {
|
55 |
-
$baseDir = Mage::getBaseDir();
|
56 |
-
$path = $this->_resource->getCleanPath($baseDir . DS . trim($t_path, DS));
|
57 |
-
}
|
58 |
-
$this->_resource->checkAndCreateFolder($path);
|
59 |
-
|
60 |
-
$realPath = realpath($path);
|
61 |
-
|
62 |
-
if (!$isError && $realPath === false) {
|
63 |
-
$message = Mage::helper('dataflow')->__('Destination folder "%s" does not exist or not access to create', Mage::getStoreConfig('salesperson/export_settings/path'));
|
64 |
-
Mage::throwException($message);
|
65 |
-
}
|
66 |
-
elseif (!$isError && !is_dir($realPath)) {
|
67 |
-
$message = Mage::helper('dataflow')->__('Destination folder "%s" is not a directory', $realPath);
|
68 |
-
Mage::throwException($message);
|
69 |
-
}
|
70 |
-
elseif (!$isError) {
|
71 |
-
if ($forWrite && !is_writeable($realPath)) {
|
72 |
-
$message = Mage::helper('dataflow')->__('Destination folder "%s" is not a writeable', $realPath);
|
73 |
-
Mage::throwException($message);
|
74 |
-
}
|
75 |
-
else {
|
76 |
-
$ioConfig['path'] = rtrim($realPath, DS);
|
77 |
-
}
|
78 |
-
}
|
79 |
-
break;
|
80 |
-
default:
|
81 |
-
$ioConfig['path'] = rtrim(Mage::getStoreConfig('salesperson/export_settings/path'), '/');
|
82 |
-
break;
|
83 |
-
}
|
84 |
-
|
85 |
-
if ($isError) {
|
86 |
-
return false;
|
87 |
-
}
|
88 |
-
try {
|
89 |
-
$this->_resource->open($ioConfig);
|
90 |
-
} catch (Exception $e) {
|
91 |
-
$message = Mage::helper('dataflow')->__('Error occured during file opening: "%s"', $e->getMessage());
|
92 |
-
Mage::throwException($message);
|
93 |
-
}
|
94 |
-
}
|
95 |
-
return $this->_resource;
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* Load data
|
100 |
-
*
|
101 |
-
* @return Mage_Dataflow_Model_Convert_Adapter_Io
|
102 |
-
*/
|
103 |
-
public function load()
|
104 |
-
{
|
105 |
-
if (!$this->getResource()) {
|
106 |
-
return $this;
|
107 |
-
}
|
108 |
-
|
109 |
-
$batchModel = Mage::getSingleton('dataflow/batch');
|
110 |
-
$destFile = $batchModel->getIoAdapter()->getFile(true);
|
111 |
-
|
112 |
-
$result = $this->getResource()->read($this->getVar('filename'), $destFile);
|
113 |
-
$filename = $this->getResource()->pwd() . '/' . $this->getVar('filename');
|
114 |
-
if (false === $result) {
|
115 |
-
$message = Mage::helper('dataflow')->__('Could not load file: "%s"', $filename);
|
116 |
-
Mage::throwException($message);
|
117 |
-
} else {
|
118 |
-
$message = Mage::helper('dataflow')->__('Loaded successfully: "%s"', $filename);
|
119 |
-
$this->addException($message);
|
120 |
-
}
|
121 |
-
|
122 |
-
$this->setData($result);
|
123 |
-
return $this;
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Save result to destionation file from temporary
|
128 |
-
*
|
129 |
-
* @return Mage_Dataflow_Model_Convert_Adapter_Io
|
130 |
-
*/
|
131 |
-
public function save()
|
132 |
-
{
|
133 |
-
if (!$this->getResource(true)) {
|
134 |
-
return $this;
|
135 |
-
}
|
136 |
-
|
137 |
-
$batchModel = Mage::getSingleton('dataflow/batch');
|
138 |
-
|
139 |
-
$dataFile = $batchModel->getIoAdapter()->getFile(true);
|
140 |
-
|
141 |
-
$filename = $this->getVar('filename', 'products.txt');
|
142 |
-
|
143 |
-
$result = $this->getResource()->write($filename, $dataFile, 0777);
|
144 |
-
|
145 |
-
if (false === $result) {
|
146 |
-
$message = Mage::helper('dataflow')->__('Could not save file: %s', $filename);
|
147 |
-
Mage::throwException($message);
|
148 |
-
} else {
|
149 |
-
$message = Mage::helper('dataflow')->__('Saved successfully: "%s" [%d byte(s)]', $filename, $batchModel->getIoAdapter()->getFileSize());
|
150 |
-
if ($this->getVar('link')) {
|
151 |
-
$message .= Mage::helper('dataflow')->__('<a href="%s" target="_blank">Link</a>', $this->getVar('link'));
|
152 |
-
}
|
153 |
-
$this->addException($message);
|
154 |
-
}
|
155 |
-
return $this;
|
156 |
-
}
|
157 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Model_Convert_Adapter_Io extends Mage_Dataflow_Model_Convert_Adapter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* @return Varien_Io_Abstract
|
14 |
+
*/
|
15 |
+
public function getResource($forWrite = false)
|
16 |
+
{
|
17 |
+
if (!$this->_resource) {
|
18 |
+
$type = Mage::getStoreConfig('salesperson/export_settings/type');
|
19 |
+
if ($type == ''){
|
20 |
+
$type = $this->getVar('type', 'file');
|
21 |
+
}
|
22 |
+
$className = 'Varien_Io_'.ucwords($type);
|
23 |
+
$this->_resource = new $className();
|
24 |
+
|
25 |
+
$isError = false;
|
26 |
+
|
27 |
+
$ioConfig = $this->getVars();
|
28 |
+
if (Mage::getStoreConfig('salesperson/export_settings/type')!= ''){
|
29 |
+
$ioConfig['type'] = Mage::getStoreConfig('salesperson/export_settings/type');
|
30 |
+
}
|
31 |
+
if (Mage::getStoreConfig('salesperson/export_settings/ftp_host')!= ''){
|
32 |
+
$ioConfig['host'] = Mage::getStoreConfig('salesperson/export_settings/ftp_host');
|
33 |
+
}
|
34 |
+
if (Mage::getStoreConfig('salesperson/export_settings/ftp_port')!= ''){
|
35 |
+
$ioConfig['port'] = Mage::getStoreConfig('salesperson/export_settings/ftp_port');
|
36 |
+
}
|
37 |
+
if (Mage::getStoreConfig('salesperson/export_settings/ftp_user')!= ''){
|
38 |
+
$ioConfig['user'] = Mage::getStoreConfig('salesperson/export_settings/ftp_user');
|
39 |
+
}
|
40 |
+
if (Mage::getStoreConfig('salesperson/export_settings/ftp_password')!= ''){
|
41 |
+
$ioConfig['password'] = Mage::getStoreConfig('salesperson/export_settings/ftp_password');
|
42 |
+
}
|
43 |
+
if (Mage::getStoreConfig('salesperson/export_settings/passive')!= ''){
|
44 |
+
$ioConfig['passive'] = Mage::getStoreConfig('salesperson/export_settings/passive');
|
45 |
+
}
|
46 |
+
switch ($type) {
|
47 |
+
case 'file':
|
48 |
+
$t_path = Mage::getStoreConfig('salesperson/export_settings/path');
|
49 |
+
if (preg_match('#^'.preg_quote(DS, '#').'#', $t_path) ||
|
50 |
+
preg_match('#^[a-z]:'.preg_quote(DS, '#') .'#i', $t_path)) {
|
51 |
+
|
52 |
+
$path = $this->_resource->getCleanPath($t_path);
|
53 |
+
}
|
54 |
+
else {
|
55 |
+
$baseDir = Mage::getBaseDir();
|
56 |
+
$path = $this->_resource->getCleanPath($baseDir . DS . trim($t_path, DS));
|
57 |
+
}
|
58 |
+
$this->_resource->checkAndCreateFolder($path);
|
59 |
+
|
60 |
+
$realPath = realpath($path);
|
61 |
+
|
62 |
+
if (!$isError && $realPath === false) {
|
63 |
+
$message = Mage::helper('dataflow')->__('Destination folder "%s" does not exist or not access to create', Mage::getStoreConfig('salesperson/export_settings/path'));
|
64 |
+
Mage::throwException($message);
|
65 |
+
}
|
66 |
+
elseif (!$isError && !is_dir($realPath)) {
|
67 |
+
$message = Mage::helper('dataflow')->__('Destination folder "%s" is not a directory', $realPath);
|
68 |
+
Mage::throwException($message);
|
69 |
+
}
|
70 |
+
elseif (!$isError) {
|
71 |
+
if ($forWrite && !is_writeable($realPath)) {
|
72 |
+
$message = Mage::helper('dataflow')->__('Destination folder "%s" is not a writeable', $realPath);
|
73 |
+
Mage::throwException($message);
|
74 |
+
}
|
75 |
+
else {
|
76 |
+
$ioConfig['path'] = rtrim($realPath, DS);
|
77 |
+
}
|
78 |
+
}
|
79 |
+
break;
|
80 |
+
default:
|
81 |
+
$ioConfig['path'] = rtrim(Mage::getStoreConfig('salesperson/export_settings/path'), '/');
|
82 |
+
break;
|
83 |
+
}
|
84 |
+
|
85 |
+
if ($isError) {
|
86 |
+
return false;
|
87 |
+
}
|
88 |
+
try {
|
89 |
+
$this->_resource->open($ioConfig);
|
90 |
+
} catch (Exception $e) {
|
91 |
+
$message = Mage::helper('dataflow')->__('Error occured during file opening: "%s"', $e->getMessage());
|
92 |
+
Mage::throwException($message);
|
93 |
+
}
|
94 |
+
}
|
95 |
+
return $this->_resource;
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Load data
|
100 |
+
*
|
101 |
+
* @return Mage_Dataflow_Model_Convert_Adapter_Io
|
102 |
+
*/
|
103 |
+
public function load()
|
104 |
+
{
|
105 |
+
if (!$this->getResource()) {
|
106 |
+
return $this;
|
107 |
+
}
|
108 |
+
|
109 |
+
$batchModel = Mage::getSingleton('dataflow/batch');
|
110 |
+
$destFile = $batchModel->getIoAdapter()->getFile(true);
|
111 |
+
|
112 |
+
$result = $this->getResource()->read($this->getVar('filename'), $destFile);
|
113 |
+
$filename = $this->getResource()->pwd() . '/' . $this->getVar('filename');
|
114 |
+
if (false === $result) {
|
115 |
+
$message = Mage::helper('dataflow')->__('Could not load file: "%s"', $filename);
|
116 |
+
Mage::throwException($message);
|
117 |
+
} else {
|
118 |
+
$message = Mage::helper('dataflow')->__('Loaded successfully: "%s"', $filename);
|
119 |
+
$this->addException($message);
|
120 |
+
}
|
121 |
+
|
122 |
+
$this->setData($result);
|
123 |
+
return $this;
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Save result to destionation file from temporary
|
128 |
+
*
|
129 |
+
* @return Mage_Dataflow_Model_Convert_Adapter_Io
|
130 |
+
*/
|
131 |
+
public function save()
|
132 |
+
{
|
133 |
+
if (!$this->getResource(true)) {
|
134 |
+
return $this;
|
135 |
+
}
|
136 |
+
|
137 |
+
$batchModel = Mage::getSingleton('dataflow/batch');
|
138 |
+
|
139 |
+
$dataFile = $batchModel->getIoAdapter()->getFile(true);
|
140 |
+
|
141 |
+
$filename = $this->getVar('filename', 'products.txt');
|
142 |
+
|
143 |
+
$result = $this->getResource()->write($filename, $dataFile, 0777);
|
144 |
+
|
145 |
+
if (false === $result) {
|
146 |
+
$message = Mage::helper('dataflow')->__('Could not save file: %s', $filename);
|
147 |
+
Mage::throwException($message);
|
148 |
+
} else {
|
149 |
+
$message = Mage::helper('dataflow')->__('Saved successfully: "%s" [%d byte(s)]', $filename, $batchModel->getIoAdapter()->getFileSize());
|
150 |
+
if ($this->getVar('link')) {
|
151 |
+
$message .= Mage::helper('dataflow')->__('<a href="%s" target="_blank">Link</a>', $this->getVar('link'));
|
152 |
+
}
|
153 |
+
$this->addException($message);
|
154 |
+
}
|
155 |
+
return $this;
|
156 |
+
}
|
157 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Model/Convert/Mapper/Column.php
RENAMED
@@ -1,175 +1,175 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Model_Convert_Mapper_Column extends Mage_Dataflow_Model_Convert_Mapper_Abstract
|
11 |
-
{
|
12 |
-
/**
|
13 |
-
* Dataflow batch model
|
14 |
-
*
|
15 |
-
* @var Mage_Dataflow_Model_Batch
|
16 |
-
*/
|
17 |
-
protected $_batch;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Dataflow batch export model
|
21 |
-
*
|
22 |
-
* @var Mage_Dataflow_Model_Batch_Export
|
23 |
-
*/
|
24 |
-
protected $_batchExport;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Dataflow batch import model
|
28 |
-
*
|
29 |
-
* @var Mage_Dataflow_Model_Batch_Import
|
30 |
-
*/
|
31 |
-
protected $_batchImport;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Retrieve Batch model singleton
|
35 |
-
*
|
36 |
-
* @return Mage_Dataflow_Model_Batch
|
37 |
-
*/
|
38 |
-
public function getBatchModel()
|
39 |
-
{
|
40 |
-
if (is_null($this->_batch)) {
|
41 |
-
$this->_batch = Mage::getSingleton('dataflow/batch');
|
42 |
-
}
|
43 |
-
return $this->_batch;
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Retrieve Batch export model
|
48 |
-
*
|
49 |
-
* @return Mage_Dataflow_Model_Batch_Export
|
50 |
-
*/
|
51 |
-
public function getBatchExportModel()
|
52 |
-
{
|
53 |
-
if (is_null($this->_batchExport)) {
|
54 |
-
$object = Mage::getModel('dataflow/batch_export');
|
55 |
-
$this->_batchExport = Varien_Object_Cache::singleton()->save($object);
|
56 |
-
}
|
57 |
-
return Varien_Object_Cache::singleton()->load($this->_batchExport);
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Retrieve Batch import model
|
62 |
-
*
|
63 |
-
* @return Mage_Dataflow_Model_Import_Export
|
64 |
-
*/
|
65 |
-
public function getBatchImportModel()
|
66 |
-
{
|
67 |
-
if (is_null($this->_batchImport)) {
|
68 |
-
$object = Mage::getModel('dataflow/batch_import');
|
69 |
-
$this->_batchImport = Varien_Object_Cache::singleton()->save($object);
|
70 |
-
}
|
71 |
-
return Varien_Object_Cache::singleton()->load($this->_batchImport);
|
72 |
-
}
|
73 |
-
|
74 |
-
public function map()
|
75 |
-
{
|
76 |
-
$batchModel = $this->getBatchModel();
|
77 |
-
$batchExport = $this->getBatchExportModel();
|
78 |
-
|
79 |
-
$batchExportIds = $batchExport
|
80 |
-
->setBatchId($this->getBatchModel()->getId())
|
81 |
-
->getIdCollection();
|
82 |
-
|
83 |
-
$onlySpecified = (bool)$this->getVar('_only_specified') === true;
|
84 |
-
|
85 |
-
if (!$onlySpecified) {
|
86 |
-
foreach ($batchExportIds as $batchExportId) {
|
87 |
-
$batchExport->load($batchExportId);
|
88 |
-
$batchModel->parseFieldList($batchExport->getBatchData());
|
89 |
-
}
|
90 |
-
|
91 |
-
return $this;
|
92 |
-
}
|
93 |
-
|
94 |
-
if ($this->getVar('map') && is_array($this->getVar('map'))) {
|
95 |
-
$attributesToSelect = $this->getVar('map');
|
96 |
-
}
|
97 |
-
else {
|
98 |
-
$attributesToSelect = array();
|
99 |
-
}
|
100 |
-
|
101 |
-
if (!$attributesToSelect) {
|
102 |
-
$this->getBatchExportModel()
|
103 |
-
->setBatchId($this->getBatchModel()->getId())
|
104 |
-
->deleteCollection();
|
105 |
-
|
106 |
-
Mage::throwException(Mage::helper('dataflow')->__('Error field mapping! Fields list for mapping is not defined'));
|
107 |
-
}
|
108 |
-
|
109 |
-
foreach ($batchExportIds as $batchExportId) {
|
110 |
-
$batchExport = $this->getBatchExportModel()->load($batchExportId);
|
111 |
-
$row = $batchExport->getBatchData();
|
112 |
-
|
113 |
-
$newRow = array();
|
114 |
-
foreach ($attributesToSelect as $field => $mapField) {
|
115 |
-
if (isset($row[$field])){
|
116 |
-
if (preg_match('/{{is_filterable}}{{is_searchable}}/', $row[$field])){
|
117 |
-
$row[$field] = preg_replace('/{{is_filterable}}{{is_searchable}}/', '', $row[$field], 1);
|
118 |
-
}
|
119 |
-
elseif (preg_match('/{{is_filterable}}/', $row[$field])){
|
120 |
-
$row[$field] = preg_replace('/{{is_filterable}}/', '', $row[$field], 1);
|
121 |
-
}
|
122 |
-
elseif (preg_match('/{{is_searchable}}/', $row[$field])){
|
123 |
-
$row[$field] = preg_replace('/{{is_searchable}}/', '', $row[$field], 1);
|
124 |
-
}
|
125 |
-
$newRow[$mapField] = $row[$field];
|
126 |
-
}
|
127 |
-
else {
|
128 |
-
$newRow[$mapField] = null;
|
129 |
-
}
|
130 |
-
}
|
131 |
-
|
132 |
-
/* Add any filterable / searchable attribute to the map */
|
133 |
-
foreach($row as $field => $val){
|
134 |
-
$attr = array();
|
135 |
-
if (preg_match('/{{is_filterable}}{{is_searchable}}/', $val)){
|
136 |
-
$val = preg_replace('/{{is_filterable}}{{is_searchable}}/', '', $val, 1);
|
137 |
-
$attr['field'] = $field;
|
138 |
-
$attr['val'] = $val;
|
139 |
-
// print ($field ." => ". $val)."<br/>";
|
140 |
-
}
|
141 |
-
elseif (preg_match('/{{is_filterable}}/', $val)){
|
142 |
-
$val = preg_replace('/{{is_filterable}}/', '', $val, 1);
|
143 |
-
$attr['field'] = $field;
|
144 |
-
$attr['val'] = $val;
|
145 |
-
// print ($field ." => ". $val)."<br/>";
|
146 |
-
}
|
147 |
-
elseif (preg_match('/{{is_searchable}}/', $val)){
|
148 |
-
$val = preg_replace('/{{is_searchable}}/', '', $val, 1);
|
149 |
-
$attr['field'] = $field;
|
150 |
-
$attr['val'] = $val;
|
151 |
-
// print ($field ." => ". $val)."<br/>";
|
152 |
-
}
|
153 |
-
if (!empty($attr)){
|
154 |
-
// Set the new field with the c:<field>:<<type>> structure
|
155 |
-
// if (!key_exists('c:'.$attr['field'].':string', $newRow) && !key_exists($attr['field'], $newRow)) {
|
156 |
-
// $newRow['c:'.$attr['field'].':string'] = $attr['val'];
|
157 |
-
// }
|
158 |
-
// Set Clean fields names structure
|
159 |
-
if (!key_exists($attr['field'], $newRow)){
|
160 |
-
$newRow[$attr['field']] = $attr['val'];
|
161 |
-
}
|
162 |
-
}
|
163 |
-
}
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
$batchExport->setBatchData($newRow)
|
168 |
-
->setStatus(1)
|
169 |
-
->save();
|
170 |
-
$this->getBatchModel()->parseFieldList($batchExport->getBatchData());
|
171 |
-
}
|
172 |
-
|
173 |
-
return $this;
|
174 |
-
}
|
175 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Model_Convert_Mapper_Column extends Mage_Dataflow_Model_Convert_Mapper_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Dataflow batch model
|
14 |
+
*
|
15 |
+
* @var Mage_Dataflow_Model_Batch
|
16 |
+
*/
|
17 |
+
protected $_batch;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Dataflow batch export model
|
21 |
+
*
|
22 |
+
* @var Mage_Dataflow_Model_Batch_Export
|
23 |
+
*/
|
24 |
+
protected $_batchExport;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Dataflow batch import model
|
28 |
+
*
|
29 |
+
* @var Mage_Dataflow_Model_Batch_Import
|
30 |
+
*/
|
31 |
+
protected $_batchImport;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Retrieve Batch model singleton
|
35 |
+
*
|
36 |
+
* @return Mage_Dataflow_Model_Batch
|
37 |
+
*/
|
38 |
+
public function getBatchModel()
|
39 |
+
{
|
40 |
+
if (is_null($this->_batch)) {
|
41 |
+
$this->_batch = Mage::getSingleton('dataflow/batch');
|
42 |
+
}
|
43 |
+
return $this->_batch;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Retrieve Batch export model
|
48 |
+
*
|
49 |
+
* @return Mage_Dataflow_Model_Batch_Export
|
50 |
+
*/
|
51 |
+
public function getBatchExportModel()
|
52 |
+
{
|
53 |
+
if (is_null($this->_batchExport)) {
|
54 |
+
$object = Mage::getModel('dataflow/batch_export');
|
55 |
+
$this->_batchExport = Varien_Object_Cache::singleton()->save($object);
|
56 |
+
}
|
57 |
+
return Varien_Object_Cache::singleton()->load($this->_batchExport);
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Retrieve Batch import model
|
62 |
+
*
|
63 |
+
* @return Mage_Dataflow_Model_Import_Export
|
64 |
+
*/
|
65 |
+
public function getBatchImportModel()
|
66 |
+
{
|
67 |
+
if (is_null($this->_batchImport)) {
|
68 |
+
$object = Mage::getModel('dataflow/batch_import');
|
69 |
+
$this->_batchImport = Varien_Object_Cache::singleton()->save($object);
|
70 |
+
}
|
71 |
+
return Varien_Object_Cache::singleton()->load($this->_batchImport);
|
72 |
+
}
|
73 |
+
|
74 |
+
public function map()
|
75 |
+
{
|
76 |
+
$batchModel = $this->getBatchModel();
|
77 |
+
$batchExport = $this->getBatchExportModel();
|
78 |
+
|
79 |
+
$batchExportIds = $batchExport
|
80 |
+
->setBatchId($this->getBatchModel()->getId())
|
81 |
+
->getIdCollection();
|
82 |
+
|
83 |
+
$onlySpecified = (bool)$this->getVar('_only_specified') === true;
|
84 |
+
|
85 |
+
if (!$onlySpecified) {
|
86 |
+
foreach ($batchExportIds as $batchExportId) {
|
87 |
+
$batchExport->load($batchExportId);
|
88 |
+
$batchModel->parseFieldList($batchExport->getBatchData());
|
89 |
+
}
|
90 |
+
|
91 |
+
return $this;
|
92 |
+
}
|
93 |
+
|
94 |
+
if ($this->getVar('map') && is_array($this->getVar('map'))) {
|
95 |
+
$attributesToSelect = $this->getVar('map');
|
96 |
+
}
|
97 |
+
else {
|
98 |
+
$attributesToSelect = array();
|
99 |
+
}
|
100 |
+
|
101 |
+
if (!$attributesToSelect) {
|
102 |
+
$this->getBatchExportModel()
|
103 |
+
->setBatchId($this->getBatchModel()->getId())
|
104 |
+
->deleteCollection();
|
105 |
+
|
106 |
+
Mage::throwException(Mage::helper('dataflow')->__('Error field mapping! Fields list for mapping is not defined'));
|
107 |
+
}
|
108 |
+
|
109 |
+
foreach ($batchExportIds as $batchExportId) {
|
110 |
+
$batchExport = $this->getBatchExportModel()->load($batchExportId);
|
111 |
+
$row = $batchExport->getBatchData();
|
112 |
+
|
113 |
+
$newRow = array();
|
114 |
+
foreach ($attributesToSelect as $field => $mapField) {
|
115 |
+
if (isset($row[$field])){
|
116 |
+
if (preg_match('/{{is_filterable}}{{is_searchable}}/', $row[$field])){
|
117 |
+
$row[$field] = preg_replace('/{{is_filterable}}{{is_searchable}}/', '', $row[$field], 1);
|
118 |
+
}
|
119 |
+
elseif (preg_match('/{{is_filterable}}/', $row[$field])){
|
120 |
+
$row[$field] = preg_replace('/{{is_filterable}}/', '', $row[$field], 1);
|
121 |
+
}
|
122 |
+
elseif (preg_match('/{{is_searchable}}/', $row[$field])){
|
123 |
+
$row[$field] = preg_replace('/{{is_searchable}}/', '', $row[$field], 1);
|
124 |
+
}
|
125 |
+
$newRow[$mapField] = $row[$field];
|
126 |
+
}
|
127 |
+
else {
|
128 |
+
$newRow[$mapField] = null;
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
/* Add any filterable / searchable attribute to the map */
|
133 |
+
foreach($row as $field => $val){
|
134 |
+
$attr = array();
|
135 |
+
if (preg_match('/{{is_filterable}}{{is_searchable}}/', $val)){
|
136 |
+
$val = preg_replace('/{{is_filterable}}{{is_searchable}}/', '', $val, 1);
|
137 |
+
$attr['field'] = $field;
|
138 |
+
$attr['val'] = $val;
|
139 |
+
// print ($field ." => ". $val)."<br/>";
|
140 |
+
}
|
141 |
+
elseif (preg_match('/{{is_filterable}}/', $val)){
|
142 |
+
$val = preg_replace('/{{is_filterable}}/', '', $val, 1);
|
143 |
+
$attr['field'] = $field;
|
144 |
+
$attr['val'] = $val;
|
145 |
+
// print ($field ." => ". $val)."<br/>";
|
146 |
+
}
|
147 |
+
elseif (preg_match('/{{is_searchable}}/', $val)){
|
148 |
+
$val = preg_replace('/{{is_searchable}}/', '', $val, 1);
|
149 |
+
$attr['field'] = $field;
|
150 |
+
$attr['val'] = $val;
|
151 |
+
// print ($field ." => ". $val)."<br/>";
|
152 |
+
}
|
153 |
+
if (!empty($attr)){
|
154 |
+
// Set the new field with the c:<field>:<<type>> structure
|
155 |
+
// if (!key_exists('c:'.$attr['field'].':string', $newRow) && !key_exists($attr['field'], $newRow)) {
|
156 |
+
// $newRow['c:'.$attr['field'].':string'] = $attr['val'];
|
157 |
+
// }
|
158 |
+
// Set Clean fields names structure
|
159 |
+
if (!key_exists($attr['field'], $newRow)){
|
160 |
+
$newRow[$attr['field']] = $attr['val'];
|
161 |
+
}
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
|
166 |
+
|
167 |
+
$batchExport->setBatchData($newRow)
|
168 |
+
->setStatus(1)
|
169 |
+
->save();
|
170 |
+
$this->getBatchModel()->parseFieldList($batchExport->getBatchData());
|
171 |
+
}
|
172 |
+
|
173 |
+
return $this;
|
174 |
+
}
|
175 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Model/Convert/Parser/Product.php
RENAMED
@@ -1,218 +1,218 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Model_Convert_Parser_Product
|
11 |
-
extends Mage_Catalog_Model_Convert_Parser_Product
|
12 |
-
{
|
13 |
-
protected $_store;
|
14 |
-
protected $_storeId;
|
15 |
-
|
16 |
-
public function getStore()
|
17 |
-
{
|
18 |
-
if (is_null($this->_store)) {
|
19 |
-
try {
|
20 |
-
$store = Mage::app()->getStore(Mage::getStoreConfig('salesperson/export_settings/store_id'));
|
21 |
-
}
|
22 |
-
catch (Exception $e) {
|
23 |
-
$this->addException(Mage::helper('catalog')->__('Invalid store specified please check the configuration'), Varien_Convert_Exception::FATAL);
|
24 |
-
throw $e;
|
25 |
-
}
|
26 |
-
$this->_store = $store;
|
27 |
-
}
|
28 |
-
return $this->_store;
|
29 |
-
}
|
30 |
-
|
31 |
-
public function getStoreId()
|
32 |
-
{
|
33 |
-
if (is_null($this->_storeId)) {
|
34 |
-
$this->_storeId = $this->getStore()->getId();
|
35 |
-
}
|
36 |
-
return $this->_storeId;
|
37 |
-
}
|
38 |
-
/**
|
39 |
-
* Unparse (prepare data) loaded products
|
40 |
-
*
|
41 |
-
* @return Mage_Catalog_Model_Convert_Parser_Product
|
42 |
-
*/
|
43 |
-
public function unparse()
|
44 |
-
{
|
45 |
-
$entityIds = $this->getData();
|
46 |
-
|
47 |
-
foreach ($entityIds as $i => $entityId) {
|
48 |
-
|
49 |
-
|
50 |
-
->setData(array())
|
51 |
-
->load($entityId)
|
52 |
-
|
53 |
-
$product = $this->getProductModel()
|
54 |
-
->reset()
|
55 |
-
->setStoreId($this->getStoreId())
|
56 |
-
->load($entityId);
|
57 |
-
$this->setProductTypeInstance($product);
|
58 |
-
|
59 |
-
/* Get Product Rating and Calculate Avrage */
|
60 |
-
|
61 |
-
$ratingResourceModel = new Celebros_Salesperson_Model_Mysql4_Qwiser();
|
62 |
-
$ratingPercents = $ratingResourceModel->getRateingByEntityId($product->getEntityId());
|
63 |
-
|
64 |
-
$productRating = 0;
|
65 |
-
foreach ($ratingPercents as $rating){
|
66 |
-
$productRating += (int)$rating['percent'];
|
67 |
-
}
|
68 |
-
if ($productRating != 0){
|
69 |
-
$productRating /= count($ratingPercents);
|
70 |
-
}
|
71 |
-
|
72 |
-
if (
|
73 |
-
$this->setProductTypeInstance($product);
|
74 |
-
/* @var $product Mage_Catalog_Model_Product */
|
75 |
-
|
76 |
-
$position = Mage::helper('catalog')->__('Line %d, SKU: %s', ($i+1), $product->getSku());
|
77 |
-
$this->setPosition($position);
|
78 |
-
|
79 |
-
$row = array(
|
80 |
-
'store' => $this->getStore()->getCode(),
|
81 |
-
'websites' => '',
|
82 |
-
'attribute_set' => $this->getAttributeSetName($product->getEntityTypeId(), $product->getAttributeSetId()),
|
83 |
-
'type' => $product->getTypeId(),
|
84 |
-
'category' => '',
|
85 |
-
'status' => '',
|
86 |
-
'rating' => $productRating,
|
87 |
-
'id' => $product->getId(),
|
88 |
-
'price' => ''
|
89 |
-
);
|
90 |
-
|
91 |
-
/*product status*/
|
92 |
-
|
93 |
-
|
94 |
-
/*categories names */
|
95 |
-
|
96 |
-
$categoryNames = array();
|
97 |
-
foreach ($product->getCategoryIds() as $categoryId){
|
98 |
-
$categoryName = Mage::getModel('catalog/category')->load($categoryId)->getName();
|
99 |
-
$categoryNames[$categoryName] = $categoryName;
|
100 |
-
}
|
101 |
-
$row['category'] = join(',', $categoryNames);
|
102 |
-
|
103 |
-
/*websites codes*/
|
104 |
-
if ($this->getStore()->getCode() == Mage_Core_Model_Store::ADMIN_CODE) {
|
105 |
-
$websiteCodes = array();
|
106 |
-
foreach ($product->getWebsiteIds() as $websiteId) {
|
107 |
-
$websiteCode = Mage::app()->getWebsite($websiteId)->getCode();
|
108 |
-
$websiteCodes[$websiteCode] = $websiteCode;
|
109 |
-
}
|
110 |
-
$row['websites'] = join(',', $websiteCodes);
|
111 |
-
}
|
112 |
-
else {
|
113 |
-
$row['websites'] = $this->getStore()->getWebsite()->getCode();
|
114 |
-
if ($this->getVar('url_field')) {
|
115 |
-
$row['url'] = $product->getProductUrl(false);
|
116 |
-
}
|
117 |
-
}
|
118 |
-
|
119 |
-
if($product->getData('type_id') == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE){
|
120 |
-
$resource = Mage::getSingleton('core/resource');
|
121 |
-
$DB = $resource->getConnection('catalog_read');
|
122 |
-
$prefix = Mage::getConfig()->getNode('global/resources/db/table_prefix');
|
123 |
-
$sql = "SELECT * FROM ".$prefix."catalog_product_index_price WHERE `entity_id` ='".$product->getId()."' GROUP BY `entity_id`";
|
124 |
-
$result = $DB->fetchAll($sql);
|
125 |
-
$row['price'] = $result[0]['min_price'];
|
126 |
-
}else{
|
127 |
-
$row['price'] = $product->getFinalPrice();
|
128 |
-
}
|
129 |
-
|
130 |
-
foreach ($product->getData() as $field => $value) {
|
131 |
-
if (in_array($field, $this->_systemFields) || is_object($value)) {
|
132 |
-
continue;
|
133 |
-
}
|
134 |
-
$attribute = $this->getAttribute($field);
|
135 |
-
if (!$attribute) {
|
136 |
-
continue;
|
137 |
-
}
|
138 |
-
|
139 |
-
if ($attribute->usesSource()) {
|
140 |
-
$option = $attribute->getSource()->getOptionText($value);
|
141 |
-
if ($value && empty($option)) {
|
142 |
-
$message = Mage::helper('catalog')->__("Invalid option id specified for %s (%s), skipping the record", $field, $value);
|
143 |
-
$this->addException($message, Mage_Dataflow_Model_Convert_Exception::ERROR);
|
144 |
-
continue;
|
145 |
-
}
|
146 |
-
if (is_array($option)) {
|
147 |
-
$value = join(self::MULTI_DELIMITER, $option);
|
148 |
-
} else {
|
149 |
-
$value = $option;
|
150 |
-
}
|
151 |
-
unset($option);
|
152 |
-
}
|
153 |
-
elseif (is_array($value)) {
|
154 |
-
continue;
|
155 |
-
}
|
156 |
-
|
157 |
-
$row[$field] = $value;
|
158 |
-
}
|
159 |
-
|
160 |
-
/* Check if there is an Indexable Attribute that is not selected and add it to the array*/
|
161 |
-
|
162 |
-
$attributes = $product->getAttributes();
|
163 |
-
foreach ($attributes as $attribute){
|
164 |
-
if($attribute->getIsFilterable()){
|
165 |
-
if (key_exists($attribute->getData('attribute_code'), $row)){
|
166 |
-
$row[$attribute->getData('attribute_code')] = $row[$attribute->getData('attribute_code')].'{{is_filterable}}';
|
167 |
-
}
|
168 |
-
}
|
169 |
-
if($attribute->getIsSearchable()){
|
170 |
-
if (key_exists($attribute->getData('attribute_code'), $row)){
|
171 |
-
$row[$attribute->getData('attribute_code')] = $row[$attribute->getData('attribute_code')].'{{is_searchable}}';
|
172 |
-
}
|
173 |
-
}
|
174 |
-
}
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
if ($stockItem = $product->getStockItem()) {
|
179 |
-
foreach ($stockItem->getData() as $field => $value) {
|
180 |
-
if (in_array($field, $this->_systemFields) || is_object($value)) {
|
181 |
-
continue;
|
182 |
-
}
|
183 |
-
$row[$field] = $value;
|
184 |
-
}
|
185 |
-
}
|
186 |
-
|
187 |
-
foreach ($this->_imageFields as $field) {
|
188 |
-
if (isset($row[$field]) && $row[$field] == 'no_selection') {
|
189 |
-
$row[$field] = null;
|
190 |
-
}
|
191 |
-
}
|
192 |
-
|
193 |
-
/* EXPORTS TIER PRICING */
|
194 |
-
#$_tierPrices = Mage::getModel('bundle/product_price')->getTierPrice("",$product);
|
195 |
-
#print_r($product->getTierPrice());
|
196 |
-
$row['tier_prices'] = "";
|
197 |
-
#$incoming_tierps = $product->getTierPrice();
|
198 |
-
$incoming_tierps = $product->getData('tier_price');
|
199 |
-
#print_r($incoming_tierps);
|
200 |
-
if(is_array($incoming_tierps)) {
|
201 |
-
foreach($incoming_tierps as $tier_str){
|
202 |
-
#print_r($tier_str);
|
203 |
-
$row['tier_prices'] .= $tier_str['cust_group'] . "=" . round($tier_str['price_qty']) . "=" . $tier_str['price'] . "|";
|
204 |
-
}
|
205 |
-
}
|
206 |
-
|
207 |
-
$batchExport = $this->getBatchExportModel()
|
208 |
-
->setId(null)
|
209 |
-
->setBatchId($this->getBatchModel()->getId())
|
210 |
-
->setBatchData($row)
|
211 |
-
->setStatus(1)
|
212 |
-
->save();
|
213 |
-
}
|
214 |
-
}
|
215 |
-
|
216 |
-
return $this;
|
217 |
-
}
|
218 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Model_Convert_Parser_Product
|
11 |
+
extends Mage_Catalog_Model_Convert_Parser_Product
|
12 |
+
{
|
13 |
+
protected $_store;
|
14 |
+
protected $_storeId;
|
15 |
+
|
16 |
+
public function getStore()
|
17 |
+
{
|
18 |
+
if (is_null($this->_store)) {
|
19 |
+
try {
|
20 |
+
$store = Mage::app()->getStore(Mage::getStoreConfig('salesperson/export_settings/store_id'));
|
21 |
+
}
|
22 |
+
catch (Exception $e) {
|
23 |
+
$this->addException(Mage::helper('catalog')->__('Invalid store specified please check the configuration'), Varien_Convert_Exception::FATAL);
|
24 |
+
throw $e;
|
25 |
+
}
|
26 |
+
$this->_store = $store;
|
27 |
+
}
|
28 |
+
return $this->_store;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getStoreId()
|
32 |
+
{
|
33 |
+
if (is_null($this->_storeId)) {
|
34 |
+
$this->_storeId = $this->getStore()->getId();
|
35 |
+
}
|
36 |
+
return $this->_storeId;
|
37 |
+
}
|
38 |
+
/**
|
39 |
+
* Unparse (prepare data) loaded products
|
40 |
+
*
|
41 |
+
* @return Mage_Catalog_Model_Convert_Parser_Product
|
42 |
+
*/
|
43 |
+
public function unparse()
|
44 |
+
{
|
45 |
+
$entityIds = $this->getData();
|
46 |
+
|
47 |
+
foreach ($entityIds as $i => $entityId) {
|
48 |
+
|
49 |
+
/*$allproduct = $this->getProductModel()
|
50 |
+
->setData(array())
|
51 |
+
->load($entityId);*/
|
52 |
+
|
53 |
+
$product = $this->getProductModel()
|
54 |
+
->reset()
|
55 |
+
->setStoreId($this->getStoreId())
|
56 |
+
->load($entityId);
|
57 |
+
$this->setProductTypeInstance($product);
|
58 |
+
|
59 |
+
/* Get Product Rating and Calculate Avrage */
|
60 |
+
|
61 |
+
$ratingResourceModel = new Celebros_Salesperson_Model_Mysql4_Qwiser();
|
62 |
+
$ratingPercents = $ratingResourceModel->getRateingByEntityId($product->getEntityId());
|
63 |
+
|
64 |
+
$productRating = 0;
|
65 |
+
foreach ($ratingPercents as $rating){
|
66 |
+
$productRating += (int)$rating['percent'];
|
67 |
+
}
|
68 |
+
if ($productRating != 0){
|
69 |
+
$productRating /= count($ratingPercents);
|
70 |
+
}
|
71 |
+
|
72 |
+
if (str_pos($product->getAttributeText('visibility'), 'Search')!==false) {
|
73 |
+
$this->setProductTypeInstance($product);
|
74 |
+
/* @var $product Mage_Catalog_Model_Product */
|
75 |
+
|
76 |
+
$position = Mage::helper('catalog')->__('Line %d, SKU: %s', ($i+1), $product->getSku());
|
77 |
+
$this->setPosition($position);
|
78 |
+
|
79 |
+
$row = array(
|
80 |
+
'store' => $this->getStore()->getCode(),
|
81 |
+
'websites' => '',
|
82 |
+
'attribute_set' => $this->getAttributeSetName($product->getEntityTypeId(), $product->getAttributeSetId()),
|
83 |
+
'type' => $product->getTypeId(),
|
84 |
+
'category' => '',
|
85 |
+
'status' => '',
|
86 |
+
'rating' => $productRating,
|
87 |
+
'id' => $product->getId(),
|
88 |
+
'price' => ''
|
89 |
+
);
|
90 |
+
|
91 |
+
/*product status*/
|
92 |
+
//$productStatus = $product->getData('status');
|
93 |
+
|
94 |
+
/*categories names */
|
95 |
+
|
96 |
+
$categoryNames = array();
|
97 |
+
foreach ($product->getCategoryIds() as $categoryId){
|
98 |
+
$categoryName = Mage::getModel('catalog/category')->load($categoryId)->getName();
|
99 |
+
$categoryNames[$categoryName] = $categoryName;
|
100 |
+
}
|
101 |
+
$row['category'] = join(',', $categoryNames);
|
102 |
+
|
103 |
+
/*websites codes*/
|
104 |
+
if ($this->getStore()->getCode() == Mage_Core_Model_Store::ADMIN_CODE) {
|
105 |
+
$websiteCodes = array();
|
106 |
+
foreach ($product->getWebsiteIds() as $websiteId) {
|
107 |
+
$websiteCode = Mage::app()->getWebsite($websiteId)->getCode();
|
108 |
+
$websiteCodes[$websiteCode] = $websiteCode;
|
109 |
+
}
|
110 |
+
$row['websites'] = join(',', $websiteCodes);
|
111 |
+
}
|
112 |
+
else {
|
113 |
+
$row['websites'] = $this->getStore()->getWebsite()->getCode();
|
114 |
+
if ($this->getVar('url_field')) {
|
115 |
+
$row['url'] = $product->getProductUrl(false);
|
116 |
+
}
|
117 |
+
}
|
118 |
+
|
119 |
+
if($product->getData('type_id') == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE){
|
120 |
+
$resource = Mage::getSingleton('core/resource');
|
121 |
+
$DB = $resource->getConnection('catalog_read');
|
122 |
+
$prefix = Mage::getConfig()->getNode('global/resources/db/table_prefix');
|
123 |
+
$sql = "SELECT * FROM ".$prefix."catalog_product_index_price WHERE `entity_id` ='".$product->getId()."' GROUP BY `entity_id`";
|
124 |
+
$result = $DB->fetchAll($sql);
|
125 |
+
$row['price'] = $result[0]['min_price'];
|
126 |
+
}else{
|
127 |
+
$row['price'] = $product->getFinalPrice();
|
128 |
+
}
|
129 |
+
|
130 |
+
foreach ($product->getData() as $field => $value) {
|
131 |
+
if (in_array($field, $this->_systemFields) || is_object($value)) {
|
132 |
+
continue;
|
133 |
+
}
|
134 |
+
$attribute = $this->getAttribute($field);
|
135 |
+
if (!$attribute) {
|
136 |
+
continue;
|
137 |
+
}
|
138 |
+
|
139 |
+
if ($attribute->usesSource()) {
|
140 |
+
$option = $attribute->getSource()->getOptionText($value);
|
141 |
+
if ($value && empty($option)) {
|
142 |
+
$message = Mage::helper('catalog')->__("Invalid option id specified for %s (%s), skipping the record", $field, $value);
|
143 |
+
$this->addException($message, Mage_Dataflow_Model_Convert_Exception::ERROR);
|
144 |
+
continue;
|
145 |
+
}
|
146 |
+
if (is_array($option)) {
|
147 |
+
$value = join(self::MULTI_DELIMITER, $option);
|
148 |
+
} else {
|
149 |
+
$value = $option;
|
150 |
+
}
|
151 |
+
unset($option);
|
152 |
+
}
|
153 |
+
elseif (is_array($value)) {
|
154 |
+
continue;
|
155 |
+
}
|
156 |
+
|
157 |
+
$row[$field] = $value;
|
158 |
+
}
|
159 |
+
|
160 |
+
/* Check if there is an Indexable Attribute that is not selected and add it to the array*/
|
161 |
+
|
162 |
+
$attributes = $product->getAttributes();
|
163 |
+
foreach ($attributes as $attribute){
|
164 |
+
if($attribute->getIsFilterable()){
|
165 |
+
if (key_exists($attribute->getData('attribute_code'), $row)){
|
166 |
+
$row[$attribute->getData('attribute_code')] = $row[$attribute->getData('attribute_code')].'{{is_filterable}}';
|
167 |
+
}
|
168 |
+
}
|
169 |
+
if($attribute->getIsSearchable()){
|
170 |
+
if (key_exists($attribute->getData('attribute_code'), $row)){
|
171 |
+
$row[$attribute->getData('attribute_code')] = $row[$attribute->getData('attribute_code')].'{{is_searchable}}';
|
172 |
+
}
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
|
177 |
+
|
178 |
+
if ($stockItem = $product->getStockItem()) {
|
179 |
+
foreach ($stockItem->getData() as $field => $value) {
|
180 |
+
if (in_array($field, $this->_systemFields) || is_object($value)) {
|
181 |
+
continue;
|
182 |
+
}
|
183 |
+
$row[$field] = $value;
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
+
foreach ($this->_imageFields as $field) {
|
188 |
+
if (isset($row[$field]) && $row[$field] == 'no_selection') {
|
189 |
+
$row[$field] = null;
|
190 |
+
}
|
191 |
+
}
|
192 |
+
|
193 |
+
/* EXPORTS TIER PRICING */
|
194 |
+
#$_tierPrices = Mage::getModel('bundle/product_price')->getTierPrice("",$product);
|
195 |
+
#print_r($product->getTierPrice());
|
196 |
+
$row['tier_prices'] = "";
|
197 |
+
#$incoming_tierps = $product->getTierPrice();
|
198 |
+
$incoming_tierps = $product->getData('tier_price');
|
199 |
+
#print_r($incoming_tierps);
|
200 |
+
if(is_array($incoming_tierps)) {
|
201 |
+
foreach($incoming_tierps as $tier_str){
|
202 |
+
#print_r($tier_str);
|
203 |
+
$row['tier_prices'] .= $tier_str['cust_group'] . "=" . round($tier_str['price_qty']) . "=" . $tier_str['price'] . "|";
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
$batchExport = $this->getBatchExportModel()
|
208 |
+
->setId(null)
|
209 |
+
->setBatchId($this->getBatchModel()->getId())
|
210 |
+
->setBatchData($row)
|
211 |
+
->setStatus(1)
|
212 |
+
->save();
|
213 |
+
}
|
214 |
+
}
|
215 |
+
|
216 |
+
return $this;
|
217 |
+
}
|
218 |
}
|
app/code/{local → community}/Celebros/Salesperson/Model/Layer.php
RENAMED
@@ -1,65 +1,65 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Model_Layer extends Mage_Catalog_Model_Layer
|
11 |
-
{
|
12 |
-
/**
|
13 |
-
* Get layer state key
|
14 |
-
*
|
15 |
-
* @return string
|
16 |
-
*/
|
17 |
-
public function getStateKey()
|
18 |
-
{
|
19 |
-
if ($this->_stateKey === null) {
|
20 |
-
$this->_stateKey = 'STORE_'.Mage::app()->getStore()->getId()
|
21 |
-
. '_CUSTGROUP_' . Mage::getSingleton('customer/session')->getCustomerGroupId();
|
22 |
-
}
|
23 |
-
|
24 |
-
return $this->_stateKey;
|
25 |
-
}
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Apply layer
|
29 |
-
* Method is colling after apply all filters, can be used
|
30 |
-
* for prepare some index data before getting information
|
31 |
-
* about existing intexes
|
32 |
-
*
|
33 |
-
* @return Mage_Catalog_Model_Layer
|
34 |
-
*/
|
35 |
-
public function apply()
|
36 |
-
{
|
37 |
-
$stateSuffix = '';
|
38 |
-
foreach ($this->getState()->getFilters() as $filterItem) {
|
39 |
-
$stateSuffix.= '_'.$filterItem['questionId']
|
40 |
-
. '=' . $filterItem['answers']->Items[0]->Id;
|
41 |
-
}
|
42 |
-
if (!empty($stateSuffix)) {
|
43 |
-
$this->_stateKey = $this->getStateKey().$stateSuffix;
|
44 |
-
}
|
45 |
-
return $this;
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Retrieve layer state object
|
50 |
-
*
|
51 |
-
* @return Mage_Catalog_Model_Layer_State
|
52 |
-
*/
|
53 |
-
public function getState()
|
54 |
-
{
|
55 |
-
$state = $this->getData('state');
|
56 |
-
if (is_null($state)) {
|
57 |
-
Varien_Profiler::start(__METHOD__);
|
58 |
-
$state = Mage::getModel('salesperson/layer_state');
|
59 |
-
$this->setData('state', $state);
|
60 |
-
Varien_Profiler::stop(__METHOD__);
|
61 |
-
}
|
62 |
-
return $state;
|
63 |
-
}
|
64 |
-
|
65 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Model_Layer extends Mage_Catalog_Model_Layer
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Get layer state key
|
14 |
+
*
|
15 |
+
* @return string
|
16 |
+
*/
|
17 |
+
public function getStateKey()
|
18 |
+
{
|
19 |
+
if ($this->_stateKey === null) {
|
20 |
+
$this->_stateKey = 'STORE_'.Mage::app()->getStore()->getId()
|
21 |
+
. '_CUSTGROUP_' . Mage::getSingleton('customer/session')->getCustomerGroupId();
|
22 |
+
}
|
23 |
+
|
24 |
+
return $this->_stateKey;
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Apply layer
|
29 |
+
* Method is colling after apply all filters, can be used
|
30 |
+
* for prepare some index data before getting information
|
31 |
+
* about existing intexes
|
32 |
+
*
|
33 |
+
* @return Mage_Catalog_Model_Layer
|
34 |
+
*/
|
35 |
+
public function apply()
|
36 |
+
{
|
37 |
+
$stateSuffix = '';
|
38 |
+
foreach ($this->getState()->getFilters() as $filterItem) {
|
39 |
+
$stateSuffix.= '_'.$filterItem['questionId']
|
40 |
+
. '=' . $filterItem['answers']->Items[0]->Id;
|
41 |
+
}
|
42 |
+
if (!empty($stateSuffix)) {
|
43 |
+
$this->_stateKey = $this->getStateKey().$stateSuffix;
|
44 |
+
}
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Retrieve layer state object
|
50 |
+
*
|
51 |
+
* @return Mage_Catalog_Model_Layer_State
|
52 |
+
*/
|
53 |
+
public function getState()
|
54 |
+
{
|
55 |
+
$state = $this->getData('state');
|
56 |
+
if (is_null($state)) {
|
57 |
+
Varien_Profiler::start(__METHOD__);
|
58 |
+
$state = Mage::getModel('salesperson/layer_state');
|
59 |
+
$this->setData('state', $state);
|
60 |
+
Varien_Profiler::stop(__METHOD__);
|
61 |
+
}
|
62 |
+
return $state;
|
63 |
+
}
|
64 |
+
|
65 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Model/Layer/State.php
RENAMED
@@ -1,66 +1,66 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Model_Layer_State extends Varien_Object
|
11 |
-
{
|
12 |
-
/**
|
13 |
-
* Add filter item to layer state
|
14 |
-
*
|
15 |
-
* @param Mage_Catalog_Model_Layer_Filter_Item $filter
|
16 |
-
* @return Mage_Catalog_Model_Layer_State
|
17 |
-
*/
|
18 |
-
public function addFilter($filter)
|
19 |
-
{
|
20 |
-
$filters = $this->getFilters();
|
21 |
-
$filters[] = $filter;
|
22 |
-
$this->setFilters($filters);
|
23 |
-
return $this;
|
24 |
-
}
|
25 |
-
|
26 |
-
public function removeFilter($answerId){
|
27 |
-
$filters = array();
|
28 |
-
foreach($this->getFilters() as $filter){
|
29 |
-
if($filter['answers']->Items[0]->Id == $answerId){
|
30 |
-
continue;
|
31 |
-
}
|
32 |
-
$filters[] = $filter;
|
33 |
-
}
|
34 |
-
$this->setFilters($filters);
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Set layer state filter items
|
39 |
-
*
|
40 |
-
* @param array $filters
|
41 |
-
* @return Mage_Catalog_Model_Layer_State
|
42 |
-
*/
|
43 |
-
public function setFilters($filters)
|
44 |
-
{
|
45 |
-
if (!is_array($filters)) {
|
46 |
-
Mage::throwException(Mage::helper('salesperson')->__('Filters must be as array'));
|
47 |
-
}
|
48 |
-
$this->setData('filters', $filters);
|
49 |
-
return $this;
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Get applied to layer filter items
|
54 |
-
*
|
55 |
-
* @return array
|
56 |
-
*/
|
57 |
-
public function getFilters()
|
58 |
-
{
|
59 |
-
$filters = $this->getData('filters');
|
60 |
-
if (is_null($filters)) {
|
61 |
-
$filters = array();
|
62 |
-
$this->setData('filters', $filters);
|
63 |
-
}
|
64 |
-
return $filters;
|
65 |
-
}
|
66 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Model_Layer_State extends Varien_Object
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Add filter item to layer state
|
14 |
+
*
|
15 |
+
* @param Mage_Catalog_Model_Layer_Filter_Item $filter
|
16 |
+
* @return Mage_Catalog_Model_Layer_State
|
17 |
+
*/
|
18 |
+
public function addFilter($filter)
|
19 |
+
{
|
20 |
+
$filters = $this->getFilters();
|
21 |
+
$filters[] = $filter;
|
22 |
+
$this->setFilters($filters);
|
23 |
+
return $this;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function removeFilter($answerId){
|
27 |
+
$filters = array();
|
28 |
+
foreach($this->getFilters() as $filter){
|
29 |
+
if($filter['answers']->Items[0]->Id == $answerId){
|
30 |
+
continue;
|
31 |
+
}
|
32 |
+
$filters[] = $filter;
|
33 |
+
}
|
34 |
+
$this->setFilters($filters);
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Set layer state filter items
|
39 |
+
*
|
40 |
+
* @param array $filters
|
41 |
+
* @return Mage_Catalog_Model_Layer_State
|
42 |
+
*/
|
43 |
+
public function setFilters($filters)
|
44 |
+
{
|
45 |
+
if (!is_array($filters)) {
|
46 |
+
Mage::throwException(Mage::helper('salesperson')->__('Filters must be as array'));
|
47 |
+
}
|
48 |
+
$this->setData('filters', $filters);
|
49 |
+
return $this;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Get applied to layer filter items
|
54 |
+
*
|
55 |
+
* @return array
|
56 |
+
*/
|
57 |
+
public function getFilters()
|
58 |
+
{
|
59 |
+
$filters = $this->getData('filters');
|
60 |
+
if (is_null($filters)) {
|
61 |
+
$filters = array();
|
62 |
+
$this->setData('filters', $filters);
|
63 |
+
}
|
64 |
+
return $filters;
|
65 |
+
}
|
66 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Model/Layout.php
RENAMED
@@ -1,129 +1,129 @@
|
|
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_Core
|
23 |
-
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Layout model
|
30 |
-
*
|
31 |
-
* @category Mage
|
32 |
-
* @package Mage_Core
|
33 |
-
*/
|
34 |
-
class Celebros_Salesperson_Model_Layout extends Mage_Core_Model_Layout
|
35 |
-
{
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Enter description here...
|
39 |
-
*
|
40 |
-
* @param Varien_Simplexml_Element $node
|
41 |
-
* @param Varien_Simplexml_Element $parent
|
42 |
-
* @return Mage_Core_Model_Layout
|
43 |
-
*/
|
44 |
-
protected function _generateAction($node, $parent)
|
45 |
-
{
|
46 |
-
if (isset($node['ifconfig']) && ($configPath = (string)$node['ifconfig'])) {
|
47 |
-
if (!Mage::getStoreConfigFlag($configPath)) {
|
48 |
-
return $this;
|
49 |
-
}
|
50 |
-
}
|
51 |
-
|
52 |
-
//
|
53 |
-
|
54 |
-
if (isset($node['ifright']) && ($configPath = (string)$node['ifright'])) {
|
55 |
-
if (Mage::getStoreConfig($configPath) != 'right') {
|
56 |
-
return $this;
|
57 |
-
}
|
58 |
-
}
|
59 |
-
if (isset($node['ifleft']) && ($configPath = (string)$node['ifleft'])) {
|
60 |
-
if (Mage::getStoreConfig($configPath) != 'left') {
|
61 |
-
return $this;
|
62 |
-
}
|
63 |
-
}
|
64 |
-
if (isset($node['iftop']) && ($configPath = (string)$node['iftop'])) {
|
65 |
-
if (Mage::getStoreConfig($configPath) != 'top') {
|
66 |
-
return $this;
|
67 |
-
}
|
68 |
-
}
|
69 |
-
|
70 |
-
//
|
71 |
-
|
72 |
-
$method = (string)$node['method'];
|
73 |
-
if (!empty($node['block'])) {
|
74 |
-
$parentName = (string)$node['block'];
|
75 |
-
} else {
|
76 |
-
$parentName = $parent->getBlockName();
|
77 |
-
}
|
78 |
-
|
79 |
-
$_profilerKey = 'BLOCK ACTION: '.$parentName.' -> '.$method;
|
80 |
-
Varien_Profiler::start($_profilerKey);
|
81 |
-
|
82 |
-
if (!empty($parentName)) {
|
83 |
-
$block = $this->getBlock($parentName);
|
84 |
-
}
|
85 |
-
if (!empty($block)) {
|
86 |
-
|
87 |
-
$args = (array)$node->children();
|
88 |
-
unset($args['@attributes']);
|
89 |
-
|
90 |
-
foreach ($args as $key => $arg) {
|
91 |
-
if (($arg instanceof Mage_Core_Model_Layout_Element)) {
|
92 |
-
if (isset($arg['helper'])) {
|
93 |
-
$helperName = explode('/', (string)$arg['helper']);
|
94 |
-
$helperMethod = array_pop($helperName);
|
95 |
-
$helperName = implode('/', $helperName);
|
96 |
-
$arg = $arg->asArray();
|
97 |
-
unset($arg['@']);
|
98 |
-
$args[$key] = call_user_func_array(array(Mage::helper($helperName), $helperMethod), $arg);
|
99 |
-
} else {
|
100 |
-
/**
|
101 |
-
* if there is no helper we hope that this is assoc array
|
102 |
-
*/
|
103 |
-
$arr = array();
|
104 |
-
foreach($arg as $subkey => $value) {
|
105 |
-
$arr[(string)$subkey] = $value->asArray();
|
106 |
-
}
|
107 |
-
if (!empty($arr)) {
|
108 |
-
$args[$key] = $arr;
|
109 |
-
}
|
110 |
-
}
|
111 |
-
}
|
112 |
-
}
|
113 |
-
|
114 |
-
if (isset($node['json'])) {
|
115 |
-
$json = explode(' ', (string)$node['json']);
|
116 |
-
foreach ($json as $arg) {
|
117 |
-
$args[$arg] = Mage::helper('core')->jsonDecode($args[$arg]);
|
118 |
-
}
|
119 |
-
}
|
120 |
-
|
121 |
-
$this->_translateLayoutNode($node, $args);
|
122 |
-
call_user_func_array(array($block, $method), $args);
|
123 |
-
}
|
124 |
-
|
125 |
-
Varien_Profiler::stop($_profilerKey);
|
126 |
-
|
127 |
-
return $this;
|
128 |
-
}
|
129 |
-
}
|
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_Core
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Layout model
|
30 |
+
*
|
31 |
+
* @category Mage
|
32 |
+
* @package Mage_Core
|
33 |
+
*/
|
34 |
+
class Celebros_Salesperson_Model_Layout extends Mage_Core_Model_Layout
|
35 |
+
{
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Enter description here...
|
39 |
+
*
|
40 |
+
* @param Varien_Simplexml_Element $node
|
41 |
+
* @param Varien_Simplexml_Element $parent
|
42 |
+
* @return Mage_Core_Model_Layout
|
43 |
+
*/
|
44 |
+
protected function _generateAction($node, $parent)
|
45 |
+
{
|
46 |
+
if (isset($node['ifconfig']) && ($configPath = (string)$node['ifconfig'])) {
|
47 |
+
if (!Mage::getStoreConfigFlag($configPath)) {
|
48 |
+
return $this;
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
//
|
53 |
+
|
54 |
+
if (isset($node['ifright']) && ($configPath = (string)$node['ifright'])) {
|
55 |
+
if (Mage::getStoreConfig($configPath) != 'right') {
|
56 |
+
return $this;
|
57 |
+
}
|
58 |
+
}
|
59 |
+
if (isset($node['ifleft']) && ($configPath = (string)$node['ifleft'])) {
|
60 |
+
if (Mage::getStoreConfig($configPath) != 'left') {
|
61 |
+
return $this;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
if (isset($node['iftop']) && ($configPath = (string)$node['iftop'])) {
|
65 |
+
if (Mage::getStoreConfig($configPath) != 'top') {
|
66 |
+
return $this;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
//
|
71 |
+
|
72 |
+
$method = (string)$node['method'];
|
73 |
+
if (!empty($node['block'])) {
|
74 |
+
$parentName = (string)$node['block'];
|
75 |
+
} else {
|
76 |
+
$parentName = $parent->getBlockName();
|
77 |
+
}
|
78 |
+
|
79 |
+
$_profilerKey = 'BLOCK ACTION: '.$parentName.' -> '.$method;
|
80 |
+
Varien_Profiler::start($_profilerKey);
|
81 |
+
|
82 |
+
if (!empty($parentName)) {
|
83 |
+
$block = $this->getBlock($parentName);
|
84 |
+
}
|
85 |
+
if (!empty($block)) {
|
86 |
+
|
87 |
+
$args = (array)$node->children();
|
88 |
+
unset($args['@attributes']);
|
89 |
+
|
90 |
+
foreach ($args as $key => $arg) {
|
91 |
+
if (($arg instanceof Mage_Core_Model_Layout_Element)) {
|
92 |
+
if (isset($arg['helper'])) {
|
93 |
+
$helperName = explode('/', (string)$arg['helper']);
|
94 |
+
$helperMethod = array_pop($helperName);
|
95 |
+
$helperName = implode('/', $helperName);
|
96 |
+
$arg = $arg->asArray();
|
97 |
+
unset($arg['@']);
|
98 |
+
$args[$key] = call_user_func_array(array(Mage::helper($helperName), $helperMethod), $arg);
|
99 |
+
} else {
|
100 |
+
/**
|
101 |
+
* if there is no helper we hope that this is assoc array
|
102 |
+
*/
|
103 |
+
$arr = array();
|
104 |
+
foreach($arg as $subkey => $value) {
|
105 |
+
$arr[(string)$subkey] = $value->asArray();
|
106 |
+
}
|
107 |
+
if (!empty($arr)) {
|
108 |
+
$args[$key] = $arr;
|
109 |
+
}
|
110 |
+
}
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
if (isset($node['json'])) {
|
115 |
+
$json = explode(' ', (string)$node['json']);
|
116 |
+
foreach ($json as $arg) {
|
117 |
+
$args[$arg] = Mage::helper('core')->jsonDecode($args[$arg]);
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
$this->_translateLayoutNode($node, $args);
|
122 |
+
call_user_func_array(array($block, $method), $args);
|
123 |
+
}
|
124 |
+
|
125 |
+
Varien_Profiler::stop($_profilerKey);
|
126 |
+
|
127 |
+
return $this;
|
128 |
+
}
|
129 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Model/Mapping.php
RENAMED
@@ -1,32 +1,32 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Celebros_Salesperson_Model_Mapping extends Mage_Core_Model_Abstract
|
4 |
-
{
|
5 |
-
private $_fieldsArray;
|
6 |
-
|
7 |
-
protected function _construct()
|
8 |
-
{
|
9 |
-
$this->_init('salesperson/mapping');
|
10 |
-
}
|
11 |
-
|
12 |
-
protected function _loadFieldsArray(){
|
13 |
-
$fieldsCollection = Mage::getSingleton("salesperson/mapping")->getCollection();
|
14 |
-
$this->_fieldsArray = array();
|
15 |
-
foreach($fieldsCollection as $field){
|
16 |
-
$this->_fieldsArray[$field->getCodeField()] = $field->getXmlField();
|
17 |
-
}
|
18 |
-
}
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Get Fields Array
|
22 |
-
*
|
23 |
-
* @return array
|
24 |
-
*/
|
25 |
-
public function getFieldsArray(){
|
26 |
-
if(!$this->_fieldsArray){
|
27 |
-
$this->_loadFieldsArray();
|
28 |
-
}
|
29 |
-
return $this->_fieldsArray;
|
30 |
-
}
|
31 |
-
|
32 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Celebros_Salesperson_Model_Mapping extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
private $_fieldsArray;
|
6 |
+
|
7 |
+
protected function _construct()
|
8 |
+
{
|
9 |
+
$this->_init('salesperson/mapping');
|
10 |
+
}
|
11 |
+
|
12 |
+
protected function _loadFieldsArray(){
|
13 |
+
$fieldsCollection = Mage::getSingleton("salesperson/mapping")->getCollection();
|
14 |
+
$this->_fieldsArray = array();
|
15 |
+
foreach($fieldsCollection as $field){
|
16 |
+
$this->_fieldsArray[$field->getCodeField()] = $field->getXmlField();
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Get Fields Array
|
22 |
+
*
|
23 |
+
* @return array
|
24 |
+
*/
|
25 |
+
public function getFieldsArray(){
|
26 |
+
if(!$this->_fieldsArray){
|
27 |
+
$this->_loadFieldsArray();
|
28 |
+
}
|
29 |
+
return $this->_fieldsArray;
|
30 |
+
}
|
31 |
+
|
32 |
}
|
app/code/{local → community}/Celebros/Salesperson/Model/Mysql4/Mapping.php
RENAMED
@@ -1,7 +1,7 @@
|
|
1 |
-
<?php
|
2 |
-
class Celebros_Salesperson_Model_Mysql4_Mapping extends Mage_Core_Model_Mysql4_Abstract{
|
3 |
-
protected function _construct()
|
4 |
-
{
|
5 |
-
$this->_init('salesperson/mapping', 'id');
|
6 |
-
}
|
7 |
}
|
1 |
+
<?php
|
2 |
+
class Celebros_Salesperson_Model_Mysql4_Mapping extends Mage_Core_Model_Mysql4_Abstract{
|
3 |
+
protected function _construct()
|
4 |
+
{
|
5 |
+
$this->_init('salesperson/mapping', 'id');
|
6 |
+
}
|
7 |
}
|
app/code/{local → community}/Celebros/Salesperson/Model/Mysql4/Mapping/Collection.php
RENAMED
@@ -1,8 +1,8 @@
|
|
1 |
-
<?php
|
2 |
-
class Celebros_Salesperson_Model_Mysql4_Mapping_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
3 |
-
protected function _construct()
|
4 |
-
{
|
5 |
-
$this->_init('salesperson/mapping');
|
6 |
-
$this->setOrder('xml_field', Varien_Data_Collection::SORT_ORDER_ASC);
|
7 |
-
}
|
8 |
}
|
1 |
+
<?php
|
2 |
+
class Celebros_Salesperson_Model_Mysql4_Mapping_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
3 |
+
protected function _construct()
|
4 |
+
{
|
5 |
+
$this->_init('salesperson/mapping');
|
6 |
+
$this->setOrder('xml_field', Varien_Data_Collection::SORT_ORDER_ASC);
|
7 |
+
}
|
8 |
}
|
app/code/{local → community}/Celebros/Salesperson/Model/Mysql4/Qwiser.php
RENAMED
@@ -1,31 +1,31 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Model_Mysql4_Qwiser extends Mage_Core_Model_Mysql4_Abstract
|
11 |
-
{
|
12 |
-
|
13 |
-
public function _construct()
|
14 |
-
{
|
15 |
-
$this->_init('rating/rating', 'rating_id');
|
16 |
-
}
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Get rating entity type id by code
|
20 |
-
*
|
21 |
-
* @param string $entityCode
|
22 |
-
* @return int
|
23 |
-
*/
|
24 |
-
public function getRateingByEntityId($entityId)
|
25 |
-
{
|
26 |
-
$select = $this->_getReadAdapter()->select()
|
27 |
-
->from( $this->getTable('rating_vote'), array('percent'))
|
28 |
-
->where('entity_pk_value = ?', $entityId);
|
29 |
-
return $this->_getReadAdapter()->fetchAll($select);
|
30 |
-
}
|
31 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Model_Mysql4_Qwiser extends Mage_Core_Model_Mysql4_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
public function _construct()
|
14 |
+
{
|
15 |
+
$this->_init('rating/rating', 'rating_id');
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Get rating entity type id by code
|
20 |
+
*
|
21 |
+
* @param string $entityCode
|
22 |
+
* @return int
|
23 |
+
*/
|
24 |
+
public function getRateingByEntityId($entityId)
|
25 |
+
{
|
26 |
+
$select = $this->_getReadAdapter()->select()
|
27 |
+
->from( $this->getTable('rating_vote'), array('percent'))
|
28 |
+
->where('entity_pk_value = ?', $entityId);
|
29 |
+
return $this->_getReadAdapter()->fetchAll($select);
|
30 |
+
}
|
31 |
}
|
app/code/{local → community}/Celebros/Salesperson/Model/Observer.php
RENAMED
@@ -1,1065 +1,1265 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
*
|
6 |
-
*
|
7 |
-
*
|
8 |
-
*
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
protected $
|
24 |
-
protected $
|
25 |
-
protected $
|
26 |
-
protected $
|
27 |
-
protected $
|
28 |
-
protected $
|
29 |
-
protected $
|
30 |
-
protected $
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
protected
|
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 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
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 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
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 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
);
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
$
|
311 |
-
|
312 |
-
$
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
if
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
$
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
$
|
345 |
-
|
346 |
-
|
347 |
-
$
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
$
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
$
|
428 |
-
|
429 |
-
|
430 |
-
$
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
$
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
$s.=str_replace("\r\n", " ", $this->content($product,$attributes,$cate,$typ,$chil,
|
458 |
-
|
459 |
-
|
460 |
-
$childrenName="";
|
461 |
-
}
|
462 |
-
|
463 |
-
//Flushing and cleaning
|
464 |
-
unset($products_collection);
|
465 |
-
fwrite($fh, $s);
|
466 |
-
unset($s);
|
467 |
-
$s = "";
|
468 |
-
}
|
469 |
-
}
|
470 |
-
|
471 |
-
|
472 |
-
$
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
$
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
$
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
$
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
public function
|
578 |
-
{
|
579 |
-
|
580 |
-
$
|
581 |
-
|
582 |
-
|
583 |
-
$
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
$
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
$
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
$
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
$
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
}
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
if($
|
729 |
-
|
730 |
-
$
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
$
|
736 |
-
$
|
737 |
-
|
738 |
-
}
|
739 |
-
}
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
$
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
}
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
{
|
775 |
-
|
776 |
-
}
|
777 |
-
|
778 |
-
|
779 |
-
return number_format($
|
780 |
-
}
|
781 |
-
|
782 |
-
public function
|
783 |
-
|
784 |
-
if($
|
785 |
-
|
786 |
-
$
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
}
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
$
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
$
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
{
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
}
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
if (
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
}
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
$
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
* @category Celebros
|
11 |
+
* @package Celebros_Salesperson
|
12 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
ini_set('display_errors', 1);
|
16 |
+
ini_set('memory_limit','1024M');
|
17 |
+
ini_set('max_execution_time',18000);
|
18 |
+
set_time_limit(18000);
|
19 |
+
|
20 |
+
//include_once("createZip.php");
|
21 |
+
class Celebros_Salesperson_Model_Observer
|
22 |
+
{
|
23 |
+
protected $_errors = array();
|
24 |
+
protected $_config;
|
25 |
+
protected $_conn;
|
26 |
+
protected $_read;
|
27 |
+
protected $_fDel;
|
28 |
+
protected $_fEnclose;
|
29 |
+
protected $_fPath;
|
30 |
+
protected $_fType;
|
31 |
+
protected $_fStore_id;
|
32 |
+
protected $_fStore;
|
33 |
+
protected $_fStore_module_enabled;
|
34 |
+
protected $_fProducts_Collection;
|
35 |
+
protected $_fProduct_Category_Matrix;
|
36 |
+
protected $_fSize;
|
37 |
+
protected $_updateStock;
|
38 |
+
protected $_flushRecordsCount = 500;
|
39 |
+
protected $_fileNameTxt = "products.txt";
|
40 |
+
protected $_fileNameZip = "products.zip";
|
41 |
+
protected $_getChildrenOfGroupProducts = true;
|
42 |
+
protected $_bUpload = true;
|
43 |
+
protected $_aProductPricingTiers;
|
44 |
+
protected $_bLargeExport = true;
|
45 |
+
|
46 |
+
public function __construct(){
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Retrieve salesperson session
|
51 |
+
*
|
52 |
+
* @return Mage_Catalog_Model_Session
|
53 |
+
*/
|
54 |
+
protected function _getSession()
|
55 |
+
{
|
56 |
+
return Mage::getSingleton('salesperson/session');
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Daily update catalog to salesperson server by cron
|
61 |
+
* This method is called from cron process, cron is workink in UTC time and
|
62 |
+
*
|
63 |
+
* @param Varien_Event_Observer $observer
|
64 |
+
* @return Celebros_Salesperson_Model_Observer
|
65 |
+
*/
|
66 |
+
public function catalogUpdate($observer)
|
67 |
+
{
|
68 |
+
$enabled = Mage::getStoreConfigFlag('salesperson/export_settings/cron_enabled');
|
69 |
+
/*$profileId = Mage::getStoreConfig('salesperson/export_settings/profile_id');*/
|
70 |
+
if($enabled) $this->export_celebros();
|
71 |
+
|
72 |
+
return $this;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Update stock after product update in the backend
|
77 |
+
*
|
78 |
+
* @param Varien_Event_Observer $observer
|
79 |
+
*/
|
80 |
+
public function updateStockConfig($observer){
|
81 |
+
if($this->_updateStock==1)
|
82 |
+
{
|
83 |
+
$event = $observer->getEvent();
|
84 |
+
$product = $event->getProduct();
|
85 |
+
$Stock =$product->getData('stock_data');
|
86 |
+
if(isset($Stock['is_in_stock']))
|
87 |
+
$isInStock=$Stock['is_in_stock'];
|
88 |
+
else
|
89 |
+
$isInStock=0;
|
90 |
+
$sku = $product->getSku();
|
91 |
+
if ((int)$isInStock == 0){
|
92 |
+
Mage::helper('salesperson')->getSalespersonApi()->RemoveProductFromStock($sku);
|
93 |
+
}
|
94 |
+
else {
|
95 |
+
Mage::helper('salesperson')->getSalespersonApi()->RestoreProductToStock($sku);
|
96 |
+
}
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Update stock after order checkout process in the front-end
|
103 |
+
*
|
104 |
+
* @param Varien_Event_Observer $observer $observer
|
105 |
+
*/
|
106 |
+
public function updateStockOrder($observer){
|
107 |
+
if($this->_updateStock==1)
|
108 |
+
{
|
109 |
+
$event = $observer->getEvent();
|
110 |
+
$order = $event->getOrder();
|
111 |
+
$productModel = Mage::getSingleton('catalog/product');
|
112 |
+
$itemModel = Mage::getSingleton('cataloginventory/stock_item');
|
113 |
+
foreach ($order->getAllItems() as $item){
|
114 |
+
$product_info = $item->getProductOptions();
|
115 |
+
$product_id = $product_info['info_buyRequest']['product'];
|
116 |
+
$product = $productModel->load($product_id);
|
117 |
+
$inventoery = $itemModel->loadByProduct($product);
|
118 |
+
$isInStock = $inventoery->getData('is_in_stock');
|
119 |
+
$sku = $product->getSku();
|
120 |
+
if ((int)$isInStock == 0){
|
121 |
+
Mage::helper('salesperson')->getSalespersonApi()->RemoveProductFromStock($sku);
|
122 |
+
}
|
123 |
+
else {
|
124 |
+
Mage::helper('salesperson')->getSalespersonApi()->RestoreProductToStock($sku);
|
125 |
+
}
|
126 |
+
}
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
public function export_celebros()
|
131 |
+
{
|
132 |
+
|
133 |
+
$export_start = (float) array_sum(explode(' ',microtime()));
|
134 |
+
$this->comments_style('header',0,0);
|
135 |
+
$this->comments_style('icon','Starting profile execution, please wait...','start');
|
136 |
+
$this->comments_style('warning','Warning: Please don\'t close window during importing/exporting data','warning');
|
137 |
+
flush();
|
138 |
+
|
139 |
+
$bCrossSellEnabled = Mage::getStoreConfigFlag('salesperson/crosssell_settings/crosssell_enabled');
|
140 |
+
if($bCrossSellEnabled) $this->export_orders_celebros();
|
141 |
+
|
142 |
+
//Connect to the database
|
143 |
+
$this->_read=Mage::getSingleton('core/resource')->getConnection('core_read');
|
144 |
+
|
145 |
+
// Reindex the URL rewrite table for relevant store views (Ones where
|
146 |
+
// nav2search is active
|
147 |
+
$this->url_rewrite_reindex();
|
148 |
+
|
149 |
+
if($this->_bLargeExport) {
|
150 |
+
$model=Mage::getModel('salesperson/ObserverLarge');
|
151 |
+
$model->export_celebros();
|
152 |
+
return;
|
153 |
+
}
|
154 |
+
|
155 |
+
//-------------------
|
156 |
+
//get the configuration
|
157 |
+
|
158 |
+
//---------------------
|
159 |
+
|
160 |
+
unset($product_category_ids);
|
161 |
+
|
162 |
+
$store_view_ids = $this->_read->fetchAll('SELECT store_id FROM '.$this->getTableName("core_store") . ' WHERE store_id <> 0'); //Added for multi store view purposes by Eli Sagy
|
163 |
+
|
164 |
+
foreach($store_view_ids as $store_view_id)
|
165 |
+
{
|
166 |
+
$export_store_start = (float) array_sum(explode(' ',microtime()));
|
167 |
+
$this->export_config($store_view_id['store_id']);
|
168 |
+
|
169 |
+
if(!$this->_fStore_export_enabled) continue;
|
170 |
+
|
171 |
+
$this->comments_style('icon','Store code: '.$this->_fStore->getCode().".",'Store');
|
172 |
+
|
173 |
+
|
174 |
+
|
175 |
+
// Check if to use flat tables for products
|
176 |
+
$cel_use_flat_tables=Mage::getStoreConfigFlag('salesperson/export_settings/flat_export_enabled');
|
177 |
+
$mage_flat_enabled=Mage::helper('catalog/product_flat')->isEnabled();
|
178 |
+
$use_flat_tables=($cel_use_flat_tables && $mage_flat_enabled);
|
179 |
+
|
180 |
+
if ($use_flat_tables)
|
181 |
+
$this->comments_style('info','Using flat tables.','Info');
|
182 |
+
else
|
183 |
+
$this->comments_style('info','Using EAV tables.','Info');
|
184 |
+
|
185 |
+
|
186 |
+
$dir = true;
|
187 |
+
|
188 |
+
if($this->_fPath!='')
|
189 |
+
{
|
190 |
+
if (!is_dir($this->_fPath)) $dir=@mkdir($this->_fPath,0777,true);
|
191 |
+
if (file_exists($this->_fPath. "/" . $this->_fileNameTxt)) unlink($this->_fPath . "/" . $this->_fileNameTxt);
|
192 |
+
$fh = fopen($this->_fPath . "/" . $this->_fileNameTxt, 'ab');
|
193 |
+
}
|
194 |
+
|
195 |
+
if(!$dir) {
|
196 |
+
$this->comments_style('error','Could not create the directory in that path','problemwith dir');
|
197 |
+
return;
|
198 |
+
}
|
199 |
+
|
200 |
+
$nameCategory=array();
|
201 |
+
$result = $this->getCategoryCollection($store_view_id['store_id']);
|
202 |
+
|
203 |
+
//Build category name look up and leaf paths with category ids
|
204 |
+
$categoryLookup = array();
|
205 |
+
$leafPaths = array();
|
206 |
+
foreach($result as $res)
|
207 |
+
{
|
208 |
+
$categoryId = $res->getId();
|
209 |
+
$categoryLookup[$categoryId] = str_replace(",", "&", $res->getName());
|
210 |
+
if(!$res->hasChildren()) $leafPaths[$categoryId] = $res->getPathIds();
|
211 |
+
}
|
212 |
+
|
213 |
+
//Build leaf paths with category names
|
214 |
+
foreach($leafPaths as $categoryId => $arrPath) {
|
215 |
+
|
216 |
+
for($i=1; $i < count($arrPath); $i++){
|
217 |
+
$ancestorId = $arrPath[$i];
|
218 |
+
if(!isset($categoryLookup[$ancestorId])) continue;
|
219 |
+
$categoryName = $categoryLookup[$ancestorId];
|
220 |
+
$nameCategory[$categoryId] = isset($nameCategory[$categoryId]) ?
|
221 |
+
$nameCategory[$categoryId] . ">" . $categoryName :
|
222 |
+
$categoryName;
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
unset($result);
|
227 |
+
|
228 |
+
$searchFilterAttrTable = Mage::helper('salesperson')->is_CE() && Mage::helper('salesperson')->is_1_3() ? "eav_attribute" : "catalog_eav_attribute";
|
229 |
+
|
230 |
+
//------------------------------------------
|
231 |
+
$configurProdAttVal=array();
|
232 |
+
|
233 |
+
$subSelect1 = $this->_read->select()
|
234 |
+
->from($this->getTableName("catalog_product_super_link"),
|
235 |
+
array('parent_id'))
|
236 |
+
->where('product_id = cpei.entity_id');
|
237 |
+
|
238 |
+
$subSelect2 = $this->_read->select()
|
239 |
+
->from($this->getTableName($searchFilterAttrTable),
|
240 |
+
array('attribute_id'))
|
241 |
+
->where('is_searchable = 1 OR is_filterable IN ( 1, 2 )');
|
242 |
+
|
243 |
+
$subSelect3 = $this->_read->select()
|
244 |
+
->distinct()
|
245 |
+
->from(array('cpei2' => $this->getTableName("catalog_product_entity_int")),
|
246 |
+
array('entity_id'))
|
247 |
+
->join(array('eet' => $this->getTableName("eav_entity_type")),
|
248 |
+
"eet.entity_type_id = cpei2.entity_type_id AND eet.entity_type_code='catalog_product'",
|
249 |
+
array())
|
250 |
+
->join(array('ea2' => $this->getTableName("eav_attribute")),
|
251 |
+
"ea2.attribute_id = cpei2.attribute_id AND ea2.attribute_code='status'",
|
252 |
+
array())
|
253 |
+
->where('cpei2.value = 2');
|
254 |
+
|
255 |
+
$select = $this->_read->select()
|
256 |
+
->distinct()
|
257 |
+
->from(array('eaov' => $this->getTableName("eav_attribute_option_value")),
|
258 |
+
array('value'))
|
259 |
+
->join(array('cpei' => $this->getTableName("catalog_product_entity_int")),
|
260 |
+
'eaov.option_id = cpei.value',
|
261 |
+
array())
|
262 |
+
->join(array('cpsa' => $this->getTableName("catalog_product_super_attribute")),
|
263 |
+
'cpei.attribute_id = cpsa.attribute_id',
|
264 |
+
array('product_id'))
|
265 |
+
->join(array('ea' => $this->getTableName("eav_attribute")),
|
266 |
+
'cpsa.attribute_id = ea.attribute_id',
|
267 |
+
array('attribute_code'))
|
268 |
+
->where('cpsa.product_id IN (?)', $subSelect1)
|
269 |
+
->where('cpsa.attribute_id IN (?)', $subSelect2)
|
270 |
+
->where('cpei.entity_id NOT IN (?)', $subSelect3);
|
271 |
+
|
272 |
+
$result = $this->_read->query($select);
|
273 |
+
|
274 |
+
foreach($result as $res)
|
275 |
+
{
|
276 |
+
if(!isset($configurProdAttVal[$res["product_id"]][$res["attribute_code"]]))
|
277 |
+
$configurProdAttVal[$res["product_id"]][$res["attribute_code"]]=$res["value"];
|
278 |
+
else
|
279 |
+
{
|
280 |
+
$configurProdAttVal[$res["product_id"]][$res["attribute_code"]].=",".$res["value"];
|
281 |
+
}
|
282 |
+
}
|
283 |
+
|
284 |
+
unset($result);
|
285 |
+
|
286 |
+
//--------------------------------------------------
|
287 |
+
|
288 |
+
//select the name of the attributes
|
289 |
+
$this->select_attributes($attributes);
|
290 |
+
|
291 |
+
//------------------------------------------------------
|
292 |
+
$products_collection=array();
|
293 |
+
$removeProducts=array();
|
294 |
+
$cate=4;
|
295 |
+
$typ=9;
|
296 |
+
$chil=10;
|
297 |
+
$childrenName="";
|
298 |
+
$num=0;
|
299 |
+
$s="";
|
300 |
+
|
301 |
+
//print the header
|
302 |
+
$s=$this->header($attributes,$cate,$typ,$chil);
|
303 |
+
|
304 |
+
//Begin the output
|
305 |
+
$sql='select min(cpe.entity_id ) as min, max( cpe.entity_id ) as max
|
306 |
+
from '.$this->getTableName("catalog_product_entity").' cpe
|
307 |
+
where cpe.type_id = "configurable"';
|
308 |
+
$result=$this->_read->fetchAll($sql);
|
309 |
+
|
310 |
+
$total_min = $result[0]["min"];
|
311 |
+
$total_max = $result[0]["max"];
|
312 |
+
if(!is_null($total_min))
|
313 |
+
{
|
314 |
+
$count=$total_max-$total_min+1;
|
315 |
+
$count=$count/$this->_flushRecordsCount;
|
316 |
+
if(!is_int($count)) $count=ceil($count);
|
317 |
+
$min = $total_min;
|
318 |
+
|
319 |
+
//select the product with the attributes
|
320 |
+
//-----------------------------
|
321 |
+
while($count>0)
|
322 |
+
{
|
323 |
+
$max=$min + $this->_flushRecordsCount -1;
|
324 |
+
|
325 |
+
if ($use_flat_tables)
|
326 |
+
{
|
327 |
+
Mage::getResourceSingleton('catalog/product_flat')->setStoreId($this->_fStore_id);
|
328 |
+
$products_collection=Mage::getModel("catalog/product")->getCollection();
|
329 |
+
}
|
330 |
+
else
|
331 |
+
{
|
332 |
+
$products_collection=Mage::getModel("catalog/product")->setStoreId($this->_fStore_id)->getCollection()->addStoreFilter($this->_fStore_id);
|
333 |
+
}
|
334 |
+
|
335 |
+
//Adding attributes to select
|
336 |
+
foreach($attributes as $key=>$value) $products_collection->addAttributeToSelect($key);
|
337 |
+
$products_collection->addAttributeToSelect("type_id");
|
338 |
+
//Adding attributes to filter
|
339 |
+
$products_collection->addAttributeToFilter("type_id","configurable");
|
340 |
+
$products_collection->addAttributeToFilter("visibility",array("neq"=>1));
|
341 |
+
$products_collection->addAttributeToFilter("status",array("eq"=>1));
|
342 |
+
$products_collection->addFieldToFilter("entity_id",array("from"=>$min,"to"=>$max));
|
343 |
+
|
344 |
+
$this->updateCategoriesMatrix($min, $max);
|
345 |
+
|
346 |
+
$min=$max+1;
|
347 |
+
$count--;
|
348 |
+
//print the content
|
349 |
+
$num+=count($products_collection);
|
350 |
+
|
351 |
+
foreach($products_collection as $product)
|
352 |
+
{
|
353 |
+
$id=$product->getentity_id();
|
354 |
+
$product = Mage::getModel('catalog/product')->load($id);
|
355 |
+
$sql='SELECT sku AS id FROM '.$this->getTableName("catalog_product_super_link").' INNER JOIN '.$this->getTableName("catalog_product_entity").' ON product_id = entity_id WHERE parent_id = '.$id;
|
356 |
+
$childProducts=$this->_read->fetchAll($sql);
|
357 |
+
foreach($childProducts as $child)
|
358 |
+
{
|
359 |
+
$childrenName.=$child["id"].',';
|
360 |
+
if(!in_array($child["id"],$removeProducts))
|
361 |
+
$removeProducts[]=$child["id"].',';
|
362 |
+
}
|
363 |
+
if($childrenName!="")
|
364 |
+
$childrenName=substr_replace($childrenName,"",strlen($childrenName)-1);
|
365 |
+
if(isset($configurProdAttVal[$id])){
|
366 |
+
$s.=str_replace("\r\n", " ", $this->content($product,$attributes,$cate,$typ,$chil,1,$configurProdAttVal[$id],$nameCategory,$childrenName));
|
367 |
+
}else{
|
368 |
+
$s.=str_replace("\r\n", " ", $this->content($product,$attributes,$cate,$typ,$chil,1,array(),$nameCategory,$childrenName));
|
369 |
+
}
|
370 |
+
$s.="\r\n";
|
371 |
+
$childrenName="";
|
372 |
+
}
|
373 |
+
|
374 |
+
//Flushing and cleaning
|
375 |
+
unset($products_collection);
|
376 |
+
fwrite($fh, $s);
|
377 |
+
unset($s);
|
378 |
+
$s = "";
|
379 |
+
}
|
380 |
+
}
|
381 |
+
|
382 |
+
//-------------------------------------------------------------------------------------------
|
383 |
+
$sql='SELECT min( cpe.entity_id ) AS min, max( cpe.entity_id ) AS max
|
384 |
+
FROM '.$this->getTableName("catalog_product_entity").' cpe
|
385 |
+
WHERE cpe.type_id <> "configurable"';
|
386 |
+
//AND cpev.store_id ='.$this->_fStore_id;/*Added for multi store view purposes by Eli Sagy*/
|
387 |
+
$result=$this->_read->fetchAll($sql);
|
388 |
+
$total_min = $result[0]["min"];
|
389 |
+
$total_max = $result[0]["max"];
|
390 |
+
|
391 |
+
if(!is_null($total_min))
|
392 |
+
{
|
393 |
+
$count=$total_max-$total_min+1;
|
394 |
+
$count=$count/$this->_flushRecordsCount;
|
395 |
+
if(!is_int($count)) $count=ceil($count);
|
396 |
+
$min = $total_min;
|
397 |
+
while($count>0)
|
398 |
+
{
|
399 |
+
$max=min($min + $this->_flushRecordsCount - 1, $total_max);
|
400 |
+
//echo "<br/>" . "max:" . $max;
|
401 |
+
|
402 |
+
if ($use_flat_tables)
|
403 |
+
{
|
404 |
+
Mage::getResourceSingleton('catalog/product_flat')->setStoreId($this->_fStore_id);
|
405 |
+
$products_collection=Mage::getModel("catalog/product")->getCollection();
|
406 |
+
}
|
407 |
+
else
|
408 |
+
{
|
409 |
+
$products_collection=Mage::getModel("catalog/product")->setStoreId($this->_fStore_id)->getCollection()->addStoreFilter($this->_fStore_id);
|
410 |
+
}
|
411 |
+
|
412 |
+
//Adding attributes to select
|
413 |
+
foreach($attributes as $key=>$value) $products_collection->addAttributeToSelect($key);
|
414 |
+
$products_collection->addAttributeToSelect("type_id");
|
415 |
+
//Adding attributes to filter
|
416 |
+
$products_collection->addAttributeToFilter("type_id",array("neq"=>"configurable"));
|
417 |
+
$products_collection->addAttributeToFilter("visibility",array("neq"=>1));
|
418 |
+
$products_collection->addAttributeToFilter("status",array("eq"=>1));
|
419 |
+
$products_collection->addFieldToFilter("entity_id",array("from"=>$min,"to"=>$max));
|
420 |
+
|
421 |
+
$this->updateCategoriesMatrix($min, $max);
|
422 |
+
|
423 |
+
$min=$max+1;
|
424 |
+
$count--;
|
425 |
+
//print the content
|
426 |
+
$num+=count($products_collection);
|
427 |
+
foreach($products_collection as $product)
|
428 |
+
{
|
429 |
+
$flg=0;
|
430 |
+
if($product->gettype_id()=="simple")
|
431 |
+
{
|
432 |
+
foreach($removeProducts as $removeProduct)
|
433 |
+
{
|
434 |
+
if($removeProduct===$product->getentity_id().",")
|
435 |
+
{
|
436 |
+
$flg=1;
|
437 |
+
$num--;
|
438 |
+
break;
|
439 |
+
}
|
440 |
+
}
|
441 |
+
}
|
442 |
+
if($flg===0)
|
443 |
+
{
|
444 |
+
$id=$product->getentity_id();
|
445 |
+
$product = Mage::getModel('catalog/product')->load($id);
|
446 |
+
if($product->gettype_id()=="grouped" && $this->_getChildrenOfGroupProducts)
|
447 |
+
{
|
448 |
+
$sql='SELECT sku AS id FROM '.$this->getTableName("catalog_product_link").' INNER JOIN '.$this->getTableName("catalog_product_entity").' ON linked_product_id = entity_id WHERE link_type_id = 3 AND product_id = '.$id;
|
449 |
+
$childProducts=$this->_read->fetchAll($sql);
|
450 |
+
foreach($childProducts as $child)
|
451 |
+
{
|
452 |
+
$childrenName.=$child["id"].',';
|
453 |
+
}
|
454 |
+
if($childrenName!="")
|
455 |
+
$childrenName=substr_replace($childrenName,"",strlen($childrenName)-1);
|
456 |
+
}
|
457 |
+
$s.=str_replace("\r\n", " ", $this->content($product,$attributes,$cate,$typ,$chil,0,array(),$nameCategory,$childrenName));
|
458 |
+
$s.="\r\n";
|
459 |
+
}
|
460 |
+
$childrenName="";
|
461 |
+
}
|
462 |
+
|
463 |
+
//Flushing and cleaning
|
464 |
+
unset($products_collection);
|
465 |
+
fwrite($fh, $s);
|
466 |
+
unset($s);
|
467 |
+
$s = "";
|
468 |
+
}
|
469 |
+
}
|
470 |
+
|
471 |
+
fclose($fh);
|
472 |
+
unset($fh);
|
473 |
+
|
474 |
+
$export_store_end = (float) array_sum(explode(' ',microtime()));
|
475 |
+
|
476 |
+
$this->comments_style('success','Loaded '.$num.' records within ' . round($export_store_end - $export_store_start, 3) . ' sec','load');
|
477 |
+
|
478 |
+
$this->comments_style('success','Saved successfully: ' . $this->_fileNameTxt . ' '.$this->_fSize.' byte(s)','save');
|
479 |
+
|
480 |
+
//Zip file
|
481 |
+
$filePath = $this->_fPath . "/" . $this->_fileNameTxt;
|
482 |
+
$zipFilePath = $this->_fPath . "/" . $this->_fileNameZip;
|
483 |
+
$this->_zipFile($filePath, $zipFilePath);
|
484 |
+
|
485 |
+
//-------------------------------
|
486 |
+
//export
|
487 |
+
|
488 |
+
if($this->_fType==="ftp" && $this->_bUpload)
|
489 |
+
{
|
490 |
+
$zipFilePath = $this->_fPath . DIRECTORY_SEPARATOR . $this->_fileNameZip;
|
491 |
+
$ftpRes = $this->ftpfile($zipFilePath);
|
492 |
+
if(!$ftpRes) $this->comments_style('error','Could not upload to ftp','Could_not_upload_to_ftp');
|
493 |
+
}
|
494 |
+
|
495 |
+
}
|
496 |
+
|
497 |
+
$export_end = (float) array_sum(explode(' ',microtime()));
|
498 |
+
|
499 |
+
$this->comments_style('info','Finished profile execution within ' . round($export_end - $export_start, 3) . ' sec.','finish');
|
500 |
+
$this->comments_style('finish',0,0);
|
501 |
+
}
|
502 |
+
|
503 |
+
|
504 |
+
function updateCategoriesMatrix($min, $max) {
|
505 |
+
//select the name of the categories
|
506 |
+
$this->_fProduct_Category_Matrix = array();
|
507 |
+
$product_category_ids = $this->_read->fetchAll('SELECT product_id, category_id FROM '.$this->getTableName("catalog_category_product")
|
508 |
+
. ' WHERE product_id BETWEEN ' . $min . ' AND ' . $max); //Added for multi store view purposes by Eli Sagy
|
509 |
+
foreach($product_category_ids as $product_category_id)
|
510 |
+
{
|
511 |
+
if (!isset($this->_fProduct_Category_Matrix[$product_category_id['product_id']])) $this->_fProduct_Category_Matrix[$product_category_id['product_id']] = array();
|
512 |
+
|
513 |
+
array_push($this->_fProduct_Category_Matrix[$product_category_id['product_id']], $product_category_id['category_id']);
|
514 |
+
}
|
515 |
+
}
|
516 |
+
|
517 |
+
//*********************************************************************************************************
|
518 |
+
//*********************************************************************************************************
|
519 |
+
//*********************************************************************************************************
|
520 |
+
//*********************************************************************************************************
|
521 |
+
//*************************************************function************************************************
|
522 |
+
public function select_attributes(&$attributes)
|
523 |
+
{
|
524 |
+
//select requied attributes
|
525 |
+
$attributesreq=array('name'=>array('text',1),'url_key'=>array('text',2),
|
526 |
+
'image'=>array('media_image',3),'description'=>array('textarea',5),'short_description'=>array('textarea',6),'status'=>array('select',7)
|
527 |
+
,'visibility'=>array('select',8), 'thumbnail'=>array('text',11), 'is_salable'=>array('text',12), 'rating_summary'=>array('text',13), 'reviews_count'=>array('text',14));
|
528 |
+
$i=count($attributesreq)+4;//entity_id,category_ides,type_id,childrenName
|
529 |
+
//select entity_type_code=catalog product
|
530 |
+
$sql='select entity_type_id
|
531 |
+
from '.$this->getTableName("eav_entity_type").'
|
532 |
+
where entity_type_code = "catalog_product"';
|
533 |
+
|
534 |
+
$result=$this->_read->fetchAll($sql);
|
535 |
+
$entity_type_id=$result[0]["entity_type_id"];
|
536 |
+
//select attribute with type=price
|
537 |
+
$sql='SELECT ea.attribute_id, attribute_code, frontend_input
|
538 |
+
FROM '.$this->getTableName("eav_attribute").' ea
|
539 |
+
WHERE (
|
540 |
+
ea.entity_type_id ='.$entity_type_id.'
|
541 |
+
)
|
542 |
+
AND ea.frontend_input = "price"';
|
543 |
+
|
544 |
+
$attributesInfo=$this->_read->fetchAll($sql);
|
545 |
+
foreach($attributesInfo as $attribute)
|
546 |
+
{
|
547 |
+
$attributesreq[$attribute["attribute_code"]]=array("price",$i);
|
548 |
+
$i++;
|
549 |
+
}
|
550 |
+
//select searchable or filterable attribute
|
551 |
+
$joinWithCatEav = Mage::helper('salesperson')->is_CE() && Mage::helper('salesperson')->is_1_3() ? "" : "INNER JOIN {$this->getTableName('catalog_eav_attribute')} cea ON ea.attribute_id = cea.attribute_id";
|
552 |
+
$whereCond = Mage::helper('salesperson')->is_CE() && Mage::helper('salesperson')->is_1_3() ? "ea.is_searchable =1 OR ea.is_filterable in(1,2)" : "cea.is_searchable =1 OR cea.is_filterable in(1,2)";
|
553 |
+
|
554 |
+
|
555 |
+
$sql='SELECT ea.attribute_id, attribute_code, frontend_input
|
556 |
+
FROM '.$this->getTableName("eav_attribute").' ea ' .
|
557 |
+
$joinWithCatEav . '
|
558 |
+
WHERE (
|
559 |
+
ea.entity_type_id ='.$entity_type_id.'
|
560 |
+
)
|
561 |
+
AND (' .
|
562 |
+
$whereCond . '
|
563 |
+
)and ea.frontend_input<>"price"';
|
564 |
+
|
565 |
+
$attributesInfo=$this->_read->fetchAll($sql);
|
566 |
+
$attributessf=array();
|
567 |
+
foreach($attributesInfo as $attribute)
|
568 |
+
{
|
569 |
+
$attributessf[$attribute["attribute_code"]]=array($attribute["frontend_input"],$i);
|
570 |
+
$i++;
|
571 |
+
}
|
572 |
+
//Union 2 array
|
573 |
+
$attributes=array_merge($attributessf,$attributesreq);
|
574 |
+
}
|
575 |
+
//-------------------------------------------------------------------
|
576 |
+
|
577 |
+
public function header($attributes,$cate,$typ,$chil)
|
578 |
+
{
|
579 |
+
$str="";
|
580 |
+
$header=array();
|
581 |
+
$name=1;
|
582 |
+
$url_key =2;
|
583 |
+
$image=3;
|
584 |
+
$map = Mage::helper('salesperson/mapping');
|
585 |
+
|
586 |
+
foreach($attributes as $key=>$value) {
|
587 |
+
$key = $map->getMapping($key);
|
588 |
+
$header[$value[1]]=$this->_fEnclose.$key.$this->_fEnclose;
|
589 |
+
}
|
590 |
+
|
591 |
+
//---------------------------
|
592 |
+
$header[$name]=$this->_fEnclose.$map->getMapping('title').$this->_fEnclose;
|
593 |
+
$header[$url_key]=$this->_fEnclose.$map->getMapping('link').$this->_fEnclose;
|
594 |
+
$header[$image]=$this->_fEnclose.$map->getMapping('image_link').$this->_fEnclose;
|
595 |
+
$str.=$this->_fEnclose.$map->getMapping('id').$this->_fEnclose.$this->_fDel;
|
596 |
+
$header[$cate]=$this->_fEnclose.$map->getMapping('category').$this->_fEnclose;
|
597 |
+
$header[$typ]=$this->_fEnclose.$map->getMapping('type').$this->_fEnclose;
|
598 |
+
$header[$chil]=$this->_fEnclose.$map->getMapping('children_skus').$this->_fEnclose;
|
599 |
+
|
600 |
+
ksort($header);
|
601 |
+
$att= implode($this->_fDel,$header);
|
602 |
+
$str.=$att."\r\n";
|
603 |
+
return $str;
|
604 |
+
}
|
605 |
+
//------------------------------------------------------------------
|
606 |
+
public function content($product,$attributes,$cate,$typ,$chil,$config,$children,$nameCategory,$childrenName)
|
607 |
+
{
|
608 |
+
$sql="";
|
609 |
+
$result="";
|
610 |
+
$products=array();
|
611 |
+
$att="";
|
612 |
+
// $getcategoties=array();
|
613 |
+
$entity_id=$product->getentity_id();
|
614 |
+
$this->setProductPricingTiers($product);
|
615 |
+
|
616 |
+
foreach($attributes as $att_code => $header_metadata)
|
617 |
+
{
|
618 |
+
$att_type = $header_metadata[0];
|
619 |
+
$header_index = $header_metadata[1];
|
620 |
+
|
621 |
+
if($config == 1 && array_key_exists($att_code,$children))
|
622 |
+
{
|
623 |
+
$products[$header_index]= $children[$att_code];
|
624 |
+
}
|
625 |
+
else
|
626 |
+
{
|
627 |
+
$products[$header_index] = $this->getProductAttributeValue($product, $att_code, $att_type);
|
628 |
+
}
|
629 |
+
|
630 |
+
//Create a copy of the product images in /media/sales_catalog, in order to remove dependency on Magento cache
|
631 |
+
$bCreateCopyOfImagesCatalog = true;
|
632 |
+
if ($bCreateCopyOfImagesCatalog && $att_code == 'image') $products[$header_index] = $this->_copyImageToSalespersonCatalog($products[$header_index], $entity_id);
|
633 |
+
|
634 |
+
$products[$header_index]=str_replace('"','""',$products[$header_index]);
|
635 |
+
$products[$header_index] = str_replace( array("\r\n","\r","\n", "\t", "", "\v") ,' ', $products[$header_index]);
|
636 |
+
$pattern = '/&#[0-9a-fA-F]*;/';
|
637 |
+
$products[$header_index] = preg_replace($pattern, '', $products[$header_index]);
|
638 |
+
$products[$header_index]=$this->_fEnclose.$products[$header_index].$this->_fEnclose;
|
639 |
+
}
|
640 |
+
//------------------------------
|
641 |
+
|
642 |
+
$products[0]=$this->_fEnclose.$entity_id.$this->_fEnclose;
|
643 |
+
//---------------------------------------------------
|
644 |
+
//Create the Query to get the products:getcategoty
|
645 |
+
$products[$cate]=$this->_fEnclose;
|
646 |
+
if (isset($this->_fProduct_Category_Matrix[$product->getId()]))
|
647 |
+
{
|
648 |
+
$getcategoties=$this->_fProduct_Category_Matrix[$product->getId()];
|
649 |
+
if($getcategoties)
|
650 |
+
{
|
651 |
+
$has_categories = false;
|
652 |
+
foreach($getcategoties as $getcategory)
|
653 |
+
{
|
654 |
+
if (isset($nameCategory[$getcategory]))
|
655 |
+
{
|
656 |
+
$products[$cate].=$nameCategory[$getcategory].',';
|
657 |
+
$has_categories = true;
|
658 |
+
}
|
659 |
+
}
|
660 |
+
if ($has_categories) $products[$cate]=substr_replace($products[$cate],"",strlen($products[$cate])-1);
|
661 |
+
}
|
662 |
+
}
|
663 |
+
|
664 |
+
$products[$cate].=$this->_fEnclose;
|
665 |
+
//-----------------------
|
666 |
+
$products[$typ]=$this->_fEnclose.$product->gettype_id().$this->_fEnclose;
|
667 |
+
//---------------------------
|
668 |
+
$products[$chil]=$this->_fEnclose.$childrenName.$this->_fEnclose;
|
669 |
+
//----------------------
|
670 |
+
ksort($products);
|
671 |
+
$att=implode($this->_fDel, $products);
|
672 |
+
return $att;
|
673 |
+
}
|
674 |
+
|
675 |
+
protected function getProductAttributeValue($product, $att_code, $att_type)
|
676 |
+
{
|
677 |
+
$attributeValue = "";
|
678 |
+
$func = 'get'.$att_code;
|
679 |
+
|
680 |
+
switch ($att_type) {
|
681 |
+
|
682 |
+
case "select":
|
683 |
+
case "multiselect":
|
684 |
+
$attributeValue = ($product->getData($att_code) == "") ? "" : trim($product->getResource()->getAttribute($att_code)->getFrontend()->getValue($product), " , ");
|
685 |
+
break;
|
686 |
+
case "media_image":
|
687 |
+
$attributeValue = $product->getImageUrl();
|
688 |
+
//$attributeValue = $product->getMediaConfig()->getMediaUrl($product->getData($att_code));
|
689 |
+
break;
|
690 |
+
|
691 |
+
case "textarea":
|
692 |
+
$attributeValue = $product->{$func}();
|
693 |
+
break;
|
694 |
+
|
695 |
+
case "price":
|
696 |
+
if($att_code==="price") $attributeValue = $this->getCalculatedPrice($product);
|
697 |
+
elseif($att_code==="giftcard_amounts") $attributeValue = $this->getAllGiftcardAmounts($product);
|
698 |
+
//elseif($att_code==="minimal_price") $attributeValue = $product->getMinimalPrice();
|
699 |
+
else $attributeValue = $product->getData($att_code);
|
700 |
+
break;
|
701 |
+
|
702 |
+
default:
|
703 |
+
if($att_code==="url_key") $attributeValue = Mage::helper('catalog/product')->getProductUrl($product);
|
704 |
+
elseif($att_code==="thumbnail") $attributeValue = Mage::helper('catalog/image')->init($product, 'thumbnail')->resize(66);
|
705 |
+
//elseif ($att_code==="is_salable") $attributeValue = $product->isSaleable();
|
706 |
+
elseif($att_code==="rating_summary") $attributeValue = $this->getRatingSummary($product);
|
707 |
+
elseif($att_code==="reviews_count") $attributeValue = $this->getReviewsCount($product);
|
708 |
+
else $attributeValue = $product->getData($att_code);
|
709 |
+
break;
|
710 |
+
}
|
711 |
+
$attributeValue = substr($attributeValue, 0, 4000);
|
712 |
+
return $attributeValue;
|
713 |
+
}
|
714 |
+
|
715 |
+
public function getRatingSummary($product){
|
716 |
+
Mage::getModel('review/review')->getEntitySummary($product, $this->_fStore_id);
|
717 |
+
$oRating_summary = $product->getRatingSummary();
|
718 |
+
return $oRating_summary->getData("rating_summary");
|
719 |
+
}
|
720 |
+
|
721 |
+
public function getReviewsCount($product){
|
722 |
+
Mage::getModel('review/review')->getEntitySummary($product, $this->_fStore_id);
|
723 |
+
$oRating_summary = $product->getRatingSummary();
|
724 |
+
return $oRating_summary->getData("reviews_count");
|
725 |
+
}
|
726 |
+
|
727 |
+
public function setProductPricingTiers($product){
|
728 |
+
if($product->getTierPriceCount()) {
|
729 |
+
$this->_aProductPricingTiers = array();
|
730 |
+
$tiers = $product->getTierPrice();
|
731 |
+
$this->_aProductPricingTiers = $tiers;
|
732 |
+
|
733 |
+
/*$websiteId = $this->_fStore->getWebsite()->getId();
|
734 |
+
foreach ($tiers as $tier) {
|
735 |
+
//var_dump($tier["website_id"]);
|
736 |
+
if($tier["website_id"] != $websiteId) continue;
|
737 |
+
$this->_aProductPricingTiers[] = $tier;
|
738 |
+
}*/
|
739 |
+
}
|
740 |
+
else {
|
741 |
+
$this->_aProductPricingTiers = null;
|
742 |
+
}
|
743 |
+
}
|
744 |
+
|
745 |
+
public function getCalculatedPrice($product)
|
746 |
+
{
|
747 |
+
$price = "";
|
748 |
+
if ($product->getData("type_id") == "giftcard")
|
749 |
+
{
|
750 |
+
$min_amount = PHP_INT_MAX;
|
751 |
+
if ($product->getData("open_amount_min") != null && Mage::getModel('catalog/product')->load($product->getId())->getData("allow_open_amount")) $min_amount = $product->getData("open_amount_min");
|
752 |
+
foreach($product->getData("giftcard_amounts") as $amount)
|
753 |
+
{
|
754 |
+
if($min_amount > $amount["value"]) $min_amount = $amount["value"];
|
755 |
+
}
|
756 |
+
$price = $min_amount;
|
757 |
+
}
|
758 |
+
elseif($this->_fStore->getConfig('salesperson/export_settings/min_tier_price') && is_array($this->_aProductPricingTiers)){
|
759 |
+
$last = count($this->_aProductPricingTiers) - 1;
|
760 |
+
$price = $this->_aProductPricingTiers[$last]["website_price"];
|
761 |
+
}
|
762 |
+
else {
|
763 |
+
$price = $product->getPrice();
|
764 |
+
}
|
765 |
+
|
766 |
+
if($price == 0){
|
767 |
+
//return; // XXX
|
768 |
+
if($product->getData("type_id") == "bundle"){
|
769 |
+
$priceModel = $product->getPriceModel();
|
770 |
+
list($minimalPriceTax, $maximalPriceTax) = $priceModel->getTotalPrices($product, null, null, false);
|
771 |
+
$price = $this->_fStore->getConfig('salesperson/export_settings/min_tier_price') ? $minimalPriceTax : $maximalPriceTax;
|
772 |
+
}
|
773 |
+
elseif($product->getData("type_id") == "grouped")
|
774 |
+
{
|
775 |
+
$price = $product->getMinimalPrice();
|
776 |
+
}
|
777 |
+
}
|
778 |
+
|
779 |
+
return number_format($price, 2, ".", "");
|
780 |
+
}
|
781 |
+
|
782 |
+
public function getTierPriceString() {
|
783 |
+
$tier_price = "";
|
784 |
+
if(is_array($this->_aProductPricingTiers) && count($this->_aProductPricingTiers)) {
|
785 |
+
$arr = array();
|
786 |
+
foreach ($this->_aProductPricingTiers as $tier) {
|
787 |
+
$price_qty = $tier["price_qty"];
|
788 |
+
$website_price = $tier["website_price"];
|
789 |
+
$arr[$price_qty] = $website_price;
|
790 |
+
}
|
791 |
+
|
792 |
+
$tier_price = Mage::helper('salesperson')->array_implode( "=>", ",", $arr);
|
793 |
+
}
|
794 |
+
|
795 |
+
|
796 |
+
return $tier_price;
|
797 |
+
}
|
798 |
+
|
799 |
+
public function getAllGiftcardAmounts($product)
|
800 |
+
{
|
801 |
+
if($product->getData("type_id") == "giftcard")
|
802 |
+
{
|
803 |
+
$list = "";
|
804 |
+
if(Mage::getModel('catalog/product')->load($product->getId())->getData("allow_open_amount")) $list = $product->getData("open_amount_min")."-".$product->getData("open_amount_max");
|
805 |
+
foreach($product->getData("giftcard_amounts") as $amount)
|
806 |
+
{
|
807 |
+
if($list != "") $list .= ", ";
|
808 |
+
$list .= $amount["value"];
|
809 |
+
}
|
810 |
+
return $list;
|
811 |
+
}
|
812 |
+
return null;
|
813 |
+
//die($priceObject[0]["value"]);
|
814 |
+
}
|
815 |
+
|
816 |
+
//--------------------------------
|
817 |
+
public function ftpfile($zipFilePath)
|
818 |
+
{
|
819 |
+
if (!file_exists($zipFilePath)) {
|
820 |
+
$this->comments_style('error','No ' . $zipFilePath . ' file found','No_zip_file_found');
|
821 |
+
return false;
|
822 |
+
}
|
823 |
+
|
824 |
+
$ioConfig=array();
|
825 |
+
|
826 |
+
if ($this->_fFTPHost != '')
|
827 |
+
{
|
828 |
+
$ioConfig['host'] = $this->_fFTPHost;
|
829 |
+
}
|
830 |
+
else
|
831 |
+
{
|
832 |
+
$this->comments_style('error','Empty host specified','Empty_host');
|
833 |
+
return false;
|
834 |
+
}
|
835 |
+
if ($this->_fFTPPort != '')
|
836 |
+
{
|
837 |
+
$ioConfig['port'] = $this->_fFTPPort;
|
838 |
+
}
|
839 |
+
|
840 |
+
if ($this->_fFTPUser != '')
|
841 |
+
{
|
842 |
+
$ioConfig['user'] = $this->_fFTPUser;
|
843 |
+
}
|
844 |
+
else
|
845 |
+
{
|
846 |
+
$ioConfig['user']='anonymous';
|
847 |
+
$ioConfig['password']='anonymous@noserver.com';
|
848 |
+
}
|
849 |
+
if ($this->_fFTPPassword != '')
|
850 |
+
{
|
851 |
+
$ioConfig['password'] = $this->_fFTPPassword;
|
852 |
+
}
|
853 |
+
|
854 |
+
$ioConfig['passive'] = $this->_fFTPPassive;
|
855 |
+
|
856 |
+
if ($this->_fPath != '')
|
857 |
+
{
|
858 |
+
$ioConfig['path']= $this->_fPath;
|
859 |
+
}
|
860 |
+
$this->_config = $ioConfig;
|
861 |
+
$this->_conn =@ftp_connect($this->_config['host'], $this->_config['port']);
|
862 |
+
if (!$this->_conn)
|
863 |
+
{
|
864 |
+
$this->comments_style('error','Could not establish FTP connection, invalid host or port','invalid_ftp_host/port');
|
865 |
+
return false;
|
866 |
+
}
|
867 |
+
if (!@ftp_login($this->_conn, $this->_config['user'], $this->_config['password']))
|
868 |
+
{
|
869 |
+
$this->close();
|
870 |
+
$this->comments_style('error','Could not establish FTP connection, invalid user name or password','Invalid_ftp_user_name_or_password');
|
871 |
+
return false;
|
872 |
+
}
|
873 |
+
/*if ($this->_config['path']!='')
|
874 |
+
{
|
875 |
+
if (!$this->ftp_is_dir($this->_conn, $this->_config['path']))
|
876 |
+
{
|
877 |
+
if(!$this->make_directory($this->_conn,$this->_config['path']))
|
878 |
+
{
|
879 |
+
$this->close();
|
880 |
+
$this->comments_style('error','Invalid path(or couldn\'t create the folders because of permissions)','invalid_path');
|
881 |
+
return false;
|
882 |
+
}
|
883 |
+
}
|
884 |
+
}*/
|
885 |
+
|
886 |
+
if (!@ftp_pasv($this->_conn, true)) {
|
887 |
+
$this->close();
|
888 |
+
$this->comments_style('error','Invalid file transfer mode','Invalid_file_transfer_mode');
|
889 |
+
return false;
|
890 |
+
}
|
891 |
+
|
892 |
+
if (!file_exists($zipFilePath)) {
|
893 |
+
$this->comments_style('error','No ' . $zipFilePath . ' file found','No_zip_file_found');
|
894 |
+
}
|
895 |
+
|
896 |
+
$upload = @ftp_put($this->_conn, basename($zipFilePath), $zipFilePath, FTP_BINARY);
|
897 |
+
if(!$upload){
|
898 |
+
$this->comments_style('error','File upload failed','File_upload_failed');
|
899 |
+
$upload=false;
|
900 |
+
}
|
901 |
+
|
902 |
+
return $upload;
|
903 |
+
}
|
904 |
+
//----------------------------------------------------
|
905 |
+
public function make_directory($ftp_stream, $dir)
|
906 |
+
{
|
907 |
+
// if directory already exists or can be immediately created return true
|
908 |
+
if ($this->ftp_is_dir($ftp_stream, $dir) || @ftp_mkdir($ftp_stream, $dir)) return true;
|
909 |
+
// otherwise recursively try to make the directory
|
910 |
+
if (!$this->make_directory($ftp_stream, dirname($dir))) return false;
|
911 |
+
// final step to create the directory
|
912 |
+
return @ftp_mkdir($ftp_stream, $dir);
|
913 |
+
}
|
914 |
+
//----------------------------------------
|
915 |
+
public function ftp_is_dir($ftp_stream, $dir)
|
916 |
+
{
|
917 |
+
// get current directory
|
918 |
+
$original_directory = ftp_pwd($ftp_stream);
|
919 |
+
// test if you can change directory to $dir
|
920 |
+
// suppress errors in case $dir is not a file or not a directory
|
921 |
+
if ( @ftp_chdir( $ftp_stream, $dir ) ) {
|
922 |
+
// If it is a directory, then change the directory back to the original directory
|
923 |
+
ftp_chdir( $ftp_stream, $original_directory );
|
924 |
+
return true;
|
925 |
+
} else {
|
926 |
+
return false;
|
927 |
+
}
|
928 |
+
}
|
929 |
+
//----------------------------------------------------
|
930 |
+
public function close()
|
931 |
+
{
|
932 |
+
return ftp_close($this->_conn);
|
933 |
+
}
|
934 |
+
//-----------------------------------------
|
935 |
+
public function comments_style($kind,$text,$alt)
|
936 |
+
{
|
937 |
+
switch($kind)
|
938 |
+
{
|
939 |
+
case 'header':
|
940 |
+
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
941 |
+
<html><head><style type="text/css">
|
942 |
+
ul { list-style-type:none; padding:0; margin:0; }
|
943 |
+
li { margin-left:0; border:1px solid #ccc; margin:2px; padding:2px 2px 2px 2px; font:normal 12px sans-serif; }
|
944 |
+
img { margin-right:5px; }
|
945 |
+
</style><title>Salesperson Exporter</title></head>
|
946 |
+
<body><ul>';
|
947 |
+
break;
|
948 |
+
case 'icon':
|
949 |
+
echo '<li style="background-color: rgb(128, 128, 128); color:rgb(255,255,255);">
|
950 |
+
<img style="margin-right: 5px;" src="'.Mage::getBaseUrl().'../skin/adminhtml/default/default/images/note_msg_icon.gif" alt='.$alt.'/>
|
951 |
+
'.$text.'
|
952 |
+
</li>';
|
953 |
+
break;
|
954 |
+
case 'info':
|
955 |
+
echo '<li>
|
956 |
+
<img style="margin-right: 5px;" src="'.Mage::getBaseUrl().'../skin/adminhtml/default/default/images/note_msg_icon.gif" alt='.$alt.'/>
|
957 |
+
'.$text.'
|
958 |
+
</li>';
|
959 |
+
break;
|
960 |
+
case 'warning':
|
961 |
+
echo '<li style="background-color: rgb(255, 255, 128);">
|
962 |
+
<img style="margin-right: 5px;" src="'.Mage::getBaseUrl().'../skin/adminhtml/default/default/images/fam_bullet_error.gif" alt='.$alt.'/>
|
963 |
+
'.$text.'
|
964 |
+
</li>';
|
965 |
+
break;
|
966 |
+
case 'success':
|
967 |
+
echo '<li style="background-color: rgb(128, 255, 128);">
|
968 |
+
<img src="'.Mage::getBaseUrl().'../skin/adminhtml/default/default/images/fam_bullet_success.gif" alt='.$alt.'/>
|
969 |
+
'.$text.'
|
970 |
+
</li>';
|
971 |
+
break;
|
972 |
+
case 'error':
|
973 |
+
echo '<li style="background-color: rgb(255, 187, 187);">
|
974 |
+
<img src="'.Mage::getBaseUrl().'../skin/adminhtml/default/default/images/error_msg_icon.gif" alt='.$alt.'/>
|
975 |
+
'.$text.'
|
976 |
+
</li>';
|
977 |
+
break;
|
978 |
+
default:
|
979 |
+
echo '</ul></body></html>';
|
980 |
+
}
|
981 |
+
}
|
982 |
+
//-------------------------------------------------------------------
|
983 |
+
public function export_config($store_id)
|
984 |
+
{
|
985 |
+
$this->_fStore_id = $store_id;
|
986 |
+
Mage::app()->setCurrentStore($store_id);
|
987 |
+
$this->_fStore = Mage::app()->getStore($store_id);
|
988 |
+
$this->_fStore_export_enabled = $this->_fStore->getConfig('salesperson/export_settings/export_enabled');
|
989 |
+
//feature is not in use
|
990 |
+
if( isset($_GET["upload"]) && $_GET["upload"] == "false") $this->_bUpload = false;
|
991 |
+
else if( getenv ("upload") && getenv ("upload") == "false") $this->_bUpload = false;
|
992 |
+
else $this->_bUpload = true;
|
993 |
+
//end
|
994 |
+
$this->_fDel = $this->_fStore->getConfig('salesperson/export_settings/delimiter');
|
995 |
+
if($this->_fDel==='\t') $this->_fDel=" ";
|
996 |
+
$this->_fEnclose = $this->_fStore->getConfig('salesperson/export_settings/enclosed_values');
|
997 |
+
$this->_fType = $this->_fStore->getConfig('salesperson/export_settings/type');
|
998 |
+
$this->_fPath = Mage::app()->getStore(0)->getConfig('salesperson/export_settings/path').'/'.$this->_fStore->getWebsite()->getCode().'/'.$this->_fStore->getCode();
|
999 |
+
$this->_fFTPHost = $this->_fStore->getConfig('salesperson/export_settings/ftp_host');
|
1000 |
+
$this->_fFTPPort = $this->_fStore->getConfig('salesperson/export_settings/ftp_port');
|
1001 |
+
$this->_fFTPUser = $this->_fStore->getConfig('salesperson/export_settings/ftp_user');
|
1002 |
+
$this->_fFTPPassword = $this->_fStore->getConfig('salesperson/export_settings/ftp_password');
|
1003 |
+
$this->_fFTPPassive = $this->_fStore->getConfig('salesperson/export_settings/passive');
|
1004 |
+
//feature is not in use
|
1005 |
+
$this->_fEnableCron = $this->_fStore->getConfig('salesperson/export_settings/cron_enabled');
|
1006 |
+
$this->_fExportProfileId = $this->_fStore->getConfig('salesperson/export_settings/profile_id');
|
1007 |
+
$this->CronExpression = $this->_fStore->getConfig('salesperson/export_settings/cron_expr');
|
1008 |
+
//end
|
1009 |
+
}
|
1010 |
+
//---------------------------
|
1011 |
+
public function getCategoryCollection($storeId)
|
1012 |
+
{
|
1013 |
+
$categoriesPool = $collection = Mage::getModel('catalog/category')->getCollection()->addNameToResult()
|
1014 |
+
->addAttributeToFilter("is_active",array("neq"=>0))
|
1015 |
+
->setStoreId($storeId);
|
1016 |
+
|
1017 |
+
foreach($categoriesPool as $category)
|
1018 |
+
{
|
1019 |
+
if (!in_array($storeId, $category->getStoreIds())) $collection->removeItemByKey($category->getId());
|
1020 |
+
}
|
1021 |
+
|
1022 |
+
return $collection;
|
1023 |
+
}
|
1024 |
+
|
1025 |
+
//-----------------------------------------
|
1026 |
+
public function getTableName($tableName)
|
1027 |
+
{
|
1028 |
+
$newTableName= Mage::getSingleton('core/resource')->getTableName($tableName);
|
1029 |
+
return $newTableName;
|
1030 |
+
}
|
1031 |
+
|
1032 |
+
protected function _copyImageToSalespersonCatalog($imageUrl, $productId){
|
1033 |
+
|
1034 |
+
$resultUrl = "";
|
1035 |
+
$mediaDir = Mage::getBaseDir("media");
|
1036 |
+
$pos = strpos($imageUrl, "media") + strlen("media");
|
1037 |
+
$catalogRelativeImagePath = substr($imageUrl, $pos + 1, strlen($imageUrl) - $pos - 1);
|
1038 |
+
$sourceImagePath = $mediaDir . DIRECTORY_SEPARATOR . $catalogRelativeImagePath;
|
1039 |
+
if(file_exists($sourceImagePath)){
|
1040 |
+
$fileName = basename($sourceImagePath);
|
1041 |
+
$destinationFolder = $mediaDir . DIRECTORY_SEPARATOR . "sales_catalog" . DIRECTORY_SEPARATOR . "product" . DIRECTORY_SEPARATOR . $productId;
|
1042 |
+
if(!is_dir($destinationFolder)){
|
1043 |
+
if(!mkdir($destinationFolder, 0777, true))
|
1044 |
+
{
|
1045 |
+
echo "failed to create directory $destinationFolder ...\n";
|
1046 |
+
exit();
|
1047 |
+
}
|
1048 |
+
}
|
1049 |
+
|
1050 |
+
/*$newCatalogRelativePath = str_replace("catalog", "sales_catalog", $catalogRelativePath);
|
1051 |
+
$destinationFolder = $mediaDir . DIRECTORY_SEPARATOR . dirname($newCatalogRelativePath) ;
|
1052 |
+
if(!is_dir($destinationFolder)){
|
1053 |
+
if(!mkdir($destinationFolder, 0777, true))
|
1054 |
+
{
|
1055 |
+
echo "failed to create directory $destinationFolder ...\n";
|
1056 |
+
exit();
|
1057 |
+
}
|
1058 |
+
}*/
|
1059 |
+
|
1060 |
+
$destinationImagePath = $destinationFolder . DIRECTORY_SEPARATOR . $fileName;
|
1061 |
+
//var_dump($destinationImagePath); exit();
|
1062 |
+
if (!copy($sourceImagePath, $destinationImagePath)) {
|
1063 |
+
echo "failed to copy $sourceImagePath to $destinationImagePath ...\n";
|
1064 |
+
exit();
|
1065 |
+
}
|
1066 |
+
}
|
1067 |
+
|
1068 |
+
$resultUrl = substr($imageUrl, 0, $pos) . DIRECTORY_SEPARATOR . "sales_catalog" . DIRECTORY_SEPARATOR . "product" . DIRECTORY_SEPARATOR . $productId . DIRECTORY_SEPARATOR . $fileName;
|
1069 |
+
return $resultUrl;
|
1070 |
+
}
|
1071 |
+
|
1072 |
+
public function getUrl(Varien_Event_Observer $observer)
|
1073 |
+
{
|
1074 |
+
$category = $observer->getCategory();
|
1075 |
+
$url = Mage::helper('salesperson')->getResultUrl($category->getName());
|
1076 |
+
$category->setData('url', $url);
|
1077 |
+
}
|
1078 |
+
|
1079 |
+
public function export_orders_celebros()
|
1080 |
+
{
|
1081 |
+
$enclosed = '"';
|
1082 |
+
$delimeter = " ";
|
1083 |
+
$newLine = "\r\n";
|
1084 |
+
|
1085 |
+
$this->_read=Mage::getSingleton('core/resource')->getConnection('core_read');
|
1086 |
+
$store_view_ids = $this->_read->fetchAll('SELECT store_id FROM '.$this->getTableName("core_store") . ' WHERE store_id <> 0'); //Added for multi store view purposes by Eli Sagy
|
1087 |
+
|
1088 |
+
foreach($store_view_ids as $store_view_id)
|
1089 |
+
{
|
1090 |
+
$this->export_config($store_view_id['store_id']);
|
1091 |
+
|
1092 |
+
if(!$this->_fStore_export_enabled) continue;
|
1093 |
+
|
1094 |
+
$header = array("OrderID", "ProductID", "Date", "Count", "Sum");
|
1095 |
+
$glue = $enclosed . $delimeter . $enclosed;
|
1096 |
+
$strResult = $enclosed . implode($glue, $header) . $enclosed . $newLine;
|
1097 |
+
|
1098 |
+
$sql = $this->_getOrdersSql();
|
1099 |
+
$stm = $this->_read->query($sql);
|
1100 |
+
|
1101 |
+
while($row = $stm->fetch()) {
|
1102 |
+
$record["OrderID"] = $row["order_id"];
|
1103 |
+
$record["ProductID"] = $row["product_id"];
|
1104 |
+
$created_at_time = strtotime($row["created_at"]);
|
1105 |
+
$record["Date"] = date("Y-m-d", $created_at_time);
|
1106 |
+
$record["Count"] = (int) $row["qty_ordered"];
|
1107 |
+
$record["Sum"] = $row["row_total"];;
|
1108 |
+
$strResult .= $enclosed . implode($glue, $record) . $enclosed . $newLine;
|
1109 |
+
}
|
1110 |
+
|
1111 |
+
//Create, flush, zip and ftp the orders file
|
1112 |
+
$this->_createAndUploadOrders($strResult);
|
1113 |
+
$this->comments_style('success',"Exported orders of store '{$this->_fStore_id}'. Memory peak was: " . memory_get_peak_usage(),'orders');
|
1114 |
+
}
|
1115 |
+
}
|
1116 |
+
|
1117 |
+
protected function _getOrdersSql(){
|
1118 |
+
$sql = "";
|
1119 |
+
$from = date("Y-m-d H:i:s", (time()-60*60*24*30*6)); //return approximately last 6 months orders
|
1120 |
+
$to = date("Y-m-d H:i:s", time());
|
1121 |
+
$orderItemTable = $this->getTableName("sales_flat_order_item");
|
1122 |
+
|
1123 |
+
if($this->_isStoreIdColumnExist($orderItemTable))
|
1124 |
+
{
|
1125 |
+
$sql = "SELECT order_id, product_id, created_at, qty_ordered, row_total, row_total_incl_tax
|
1126 |
+
FROM {$orderItemTable}
|
1127 |
+
WHERE store_id = {$this->_fStore_id} AND created_at between '{$from}' AND '{$to}' AND parent_item_id IS NULL
|
1128 |
+
";
|
1129 |
+
}
|
1130 |
+
else
|
1131 |
+
{
|
1132 |
+
$ordersTable = $this->_getOrdersTable();
|
1133 |
+
$sql = "SELECT item.order_id, item.product_id, item.created_at, item.qty_ordered, item.row_total
|
1134 |
+
FROM
|
1135 |
+
(SELECT order_id, product_id, created_at, qty_ordered, row_total
|
1136 |
+
FROM {$orderItemTable}
|
1137 |
+
WHERE created_at between '{$from}' AND '{$to}' AND parent_item_id IS NULL) as item
|
1138 |
+
JOIN
|
1139 |
+
(SELECT entity_id
|
1140 |
+
FROM {$ordersTable}
|
1141 |
+
WHERE store_id = {$this->_fStore_id} AND created_at between '{$from}' AND '{$to}') as sales_order
|
1142 |
+
ON sales_order.entity_id = item.order_id
|
1143 |
+
";
|
1144 |
+
}
|
1145 |
+
return $sql;
|
1146 |
+
}
|
1147 |
+
|
1148 |
+
protected function _isStoreIdColumnExist($table) {
|
1149 |
+
$sql = "SHOW COLUMNS FROM {$table} LIKE 'store_id'";
|
1150 |
+
return (bool)$this->_read->fetchOne($sql);
|
1151 |
+
}
|
1152 |
+
|
1153 |
+
protected function _getOrdersTable() {
|
1154 |
+
$table = $this->getTableName("sales_flat_order");
|
1155 |
+
$sql = "SHOW TABLES LIKE '{$table}'";
|
1156 |
+
$bExist = (bool)$this->_read->fetchOne($sql);
|
1157 |
+
return ($bExist) ? $table : $this->getTableName("sales_order");
|
1158 |
+
}
|
1159 |
+
|
1160 |
+
protected function _createAndUploadOrders($str){
|
1161 |
+
|
1162 |
+
//Create directory to put the file
|
1163 |
+
if(!$this->_createDir($this->_fPath)) {
|
1164 |
+
$this->comments_style('error','Could not create the directory in ' . $this->_fPath . ' path','problemwith dir');
|
1165 |
+
return;
|
1166 |
+
}
|
1167 |
+
|
1168 |
+
$filePath = $this->_fPath . DIRECTORY_SEPARATOR . "Data_history.txt";
|
1169 |
+
$zipFilePath = $this->_fPath . DIRECTORY_SEPARATOR . "Data_history.zip";
|
1170 |
+
|
1171 |
+
//Create file
|
1172 |
+
if((!$fh = $this->_createFile($filePath))) {
|
1173 |
+
$this->comments_style('error','Could not create the file in ' . $filePath,'problemwith file');
|
1174 |
+
return;
|
1175 |
+
}
|
1176 |
+
|
1177 |
+
//Flush string orders data to file
|
1178 |
+
$this->_stringToTextFile($str, $fh);
|
1179 |
+
fclose($fh);
|
1180 |
+
|
1181 |
+
//Zip file
|
1182 |
+
$this->_zipFile($filePath, $zipFilePath);
|
1183 |
+
|
1184 |
+
//Ftp file
|
1185 |
+
if($this->_fType==="ftp" && $this->_bUpload)
|
1186 |
+
{
|
1187 |
+
$ftpRes = $this->ftpfile($zipFilePath);
|
1188 |
+
if(!$ftpRes) $this->comments_style('error','Could not upload ' . $zipFilePath . ' to ftp','Could_not_upload_to_ftp');
|
1189 |
+
}
|
1190 |
+
}
|
1191 |
+
|
1192 |
+
protected function _createDir($dirPath) {
|
1193 |
+
if (!is_dir($dirPath)) $dir=@mkdir($dirPath, 0777,true);
|
1194 |
+
return $dirPath;
|
1195 |
+
|
1196 |
+
}
|
1197 |
+
|
1198 |
+
protected function _createFile($filePath) {
|
1199 |
+
if (file_exists($filePath)) unlink($filePath);
|
1200 |
+
$fh = fopen($filePath, 'ab');
|
1201 |
+
return $fh ;
|
1202 |
+
|
1203 |
+
}
|
1204 |
+
|
1205 |
+
protected function _stringToTextFile($str, $fh){
|
1206 |
+
fwrite($fh, $str);
|
1207 |
+
}
|
1208 |
+
|
1209 |
+
protected function _zipFile($filePath, $zipFilePath)
|
1210 |
+
{
|
1211 |
+
$out = false;
|
1212 |
+
|
1213 |
+
if (!file_exists($filePath)) {
|
1214 |
+
$this->comments_style('error','No ' . $filePath . ' file found','No_txt_file_found');
|
1215 |
+
exit();
|
1216 |
+
return false;
|
1217 |
+
}
|
1218 |
+
|
1219 |
+
$zip = new ZipArchive();
|
1220 |
+
if ($zip->open($zipFilePath, ZipArchive::CREATE) == true) {
|
1221 |
+
$out = $zip->addFile($filePath, basename($filePath));
|
1222 |
+
if(!$out) $this->comments_style('error','Could not add ' . $filePath . 'to zip archive','Could_not_add_txt_file_to_zip_file');
|
1223 |
+
$zip->close();
|
1224 |
+
unlink($filePath);
|
1225 |
+
}
|
1226 |
+
else
|
1227 |
+
{
|
1228 |
+
$this->comments_style('error','Could not create ' . $zipFilePath . ' file','Could_not_create_zip_file');
|
1229 |
+
}
|
1230 |
+
|
1231 |
+
return $out;
|
1232 |
+
}
|
1233 |
+
|
1234 |
+
public function url_rewrite_reindex()
|
1235 |
+
{
|
1236 |
+
$this->_read=Mage::getSingleton('core/resource')->getConnection('core_read');
|
1237 |
+
|
1238 |
+
|
1239 |
+
$store_view_ids = $this->_read->fetchAll('SELECT store_id,name FROM '.$this->getTableName("core_store") . ' WHERE store_id <> 0');
|
1240 |
+
|
1241 |
+
foreach($store_view_ids as $store_view)
|
1242 |
+
{
|
1243 |
+
$store_view_id=$store_view['store_id'];
|
1244 |
+
$store_view_name=$store_view['name'];
|
1245 |
+
|
1246 |
+
|
1247 |
+
Mage::log("Salesperson- Checking need for reindexing of URL rewrite for store: {$store_view_name}, ID:{$store_view_id}",null,'celebros.log',true);
|
1248 |
+
|
1249 |
+
if(Mage::getStoreConfigFlag('salesperson/nav_to_search_settings/nav_to_search',$store_view_id))
|
1250 |
+
{
|
1251 |
+
$rewrite_start = (float) array_sum(explode(' ',microtime()));
|
1252 |
+
Mage::helper('salesperson')->updateCategoriesUrlRewrites($store_view_id);
|
1253 |
+
$rewrite_end = (float) array_sum(explode(' ',microtime()));
|
1254 |
+
|
1255 |
+
Mage::log("Salesperson- Reindexed URL rewrite for store: {$store_view_name}, ID:{$store_view_id}. Total Time: ".round($rewrite_end - $rewrite_start, 1) . ' sec.',null,'celebros.log',true);
|
1256 |
+
}
|
1257 |
+
}
|
1258 |
+
}
|
1259 |
+
|
1260 |
+
|
1261 |
+
public function after_reindex_process_catalog_url($observer)
|
1262 |
+
{
|
1263 |
+
$this->url_rewrite_reindex();
|
1264 |
+
}
|
1265 |
+
}
|
app/code/community/Celebros/Salesperson/Model/ObserverLarge.php
ADDED
@@ -0,0 +1,649 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
ini_set('memory_limit','1535M');
|
3 |
+
set_time_limit(7200);
|
4 |
+
ini_set('max_execution_time',7200);
|
5 |
+
ini_set('display_errors', 1);
|
6 |
+
ini_set('output_buffering', 0);
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Celebros Qwiser - Magento Extension
|
12 |
+
*
|
13 |
+
* DISCLAIMER
|
14 |
+
*
|
15 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
16 |
+
* If you wish to customize it, please contact Celebros.
|
17 |
+
*
|
18 |
+
* @category Celebros
|
19 |
+
* @package Celebros_Salesperson
|
20 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
21 |
+
*
|
22 |
+
*/
|
23 |
+
//include_once("createZip.php");
|
24 |
+
class Celebros_Salesperson_Model_ObserverLarge extends Celebros_Salesperson_Model_Observer
|
25 |
+
{
|
26 |
+
protected static $_profilingResults;
|
27 |
+
protected $bExportProductLink = true;
|
28 |
+
protected $_product_entity_type_id = null;
|
29 |
+
protected $_category_entity_type_id = null;
|
30 |
+
protected $prod_file_name="product_file";
|
31 |
+
protected $isLogProfiler=true;
|
32 |
+
|
33 |
+
function __construct() {
|
34 |
+
|
35 |
+
$this->_fStore_id = 1;
|
36 |
+
$this->export_config($this->_fStore_id);
|
37 |
+
$this->_read=Mage::getSingleton('core/resource')->getConnection('core_read');
|
38 |
+
$this->_product_entity_type_id = $this->get_product_entity_type_id();
|
39 |
+
$this->_category_entity_type_id = $this->get_category_entity_type_id();
|
40 |
+
}
|
41 |
+
|
42 |
+
private function logProfiler($msg, $isSpaceLine=false)
|
43 |
+
{
|
44 |
+
if (!($this->isLogProfiler))
|
45 |
+
return;
|
46 |
+
|
47 |
+
Mage::log(date("Y-m-d, H:i:s:: ").$msg, null, 'celebros_profiler',true);
|
48 |
+
|
49 |
+
if ($isSpaceLine)
|
50 |
+
Mage::log('', null, 'celebros_profiler',true);
|
51 |
+
}
|
52 |
+
|
53 |
+
public function export_celebros() {
|
54 |
+
//self::startProfiling(__FUNCTION__);
|
55 |
+
|
56 |
+
$this->logProfiler('===============');
|
57 |
+
$this->logProfiler('Starting Export');
|
58 |
+
$this->logProfiler('===============',true);
|
59 |
+
|
60 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true),true);
|
61 |
+
|
62 |
+
|
63 |
+
echo "<BR>".date('Y/m/d H:i:s');
|
64 |
+
echo "<BR>Starting export<BR>";
|
65 |
+
echo "===============<BR>";
|
66 |
+
echo "Memory usage: ".memory_get_usage(true)."<BR>";
|
67 |
+
|
68 |
+
echo "<BR>Exporting tables<BR>";
|
69 |
+
echo "================<BR>";
|
70 |
+
echo "Memory usage: ".memory_get_usage(true)."<BR>";
|
71 |
+
echo str_repeat(" ", 4096);
|
72 |
+
flush();
|
73 |
+
|
74 |
+
$this->logProfiler('Exporting tables');
|
75 |
+
$this->logProfiler('----------------',true);
|
76 |
+
|
77 |
+
$this->export_tables();
|
78 |
+
|
79 |
+
echo "<BR>Exporting products<BR>";
|
80 |
+
echo "==================<BR>";
|
81 |
+
echo "Memory usage: ".memory_get_usage(true)."<BR>";
|
82 |
+
echo str_repeat(" ", 4096);
|
83 |
+
flush();
|
84 |
+
|
85 |
+
$this->logProfiler('Writing products file');
|
86 |
+
$this->logProfiler('---------------------',true);
|
87 |
+
|
88 |
+
$this->export_products();
|
89 |
+
|
90 |
+
echo "<BR>Creating ZIP file<BR>";
|
91 |
+
echo "=================<BR>";
|
92 |
+
echo "Memory usage: ".memory_get_usage(true)."<BR>";
|
93 |
+
echo str_repeat(" ", 4096);
|
94 |
+
flush();
|
95 |
+
|
96 |
+
$this->logProfiler('Creating ZIP file');
|
97 |
+
$this->logProfiler('-----------------',true);
|
98 |
+
|
99 |
+
$zipFilePath = $this->zipLargeFiles();
|
100 |
+
$this->ftpfile($zipFilePath);
|
101 |
+
|
102 |
+
echo "<BR>Finished<BR>";
|
103 |
+
echo "========<BR>";
|
104 |
+
echo "Memory usage: ".memory_get_usage(true)."<BR>";
|
105 |
+
echo "Memory peek usage: ".memory_get_peak_usage(true)."<BR>";
|
106 |
+
|
107 |
+
echo "<BR><BR>".date('Y/m/d H:i:s');
|
108 |
+
echo str_repeat(" ", 4096);
|
109 |
+
flush();
|
110 |
+
|
111 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true),true);
|
112 |
+
$this->logProfiler('Mem peek usage: '.memory_get_peak_usage(true),true);
|
113 |
+
//self::stopProfiling(__FUNCTION__);
|
114 |
+
|
115 |
+
//$html = self::getProfilingResultsString();
|
116 |
+
//$this->log_profiling_results($html);
|
117 |
+
//echo $html;
|
118 |
+
}
|
119 |
+
|
120 |
+
protected function log_profiling_results($html) {
|
121 |
+
$fh = $this->create_file("profiling_results.log", "html");
|
122 |
+
$this->write_to_file($html, $fh);
|
123 |
+
}
|
124 |
+
|
125 |
+
protected function get_status_attribute_id() {
|
126 |
+
$table = $this->getTableName("eav_attribute");
|
127 |
+
$sql = "SELECT attribute_id
|
128 |
+
FROM {$table}
|
129 |
+
WHERE entity_type_id ={$this->_product_entity_type_id} AND attribute_code='status'";
|
130 |
+
return $this->_read->fetchOne($sql);
|
131 |
+
}
|
132 |
+
|
133 |
+
protected function get_product_entity_type_id() {
|
134 |
+
$table = $this->getTableName("eav_entity_type");
|
135 |
+
$sql = "SELECT entity_type_id
|
136 |
+
FROM {$table}
|
137 |
+
WHERE entity_type_code='catalog_product'";
|
138 |
+
return $this->_read->fetchOne($sql);
|
139 |
+
}
|
140 |
+
|
141 |
+
protected function get_category_entity_type_id() {
|
142 |
+
$table = $this->getTableName("eav_entity_type");
|
143 |
+
$sql = "SELECT entity_type_id
|
144 |
+
FROM {$table}
|
145 |
+
WHERE entity_type_code='catalog_category'";
|
146 |
+
return $this->_read->fetchOne($sql);
|
147 |
+
}
|
148 |
+
|
149 |
+
protected function get_visibility_attribute_id() {
|
150 |
+
$table = $this->getTableName("eav_attribute");
|
151 |
+
$sql = "SELECT attribute_id
|
152 |
+
FROM {$table}
|
153 |
+
WHERE entity_type_id ={$this->_product_entity_type_id} AND attribute_code='visibility'";
|
154 |
+
return $this->_read->fetchOne($sql);
|
155 |
+
}
|
156 |
+
|
157 |
+
protected function get_category_name_attribute_id() {
|
158 |
+
$table = $this->getTableName("eav_attribute");
|
159 |
+
$sql = "SELECT attribute_id
|
160 |
+
FROM {$table}
|
161 |
+
WHERE entity_type_id ={$this->_category_entity_type_id} AND attribute_code='name'";
|
162 |
+
return $this->_read->fetchOne($sql);
|
163 |
+
}
|
164 |
+
|
165 |
+
protected function get_category_is_active_attribute_id() {
|
166 |
+
$table = $this->getTableName("eav_attribute");
|
167 |
+
$sql = "SELECT attribute_id
|
168 |
+
FROM {$table}
|
169 |
+
WHERE entity_type_id ={$this->_category_entity_type_id} AND attribute_code='is_active'";
|
170 |
+
return $this->_read->fetchOne($sql);
|
171 |
+
}
|
172 |
+
|
173 |
+
protected function export_tables() {
|
174 |
+
//self::startProfiling(__FUNCTION__);
|
175 |
+
|
176 |
+
$table = $this->getTableName("eav_attribute");
|
177 |
+
$this->logProfiler("START {$table}");
|
178 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true));
|
179 |
+
$sql = "SELECT attribute_id, attribute_code, backend_type, frontend_input
|
180 |
+
FROM {$table}
|
181 |
+
WHERE entity_type_id ={$this->_product_entity_type_id}";
|
182 |
+
$this->export_table($sql, "attributes_lookup");
|
183 |
+
$this->logProfiler("FINISH {$table}");
|
184 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true),true);
|
185 |
+
|
186 |
+
|
187 |
+
$table = $this->getTableName("catalog_product_entity");
|
188 |
+
$this->logProfiler("START {$table}");
|
189 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true));
|
190 |
+
$sql = "SELECT entity_id, type_id, sku
|
191 |
+
FROM {$table}
|
192 |
+
WHERE entity_type_id ={$this->_product_entity_type_id}";
|
193 |
+
$this->export_table($sql, $table);
|
194 |
+
$this->logProfiler("FINISH {$table}");
|
195 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true),true);
|
196 |
+
|
197 |
+
|
198 |
+
$table = $this->getTableName("catalog_product_entity_int");
|
199 |
+
$this->logProfiler("START {$table}");
|
200 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true));
|
201 |
+
$status_attribute_id = $this->get_status_attribute_id();
|
202 |
+
$sql = "SELECT DISTINCT entity_id
|
203 |
+
FROM {$table}
|
204 |
+
WHERE entity_type_id ={$this->_product_entity_type_id}
|
205 |
+
AND store_id =0
|
206 |
+
AND attribute_id = {$status_attribute_id}
|
207 |
+
AND value = 2";
|
208 |
+
$this->export_table($sql, "disabled_products");
|
209 |
+
$this->logProfiler("FINISH {$table}");
|
210 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true),true);
|
211 |
+
|
212 |
+
|
213 |
+
$table = $this->getTableName("catalog_product_entity_int");
|
214 |
+
$this->logProfiler("START {$table}");
|
215 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true));
|
216 |
+
$visibility_attribute_id = $this->get_visibility_attribute_id();
|
217 |
+
$sql = "SELECT DISTINCT entity_id
|
218 |
+
FROM {$table}
|
219 |
+
WHERE entity_type_id ={$this->_product_entity_type_id}
|
220 |
+
AND store_id =0
|
221 |
+
AND attribute_id = $visibility_attribute_id
|
222 |
+
AND value = 1";
|
223 |
+
$this->export_table($sql, "not_visible_individually_products");
|
224 |
+
$this->logProfiler("FINISH {$table}");
|
225 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true),true);
|
226 |
+
|
227 |
+
|
228 |
+
$table = $this->getTableName("catalog_product_entity_varchar");
|
229 |
+
$this->logProfiler("START {$table}");
|
230 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true));
|
231 |
+
$sql = "SELECT entity_id, value, attribute_id
|
232 |
+
FROM {$table}
|
233 |
+
WHERE entity_type_id ={$this->_product_entity_type_id}
|
234 |
+
AND store_id =0";
|
235 |
+
$this->export_table($sql, $table);
|
236 |
+
$this->logProfiler("FINISH {$table}");
|
237 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true),true);
|
238 |
+
|
239 |
+
|
240 |
+
$table = $this->getTableName("catalog_product_entity_int");
|
241 |
+
$this->logProfiler("START {$table}");
|
242 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true));
|
243 |
+
$sql = "SELECT entity_id, value, attribute_id
|
244 |
+
FROM {$table}
|
245 |
+
WHERE entity_type_id ={$this->_product_entity_type_id}
|
246 |
+
AND store_id =0";
|
247 |
+
$this->export_table($sql, $table);
|
248 |
+
$this->logProfiler("FINISH {$table}");
|
249 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true),true);
|
250 |
+
|
251 |
+
|
252 |
+
$table = $this->getTableName("catalog_product_entity_text");
|
253 |
+
$this->logProfiler("START {$table}");
|
254 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true));
|
255 |
+
$sql = "SELECT entity_id, value, attribute_id
|
256 |
+
FROM {$table}
|
257 |
+
WHERE entity_type_id ={$this->_product_entity_type_id}
|
258 |
+
AND store_id =0";
|
259 |
+
$this->export_table($sql, $table);
|
260 |
+
$this->logProfiler("FINISH {$table}");
|
261 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true),true);
|
262 |
+
|
263 |
+
|
264 |
+
$table = $this->getTableName("catalog_product_entity_decimal");
|
265 |
+
$this->logProfiler("START {$table}");
|
266 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true));
|
267 |
+
$sql = "SELECT entity_id, value, attribute_id
|
268 |
+
FROM {$table}
|
269 |
+
WHERE entity_type_id ={$this->_product_entity_type_id}
|
270 |
+
AND store_id =0";
|
271 |
+
$this->export_table($sql, $table);
|
272 |
+
$this->logProfiler("FINISH {$table}");
|
273 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true),true);
|
274 |
+
|
275 |
+
|
276 |
+
$table = $this->getTableName("catalog_product_entity_datetime");
|
277 |
+
$this->logProfiler("START {$table}");
|
278 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true));
|
279 |
+
$sql = "SELECT entity_id, value, attribute_id
|
280 |
+
FROM {$table}
|
281 |
+
WHERE entity_type_id ={$this->_product_entity_type_id}
|
282 |
+
AND store_id =0";
|
283 |
+
$this->export_table($sql, $table);
|
284 |
+
$this->logProfiler("FINISH {$table}");
|
285 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true),true);
|
286 |
+
|
287 |
+
|
288 |
+
$table = $this->getTableName("eav_attribute_option_value");
|
289 |
+
$this->logProfiler("START {$table}");
|
290 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true));
|
291 |
+
$sql = "SELECT option_id, value
|
292 |
+
FROM {$table}
|
293 |
+
WHERE store_id = 0";
|
294 |
+
$this->export_table($sql, $table);
|
295 |
+
$this->logProfiler("FINISH {$table}");
|
296 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true),true);
|
297 |
+
|
298 |
+
|
299 |
+
$table = $this->getTableName("eav_attribute_option");
|
300 |
+
$this->logProfiler("START {$table}");
|
301 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true));
|
302 |
+
$sql = "SELECT option_id, attribute_id
|
303 |
+
FROM {$table}";
|
304 |
+
$this->export_table($sql, $table);
|
305 |
+
$this->logProfiler("FINISH {$table}");
|
306 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true),true);
|
307 |
+
|
308 |
+
|
309 |
+
$table = $this->getTableName("catalog_category_product");
|
310 |
+
$this->logProfiler("START {$table}");
|
311 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true));
|
312 |
+
$sql = "SELECT category_id, product_id
|
313 |
+
FROM {$table}";
|
314 |
+
$this->export_table($sql, $table);
|
315 |
+
$this->logProfiler("FINISH {$table}");
|
316 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true),true);
|
317 |
+
|
318 |
+
|
319 |
+
$table = $this->getTableName("catalog_category_entity");
|
320 |
+
$this->logProfiler("START {$table}");
|
321 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true));
|
322 |
+
$sql = "SELECT entity_id, parent_id, path
|
323 |
+
FROM {$table}";
|
324 |
+
$this->export_table($sql, $table);
|
325 |
+
$this->logProfiler("FINISH {$table}");
|
326 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true),true);
|
327 |
+
|
328 |
+
|
329 |
+
$table = $this->getTableName("catalog_category_entity_varchar");
|
330 |
+
$this->logProfiler("START {$table}");
|
331 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true));
|
332 |
+
$name_attribute_id = $this->get_category_name_attribute_id();
|
333 |
+
$sql = "SELECT entity_id, value
|
334 |
+
FROM {$table}
|
335 |
+
WHERE attribute_id = {$name_attribute_id}
|
336 |
+
AND store_id =0";
|
337 |
+
$this->export_table($sql, "category_lookup");
|
338 |
+
$this->logProfiler("FINISH {$table}");
|
339 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true),true);
|
340 |
+
|
341 |
+
|
342 |
+
$table = $this->getTableName("catalog_category_entity_int");
|
343 |
+
$this->logProfiler("START {$table}");
|
344 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true));
|
345 |
+
$is_active_attribute_id = $this->get_category_is_active_attribute_id();
|
346 |
+
$sql = "SELECT entity_id
|
347 |
+
FROM {$table}
|
348 |
+
WHERE `attribute_id` = {$is_active_attribute_id}
|
349 |
+
AND value = 0
|
350 |
+
AND entity_type_id ={$this->_category_entity_type_id}
|
351 |
+
AND store_id =0";
|
352 |
+
$this->export_table($sql, "disabled_categories");
|
353 |
+
$this->logProfiler("FINISH {$table}");
|
354 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true),true);
|
355 |
+
|
356 |
+
|
357 |
+
$table = $this->getTableName("catalog_product_super_link");
|
358 |
+
$this->logProfiler("START {$table}");
|
359 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true));
|
360 |
+
$sql = "SELECT product_id, parent_id
|
361 |
+
FROM {$table}";
|
362 |
+
$this->export_table($sql, $table);
|
363 |
+
$this->logProfiler("FINISH {$table}");
|
364 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true),true);
|
365 |
+
|
366 |
+
|
367 |
+
$table = $this->getTableName("catalog_product_super_attribute");
|
368 |
+
$this->logProfiler("START {$table}");
|
369 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true));
|
370 |
+
$sql = "SELECT product_id, attribute_id
|
371 |
+
FROM {$table}";
|
372 |
+
$this->export_table($sql, $table);
|
373 |
+
$this->logProfiler("FINISH {$table}");
|
374 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true),true);
|
375 |
+
|
376 |
+
//self::stopProfiling(__FUNCTION__);
|
377 |
+
}
|
378 |
+
|
379 |
+
protected function export_table($sql, $filename) {
|
380 |
+
$fh = $this->create_file($filename);
|
381 |
+
stream_set_write_buffer($fh,4096);
|
382 |
+
|
383 |
+
$header = "";
|
384 |
+
$str = "";
|
385 |
+
$i = 0;
|
386 |
+
|
387 |
+
$stm = $this->_read->query($sql . " LIMIT 0, 100000000");
|
388 |
+
|
389 |
+
$hasData=($row = $stm->fetch());
|
390 |
+
|
391 |
+
if ($hasData)
|
392 |
+
{
|
393 |
+
$header = "^" . implode("^ ^",array_keys($row)) . "^" . "\r\n";
|
394 |
+
$this->write_to_file($header, $fh);
|
395 |
+
}
|
396 |
+
|
397 |
+
$rowCount=0;
|
398 |
+
while($hasData)
|
399 |
+
{
|
400 |
+
do
|
401 |
+
{
|
402 |
+
$str.= "^" . implode("^ ^",$row) . "^" . "\r\n";
|
403 |
+
$rowCount++;
|
404 |
+
|
405 |
+
if (($rowCount%1000)==0)
|
406 |
+
{
|
407 |
+
$this->logProfiler("Write block start");
|
408 |
+
$this->write_to_file($str , $fh);
|
409 |
+
$this->logProfiler("Write block end");
|
410 |
+
$str="";
|
411 |
+
}
|
412 |
+
|
413 |
+
$hasData=($row=$stm->fetch());
|
414 |
+
} while($hasData);
|
415 |
+
}
|
416 |
+
|
417 |
+
if (($rowCount%1000)!=0)
|
418 |
+
{
|
419 |
+
$this->logProfiler("Write last block start");
|
420 |
+
$this->write_to_file($str , $fh);
|
421 |
+
$this->logProfiler("Write last block end");
|
422 |
+
}
|
423 |
+
|
424 |
+
$this->logProfiler("Total rows: {$rowCount}");
|
425 |
+
|
426 |
+
fclose($fh);
|
427 |
+
//self::stopProfiling(__FUNCTION__. "({$filename})");
|
428 |
+
}
|
429 |
+
|
430 |
+
protected function create_file($name, $ext = "txt") {
|
431 |
+
//self::startProfiling(__FUNCTION__);
|
432 |
+
if (!is_dir($this->_fPath)) $dir=@mkdir($this->_fPath,0777,true);
|
433 |
+
$filePath = $this->_fPath . DIRECTORY_SEPARATOR . $name . "." . $ext;
|
434 |
+
if (file_exists($filePath)) unlink($filePath);
|
435 |
+
$fh = fopen($filePath, 'ab');
|
436 |
+
//self::stopProfiling(__FUNCTION__);
|
437 |
+
return $fh;
|
438 |
+
}
|
439 |
+
|
440 |
+
protected function write_to_file($str, $fh){
|
441 |
+
//self::startProfiling(__FUNCTION__);
|
442 |
+
fwrite($fh, $str);
|
443 |
+
|
444 |
+
//self::stopProfiling(__FUNCTION__);
|
445 |
+
}
|
446 |
+
|
447 |
+
public function zipLargeFiles() {
|
448 |
+
//self::startProfiling(__FUNCTION__);
|
449 |
+
|
450 |
+
$out = false;
|
451 |
+
$zipPath = $this->_fPath . DIRECTORY_SEPARATOR . "products_file.zip";//$this->_fileNameZip;
|
452 |
+
|
453 |
+
$dh=opendir($this->_fPath);
|
454 |
+
$filesToZip = array();
|
455 |
+
while(($item=readdir($dh)) !== false && !is_null($item)){
|
456 |
+
$filePath = $this->_fPath . DIRECTORY_SEPARATOR . $item;
|
457 |
+
$ext = pathinfo($filePath, PATHINFO_EXTENSION);
|
458 |
+
if(is_file($filePath) && ($ext == "txt" || $ext == "log")) {
|
459 |
+
$filesToZip[] = $filePath;
|
460 |
+
}
|
461 |
+
}
|
462 |
+
|
463 |
+
for($i=0; $i < count($filesToZip); $i++) {
|
464 |
+
$filePath = $filesToZip[$i];
|
465 |
+
$out = $this->zipLargeFile($filePath, $zipPath);
|
466 |
+
}
|
467 |
+
|
468 |
+
//self::stopProfiling(__FUNCTION__);
|
469 |
+
return $out ? $zipPath : false;
|
470 |
+
}
|
471 |
+
|
472 |
+
public function zipLargeFile($filePath, $zipPath)
|
473 |
+
{
|
474 |
+
//self::startProfiling(__FUNCTION__);
|
475 |
+
|
476 |
+
$out = false;
|
477 |
+
|
478 |
+
$zip = new ZipArchive();
|
479 |
+
if ($zip->open($zipPath, ZipArchive::CREATE) == true) {
|
480 |
+
$fileName = basename($filePath);
|
481 |
+
$out = $zip->addFile($filePath, basename($filePath));
|
482 |
+
if(!$out) throw new Exception("Could not add file '{$fileName}' to_zip_file");
|
483 |
+
$zip->close();
|
484 |
+
$ext = pathinfo($fileName, PATHINFO_EXTENSION);
|
485 |
+
if($ext != "log") unlink($filePath);
|
486 |
+
}
|
487 |
+
else
|
488 |
+
{
|
489 |
+
throw new Exception("Could not create zip file");
|
490 |
+
}
|
491 |
+
|
492 |
+
//self::stopProfiling(__FUNCTION__);
|
493 |
+
return $out;
|
494 |
+
}
|
495 |
+
|
496 |
+
|
497 |
+
protected function export_products()
|
498 |
+
{
|
499 |
+
echo "Begining products export<BR>Memory usage: ".memory_get_usage(true)."<BR>";
|
500 |
+
|
501 |
+
$fh = $this->create_file($this->prod_file_name);
|
502 |
+
stream_set_write_buffer($fh,4096);
|
503 |
+
|
504 |
+
$fields = array("id", "price", "image_link", "thumbnail", "type_id", "product_sku");
|
505 |
+
$attributes = array("price", "image", "thumbnail", "type");
|
506 |
+
|
507 |
+
if($this->bExportProductLink) $fields[] = "link";
|
508 |
+
if($this->bExportProductLink) $attributes[] = "url_key";
|
509 |
+
|
510 |
+
if(count($fields)- 2 != count($attributes)) throw new Exception('Fields (without id):' . implode("^ ^",$fields) . ' are not equal to ' . implode("^ ^",$fields));
|
511 |
+
|
512 |
+
$header = "^" . implode("^ ^",$fields) . "^" . "\r\n";
|
513 |
+
$this->write_to_file($header, $fh);
|
514 |
+
|
515 |
+
// *********************************
|
516 |
+
|
517 |
+
$table = $this->getTableName("catalog_product_entity");
|
518 |
+
$sql = "SELECT entity_id, type_id, sku
|
519 |
+
FROM {$table}
|
520 |
+
WHERE entity_type_id ={$this->_product_entity_type_id}";
|
521 |
+
|
522 |
+
$stm = $this->_read->query($sql . " LIMIT 0, 100000000");
|
523 |
+
|
524 |
+
$productNum=0;
|
525 |
+
$rowCount=0;
|
526 |
+
$str='';
|
527 |
+
|
528 |
+
$product=Mage::getSingleton('catalog/product');
|
529 |
+
|
530 |
+
$hasData=($row=$stm->fetch());
|
531 |
+
|
532 |
+
while($hasData)
|
533 |
+
{
|
534 |
+
do
|
535 |
+
{
|
536 |
+
$product->load(($row["entity_id"]));
|
537 |
+
|
538 |
+
if ($product->isSaleable())
|
539 |
+
{
|
540 |
+
$values["id"] = $product->getentity_id();
|
541 |
+
$values["price"] = $this->getCalculatedPrice($product);
|
542 |
+
$values["image_link"] = $product->getMediaConfig()->getMediaUrl($product->getData("image"));
|
543 |
+
$values["thumbnail"] = Mage::helper('catalog/image')->init($product, 'thumbnail')->resize(66);
|
544 |
+
$values["type_id"] = $product->gettype_id();
|
545 |
+
$values["product_sku"] = $product->getSku();
|
546 |
+
|
547 |
+
if($this->bExportProductLink)
|
548 |
+
{
|
549 |
+
$values["link"] = $product->getProductUrl();
|
550 |
+
}
|
551 |
+
|
552 |
+
$str.= "^" . implode("^ ^",$values) . "^" . "\r\n";
|
553 |
+
|
554 |
+
$productNum++;
|
555 |
+
|
556 |
+
if (($productNum%1000)==0)
|
557 |
+
{
|
558 |
+
$this->logProfiler("Product num: {$productNum}");
|
559 |
+
$this->logProfiler('Mem usage: '.memory_get_usage(true));
|
560 |
+
$this->logProfiler("Write block start");
|
561 |
+
$this->write_to_file($str , $fh);
|
562 |
+
$this->logProfiler("Write block end",true);
|
563 |
+
$str='';
|
564 |
+
}
|
565 |
+
}
|
566 |
+
|
567 |
+
//$product->cleanCache();
|
568 |
+
$product->clearInstance();
|
569 |
+
$product->reset();
|
570 |
+
|
571 |
+
$rowCount++;
|
572 |
+
|
573 |
+
/* if (($rowCount%1000)==0)
|
574 |
+
{
|
575 |
+
$this->logProfiler("Number of processed rows: {$rowCount}");
|
576 |
+
$this->logProfiler("Fetch start");
|
577 |
+
$hasData=($row=$stm->fetch());
|
578 |
+
$this->logProfiler("Fetch end", true);
|
579 |
+
}
|
580 |
+
else
|
581 |
+
*/
|
582 |
+
$hasData=($row=$stm->fetch());
|
583 |
+
} while($hasData);
|
584 |
+
|
585 |
+
if (($productNum%1000)!=0)
|
586 |
+
{
|
587 |
+
$this->logProfiler("Product num: {$productNum}");
|
588 |
+
$this->logProfiler("Write last block start");
|
589 |
+
$this->write_to_file($str , $fh);
|
590 |
+
$this->logProfiler("Write last block end",true);
|
591 |
+
}
|
592 |
+
|
593 |
+
}
|
594 |
+
|
595 |
+
$this->logProfiler("Finished outer while",true);
|
596 |
+
|
597 |
+
fclose($fh);
|
598 |
+
}
|
599 |
+
|
600 |
+
|
601 |
+
protected static function startProfiling($key) {
|
602 |
+
|
603 |
+
if(!isset(self::$_profilingResults[$key])) {
|
604 |
+
$profile = new stdClass();
|
605 |
+
$profile->average =0 ;
|
606 |
+
$profile->count = 0;
|
607 |
+
$profile->max = 0;
|
608 |
+
self::$_profilingResults[$key] = $profile;
|
609 |
+
}
|
610 |
+
|
611 |
+
$profile = self::$_profilingResults[$key];
|
612 |
+
if(isset($profile->start) && $profile->start > $profile->end) throw new Exception("The start of profiling timer '{$key}' is called before the stop of it was called");
|
613 |
+
|
614 |
+
$profile->start = (float) array_sum(explode(' ',microtime()));
|
615 |
+
}
|
616 |
+
|
617 |
+
protected static function stopProfiling($key) {
|
618 |
+
if(!isset(self::$_profilingResults[$key])) throw new Exception("The stop of profiling timer '{$key}' was called while the start was never declared");
|
619 |
+
|
620 |
+
$profile = self::$_profilingResults[$key];
|
621 |
+
if($profile->start == -1) throw new Exception("The start time of '{$key}' profiling is -1");
|
622 |
+
|
623 |
+
$profile->end = (float) array_sum(explode(' ',microtime()));
|
624 |
+
$duration = $profile->end - $profile->start;
|
625 |
+
if($profile->max < $duration) $profile->max = $duration;
|
626 |
+
|
627 |
+
$profile->average = ($profile->average * $profile->count + $duration)/($profile->count +1);
|
628 |
+
$profile->count++;
|
629 |
+
}
|
630 |
+
|
631 |
+
protected static function getProfilingResultsString() {
|
632 |
+
$html = "";
|
633 |
+
if(count(self::$_profilingResults)) {
|
634 |
+
$html.= "In sec:";
|
635 |
+
$html.= '<table border="1">';
|
636 |
+
$html.= "<tr><th>Timer</th><th>Total</th><th>Average</th><th>Count</th><th>Peak</th></tr>";
|
637 |
+
foreach(self::$_profilingResults as $key =>$profile) {
|
638 |
+
$total = $profile->average * $profile->count;
|
639 |
+
$html.= "<tr><td>{$key}</td><td>{$total}</td><td>{$profile->average}</td><td>{$profile->count}</td><td>{$profile->max}</td></tr>";
|
640 |
+
}
|
641 |
+
$html.= "</table>";
|
642 |
+
}
|
643 |
+
|
644 |
+
$html.= 'PHP Memory peak usage: ' . memory_get_peak_usage();
|
645 |
+
|
646 |
+
return $html;
|
647 |
+
}
|
648 |
+
|
649 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Model/Product.php
RENAMED
@@ -1,216 +1,212 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Model_Product extends Celebros_Salesperson_Model_Api_QwiserProduct
|
11 |
-
{
|
12 |
-
/**
|
13 |
-
* Initialize resources
|
14 |
-
*/
|
15 |
-
protected function _construct()
|
16 |
-
{
|
17 |
-
$this->_init('salesperson/product');
|
18 |
-
}
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Retrive product by SKU
|
22 |
-
*
|
23 |
-
* @param string $productSku
|
24 |
-
* @return Celebros_Salesperson_Model_Api_QwiserProduct
|
25 |
-
*/
|
26 |
-
public function load($productSku){
|
27 |
-
$products = Mage::Helper("salesperson")->getSalespersonApi()->results->Products->Items;
|
28 |
-
foreach ($products as $product)
|
29 |
-
{
|
30 |
-
if($product->Sku = $productSku){
|
31 |
-
return $product;
|
32 |
-
}
|
33 |
-
}
|
34 |
-
}
|
35 |
-
/**
|
36 |
-
* Retrive QwiserSearchResult
|
37 |
-
*
|
38 |
-
* @return Celebros_Salesperson_Model_Api_QwiserSearchResult
|
39 |
-
*/
|
40 |
-
protected function getQwiserSearchResults(){
|
41 |
-
if(Mage::helper('salesperson')->getSalespersonApi()->results)
|
42 |
-
return Mage::helper('salesperson')->getSalespersonApi()->results;
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Retrieve Store Id of the product
|
47 |
-
*
|
48 |
-
* @return int
|
49 |
-
*/
|
50 |
-
public function getStoreId()
|
51 |
-
{
|
52 |
-
if (key_exists(Mage::Helper('salesperson/mapping')->getMapping('store_id'),$this->Field)) {
|
53 |
-
return $this->Field(Mage::Helper('salesperson/mapping')->getMapping('store_id'));
|
54 |
-
}
|
55 |
-
return Mage::app()->getStore()->getId();
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Get product url model
|
60 |
-
*
|
61 |
-
* @return Mage_Catalog_Model_Product_Url
|
62 |
-
*/
|
63 |
-
public function getUrlModel()
|
64 |
-
{
|
65 |
-
if ($this->_urlModel === null) {
|
66 |
-
$this->_urlModel = Mage::getSingleton('catalog/product_url');
|
67 |
-
}
|
68 |
-
return $this->_urlModel;
|
69 |
-
}
|
70 |
-
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Get product name
|
74 |
-
*
|
75 |
-
* @return string
|
76 |
-
*/
|
77 |
-
public function getName()
|
78 |
-
{
|
79 |
-
return $this->Field(Mage::Helper('salesperson/mapping')->getMapping('title'));
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Get product status
|
84 |
-
*
|
85 |
-
* @return int
|
86 |
-
*/
|
87 |
-
public function getStatus()
|
88 |
-
{
|
89 |
-
return $this->Field[Mage::Helper('salesperson/mapping')->getMapping('status')] == 'Enabled';
|
90 |
-
}
|
91 |
-
|
92 |
-
public function getInStock() {
|
93 |
-
|
94 |
-
// $productModel = Mage::getSingleton('catalog/product');
|
95 |
-
// $product = $productModel->load($this->getId());
|
96 |
-
// $inventoery = Mage::getSingleton('cataloginventory/stock_item')->loadByProduct($product);
|
97 |
-
// $isInStock = $inventoery->getData('is_in_stock');
|
98 |
-
// if ((int)$isInStock == 0){ return false; }else { return true; }
|
99 |
-
return key_exists(Mage::Helper('salesperson/mapping')->getMapping('is_in_stock'), $this->Field) && (int)$this->Field[Mage::Helper('salesperson/mapping')->getMapping('is_in_stock')] ==
|
100 |
-
}
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
return $this->Field[Mage::Helper('salesperson/mapping')->getMapping('
|
114 |
-
}
|
115 |
-
|
116 |
-
/**
|
117 |
-
*
|
118 |
-
*
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
*
|
128 |
-
|
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 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
$urlParams
|
194 |
-
|
195 |
-
|
196 |
-
$
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
$urlParams
|
206 |
-
|
207 |
-
|
208 |
-
$
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
}
|
214 |
-
}
|
215 |
-
}
|
216 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Model_Product extends Celebros_Salesperson_Model_Api_QwiserProduct
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Initialize resources
|
14 |
+
*/
|
15 |
+
protected function _construct()
|
16 |
+
{
|
17 |
+
$this->_init('salesperson/product');
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Retrive product by SKU
|
22 |
+
*
|
23 |
+
* @param string $productSku
|
24 |
+
* @return Celebros_Salesperson_Model_Api_QwiserProduct
|
25 |
+
*/
|
26 |
+
public function load($productSku){
|
27 |
+
$products = Mage::Helper("salesperson")->getSalespersonApi()->results->Products->Items;
|
28 |
+
foreach ($products as $product)
|
29 |
+
{
|
30 |
+
if($product->Sku = $productSku){
|
31 |
+
return $product;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
}
|
35 |
+
/**
|
36 |
+
* Retrive QwiserSearchResult
|
37 |
+
*
|
38 |
+
* @return Celebros_Salesperson_Model_Api_QwiserSearchResult
|
39 |
+
*/
|
40 |
+
protected function getQwiserSearchResults(){
|
41 |
+
if(Mage::helper('salesperson')->getSalespersonApi()->results)
|
42 |
+
return Mage::helper('salesperson')->getSalespersonApi()->results;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Retrieve Store Id of the product
|
47 |
+
*
|
48 |
+
* @return int
|
49 |
+
*/
|
50 |
+
public function getStoreId()
|
51 |
+
{
|
52 |
+
if (key_exists(Mage::Helper('salesperson/mapping')->getMapping('store_id'),$this->Field)) {
|
53 |
+
return $this->Field(Mage::Helper('salesperson/mapping')->getMapping('store_id'));
|
54 |
+
}
|
55 |
+
return Mage::app()->getStore()->getId();
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Get product url model
|
60 |
+
*
|
61 |
+
* @return Mage_Catalog_Model_Product_Url
|
62 |
+
*/
|
63 |
+
public function getUrlModel()
|
64 |
+
{
|
65 |
+
if ($this->_urlModel === null) {
|
66 |
+
$this->_urlModel = Mage::getSingleton('catalog/product_url');
|
67 |
+
}
|
68 |
+
return $this->_urlModel;
|
69 |
+
}
|
70 |
+
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Get product name
|
74 |
+
*
|
75 |
+
* @return string
|
76 |
+
*/
|
77 |
+
public function getName()
|
78 |
+
{
|
79 |
+
return $this->Field(Mage::Helper('salesperson/mapping')->getMapping('title'));
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Get product status
|
84 |
+
*
|
85 |
+
* @return int
|
86 |
+
*/
|
87 |
+
public function getStatus()
|
88 |
+
{
|
89 |
+
return $this->Field[Mage::Helper('salesperson/mapping')->getMapping('status')] == 'Enabled';
|
90 |
+
}
|
91 |
+
|
92 |
+
public function getInStock() {
|
93 |
+
|
94 |
+
// $productModel = Mage::getSingleton('catalog/product');
|
95 |
+
// $product = $productModel->load($this->getId());
|
96 |
+
// $inventoery = Mage::getSingleton('cataloginventory/stock_item')->loadByProduct($product);
|
97 |
+
// $isInStock = $inventoery->getData('is_in_stock');
|
98 |
+
// if ((int)$isInStock == 0){ return false; }else { return true; }
|
99 |
+
return key_exists(Mage::Helper('salesperson/mapping')->getMapping('is_in_stock'), $this->Field) && (int)$this->Field[Mage::Helper('salesperson/mapping')->getMapping('is_in_stock')] == 0 ? true : false;
|
100 |
+
}
|
101 |
+
public function isSaleable() {
|
102 |
+
// $productModel = Mage::getSingleton('catalog/product');
|
103 |
+
// $product = $productModel->load($this->getId());
|
104 |
+
// $inventoery = Mage::getSingleton('cataloginventory/stock_item')->loadByProduct($product);
|
105 |
+
// $isInStock = $inventoery->getData('is_in_stock');
|
106 |
+
// if ((int)$isInStock == 0){ return false; }else { return true; }
|
107 |
+
return key_exists(Mage::Helper('salesperson/mapping')->getMapping('is_salable'), $this->Field) && (int)$this->Field[Mage::Helper('salesperson/mapping')->getMapping('is_salable')] == 0 ? false : true;
|
108 |
+
}
|
109 |
+
|
110 |
+
|
111 |
+
public function getSku()
|
112 |
+
{
|
113 |
+
return key_exists(Mage::Helper('salesperson/mapping')->getMapping('sku'),$this->Field) ? $this->Field[Mage::Helper('salesperson/mapping')->getMapping('sku')] : false;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Retrive Product Id
|
118 |
+
* @return string
|
119 |
+
*/
|
120 |
+
public function getId() {
|
121 |
+
return $this->Field[Mage::Helper('salesperson/mapping')->getMapping('id')];
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Retrieve assigned category Ids
|
126 |
+
*
|
127 |
+
* @return array
|
128 |
+
*/
|
129 |
+
public function getCategory()
|
130 |
+
{
|
131 |
+
return key_exists(Mage::Helper('salesperson/mapping')->getMapping('category'),$this->Field) ? $this->Field[Mage::Helper('salesperson/mapping')->getMapping('category')] : false;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Retrieve product websites identifiers
|
136 |
+
*
|
137 |
+
* @return array
|
138 |
+
*/
|
139 |
+
public function getWebsiteIds()
|
140 |
+
{
|
141 |
+
if (strpos($this->Field[Mage::Helper('salesperson/mapping')->getMapping('websites')],',')){
|
142 |
+
$websitesIds = explode(",", $this->Field[Mage::Helper('salesperson/mapping')->getMapping('websites')]);
|
143 |
+
return $websitesIds;
|
144 |
+
}
|
145 |
+
else {
|
146 |
+
return array($this->Field[Mage::Helper('salesperson/mapping')->getMapping('websites')]);
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Get all sore ids where product is presented
|
152 |
+
*
|
153 |
+
* @return array
|
154 |
+
*/
|
155 |
+
public function getStoreIds()
|
156 |
+
{
|
157 |
+
if (strpos($this->Field[Mage::Helper('salesperson/mapping')->getMapping('store_id')],',')){
|
158 |
+
$storeIds = explode(",", $this->Field[Mage::Helper('salesperson/mapping')->getMapping('store_id')]);
|
159 |
+
return $storeIds;
|
160 |
+
}
|
161 |
+
else {
|
162 |
+
return array($this->Field[Mage::Helper('salesperson/mapping')->getMapping('store_id')]);
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Retrive the Rating precent
|
168 |
+
*
|
169 |
+
* @return string
|
170 |
+
*/
|
171 |
+
public function getRatingSummary()
|
172 |
+
{
|
173 |
+
return $this->Field[$this->Field[Mage::Helper('salesperson/mapping')->getMapping('rating_summary')]]; //_getData('rating_summary');
|
174 |
+
}
|
175 |
+
/**
|
176 |
+
* Retrieve product found in
|
177 |
+
*
|
178 |
+
* @return category with link
|
179 |
+
*/
|
180 |
+
public function getAvailableInCategories()
|
181 |
+
{
|
182 |
+
if(key_exists(Mage::Helper('salesperson/mapping')->getMapping('category'), $this->Field) && $this->Field[Mage::Helper('salesperson/mapping')->getMapping('category')] != ''){
|
183 |
+
$categories = strpos($this->Field[Mage::Helper('salesperson/mapping')->getMapping('category')],',')
|
184 |
+
? explode(',',$this->Field[Mage::Helper('salesperson/mapping')->getMapping('category')])
|
185 |
+
: $this->Field[Mage::Helper('salesperson/mapping')->getMapping('category')];
|
186 |
+
if (is_array($categories)){
|
187 |
+
$urls = array();
|
188 |
+
foreach ($categories as $category){
|
189 |
+
$urlParams = array();
|
190 |
+
$urlParams['_current'] = false;
|
191 |
+
$urlParams['_escape'] = true;
|
192 |
+
$urlParams['_use_rewrite'] = false;
|
193 |
+
$urlParams['_query'] = array(
|
194 |
+
'q' => $category,
|
195 |
+
);
|
196 |
+
$urls[$category] = Mage::getUrl('*/*/index', $urlParams);
|
197 |
+
}
|
198 |
+
return $urls;
|
199 |
+
}
|
200 |
+
else {
|
201 |
+
$urlParams = array();
|
202 |
+
$urlParams['_current'] = false;
|
203 |
+
$urlParams['_escape'] = true;
|
204 |
+
$urlParams['_use_rewrite'] = false;
|
205 |
+
$urlParams['_query'] = array(
|
206 |
+
'q' => $categories,
|
207 |
+
);
|
208 |
+
return array($categories => Mage::getUrl('*/*/index', $urlParams));
|
209 |
+
}
|
210 |
+
}
|
211 |
+
}
|
212 |
+
}
|
|
|
|
|
|
|
|
app/code/community/Celebros/Salesperson/Model/SalespersonCrossSellApi.php
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* DISCLAIMER
|
6 |
+
*
|
7 |
+
* Do not edit or add to this file if you wish correct extension functionality.
|
8 |
+
* If you wish to customize it, please contact Celebros.
|
9 |
+
*
|
10 |
+
* @category Celebros
|
11 |
+
* @package Celebros_Salesperson
|
12 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Celebros_Salesperson_Model_SalespersonCrossSellApi extends Mage_Core_Model_Abstract
|
17 |
+
{
|
18 |
+
|
19 |
+
protected $_serverAddress;
|
20 |
+
|
21 |
+
protected $_siteKey;
|
22 |
+
|
23 |
+
protected $_requestHandle;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Init resource model
|
27 |
+
*
|
28 |
+
*/
|
29 |
+
protected function _construct()
|
30 |
+
{
|
31 |
+
$this->_init('salesperson/SalespersonCrossSellApi');
|
32 |
+
if (Mage::getStoreConfig('salesperson/crosssell_settings/crosssell_customer_name') != '' && Mage::getStoreConfig('salesperson/crosssell_settings/crosssell_address') != '' && Mage::getStoreConfig('salesperson/crosssell_settings/crosssell_request_handle') != ''){
|
33 |
+
$this->_serverAddress = Mage::getStoreConfig('salesperson/crosssell_settings/crosssell_address');
|
34 |
+
if (preg_match('/http:\/\//',$this->_serverAddress)){
|
35 |
+
$this->_serverAddress = preg_replace('/http::\/\//','', $this->_serverAddress);
|
36 |
+
}
|
37 |
+
$this->_siteKey = Mage::getStoreConfig('salesperson/crosssell_settings/crosssell_customer_name');
|
38 |
+
$this->_requestHandle = Mage::getStoreConfig('salesperson/crosssell_settings/crosssell_request_handle');
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
public function getRecommendationsIds($id) {
|
43 |
+
$arrIds = array();
|
44 |
+
|
45 |
+
$url = "http://{$this->_serverAddress}/JsonEndPoint/ProductsRecommendation.aspx?siteKey={$this->_siteKey}&RequestHandle={$this->_requestHandle}&RequestType=1&SKU={$id}&Encoding=utf-8";
|
46 |
+
|
47 |
+
$jsonData = $this->_get_data($url);
|
48 |
+
|
49 |
+
$obj = json_decode($jsonData);
|
50 |
+
|
51 |
+
for($i=0; isset($obj->Items) && $i < count($obj->Items); $i++) {
|
52 |
+
$arrIds[] = (int) $obj->Items[$i]->Fields->SKU;
|
53 |
+
}
|
54 |
+
|
55 |
+
return $arrIds;
|
56 |
+
}
|
57 |
+
|
58 |
+
protected function _get_data($url){
|
59 |
+
//var_dump($url);
|
60 |
+
$data = null;
|
61 |
+
try {
|
62 |
+
$ch = curl_init();
|
63 |
+
$timeout = 5;
|
64 |
+
curl_setopt($ch,CURLOPT_URL,$url);
|
65 |
+
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
|
66 |
+
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
|
67 |
+
$data = curl_exec($ch);
|
68 |
+
$curlError = curl_error($ch);
|
69 |
+
curl_close($ch);
|
70 |
+
if(!empty($curlError)) {
|
71 |
+
Mage::throwException('get_data: ' . $curlError .' Request Url: ' . $url);
|
72 |
+
}
|
73 |
+
}
|
74 |
+
catch (Exception $e) {
|
75 |
+
Mage::logException($e);
|
76 |
+
}
|
77 |
+
|
78 |
+
return $data;
|
79 |
+
}
|
80 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Model/SalespersonSearchApi.php
RENAMED
@@ -1,567 +1,593 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
*
|
8 |
-
*/
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
class Celebros_Salesperson_Model_SalespersonSearchApi extends Mage_Core_Model_Abstract
|
31 |
-
{
|
32 |
-
|
33 |
-
var $CommunicationPort; //The name of the comm port to use for access to the search server.
|
34 |
-
var $HostName; //The name of the search server to connect to.
|
35 |
-
var $SiteKey; //the api site key.
|
36 |
-
var $LastOperationErrorMessage; //the last operation error message.
|
37 |
-
var $LastOperationSucceeded; //return true if the last operation ended successfully.
|
38 |
-
var $WebService; //Search WebService full uri.
|
39 |
-
|
40 |
-
public $results;
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Init resource model
|
44 |
-
*
|
45 |
-
*/
|
46 |
-
protected function _construct()
|
47 |
-
{
|
48 |
-
$this->_init('salesperson/salespersonSearchApi');
|
49 |
-
if (Mage::getStoreConfig('salesperson/general_settings/host') != '' && Mage::getStoreConfig('salesperson/general_settings/port') != '' && Mage::getStoreConfig('salesperson/general_settings/sitekey') != ''){
|
50 |
-
$this->HostName = Mage::getStoreConfig('salesperson/general_settings/host');
|
51 |
-
if (preg_match('/http:\/\//',$this->HostName)){
|
52 |
-
$this->HostName = preg_replace('/http::\/\//','', $this->HostName);
|
53 |
-
}
|
54 |
-
$this->CommunicationPort = Mage::getStoreConfig('salesperson/general_settings/port');
|
55 |
-
$this->SiteKey = Mage::getStoreConfig('salesperson/general_settings/sitekey');
|
56 |
-
$this->WebService ="http://".$this->HostName.":".$this->CommunicationPort."/";
|
57 |
-
$this->LastOperationSucceeded = true;
|
58 |
-
}
|
59 |
-
}
|
60 |
-
|
61 |
-
//Activate serach Profile
|
62 |
-
Function ActivateProfile($SearchHandle,$SearchProfile)
|
63 |
-
{
|
64 |
-
$SearchProfile = urlencode($SearchProfile);
|
65 |
-
$RequestUrl = "ActivateProfile?SearchHandle=".$SearchHandle."&SearchProfile=".$SearchProfile."&Sitekey=".$this->SiteKey;
|
66 |
-
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
67 |
-
return $this;
|
68 |
-
}
|
69 |
-
|
70 |
-
//Answer Question
|
71 |
-
Function AnswerQuestion($SearchHandle,$AnswerId,$EffectOnSearchPath)
|
72 |
-
{
|
73 |
-
$RequestUrl = "AnswerQuestion?SearchHandle=".$SearchHandle."&answerId=".$AnswerId."&EffectOnSearchPath=".$EffectOnSearchPath."&Sitekey=".$this->SiteKey;
|
74 |
-
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
75 |
-
return $this;
|
76 |
-
}
|
77 |
-
|
78 |
-
//
|
79 |
-
Function
|
80 |
-
{
|
81 |
-
$RequestUrl = "
|
82 |
-
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
83 |
-
return $this;
|
84 |
-
}
|
85 |
-
|
86 |
-
//Change
|
87 |
-
Function
|
88 |
-
{
|
89 |
-
$RequestUrl = "
|
90 |
-
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
91 |
-
return $this;
|
92 |
-
}
|
93 |
-
|
94 |
-
//
|
95 |
-
Function
|
96 |
-
{
|
97 |
-
$RequestUrl = "
|
98 |
-
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
99 |
-
return $this;
|
100 |
-
}
|
101 |
-
|
102 |
-
//
|
103 |
-
Function
|
104 |
-
{
|
105 |
-
$RequestUrl = "
|
106 |
-
$this->results =
|
107 |
-
return $this;
|
108 |
-
}
|
109 |
-
|
110 |
-
//
|
111 |
-
Function
|
112 |
-
{
|
113 |
-
$RequestUrl = "
|
114 |
-
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
115 |
-
return $this;
|
116 |
-
}
|
117 |
-
|
118 |
-
//
|
119 |
-
Function
|
120 |
-
{
|
121 |
-
$RequestUrl = "
|
122 |
-
$this->results = $this->GetResult($RequestUrl,"
|
123 |
-
return $this;
|
124 |
-
}
|
125 |
-
|
126 |
-
//
|
127 |
-
Function
|
128 |
-
{
|
129 |
-
$RequestUrl = "
|
130 |
-
$this->results = $this->GetResult($RequestUrl,"
|
131 |
-
return $this;
|
132 |
-
}
|
133 |
-
|
134 |
-
//Return all
|
135 |
-
Function
|
136 |
-
{
|
137 |
-
$RequestUrl = "
|
138 |
-
$this->results = $this->GetResult($RequestUrl,"
|
139 |
-
return $this;
|
140 |
-
}
|
141 |
-
|
142 |
-
//
|
143 |
-
Function
|
144 |
-
{
|
145 |
-
$RequestUrl = "
|
146 |
-
$this->results = $this->GetResult($RequestUrl,"
|
147 |
-
return $this;
|
148 |
-
}
|
149 |
-
|
150 |
-
//Gets
|
151 |
-
Function
|
152 |
-
{
|
153 |
-
$RequestUrl = "
|
154 |
-
$this->results = $this->GetResult($RequestUrl,"
|
155 |
-
return $this;
|
156 |
-
}
|
157 |
-
|
158 |
-
//Gets
|
159 |
-
Function
|
160 |
-
{
|
161 |
-
$
|
162 |
-
$
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
$
|
171 |
-
$
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
$RequestUrl = "
|
180 |
-
$this->results = $this->GetResult($RequestUrl,"
|
181 |
-
return $this;
|
182 |
-
}
|
183 |
-
|
184 |
-
//
|
185 |
-
Function
|
186 |
-
{
|
187 |
-
$
|
188 |
-
$
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
$RequestUrl = "
|
197 |
-
$this->results = $this->GetResult($RequestUrl,"
|
198 |
-
return $this;
|
199 |
-
}
|
200 |
-
|
201 |
-
//
|
202 |
-
Function
|
203 |
-
{
|
204 |
-
$RequestUrl = "
|
205 |
-
$this->results = $this->GetResult($RequestUrl,"
|
206 |
-
return $this;
|
207 |
-
}
|
208 |
-
|
209 |
-
//
|
210 |
-
Function
|
211 |
-
{
|
212 |
-
$RequestUrl = "
|
213 |
-
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
214 |
-
return $this;
|
215 |
-
}
|
216 |
-
|
217 |
-
//Moves to the
|
218 |
-
Function
|
219 |
-
{
|
220 |
-
$RequestUrl = "
|
221 |
-
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
222 |
-
return $this;
|
223 |
-
}
|
224 |
-
|
225 |
-
//Moves to the
|
226 |
-
Function
|
227 |
-
{
|
228 |
-
$RequestUrl = "
|
229 |
-
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
230 |
-
return $this;
|
231 |
-
}
|
232 |
-
|
233 |
-
//
|
234 |
-
Function
|
235 |
-
{
|
236 |
-
$RequestUrl = "
|
237 |
-
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
238 |
-
return $this;
|
239 |
-
}
|
240 |
-
|
241 |
-
//Removes the specified
|
242 |
-
Function
|
243 |
-
{
|
244 |
-
$RequestUrl = "
|
245 |
-
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
246 |
-
return $this;
|
247 |
-
}
|
248 |
-
|
249 |
-
//Removes the specified answers from the list of answered answers in this session.
|
250 |
-
Function
|
251 |
-
{
|
252 |
-
$RequestUrl = "
|
253 |
-
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
254 |
-
return $this;
|
255 |
-
}
|
256 |
-
|
257 |
-
//
|
258 |
-
Function
|
259 |
-
{
|
260 |
-
$RequestUrl = "
|
261 |
-
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
$
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
$
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
$
|
289 |
-
$
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
$
|
298 |
-
$
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
$
|
310 |
-
$
|
311 |
-
$this->
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
$
|
319 |
-
|
320 |
-
$this->
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
$RequestUrl = "
|
328 |
-
|
329 |
-
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
330 |
-
return $this;
|
331 |
-
}
|
332 |
-
|
333 |
-
//Changes the sorting of the results to display products by
|
334 |
-
Function
|
335 |
-
{
|
336 |
-
$RequestUrl = "
|
337 |
-
|
338 |
-
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
339 |
-
return $this;
|
340 |
-
}
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
$
|
399 |
-
|
400 |
-
//
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
//
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
}
|
552 |
-
|
553 |
-
//Global function: Returns Array of
|
554 |
-
function
|
555 |
-
{
|
556 |
-
$
|
557 |
-
$
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
567 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
|
10 |
+
//require_once(dirname(dirname(__FILE__)).DS."Model".DS."Api".DS."SearchInformation.php");
|
11 |
+
//*require_once(dirname(dirname(__FILE__)).DS."Model".DS."Api".DS."QwiserSearchResults.php");
|
12 |
+
//require_once(dirname(dirname(__FILE__)).DS."Model".DS."Api".DS."QwiserProducts.php");
|
13 |
+
//*require_once(dirname(dirname(__FILE__)).DS."Model".DS."Api".DS."QwiserProduct.php");
|
14 |
+
//require_once(dirname(dirname(__FILE__)).DS."Model".DS."Api".DS."SortingOptions.php");
|
15 |
+
//require_once(dirname(dirname(__FILE__)).DS."Model".DS."Api".DS."QwiserQuestions.php");
|
16 |
+
//require_once(dirname(dirname(__FILE__)).DS."Model".DS."Api".DS."QwiserQuestion.php");
|
17 |
+
//require_once(dirname(dirname(__FILE__)).DS."Model".DS."Api".DS."QwiserAnswers.php");
|
18 |
+
//require_once(dirname(dirname(__FILE__)).DS."Model".DS."Api".DS."QwiserAnswer.php");
|
19 |
+
//require_once(dirname(dirname(__FILE__)).DS."Model".DS."Api".DS."QwiserSearchPath.php");
|
20 |
+
//require_once(dirname(dirname(__FILE__)).DS."Model".DS."Api".DS."QwiserSearchPathEntry.php");
|
21 |
+
//require_once(dirname(dirname(__FILE__)).DS."Model".DS."Api".DS."QwiserSpellerInformation.php");
|
22 |
+
//require_once(dirname(dirname(__FILE__)).DS."Model".DS."Api".DS."QwiserConcepts.php");
|
23 |
+
//require_once(dirname(dirname(__FILE__)).DS."Model".DS."Api".DS."QwiserConcept.php");
|
24 |
+
//*require_once(dirname(dirname(__FILE__)).DS."Model".DS."Api".DS."QwiserProductAnswers.php");
|
25 |
+
//require_once(dirname(dirname(__FILE__)).DS."Model".DS."Api".DS."QwiserProductAnswer.php");
|
26 |
+
//*require_once(dirname(dirname(__FILE__)).DS."Model".DS."Api".DS."QwiserProductFields.php");
|
27 |
+
//require_once(dirname(dirname(__FILE__)).DS."Model".DS."Api".DS."QwiserProductField.php");
|
28 |
+
//require_once(dirname(dirname(__FILE__)).DS."Model".DS."Api".DS."domxml-php4-to-php5.php");
|
29 |
+
|
30 |
+
class Celebros_Salesperson_Model_SalespersonSearchApi extends Mage_Core_Model_Abstract
|
31 |
+
{
|
32 |
+
|
33 |
+
var $CommunicationPort; //The name of the comm port to use for access to the search server.
|
34 |
+
var $HostName; //The name of the search server to connect to.
|
35 |
+
var $SiteKey; //the api site key.
|
36 |
+
var $LastOperationErrorMessage; //the last operation error message.
|
37 |
+
var $LastOperationSucceeded; //return true if the last operation ended successfully.
|
38 |
+
var $WebService; //Search WebService full uri.
|
39 |
+
|
40 |
+
public $results;
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Init resource model
|
44 |
+
*
|
45 |
+
*/
|
46 |
+
protected function _construct()
|
47 |
+
{
|
48 |
+
$this->_init('salesperson/salespersonSearchApi');
|
49 |
+
if (Mage::getStoreConfig('salesperson/general_settings/host') != '' && Mage::getStoreConfig('salesperson/general_settings/port') != '' && Mage::getStoreConfig('salesperson/general_settings/sitekey') != ''){
|
50 |
+
$this->HostName = Mage::getStoreConfig('salesperson/general_settings/host');
|
51 |
+
if (preg_match('/http:\/\//',$this->HostName)){
|
52 |
+
$this->HostName = preg_replace('/http::\/\//','', $this->HostName);
|
53 |
+
}
|
54 |
+
$this->CommunicationPort = Mage::getStoreConfig('salesperson/general_settings/port');
|
55 |
+
$this->SiteKey = Mage::getStoreConfig('salesperson/general_settings/sitekey');
|
56 |
+
$this->WebService ="http://".$this->HostName.":".$this->CommunicationPort."/";
|
57 |
+
$this->LastOperationSucceeded = true;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
//Activate serach Profile
|
62 |
+
Function ActivateProfile($SearchHandle,$SearchProfile)
|
63 |
+
{
|
64 |
+
$SearchProfile = urlencode($SearchProfile);
|
65 |
+
$RequestUrl = "ActivateProfile?SearchHandle=".$SearchHandle."&SearchProfile=".$SearchProfile."&Sitekey=".$this->SiteKey;
|
66 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
67 |
+
return $this;
|
68 |
+
}
|
69 |
+
|
70 |
+
//Answer Question
|
71 |
+
Function AnswerQuestion($SearchHandle,$AnswerId,$EffectOnSearchPath)
|
72 |
+
{
|
73 |
+
$RequestUrl = "AnswerQuestion?SearchHandle=".$SearchHandle."&answerId=".$AnswerId."&EffectOnSearchPath=".$EffectOnSearchPath."&Sitekey=".$this->SiteKey;
|
74 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
75 |
+
return $this;
|
76 |
+
}
|
77 |
+
|
78 |
+
//Answer Questions
|
79 |
+
Function AnswerQuestions($SearchHandle,$AnswerIds,$EffectOnSearchPath)
|
80 |
+
{
|
81 |
+
$RequestUrl = "AnswerQuestions?SearchHandle=".$SearchHandle."&answerIds=".$AnswerIds."&EffectOnSearchPath=".$EffectOnSearchPath."&Sitekey=".$this->SiteKey;
|
82 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
83 |
+
return $this;
|
84 |
+
}
|
85 |
+
|
86 |
+
//Change Number of Products in Page
|
87 |
+
Function ChangePageSize($SearchHandle,$PageSize)
|
88 |
+
{
|
89 |
+
$RequestUrl = "ChangePageSize?SearchHandle=".$SearchHandle."&pageSize=".$PageSize."&Sitekey=".$this->SiteKey;
|
90 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
91 |
+
return $this;
|
92 |
+
}
|
93 |
+
|
94 |
+
//Change the search default price
|
95 |
+
Function ChangePriceColumn($SearchHandle,$PriceColumn)
|
96 |
+
{
|
97 |
+
$RequestUrl = "ChangePriceColumn?SearchHandle=".$SearchHandle."&PriceColumn=".$PriceColumn."&Sitekey=".$this->SiteKey;
|
98 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
99 |
+
return $this;
|
100 |
+
}
|
101 |
+
|
102 |
+
//Deactivate Search Profile
|
103 |
+
Function DeactivateProfile($SearchHandle)
|
104 |
+
{
|
105 |
+
$RequestUrl = "DeactivateProfile?SearchHandle=".$SearchHandle."&Sitekey=".$this->SiteKey;
|
106 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
107 |
+
return $this;
|
108 |
+
}
|
109 |
+
|
110 |
+
//Moves to the first page of the results
|
111 |
+
Function FirstPage($SearchHandle)
|
112 |
+
{
|
113 |
+
$RequestUrl = "FirstPage?SearchHandle=".$SearchHandle."&Sitekey=".$this->SiteKey;
|
114 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
115 |
+
return $this;
|
116 |
+
}
|
117 |
+
|
118 |
+
//Forces the BQF to allow the specified question to appear first
|
119 |
+
Function ForceQuestionAsFirst($SearchHandle,$QuestionId)
|
120 |
+
{
|
121 |
+
$RequestUrl = "ForceQuestionAsFirst?SearchHandle=".$SearchHandle."&QuestionId=".$QuestionId."&Sitekey=".$this->SiteKey;
|
122 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
123 |
+
return $this;
|
124 |
+
}
|
125 |
+
|
126 |
+
//Get alll the product fields
|
127 |
+
Function GetAllProductFields()
|
128 |
+
{
|
129 |
+
$RequestUrl = "GetAllProductFields?Sitekey=".$this->SiteKey;
|
130 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserProductFields");
|
131 |
+
return $this;
|
132 |
+
}
|
133 |
+
|
134 |
+
//Return all the questions
|
135 |
+
Function GetAllQuestions()
|
136 |
+
{
|
137 |
+
$RequestUrl = "GetAllQuestions?Sitekey=".$this->SiteKey;
|
138 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserQuestions");
|
139 |
+
return $this;
|
140 |
+
}
|
141 |
+
|
142 |
+
//Return all search profiles
|
143 |
+
Function GetAllSearchProfiles()
|
144 |
+
{
|
145 |
+
$RequestUrl = "GetAllSearchProfiles?Sitekey=".$this->SiteKey;
|
146 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSimpleStringCollection");
|
147 |
+
return $this;
|
148 |
+
}
|
149 |
+
|
150 |
+
//Gets the results for the specified search handle
|
151 |
+
Function GetCustomResults($SearchHandle,$bNewSearch,$PreviousSearchHandle)
|
152 |
+
{
|
153 |
+
$RequestUrl = "GetCustomResults?SearchHandle=".$SearchHandle."&NewSearch=".$bNewSearch."&PreviousSearchHandle=".$PreviousSearchHandle."&Sitekey=".$this->SiteKey;
|
154 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
155 |
+
return $this;
|
156 |
+
}
|
157 |
+
|
158 |
+
//Gets Engine Status
|
159 |
+
Function GetEngineStatus()
|
160 |
+
{
|
161 |
+
$RequestUrl = "GetEngineStatus?Sitekey=".$this->SiteKey;
|
162 |
+
$this->results = $this->GetResult($RequestUrl,"String");
|
163 |
+
return $this;
|
164 |
+
}
|
165 |
+
|
166 |
+
//Gets all the answers that a product exists in
|
167 |
+
Function GetProductAnswers($Sku)
|
168 |
+
{
|
169 |
+
$Sku = urlencode($Sku);
|
170 |
+
$RequestUrl = "GetProductAnswers?Sku=".$Sku."&Sitekey=".$this->SiteKey;
|
171 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserProductAnswers");
|
172 |
+
return $this;
|
173 |
+
}
|
174 |
+
|
175 |
+
//Gets the full path to the best answer for this product under the selected question for the �View All� feature (in the SPD).
|
176 |
+
Function GetProductSearchPath($Sku)
|
177 |
+
{
|
178 |
+
$Sku = urlencode($Sku);
|
179 |
+
$RequestUrl = "GetProductSearchPath?Sku=".$Sku."&Sitekey=".$this->SiteKey;
|
180 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchPath");
|
181 |
+
return $this;
|
182 |
+
}
|
183 |
+
|
184 |
+
//Returns the answers for a specific question
|
185 |
+
Function GetQuestionAnswers($QuestionId)
|
186 |
+
{
|
187 |
+
$RequestUrl = "GetQuestionAnswers?QuestionId=".$QuestionId."&Sitekey=".$this->SiteKey;
|
188 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserAnswers");
|
189 |
+
return $this;
|
190 |
+
}
|
191 |
+
|
192 |
+
//return all the question ampped to the given search profile
|
193 |
+
Function GetSearchProfileQuestions($SearchProfile)
|
194 |
+
{
|
195 |
+
$SearchProfile = urlencode($SearchProfile);
|
196 |
+
$RequestUrl = "GetSearchProfileQuestions?SearchProfile=".$SearchProfile."&Sitekey=".$this->SiteKey;
|
197 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserQuestions");
|
198 |
+
return $this;
|
199 |
+
}
|
200 |
+
|
201 |
+
//Gets all the answers a collection of products exist in.
|
202 |
+
Function GetSeveralProductsAnswers($Skus)
|
203 |
+
{
|
204 |
+
$RequestUrl = "GetSeveralProductsAnswers?Skus=".$Skus."&Sitekey=".$this->SiteKey;
|
205 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserProductAnswers");
|
206 |
+
return $this;
|
207 |
+
}
|
208 |
+
|
209 |
+
//Return the LastPage.
|
210 |
+
Function LastPage($SearchHandle)
|
211 |
+
{
|
212 |
+
$RequestUrl = "LastPage?SearchHandle=".$SearchHandle."&Sitekey=".$this->SiteKey;
|
213 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
214 |
+
return $this;
|
215 |
+
}
|
216 |
+
|
217 |
+
//Moves to the specified page of the results
|
218 |
+
Function MoveToPage($SearchHandle,$Page)
|
219 |
+
{
|
220 |
+
$RequestUrl = "MoveToPage?SearchHandle=".$SearchHandle."&Page=".$Page."&Sitekey=".$this->SiteKey;
|
221 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
222 |
+
return $this;
|
223 |
+
}
|
224 |
+
|
225 |
+
//Moves to the previous page of the results
|
226 |
+
Function PreviousPage($SearchHandle)
|
227 |
+
{
|
228 |
+
$RequestUrl = "PreviousPage?SearchHandle=".$SearchHandle."&Sitekey=".$this->SiteKey;
|
229 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
230 |
+
return $this;
|
231 |
+
}
|
232 |
+
|
233 |
+
//Moves to the next page of the results
|
234 |
+
Function NextPage($SearchHandle)
|
235 |
+
{
|
236 |
+
$RequestUrl = "NextPage?SearchHandle=".$SearchHandle."&Sitekey=".$this->SiteKey;
|
237 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
238 |
+
return $this;
|
239 |
+
}
|
240 |
+
|
241 |
+
//Removes the specified answer from the list of answered answers in this session.
|
242 |
+
Function RemoveAnswer($SearchHandle,$AnswerId)
|
243 |
+
{
|
244 |
+
$RequestUrl = "RemoveAnswer?SearchHandle=".$SearchHandle."&AnswerId=".$AnswerId."&Sitekey=".$this->SiteKey;
|
245 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
246 |
+
return $this;
|
247 |
+
}
|
248 |
+
|
249 |
+
//Removes the specified answers from the list of answered answers in this session.
|
250 |
+
Function RemoveAnswerAt($SearchHandle,$AnswerIndex)
|
251 |
+
{
|
252 |
+
$RequestUrl = "RemoveAnswerAt?SearchHandle=".$SearchHandle."&AnswerIndex=".$AnswerIndex."&Sitekey=".$this->SiteKey;
|
253 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
254 |
+
return $this;
|
255 |
+
}
|
256 |
+
|
257 |
+
//Removes the specified answers from the list of answered answers in this session.
|
258 |
+
Function RemoveAnswers($SearchHandle,$AnswerIds)
|
259 |
+
{
|
260 |
+
$RequestUrl = "RemoveAnswers?SearchHandle=".$SearchHandle."&AnswerIds=".$AnswerIds."&Sitekey=".$this->SiteKey;
|
261 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
262 |
+
return $this;
|
263 |
+
}
|
264 |
+
|
265 |
+
//Remove the all the answer from the search information form the given index
|
266 |
+
Function RemoveAnswersFrom($SearchHandle,$StartIndex)
|
267 |
+
{
|
268 |
+
$RequestUrl = "RemoveAnswersFrom?SearchHandle=".$SearchHandle."&StartIndex=".$StartIndex."&Sitekey=".$this->SiteKey;
|
269 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
270 |
+
|
271 |
+
return $this;
|
272 |
+
}
|
273 |
+
|
274 |
+
//Marks a product as out of stock.
|
275 |
+
Function RemoveProductFromStock($Sku)
|
276 |
+
{
|
277 |
+
$Sku = urlencode($Sku);
|
278 |
+
$RequestUrl = "RemoveProductFromStock?Sku=".$Sku."&Sitekey=".$this->SiteKey;
|
279 |
+
$this->results = $this->GetResult($RequestUrl,"String");
|
280 |
+
|
281 |
+
return $this;
|
282 |
+
}
|
283 |
+
|
284 |
+
//Marks a product as in stock.
|
285 |
+
Function RestoreProductToStock($Sku)
|
286 |
+
{
|
287 |
+
$Sku = urlencode($Sku);
|
288 |
+
$RequestUrl = "RestoreProductToStock?Sku=".$Sku."&Sitekey=".$this->SiteKey;
|
289 |
+
$this->results = $this->GetResult($RequestUrl,"String");
|
290 |
+
return $this;
|
291 |
+
}
|
292 |
+
|
293 |
+
//Gets the results for the specified search term.
|
294 |
+
Function Search($Query)
|
295 |
+
{
|
296 |
+
$Query = urlencode($Query);
|
297 |
+
$RequestUrl = "search?Query=".$Query."&sitekey=".$this->SiteKey;
|
298 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
299 |
+
return $this;
|
300 |
+
}
|
301 |
+
|
302 |
+
//Gets the results for the specified search term under the specified search profile and the answer which Id was specified.
|
303 |
+
Function SearchAdvance($Query,$SearchProfile,$AnswerId,$EffectOnSearchPath,$PriceColumn,$PageSize,$Sortingfield,$bNumericsort,$bAscending)
|
304 |
+
{
|
305 |
+
$Query = urlencode($Query);
|
306 |
+
$SearchProfile = urlencode($SearchProfile);
|
307 |
+
$Sortingfield = urlencode($Sortingfield);
|
308 |
+
//$PriceColumn = urlencode($PriceColumn);
|
309 |
+
$PriceColumn = "";
|
310 |
+
$RequestUrl = "SearchAdvance?Query=".$Query."&SearchProfile=".$SearchProfile."&AnswerId=".$AnswerId."&EffectOnSearchPath=".$EffectOnSearchPath."&PriceColumn=".$PriceColumn."&PageSize=".$PageSize."&Sortingfield=".$Sortingfield."&Numericsort=".$bNumericsort."&Ascending=".$bAscending."&sitekey=".$this->SiteKey;
|
311 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
312 |
+
return $this;
|
313 |
+
}
|
314 |
+
|
315 |
+
//set the general params of the api
|
316 |
+
Function SetQwiserSearchAPI($siteKey ,$serverName ,$port )
|
317 |
+
{
|
318 |
+
$this->SiteKey = $siteKey;
|
319 |
+
$this->HostName = $serverName;
|
320 |
+
$this->CommunicationPort = $port;
|
321 |
+
}
|
322 |
+
|
323 |
+
//Changes the sorting of the results to display products by the value of the specified field, and whether to perform a numeric sort on that field, in the specified sorting direction.
|
324 |
+
Function SortByField($SearchHandle,$FieldName,$bNumericSort,$bAscending)
|
325 |
+
{
|
326 |
+
$FieldName = urlencode($FieldName);
|
327 |
+
$RequestUrl = "SortByField?SearchHandle=".$SearchHandle."&FieldName=".$FieldName."&NumericSort=".$bNumericSort."&Ascending=".$bAscending."&sitekey=".$this->SiteKey;
|
328 |
+
|
329 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
330 |
+
return $this;
|
331 |
+
}
|
332 |
+
|
333 |
+
//Changes the sorting of the results to display products by their price in the specified sorting direction
|
334 |
+
Function SortByPrice($SearchHandle,$bAscending)
|
335 |
+
{
|
336 |
+
$RequestUrl = "SortByPrice?SearchHandle=".$SearchHandle."&Ascending=".$bAscending."&sitekey=".$this->SiteKey;
|
337 |
+
|
338 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
339 |
+
return $this;
|
340 |
+
}
|
341 |
+
|
342 |
+
//Changes the sorting of the results to display products by relevancy in descending order.
|
343 |
+
Function SortByRelevancy($SearchHandle)
|
344 |
+
{
|
345 |
+
$RequestUrl = "SortByRelevancy?SearchHandle=".$SearchHandle."&Sitekey=".$this->SiteKey;
|
346 |
+
|
347 |
+
$this->results = $this->GetResult($RequestUrl,"QwiserSearchResults");
|
348 |
+
return $this;
|
349 |
+
}
|
350 |
+
|
351 |
+
Function get_data($url)
|
352 |
+
{
|
353 |
+
//var_dump($url); exit();
|
354 |
+
$data = null;
|
355 |
+
try {
|
356 |
+
$ch = curl_init();
|
357 |
+
$timeout = 5;
|
358 |
+
curl_setopt($ch,CURLOPT_URL,$url);
|
359 |
+
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
|
360 |
+
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
|
361 |
+
|
362 |
+
curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
|
363 |
+
curl_setopt($ch, CURLOPT_HEADER, 1);
|
364 |
+
|
365 |
+
curl_setopt($ch, CURLOPT_ENCODING, "gzip,deflate");
|
366 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
367 |
+
|
368 |
+
$response= curl_exec($ch);
|
369 |
+
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
|
370 |
+
$data = $this->parse_response($response, $header_size);
|
371 |
+
|
372 |
+
$curlError = curl_error($ch);
|
373 |
+
curl_close($ch);
|
374 |
+
if(!empty($curlError)) {
|
375 |
+
Mage::throwException('get_data: ' . $curlError .' Request Url: ' . $url);
|
376 |
+
}
|
377 |
+
}
|
378 |
+
catch (Exception $e) {
|
379 |
+
Mage::logException($e);
|
380 |
+
}
|
381 |
+
return $data;
|
382 |
+
}
|
383 |
+
|
384 |
+
Function parse_response($response, $header_size) {
|
385 |
+
$header = substr($response, 0, $header_size);
|
386 |
+
$data = substr($response, $header_size);
|
387 |
+
|
388 |
+
return $data;
|
389 |
+
}
|
390 |
+
|
391 |
+
//Gets the xml file, parse it and chack for Errors.
|
392 |
+
Function GetResult($RequestUrl,$ReturnValue)
|
393 |
+
{
|
394 |
+
if(!$this->WebService) {
|
395 |
+
Mage::throwException(Mage::helper('salesperson')->__('Salesperson configuration error! Check saleseperson admin host general settings.'));
|
396 |
+
}
|
397 |
+
|
398 |
+
//print $this->WebService.$RequestUrl;
|
399 |
+
//get xml file from url.
|
400 |
+
//echo $this->WebService.$RequestUrl; exit();
|
401 |
+
//$xml_file = file_get_contents($this->WebService.$RequestUrl);
|
402 |
+
$xml_file = $this->get_data($this->WebService.$RequestUrl);
|
403 |
+
|
404 |
+
//file_get_contents return value should be true.
|
405 |
+
if(!$xml_file)
|
406 |
+
{
|
407 |
+
$this->LastOperationSucceeded = false;
|
408 |
+
$this->LastOperationErrorMessage = "Error : could not GET XML input, there might be a problem with the connection";
|
409 |
+
return;
|
410 |
+
}
|
411 |
+
|
412 |
+
//Parse the xml file with php4 Dom parser.
|
413 |
+
$xml_doc= Mage::getModel('salesperson/Api_DomXMLPhp4ToPhp5')->domxml_open_mem($xml_file);
|
414 |
+
|
415 |
+
//domxml_open_mem should Return object.
|
416 |
+
if ((!is_object($xml_doc)) && !$xml_doc)
|
417 |
+
{
|
418 |
+
$this->LastOperationSucceeded = false;
|
419 |
+
$this->LastOperationErrorMessage = "Error : could not parse XML input, there might be a problem with the connection";
|
420 |
+
return ;
|
421 |
+
}
|
422 |
+
|
423 |
+
//Get the Root Element.
|
424 |
+
$xml_root=$xml_doc->document_element();
|
425 |
+
|
426 |
+
//Check the ErrorOccured node in the xml file
|
427 |
+
// if(!$this->CheckForAPIErrors($xml_root))
|
428 |
+
// {
|
429 |
+
// return ;
|
430 |
+
// }
|
431 |
+
|
432 |
+
return $this->GetReturnValue($xml_root,$ReturnValue);
|
433 |
+
}
|
434 |
+
|
435 |
+
//return value by xml type
|
436 |
+
function GetReturnValue($xml_root,$ReturnValue)
|
437 |
+
{
|
438 |
+
switch ($ReturnValue)
|
439 |
+
{
|
440 |
+
case "QwiserSearchResults":
|
441 |
+
return (new Celebros_Salesperson_Model_Api_QwiserSearchResults($xml_root));
|
442 |
+
break;
|
443 |
+
case "String":
|
444 |
+
return $this->SimpleStringParser($xml_root);
|
445 |
+
break;
|
446 |
+
case "QwiserQuestions":
|
447 |
+
return (new Celebros_Salesperson_Model_Api_QwiserQuestions(current($xml_root->get_elements_by_tagname("Questions"))));
|
448 |
+
break;
|
449 |
+
case "QwiserProductAnswers":
|
450 |
+
return (new Celebros_Salesperson_Model_Api_QwiserProductAnswers(current($xml_root->get_elements_by_tagname("ProductAnswers"))));
|
451 |
+
break;
|
452 |
+
case "QwiserProductFields":
|
453 |
+
return (new Celebros_Salesperson_Model_Api_QwiserProductFields(current($xml_root->get_elements_by_tagname("ProductFields"))));
|
454 |
+
break;
|
455 |
+
case "QwiserSearchPath":
|
456 |
+
return (new Celebros_Salesperson_Model_Api_QwiserSearchPath(current($xml_root->get_elements_by_tagname("SearchPath"))));
|
457 |
+
break;
|
458 |
+
case "QwiserAnswers":
|
459 |
+
return (new Celebros_Salesperson_Model_Api_QwiserAnswers(current($xml_root->get_elements_by_tagname("Answers"))));
|
460 |
+
break;
|
461 |
+
case "QwiserSimpleStringCollection":
|
462 |
+
return GetQwiserSimpleStringCollection(current($xml_root->get_elements_by_tagname("QwiserSimpleStringCollection")));
|
463 |
+
break;
|
464 |
+
}
|
465 |
+
}
|
466 |
+
|
467 |
+
//Checks the error node
|
468 |
+
function CheckForAPIErrors($xml_root)
|
469 |
+
{
|
470 |
+
|
471 |
+
$ErrorNode = current($xml_root->get_elements_by_tagname("LastError"));
|
472 |
+
if(is_object($ErrorNode))
|
473 |
+
{
|
474 |
+
$MethodName = $ErrorNode->get_attribute("MethodName");
|
475 |
+
if($MethodName=="")
|
476 |
+
return true;
|
477 |
+
$ErrorMessage = $ErrorNode->get_attribute("ErrorMessage");
|
478 |
+
$this->LastOperationErrorMessage = "Error: MethodName=".$MethodName." ErrorMessage=".$ErrorMessage;
|
479 |
+
|
480 |
+
$this->LastOperationSucceeded = false;
|
481 |
+
|
482 |
+
}
|
483 |
+
else {
|
484 |
+
$this->LastOperationErrorMessage = "Error: ".$xml_root->get_content();
|
485 |
+
|
486 |
+
}
|
487 |
+
|
488 |
+
return false;
|
489 |
+
|
490 |
+
}
|
491 |
+
|
492 |
+
//returns the "ReturnValue" node as string
|
493 |
+
function SimpleStringParser($xml_root)
|
494 |
+
{
|
495 |
+
$StringValue = current($xml_root->get_elements_by_tagname("ReturnValue"));
|
496 |
+
return $StringValue->get_content();
|
497 |
+
}
|
498 |
+
|
499 |
+
///////////////////////////////////////////////////////////////////////////////
|
500 |
+
|
501 |
+
/**
|
502 |
+
* Retrieve minimum query length
|
503 |
+
*
|
504 |
+
* @deprecated after 1.3.2.3 use getMinQueryLength() instead
|
505 |
+
* @return int
|
506 |
+
*/
|
507 |
+
public function getMinQueryLenght()
|
508 |
+
{
|
509 |
+
return Mage::getStoreConfig(self::XML_PATH_MIN_QUERY_LENGTH, $this->getStoreId());
|
510 |
+
}
|
511 |
+
|
512 |
+
/**
|
513 |
+
* Retrieve minimum query length
|
514 |
+
*
|
515 |
+
* @return int
|
516 |
+
*/
|
517 |
+
public function getMinQueryLength(){
|
518 |
+
return $this->getMinQueryLenght();
|
519 |
+
}
|
520 |
+
|
521 |
+
/**
|
522 |
+
* Retrieve maximum query length
|
523 |
+
*
|
524 |
+
* @deprecated after 1.3.2.3 use getMaxQueryLength() instead
|
525 |
+
* @return int
|
526 |
+
*/
|
527 |
+
public function getMaxQueryLenght()
|
528 |
+
{
|
529 |
+
return Mage::getStoreConfig(self::XML_PATH_MAX_QUERY_LENGTH, $this->getStoreId());
|
530 |
+
}
|
531 |
+
|
532 |
+
/**
|
533 |
+
* Retrieve maximum query length
|
534 |
+
*
|
535 |
+
* @return int
|
536 |
+
*/
|
537 |
+
public function getMaxQueryLength()
|
538 |
+
{
|
539 |
+
return $this->getMaxQueryLenght();
|
540 |
+
}
|
541 |
+
|
542 |
+
/**
|
543 |
+
* Retrieve maximum query words for like search
|
544 |
+
*
|
545 |
+
* @return int
|
546 |
+
*/
|
547 |
+
public function getMaxQueryWords()
|
548 |
+
{
|
549 |
+
return Mage::getStoreConfig(self::XML_PATH_MAX_QUERY_WORDS, $this->getStoreId());
|
550 |
+
}
|
551 |
+
}
|
552 |
+
|
553 |
+
//Global function: Returns Array of strings from Array of nodes contents.
|
554 |
+
function GetQwiserSimpleStringCollection ($xml_node)
|
555 |
+
{
|
556 |
+
$xml_nodes = $xml_node->child_nodes();
|
557 |
+
$xml_nodes = getDomElements($xml_nodes);
|
558 |
+
$arr = array();
|
559 |
+
foreach($xml_nodes as $node)
|
560 |
+
{
|
561 |
+
$arr[] = $node->get_content();
|
562 |
+
}
|
563 |
+
return $arr;
|
564 |
+
}
|
565 |
+
|
566 |
+
//Global function: Returns hash of value .
|
567 |
+
function GetQwiserSimpleStringDictionary($xml_node)
|
568 |
+
{
|
569 |
+
$xml_nodes = $xml_node->child_nodes();
|
570 |
+
$xml_nodes = getDomElements($xml_nodes);
|
571 |
+
$arr = array();
|
572 |
+
foreach($xml_nodes as $node)
|
573 |
+
{
|
574 |
+
$arr[$node->get_attribute("name")] = $node->get_attribute("value");
|
575 |
+
}
|
576 |
+
return $arr;
|
577 |
+
}
|
578 |
+
|
579 |
+
//Global function: Returns Array of only DomElments
|
580 |
+
function getDomElements($element)
|
581 |
+
{
|
582 |
+
$p=0;
|
583 |
+
$new_element = array();
|
584 |
+
foreach ($element as $value)
|
585 |
+
{
|
586 |
+
if($value->node_type()==1)
|
587 |
+
{
|
588 |
+
$new_element[$p]=$value;
|
589 |
+
$p++;
|
590 |
+
}
|
591 |
+
}
|
592 |
+
return $new_element;
|
593 |
}
|
app/code/{local → community}/Celebros/Salesperson/Model/Session.php
RENAMED
@@ -1,22 +1,22 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Model_Session extends Mage_Core_Model_Session_Abstract
|
11 |
-
{
|
12 |
-
public function __construct()
|
13 |
-
{
|
14 |
-
$this->init('salesperson');
|
15 |
-
}
|
16 |
-
|
17 |
-
public function getDisplayMode()
|
18 |
-
{
|
19 |
-
return $this->_getData('display_mode');
|
20 |
-
}
|
21 |
-
|
22 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Model_Session extends Mage_Core_Model_Session_Abstract
|
11 |
+
{
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
$this->init('salesperson');
|
15 |
+
}
|
16 |
+
|
17 |
+
public function getDisplayMode()
|
18 |
+
{
|
19 |
+
return $this->_getData('display_mode');
|
20 |
+
}
|
21 |
+
|
22 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Model/System/Config/Backend/Export/Cron.php
RENAMED
@@ -1,42 +1,42 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Model_System_Config_Backend_Export_Cron extends Mage_Core_Model_Config_Data
|
11 |
-
{
|
12 |
-
const CRON_STRING_PATH = 'crontab/jobs/salesperson_export/schedule/cron_expr';
|
13 |
-
const CRON_MODEL_PATH = 'crontab/jobs/salesperson_export/run/model';
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Cron settings after save
|
17 |
-
*
|
18 |
-
* @return Celebros_Salesperson_Model_System_Config_Backend_Export_Cron
|
19 |
-
*/
|
20 |
-
protected function _afterSave()
|
21 |
-
{
|
22 |
-
|
23 |
-
$cron_expr = $this->getData('groups/export_settings/fields/cron_expr/value');
|
24 |
-
try {
|
25 |
-
Mage::getModel('core/config_data')
|
26 |
-
->load(self::CRON_STRING_PATH, 'path')
|
27 |
-
->setValue($cron_expr)
|
28 |
-
->setPath(self::CRON_STRING_PATH)
|
29 |
-
->save();
|
30 |
-
|
31 |
-
Mage::getModel('core/config_data')
|
32 |
-
->load(self::CRON_MODEL_PATH, 'path')
|
33 |
-
->setValue((string) Mage::getConfig()->getNode(self::CRON_MODEL_PATH))
|
34 |
-
->setPath(self::CRON_MODEL_PATH)
|
35 |
-
->save();
|
36 |
-
}
|
37 |
-
catch (Exception $e) {
|
38 |
-
Mage::throwException(Mage::helper('adminhtml')->__($e.' - Unable to save Cron expression'));
|
39 |
-
}
|
40 |
-
|
41 |
-
}
|
42 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Model_System_Config_Backend_Export_Cron extends Mage_Core_Model_Config_Data
|
11 |
+
{
|
12 |
+
const CRON_STRING_PATH = 'crontab/jobs/salesperson_export/schedule/cron_expr';
|
13 |
+
const CRON_MODEL_PATH = 'crontab/jobs/salesperson_export/run/model';
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Cron settings after save
|
17 |
+
*
|
18 |
+
* @return Celebros_Salesperson_Model_System_Config_Backend_Export_Cron
|
19 |
+
*/
|
20 |
+
protected function _afterSave()
|
21 |
+
{
|
22 |
+
//$enabled = $this->getData('groups/export_settings/fields/cron_enabled/value');
|
23 |
+
$cron_expr = $this->getData('groups/export_settings/fields/cron_expr/value');
|
24 |
+
try {
|
25 |
+
Mage::getModel('core/config_data')
|
26 |
+
->load(self::CRON_STRING_PATH, 'path')
|
27 |
+
->setValue($cron_expr)
|
28 |
+
->setPath(self::CRON_STRING_PATH)
|
29 |
+
->save();
|
30 |
+
|
31 |
+
Mage::getModel('core/config_data')
|
32 |
+
->load(self::CRON_MODEL_PATH, 'path')
|
33 |
+
->setValue((string) Mage::getConfig()->getNode(self::CRON_MODEL_PATH))
|
34 |
+
->setPath(self::CRON_MODEL_PATH)
|
35 |
+
->save();
|
36 |
+
}
|
37 |
+
catch (Exception $e) {
|
38 |
+
Mage::throwException(Mage::helper('adminhtml')->__($e.' - Unable to save Cron expression'));
|
39 |
+
}
|
40 |
+
|
41 |
+
}
|
42 |
+
}
|
app/code/community/Celebros/Salesperson/Model/System/Config/Backend/Navigationtosearch/Enable.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Model_System_Config_Backend_Navigationtosearch_Enable extends Mage_Core_Model_Config_Data
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
*
|
14 |
+
*
|
15 |
+
* @return Celebros_Salesperson_Model_System_Config_Backend_Navigationtosearch_Enable
|
16 |
+
*/
|
17 |
+
protected function _afterSave()
|
18 |
+
{
|
19 |
+
$store_code=(Mage::app()->getRequest()->getParam('store')); // Current store scope
|
20 |
+
|
21 |
+
/*
|
22 |
+
if ($store_code=='default') // do not allow to change nav2search from the default store view. Can collide with the default scope
|
23 |
+
{
|
24 |
+
return;
|
25 |
+
}
|
26 |
+
*/
|
27 |
+
|
28 |
+
if (!(isset($store_code)))
|
29 |
+
{
|
30 |
+
$websites=Mage::app()->getWebsites();
|
31 |
+
$website=$websites['1'];
|
32 |
+
$store_code=$website->getDefaultStore()->getCode();
|
33 |
+
}
|
34 |
+
|
35 |
+
$store_col=Mage::getModel('core/store')->getCollection()->load();
|
36 |
+
foreach($store_col as $store)
|
37 |
+
{
|
38 |
+
if ($store->getCode()==$store_code)
|
39 |
+
{
|
40 |
+
$store_id=$store->getStoreId();
|
41 |
+
break;
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
if ( ($this->getData('groups/nav_to_search_settings/fields/nav_to_search/value') === "0") && (Mage::getStoreConfigFlag('salesperson/nav_to_search_settings/nav_to_search',$store_id)) )
|
46 |
+
{
|
47 |
+
$rewrites = Mage::helper('salesperson')->getCategoriesRewrites($store_id);
|
48 |
+
foreach($rewrites as $rewrite)
|
49 |
+
{
|
50 |
+
$rewrite->delete();
|
51 |
+
$rewrite->getResource()->commit();
|
52 |
+
}
|
53 |
+
|
54 |
+
$model = Mage::getModel('catalog/url');
|
55 |
+
|
56 |
+
$store = Mage::app()->getStore($store_id);
|
57 |
+
$model->refreshCategoryRewrite($store->getRootCategoryId(), $store_id, false);
|
58 |
+
} // Check if activated
|
59 |
+
elseif($this->getData('groups/nav_to_search_settings/fields/nav_to_search/value') === "1") /*&&
|
60 |
+
!Mage::getStoreConfigFlag('salesperson/nav_to_search_settings/nav_to_search',$store_id))*/
|
61 |
+
{
|
62 |
+
Mage::helper('salesperson')->updateCategoriesUrlRewrites($store_id);
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Model/System/Config/Source/Fileftp.php
RENAMED
@@ -1,19 +1,19 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Model_System_Config_Source_Fileftp
|
11 |
-
{
|
12 |
-
public function toOptionArray()
|
13 |
-
{
|
14 |
-
return array(
|
15 |
-
array('value' => 'file', 'label'=>Mage::helper('salesperson')->__('File')),
|
16 |
-
array('value' => 'ftp', 'label'=>Mage::helper('salesperson')->__('FTP')),
|
17 |
-
);
|
18 |
-
}
|
19 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Model_System_Config_Source_Fileftp
|
11 |
+
{
|
12 |
+
public function toOptionArray()
|
13 |
+
{
|
14 |
+
return array(
|
15 |
+
array('value' => 'file', 'label'=>Mage::helper('salesperson')->__('File')),
|
16 |
+
array('value' => 'ftp', 'label'=>Mage::helper('salesperson')->__('FTP')),
|
17 |
+
);
|
18 |
+
}
|
19 |
}
|
app/code/community/Celebros/Salesperson/Model/System/Config/Source/Giftfindertypes.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Model_System_Config_Source_GiftFinderTypes{
|
11 |
+
|
12 |
+
protected $_options;
|
13 |
+
|
14 |
+
public function toOptionArray()
|
15 |
+
{
|
16 |
+
if (!$this->_options) {
|
17 |
+
$this->_options = array(
|
18 |
+
array( 'value'=>'salesperson/giftfinder/view.phtml','label'=>'Standard'),
|
19 |
+
array( 'value'=>'salesperson/giftfinder/viewdynamic.phtml','label'=>'Dynamic'),
|
20 |
+
array( 'value'=>'salesperson/giftfinder/viewajaxdynamic.phtml','label'=>'Dynamic Ajax'),
|
21 |
+
);
|
22 |
+
}
|
23 |
+
return $this->_options;
|
24 |
+
}
|
25 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Model/System/Config/Source/Layouts.php
RENAMED
@@ -1,26 +1,26 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Model_System_Config_Source_Layouts{
|
11 |
-
|
12 |
-
protected $_options;
|
13 |
-
|
14 |
-
public function toOptionArray()
|
15 |
-
{
|
16 |
-
if (!$this->_options) {
|
17 |
-
$this->_options = array(
|
18 |
-
array( 'value'=>'salesperson/1column.phtml','label'=>'1 column'),
|
19 |
-
array( 'value'=>'salesperson/2columns-left.phtml','label'=>'2 columns with left bar'),
|
20 |
-
array( 'value'=>'salesperson/2columns-right.phtml','label'=>'2 columns with right bar'),
|
21 |
-
array( 'value'=>'salesperson/3columns.phtml','label'=>'3 columns'),
|
22 |
-
);
|
23 |
-
}
|
24 |
-
return $this->_options;
|
25 |
-
}
|
26 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Model_System_Config_Source_Layouts{
|
11 |
+
|
12 |
+
protected $_options;
|
13 |
+
|
14 |
+
public function toOptionArray()
|
15 |
+
{
|
16 |
+
if (!$this->_options) {
|
17 |
+
$this->_options = array(
|
18 |
+
array( 'value'=>'salesperson/1column.phtml','label'=>'1 column'),
|
19 |
+
array( 'value'=>'salesperson/2columns-left.phtml','label'=>'2 columns with left bar'),
|
20 |
+
array( 'value'=>'salesperson/2columns-right.phtml','label'=>'2 columns with right bar'),
|
21 |
+
array( 'value'=>'salesperson/3columns.phtml','label'=>'3 columns'),
|
22 |
+
);
|
23 |
+
}
|
24 |
+
return $this->_options;
|
25 |
+
}
|
26 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Model/System/Config/Source/Lead.php
RENAMED
@@ -1,19 +1,19 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Model_System_Config_Source_Lead
|
11 |
-
{
|
12 |
-
public function toOptionArray()
|
13 |
-
{
|
14 |
-
return array(
|
15 |
-
array('value' => 1, 'label'=>Mage::helper('salesperson')->__('On top')),
|
16 |
-
array('value' => 0, 'label'=>Mage::helper('salesperson')->__('None')),
|
17 |
-
);
|
18 |
-
}
|
19 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Model_System_Config_Source_Lead
|
11 |
+
{
|
12 |
+
public function toOptionArray()
|
13 |
+
{
|
14 |
+
return array(
|
15 |
+
array('value' => 1, 'label'=>Mage::helper('salesperson')->__('On top')),
|
16 |
+
array('value' => 0, 'label'=>Mage::helper('salesperson')->__('None')),
|
17 |
+
);
|
18 |
+
}
|
19 |
}
|
app/code/community/Celebros/Salesperson/Model/System/Config/Source/Navigationtosearch.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Model_System_Config_Source_Navigationtosearch
|
11 |
+
{
|
12 |
+
public function toOptionArray()
|
13 |
+
{
|
14 |
+
return array(
|
15 |
+
array('value' => 'category', 'label'=>Mage::helper('salesperson')->__('Category name')),
|
16 |
+
array('value' => 'full_path', 'label'=>Mage::helper('salesperson')->__('Full category path')),
|
17 |
+
array('value' => 'category_and_parent', 'label'=>Mage::helper('salesperson')->__('Category and category parent name')),
|
18 |
+
array('value' => 'category_and_root', 'label'=>Mage::helper('salesperson')->__('Category and category root name')),
|
19 |
+
);
|
20 |
+
}
|
21 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Model/System/Config/Source/Nonlead.php
RENAMED
@@ -1,20 +1,20 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Model_System_Config_Source_Nonlead
|
11 |
-
{
|
12 |
-
public function toOptionArray()
|
13 |
-
{
|
14 |
-
return array(
|
15 |
-
array('value' => 'top', 'label'=>Mage::helper('salesperson')->__('On top')),
|
16 |
-
array('value' => 'left', 'label'=>Mage::helper('salesperson')->__('On left')),
|
17 |
-
array('value' => 'right', 'label'=>Mage::helper('salesperson')->__('On right')),
|
18 |
-
);
|
19 |
-
}
|
20 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Model_System_Config_Source_Nonlead
|
11 |
+
{
|
12 |
+
public function toOptionArray()
|
13 |
+
{
|
14 |
+
return array(
|
15 |
+
array('value' => 'top', 'label'=>Mage::helper('salesperson')->__('On top')),
|
16 |
+
array('value' => 'left', 'label'=>Mage::helper('salesperson')->__('On left')),
|
17 |
+
array('value' => 'right', 'label'=>Mage::helper('salesperson')->__('On right')),
|
18 |
+
);
|
19 |
+
}
|
20 |
}
|
app/code/{local → community}/Celebros/Salesperson/Model/System/Config/Source/Pagenavtype.php
RENAMED
@@ -1,19 +1,19 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Model_System_Config_Source_Pagenavtype
|
11 |
-
{
|
12 |
-
public function toOptionArray()
|
13 |
-
{
|
14 |
-
return array(
|
15 |
-
array('value' => 'textual', 'label'=>Mage::helper('salesperson')->__('Limited')),
|
16 |
-
array('value' => 'multipage', 'label'=>Mage::helper('salesperson')->__('Full')),
|
17 |
-
);
|
18 |
-
}
|
19 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Model_System_Config_Source_Pagenavtype
|
11 |
+
{
|
12 |
+
public function toOptionArray()
|
13 |
+
{
|
14 |
+
return array(
|
15 |
+
array('value' => 'textual', 'label'=>Mage::helper('salesperson')->__('Limited')),
|
16 |
+
array('value' => 'multipage', 'label'=>Mage::helper('salesperson')->__('Full')),
|
17 |
+
);
|
18 |
+
}
|
19 |
}
|
app/code/community/Celebros/Salesperson/Model/System/Config/Source/Pricetype.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Model_System_Config_Source_Pricetype
|
11 |
+
{
|
12 |
+
public function toOptionArray()
|
13 |
+
{
|
14 |
+
return array(
|
15 |
+
array('value' => 'slider', 'label'=>Mage::helper('salesperson')->__('Slider')),
|
16 |
+
array('value' => 'dropdown', 'label'=>Mage::helper('salesperson')->__('Dropdown')),
|
17 |
+
);
|
18 |
+
}
|
19 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/Model/System/Config/Source/Selectortype.php
RENAMED
@@ -1,19 +1,19 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Model_System_Config_Source_Selectortype
|
11 |
-
{
|
12 |
-
public function toOptionArray()
|
13 |
-
{
|
14 |
-
return array(
|
15 |
-
array('value' => 'links', 'label'=>Mage::helper('salesperson')->__('Links')),
|
16 |
-
array('value' => 'dropdown', 'label'=>Mage::helper('salesperson')->__('Dropdown')),
|
17 |
-
);
|
18 |
-
}
|
19 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_Model_System_Config_Source_Selectortype
|
11 |
+
{
|
12 |
+
public function toOptionArray()
|
13 |
+
{
|
14 |
+
return array(
|
15 |
+
array('value' => 'links', 'label'=>Mage::helper('salesperson')->__('Links')),
|
16 |
+
array('value' => 'dropdown', 'label'=>Mage::helper('salesperson')->__('Dropdown')),
|
17 |
+
);
|
18 |
+
}
|
19 |
}
|
app/code/{local → community}/Celebros/Salesperson/controllers/Adminhtml/MappingController.php
RENAMED
@@ -1,40 +1,40 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Celebros_Salesperson_Adminhtml_MappingController extends Mage_Adminhtml_Controller_Action
|
4 |
-
{
|
5 |
-
public function indexAction()
|
6 |
-
{
|
7 |
-
$this->loadLayout()->renderLayout();
|
8 |
-
}
|
9 |
-
|
10 |
-
public function postAction()
|
11 |
-
{
|
12 |
-
$post = $this->getRequest()->getPost();
|
13 |
-
|
14 |
-
try {
|
15 |
-
if (empty($post)) {
|
16 |
-
Mage::throwException($this->__('Invalid form data.'));
|
17 |
-
}
|
18 |
-
|
19 |
-
/* here's your form processing */
|
20 |
-
|
21 |
-
$mappingModel = Mage::getSingleton("salesperson/mapping");
|
22 |
-
|
23 |
-
if (!key_exists('mapping',$post)) {
|
24 |
-
Mage::throwException($this->__('Invalid form data.'));
|
25 |
-
}
|
26 |
-
|
27 |
-
foreach($post['mapping'] as $key => $value){
|
28 |
-
$mappingModel->load($key);
|
29 |
-
$mappingModel->setXmlField($value);
|
30 |
-
$mappingModel->save();
|
31 |
-
}
|
32 |
-
|
33 |
-
$message = $this->__('The mapping has been saved successfully.');
|
34 |
-
Mage::getSingleton('adminhtml/session')->addSuccess($message);
|
35 |
-
} catch (Exception $e) {
|
36 |
-
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
37 |
-
}
|
38 |
-
$this->_redirect('*/*');
|
39 |
-
}
|
40 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Celebros_Salesperson_Adminhtml_MappingController extends Mage_Adminhtml_Controller_Action
|
4 |
+
{
|
5 |
+
public function indexAction()
|
6 |
+
{
|
7 |
+
$this->loadLayout()->renderLayout();
|
8 |
+
}
|
9 |
+
|
10 |
+
public function postAction()
|
11 |
+
{
|
12 |
+
$post = $this->getRequest()->getPost();
|
13 |
+
|
14 |
+
try {
|
15 |
+
if (empty($post)) {
|
16 |
+
Mage::throwException($this->__('Invalid form data.'));
|
17 |
+
}
|
18 |
+
|
19 |
+
/* here's your form processing */
|
20 |
+
|
21 |
+
$mappingModel = Mage::getSingleton("salesperson/mapping");
|
22 |
+
|
23 |
+
if (!key_exists('mapping',$post)) {
|
24 |
+
Mage::throwException($this->__('Invalid form data.'));
|
25 |
+
}
|
26 |
+
|
27 |
+
foreach($post['mapping'] as $key => $value){
|
28 |
+
$mappingModel->load($key);
|
29 |
+
$mappingModel->setXmlField($value);
|
30 |
+
$mappingModel->save();
|
31 |
+
}
|
32 |
+
|
33 |
+
$message = $this->__('The mapping has been saved successfully.');
|
34 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($message);
|
35 |
+
} catch (Exception $e) {
|
36 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
37 |
+
}
|
38 |
+
$this->_redirect('*/*');
|
39 |
+
}
|
40 |
+
}
|
app/code/community/Celebros/Salesperson/controllers/ExportController.php
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author (this controller only) 3BaseGroup Co. - Miri Meltzer & Shulamit Tal (email: mirim@3basegroup.com)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_ExportController extends Mage_Adminhtml_Controller_Action
|
11 |
+
{
|
12 |
+
|
13 |
+
public function export_celebrosAction()
|
14 |
+
{
|
15 |
+
$model=Mage::getModel('salesperson/observer');
|
16 |
+
$model->export_celebros();
|
17 |
+
}
|
18 |
+
|
19 |
+
public function export_orders_celebrosAction()
|
20 |
+
{
|
21 |
+
$model=Mage::getModel('salesperson/observer');
|
22 |
+
$model->export_orders_celebros();
|
23 |
+
}
|
24 |
+
|
25 |
+
public function schedule_exportAction() {
|
26 |
+
|
27 |
+
$SCHEDULE_EVERY_MINUTES = 30;
|
28 |
+
|
29 |
+
//Flooring the minutes
|
30 |
+
$startTimeSeconds = ((int)(time()/60))*60;
|
31 |
+
//Ceiling to the next 5 minutes
|
32 |
+
$startTimeMinutes = $startTimeSeconds/60;
|
33 |
+
$startTimeMinutes = ((int)($startTimeMinutes/5))*5 + 5;
|
34 |
+
$startTimeSeconds = $startTimeMinutes * 60;
|
35 |
+
|
36 |
+
$bAddedFromXml = false;
|
37 |
+
$config = Mage::getConfig()->getNode('crontab/jobs');
|
38 |
+
if ($config instanceof Mage_Core_Model_Config_Element) {
|
39 |
+
$jobs = $config->children();
|
40 |
+
|
41 |
+
$i = 0;
|
42 |
+
foreach ($jobs as $jobCode => $jobConfig) {
|
43 |
+
if(strpos($jobCode, 'salesperson') === false) continue;
|
44 |
+
$timecreated = strftime('%Y-%m-%d %H:%M:%S', time());
|
45 |
+
$timescheduled = strftime('%Y-%m-%d %H:%M:%S', $startTimeSeconds + $i*60*$SCHEDULE_EVERY_MINUTES);
|
46 |
+
|
47 |
+
try {
|
48 |
+
$schedule = Mage::getModel('cron/schedule');
|
49 |
+
$schedule->setJobCode($jobCode)
|
50 |
+
->setCreatedAt($timecreated)
|
51 |
+
->setScheduledAt($timescheduled)
|
52 |
+
->setStatus(Mage_Cron_Model_Schedule::STATUS_PENDING)
|
53 |
+
->save();
|
54 |
+
echo "{$jobCode} cron job is scheduled at $timescheduled <br/>";
|
55 |
+
|
56 |
+
} catch (Exception $e) {
|
57 |
+
throw new Exception(Mage::helper('cron')->__('Unable to schedule Cron'));
|
58 |
+
}
|
59 |
+
|
60 |
+
$bAddedFromXml = true;
|
61 |
+
$i++;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
if(!$bAddedFromXml) {
|
66 |
+
$config = Mage::getConfig()->getNode('default/crontab/jobs');
|
67 |
+
if ($config instanceof Mage_Core_Model_Config_Element) {
|
68 |
+
$jobs = $config->children();
|
69 |
+
$i = 0;
|
70 |
+
foreach ($jobs as $jobCode => $jobConfig) {
|
71 |
+
if(strpos($jobCode, 'salesperson') === false) continue;
|
72 |
+
$timecreated = strftime('%Y-%m-%d %H:%M:%S', time());
|
73 |
+
$timescheduled = strftime('%Y-%m-%d %H:%M:%S', $startTimeSeconds + $i*60*$SCHEDULE_EVERY_MINUTES);
|
74 |
+
|
75 |
+
try {
|
76 |
+
$schedule = Mage::getModel('cron/schedule');
|
77 |
+
$schedule->setJobCode($jobCode)
|
78 |
+
->setCreatedAt($timecreated)
|
79 |
+
->setScheduledAt($timescheduled)
|
80 |
+
->setStatus(Mage_Cron_Model_Schedule::STATUS_PENDING)
|
81 |
+
->save();
|
82 |
+
echo "{$jobCode} cron job is scheduled at $timescheduled <br/>";
|
83 |
+
|
84 |
+
} catch (Exception $e) {
|
85 |
+
throw new Exception(Mage::helper('cron')->__('Unable to schedule Cron'));
|
86 |
+
}
|
87 |
+
|
88 |
+
$i++;
|
89 |
+
}
|
90 |
+
}
|
91 |
+
}
|
92 |
+
}
|
93 |
+
}
|
94 |
+
|
95 |
+
?>
|
app/code/community/Celebros/Salesperson/controllers/GiftfinderController.php
ADDED
@@ -0,0 +1,301 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_GiftfinderController extends Mage_Core_Controller_Front_Action
|
11 |
+
{
|
12 |
+
const CATALOG_CATEGORY_ATTRIBUTE_ENTITY_TYPE = '9';
|
13 |
+
const CATALOG_PRODUCT_ATTRIBUTE_ENTITY_TYPE = '10';
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Retrieve salesperson session
|
17 |
+
*
|
18 |
+
* @return Mage_Catalog_Model_Session
|
19 |
+
*/
|
20 |
+
protected function _getSession()
|
21 |
+
{
|
22 |
+
return Mage::getSingleton('salesperson/session');
|
23 |
+
}
|
24 |
+
|
25 |
+
protected function getDefaultSortBy()
|
26 |
+
{
|
27 |
+
return Mage::helper('salesperson')->getDefaultSortBy();
|
28 |
+
}
|
29 |
+
|
30 |
+
public function indexAction()
|
31 |
+
{
|
32 |
+
$bUseAjax = Mage::helper('salesperson')->isGiftfinderDynamicAjaxTemplate();
|
33 |
+
Mage::helper('salesperson')->setAjaxMode($bUseAjax);
|
34 |
+
|
35 |
+
$this->loadLayout();
|
36 |
+
|
37 |
+
$this->getLayout()->getBlock('root')->setTemplate(Mage::getStoreConfig('salesperson/display_settings/layout'));
|
38 |
+
|
39 |
+
$this->getLayout()->getBlock('product_list_toolbar')->setData('_current_grid_order', $this->getDefaultSortBy());
|
40 |
+
$this->_initLayoutMessages('salesperson/session');
|
41 |
+
$this->_initLayoutMessages('checkout/session');
|
42 |
+
if($this->getRequest()->getParam("renderAjax"))
|
43 |
+
{
|
44 |
+
$this->renderAjaxBlocks();
|
45 |
+
}
|
46 |
+
else {
|
47 |
+
$this->renderLayout();
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
*
|
53 |
+
*
|
54 |
+
*/
|
55 |
+
protected function renderAjaxBlocks()
|
56 |
+
{
|
57 |
+
$arrBlocks = array();
|
58 |
+
|
59 |
+
$arrBlocks["salesperson_giftfinder_view"] = $this->getLayout()
|
60 |
+
->getBlock('salesperson.giftfinder.view')
|
61 |
+
->toHtml();
|
62 |
+
|
63 |
+
|
64 |
+
$arrBlocks["salesperson_result"] = $this->getLayout()
|
65 |
+
->getBlock('salesperson.result')
|
66 |
+
->toHtml();
|
67 |
+
|
68 |
+
//**************** Non lead questions *********************
|
69 |
+
$blockName = '';
|
70 |
+
if (Mage::getStoreConfig('salesperson/display_settings/display_non_lead') == 'top')
|
71 |
+
$blockName = 'salesperson.nonleadquestions.top';
|
72 |
+
elseif (Mage::getStoreConfig('salesperson/display_settings/display_non_lead') == 'left')
|
73 |
+
$blockName = 'salesperson.nonleadquestions.left';
|
74 |
+
elseif (Mage::getStoreConfig('salesperson/display_settings/display_non_lead') == 'right')
|
75 |
+
$blockName = 'salesperson.nonleadquestions.right';
|
76 |
+
|
77 |
+
$arrBlocks["salesperson_nonleadquestions"] = $this->getLayout()
|
78 |
+
->getBlock($blockName)
|
79 |
+
->toHtml();
|
80 |
+
//*********************************************************
|
81 |
+
|
82 |
+
$arrBlocks["salesperson_leadquestion_top"] = $this->getLayout()
|
83 |
+
->getBlock('salesperson.leadquestion.top')
|
84 |
+
->toHtml();
|
85 |
+
|
86 |
+
$arrBlocks["breadcrumbs"] = $this->getLayout()
|
87 |
+
->getBlock('breadcrumbs')
|
88 |
+
->toHtml();
|
89 |
+
|
90 |
+
|
91 |
+
|
92 |
+
$this->getResponse()
|
93 |
+
->setBody(json_encode($arrBlocks));
|
94 |
+
}
|
95 |
+
|
96 |
+
public function changeAction()
|
97 |
+
{
|
98 |
+
$bUseAjax = Mage::helper('salesperson')->isGiftfinderDynamicAjaxTemplate();
|
99 |
+
Mage::helper('salesperson')->setAjaxMode($bUseAjax);
|
100 |
+
|
101 |
+
if($this->getRequest()->getParam("salespersonaction") && $this->getRequest()->getParam("searchHandle")||$this->getRequest()->getParam("mode") && $this->getRequest()->getParam("searchHandle")){
|
102 |
+
$salesperson = Mage::helper('salesperson')->getSalespersonApi();
|
103 |
+
/* @var $query Celebros_Salesperson_Model_QwiserSearchApi */
|
104 |
+
|
105 |
+
$salesperson->setStoreId(Mage::app()->getStore()->getId());
|
106 |
+
//Retrieve the action type & search handle to perform on the search results
|
107 |
+
$action = $this->getRequest()->getParam("salespersonaction");
|
108 |
+
$mode=$this->getRequest()->getParam("mode");
|
109 |
+
$searchHandle = $this->getRequest()->getParam("searchHandle");
|
110 |
+
$salespersonSearch = false;
|
111 |
+
if($action)
|
112 |
+
{
|
113 |
+
switch($action)
|
114 |
+
{
|
115 |
+
case "limit":
|
116 |
+
if(!$mode)
|
117 |
+
{
|
118 |
+
$size = $this->getRequest()->getParam("size");
|
119 |
+
$salespersonSearch = $salesperson->ChangePageSize($searchHandle, $size);
|
120 |
+
break;
|
121 |
+
}
|
122 |
+
else
|
123 |
+
{
|
124 |
+
$perPageConfigKey = 'catalog/frontend/' . $mode . '_per_page_values';
|
125 |
+
$perPageValues = (string)Mage::getStoreConfig($perPageConfigKey);
|
126 |
+
$perPageValues = explode(',', $perPageValues);
|
127 |
+
$perPageValues = array_combine($perPageValues, $perPageValues);
|
128 |
+
if (Mage::getStoreConfigFlag('catalog/frontend/list_allow_all')) {
|
129 |
+
$perPageValues=$perPageValues + array('all'=>$this->__('All'));
|
130 |
+
}
|
131 |
+
$size = $this->getRequest()->getParam("size");
|
132 |
+
if(!in_array($size,$perPageValues))
|
133 |
+
{
|
134 |
+
$size=Mage::Helper('salesperson')->getDefaultPageSize();
|
135 |
+
|
136 |
+
}
|
137 |
+
$salespersonSearch = $salesperson->ChangePageSize($searchHandle, $size);
|
138 |
+
break;
|
139 |
+
}
|
140 |
+
case "sort":
|
141 |
+
$newOrder = $this->getRequest()->getParam("order");
|
142 |
+
$direction = $this->getRequest()->getParam("dir");
|
143 |
+
$direction = ($direction == 'asc') ? 1 : 0;
|
144 |
+
switch ($newOrder){
|
145 |
+
case 'price':
|
146 |
+
$salespersonSearch = $salesperson->SortByPrice($searchHandle, $direction);
|
147 |
+
break;
|
148 |
+
case 'relevancy':
|
149 |
+
$salespersonSearch = $salesperson->SortByRelevancy($searchHandle, $direction);
|
150 |
+
break;
|
151 |
+
case 'name':
|
152 |
+
$newOrder = 'title';
|
153 |
+
default:
|
154 |
+
$bNumericsort = 1;
|
155 |
+
/*
|
156 |
+
* if the sort by attribute is not numeric value then change the $bNumericsort to false
|
157 |
+
*/
|
158 |
+
if ($sortableAttribute = Mage::getModel('eav/entity_attribute')->loadByCode(self::CATALOG_CATEGORY_ATTRIBUTE_ENTITY_TYPE,$newOrder) == null);
|
159 |
+
$sortableAttribute = Mage::getModel('eav/entity_attribute')->loadByCode(self::CATALOG_PRODUCT_ATTRIBUTE_ENTITY_TYPE,$newOrder);
|
160 |
+
if ($sortableAttribute->getBackendType() != 'int'){
|
161 |
+
$bNumericsort = 0;
|
162 |
+
}
|
163 |
+
$salespersonSearch = $salesperson->SortByField($searchHandle, $newOrder, $bNumericsort,$direction);
|
164 |
+
break;
|
165 |
+
}
|
166 |
+
|
167 |
+
break;
|
168 |
+
case "page":
|
169 |
+
$page = (int)$this->getRequest()->getParam("p") - 1;
|
170 |
+
if ($page < 0) $page = 0;
|
171 |
+
$salespersonSearch = $salesperson->MoveToPage($searchHandle, $page);
|
172 |
+
break;
|
173 |
+
case "answerQuestion":
|
174 |
+
$answerId = $this->getRequest()->getParam("answerId");
|
175 |
+
$salespersonSearch = $salesperson->AnswerQuestion($searchHandle, $answerId, 1);
|
176 |
+
break;
|
177 |
+
case "answerQuestions":
|
178 |
+
$answerIds = "";
|
179 |
+
foreach($this->getRequest()->getParams() as $name=>$value) {
|
180 |
+
if(substr($name,0,7) !="filter_" || empty($value)) continue;
|
181 |
+
$answerId = $value;
|
182 |
+
$answerIds = empty($answerIds) ? $answerId : $answerId . urlencode('#') . $answerIds;
|
183 |
+
}
|
184 |
+
$salespersonSearch = $salesperson->AnswerQuestions($searchHandle, $answerIds, 1);
|
185 |
+
break;
|
186 |
+
case "removeAnswer":
|
187 |
+
$answerId = $this->getRequest()->getParam("answerId");
|
188 |
+
$salespersonSearch = $salesperson->RemoveAnswer($searchHandle, $answerId);
|
189 |
+
Mage::getSingleton('salesperson/layer')
|
190 |
+
->getState()->removeFilter($answerId);
|
191 |
+
break;
|
192 |
+
case "removeAllAnswers":
|
193 |
+
$answerIds = $this->getRequest()->getParam("answerIds");
|
194 |
+
if(!strpos($answerIds,',')){ //one answer
|
195 |
+
$salespersonSearch = $salesperson->RemoveAnswer($searchHandle, $answerIds);
|
196 |
+
}
|
197 |
+
else {
|
198 |
+
$answerIds = explode(',', $answerIds);
|
199 |
+
if (is_array($answerIds)){
|
200 |
+
foreach ($answerIds as $answerId){
|
201 |
+
Mage::getSingleton('salesperson/layer')
|
202 |
+
->getState()->removeFilter($answerId);
|
203 |
+
}
|
204 |
+
$answerIds = join('%23', $answerIds);
|
205 |
+
$salespersonSearch = $salesperson->RemoveAnswers($searchHandle, $answerIds);
|
206 |
+
}
|
207 |
+
else {
|
208 |
+
$salespersonSearch = $salesperson->RemoveAnswer($searchHandle, $answerIds);
|
209 |
+
Mage::getSingleton('salesperson/layer')
|
210 |
+
->getState()->removeFilter($answerIds);
|
211 |
+
}
|
212 |
+
}
|
213 |
+
break;
|
214 |
+
case "forceQuestion":
|
215 |
+
$questionId = $this->getRequest()->getParam('questionId');
|
216 |
+
$salespersonSearch = $salesperson->ForceQuestionAsFirst($searchHandle, $questionId);
|
217 |
+
break;
|
218 |
+
|
219 |
+
}
|
220 |
+
}
|
221 |
+
else
|
222 |
+
{
|
223 |
+
$pageSize = Mage::Helper('salesperson')->getDefaultPageSize();
|
224 |
+
if ($this->getRequest()->getParam("mode") == "list")
|
225 |
+
{
|
226 |
+
$pageSize = Mage::getStoreConfig('catalog/frontend/list_per_page');
|
227 |
+
}
|
228 |
+
if ($this->getRequest()->getParam("mode") == "grid")
|
229 |
+
{
|
230 |
+
$pageSize = Mage::getStoreConfig('catalog/frontend/list_per_page');
|
231 |
+
}
|
232 |
+
$salespersonSearch = $salesperson->ChangePageSize($searchHandle,$pageSize);
|
233 |
+
}
|
234 |
+
if($salespersonSearch){
|
235 |
+
//Check the results for errors
|
236 |
+
if($salespersonSearch->results->GetErrorOccurred()){
|
237 |
+
if ($salespersonSearch->results->GetErrorMessage() != ''){
|
238 |
+
$this->_getSession()->addError($this->__($salespersonSearch->results->GetErrorMessage()));
|
239 |
+
}
|
240 |
+
}
|
241 |
+
//Check the results for search path and update the layer state
|
242 |
+
if(count($salespersonSearch->results->SearchPath->Items) > 0){
|
243 |
+
$state = Mage::getSingleton('salesperson/layer')->getState();
|
244 |
+
foreach($salespersonSearch->results->SearchPath->Items as $searchPath){
|
245 |
+
$state->addFilter(array(
|
246 |
+
'stage'=> $salespersonSearch->results->SearchInformation->Stage,
|
247 |
+
'questionId' => $searchPath->QuestionId,
|
248 |
+
'answers' => $searchPath->Answers)
|
249 |
+
);
|
250 |
+
}
|
251 |
+
}
|
252 |
+
|
253 |
+
//Check if there is only one result & if the store config is set to redirect
|
254 |
+
if($salespersonSearch->results->GetRelevantProductsCount() == 1){
|
255 |
+
if(Mage::Helper('salesperson')->goToProductOnOneResult()){
|
256 |
+
$url = $salespersonSearch->results->Products->Items[0]->Field[Mage::Helper('salesperson/mapping')->getMapping('link')];
|
257 |
+
if($this->getRequest()->getParam("renderAjax"))
|
258 |
+
{
|
259 |
+
$ajaxResponseArr = array('redirectionUrl'=>$url);
|
260 |
+
$this->getResponse()
|
261 |
+
->setBody(json_encode($ajaxResponseArr));
|
262 |
+
return;
|
263 |
+
}
|
264 |
+
else {
|
265 |
+
$this->getResponse()->setRedirect($url);
|
266 |
+
}
|
267 |
+
}
|
268 |
+
}
|
269 |
+
|
270 |
+
//Retrieve the recommended message from the search results
|
271 |
+
Mage::helper('salesperson')->getRecommendedMessages();
|
272 |
+
|
273 |
+
//Load the results layout
|
274 |
+
$this->loadLayout();
|
275 |
+
|
276 |
+
//Set the result layout according to the store config settings
|
277 |
+
|
278 |
+
$this->_getSession()->setSearchHandle($salespersonSearch->results->GetSearchHandle());
|
279 |
+
// Save the ssid in the current session for anlx in the product page
|
280 |
+
$this->_getSession()->setSearchSessionId($salespersonSearch->results->SearchInformation->SessionId);
|
281 |
+
|
282 |
+
$this->getLayout()->getBlock('root')->setTemplate(Mage::getStoreConfig('salesperson/display_settings/layout'));
|
283 |
+
$this->_initLayoutMessages('salesperson/session');
|
284 |
+
$this->_initLayoutMessages('checkout/session');
|
285 |
+
|
286 |
+
if($this->getRequest()->getParam("renderAjax"))
|
287 |
+
{
|
288 |
+
$this->renderAjaxBlocks();
|
289 |
+
}
|
290 |
+
else {
|
291 |
+
$this->renderLayout();
|
292 |
+
}
|
293 |
+
}
|
294 |
+
|
295 |
+
} // if($this->getRequest()->getParam("salespersonaction") && $this->getRequest()->getParam("searchHandle")){
|
296 |
+
else {
|
297 |
+
//Redirect the user to homepage
|
298 |
+
$this->_redirectReferer();
|
299 |
+
}
|
300 |
+
}
|
301 |
+
}
|
app/code/{local → community}/Celebros/Salesperson/controllers/IndexController.php
RENAMED
@@ -1,11 +1,11 @@
|
|
1 |
-
<?php
|
2 |
-
class Celebros_Salesperson_IndexController extends Mage_Core_Controller_Front_Action
|
3 |
-
{
|
4 |
-
public function testModelAction() {
|
5 |
-
$mappings = Mage::getModel('salesperson/mapping')->getCollection();
|
6 |
-
foreach($mappings as $mapping){
|
7 |
-
echo '<h3>'.$mapping->getXmlField().'</h3>';
|
8 |
-
echo nl2br($mapping->getCodeField());
|
9 |
-
}
|
10 |
-
}
|
11 |
}
|
1 |
+
<?php
|
2 |
+
class Celebros_Salesperson_IndexController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
public function testModelAction() {
|
5 |
+
$mappings = Mage::getModel('salesperson/mapping')->getCollection();
|
6 |
+
foreach($mappings as $mapping){
|
7 |
+
echo '<h3>'.$mapping->getXmlField().'</h3>';
|
8 |
+
echo nl2br($mapping->getCodeField());
|
9 |
+
}
|
10 |
+
}
|
11 |
}
|
app/code/{local → community}/Celebros/Salesperson/controllers/ResultController.php
RENAMED
@@ -1,376 +1,462 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_ResultController extends Mage_Core_Controller_Front_Action
|
11 |
-
{
|
12 |
-
const CATALOG_CATEGORY_ATTRIBUTE_ENTITY_TYPE = '9';
|
13 |
-
const CATALOG_PRODUCT_ATTRIBUTE_ENTITY_TYPE = '10';
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Retrieve salesperson session
|
17 |
-
*
|
18 |
-
* @return Mage_Catalog_Model_Session
|
19 |
-
*/
|
20 |
-
protected function _getSession()
|
21 |
-
{
|
22 |
-
return Mage::getSingleton('salesperson/session');
|
23 |
-
}
|
24 |
-
|
25 |
-
public function indexAction()
|
26 |
-
{
|
27 |
-
$
|
28 |
-
|
29 |
-
|
30 |
-
|
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 |
-
Mage::
|
67 |
-
|
68 |
-
'',//
|
69 |
-
'
|
70 |
-
|
71 |
-
|
72 |
-
$
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
->
|
80 |
-
->
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
}
|
101 |
-
|
102 |
-
if (!Mage::helper('salesperson')->isMinQueryLength()) {
|
103 |
-
$query->save();
|
104 |
-
}
|
105 |
-
//End saving query to the suggestion database
|
106 |
-
|
107 |
-
if($salespersonSearch){
|
108 |
-
//Check the results for errors & concepts
|
109 |
-
if($salespersonSearch->results->GetErrorOccurred()){
|
110 |
-
if ($salespersonSearch->results->GetErrorMessage() != ''){
|
111 |
-
$this->_getSession()->addError($this->__($salespersonSearch->results->GetErrorMessage()));
|
112 |
-
}
|
113 |
-
}
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
}
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
$
|
135 |
-
break;
|
136 |
-
case "
|
137 |
-
$
|
138 |
-
break;
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
}
|
149 |
-
}
|
150 |
-
|
151 |
-
//
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
//If
|
162 |
-
|
163 |
-
Mage::Helper('salesperson')->
|
164 |
-
}
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
if ($
|
173 |
-
|
174 |
-
}
|
175 |
-
|
176 |
-
|
177 |
-
$this->
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
$
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
$
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
->
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
}
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
$
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Celebros_Salesperson_ResultController extends Mage_Core_Controller_Front_Action
|
11 |
+
{
|
12 |
+
const CATALOG_CATEGORY_ATTRIBUTE_ENTITY_TYPE = '9';
|
13 |
+
const CATALOG_PRODUCT_ATTRIBUTE_ENTITY_TYPE = '10';
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Retrieve salesperson session
|
17 |
+
*
|
18 |
+
* @return Mage_Catalog_Model_Session
|
19 |
+
*/
|
20 |
+
protected function _getSession()
|
21 |
+
{
|
22 |
+
return Mage::getSingleton('salesperson/session');
|
23 |
+
}
|
24 |
+
|
25 |
+
public function indexAction()
|
26 |
+
{
|
27 |
+
$bUseAjax = Mage::helper('salesperson')->useAjaxOnSearchPage();
|
28 |
+
Mage::helper('salesperson')->setAjaxMode($bUseAjax);
|
29 |
+
|
30 |
+
$query = Mage::getModel('catalogsearch/query')
|
31 |
+
->loadByQuery(Mage::helper('salesperson')->getQueryText());
|
32 |
+
/* @var $query Mage_CatalogSearch_Model_Query */
|
33 |
+
if (!$query->getId()) {
|
34 |
+
$query->setQueryText(Mage::helper('salesperson')->getQueryText());
|
35 |
+
}
|
36 |
+
|
37 |
+
$query->setStoreId(Mage::app()->getStore()->getId());
|
38 |
+
|
39 |
+
$salesperson = Mage::helper('salesperson')->getSalespersonApi();
|
40 |
+
/* @var $query Celebros_Salesperson_Model_QwiserSearchApi */
|
41 |
+
|
42 |
+
$salesperson->setStoreId(Mage::app()->getStore()->getId());
|
43 |
+
|
44 |
+
$bNumericsort = 1;
|
45 |
+
/*
|
46 |
+
* if the sort by attribute is not numeric value then change the $bNumericsort to false
|
47 |
+
*/
|
48 |
+
$defaultSortBy = Mage::helper('salesperson')->getDefaultSortBy();
|
49 |
+
|
50 |
+
$sortBy = ($defaultSortBy == "relevancy") ? "" : $defaultSortBy;
|
51 |
+
|
52 |
+
if($sortBy == 'price') {
|
53 |
+
$bNumericsort = 1;
|
54 |
+
}
|
55 |
+
else {
|
56 |
+
$sortableAttribute = Mage::getModel('eav/entity_attribute')->loadByCode(self::CATALOG_PRODUCT_ATTRIBUTE_ENTITY_TYPE,$sortBy);
|
57 |
+
|
58 |
+
if ($sortableAttribute->getBackendType() != 'int'){
|
59 |
+
$bNumericsort = 0;
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
if (Mage::helper('salesperson')->getQueryText()) {
|
64 |
+
|
65 |
+
$salespersonSearch = $salesperson->SearchAdvance(
|
66 |
+
Mage::helper('salesperson')->getQueryText(), //Query
|
67 |
+
Mage::Helper('salesperson')->getStoreSearchProfile(),//SearchProfile
|
68 |
+
'',//AnswerId
|
69 |
+
'',//EffectOnSearchPath
|
70 |
+
'price',//PriceColumn
|
71 |
+
Mage::Helper('salesperson')->getDefaultPageSize(),//PageSize
|
72 |
+
$sortBy,//Sortingfield
|
73 |
+
$bNumericsort,
|
74 |
+
true
|
75 |
+
);
|
76 |
+
|
77 |
+
//Save the query string to the suggestion database
|
78 |
+
if (Mage::helper('salesperson')->isMinQueryLength()) {
|
79 |
+
$query->setId(0)
|
80 |
+
->setIsActive(1)
|
81 |
+
->setIsProcessed(1);
|
82 |
+
}
|
83 |
+
else {
|
84 |
+
if ($query->getId()) {
|
85 |
+
$query->setPopularity($query->getPopularity()+1);
|
86 |
+
}
|
87 |
+
else {
|
88 |
+
$query->setPopularity(1);
|
89 |
+
}
|
90 |
+
|
91 |
+
/*if ($query->getRedirect()) {
|
92 |
+
$query->save();
|
93 |
+
$this->getResponse()->setRedirect($query->getRedirect());
|
94 |
+
return;
|
95 |
+
} else {*/
|
96 |
+
if ($salespersonSearch->results) {
|
97 |
+
Mage::helper('salesperson')->prepare($query, $salespersonSearch->results->GetRelevantProductsCount());
|
98 |
+
}
|
99 |
+
/* }*/
|
100 |
+
}
|
101 |
+
|
102 |
+
if (!Mage::helper('salesperson')->isMinQueryLength()) {
|
103 |
+
$query->save();
|
104 |
+
}
|
105 |
+
//End saving query to the suggestion database
|
106 |
+
|
107 |
+
if($salespersonSearch && $salespersonSearch->results){
|
108 |
+
//Check the results for errors & concepts
|
109 |
+
if($salespersonSearch->results->GetErrorOccurred()){
|
110 |
+
if ($salespersonSearch->results->GetErrorMessage() != ''){
|
111 |
+
$this->_getSession()->addError($this->__($salespersonSearch->results->GetErrorMessage()));
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
//$state = Mage::getSingleton('salesperson/layer')->getState();
|
116 |
+
//$state->setInitialQuestions();
|
117 |
+
|
118 |
+
if($salespersonSearch->results->QueryConcepts->Count > 0){
|
119 |
+
foreach ($queryConcepts = $salespersonSearch->results->QueryConcepts->Items as $queryConcept){
|
120 |
+
foreach ($queryConcept->DynamicProperties as $name => $value){
|
121 |
+
$query_str = Mage::helper('salesperson')->getQueryText();
|
122 |
+
switch($name){
|
123 |
+
case "alternative products":
|
124 |
+
$msg = str_replace('{{query}}', $query_str, Mage::getStoreConfig('salesperson/display_settings/alt_message'));
|
125 |
+
$msg = str_replace('{{new_query}}', $value, $msg);
|
126 |
+
if($salespersonSearch->results->GetRelevantProductsCount() == 1 && Mage::Helper('salesperson')->goToProductOnOneResult()){
|
127 |
+
if(Mage::getStoreConfig('salesperson/display_settings/alt_message') != '') Mage::getSingleton('catalog/session')->addNotice($msg);
|
128 |
+
}
|
129 |
+
else {
|
130 |
+
if(Mage::getStoreConfig('salesperson/display_settings/alt_message') != '') $this->_getSession()->addNotice($msg);
|
131 |
+
}
|
132 |
+
break;
|
133 |
+
case "banner image":
|
134 |
+
$bannerImg = $value;
|
135 |
+
break;
|
136 |
+
case "banner flash":
|
137 |
+
$bannerFlash = $value;
|
138 |
+
break;
|
139 |
+
case "custom message":
|
140 |
+
//$customMessage = $value;
|
141 |
+
$this->_getSession()->addNotice($value);
|
142 |
+
break;
|
143 |
+
case "redirection url":
|
144 |
+
$this->getResponse()->setRedirect($value);
|
145 |
+
break;
|
146 |
+
}
|
147 |
+
}
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
//Check if there is only one result & if the store config is set to redirect
|
152 |
+
if($salespersonSearch->results->GetRelevantProductsCount() == 1){
|
153 |
+
if(Mage::Helper('salesperson')->goToProductOnOneResult()){
|
154 |
+
$this->getResponse()->setRedirect($salespersonSearch->results->Products->Items[0]->Field[Mage::Helper('salesperson/mapping')->getMapping('link')]);
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
//Retrieve the recommended message from the search results
|
159 |
+
Mage::helper('salesperson')->getRecommendedMessages();
|
160 |
+
|
161 |
+
//If banner image exists for this search add it to the layout
|
162 |
+
if (isset($bannerImg)){
|
163 |
+
Mage::Helper('salesperson')->setBannerImage($bannerImg);
|
164 |
+
}
|
165 |
+
|
166 |
+
//If banner flash exists for this search add it to the layout
|
167 |
+
if (isset($bannerFlash)){
|
168 |
+
Mage::Helper('salesperson')->setBannerFlash($bannerFlash);
|
169 |
+
}
|
170 |
+
|
171 |
+
//If custom message exists for this search add it to the layout
|
172 |
+
/*if (isset($customMessage)){
|
173 |
+
Mage::Helper('salesperson')->setCustomMessage($customMessage);
|
174 |
+
}*/
|
175 |
+
//Set the result layout according to the store config settings
|
176 |
+
|
177 |
+
$this->_getSession()->setSearchHandle($salespersonSearch->results->GetSearchHandle());
|
178 |
+
// Save the ssid in the current session for anlx in the product page
|
179 |
+
$this->_getSession()->setSearchSessionId($salespersonSearch->results->SearchInformation->SessionId);
|
180 |
+
|
181 |
+
$this->_initLayoutMessages('salesperson/session');
|
182 |
+
$this->_initLayoutMessages('checkout/session');
|
183 |
+
|
184 |
+
//Load the results layout
|
185 |
+
$this->loadLayout();
|
186 |
+
|
187 |
+
$this->getLayout()->getBlock('root')->setTemplate(Mage::getStoreConfig('salesperson/display_settings/layout'));
|
188 |
+
|
189 |
+
if($this->getRequest()->getParam("renderAjax"))
|
190 |
+
{
|
191 |
+
$this->renderAjaxBlocks();
|
192 |
+
}
|
193 |
+
else {
|
194 |
+
$this->renderLayout();
|
195 |
+
}
|
196 |
+
}
|
197 |
+
else {
|
198 |
+
$this->_redirectReferer();
|
199 |
+
}
|
200 |
+
} // if (Mage::helper('salesperson')->getQueryText()) {
|
201 |
+
else {
|
202 |
+
//Redirect the user to homepage
|
203 |
+
$this->_redirectReferer();
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
*
|
209 |
+
*
|
210 |
+
*/
|
211 |
+
protected function renderAjaxBlocks()
|
212 |
+
{
|
213 |
+
$arrBlocks = array();
|
214 |
+
|
215 |
+
$arrBlocks["salesperson_result"] = $this->getLayout()
|
216 |
+
->getBlock('salesperson.result')
|
217 |
+
->toHtml();
|
218 |
+
|
219 |
+
//**************** Non lead questions *********************
|
220 |
+
$blockName = '';
|
221 |
+
if (Mage::getStoreConfig('salesperson/display_settings/display_non_lead') == 'top')
|
222 |
+
$blockName = 'salesperson.nonleadquestions.top';
|
223 |
+
elseif (Mage::getStoreConfig('salesperson/display_settings/display_non_lead') == 'left')
|
224 |
+
$blockName = 'salesperson.nonleadquestions.left';
|
225 |
+
elseif (Mage::getStoreConfig('salesperson/display_settings/display_non_lead') == 'right')
|
226 |
+
$blockName = 'salesperson.nonleadquestions.right';
|
227 |
+
|
228 |
+
$arrBlocks["salesperson_nonleadquestions"] = $this->getLayout()
|
229 |
+
->getBlock($blockName)
|
230 |
+
->toHtml();
|
231 |
+
//*********************************************************
|
232 |
+
|
233 |
+
$arrBlocks["salesperson_leadquestion_top"] = $this->getLayout()
|
234 |
+
->getBlock('salesperson.leadquestion.top')
|
235 |
+
->toHtml();
|
236 |
+
|
237 |
+
$arrBlocks["breadcrumbs"] = $this->getLayout()
|
238 |
+
->getBlock('breadcrumbs')
|
239 |
+
->toHtml();
|
240 |
+
|
241 |
+
|
242 |
+
|
243 |
+
$this->getResponse()
|
244 |
+
->setBody(json_encode($arrBlocks));
|
245 |
+
}
|
246 |
+
|
247 |
+
/**
|
248 |
+
* Every change to the results is made by this action
|
249 |
+
*
|
250 |
+
*/
|
251 |
+
public function changeAction(){
|
252 |
+
$bUseAjax = Mage::helper('salesperson')->useAjaxOnSearchPage();
|
253 |
+
Mage::helper('salesperson')->setAjaxMode($bUseAjax);
|
254 |
+
|
255 |
+
if($this->getRequest()->getParam("salespersonaction") && $this->getRequest()->getParam("searchHandle")||$this->getRequest()->getParam("mode") && $this->getRequest()->getParam("searchHandle")){
|
256 |
+
$salesperson = Mage::helper('salesperson')->getSalespersonApi();
|
257 |
+
/* @var $query Celebros_Salesperson_Model_QwiserSearchApi */
|
258 |
+
|
259 |
+
$salesperson->setStoreId(Mage::app()->getStore()->getId());
|
260 |
+
//Retrieve the action type & search handle to perform on the search results
|
261 |
+
$action = $this->getRequest()->getParam("salespersonaction");
|
262 |
+
$mode=$this->getRequest()->getParam("mode");
|
263 |
+
$searchHandle = $this->getRequest()->getParam("searchHandle");
|
264 |
+
$salespersonSearch = false;
|
265 |
+
if($action)
|
266 |
+
{
|
267 |
+
switch($action)
|
268 |
+
{
|
269 |
+
case "limit":
|
270 |
+
$size = $this->getRequest()->getParam("size");
|
271 |
+
if($mode)
|
272 |
+
{
|
273 |
+
$perPageConfigKey = 'catalog/frontend/' . $mode . '_per_page_values';
|
274 |
+
$perPageValues = (string)Mage::getStoreConfig($perPageConfigKey);
|
275 |
+
$perPageValues = explode(',', $perPageValues);
|
276 |
+
$perPageValues = array_combine($perPageValues, $perPageValues);
|
277 |
+
if (Mage::getStoreConfigFlag('catalog/frontend/list_allow_all')) {
|
278 |
+
$perPageValues=$perPageValues + array('all'=>$this->__('All'));
|
279 |
+
}
|
280 |
+
if(!in_array($size,$perPageValues))
|
281 |
+
{
|
282 |
+
$size=Mage::Helper('salesperson')->getDefaultPageSize();
|
283 |
+
}
|
284 |
+
}
|
285 |
+
if($size == 'all') $size = Mage::Helper('salesperson')->getAllPageSize();
|
286 |
+
$salespersonSearch = $salesperson->ChangePageSize($searchHandle, $size);
|
287 |
+
break;
|
288 |
+
case "sort":
|
289 |
+
$order_tmp=$this->getRequest()->getParam("order");
|
290 |
+
$newOrder = substr($order_tmp,strpos($order_tmp,'~')+1);
|
291 |
+
|
292 |
+
$direction = $this->getRequest()->getParam("dir");
|
293 |
+
$direction = ($direction == 'asc') ? 1 : 0;
|
294 |
+
switch ($newOrder){
|
295 |
+
case 'price':
|
296 |
+
$salespersonSearch = $salesperson->SortByPrice($searchHandle, $direction);
|
297 |
+
break;
|
298 |
+
case 'relevancy':
|
299 |
+
$salespersonSearch = $salesperson->SortByRelevancy($searchHandle, $direction);
|
300 |
+
break;
|
301 |
+
case 'name':
|
302 |
+
$newOrder = 'title';
|
303 |
+
default:
|
304 |
+
$bNumericsort = 1;
|
305 |
+
/*
|
306 |
+
* if the sort by attribute is not numeric value then change the $bNumericsort to false
|
307 |
+
*/
|
308 |
+
if ($sortableAttribute = Mage::getModel('eav/entity_attribute')->loadByCode(self::CATALOG_CATEGORY_ATTRIBUTE_ENTITY_TYPE,$newOrder) == null);
|
309 |
+
$sortableAttribute = Mage::getModel('eav/entity_attribute')->loadByCode(self::CATALOG_PRODUCT_ATTRIBUTE_ENTITY_TYPE,$newOrder);
|
310 |
+
if ($sortableAttribute->getBackendType() != 'int'){
|
311 |
+
$bNumericsort = 0;
|
312 |
+
}
|
313 |
+
$salespersonSearch = $salesperson->SortByField($searchHandle, $newOrder, $bNumericsort,$direction);
|
314 |
+
break;
|
315 |
+
}
|
316 |
+
|
317 |
+
break;
|
318 |
+
case "page":
|
319 |
+
$page = (int)$this->getRequest()->getParam("p") - 1;
|
320 |
+
if ($page < 0) $page = 0;
|
321 |
+
$salespersonSearch = $salesperson->MoveToPage($searchHandle, $page);
|
322 |
+
break;
|
323 |
+
case "answerQuestion":
|
324 |
+
$answerId = $this->getRequest()->getParam("answerId");
|
325 |
+
$salespersonSearch = $salesperson->AnswerQuestion($searchHandle, $answerId, 1);
|
326 |
+
//If price question was answered, remove all other price answers
|
327 |
+
if(substr($answerId, 0, 2) == '_P'){
|
328 |
+
$searchPaths = $salespersonSearch->results->SearchPath->Items;
|
329 |
+
foreach($searchPaths as $searchPath){
|
330 |
+
if($searchPath->QuestionId == "PriceQuestion" && $searchPath->Answers->Items[0]->Id!=$answerId)
|
331 |
+
{
|
332 |
+
$searchHandle = $salespersonSearch->results->GetSearchHandle();
|
333 |
+
$salespersonSearch = $salesperson->RemoveAnswer($searchHandle, $searchPath->Answers->Items[0]->Id);
|
334 |
+
}
|
335 |
+
}
|
336 |
+
}
|
337 |
+
break;
|
338 |
+
case "answerQuestions":
|
339 |
+
$answerIds = "";
|
340 |
+
foreach($this->getRequest()->getParams() as $name=>$value) {
|
341 |
+
if(substr($name,0,7) !="filter_" || empty($value)) continue;
|
342 |
+
$answerId = $value;
|
343 |
+
$answerIds = empty($answerIds) ? $answerId : $answerId . urlencode('#') . $answerIds;
|
344 |
+
}
|
345 |
+
$salespersonSearch = $salesperson->AnswerQuestions($searchHandle, $answerIds, 1);
|
346 |
+
break;
|
347 |
+
case "removeAnswer":
|
348 |
+
$answerId = $this->getRequest()->getParam("answerId");
|
349 |
+
$salespersonSearch = $salesperson->RemoveAnswer($searchHandle, $answerId);
|
350 |
+
Mage::getSingleton('salesperson/layer')
|
351 |
+
->getState()->removeFilter($answerId);
|
352 |
+
break;
|
353 |
+
case "removeAllAnswers":
|
354 |
+
$answerIds = $this->getRequest()->getParam("answerIds");
|
355 |
+
if(!strpos($answerIds,',')){ //one answer
|
356 |
+
$salespersonSearch = $salesperson->RemoveAnswer($searchHandle, $answerIds);
|
357 |
+
}
|
358 |
+
else {
|
359 |
+
$answerIds = explode(',', $answerIds);
|
360 |
+
if (is_array($answerIds)){
|
361 |
+
foreach ($answerIds as $answerId){
|
362 |
+
Mage::getSingleton('salesperson/layer')
|
363 |
+
->getState()->removeFilter($answerId);
|
364 |
+
}
|
365 |
+
$answerIds = join('%23', $answerIds);
|
366 |
+
$salespersonSearch = $salesperson->RemoveAnswers($searchHandle, $answerIds);
|
367 |
+
}
|
368 |
+
else {
|
369 |
+
$salespersonSearch = $salesperson->RemoveAnswer($searchHandle, $answerIds);
|
370 |
+
Mage::getSingleton('salesperson/layer')
|
371 |
+
->getState()->removeFilter($answerIds);
|
372 |
+
}
|
373 |
+
}
|
374 |
+
break;
|
375 |
+
case "forceQuestion":
|
376 |
+
$questionId = $this->getRequest()->getParam('questionId');
|
377 |
+
$salespersonSearch = $salesperson->ForceQuestionAsFirst($searchHandle, $questionId);
|
378 |
+
break;
|
379 |
+
|
380 |
+
}
|
381 |
+
}
|
382 |
+
else
|
383 |
+
{
|
384 |
+
$pageSize = Mage::Helper('salesperson')->getDefaultPageSize();
|
385 |
+
if ($this->getRequest()->getParam("mode") == "list")
|
386 |
+
{
|
387 |
+
$pageSize = Mage::getStoreConfig('catalog/frontend/list_per_page');
|
388 |
+
}
|
389 |
+
if ($this->getRequest()->getParam("mode") == "grid")
|
390 |
+
{
|
391 |
+
$pageSize = Mage::getStoreConfig('catalog/frontend/list_per_page');
|
392 |
+
}
|
393 |
+
$salespersonSearch = $salesperson->ChangePageSize($searchHandle,$pageSize);
|
394 |
+
}
|
395 |
+
if($salespersonSearch){
|
396 |
+
|
397 |
+
//Check the results for errors
|
398 |
+
if($salespersonSearch->results->GetErrorOccurred()){
|
399 |
+
if ($salespersonSearch->results->GetErrorMessage() != ''){
|
400 |
+
$this->_getSession()->addError($this->__($salespersonSearch->results->GetErrorMessage()));
|
401 |
+
}
|
402 |
+
}
|
403 |
+
//Check the results for search path and update the layer state
|
404 |
+
if(count($salespersonSearch->results->SearchPath->Items) > 0){
|
405 |
+
$state = Mage::getSingleton('salesperson/layer')->getState();
|
406 |
+
foreach($salespersonSearch->results->SearchPath->Items as $searchPath){
|
407 |
+
$state->addFilter(array(
|
408 |
+
'stage'=> $salespersonSearch->results->SearchInformation->Stage,
|
409 |
+
'questionId' => $searchPath->QuestionId,
|
410 |
+
'answers' => $searchPath->Answers)
|
411 |
+
);
|
412 |
+
}
|
413 |
+
}
|
414 |
+
|
415 |
+
//Check if there is only one result & if the store config is set to redirect
|
416 |
+
if($salespersonSearch->results->GetRelevantProductsCount() == 1){
|
417 |
+
if(Mage::Helper('salesperson')->goToProductOnOneResult()){
|
418 |
+
$url = $salespersonSearch->results->Products->Items[0]->Field[Mage::Helper('salesperson/mapping')->getMapping('link')];
|
419 |
+
if($this->getRequest()->getParam("renderAjax"))
|
420 |
+
{
|
421 |
+
$ajaxResponseArr = array('redirectionUrl'=>$url);
|
422 |
+
$this->getResponse()
|
423 |
+
->setBody(json_encode($ajaxResponseArr));
|
424 |
+
return;
|
425 |
+
}
|
426 |
+
else {
|
427 |
+
$this->getResponse()->setRedirect($url);
|
428 |
+
}
|
429 |
+
}
|
430 |
+
}
|
431 |
+
|
432 |
+
//Retrieve the recommended message from the search results
|
433 |
+
Mage::helper('salesperson')->getRecommendedMessages();
|
434 |
+
|
435 |
+
//Load the results layout
|
436 |
+
$this->loadLayout();
|
437 |
+
|
438 |
+
//Set the result layout according to the store config settings
|
439 |
+
|
440 |
+
$this->_getSession()->setSearchHandle($salespersonSearch->results->GetSearchHandle());
|
441 |
+
// Save the ssid in the current session for anlx in the product page
|
442 |
+
$this->_getSession()->setSearchSessionId($salespersonSearch->results->SearchInformation->SessionId);
|
443 |
+
|
444 |
+
$this->getLayout()->getBlock('root')->setTemplate(Mage::getStoreConfig('salesperson/display_settings/layout'));
|
445 |
+
$this->_initLayoutMessages('salesperson/session');
|
446 |
+
$this->_initLayoutMessages('checkout/session');
|
447 |
+
if($this->getRequest()->getParam("renderAjax"))
|
448 |
+
{
|
449 |
+
$this->renderAjaxBlocks();
|
450 |
+
}
|
451 |
+
else {
|
452 |
+
$this->renderLayout();
|
453 |
+
}
|
454 |
+
}
|
455 |
+
|
456 |
+
} // if($this->getRequest()->getParam("salespersonaction") && $this->getRequest()->getParam("searchHandle")){
|
457 |
+
else {
|
458 |
+
//Redirect the user to homepage
|
459 |
+
$this->_redirectReferer();
|
460 |
+
}
|
461 |
+
}
|
462 |
+
}
|
app/code/community/Celebros/Salesperson/controllers/TestController.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Celebros_Salesperson_TestController extends
|
3 |
+
Mage_Adminhtml_Controller_Action
|
4 |
+
{
|
5 |
+
|
6 |
+
public function indexAction()
|
7 |
+
{
|
8 |
+
echo "Hello, World.";
|
9 |
+
|
10 |
+
}
|
11 |
+
}
|
12 |
+
|
13 |
+
?>
|
app/code/community/Celebros/Salesperson/docs/Celebros Salesperson - Magento plugin configuration manual 2011 extension.pdf
ADDED
Binary file
|
app/code/community/Celebros/Salesperson/docs/Release_notes.txt
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
======================
|
2 |
+
xx/xx/2013 Build 2.1.1
|
3 |
+
======================
|
4 |
+
|
5 |
+
|
6 |
+
Fixes
|
7 |
+
-----
|
8 |
+
- nav2search multi store: Better support for multi-store. Reindex and create url redirections when enabling nav2search and in export so that category changed will be taken.
|
9 |
+
|
10 |
+
- Sort by: Allows now for using the same XML field twice (For asc and desc).
|
11 |
+
|
12 |
+
|
13 |
+
Improved
|
14 |
+
--------
|
15 |
+
- Large export:
|
16 |
+
* Memory usage is greatly reduced
|
17 |
+
* Better reporting.
|
18 |
+
|
19 |
+
|
20 |
+
Changed files
|
21 |
+
-------------
|
22 |
+
Data.php
|
23 |
+
Enable.php
|
24 |
+
Observer.php
|
25 |
+
ObserverLarge.php
|
26 |
+
ResultController.php
|
27 |
+
|
28 |
+
|
29 |
+
*********************************************************************************************
|
30 |
+
|
31 |
+
======================
|
32 |
+
11/04/2013 Build 2.1.0
|
33 |
+
======================
|
34 |
+
|
35 |
+
New
|
36 |
+
---
|
37 |
+
* Allow usage of flat tables in export (Important for multi-store websites)
|
38 |
+
|
39 |
+
|
40 |
+
Fixes
|
41 |
+
-----
|
42 |
+
* Export crash when export encounters disabled categories.
|
43 |
+
* Disabled variant products being exported
|
44 |
+
* Enable/disable AC from admin
|
45 |
+
|
46 |
+
|
47 |
+
Improved
|
48 |
+
--------
|
49 |
+
* Better reporting in manual export (More details and better output).
|
50 |
+
|
51 |
+
|
52 |
+
Changed files
|
53 |
+
-------------
|
54 |
+
config.xml
|
55 |
+
system.xml
|
56 |
+
Observer.php
|
57 |
+
|
58 |
+
*********************************************************************************************
|
59 |
+
|
60 |
+
Build x.x.17
|
61 |
+
|
62 |
+
Release notes:
|
63 |
+
|
64 |
+
� Change in Analytics to work with AIWriter API
|
65 |
+
|
66 |
+
Files updated:
|
67 |
+
|
68 |
+
� /app/code/local/Celebros/Salesperson/etc/config.xml
|
69 |
+
� /app/code/local/Celebros/Salesperson/Model/Observer.php
|
70 |
+
� /app/code/local/Celebros/Salesperson/controllers/ResultController.php
|
app/code/community/Celebros/Salesperson/etc/config.xml
ADDED
@@ -0,0 +1,317 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Celebros Qwiser - Magento Extension
|
5 |
+
*
|
6 |
+
* @category Celebros
|
7 |
+
* @package Celebros_Qwiser
|
8 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
-->
|
12 |
+
<config>
|
13 |
+
<modules>
|
14 |
+
<Celebros_Salesperson>
|
15 |
+
<version>2.0.0</version>
|
16 |
+
</Celebros_Salesperson>
|
17 |
+
</modules>
|
18 |
+
<global>
|
19 |
+
<models>
|
20 |
+
<salesperson>
|
21 |
+
<class>Celebros_Salesperson_Model</class>
|
22 |
+
<resourceModel>salesperson_mysql4</resourceModel>
|
23 |
+
</salesperson>
|
24 |
+
<core>
|
25 |
+
<rewrite>
|
26 |
+
<layout>Celebros_Salesperson_Model_Layout</layout>
|
27 |
+
</rewrite>
|
28 |
+
</core>
|
29 |
+
<!--<catalog>
|
30 |
+
<rewrite>
|
31 |
+
<url>Celebros_Salesperson_Model_Catalog_Url</url>
|
32 |
+
</rewrite>
|
33 |
+
</catalog>-->
|
34 |
+
<salesperson_mysql4>
|
35 |
+
<class>Celebros_Salesperson_Model_Mysql4</class>
|
36 |
+
<entities>
|
37 |
+
<mapping>
|
38 |
+
<table>celebrosfieldsmapping</table>
|
39 |
+
</mapping>
|
40 |
+
</entities>
|
41 |
+
</salesperson_mysql4>
|
42 |
+
</models>
|
43 |
+
<blocks>
|
44 |
+
<salesperson>
|
45 |
+
<class>Celebros_Salesperson_Block</class>
|
46 |
+
</salesperson>
|
47 |
+
<adminhtml>
|
48 |
+
<rewrite>
|
49 |
+
<system_convert_profile_edit_tab_run>Celebros_Salesperson_Block_System_Convert_Profile_Edit_Tab_Run</system_convert_profile_edit_tab_run>
|
50 |
+
</rewrite>
|
51 |
+
</adminhtml>
|
52 |
+
<!--<checkout>
|
53 |
+
<rewrite>
|
54 |
+
<cart_crosssell>Celebros_Salesperson_Block_Checkout_Cart_Crosssell</cart_crosssell>
|
55 |
+
</rewrite>
|
56 |
+
</checkout>-->
|
57 |
+
<!--<catalog>
|
58 |
+
<rewrite>
|
59 |
+
<navigation>Celebros_Salesperson_Block_Navigation</navigation>
|
60 |
+
</rewrite>
|
61 |
+
</catalog>-->
|
62 |
+
</blocks>
|
63 |
+
<helpers>
|
64 |
+
<salesperson>
|
65 |
+
<class>Celebros_Salesperson_Helper</class>
|
66 |
+
</salesperson>
|
67 |
+
</helpers>
|
68 |
+
<resources>
|
69 |
+
<salesperson_setup>
|
70 |
+
<setup>
|
71 |
+
<module>Celebros_Salesperson</module>
|
72 |
+
</setup>
|
73 |
+
<connection>
|
74 |
+
<use>core_setup</use>
|
75 |
+
</connection>
|
76 |
+
</salesperson_setup>
|
77 |
+
<salesperson_write>
|
78 |
+
<connection>
|
79 |
+
<use>core_write</use>
|
80 |
+
</connection>
|
81 |
+
</salesperson_write>
|
82 |
+
<salesperson_read>
|
83 |
+
<connection>
|
84 |
+
<use>core_read</use>
|
85 |
+
</connection>
|
86 |
+
</salesperson_read>
|
87 |
+
</resources>
|
88 |
+
<events>
|
89 |
+
<after_reindex_process_catalog_url>
|
90 |
+
<observers>
|
91 |
+
<Celebros_Salesperson_observer>
|
92 |
+
<type>singleton</type>
|
93 |
+
<class>salesperson/observer</class>
|
94 |
+
<method>after_reindex_process_catalog_url</method>
|
95 |
+
</Celebros_Salesperson_observer>
|
96 |
+
</observers>
|
97 |
+
</after_reindex_process_catalog_url>
|
98 |
+
<!--<catalog_category_save_after>
|
99 |
+
<observers>
|
100 |
+
<Celebros_Salesperson_observer>
|
101 |
+
<type>singleton</type>
|
102 |
+
<class>salesperson/observer</class>
|
103 |
+
<method>after_reindex_process_catalog_url</method>
|
104 |
+
</Celebros_Salesperson_observer>
|
105 |
+
</observers>
|
106 |
+
</catalog_category_save_after>-->
|
107 |
+
|
108 |
+
<!--<catalog_product_save_after>-->
|
109 |
+
<!-- <observers>-->
|
110 |
+
<!-- <Celebros_Salesperson_observer>-->
|
111 |
+
<!-- <type>singleton</type>-->
|
112 |
+
<!-- <class>salesperson/observer</class>-->
|
113 |
+
<!-- <method>updateStockConfig</method>-->
|
114 |
+
<!-- </Celebros_Salesperson_observer>-->
|
115 |
+
<!-- </observers>-->
|
116 |
+
<!--</catalog_product_save_after>-->
|
117 |
+
<!-- <sales_order_shipment_save_after>-->
|
118 |
+
<!-- <observers>-->
|
119 |
+
<!-- <Celebros_Salesperson_observer>-->
|
120 |
+
<!-- <type>singleton</type>-->
|
121 |
+
<!-- <class>salesperson/observer</class>-->
|
122 |
+
<!-- <method>updateStockShipment</method>-->
|
123 |
+
<!-- </Celebros_Salesperson_observer>-->
|
124 |
+
<!-- </observers>-->
|
125 |
+
<!-- </sales_order_shipment_save_after>-->
|
126 |
+
<!--<checkout_type_onepage_save_order_after>-->
|
127 |
+
<!-- <observers>-->
|
128 |
+
<!-- <Celebros_Salesperson_observer>-->
|
129 |
+
<!-- <type>singleton</type>-->
|
130 |
+
<!-- <class>salesperson/observer</class>-->
|
131 |
+
<!-- <method>updateStockOrder</method>-->
|
132 |
+
<!-- </Celebros_Salesperson_observer>-->
|
133 |
+
<!-- </observers>-->
|
134 |
+
<!--</checkout_type_onepage_save_order_after>-->
|
135 |
+
</events>
|
136 |
+
</global>
|
137 |
+
<admin>
|
138 |
+
<routers>
|
139 |
+
<salesperson_admin>
|
140 |
+
<use>admin</use>
|
141 |
+
<args>
|
142 |
+
<module>Celebros_Salesperson</module>
|
143 |
+
<frontName>salesperson_admin</frontName>
|
144 |
+
</args>
|
145 |
+
</salesperson_admin>
|
146 |
+
</routers>
|
147 |
+
</admin>
|
148 |
+
<frontend>
|
149 |
+
|
150 |
+
<events>
|
151 |
+
<!-- <catalog_category_load_after>
|
152 |
+
<observers>
|
153 |
+
<Celebros_Salesperson_observer>
|
154 |
+
<type>model</type>
|
155 |
+
<class>salesperson/observer</class>
|
156 |
+
<method>getUrl</method>
|
157 |
+
</Celebros_Salesperson_observer>
|
158 |
+
</observers>
|
159 |
+
</catalog_category_load_after> -->
|
160 |
+
</events>
|
161 |
+
<routers>
|
162 |
+
<salesperson>
|
163 |
+
<use>standard</use>
|
164 |
+
<args>
|
165 |
+
<module>Celebros_Salesperson</module>
|
166 |
+
<frontName>salesperson</frontName>
|
167 |
+
</args>
|
168 |
+
</salesperson>
|
169 |
+
</routers>
|
170 |
+
<!-- <translate>-->
|
171 |
+
<!-- <modules>-->
|
172 |
+
<!-- <Celebros_Salesperson>-->
|
173 |
+
<!-- <files>-->
|
174 |
+
<!-- <default>Celebros_Salesperson.csv</default>-->
|
175 |
+
<!-- </files>-->
|
176 |
+
<!-- </Celebros_Salesperson>-->
|
177 |
+
<!-- </modules>-->
|
178 |
+
<!-- </translate>-->
|
179 |
+
<layout>
|
180 |
+
<updates>
|
181 |
+
<salesperson>
|
182 |
+
<file>salesperson.xml</file>
|
183 |
+
</salesperson>
|
184 |
+
</updates>
|
185 |
+
</layout>
|
186 |
+
</frontend>
|
187 |
+
<adminhtml>
|
188 |
+
<translate>
|
189 |
+
<modules>
|
190 |
+
<Celebros_Salesperson>
|
191 |
+
<files>
|
192 |
+
<default>Celebros_Salesperson.csv</default>
|
193 |
+
</files>
|
194 |
+
</Celebros_Salesperson>
|
195 |
+
</modules>
|
196 |
+
</translate>
|
197 |
+
<menu>
|
198 |
+
<menu1 translate="title" module="salesperson">
|
199 |
+
<title>Test</title>
|
200 |
+
<sort_order>60</sort_order>
|
201 |
+
<children>
|
202 |
+
<menuitem1 module="salesperson">
|
203 |
+
<title>Celebros Test</title>
|
204 |
+
<action>salesperson_admin/export/test</action>
|
205 |
+
</menuitem1>
|
206 |
+
</children>
|
207 |
+
</menu1>
|
208 |
+
</menu>
|
209 |
+
<menu>
|
210 |
+
<catalog>
|
211 |
+
<children>
|
212 |
+
<salesperson_mapping translate="title" module="salesperson">
|
213 |
+
<title>Salesperson Mapping</title>
|
214 |
+
<action>salesperson_admin/adminhtml_mapping</action>
|
215 |
+
</salesperson_mapping>
|
216 |
+
</children>
|
217 |
+
</catalog>
|
218 |
+
</menu>
|
219 |
+
<acl>
|
220 |
+
<resources>
|
221 |
+
<all>
|
222 |
+
<title translate="title">Allow Everything</title>
|
223 |
+
</all>
|
224 |
+
<admin>
|
225 |
+
<children>
|
226 |
+
<system>
|
227 |
+
<children>
|
228 |
+
<config>
|
229 |
+
<children>
|
230 |
+
<salesperson>
|
231 |
+
<title translate="title">Celebros Salesperson Section</title>
|
232 |
+
</salesperson>
|
233 |
+
</children>
|
234 |
+
</config>
|
235 |
+
</children>
|
236 |
+
</system>
|
237 |
+
<catalog>
|
238 |
+
<children>
|
239 |
+
<salesperson_mapping>
|
240 |
+
<title translate="title">Salesperson Mapping</title>
|
241 |
+
</salesperson_mapping>
|
242 |
+
</children>
|
243 |
+
</catalog>
|
244 |
+
</children>
|
245 |
+
</admin>
|
246 |
+
</resources>
|
247 |
+
</acl>
|
248 |
+
<layout>
|
249 |
+
<updates>
|
250 |
+
<salesperson>
|
251 |
+
<file>salesperson.xml</file>
|
252 |
+
</salesperson>
|
253 |
+
</updates>
|
254 |
+
</layout>
|
255 |
+
</adminhtml>
|
256 |
+
|
257 |
+
<default>
|
258 |
+
<salesperson>
|
259 |
+
<general_settings>
|
260 |
+
<host></host>
|
261 |
+
<port></port>
|
262 |
+
<sitekey></sitekey>
|
263 |
+
</general_settings>
|
264 |
+
<export_settings>
|
265 |
+
<delimiter>\t</delimiter>
|
266 |
+
<enclosed_values>"</enclosed_values>
|
267 |
+
<flat_export_enabled>0</flat_export_enabled>
|
268 |
+
<min_tier_price>0</min_tier_price>
|
269 |
+
<type>file</type>
|
270 |
+
<path></path>
|
271 |
+
</export_settings>
|
272 |
+
<display_settings>
|
273 |
+
<layout>salesperson/3columns.phtml</layout>
|
274 |
+
<search_page_ajax_enabled>0</search_page_ajax_enabled>
|
275 |
+
<display_lead_top>On top</display_lead_top>
|
276 |
+
<display_non_lead>left</display_non_lead>
|
277 |
+
<breadcrumbs>1</breadcrumbs>
|
278 |
+
<display_image_lead_question>1</display_image_lead_question>
|
279 |
+
<max_lead_answers>4</max_lead_answers>
|
280 |
+
<max_non_lead_questions>4</max_non_lead_questions>
|
281 |
+
<max_non_lead_answers>10</max_non_lead_answers>
|
282 |
+
<enable_non_lead_answers_multiselect>1</enable_non_lead_answers_multiselect>
|
283 |
+
<show_product_count_in_lead_answers>1</show_product_count_in_lead_answers>
|
284 |
+
<show_product_count_in_non_lead_answers>1</show_product_count_in_non_lead_answers>
|
285 |
+
<alt_message translate="label">We do not have {{query}}, maybe you will be interested in {{new_query}}</alt_message>
|
286 |
+
<page_size_selector>dropdown</page_size_selector>
|
287 |
+
<all_per_page>150</all_per_page>
|
288 |
+
<sorting_selector>dropdown</sorting_selector>
|
289 |
+
<sorting_fields>
|
290 |
+
<![CDATA[relevancy~desc~Relevancy
|
291 |
+
price~asc~Price
|
292 |
+
title~asc~Name]]>
|
293 |
+
</sorting_fields>
|
294 |
+
<default_sort_by>relevancy</default_sort_by>
|
295 |
+
<price_selector>dropdown</price_selector>
|
296 |
+
<page_nav_type>multipage</page_nav_type>
|
297 |
+
<go_to_product_on_one_result>1</go_to_product_on_one_result>
|
298 |
+
</display_settings>
|
299 |
+
<nav_to_search_settings>
|
300 |
+
<nav_to_search_use_full_category_path>category</nav_to_search_use_full_category_path>
|
301 |
+
<nav_to_search_use_full_category_path>0</nav_to_search_use_full_category_path>
|
302 |
+
</nav_to_search_settings>
|
303 |
+
<giftfinder_settings>
|
304 |
+
<giftfinder_type>salesperson/giftfinder/view.phtml</giftfinder_type>
|
305 |
+
</giftfinder_settings>
|
306 |
+
</salesperson>
|
307 |
+
</default>
|
308 |
+
<crontab>
|
309 |
+
<jobs>
|
310 |
+
<salesperson_export>
|
311 |
+
<run>
|
312 |
+
<model>salesperson/observer::catalogUpdate</model>
|
313 |
+
</run>
|
314 |
+
</salesperson_export>
|
315 |
+
</jobs>
|
316 |
+
</crontab>
|
317 |
+
</config>
|
app/code/community/Celebros/Salesperson/etc/config.xml.gpg
ADDED
Binary file
|
app/code/{local → community}/Celebros/Salesperson/etc/system.xml
RENAMED
@@ -1,389 +1,654 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* Celebros Qwiser - Magento Extension
|
5 |
-
*
|
6 |
-
* @category Celebros
|
7 |
-
* @package Celebros_Qwiser
|
8 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
9 |
-
*
|
10 |
-
*/
|
11 |
-
-->
|
12 |
-
<config>
|
13 |
-
<tabs>
|
14 |
-
<celebros translate="label" module="salesperson">
|
15 |
-
<label>
|
16 |
-
<sort_order>300</sort_order>
|
17 |
-
</celebros>
|
18 |
-
</tabs>
|
19 |
-
<sections>
|
20 |
-
<salesperson translate="label" module="salesperson">
|
21 |
-
<label>
|
22 |
-
<tab>celebros</tab>
|
23 |
-
<frontend_type>text</frontend_type>
|
24 |
-
<sort_order>0</sort_order>
|
25 |
-
<show_in_default>1</show_in_default>
|
26 |
-
<show_in_website>0</show_in_website>
|
27 |
-
<show_in_store>1</show_in_store>
|
28 |
-
<groups>
|
29 |
-
<general_settings translat="label">
|
30 |
-
<label>General Settings</label>
|
31 |
-
<frontend_type>text</frontend_type>
|
32 |
-
<sort_order>0</sort_order>
|
33 |
-
<show_in_default>1</show_in_default>
|
34 |
-
<show_in_website>0</show_in_website>
|
35 |
-
<show_in_store>1</show_in_store>
|
36 |
-
<fields>
|
37 |
-
<
|
38 |
-
<label>
|
39 |
-
<frontend_type>
|
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 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
<
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
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 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
<
|
127 |
-
|
128 |
-
|
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 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
<
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
<
|
282 |
-
<
|
283 |
-
|
284 |
-
<
|
285 |
-
<
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
<
|
309 |
-
|
310 |
-
<
|
311 |
-
<
|
312 |
-
<
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
<
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
<label>
|
369 |
-
<frontend_type>select</frontend_type>
|
370 |
-
<source_model>
|
371 |
-
<sort_order>
|
372 |
-
<show_in_default>1</show_in_default>
|
373 |
-
<show_in_website>0</show_in_website>
|
374 |
-
<show_in_store>1</show_in_store>
|
375 |
-
</
|
376 |
-
|
377 |
-
|
378 |
-
<frontend_type>text</frontend_type>
|
379 |
-
<sort_order>
|
380 |
-
<show_in_default>1</show_in_default>
|
381 |
-
<show_in_website>0</show_in_website>
|
382 |
-
<show_in_store>1</show_in_store>
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
</
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Celebros Qwiser - Magento Extension
|
5 |
+
*
|
6 |
+
* @category Celebros
|
7 |
+
* @package Celebros_Qwiser
|
8 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
-->
|
12 |
+
<config>
|
13 |
+
<tabs>
|
14 |
+
<celebros translate="label" module="salesperson">
|
15 |
+
<label>Conversion Pro Settings</label>
|
16 |
+
<sort_order>300</sort_order>
|
17 |
+
</celebros>
|
18 |
+
</tabs>
|
19 |
+
<sections>
|
20 |
+
<salesperson translate="label" module="salesperson">
|
21 |
+
<label>Conversion Pro Settings</label>
|
22 |
+
<tab>celebros</tab>
|
23 |
+
<frontend_type>text</frontend_type>
|
24 |
+
<sort_order>0</sort_order>
|
25 |
+
<show_in_default>1</show_in_default>
|
26 |
+
<show_in_website>0</show_in_website>
|
27 |
+
<show_in_store>1</show_in_store>
|
28 |
+
<groups>
|
29 |
+
<general_settings translat="label">
|
30 |
+
<label>General Settings</label>
|
31 |
+
<frontend_type>text</frontend_type>
|
32 |
+
<sort_order>0</sort_order>
|
33 |
+
<show_in_default>1</show_in_default>
|
34 |
+
<show_in_website>0</show_in_website>
|
35 |
+
<show_in_store>1</show_in_store>
|
36 |
+
<fields>
|
37 |
+
<search_enabled translate="label">
|
38 |
+
<label>Enable search</label>
|
39 |
+
<frontend_type>select</frontend_type>
|
40 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
41 |
+
<sort_order>0</sort_order>
|
42 |
+
<show_in_default>1</show_in_default>
|
43 |
+
<show_in_website>0</show_in_website>
|
44 |
+
<show_in_store>1</show_in_store>
|
45 |
+
</search_enabled>
|
46 |
+
<host translate="label">
|
47 |
+
<label>Host</label>
|
48 |
+
<frontend_type>text</frontend_type>
|
49 |
+
<sort_order>5</sort_order>
|
50 |
+
<show_in_default>1</show_in_default>
|
51 |
+
<show_in_website>0</show_in_website>
|
52 |
+
<show_in_store>1</show_in_store>
|
53 |
+
<depends><search_enabled>1</search_enabled></depends>
|
54 |
+
</host>
|
55 |
+
<port translate="label">
|
56 |
+
<label>Port</label>
|
57 |
+
<frontend_type>text</frontend_type>
|
58 |
+
<sort_order>10</sort_order>
|
59 |
+
<show_in_default>1</show_in_default>
|
60 |
+
<show_in_website>0</show_in_website>
|
61 |
+
<show_in_store>1</show_in_store>
|
62 |
+
<depends><search_enabled>1</search_enabled></depends>
|
63 |
+
</port>
|
64 |
+
<sitekey translate="label">
|
65 |
+
<label>Site Key</label>
|
66 |
+
<frontend_type>text</frontend_type>
|
67 |
+
<sort_order>20</sort_order>
|
68 |
+
<show_in_default>1</show_in_default>
|
69 |
+
<show_in_website>0</show_in_website>
|
70 |
+
<show_in_store>1</show_in_store>
|
71 |
+
<depends><search_enabled>1</search_enabled></depends>
|
72 |
+
</sitekey>
|
73 |
+
</fields>
|
74 |
+
</general_settings>
|
75 |
+
<export_settings translat="label">
|
76 |
+
<label>Export Data Settings</label>
|
77 |
+
<frontend_type>text</frontend_type>
|
78 |
+
<sort_order>10</sort_order>
|
79 |
+
<show_in_default>1</show_in_default>
|
80 |
+
<show_in_website>0</show_in_website>
|
81 |
+
<show_in_store>1</show_in_store>
|
82 |
+
<fields>
|
83 |
+
<export_enabled translate="label">
|
84 |
+
<label>Enable export</label>
|
85 |
+
<frontend_type>select</frontend_type>
|
86 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
87 |
+
<sort_order>0</sort_order>
|
88 |
+
<show_in_default>1</show_in_default>
|
89 |
+
<show_in_website>0</show_in_website>
|
90 |
+
<show_in_store>1</show_in_store>
|
91 |
+
</export_enabled>
|
92 |
+
<flat_export_enabled translate="label">
|
93 |
+
<label>Enable flat tables usage (If enabled in Magento)</label>
|
94 |
+
<frontend_type>select</frontend_type>
|
95 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
96 |
+
<sort_order>3</sort_order>
|
97 |
+
<show_in_default>1</show_in_default>
|
98 |
+
<show_in_website>0</show_in_website>
|
99 |
+
<show_in_store>1</show_in_store>
|
100 |
+
</flat_export_enabled>
|
101 |
+
<delimiter translate="label">
|
102 |
+
<label>Value Delimtier</label>
|
103 |
+
<frontend_type>text</frontend_type>
|
104 |
+
<sort_order>5</sort_order>
|
105 |
+
<show_in_default>1</show_in_default>
|
106 |
+
<show_in_website>0</show_in_website>
|
107 |
+
<show_in_store>1</show_in_store>
|
108 |
+
<comment>(\t for tab)</comment>
|
109 |
+
<depends><export_enabled>1</export_enabled></depends>
|
110 |
+
</delimiter>
|
111 |
+
<enclosed_values translate="label">
|
112 |
+
<label>Enclosed Value In</label>
|
113 |
+
<frontend_type>text</frontend_type>
|
114 |
+
<sort_order>10</sort_order>
|
115 |
+
<show_in_default>1</show_in_default>
|
116 |
+
<show_in_website>0</show_in_website>
|
117 |
+
<show_in_store>1</show_in_store>
|
118 |
+
<comment>Warning! Empty value can cause problems with CSV format.</comment>
|
119 |
+
<depends><export_enabled>1</export_enabled></depends>
|
120 |
+
</enclosed_values>
|
121 |
+
<min_tier_price translate="label">
|
122 |
+
<label>Minimal tier pricing as a price</label>
|
123 |
+
<frontend_type>select</frontend_type>
|
124 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
125 |
+
<sort_order>11</sort_order>
|
126 |
+
<show_in_default>1</show_in_default>
|
127 |
+
<show_in_website>0</show_in_website>
|
128 |
+
<show_in_store>1</show_in_store>
|
129 |
+
<depends><export_enabled>1</export_enabled></depends>
|
130 |
+
</min_tier_price>
|
131 |
+
<type translate="label">
|
132 |
+
<label>Type</label>
|
133 |
+
<frontend_type>select</frontend_type>
|
134 |
+
<source_model>salesperson/system_config_source_fileftp</source_model>
|
135 |
+
<sort_order>20</sort_order>
|
136 |
+
<show_in_default>1</show_in_default>
|
137 |
+
<show_in_website>0</show_in_website>
|
138 |
+
<show_in_store>1</show_in_store>
|
139 |
+
<depends><export_enabled>1</export_enabled></depends>
|
140 |
+
</type>
|
141 |
+
<path translate="label">
|
142 |
+
<label>Absolute Path</label>
|
143 |
+
<frontend_type>text</frontend_type>
|
144 |
+
<comment>E.g. /var/www/vhosts/yourdomain.com/var/export</comment>
|
145 |
+
<sort_order>30</sort_order>
|
146 |
+
<show_in_default>1</show_in_default>
|
147 |
+
<show_in_website>0</show_in_website>
|
148 |
+
<show_in_store>0</show_in_store>
|
149 |
+
<depends><export_enabled>1</export_enabled></depends>
|
150 |
+
</path>
|
151 |
+
<ftp_host translate="label">
|
152 |
+
<label>FTP Host</label>
|
153 |
+
<frontend_type>text</frontend_type>
|
154 |
+
<sort_order>40</sort_order>
|
155 |
+
<show_in_default>1</show_in_default>
|
156 |
+
<show_in_website>0</show_in_website>
|
157 |
+
<show_in_store>1</show_in_store>
|
158 |
+
<depends><type>ftp</type></depends>
|
159 |
+
<depends><export_enabled>1</export_enabled></depends>
|
160 |
+
</ftp_host>
|
161 |
+
<ftp_port translate="label">
|
162 |
+
<label>FTP Port</label>
|
163 |
+
<frontend_type>text</frontend_type>
|
164 |
+
<sort_order>50</sort_order>
|
165 |
+
<show_in_default>1</show_in_default>
|
166 |
+
<show_in_website>0</show_in_website>
|
167 |
+
<show_in_store>1</show_in_store>
|
168 |
+
<depends><type>ftp</type></depends>
|
169 |
+
<depends><export_enabled>1</export_enabled></depends>
|
170 |
+
</ftp_port>
|
171 |
+
<ftp_user translate="label">
|
172 |
+
<label>FTP User</label>
|
173 |
+
<frontend_type>text</frontend_type>
|
174 |
+
<sort_order>60</sort_order>
|
175 |
+
<show_in_default>1</show_in_default>
|
176 |
+
<show_in_website>0</show_in_website>
|
177 |
+
<show_in_store>1</show_in_store>
|
178 |
+
<depends><type>ftp</type></depends>
|
179 |
+
<depends><export_enabled>1</export_enabled></depends>
|
180 |
+
</ftp_user>
|
181 |
+
<ftp_password translate="label">
|
182 |
+
<label>FTP Password</label>
|
183 |
+
<frontend_type>text</frontend_type>
|
184 |
+
<sort_order>70</sort_order>
|
185 |
+
<show_in_default>1</show_in_default>
|
186 |
+
<show_in_website>0</show_in_website>
|
187 |
+
<show_in_store>1</show_in_store>
|
188 |
+
<depends><type>ftp</type></depends>
|
189 |
+
<depends><export_enabled>1</export_enabled></depends>
|
190 |
+
</ftp_password>
|
191 |
+
<passive translate="label">
|
192 |
+
<label>Passive</label>
|
193 |
+
<frontend_type>select</frontend_type>
|
194 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
195 |
+
<sort_order>80</sort_order>
|
196 |
+
<show_in_default>1</show_in_default>
|
197 |
+
<show_in_website>0</show_in_website>
|
198 |
+
<show_in_store>1</show_in_store>
|
199 |
+
<depends><type>ftp</type></depends>
|
200 |
+
<depends><export_enabled>1</export_enabled></depends>
|
201 |
+
</passive>
|
202 |
+
<cron_enabled translate="label">
|
203 |
+
<label>Enable Cron Catalog Update</label>
|
204 |
+
<frontend_type>select</frontend_type>
|
205 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
206 |
+
<sort_order>81</sort_order>
|
207 |
+
<show_in_default>1</show_in_default>
|
208 |
+
<show_in_website>0</show_in_website>
|
209 |
+
<show_in_store>1</show_in_store>
|
210 |
+
<depends><export_enabled>1</export_enabled></depends>
|
211 |
+
</cron_enabled>
|
212 |
+
<profile_id translate="label">
|
213 |
+
<label>Salesperson Export Profile Id</label>
|
214 |
+
<frontend_type>text</frontend_type>
|
215 |
+
<sort_order>85</sort_order>
|
216 |
+
<show_in_default>1</show_in_default>
|
217 |
+
<show_in_website>0</show_in_website>
|
218 |
+
<show_in_store>1</show_in_store>
|
219 |
+
<depends><cron_enabled>1</cron_enabled></depends>
|
220 |
+
<depends><export_enabled>1</export_enabled></depends>
|
221 |
+
</profile_id>
|
222 |
+
<cron_expr translate="label">
|
223 |
+
<label>Cron Expression</label>
|
224 |
+
<frontend_type>text</frontend_type>
|
225 |
+
<comment>Cron expression syntax</comment>
|
226 |
+
<backend_model>salesperson/system_config_backend_export_cron</backend_model>
|
227 |
+
<sort_order>90</sort_order>
|
228 |
+
<show_in_default>1</show_in_default>
|
229 |
+
<show_in_website>0</show_in_website>
|
230 |
+
<show_in_store>1</show_in_store>
|
231 |
+
<depends><cron_enabled>1</cron_enabled></depends>
|
232 |
+
<depends><export_enabled>1</export_enabled></depends>
|
233 |
+
</cron_expr>
|
234 |
+
</fields>
|
235 |
+
</export_settings>
|
236 |
+
<display_settings>
|
237 |
+
<label translate="label">Result Display Settings</label>
|
238 |
+
<frontend_type>text</frontend_type>
|
239 |
+
<sort_order>20</sort_order>
|
240 |
+
<show_in_default>1</show_in_default>
|
241 |
+
<show_in_website>0</show_in_website>
|
242 |
+
<show_in_store>1</show_in_store>
|
243 |
+
<fields>
|
244 |
+
<alt_message translate="label">
|
245 |
+
<label>Alternative Products Message</label>
|
246 |
+
<frontend_type>text</frontend_type>
|
247 |
+
<comment>Use {{query}}, {{new_query}} tags to display the search terms</comment>
|
248 |
+
<sort_order>5</sort_order>
|
249 |
+
<show_in_default>1</show_in_default>
|
250 |
+
<show_in_website>0</show_in_website>
|
251 |
+
<show_in_store>1</show_in_store>
|
252 |
+
</alt_message>
|
253 |
+
<layout translate="label">
|
254 |
+
<label>Page Layout</label>
|
255 |
+
<frontend_type>select</frontend_type>
|
256 |
+
<source_model>salesperson/system_config_source_layouts</source_model>
|
257 |
+
<sort_order>10</sort_order>
|
258 |
+
<show_in_default>1</show_in_default>
|
259 |
+
<show_in_website>0</show_in_website>
|
260 |
+
<show_in_store>1</show_in_store>
|
261 |
+
</layout>
|
262 |
+
<search_page_ajax_enabled translate="label">
|
263 |
+
<label>Enable Ajax Search Results Page</label>
|
264 |
+
<frontend_type>select</frontend_type>
|
265 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
266 |
+
<sort_order>15</sort_order>
|
267 |
+
<show_in_default>1</show_in_default>
|
268 |
+
<show_in_website>0</show_in_website>
|
269 |
+
<show_in_store>1</show_in_store>
|
270 |
+
</search_page_ajax_enabled >
|
271 |
+
<display_non_lead translate="label">
|
272 |
+
<label>Show Non Lead Questions</label>
|
273 |
+
<frontend_type>select</frontend_type>
|
274 |
+
<source_model>salesperson/system_config_source_nonlead</source_model>
|
275 |
+
<sort_order>20</sort_order>
|
276 |
+
<show_in_default>1</show_in_default>
|
277 |
+
<show_in_website>0</show_in_website>
|
278 |
+
<show_in_store>1</show_in_store>
|
279 |
+
</display_non_lead>
|
280 |
+
<display_lead translate="label">
|
281 |
+
<label>Show Lead Question</label>
|
282 |
+
<frontend_type>select</frontend_type>
|
283 |
+
<source_model>salesperson/system_config_source_lead</source_model>
|
284 |
+
<sort_order>30</sort_order>
|
285 |
+
<show_in_default>1</show_in_default>
|
286 |
+
<show_in_website>0</show_in_website>
|
287 |
+
<show_in_store>1</show_in_store>
|
288 |
+
</display_lead>
|
289 |
+
<breadcrumbs translate="label">
|
290 |
+
<label>Show Breadcrumbs</label>
|
291 |
+
<frontend_type>select</frontend_type>
|
292 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
293 |
+
<sort_order>80</sort_order>
|
294 |
+
<show_in_default>1</show_in_default>
|
295 |
+
<show_in_website>0</show_in_website>
|
296 |
+
<show_in_store>1</show_in_store>
|
297 |
+
</breadcrumbs>
|
298 |
+
<display_image_lead_question translate="label">
|
299 |
+
<label>Display Images In Lead Question</label>
|
300 |
+
<frontend_type>select</frontend_type>
|
301 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
302 |
+
<sort_order>85</sort_order>
|
303 |
+
<show_in_default>1</show_in_default>
|
304 |
+
<show_in_website>0</show_in_website>
|
305 |
+
<show_in_store>1</show_in_store>
|
306 |
+
</display_image_lead_question>
|
307 |
+
<radiobuttons_questions translate="label">
|
308 |
+
<label>Radio Buttons Questions</label>
|
309 |
+
<comment>Enter comma separated question names</comment>
|
310 |
+
<frontend_type>text</frontend_type>
|
311 |
+
<sort_order>86</sort_order>
|
312 |
+
<show_in_default>1</show_in_default>
|
313 |
+
<show_in_website>0</show_in_website>
|
314 |
+
<show_in_store>1</show_in_store>
|
315 |
+
</radiobuttons_questions>
|
316 |
+
<max_lead_answers translate="label">
|
317 |
+
<label>Maximum Lead Answers</label>
|
318 |
+
<frontend_type>text</frontend_type>
|
319 |
+
<sort_order>90</sort_order>
|
320 |
+
<show_in_default>1</show_in_default>
|
321 |
+
<show_in_website>0</show_in_website>
|
322 |
+
<show_in_store>1</show_in_store>
|
323 |
+
</max_lead_answers>
|
324 |
+
<max_non_lead_questions translate="label">
|
325 |
+
<label>Maximum Non Lead Questions</label>
|
326 |
+
<frontend_type>text</frontend_type>
|
327 |
+
<sort_order>110</sort_order>
|
328 |
+
<show_in_default>1</show_in_default>
|
329 |
+
<show_in_website>0</show_in_website>
|
330 |
+
<show_in_store>1</show_in_store>
|
331 |
+
</max_non_lead_questions>
|
332 |
+
<max_non_lead_answers translate="label">
|
333 |
+
<label>Maximum Non Lead Answers</label>
|
334 |
+
<frontend_type>text</frontend_type>
|
335 |
+
<sort_order>120</sort_order>
|
336 |
+
<show_in_default>1</show_in_default>
|
337 |
+
<show_in_website>0</show_in_website>
|
338 |
+
<show_in_store>1</show_in_store>
|
339 |
+
</max_non_lead_answers>
|
340 |
+
<enable_non_lead_answers_multiselect translate="label">
|
341 |
+
<label>Enable Non Lead Answers Multiselect</label>
|
342 |
+
<frontend_type>select</frontend_type>
|
343 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
344 |
+
<sort_order>131</sort_order>
|
345 |
+
<show_in_default>1</show_in_default>
|
346 |
+
<show_in_website>0</show_in_website>
|
347 |
+
<show_in_store>1</show_in_store>
|
348 |
+
</enable_non_lead_answers_multiselect>
|
349 |
+
<show_product_count_in_lead_answers translate="label">
|
350 |
+
<label>Show Product Count In Lead Answers</label>
|
351 |
+
<frontend_type>select</frontend_type>
|
352 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
353 |
+
<sort_order>140</sort_order>
|
354 |
+
<show_in_default>1</show_in_default>
|
355 |
+
<show_in_website>0</show_in_website>
|
356 |
+
<show_in_store>1</show_in_store>
|
357 |
+
</show_product_count_in_lead_answers>
|
358 |
+
<show_product_count_in_non_lead_answers translate="label">
|
359 |
+
<label>Show Product Count In Non Lead Answers</label>
|
360 |
+
<frontend_type>select</frontend_type>
|
361 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
362 |
+
<sort_order>150</sort_order>
|
363 |
+
<show_in_default>1</show_in_default>
|
364 |
+
<show_in_website>0</show_in_website>
|
365 |
+
<show_in_store>1</show_in_store>
|
366 |
+
</show_product_count_in_non_lead_answers>
|
367 |
+
<page_size_selector translate="label">
|
368 |
+
<label>Page Size Selector Type</label>
|
369 |
+
<frontend_type>select</frontend_type>
|
370 |
+
<source_model>salesperson/system_config_source_selectortype</source_model>
|
371 |
+
<sort_order>170</sort_order>
|
372 |
+
<show_in_default>1</show_in_default>
|
373 |
+
<show_in_website>0</show_in_website>
|
374 |
+
<show_in_store>1</show_in_store>
|
375 |
+
</page_size_selector>
|
376 |
+
<all_per_page translate="label">
|
377 |
+
<label>Actual Page Size for Show All</label>
|
378 |
+
<frontend_type>text</frontend_type>
|
379 |
+
<sort_order>175</sort_order>
|
380 |
+
<show_in_default>1</show_in_default>
|
381 |
+
<show_in_website>0</show_in_website>
|
382 |
+
<show_in_store>1</show_in_store>
|
383 |
+
</all_per_page>
|
384 |
+
<sorting_selector translate="label">
|
385 |
+
<label>Sort Selector Type</label>
|
386 |
+
<frontend_type>select</frontend_type>
|
387 |
+
<source_model>salesperson/system_config_source_selectortype</source_model>
|
388 |
+
<sort_order>180</sort_order>
|
389 |
+
<show_in_default>1</show_in_default>
|
390 |
+
<show_in_website>0</show_in_website>
|
391 |
+
<show_in_store>1</show_in_store>
|
392 |
+
</sorting_selector>
|
393 |
+
<sorting_fields translate="label">
|
394 |
+
<label>Sorting fields</label>
|
395 |
+
<frontend_type>textarea</frontend_type>
|
396 |
+
<sort_order>181</sort_order>
|
397 |
+
<show_in_default>1</show_in_default>
|
398 |
+
<show_in_website>0</show_in_website>
|
399 |
+
<show_in_store>1</show_in_store>
|
400 |
+
<comment>Magento attribute code ~ order ~ Salesperson attribute code (usually the same as Magento) </comment>
|
401 |
+
</sorting_fields>
|
402 |
+
<default_sort_by translate="label">
|
403 |
+
<label>Default sort</label>
|
404 |
+
<frontend_type>text</frontend_type>
|
405 |
+
<sort_order>182</sort_order>
|
406 |
+
<show_in_default>1</show_in_default>
|
407 |
+
<show_in_website>0</show_in_website>
|
408 |
+
<show_in_store>1</show_in_store>
|
409 |
+
</default_sort_by>
|
410 |
+
<price_selector translate="label">
|
411 |
+
<label>Price Selector Type</label>
|
412 |
+
<frontend_type>select</frontend_type>
|
413 |
+
<source_model>salesperson/system_config_source_pricetype</source_model>
|
414 |
+
<sort_order>185</sort_order>
|
415 |
+
<show_in_default>1</show_in_default>
|
416 |
+
<show_in_website>0</show_in_website>
|
417 |
+
<show_in_store>1</show_in_store>
|
418 |
+
</price_selector>
|
419 |
+
<page_nav_type translate="label">
|
420 |
+
<label>Pagination</label>
|
421 |
+
<frontend_type>select</frontend_type>
|
422 |
+
<source_model>salesperson/system_config_source_pagenavtype</source_model>
|
423 |
+
<sort_order>190</sort_order>
|
424 |
+
<show_in_default>1</show_in_default>
|
425 |
+
<show_in_website>0</show_in_website>
|
426 |
+
<show_in_store>1</show_in_store>
|
427 |
+
</page_nav_type>
|
428 |
+
<go_to_product_on_one_result translate="label">
|
429 |
+
<label>Go To Product Page On One Result</label>
|
430 |
+
<frontend_type>select</frontend_type>
|
431 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
432 |
+
<sort_order>200</sort_order>
|
433 |
+
<show_in_default>1</show_in_default>
|
434 |
+
<show_in_website>0</show_in_website>
|
435 |
+
<show_in_store>1</show_in_store>
|
436 |
+
</go_to_product_on_one_result>
|
437 |
+
<search_profile translate="label">
|
438 |
+
<label>Search profile name</label>
|
439 |
+
<frontend_type>text</frontend_type>
|
440 |
+
<sort_order>210</sort_order>
|
441 |
+
<show_in_default>1</show_in_default>
|
442 |
+
<show_in_website>0</show_in_website>
|
443 |
+
<show_in_store>1</show_in_store>
|
444 |
+
</search_profile>
|
445 |
+
</fields>
|
446 |
+
</display_settings>
|
447 |
+
<nav_to_search_settings>
|
448 |
+
<label>Navigation to Search Settings</label>
|
449 |
+
<frontend_type>text</frontend_type>
|
450 |
+
<sort_order>25</sort_order>
|
451 |
+
<show_in_default>1</show_in_default>
|
452 |
+
<show_in_website>0</show_in_website>
|
453 |
+
<show_in_store>1</show_in_store>
|
454 |
+
<fields>
|
455 |
+
<nav_to_search translate="label">
|
456 |
+
<label>Enable Navigation to Search</label>
|
457 |
+
<frontend_type>select</frontend_type>
|
458 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
459 |
+
<backend_model>salesperson/system_config_backend_navigationtosearch_enable</backend_model>
|
460 |
+
<sort_order>0</sort_order>
|
461 |
+
<show_in_default>1</show_in_default>
|
462 |
+
<show_in_website>0</show_in_website>
|
463 |
+
<show_in_store>1</show_in_store>
|
464 |
+
</nav_to_search>
|
465 |
+
<nav_to_search_use_full_category_path translate="label">
|
466 |
+
<label>Navigation to Search by</label>
|
467 |
+
<frontend_type>select</frontend_type>
|
468 |
+
<source_model>salesperson/system_config_source_navigationtosearch</source_model>
|
469 |
+
<sort_order>10</sort_order>
|
470 |
+
<show_in_default>1</show_in_default>
|
471 |
+
<show_in_website>0</show_in_website>
|
472 |
+
<show_in_store>1</show_in_store>
|
473 |
+
<depends>
|
474 |
+
<nav_to_search>1</nav_to_search>
|
475 |
+
</depends>
|
476 |
+
</nav_to_search_use_full_category_path>
|
477 |
+
</fields>
|
478 |
+
</nav_to_search_settings>
|
479 |
+
<anlx_settings>
|
480 |
+
<label translate="label">Analytics Settings</label>
|
481 |
+
<frontend_type>text</frontend_type>
|
482 |
+
<sort_order>30</sort_order>
|
483 |
+
<show_in_default>1</show_in_default>
|
484 |
+
<show_in_website>0</show_in_website>
|
485 |
+
<show_in_store>1</show_in_store>
|
486 |
+
<fields>
|
487 |
+
<host translate="label">
|
488 |
+
<label>Host</label>
|
489 |
+
<frontend_type>text</frontend_type>
|
490 |
+
<sort_order>0</sort_order>
|
491 |
+
<show_in_default>1</show_in_default>
|
492 |
+
<show_in_website>0</show_in_website>
|
493 |
+
<show_in_store>1</show_in_store>
|
494 |
+
</host>
|
495 |
+
<cid translate="label">
|
496 |
+
<label>Customer Id</label>
|
497 |
+
<frontend_type>text</frontend_type>
|
498 |
+
<sort_order>10</sort_order>
|
499 |
+
<show_in_default>1</show_in_default>
|
500 |
+
<show_in_website>0</show_in_website>
|
501 |
+
<show_in_store>1</show_in_store>
|
502 |
+
</cid>
|
503 |
+
</fields>
|
504 |
+
</anlx_settings>
|
505 |
+
<autocomplete_settings>
|
506 |
+
<label>Auto Complete Settings</label>
|
507 |
+
<frontend_type>text</frontend_type>
|
508 |
+
<sort_order>40</sort_order>
|
509 |
+
<show_in_default>1</show_in_default>
|
510 |
+
<show_in_website>0</show_in_website>
|
511 |
+
<show_in_store>1</show_in_store>
|
512 |
+
<fields>
|
513 |
+
<autocomplete_enabled translate="label">
|
514 |
+
<label>Enable Auto Complete</label>
|
515 |
+
<frontend_type>select</frontend_type>
|
516 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
517 |
+
<sort_order>0</sort_order>
|
518 |
+
<show_in_default>1</show_in_default>
|
519 |
+
<show_in_website>0</show_in_website>
|
520 |
+
<show_in_store>1</show_in_store>
|
521 |
+
</autocomplete_enabled>
|
522 |
+
<ac_customer_name translate="label">
|
523 |
+
<label>Auto Complete Customer Name</label>
|
524 |
+
<frontend_type>text</frontend_type>
|
525 |
+
<comment>Customer name as defined by Celebros</comment>
|
526 |
+
<sort_order>5</sort_order>
|
527 |
+
<show_in_default>1</show_in_default>
|
528 |
+
<show_in_website>0</show_in_website>
|
529 |
+
<show_in_store>1</show_in_store>
|
530 |
+
<depends><autocomplete_enabled>1</autocomplete_enabled></depends>
|
531 |
+
</ac_customer_name>
|
532 |
+
<ac_frontend_address translate="label">
|
533 |
+
<label>Auto Complete Frontend Server</label>
|
534 |
+
<frontend_type>text</frontend_type>
|
535 |
+
<comment>Host name / ip of the server on which the AutoComplete front-end resides</comment>
|
536 |
+
<sort_order>10</sort_order>
|
537 |
+
<show_in_default>1</show_in_default>
|
538 |
+
<show_in_website>0</show_in_website>
|
539 |
+
<show_in_store>1</show_in_store>
|
540 |
+
<depends><autocomplete_enabled>1</autocomplete_enabled></depends>
|
541 |
+
</ac_frontend_address>
|
542 |
+
<ac_scriptserver_address translate="label">
|
543 |
+
<label>Auto Complete Script Server</label>
|
544 |
+
<frontend_type>text</frontend_type>
|
545 |
+
<comment>Host name / ip of the server on which the AutoComplete content (scripts and styles) website resides. This is typically the same as above.</comment>
|
546 |
+
<sort_order>15</sort_order>
|
547 |
+
<show_in_default>1</show_in_default>
|
548 |
+
<show_in_website>0</show_in_website>
|
549 |
+
<show_in_store>1</show_in_store>
|
550 |
+
<depends><autocomplete_enabled>1</autocomplete_enabled></depends>
|
551 |
+
</ac_scriptserver_address>
|
552 |
+
</fields>
|
553 |
+
</autocomplete_settings>
|
554 |
+
<crosssell_settings>
|
555 |
+
<label>CrossSell Settings</label>
|
556 |
+
<frontend_type>text</frontend_type>
|
557 |
+
<sort_order>50</sort_order>
|
558 |
+
<show_in_default>1</show_in_default>
|
559 |
+
<show_in_website>0</show_in_website>
|
560 |
+
<show_in_store>1</show_in_store>
|
561 |
+
<fields>
|
562 |
+
<crosssell_enabled translate="label">
|
563 |
+
<label>Enable Crosssell</label>
|
564 |
+
<frontend_type>select</frontend_type>
|
565 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
566 |
+
<sort_order>0</sort_order>
|
567 |
+
<show_in_default>1</show_in_default>
|
568 |
+
<show_in_website>0</show_in_website>
|
569 |
+
<show_in_store>1</show_in_store>
|
570 |
+
</crosssell_enabled>
|
571 |
+
<crosssell_customer_name translate="label">
|
572 |
+
<label>Cross-Sell Customer Name</label>
|
573 |
+
<frontend_type>text</frontend_type>
|
574 |
+
<comment>Cross-Sell customer name as defined by Celebros</comment>
|
575 |
+
<sort_order>5</sort_order>
|
576 |
+
<show_in_default>1</show_in_default>
|
577 |
+
<show_in_website>0</show_in_website>
|
578 |
+
<show_in_store>1</show_in_store>
|
579 |
+
<depends><crosssell_enabled>1</crosssell_enabled></depends>
|
580 |
+
</crosssell_customer_name>
|
581 |
+
<crosssell_request_handle translate="label">
|
582 |
+
<label>Cross-Sell Request Handle</label>
|
583 |
+
<frontend_type>text</frontend_type>
|
584 |
+
<comment>Cross-Sell request handle name as defined by Celebros</comment>
|
585 |
+
<sort_order>10</sort_order>
|
586 |
+
<show_in_default>1</show_in_default>
|
587 |
+
<show_in_website>0</show_in_website>
|
588 |
+
<show_in_store>1</show_in_store>
|
589 |
+
<depends><crosssell_enabled>1</crosssell_enabled></depends>
|
590 |
+
</crosssell_request_handle>
|
591 |
+
<crosssell_address translate="label">
|
592 |
+
<label>Cross-Sell Server</label>
|
593 |
+
<frontend_type>text</frontend_type>
|
594 |
+
<comment>Host name / ip of the server on which the Cross-Sell resides</comment>
|
595 |
+
<sort_order>20</sort_order>
|
596 |
+
<show_in_default>1</show_in_default>
|
597 |
+
<show_in_website>0</show_in_website>
|
598 |
+
<show_in_store>1</show_in_store>
|
599 |
+
<depends><crosssell_enabled>1</crosssell_enabled></depends>
|
600 |
+
<depends><crosssell_enabled>1</crosssell_enabled></depends>
|
601 |
+
</crosssell_address>
|
602 |
+
</fields>
|
603 |
+
</crosssell_settings>
|
604 |
+
<giftfinder_settings>
|
605 |
+
<label>Giftfinder Settings</label>
|
606 |
+
<frontend_type>text</frontend_type>
|
607 |
+
<sort_order>60</sort_order>
|
608 |
+
<show_in_default>1</show_in_default>
|
609 |
+
<show_in_website>0</show_in_website>
|
610 |
+
<show_in_store>1</show_in_store>
|
611 |
+
<fields>
|
612 |
+
<giftfinder_profile translate="label">
|
613 |
+
<label>Gift Finder Profile Name</label>
|
614 |
+
<comment>To get the gift finder example go to {{store url}}/salesperson/giftfinder</comment>
|
615 |
+
<frontend_type>text</frontend_type>
|
616 |
+
<sort_order>0</sort_order>
|
617 |
+
<show_in_default>1</show_in_default>
|
618 |
+
<show_in_website>0</show_in_website>
|
619 |
+
<show_in_store>1</show_in_store>
|
620 |
+
</giftfinder_profile>
|
621 |
+
<giftfinder_type translate="label">
|
622 |
+
<label>Gift Finder Type</label>
|
623 |
+
<frontend_type>select</frontend_type>
|
624 |
+
<source_model>salesperson/system_config_source_giftfindertypes</source_model>
|
625 |
+
<sort_order>10</sort_order>
|
626 |
+
<show_in_default>1</show_in_default>
|
627 |
+
<show_in_website>0</show_in_website>
|
628 |
+
<show_in_store>1</show_in_store>
|
629 |
+
</giftfinder_type>
|
630 |
+
</fields>
|
631 |
+
</giftfinder_settings>
|
632 |
+
<livesight_settings>
|
633 |
+
<label>LiveSight Settings</label>
|
634 |
+
<frontend_type>text</frontend_type>
|
635 |
+
<sort_order>70</sort_order>
|
636 |
+
<show_in_default>1</show_in_default>
|
637 |
+
<show_in_website>0</show_in_website>
|
638 |
+
<show_in_store>1</show_in_store>
|
639 |
+
<fields>
|
640 |
+
<livesight_enabled translate="label">
|
641 |
+
<label>Enable LiveSight</label>
|
642 |
+
<frontend_type>select</frontend_type>
|
643 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
644 |
+
<sort_order>0</sort_order>
|
645 |
+
<show_in_default>1</show_in_default>
|
646 |
+
<show_in_website>0</show_in_website>
|
647 |
+
<show_in_store>1</show_in_store>
|
648 |
+
</livesight_enabled>
|
649 |
+
</fields>
|
650 |
+
</livesight_settings>
|
651 |
+
</groups>
|
652 |
+
</salesperson>
|
653 |
+
</sections>
|
654 |
+
</config>
|
app/code/{local → community}/Celebros/Salesperson/sql/salesperson_setup/mysql4-install-0.1.0.php
RENAMED
@@ -1,74 +1,68 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
|
11 |
-
//echo "started"; exit();
|
12 |
-
|
13 |
-
$installer = $this;
|
14 |
-
/* @var $installer Mage_Core_Model_Resource_Setup */
|
15 |
-
|
16 |
-
$installer->startSetup();
|
17 |
-
|
18 |
-
$installer->run(
|
19 |
-
"INSERT INTO `{$this->getTable('dataflow_profile')}` (`profile_id`, `name`, `created_at`, `updated_at`, `actions_xml`, `gui_data`, `direction`, `entity_type`, `store_id`, `data_transfer`) VALUES"
|
20 |
-
." (null, 'Salesperson Exporter', '2010-03-03 10:49:35', '2010-03-08 17:54:19',
|
21 |
-
'<action type=\"catalog/convert_adapter_product\" method=\"load\">
|
22 |
-
<var name=\"store\"><![CDATA[0]]></var>
|
23 |
-
</action>
|
24 |
-
|
25 |
-
<action type=\"salesperson/convert_parser_product\" method=\"unparse\">
|
26 |
-
<var name=\"store\"><![CDATA[0]]></var>
|
27 |
-
<var name=\"url_field\"><![CDATA[0]]></var>
|
28 |
-
</action>
|
29 |
-
|
30 |
-
<action type=\"salesperson/convert_mapper_column\" method=\"map\">
|
31 |
-
<var name=\"map\">
|
32 |
-
<map name=\"store_id\"><![CDATA[store_id]]></map>
|
33 |
-
<map name=\"websites\"><![CDATA[websites]]></map>
|
34 |
-
<map name=\"id\"><![CDATA[id]]></map>
|
35 |
-
<map name=\"name\"><![CDATA[title]]></map>
|
36 |
-
<map name=\"price\"><![CDATA[price]]></map>
|
37 |
-
<map name=\"rating\"><![CDATA[rating]]></map>
|
38 |
-
<map name=\"url_path\"><![CDATA[link]]></map>
|
39 |
-
<map name=\"thumbnail\"><![CDATA[image_link]]></map>
|
40 |
-
<map name=\"category\"><![CDATA[category]]></map>
|
41 |
-
<map name=\"type\"><![CDATA[type]]></map>
|
42 |
-
<map name=\"weight\"><![CDATA[weight]]></map>
|
43 |
-
<map name=\"manufacturer\"><![CDATA[brand]]></map>
|
44 |
-
<map name=\"color\"><![CDATA[color]]></map>
|
45 |
-
<map name=\"thumbnail_label\"><![CDATA[thumbnail_label]]></map>
|
46 |
-
<map name=\"description\"><![CDATA[description]]></map>
|
47 |
-
<map name=\"short_description\"><![CDATA[short_description]]></map>
|
48 |
-
<map name=\"is_in_stock\"><![CDATA[is_in_stock]]></map>
|
49 |
-
<map name=\"news_from_date\"><![CDATA[news_from_date]]></map>
|
50 |
-
<map name=\"news_to_date\"><![CDATA[news_to_date]]></map>
|
51 |
-
<map name=\"sku\"><![CDATA[product_sku]]></map>
|
52 |
-
<map name=\"status\"><![CDATA[status]]></map>
|
53 |
-
</var>
|
54 |
-
<var name=\"_only_specified\">true</var>
|
55 |
-
</action>
|
56 |
-
|
57 |
-
<action type=\"salesperson/
|
58 |
-
<var name=\"
|
59 |
-
<var name=\"
|
60 |
-
<var name=\"
|
61 |
-
</action>
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
'', NULL, '', 0, NULL);"
|
69 |
-
);
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
|
11 |
+
//echo "started"; exit();
|
12 |
+
|
13 |
+
$installer = $this;
|
14 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
15 |
+
|
16 |
+
$installer->startSetup();
|
17 |
+
|
18 |
+
$installer->run(
|
19 |
+
"INSERT INTO `{$this->getTable('dataflow_profile')}` (`profile_id`, `name`, `created_at`, `updated_at`, `actions_xml`, `gui_data`, `direction`, `entity_type`, `store_id`, `data_transfer`) VALUES"
|
20 |
+
." (null, 'Salesperson Exporter', '2010-03-03 10:49:35', '2010-03-08 17:54:19',
|
21 |
+
'<action type=\"catalog/convert_adapter_product\" method=\"load\">
|
22 |
+
<var name=\"store\"><![CDATA[0]]></var>
|
23 |
+
</action>
|
24 |
+
|
25 |
+
<action type=\"salesperson/convert_parser_product\" method=\"unparse\">
|
26 |
+
<var name=\"store\"><![CDATA[0]]></var>
|
27 |
+
<var name=\"url_field\"><![CDATA[0]]></var>
|
28 |
+
</action>
|
29 |
+
|
30 |
+
<action type=\"salesperson/convert_mapper_column\" method=\"map\">
|
31 |
+
<var name=\"map\">
|
32 |
+
<map name=\"store_id\"><![CDATA[store_id]]></map>
|
33 |
+
<map name=\"websites\"><![CDATA[websites]]></map>
|
34 |
+
<map name=\"id\"><![CDATA[id]]></map>
|
35 |
+
<map name=\"name\"><![CDATA[title]]></map>
|
36 |
+
<map name=\"price\"><![CDATA[price]]></map>
|
37 |
+
<map name=\"rating\"><![CDATA[rating]]></map>
|
38 |
+
<map name=\"url_path\"><![CDATA[link]]></map>
|
39 |
+
<map name=\"thumbnail\"><![CDATA[image_link]]></map>
|
40 |
+
<map name=\"category\"><![CDATA[category]]></map>
|
41 |
+
<map name=\"type\"><![CDATA[type]]></map>
|
42 |
+
<map name=\"weight\"><![CDATA[weight]]></map>
|
43 |
+
<map name=\"manufacturer\"><![CDATA[brand]]></map>
|
44 |
+
<map name=\"color\"><![CDATA[color]]></map>
|
45 |
+
<map name=\"thumbnail_label\"><![CDATA[thumbnail_label]]></map>
|
46 |
+
<map name=\"description\"><![CDATA[description]]></map>
|
47 |
+
<map name=\"short_description\"><![CDATA[short_description]]></map>
|
48 |
+
<map name=\"is_in_stock\"><![CDATA[is_in_stock]]></map>
|
49 |
+
<map name=\"news_from_date\"><![CDATA[news_from_date]]></map>
|
50 |
+
<map name=\"news_to_date\"><![CDATA[news_to_date]]></map>
|
51 |
+
<map name=\"sku\"><![CDATA[product_sku]]></map>
|
52 |
+
<map name=\"status\"><![CDATA[status]]></map>
|
53 |
+
</var>
|
54 |
+
<var name=\"_only_specified\">true</var>
|
55 |
+
</action>
|
56 |
+
|
57 |
+
<action type=\"salesperson/convert_adapter_io\" method=\"save\">
|
58 |
+
<var name=\"type\">file</var>
|
59 |
+
<var name=\"path\">var/export</var>
|
60 |
+
<var name=\"filename\"><![CDATA[products.txt]]></var>
|
61 |
+
</action>',
|
62 |
+
'', NULL, '', 0, NULL);"
|
63 |
+
);
|
64 |
+
|
65 |
+
|
66 |
+
|
67 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
$installer->endSetup();
|
app/code/{local → community}/Celebros/Salesperson/sql/salesperson_setup/mysql4-upgrade-0.1.0-0.1.1.php
RENAMED
@@ -1,45 +1,44 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
$installer = $this;
|
11 |
-
/* @var $installer Mage_Core_Model_Resource_Setup */
|
12 |
-
|
13 |
-
$installer->startSetup();
|
14 |
-
|
15 |
-
$installer->run("
|
16 |
-
CREATE TABLE IF NOT EXISTS `{$this->getTable('celebrosfieldsmapping')}` (
|
17 |
-
`id` int(11) NOT NULL auto_increment,
|
18 |
-
`xml_field` VARCHAR(255) NULL,
|
19 |
-
`code_field` text,
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
(null,'
|
28 |
-
(null, '
|
29 |
-
(null, '
|
30 |
-
(null, '
|
31 |
-
(null, '
|
32 |
-
(null, '
|
33 |
-
(null, '
|
34 |
-
(null, '
|
35 |
-
(null, '
|
36 |
-
(null, '
|
37 |
-
(null, '
|
38 |
-
(null, '
|
39 |
-
(null, '
|
40 |
-
(null, '
|
41 |
-
(null, '
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
$installer = $this;
|
11 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
12 |
+
|
13 |
+
$installer->startSetup();
|
14 |
+
|
15 |
+
$installer->run("
|
16 |
+
CREATE TABLE IF NOT EXISTS `{$this->getTable('celebrosfieldsmapping')}` (
|
17 |
+
`id` int(11) NOT NULL auto_increment,
|
18 |
+
`xml_field` VARCHAR(255) NULL,
|
19 |
+
`code_field` text,
|
20 |
+
PRIMARY KEY (`id`),
|
21 |
+
UNIQUE `XML_FIELD` ( `xml_field` )
|
22 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
23 |
+
|
24 |
+
INSERT INTO `{$this->getTable('celebrosfieldsmapping')}` (id, xml_field, code_field)
|
25 |
+
VALUES
|
26 |
+
(null,'title','title'),
|
27 |
+
(null, 'link', 'link'),
|
28 |
+
(null, 'status','status'),
|
29 |
+
(null, 'image_link','image_link'),
|
30 |
+
(null, 'thumbnail_label','thumbnail_label'),
|
31 |
+
(null, 'rating','rating'),
|
32 |
+
(null, 'short_description','short_description'),
|
33 |
+
(null, 'id', 'id'),
|
34 |
+
(null, 'visible', 'visible'),
|
35 |
+
(null, 'store_id', 'store_id'),
|
36 |
+
(null, 'is_in_stock', 'is_in_stock'),
|
37 |
+
(null, 'product_sku', 'sku'),
|
38 |
+
(null, 'category', 'category'),
|
39 |
+
(null, 'websites', 'websites'),
|
40 |
+
(null, 'news_from_date', 'news_from_date'),
|
41 |
+
(null, 'news_to_date', 'news_to_date') ON DUPLICATE KEY UPDATE code_field=code_field;
|
42 |
+
");
|
43 |
+
|
|
|
44 |
$installer->endSetup();
|
app/code/community/Celebros/Salesperson/sql/salesperson_setup/mysql4-upgrade-0.1.1-0.1.2.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Celebros Qwiser - Magento Extension
|
4 |
+
*
|
5 |
+
* @category Celebros
|
6 |
+
* @package Celebros_Salesperson
|
7 |
+
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
$installer = Mage::getResourceModel('catalog/setup', 'default_setup');
|
11 |
+
/* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
|
12 |
+
|
13 |
+
$installer->startSetup();
|
14 |
+
|
15 |
+
$entityTypeId = $installer->getEntityTypeId('catalog_category');
|
16 |
+
$attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);
|
17 |
+
$attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
|
18 |
+
$attributeCode = 'salesperson_search_phrase';
|
19 |
+
|
20 |
+
if(!$installer->getAttribute('catalog_category', $attributeCode)) {
|
21 |
+
$installer->addAttribute('catalog_category', $attributeCode, array(
|
22 |
+
'type' => 'varchar',
|
23 |
+
'label' => 'Salesperson search phrase',
|
24 |
+
'input' => 'text',
|
25 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
|
26 |
+
'visible' => true,
|
27 |
+
'required' => false,
|
28 |
+
'user_defined' => false,
|
29 |
+
'default' => ''
|
30 |
+
));
|
31 |
+
|
32 |
+
$installer->addAttributeToGroup(
|
33 |
+
$entityTypeId,
|
34 |
+
$attributeSetId,
|
35 |
+
$attributeGroupId,
|
36 |
+
$attributeCode,
|
37 |
+
'10000' //last Magento's attribute position in General tab is 10
|
38 |
+
);
|
39 |
+
|
40 |
+
}
|
41 |
+
|
42 |
+
$installer->endSetup();
|
app/code/local/Celebros/Salesperson/Block/Layer/View.php
DELETED
@@ -1,183 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_salesperson_Block_Layer_View extends Mage_Core_Block_Template
|
11 |
-
{
|
12 |
-
protected function getQwiserSearchResults(){
|
13 |
-
if(Mage::helper('salesperson')->getSalespersonApi()->results)
|
14 |
-
return Mage::helper('salesperson')->getSalespersonApi()->results;
|
15 |
-
}
|
16 |
-
/**
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Prepare child blocks
|
20 |
-
*
|
21 |
-
* @return Celebros_Salesperson_Block_Layer_View
|
22 |
-
*/
|
23 |
-
protected function _prepareLayout()
|
24 |
-
{
|
25 |
-
$stateBlock = $this->getLayout()->createBlock('salesperson/layer_state')
|
26 |
-
->setLayer($this->getLayer());
|
27 |
-
$this->setChild('layer_state', $stateBlock);
|
28 |
-
|
29 |
-
return parent::_prepareLayout();
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Get layer object
|
34 |
-
*
|
35 |
-
* @return Celebros_Salesperson_Model_Layer
|
36 |
-
*/
|
37 |
-
public function getLayer()
|
38 |
-
{
|
39 |
-
return Mage::getSingleton('salesperson/layer');
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Get layered navigation state html
|
44 |
-
*
|
45 |
-
* @return string
|
46 |
-
*/
|
47 |
-
public function getStateHtml()
|
48 |
-
{
|
49 |
-
return $this->getChildHtml('layer_state');
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Get all layer filters
|
54 |
-
*
|
55 |
-
* @return array
|
56 |
-
*/
|
57 |
-
public function getFilters()
|
58 |
-
{
|
59 |
-
$questions = $this->getQwiserSearchResults()->Questions->GetAllQuestions();
|
60 |
-
|
61 |
-
$filters = array();
|
62 |
-
if ($questions){
|
63 |
-
foreach($questions as $question){
|
64 |
-
$filters[] = $question;
|
65 |
-
}
|
66 |
-
}
|
67 |
-
|
68 |
-
return $filters;
|
69 |
-
}
|
70 |
-
|
71 |
-
public function answerQuestionUrl($answerId){
|
72 |
-
$urlParams = array();
|
73 |
-
$urlParams['_current'] = true;
|
74 |
-
$urlParams['_escape'] = true;
|
75 |
-
$urlParams['_use_rewrite'] = true;
|
76 |
-
$urlParams['_query'] = array(
|
77 |
-
'searchHandle' => $this->getQwiserSearchResults()->GetSearchHandle(),
|
78 |
-
'salespersonaction' => 'answerQuestion',
|
79 |
-
'answerId' => $answerId,
|
80 |
-
);
|
81 |
-
$url = Mage::getUrl('*/*/change', $urlParams);
|
82 |
-
if (preg_match("/p=*\d/", $url)){
|
83 |
-
$url = preg_replace("/p=*\d/",'p=1', $url);
|
84 |
-
}
|
85 |
-
else {
|
86 |
-
$url .= "&p=1";
|
87 |
-
}
|
88 |
-
return $url;
|
89 |
-
}
|
90 |
-
|
91 |
-
public function getFilterText($filter,$type){
|
92 |
-
if ($type == "nonlead" && Mage::Helper('salesperson')->getNonLeadQuestionsPosition() != 'top'){
|
93 |
-
return $filter->SideText;
|
94 |
-
}
|
95 |
-
elseif ($type == "lead"){
|
96 |
-
return $filter->SideText;
|
97 |
-
}
|
98 |
-
return $filter->Text;
|
99 |
-
}
|
100 |
-
|
101 |
-
public function getMaxLeadAnswers(){
|
102 |
-
return Mage::getStoreConfig('salesperson/display_settings/max_lead_answers');
|
103 |
-
}
|
104 |
-
|
105 |
-
public function getMaxNonLeadAnswers(){
|
106 |
-
if (Mage::Helper('salesperson')->getNonLeadQuestionsPosition() == 'left' || Mage::Helper('salesperson')->getNonLeadQuestionsPosition() == 'right'){
|
107 |
-
return Mage::getStoreConfig('salesperson/display_settings/max_non_lead_answers_side_nav');
|
108 |
-
}
|
109 |
-
return Mage::getStoreConfig('salesperson/display_settings/max_non_lead_answers');
|
110 |
-
}
|
111 |
-
|
112 |
-
public function getMaxNonLeadQuestions(){
|
113 |
-
return Mage::getStoreConfig('salesperson/display_settings/max_non_lead_questions');
|
114 |
-
}
|
115 |
-
|
116 |
-
public function showProductCountInLeadAnswers(){
|
117 |
-
return Mage::getStoreConfigFlag('salesperson/display_settings/show_product_count_in_lead_answers');
|
118 |
-
}
|
119 |
-
|
120 |
-
public function showProductCountInNonLeadAnswers(){
|
121 |
-
return Mage::getStoreConfigFlag('salesperson/display_settings/show_product_count_in_non_lead_answers');
|
122 |
-
}
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Check availability display layer block
|
128 |
-
*
|
129 |
-
* @return bool
|
130 |
-
*/
|
131 |
-
public function canShowNoneLeadSideBlock()
|
132 |
-
{
|
133 |
-
return Mage::Helper('salesperson')->getNonLeadQuestionsPosition() == 'left' || Mage::Helper('salesperson')->getNonLeadQuestionsPosition() == 'right';
|
134 |
-
}
|
135 |
-
|
136 |
-
public function canShowLeadQuestion(){
|
137 |
-
return Mage::getStoreConfigFlag('salesperson/display_settings/display_lead');
|
138 |
-
}
|
139 |
-
|
140 |
-
public function forceLeadQuestion($questionId){
|
141 |
-
$urlParams = array();
|
142 |
-
$urlParams['_current'] = true;
|
143 |
-
$urlParams['_escape'] = true;
|
144 |
-
$urlParams['_use_rewrite'] = true;
|
145 |
-
$urlParams['_query'] = array(
|
146 |
-
'searchHandle' => $this->getQwiserSearchResults()->GetSearchHandle(),
|
147 |
-
'salespersonaction' => 'forceQuestion',
|
148 |
-
'questionId' => $questionId,
|
149 |
-
);
|
150 |
-
return Mage::getUrl('*/*/change', $urlParams);
|
151 |
-
}
|
152 |
-
|
153 |
-
public function stateHasFilters(){
|
154 |
-
return count($this->getLayer()->getState()->getFilters()) > 0;
|
155 |
-
}
|
156 |
-
|
157 |
-
public function getCustomPriceAnswerUrl(){
|
158 |
-
$urlParams = array();
|
159 |
-
$urlParams['_current'] = true;
|
160 |
-
$urlParams['_escape'] = false;
|
161 |
-
$urlParams['_use_rewrite'] = true;
|
162 |
-
$urlParams['_query'] = array(
|
163 |
-
'searchHandle' => $this->getQwiserSearchResults()->GetSearchHandle(),
|
164 |
-
'salespersonaction' => 'answerQuestion',
|
165 |
-
);
|
166 |
-
$url = Mage::getUrl('*/*/change', $urlParams);
|
167 |
-
if(strpos($url, "answerId=")){
|
168 |
-
$replace_string = substr($url,strpos($url, "answerId="),strpos($url, '&',strpos($url, "answerId=")) - strpos($url, "answerId="));
|
169 |
-
$url = str_replace($replace_string, '', $url);
|
170 |
-
}
|
171 |
-
if (preg_match("/p=*\d/", $url)){
|
172 |
-
$url = preg_replace("/p=*\d/",'p=1', $url);
|
173 |
-
}
|
174 |
-
else {
|
175 |
-
$url .= "&p=1";
|
176 |
-
}
|
177 |
-
return $url;
|
178 |
-
}
|
179 |
-
|
180 |
-
public function getDisplayImageInLeadQuestion(){
|
181 |
-
return Mage::getStoreConfigFlag('salesperson/display_settings/display_image_lead_question');
|
182 |
-
}
|
183 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Celebros/Salesperson/Helper/Data.php
DELETED
@@ -1,380 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Helper_Data extends Mage_CatalogSearch_Helper_Data
|
11 |
-
{
|
12 |
-
const QUERY_VAR_NAME = 'q';
|
13 |
-
const MAX_QUERY_LEN = 200;
|
14 |
-
const ICONV_CHARSET = 'UTF-8';
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Query object
|
18 |
-
*
|
19 |
-
* @var Mage_CatalogSearch_Model_Query
|
20 |
-
*/
|
21 |
-
protected $_query;
|
22 |
-
|
23 |
-
/**
|
24 |
-
* QwiserSearchApi object
|
25 |
-
*
|
26 |
-
* @var Mage_CatalogSearch_Model_Query
|
27 |
-
*/
|
28 |
-
protected $_api;
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Query string
|
32 |
-
*
|
33 |
-
* @var string
|
34 |
-
*/
|
35 |
-
protected $_queryText;
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Note messages
|
39 |
-
*
|
40 |
-
* @var array
|
41 |
-
*/
|
42 |
-
protected $_messages = array();
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Is a maximum length cut
|
46 |
-
*
|
47 |
-
* @var bool
|
48 |
-
*/
|
49 |
-
protected $_isMaxLength = false;
|
50 |
-
|
51 |
-
protected $_gmessages;
|
52 |
-
|
53 |
-
protected $_bannerImage;
|
54 |
-
protected $_customMessage;
|
55 |
-
protected $_relatedSearches;
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Retrieve salesperson session
|
59 |
-
*
|
60 |
-
* @return Mage_Catalog_Model_Session
|
61 |
-
*/
|
62 |
-
protected function _getSession()
|
63 |
-
{
|
64 |
-
return Mage::getSingleton('salesperson/session');
|
65 |
-
}
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Retrieve search query parameter name
|
69 |
-
*
|
70 |
-
* @return string
|
71 |
-
*/
|
72 |
-
public function getQueryParamName()
|
73 |
-
{
|
74 |
-
return self::QUERY_VAR_NAME;
|
75 |
-
}
|
76 |
-
|
77 |
-
public function getSalespersonApi()
|
78 |
-
{
|
79 |
-
if (!$this->_api) {
|
80 |
-
$this->_api = Mage::getModel('salesperson/salespersonSearchApi');
|
81 |
-
}
|
82 |
-
return $this->_api;
|
83 |
-
}
|
84 |
-
|
85 |
-
public function getSalespersonAnlxApi()
|
86 |
-
{
|
87 |
-
return Mage::getModel('salesperson/salespersonAnalyticsApi');
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
*
|
92 |
-
* Clean non UTF-8 characters
|
93 |
-
*
|
94 |
-
* @param string $string
|
95 |
-
* @return string
|
96 |
-
* @author Sveta Oksen copied from Magento v1.5
|
97 |
-
* @since 31/03/2011
|
98 |
-
*/
|
99 |
-
public function cleanString($string)
|
100 |
-
{
|
101 |
-
return '"libiconv"' == ICONV_IMPL ? iconv(self::ICONV_CHARSET, self::ICONV_CHARSET . '//IGNORE', $string) : $string;
|
102 |
-
}
|
103 |
-
|
104 |
-
public function getQueryText()
|
105 |
-
{
|
106 |
-
if (is_null($this->_queryText)) {
|
107 |
-
$this->_queryText = $this->_getRequest()->getParam($this->getQueryParamName());
|
108 |
-
if ($this->_queryText === null) {
|
109 |
-
$this->_queryText = '';
|
110 |
-
} else {
|
111 |
-
if (is_array($this->_queryText)) {
|
112 |
-
$this->_queryText = null;
|
113 |
-
}
|
114 |
-
$this->_queryText = trim($this->_queryText);
|
115 |
-
$this->_queryText = $this->cleanString($this->_queryText);
|
116 |
-
|
117 |
-
if (Mage::helper('core/string')->strlen($this->_queryText) > $this->getMaxQueryLength()) {
|
118 |
-
$this->_queryText = Mage::helper('core/string')->substr(
|
119 |
-
$this->_queryText,
|
120 |
-
0,
|
121 |
-
$this->getMaxQueryLength()
|
122 |
-
);
|
123 |
-
$this->_isMaxLength = true;
|
124 |
-
}
|
125 |
-
}
|
126 |
-
}
|
127 |
-
return $this->_queryText;
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Retrieve HTML escaped search query
|
132 |
-
*
|
133 |
-
* @return string
|
134 |
-
*/
|
135 |
-
public function getEscapedQueryText()
|
136 |
-
{
|
137 |
-
return $this->htmlEscape($this->getQueryText());
|
138 |
-
}
|
139 |
-
|
140 |
-
public function getDefaultPageSize(){
|
141 |
-
if (substr(Mage::getStoreConfig('catalog/frontend/list_mode'),0,4) == 'grid'){
|
142 |
-
return Mage::getStoreConfig('catalog/frontend/grid_per_page');
|
143 |
-
}
|
144 |
-
else {
|
145 |
-
return Mage::getStoreConfig('catalog/frontend/list_per_page');
|
146 |
-
}
|
147 |
-
}
|
148 |
-
|
149 |
-
public function getDefaultSortByField(){
|
150 |
-
return Mage::getStoreConfig('catalog/frontend/default_sort_by');
|
151 |
-
}
|
152 |
-
|
153 |
-
public function getStoreSearchProfile(){
|
154 |
-
return Mage::getStoreConfig('salesperson/display_settings/search_profile');
|
155 |
-
}
|
156 |
-
|
157 |
-
/**
|
158 |
-
* Is a minimum query length
|
159 |
-
*
|
160 |
-
* @return bool
|
161 |
-
*/
|
162 |
-
public function isMinQueryLength()
|
163 |
-
{
|
164 |
-
if (Mage::helper('core/string')->strlen($this->getQueryText()) < $this->getMinQueryLength()) {
|
165 |
-
return true;
|
166 |
-
}
|
167 |
-
return false;
|
168 |
-
}
|
169 |
-
|
170 |
-
/**
|
171 |
-
* Retrieve minimum query length
|
172 |
-
*
|
173 |
-
* @param mixed $store
|
174 |
-
* @return int
|
175 |
-
*/
|
176 |
-
public function getMinQueryLength($store = null)
|
177 |
-
{
|
178 |
-
return Mage::getStoreConfig(Mage_CatalogSearch_Model_Query::XML_PATH_MIN_QUERY_LENGTH, $store);
|
179 |
-
}
|
180 |
-
|
181 |
-
/**
|
182 |
-
* Retrieve result page url and set "secure" param to avoid confirm
|
183 |
-
* message when we submit form from secure page to unsecure
|
184 |
-
*
|
185 |
-
* @param string $query
|
186 |
-
* @return string
|
187 |
-
*/
|
188 |
-
public function getResultUrl($query = null)
|
189 |
-
{
|
190 |
-
return $this->_getUrl('salesperson/result', array(
|
191 |
-
'_query' => array(self::QUERY_VAR_NAME => $query),
|
192 |
-
'_secure' => Mage::app()->getFrontController()->getRequest()->isSecure()
|
193 |
-
));
|
194 |
-
}
|
195 |
-
|
196 |
-
/**
|
197 |
-
* Prepare save query for result
|
198 |
-
*
|
199 |
-
* @return Mage_CatalogSearch_Model_Query
|
200 |
-
*/
|
201 |
-
public function prepare(Mage_CatalogSearch_Model_Query $query, $num_result)
|
202 |
-
{
|
203 |
-
if (!$query->getId()) {
|
204 |
-
$query->setIsActive(0);
|
205 |
-
$query->setIsProcessed(0);
|
206 |
-
$query->setNumResults($num_result);
|
207 |
-
$query->save();
|
208 |
-
$query->setIsActive(1);
|
209 |
-
}
|
210 |
-
|
211 |
-
return $this;
|
212 |
-
}
|
213 |
-
|
214 |
-
/**
|
215 |
-
* Retrieve suggest url
|
216 |
-
*
|
217 |
-
* @return string
|
218 |
-
*/
|
219 |
-
public function getSuggestUrl()
|
220 |
-
{
|
221 |
-
return $this->_getUrl('catalogsearch/ajax/suggest');
|
222 |
-
}
|
223 |
-
|
224 |
-
/**
|
225 |
-
* Retrieve search term url
|
226 |
-
*
|
227 |
-
* @return string
|
228 |
-
*/
|
229 |
-
public function getSearchTermUrl()
|
230 |
-
{
|
231 |
-
return $this->_getUrl('catalogsearch/term/popular');
|
232 |
-
}
|
233 |
-
|
234 |
-
/**
|
235 |
-
* Retrieve advanced search URL
|
236 |
-
*
|
237 |
-
* @return string
|
238 |
-
*/
|
239 |
-
public function getAdvancedSearchUrl()
|
240 |
-
{
|
241 |
-
return $this->_getUrl('catalogsearch/advanced');
|
242 |
-
}
|
243 |
-
|
244 |
-
/**
|
245 |
-
* Retrieve maximum query words count for like search
|
246 |
-
*
|
247 |
-
* @param mixed $store
|
248 |
-
* @return int
|
249 |
-
*/
|
250 |
-
public function getMaxQueryWords($store = null)
|
251 |
-
{
|
252 |
-
return Mage::getStoreConfig(Mage_CatalogSearch_Model_Query::XML_PATH_MAX_QUERY_WORDS, $store);
|
253 |
-
}
|
254 |
-
|
255 |
-
/**
|
256 |
-
* Retrieve maximum query length
|
257 |
-
*
|
258 |
-
* @param mixed $store
|
259 |
-
* @return int
|
260 |
-
*/
|
261 |
-
public function getMaxQueryLength($store = null)
|
262 |
-
{
|
263 |
-
return Mage::getStoreConfig(Mage_CatalogSearch_Model_Query::XML_PATH_MAX_QUERY_LENGTH, $store);
|
264 |
-
}
|
265 |
-
|
266 |
-
/**
|
267 |
-
* Add Note message
|
268 |
-
*
|
269 |
-
* @param string $message
|
270 |
-
* @return Mage_CatalogSearch_Helper_Data
|
271 |
-
*/
|
272 |
-
public function addNoteMessage($message)
|
273 |
-
{
|
274 |
-
$this->_messages[] = $message;
|
275 |
-
return $this;
|
276 |
-
}
|
277 |
-
|
278 |
-
/**
|
279 |
-
* Set Note messages
|
280 |
-
*
|
281 |
-
* @param array $messages
|
282 |
-
* @return Mage_CatalogSearch_Helper_Data
|
283 |
-
*/
|
284 |
-
public function setNoteMessages(array $messages)
|
285 |
-
{
|
286 |
-
$this->_messages = $messages;
|
287 |
-
return $this;
|
288 |
-
}
|
289 |
-
|
290 |
-
/**
|
291 |
-
* Get the recommended attribute from salesperson API and add it to NoteMessages
|
292 |
-
*
|
293 |
-
*/
|
294 |
-
public function getRecommendedMessages(){
|
295 |
-
if($this->getSalespersonApi()->results->GetRecommendedMessage() != ''){
|
296 |
-
$message = preg_replace('/#%/', '', $this->getSalespersonApi()->results->GetRecommendedMessage());
|
297 |
-
$message = preg_replace('/%#/', '', $message);
|
298 |
-
$this->addNoteMessage($this->__($message));
|
299 |
-
}
|
300 |
-
}
|
301 |
-
|
302 |
-
/**
|
303 |
-
* Retrieve Current Note messages
|
304 |
-
*
|
305 |
-
* @return array
|
306 |
-
*/
|
307 |
-
public function getNoteMessages()
|
308 |
-
{
|
309 |
-
return $this->_messages;
|
310 |
-
}
|
311 |
-
|
312 |
-
/**
|
313 |
-
* Check query of a warnings
|
314 |
-
*
|
315 |
-
* @param mixed $store
|
316 |
-
* @return Celebros_Salesperson_Helper_Data
|
317 |
-
*/
|
318 |
-
public function checkNotes($store = null)
|
319 |
-
{
|
320 |
-
if ($this->_isMaxLength) {
|
321 |
-
$this->addNoteMessage($this->__('Maximum Search query length is %s. Your query was cut.', $this->getMaxQueryLength()));
|
322 |
-
}
|
323 |
-
|
324 |
-
$stringHelper = Mage::helper('core/string');
|
325 |
-
/* @var $stringHelper Mage_Core_Helper_String */
|
326 |
-
|
327 |
-
}
|
328 |
-
|
329 |
-
|
330 |
-
public function getNonLeadQuestionsPosition(){
|
331 |
-
if (Mage::getStoreConfig('salesperson/display_settings/display_non_lead_top'))
|
332 |
-
return 'top';
|
333 |
-
elseif (Mage::getStoreConfig('salesperson/display_settings/display_non_lead_left'))
|
334 |
-
return 'left';
|
335 |
-
elseif (Mage::getStoreConfig('salesperson/display_settings/display_non_lead_right'))
|
336 |
-
return 'right';
|
337 |
-
}
|
338 |
-
public function goToProductOnOneResult(){
|
339 |
-
return Mage::getStoreConfigFlag('salesperson/display_settings/go_to_product_on_one_result');
|
340 |
-
}
|
341 |
-
|
342 |
-
public function getResultCount()
|
343 |
-
{
|
344 |
-
if($this->getSalespersonApi()->results){
|
345 |
-
return $this->getSalespersonApi()->results->GetRelevantProductsCount();
|
346 |
-
}
|
347 |
-
}
|
348 |
-
|
349 |
-
public function getNoteHelperMessages() {
|
350 |
-
return $this->_gmessages;
|
351 |
-
}
|
352 |
-
|
353 |
-
public function setNoteHelperMessages($messages) {
|
354 |
-
$this->_gmessages = $messages;
|
355 |
-
}
|
356 |
-
|
357 |
-
public function setRelatedSearches($relatedSearches){
|
358 |
-
return $this->_relatedSearches = $relatedSearches;
|
359 |
-
}
|
360 |
-
|
361 |
-
public function setBannerImage($img){
|
362 |
-
$this->_bannerImage = $img;
|
363 |
-
}
|
364 |
-
|
365 |
-
public function setCustomMessage($msg){
|
366 |
-
$this->_customMessage = $msg;
|
367 |
-
}
|
368 |
-
|
369 |
-
public function getBannerImage(){
|
370 |
-
return $this->_bannerImage != '' ? $this->_bannerImage : false;
|
371 |
-
}
|
372 |
-
|
373 |
-
public function getCustomMessage(){
|
374 |
-
return $this->_customMessage != '' ? $this->_customMessage : false;
|
375 |
-
}
|
376 |
-
|
377 |
-
public function getRelatedSearches(){
|
378 |
-
return $this->_relatedSearches;
|
379 |
-
}
|
380 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Celebros/Salesperson/Model/Api/Anlx/AnalyticsFunctions.php
DELETED
@@ -1,355 +0,0 @@
|
|
1 |
-
<? //@-; This file was released in build:QANLX V1.6.0049 Date: 9/20/2006 6:32:27 PM @@@
|
2 |
-
include("LogRequest.php");
|
3 |
-
|
4 |
-
//define("G_DATA_COLLECTOR_ADDRESS","");
|
5 |
-
//define("G_CUSTOMER_ID","");
|
6 |
-
//define("G_CUSTOMER_NAME","");
|
7 |
-
//define("G_PUBLIC_KEY","");
|
8 |
-
|
9 |
-
class Celebros_Salesperson_Model_Api_Anlx_AnalyticsFunctions
|
10 |
-
{
|
11 |
-
var $DATA_COLLECTOR_ADDRESS;
|
12 |
-
var $CUSTOMER_ID;
|
13 |
-
var $CUSTOMER_NAME;
|
14 |
-
var $PUBLIC_KEY;
|
15 |
-
|
16 |
-
// validate result
|
17 |
-
var $ValidateResult;
|
18 |
-
|
19 |
-
// Anlx object
|
20 |
-
var $AnlxApi;
|
21 |
-
|
22 |
-
function Celebros_Salesperson_Model_Api_Anlx_AnalyticsFunctions($arguments)
|
23 |
-
{
|
24 |
-
$this->DATA_COLLECTOR_ADDRESS=$arguments["G_DATA_COLLECTOR_ADDRESS"];
|
25 |
-
$this->CUSTOMER_ID=$arguments["G_CUSTOMER_ID"];
|
26 |
-
$this->CUSTOMER_NAME=$arguments["G_CUSTOMER_NAME"];
|
27 |
-
$this->PUBLIC_KEY=$arguments["G_PUBLIC_KEY"];
|
28 |
-
|
29 |
-
//$this->AnlxApi = $this->GetAnlxObject($bIsSSL);
|
30 |
-
}
|
31 |
-
|
32 |
-
function GetAnlxObject( $IsSSL )
|
33 |
-
{
|
34 |
-
$AnlxApi = new LogRequest();
|
35 |
-
|
36 |
-
if ($IsSSL)
|
37 |
-
$AnlxApi->Mode="secured";
|
38 |
-
else
|
39 |
-
$AnlxApi->Mode="plainData";
|
40 |
-
|
41 |
-
$this->ValidateResult = new sValidateResult();
|
42 |
-
|
43 |
-
$AnlxApi->DataCollectorIP=$this->DATA_COLLECTOR_ADDRESS;
|
44 |
-
$AnlxApi->CustomerID=$this->CUSTOMER_ID;
|
45 |
-
$AnlxApi->CustomerName=$this->CUSTOMER_NAME;
|
46 |
-
$AnlxApi->PublicKeyToken=$this->PUBLIC_KEY;
|
47 |
-
|
48 |
-
return $AnlxApi;
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Call this function from any page on the site to have Qwiser Analytics log information about visits to this page.
|
53 |
-
* @param sUserID A unique ID for the user. It could be any type of ID such as the Web Server ID, session ID, etc.
|
54 |
-
* @param sGroupID The ID of the testing group to which this user belongs to, as defined in the Qwiser Analytics system. If you do not know what to pass here, you may pass an empty ("") String.
|
55 |
-
* @param sWebSessionID The ID of the current web server's session ID.
|
56 |
-
* @param sReferrer The URL of the page which led the user to this page (the referrer). The URL should not contain any parameters.
|
57 |
-
* @param bIsSSL Set to true if the calling page is on a Secure Socket Layer (SSL)
|
58 |
-
**/
|
59 |
-
|
60 |
-
function Celebros_Analytics_Visit($sUserID,$sGroupID,$sWebSessionID,$sReferrer,$bIsSSL)
|
61 |
-
{
|
62 |
-
$AnlxApi = $this->GetAnlxObject($bIsSSL);
|
63 |
-
|
64 |
-
if ($sGroupID==null || trim($sGroupID)=="")
|
65 |
-
$sGroupID = "1";
|
66 |
-
|
67 |
-
$AnlxApi->sGroupID=$sGroupID;
|
68 |
-
$AnlxApi->sUserID=$sUserID;
|
69 |
-
$AnlxApi->sWebSessionID=$sWebSessionID;
|
70 |
-
|
71 |
-
// visit info
|
72 |
-
$AnlxApi->sPreviousPageURL=$sReferrer;
|
73 |
-
|
74 |
-
$sLogRequest = $AnlxApi->GetLogRequest("LogVisitInfo");
|
75 |
-
$this->ValidateResult = $AnlxApi->GetValidateResult();
|
76 |
-
|
77 |
-
return $sLogRequest;
|
78 |
-
}
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Call this function from a Qwiser search results page to have Qwiser Analytics collect user search behavior information.
|
82 |
-
* <b>This function is not intended for use with a search results page that does not use Qwiser.</b>
|
83 |
-
* @param sSearchHandle The SearchHandle String of the current search state.
|
84 |
-
* @param sLogHandle The Qwiser LogHandle String (additional information for Qwiser Analytics) generated by Qwiser for the current state of the search results.
|
85 |
-
* @param sUserID A unique ID for the user. It could be any type of ID such as the Web Server ID, session ID, etc.
|
86 |
-
* @param sGroupID The ID of the testing group which this user belongs to, as defined in the Qwiser Analytics system. If you do not know what to pass here, you may pass an empty ("") String.
|
87 |
-
* @param sWebSessionID The ID of the current web server's session ID.
|
88 |
-
* @param sReferrer The URL of the page from which the user got to this page (the referrer). The URL should not contain any parameters.
|
89 |
-
* @param bIsSSL Set to true if the calling page is on a Secure Socket Layer (SSL)
|
90 |
-
* @param bFromQwiser Set to true if Qwiser Search is used
|
91 |
-
* **/
|
92 |
-
|
93 |
-
function Celebros_Analytics_SearchResults($sSearchSession,$sLogHandle,$sUserID,$sGroupID,$sWebSessionID,$sReferrer, $bIsSSL, $bFromQwiser)
|
94 |
-
{
|
95 |
-
/*echo "<br>P:<br>";
|
96 |
-
var_dump($sSearchSession);
|
97 |
-
echo "<br>P:<br>";
|
98 |
-
var_dump($sLogHandle);
|
99 |
-
echo "<br>P:<br>";
|
100 |
-
var_dump($sUserID);
|
101 |
-
echo "<br>P:<br>";
|
102 |
-
var_dump($sGroupID);
|
103 |
-
echo "<br>P:<br>";
|
104 |
-
var_dump($sWebSessionID);
|
105 |
-
echo "<br>P:<br>";
|
106 |
-
var_dump($sReferrer);
|
107 |
-
echo "<br>P:<br>";
|
108 |
-
var_dump($bIsSSL);
|
109 |
-
echo "<br>P:<br>";
|
110 |
-
var_dump($bFromQwiser);
|
111 |
-
exit();*/
|
112 |
-
|
113 |
-
$AnlxApi = $this->GetAnlxObject($bIsSSL);
|
114 |
-
|
115 |
-
$AnlxApi->SID=$sSearchSession;
|
116 |
-
$AnlxApi->LH=$sLogHandle;
|
117 |
-
$AnlxApi->FromQwiser=$bFromQwiser;
|
118 |
-
|
119 |
-
|
120 |
-
if ($sGroupID==null || trim($sGroupID)=="")
|
121 |
-
$sGroupID = "1";
|
122 |
-
|
123 |
-
$AnlxApi->sGroupID=$sGroupID;
|
124 |
-
$AnlxApi->sUserID=$sUserID;
|
125 |
-
$AnlxApi->sWebSessionID=$sWebSessionID;
|
126 |
-
$AnlxApi->sPreviousPageURL=$sReferrer;
|
127 |
-
|
128 |
-
$sLogRequest = $AnlxApi->GetLogRequest("LogSearchResult");
|
129 |
-
$this->ValidateResult = $AnlxApi->ValidateResult;
|
130 |
-
|
131 |
-
return $sLogRequest;
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
* Call this function from any search results page to have Qwiser Analytics collect user search behavior information.
|
136 |
-
* <b>This function intend for use with a search results page that does not use Qwiser.</b>
|
137 |
-
* @param sSessionID A unique string to identify the current search state.
|
138 |
-
* @param sQuery The query string that the user used for his search.
|
139 |
-
* @param bFromBrowse Is the search is coming from a browser or not.
|
140 |
-
* @param sUserID A unique ID for the user. It could be any type of ID such as the Web Server ID, session ID, etc.
|
141 |
-
* @param sGroupID The ID of the testing group which this user belongs to, as defined in the Qwiser Analytics system. If you do not know what to pass here, you may pass an empty ("") String.
|
142 |
-
* @param sWebSessionID The ID of the current web server's session ID.
|
143 |
-
* @param sReferrer The URL of the page from which the user got to this page (the referrer). The URL should not contain any parameters.
|
144 |
-
* @param bIsSSL Set to true if the calling page is on a Secure Socket Layer (SSL)
|
145 |
-
* **/
|
146 |
-
|
147 |
-
function Celebros_Analytics_GenericSearchResults($sSessionID,$sQuery,$bFromBrowse,$sUserID,$sGroupID,$sWebSessionID,$sReferrer, $bIsSSL)
|
148 |
-
{
|
149 |
-
$AnlxApi = $this->GetAnlxObject($bIsSSL);
|
150 |
-
|
151 |
-
$this->AnlxApi->strSearchSessionID = $sSessionID;
|
152 |
-
$this->AnlxApi->strQuery = $sQuery;
|
153 |
-
$this->AnlxApi->bFromBrowse = $bFromBrowse;
|
154 |
-
|
155 |
-
if ($sGroupID==null || trim($sGroupID)=="")
|
156 |
-
$sGroupID = "1";
|
157 |
-
|
158 |
-
$this->AnlxApi->sGroupID=$sGroupID;
|
159 |
-
$this->AnlxApi->sUserID=$sUserID;
|
160 |
-
$this->AnlxApi->sWebSessionID=$sWebSessionID;
|
161 |
-
$this->AnlxApi->sPreviousPageURL=$sReferrer;
|
162 |
-
|
163 |
-
$sLogRequest = $this->AnlxApi->GetLogRequest("LogGenericSearchResult");
|
164 |
-
$this->ValidateResult = $this->AnlxApi->ValidateResult;
|
165 |
-
|
166 |
-
return $sLogRequest;
|
167 |
-
|
168 |
-
}
|
169 |
-
|
170 |
-
|
171 |
-
/**
|
172 |
-
* Call this function from a product details page to have Qwiser Analytics collect information about traffic in the product details page.
|
173 |
-
* @param sSKU The SKU or product code of the current product being displayed.
|
174 |
-
* @param sVariant Any String definition that would distinguish this product from other products in a certain product group. e.g. "Blue" or "GS23" (a child SKU). The combination of the sSKU parameter and this one should be unique for every product variant. If this information is not available or not applicable, you may pass an empty ("") String.
|
175 |
-
* @param sName The name or title of the product being displayed.
|
176 |
-
* @param fPrice The price of the product being displayed.
|
177 |
-
* @param sCategory The category to which this product belongs, if available. If not, you may pass an empty ("") String.
|
178 |
-
* @param sSearchSession The SearchHandle String of the current search state, if available. If not, you may pass an empty ("") String.
|
179 |
-
* @param sUserID A unique ID for the user. It could be any type of ID such as the Web Server ID, session ID, etc.
|
180 |
-
* @param sGroupID The ID of the testing group to which this user belongs to, as defined in the Qwiser Analytics system. If you do not know what to pass here, you may pass an empty ("") String.
|
181 |
-
* @param sWebSessionID The ID of the current web server's session ID.
|
182 |
-
* @param sReferrer The URL of the page which led the user to this page (the referrer). The URL should not contain any parameters.
|
183 |
-
* @param iSourceType The type of location that linked to this page:<ul><li><b>Value -> </b><b>Description</b></li><li>0 -> Qwiser Search</li><li>1 -> Banner/Ad on web page</li><li>2 -> Browse (the shopper did not use the search)</li><li>3 -> E-Mail promotion</li><li>4 -> Direct Mailing (Hard copy catalog, etc.)</li><li>5 -> Print (Newspapers, periodicals, in-flight magazines, etc.)</li><li>6 -> Television</li><li>100 -> Other sources</li></ul>
|
184 |
-
* @param sSourceName If the source type is "Other", provide a name for this source to distinguish between custom sources. Otherwise, you may pass an empty ("") String.
|
185 |
-
* @param bIsSSL Set to true if the calling page is on a Secure Socket Layer (SSL)
|
186 |
-
* **/
|
187 |
-
|
188 |
-
function Celebros_Analytics_ProductDetails($sSKU,$sVariant,$sName,$fPrice,$sCategory,$sSearchSession,$sUserID,$sGroupID,$sWebSessionID,$sReferrer,$iSourceType,$sSourceTypeName, $bIsSSL)
|
189 |
-
{
|
190 |
-
$AnlxApi = $this->GetAnlxObject($bIsSSL);
|
191 |
-
|
192 |
-
if ($sGroupID==null || trim($sGroupID)=="")
|
193 |
-
$sGroupID = "1";
|
194 |
-
|
195 |
-
$AnlxApi->sGroupID=$sGroupID;
|
196 |
-
$AnlxApi->sUserID=$sUserID;
|
197 |
-
$AnlxApi->sWebSessionID=$sWebSessionID;
|
198 |
-
|
199 |
-
if($iSourceType==0)
|
200 |
-
$AnlxApi->bUsingQwiserSearch=true;
|
201 |
-
else
|
202 |
-
$AnlxApi->bUsingQwiserSearch=false;
|
203 |
-
|
204 |
-
$AnlxApi->SID=$sSearchSession;
|
205 |
-
|
206 |
-
// visit info
|
207 |
-
$AnlxApi->sPreviousPageURL=$sReferrer;
|
208 |
-
$AnlxApi->iSourceType=$iSourceType;
|
209 |
-
$AnlxApi->sSourceTypeName=$sSourceTypeName;
|
210 |
-
|
211 |
-
//product info
|
212 |
-
$AnlxApi->sProductSKU=$sSKU;
|
213 |
-
$AnlxApi->sProductVariant=$sVariant;
|
214 |
-
$AnlxApi->sProductName=$sName;
|
215 |
-
$AnlxApi->fProductPrice=$fPrice;
|
216 |
-
$AnlxApi->sProductCategory=$sCategory;
|
217 |
-
|
218 |
-
$sLogRequest = $AnlxApi->GetLogRequest("LogProductDetails");
|
219 |
-
$this->ValidateResult = $AnlxApi->ValidateResult;
|
220 |
-
|
221 |
-
return $sLogRequest;
|
222 |
-
}
|
223 |
-
/**
|
224 |
-
* Call this function from the Add-To-Cart page to have Qwiser Analytics collect information about user activity with their shopping cart.
|
225 |
-
* This function is not intended for use when editing items in the cart or removing items from the cart.
|
226 |
-
* When the user purchases the items in the cart, those cart changes will be picked up.
|
227 |
-
* @param sSKU The SKU or product code of the current product being added.
|
228 |
-
* @param sVariant Any String definition that would distinguish this product from other products in a certain product group. e.g. "Blue" or "GS23" (a child SKU). The combination of the sSKU parameter and this one should be unique for every product variant. If this information is not available or not applicable, you may pass an empty ("") String.
|
229 |
-
* @param sName The name or title of the product being added.
|
230 |
-
* @param iQuantity The number of individual units of this specific product that are added to the cart.
|
231 |
-
* @param fPrice The price of the product being displayed.
|
232 |
-
* @param sCategory The category to which this product belongs, if available. If not, you may pass an empty ("") String.
|
233 |
-
* @param sCartID The ID of the user's cart, as defined in your cart management system, or another ID that can uniquely identify the specific cart.
|
234 |
-
* @param iCartProductCount The number of products in the cart after the new addition.
|
235 |
-
* @param fCartSubTotal The Subtotal price of all the items in the cart after the new addition.
|
236 |
-
* @param sCartCoupon A String representing a coupon used in this cart (which applies to the entire cart), if any. If no coupon was used, you may pass an empty ("") String.
|
237 |
-
* @param fCartDiscount The discount factor for this cart. e.g. If the entire cart is discounted by 25%, use 0.25. If there is no discount, use 0.
|
238 |
-
* @param sSearchSession The SearchHandle String of the current search state.
|
239 |
-
* @param sUserID A unique ID for the user. It could be any type of ID such as the Web Server ID, session ID, etc.
|
240 |
-
* @param sGroupID The ID of the testing group to which this user belongs to, as defined in the Qwiser Analytics system. If you do not know what to pass here, you may pass an empty ("") String.
|
241 |
-
* @param sWebSessionID The ID of the current web server's session ID.
|
242 |
-
* @param sReferrer The URL of the page which led the user to this page (the referrer). The URL should not contain any parameters.
|
243 |
-
* @param bIsSSL Set to true if your Add-To-Cart page is on a Secure Socket Layer (SSL).
|
244 |
-
**/
|
245 |
-
|
246 |
-
function Celebros_Analytics_AddToCart($sSKU,$sVariant,$sName,$iQuantity,$fPrice,$sCategory,$sCartID,$iCartProductCount,$fCartSubTotal, $sCartCoupon,$fCartDiscount,$sSearchSession,$sUserID,$sGroupID,$sWebSessionID,$sReferrer,$bIsSSL)
|
247 |
-
{
|
248 |
-
$AnlxApi = $this->GetAnlxObject($bIsSSL);
|
249 |
-
|
250 |
-
if ($sGroupID==null || trim($sGroupID)=="")
|
251 |
-
$sGroupID = "1";
|
252 |
-
|
253 |
-
$AnlxApi->sGroupID=$sGroupID;
|
254 |
-
$AnlxApi->sUserID=$sUserID;
|
255 |
-
$AnlxApi->sWebSessionID=$sWebSessionID;
|
256 |
-
|
257 |
-
//search handle
|
258 |
-
if(!($sSearchSession=="" || $sSearchSession==null))
|
259 |
-
{
|
260 |
-
$AnlxApi->SID=$sSearchSession;
|
261 |
-
$AnlxApi->bUsingQwiserSearch=true;
|
262 |
-
}
|
263 |
-
else
|
264 |
-
{
|
265 |
-
$AnlxApi->bUsingQwiserSearch=false;
|
266 |
-
$AnlxApi->SID=$sWebSessionID;
|
267 |
-
}
|
268 |
-
|
269 |
-
// visit info
|
270 |
-
$AnlxApi->sPreviousPageURL=$sReferrer;
|
271 |
-
|
272 |
-
//'cart info
|
273 |
-
$AnlxApi->sCartID=$sCartID;
|
274 |
-
$AnlxApi->sCartCoupon=$sCartCoupon;
|
275 |
-
$AnlxApi->fCartDiscount=$fCartDiscount;
|
276 |
-
$AnlxApi->iCartProductCount=$iCartProductCount;
|
277 |
-
$AnlxApi->fCartSubTotal=$fCartSubTotal;
|
278 |
-
|
279 |
-
//product info
|
280 |
-
$AnlxApi->sProductSKU=$sSKU;
|
281 |
-
$AnlxApi->sProductVariant=$sVariant;
|
282 |
-
$AnlxApi->sProductName=$sName;
|
283 |
-
$AnlxApi->fProductPrice=$fPrice;
|
284 |
-
$AnlxApi->sProductCategory=$sCategory;
|
285 |
-
$AnlxApi->iProductQuantity=$iQuantity;
|
286 |
-
|
287 |
-
$sLogRequest = $AnlxApi->GetLogRequest("LogAddToCart");
|
288 |
-
$this->ValidateResult = $AnlxApi->ValidateResult;
|
289 |
-
|
290 |
-
return $sLogRequest;
|
291 |
-
}
|
292 |
-
|
293 |
-
/**
|
294 |
-
* Call this function from the Checkout page to have Qwiser Analytics collect purchase activity information.
|
295 |
-
* @param ProductsArray A 2-dimensional array containing information about all products being purchased. Each element in the first dimension represents a product. Elements in the second dimension contain product information as follows:<br><br><table border=1><tr><td><b>Index</b></td><td><b>Description</b></td></tr><tr><td>0</td><td>sSKU: The SKU or product code of the current product being purchased.</td></tr><tr><td>1</td><td>sVariant: Any string definition that would distinguish this product from other products in a certain products group. e.g. "Blue" or "GS23" (a child SKU). The combination of the sSKU parameter and this one should be unique for every product variant. If this information is not available or not applicable, you may pass an empty ("") string.</td></tr><tr><td>2</td><td>fPrice: The price of the product being purchased.</td></tr><tr><td>3</td><td>iQuantity: The number of units of this specific product being purchased.</td></tr><tr><td>4</td><td>fProductDiscount: The discount factor applied to this specific product ot the entire cart), e.g. If there is a 25% discount on this product, use 0.25. If there is no discount, use 0.</td></tr><tr><td>5</td><td>sProductCoupon: A String representing a coupon used to purchase this product (i.e. A coupon that applies to this specific product, as opposed to one applied to the entire cart), if any. (optional)</td></tr></table><hr>
|
296 |
-
* @param sCartID The ID of the user's cart, as defined in your cart management system, or another ID that can uniquely identify the specific cart.
|
297 |
-
* @param iCartProductCount The number of products in the cart.
|
298 |
-
* @param fCartTotal The total price of all items in the cart being purchased.
|
299 |
-
* @param sCartCoupon A String representing a coupon used in this cart (which applies to the entire cart), if any. If no coupon was used, you may pass an empty ("") String.
|
300 |
-
* @param fCartDiscount The discount factor for this cart. e.g. If the entire cart is discounted by 25%, use 0.25. If there is no discount, use 0.
|
301 |
-
* @param sUserID A unique ID for the user. It could be any type of ID such as the Web Server ID, session ID, etc.
|
302 |
-
* @param sGroupID The ID of the testing group to which this user belongs to, as defined in the Qwiser Analytics system. If you do not know what to pass here, you may pass an empty ("") String.
|
303 |
-
* @param sWebSessionID The ID of the current web server's session ID.
|
304 |
-
* @param sReferrer The URL of the page which led the user to this page (the referrer). The URL should not contain any parameters.
|
305 |
-
* @param bIsSSL Set to true if the calling page is on a Secure Socket Layer (SSL) .
|
306 |
-
**/
|
307 |
-
|
308 |
-
function Celebros_Analytics_CheckOut($sOrderID, $ProductsArray,$sCartID,$iCartProductCount,$fCartTotal,$sCartCoupon,$fCartDiscount,$sUserID,$sGroupID,$sWebSessionID,$sReferrer,$bIsSSL)
|
309 |
-
{
|
310 |
-
$AnlxApi = $this->GetAnlxObject($bIsSSL);
|
311 |
-
if ($sGroupID==null || trim($sGroupID)=="")
|
312 |
-
$sGroupID = "1";
|
313 |
-
|
314 |
-
$AnlxApi->sGroupID=$sGroupID;
|
315 |
-
$AnlxApi->sUserID=$sUserID;
|
316 |
-
$AnlxApi->sWebSessionID=$sWebSessionID;
|
317 |
-
$AnlxApi->sPreviousPageURL =$sReferrer;
|
318 |
-
|
319 |
-
//products
|
320 |
-
$AnlxApi->ProductsArray=$ProductsArray;
|
321 |
-
//'cart info
|
322 |
-
$AnlxApi->sCartID=$sCartID;
|
323 |
-
$AnlxApi->sCartCoupon=$sCartCoupon;
|
324 |
-
$AnlxApi->fCartDiscount=$fCartDiscount;
|
325 |
-
$AnlxApi->iCartProductCount=$iCartProductCount;
|
326 |
-
$AnlxApi->fCartSubTotal=$fCartTotal;
|
327 |
-
|
328 |
-
// order info
|
329 |
-
$AnlxApi->sOrderID=$sOrderID;
|
330 |
-
|
331 |
-
$sLogRequest = $AnlxApi->GetLogRequest("LogCheckOut");
|
332 |
-
$this->ValidateResult = $AnlxApi->ValidateResult;
|
333 |
-
|
334 |
-
return $sLogRequest;
|
335 |
-
}
|
336 |
-
|
337 |
-
/*function AddCustomProperty($Name, $Value)
|
338 |
-
{
|
339 |
-
$this->AnlxApi = $this->GetAnlxObject($bIsSSL);
|
340 |
-
$this->AnlxApi->AddCustomProperty($Name, $Value);
|
341 |
-
}*/
|
342 |
-
|
343 |
-
function GetLastErrorMessage()
|
344 |
-
{
|
345 |
-
return $this->ValidateResult->strMessage;
|
346 |
-
}
|
347 |
-
|
348 |
-
function GetLastErrorSeverity()
|
349 |
-
{
|
350 |
-
return $this->ValidateResult->iSeverity;
|
351 |
-
}
|
352 |
-
}
|
353 |
-
|
354 |
-
?>
|
355 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Celebros/Salesperson/Model/Api/Anlx/DataStructure.php
DELETED
@@ -1,58 +0,0 @@
|
|
1 |
-
<? //@-; This file was released in build:QANLX V1.6.0049 Date: 9/20/2006 6:32:27 PM @@@
|
2 |
-
/*function GetValidateMessageID($messageID)
|
3 |
-
{
|
4 |
-
switch ($messageID)
|
5 |
-
{
|
6 |
-
CASE "NoError":
|
7 |
-
return "0";
|
8 |
-
CASE "evrErrSearchHandleIsMissing":
|
9 |
-
return "1";
|
10 |
-
CASE "evrErrSearchSessionIDIsMissing":
|
11 |
-
return "2";
|
12 |
-
CASE "evrErrSearchSessionIsMissing":
|
13 |
-
return "3";
|
14 |
-
CASE "evrErrSKUIsMissing":
|
15 |
-
return "4";
|
16 |
-
CASE "evrErrCartIDIsMissing":
|
17 |
-
return "5";
|
18 |
-
CASE "evrErrServerNameIsMissing":
|
19 |
-
return "6";
|
20 |
-
CASE "evrErrCustomerIDIsMissing":
|
21 |
-
return "7";
|
22 |
-
CASE "evrWrnCustomerNameISMissing":
|
23 |
-
return "8";
|
24 |
-
CASE "evrWrnConflictInDCParam":
|
25 |
-
return "9";
|
26 |
-
CASE "evrErrOrderIDIsMissing":
|
27 |
-
return "10";
|
28 |
-
CASE "evrErrLogHandleIsMissing":
|
29 |
-
return "11";
|
30 |
-
|
31 |
-
default:
|
32 |
-
return "0";
|
33 |
-
}
|
34 |
-
|
35 |
-
}*/
|
36 |
-
|
37 |
-
/*function GetSeverity($Severity)
|
38 |
-
{
|
39 |
-
switch ($Severity)
|
40 |
-
{
|
41 |
-
case "RequestOK":
|
42 |
-
return "0";
|
43 |
-
case "Warning":
|
44 |
-
return "1";
|
45 |
-
case "Error":
|
46 |
-
return "2";
|
47 |
-
|
48 |
-
}
|
49 |
-
}*/
|
50 |
-
|
51 |
-
class sValidateResult
|
52 |
-
{
|
53 |
-
var $iSeverity;
|
54 |
-
var $strMessage;
|
55 |
-
}
|
56 |
-
|
57 |
-
|
58 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Celebros/Salesperson/Model/Api/Anlx/DynamicProperty.php
DELETED
@@ -1,179 +0,0 @@
|
|
1 |
-
<? //@-; This file was released in build:QANLX V1.6.0049 Date: 9/20/2006 6:32:27 PM @@@
|
2 |
-
|
3 |
-
define('DEFAULT_DELIMITER',"&");
|
4 |
-
|
5 |
-
class DynamicProperty
|
6 |
-
{
|
7 |
-
|
8 |
-
var $m_properties;
|
9 |
-
//private Hashtable m_properties = new Hashtable();
|
10 |
-
|
11 |
-
// constructors
|
12 |
-
function DynamicProperty()
|
13 |
-
{
|
14 |
-
$m_properties = array();
|
15 |
-
}
|
16 |
-
|
17 |
-
|
18 |
-
function SetDPWithProp($strProp)//:this(strProp,DEFAULT_DELIMITER)
|
19 |
-
{
|
20 |
-
$this->SetDPWIthDelimiter($strProp, DEFAULT_DELIMITER);
|
21 |
-
}
|
22 |
-
|
23 |
-
|
24 |
-
function SetDPWIthDelimiter($strProp,$strDelimit)
|
25 |
-
{
|
26 |
-
$Prop = $strProp;
|
27 |
-
//m_properties.Clear();
|
28 |
-
$m_properties = array();
|
29 |
-
|
30 |
-
//if (Prop.StartsWith(strDelimit))
|
31 |
-
if (strchr($Prop, $strDelimit) == 0 )
|
32 |
-
{
|
33 |
-
$start = strlen($strDelimit);
|
34 |
-
$end = strlen($Prop);
|
35 |
-
$Prop = substr($Prop, $start, $end-$start);
|
36 |
-
}
|
37 |
-
|
38 |
-
$parts[] = split($strDelimit, $Prop);
|
39 |
-
|
40 |
-
foreach ($parts as $pairs)
|
41 |
-
{
|
42 |
-
$pair[] = split("=", $pairs, 2);
|
43 |
-
if ( count($pair) == 2 )
|
44 |
-
{
|
45 |
-
$this->m_properties[$pair[0]] = $pair[1];
|
46 |
-
}
|
47 |
-
}
|
48 |
-
}
|
49 |
-
|
50 |
-
/*function SetDynamicProperty(DynamicProperty dynamicProp)
|
51 |
-
{
|
52 |
-
Hashtable properties = dynamicProp.GetAllProperties();
|
53 |
-
|
54 |
-
m_properties.Clear();
|
55 |
-
// Enumerate properties and create report server specific string.
|
56 |
-
IDictionaryEnumerator customPropEnumerator = properties.GetEnumerator();
|
57 |
-
while ( customPropEnumerator.MoveNext() )
|
58 |
-
{
|
59 |
-
m_properties.Add(customPropEnumerator.Key,customPropEnumerator.Value);
|
60 |
-
}
|
61 |
-
}*/
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
/// <summary>
|
66 |
-
/// create string that hold all parameters delimit by delimit parameter
|
67 |
-
/// </summary>
|
68 |
-
/// <param name="strDelimit">string seperator between pairs.</param>
|
69 |
-
/// <returns>string with all parameters.</returns>
|
70 |
-
function BuildStringWithDel($strDelimit)
|
71 |
-
{
|
72 |
-
$strParameters = $this->EmumProperties($this->m_properties,$strDelimit);
|
73 |
-
return $strParameters;
|
74 |
-
}
|
75 |
-
|
76 |
-
#endregion
|
77 |
-
|
78 |
-
#region Methods
|
79 |
-
|
80 |
-
/// <summary>
|
81 |
-
/// Enumerate Hashtable and create report server access specific string.
|
82 |
-
/// </summary>
|
83 |
-
/// <param name="properties">hash table of all properties</param>
|
84 |
-
/// <param name="strDelimiter">string use to delimiter between pairs. (empty string will become ampersand)</param>
|
85 |
-
/// <returns></returns>
|
86 |
-
//function EmumProperties(Hashtable properties,$strDelimiter)
|
87 |
-
function EmumProperties($properties,$strDelimiter)
|
88 |
-
{
|
89 |
-
$paramsString = "";
|
90 |
-
if ($strDelimiter == "")
|
91 |
-
$strDelimiter = DEFAULT_DELIMITER;
|
92 |
-
|
93 |
-
// Enumerate properties and create report server specific string.
|
94 |
-
//IDictionaryEnumerator customPropEnumerator = properties.GetEnumerator();
|
95 |
-
//$customPropEnumerator = $properties.GetEnumerator();
|
96 |
-
|
97 |
-
/*while (list($key,$value) = each($goodfoodArray)) {
|
98 |
-
echo "$key : $value<br>";*/
|
99 |
-
|
100 |
-
if ($properties != null)
|
101 |
-
{
|
102 |
-
$key = array_keys($properties);
|
103 |
-
foreach ($key as $value)
|
104 |
-
{
|
105 |
-
$paramsString .= $strDelimiter
|
106 |
-
. $value . "=" . $properties[$value];
|
107 |
-
}
|
108 |
-
}
|
109 |
-
return $paramsString;
|
110 |
-
}
|
111 |
-
|
112 |
-
/// <summary>
|
113 |
-
/// get all the parameters
|
114 |
-
/// </summary>
|
115 |
-
/// <returns>Hashtable that hold all the parameters in the DP object</returns>
|
116 |
-
/*public Hashtable GetAllProperties()
|
117 |
-
{
|
118 |
-
return m_properties;
|
119 |
-
}*/
|
120 |
-
|
121 |
-
/// <summary>
|
122 |
-
/// Add or remove url access string properties.
|
123 |
-
/// </summary>
|
124 |
-
/// <param name="name"></param>
|
125 |
-
/// <param name="value"></param>
|
126 |
-
function SetProperty($name, $value)
|
127 |
-
{
|
128 |
-
//try
|
129 |
-
//{
|
130 |
-
// Remove if value is null or empty. Value is null of the property grid value
|
131 |
-
// is null or empty. Empty or null removes the property from the Hashtable.
|
132 |
-
if($value == null || $value == "" )
|
133 |
-
{
|
134 |
-
if ($name != null && $name != "")
|
135 |
-
{
|
136 |
-
$bFound = false;
|
137 |
-
in_array($name, $bFound);
|
138 |
-
if ($bFound)
|
139 |
-
$this->m_properties.Remove($name);
|
140 |
-
}
|
141 |
-
}
|
142 |
-
else
|
143 |
-
{
|
144 |
-
if ($this->m_properties != null)
|
145 |
-
{
|
146 |
-
if( array_key_exists($name, $this->m_properties) )
|
147 |
-
{
|
148 |
-
// Change if key exists
|
149 |
-
$this->m_properties[$name] = $value;
|
150 |
-
}
|
151 |
-
else
|
152 |
-
{
|
153 |
-
// Add if key does not exist
|
154 |
-
$this->m_properties[$name] = $value;
|
155 |
-
}
|
156 |
-
}
|
157 |
-
}
|
158 |
-
// Build a new string with all the parameters as pairs.
|
159 |
-
$this->BuildString();
|
160 |
-
/*
|
161 |
-
}
|
162 |
-
catch(Exception ex)
|
163 |
-
{
|
164 |
-
// throws the exception to the client
|
165 |
-
throw ex;
|
166 |
-
}*/
|
167 |
-
}
|
168 |
-
|
169 |
-
// create string that hold all parameters delimit by ampersand
|
170 |
-
function BuildString()
|
171 |
-
{
|
172 |
-
$strParameters = $this->EmumProperties($this->m_properties,"");
|
173 |
-
return $strParameters;
|
174 |
-
}
|
175 |
-
|
176 |
-
}
|
177 |
-
|
178 |
-
?>
|
179 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Celebros/Salesperson/Model/Api/Anlx/Holders.php
DELETED
@@ -1,225 +0,0 @@
|
|
1 |
-
<? //@-; This file was released in build:QANLX V1.6.0049 Date: 9/20/2006 6:32:27 PM @@@
|
2 |
-
class ReferrerInfoHolder
|
3 |
-
{
|
4 |
-
var $ReferrerUrl;
|
5 |
-
var $CampaignName;
|
6 |
-
var $CampaignType;
|
7 |
-
|
8 |
-
function ToString()
|
9 |
-
{
|
10 |
-
$strStream = "";
|
11 |
-
$sc;
|
12 |
-
|
13 |
-
if( trim($this->CampaignType=="") || $this->CampaignType==null)
|
14 |
-
$this->CampaignType=0;
|
15 |
-
|
16 |
-
$sc[]=$this->ReferrerUrl;
|
17 |
-
$sc[]=$this->CampaignName;
|
18 |
-
$sc[]=$this->CampaignType;
|
19 |
-
$sc[]=$this->SearchPhrase;
|
20 |
-
|
21 |
-
$strStream = GetStream($sc);
|
22 |
-
$strStream = UUEncode($strStream);
|
23 |
-
return $strStream;
|
24 |
-
}
|
25 |
-
}
|
26 |
-
|
27 |
-
class GenericSRHolder
|
28 |
-
{
|
29 |
-
var $SearchSession;
|
30 |
-
var $Query;
|
31 |
-
var $FromBrowse;
|
32 |
-
|
33 |
-
function ToString()
|
34 |
-
{
|
35 |
-
$strStream = "";
|
36 |
-
$sc;
|
37 |
-
|
38 |
-
$sc[]=$this->SearchSession;
|
39 |
-
$sc[]=$this->Query;
|
40 |
-
$sc[]=$this->FromBrowse;
|
41 |
-
|
42 |
-
$strStream = GetStream($sc);
|
43 |
-
$strStream = UUEncode($strStream);
|
44 |
-
return $strStream;
|
45 |
-
}
|
46 |
-
}
|
47 |
-
|
48 |
-
class SRAdditionalHolder
|
49 |
-
{
|
50 |
-
var $SpellingCorrectionDriven;
|
51 |
-
var $CorrectedFrom;
|
52 |
-
var $FromBrowse;
|
53 |
-
|
54 |
-
|
55 |
-
function ToString()
|
56 |
-
{
|
57 |
-
$strStream = "";
|
58 |
-
$sc;
|
59 |
-
|
60 |
-
$sc[]=$this->SpellingCorrectionDriven;
|
61 |
-
$sc[]=$this->CorrectedFrom;
|
62 |
-
$sc[]=$this->FromBrowse;
|
63 |
-
|
64 |
-
$strStream = GetStream($sc);
|
65 |
-
$strStream = UUEncode($strStream);
|
66 |
-
return $strStream;
|
67 |
-
}
|
68 |
-
}
|
69 |
-
|
70 |
-
class CartInfoHolder
|
71 |
-
{
|
72 |
-
var $CartID;
|
73 |
-
var $Coupon;
|
74 |
-
var $Discount;
|
75 |
-
var $ProductCount;
|
76 |
-
var $SubTotal;
|
77 |
-
|
78 |
-
function ToString()
|
79 |
-
{
|
80 |
-
$strStream = "";
|
81 |
-
$sc=array();
|
82 |
-
|
83 |
-
if($this->ProductCount==null || trim($this->ProductCount)=="")
|
84 |
-
$this->ProductCount=0;
|
85 |
-
if($this->Discount==null || trim($this->ProductCount==""))
|
86 |
-
$this->Discount=0;
|
87 |
-
if($this->SubTotal==null || trim($this->SubTotal==""))
|
88 |
-
$this->SubTotal=0;
|
89 |
-
|
90 |
-
$sc[]=$this->CartID;
|
91 |
-
$sc[]=$this->ProductCount;
|
92 |
-
$sc[]=$this->Coupon;
|
93 |
-
$sc[]=$this->Discount;
|
94 |
-
$sc[]=$this->SubTotal;
|
95 |
-
|
96 |
-
$strStream = GetStream($sc);
|
97 |
-
$strStream = UUEncode($strStream);
|
98 |
-
return $strStream;
|
99 |
-
}
|
100 |
-
}
|
101 |
-
|
102 |
-
class ProductDetailsHolder
|
103 |
-
{
|
104 |
-
var $ProductList;
|
105 |
-
|
106 |
-
function ToString()
|
107 |
-
{
|
108 |
-
$strStream = "";
|
109 |
-
$sc=array();
|
110 |
-
|
111 |
-
// add the number of products in array.
|
112 |
-
$sc[]=count($this->ProductList);
|
113 |
-
|
114 |
-
// add products
|
115 |
-
foreach ($this->ProductList as $p)
|
116 |
-
{
|
117 |
-
if($p["Price"]==null || trim($p["Price"])=="")
|
118 |
-
$p["Price"]=0;
|
119 |
-
if($p["Quantity"]==null || trim($p["Quantity"])=="")
|
120 |
-
$p["Quantity"]=0;
|
121 |
-
|
122 |
-
$scProduct[]=$p["SKU"];
|
123 |
-
$scProduct[]=$p["Variant"];
|
124 |
-
$scProduct[]=$p["Price"];
|
125 |
-
$scProduct[]=$p["Quantity"];
|
126 |
-
$scProduct[]=$p["Category"];
|
127 |
-
$scProduct[]=$p["Name"];
|
128 |
-
|
129 |
-
$sc[]=GetStream($scProduct);
|
130 |
-
}
|
131 |
-
|
132 |
-
$strStream = GetStream($sc);
|
133 |
-
$strStream = UUEncode($strStream);
|
134 |
-
//$strStream = UUEncode($sc);
|
135 |
-
return $strStream;
|
136 |
-
}
|
137 |
-
}
|
138 |
-
|
139 |
-
class ProductCOHolder
|
140 |
-
{
|
141 |
-
var $ProductList;
|
142 |
-
|
143 |
-
function ToString()
|
144 |
-
{
|
145 |
-
$strStream = "";
|
146 |
-
$sc=array();
|
147 |
-
|
148 |
-
// add the number of products in array.
|
149 |
-
$sc[]=count($this->ProductList);
|
150 |
-
if (count($this->ProductList)>0)
|
151 |
-
{
|
152 |
-
// add products
|
153 |
-
foreach ($this->ProductList as $p)
|
154 |
-
{
|
155 |
-
if($p["Price"]==null || trim($p["Price"])=="")
|
156 |
-
$p["Price"]=0;
|
157 |
-
if($p["Quantity"]==null || trim($p["Quantity"])=="")
|
158 |
-
$p["Quantity"]=0;
|
159 |
-
if($p["Discount"]==null || trim($p["Discount"])=="")
|
160 |
-
$p["Discount"]=0;
|
161 |
-
|
162 |
-
$scProduct[]=$p["SKU"];
|
163 |
-
$scProduct[]=$p["Variant"];
|
164 |
-
$scProduct[]=$p["Price"];
|
165 |
-
$scProduct[]=$p["Quantity"];
|
166 |
-
$scProduct[]=$p["Coupon"];
|
167 |
-
$scProduct[]=$p["Discount"];
|
168 |
-
|
169 |
-
$sc[]=GetStream($scProduct);
|
170 |
-
//echo "FROM HOLDERS _____ ".var_dump($sc) . "<br>";
|
171 |
-
$scProduct=array();
|
172 |
-
}
|
173 |
-
}
|
174 |
-
$strStream = GetStream($sc);
|
175 |
-
$strStream = UUEncode($strStream);
|
176 |
-
return $strStream;
|
177 |
-
}
|
178 |
-
}
|
179 |
-
|
180 |
-
class PageInfoHolder
|
181 |
-
{
|
182 |
-
var $Name;
|
183 |
-
var $Url;
|
184 |
-
var $Category;
|
185 |
-
|
186 |
-
function ToString()
|
187 |
-
{
|
188 |
-
$sc[]=$this->Name;
|
189 |
-
$sc[]=$this->Url;
|
190 |
-
$sc[]=$this->Category;
|
191 |
-
$str=GetStream($sc);
|
192 |
-
return UUEncode($str);
|
193 |
-
}
|
194 |
-
}
|
195 |
-
|
196 |
-
|
197 |
-
function GetStream($arr)
|
198 |
-
{
|
199 |
-
$sb = "";
|
200 |
-
for($i=0;$i<count($arr);$i++)
|
201 |
-
{
|
202 |
-
$strStream = $arr[$i];
|
203 |
-
$strStream = MakeStreamItem($strStream);
|
204 |
-
$sb.=$strStream;
|
205 |
-
}
|
206 |
-
$res = MakeStreamItem($sb);
|
207 |
-
return $res;
|
208 |
-
}
|
209 |
-
|
210 |
-
function MakeStreamItem($strItem)
|
211 |
-
{
|
212 |
-
$res = "";
|
213 |
-
|
214 |
-
$strLength = strlen($strItem);
|
215 |
-
for($i=strlen($strLength);$i<4;$i++)
|
216 |
-
$res.="0";
|
217 |
-
$res.=$strLength;
|
218 |
-
$res.=$strItem;
|
219 |
-
|
220 |
-
return $res;
|
221 |
-
}
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Celebros/Salesperson/Model/Api/Anlx/LogRequest.php
DELETED
@@ -1,637 +0,0 @@
|
|
1 |
-
<? //@-; This file was released in build:QANLX V1.6.0049 Date: 9/20/2006 6:32:27 PM @@@
|
2 |
-
include_once("packetizer.php");
|
3 |
-
include_once("StringEncoder.php");
|
4 |
-
include_once("Holders.php");
|
5 |
-
include_once("DataStructure.php");
|
6 |
-
include_once("ValidateResult.php");
|
7 |
-
include_once("DynamicProperty.php");
|
8 |
-
|
9 |
-
define("MAX_PACKET_SIZE",800);
|
10 |
-
define("UNSECURED_PORT",80);
|
11 |
-
define("SECURED_PORT" ,443);
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
class LogRequest
|
16 |
-
{
|
17 |
-
var $DataCollectorIP;
|
18 |
-
var $dpCustomProperties;
|
19 |
-
var $PublicKeyToken;
|
20 |
-
var $Referrer;
|
21 |
-
|
22 |
-
var $RequestID;
|
23 |
-
var $CustomerID;
|
24 |
-
var $CustomerName;
|
25 |
-
|
26 |
-
// Product members
|
27 |
-
|
28 |
-
var $bUsingQwiserSearch;
|
29 |
-
var $sProductName;
|
30 |
-
var $sProductSKU;
|
31 |
-
var $sProductVariant;
|
32 |
-
var $fProductPrice;
|
33 |
-
var $sProductCategory;
|
34 |
-
var $iProductQuantity;
|
35 |
-
|
36 |
-
//General memebers
|
37 |
-
|
38 |
-
var $sUserID;
|
39 |
-
var $sGroupID;
|
40 |
-
var $sWebSessionID;
|
41 |
-
var $Mode;
|
42 |
-
var $SID;
|
43 |
-
var $LH;
|
44 |
-
var $sCurrentPageURL;
|
45 |
-
var $sPreviousPageURL;
|
46 |
-
var $iSourceType;
|
47 |
-
var $sSourceTypeName;
|
48 |
-
var $SearchPhrase;
|
49 |
-
|
50 |
-
// QWACart memebers
|
51 |
-
|
52 |
-
var $sCartID;
|
53 |
-
var $sCartCoupon;
|
54 |
-
var $fCartDiscount;
|
55 |
-
var $iCartProductCount;
|
56 |
-
var $fCartSubTotal;
|
57 |
-
|
58 |
-
// checkout members
|
59 |
-
var $sOrderID;
|
60 |
-
|
61 |
-
// Product array
|
62 |
-
var $ProductsArray;
|
63 |
-
|
64 |
-
// Search result memebers
|
65 |
-
var $SpellingCorrectionDriven = false;
|
66 |
-
var $CorrectedFrom;
|
67 |
-
|
68 |
-
// Generic search members
|
69 |
-
var $strQuery;
|
70 |
-
var $strSearchSessionID;
|
71 |
-
var $bFromBrowse = false;
|
72 |
-
var $bFromQwiser = true;
|
73 |
-
|
74 |
-
// QWAValidateResult memebers
|
75 |
-
var $ValidateResult;
|
76 |
-
|
77 |
-
// custom property
|
78 |
-
var $m_customProperty;
|
79 |
-
|
80 |
-
|
81 |
-
function GetLogRequest($LogRequestName)
|
82 |
-
{
|
83 |
-
$strHttp = "";
|
84 |
-
$iCurrentPort= 0;
|
85 |
-
$strLogReq = ""; // return string with img tags.
|
86 |
-
$strRqtID =uniqid(rand(), true); //????? id of the log Request.
|
87 |
-
$RequestData = $this->GetData($LogRequestName); // actual data.
|
88 |
-
$DataLength = strlen($RequestData); // total length of the data.
|
89 |
-
$dTimeStamp = gmdate("U") - 946684800; // mktime()-946677600; //946684800 <- time from 01/01/1970 till 01/01/2000; 946080000;946634400
|
90 |
-
$strAsmVer = "3.0";
|
91 |
-
|
92 |
-
if ( $this->ValidateLogRequest($LogRequestName) == "Error")
|
93 |
-
{
|
94 |
-
return "";
|
95 |
-
}
|
96 |
-
|
97 |
-
switch ($this->Mode)
|
98 |
-
{
|
99 |
-
case "plainData":
|
100 |
-
$strHttp = "http";
|
101 |
-
$iCurrentPort = UNSECURED_PORT;
|
102 |
-
break;
|
103 |
-
case "encrypted":
|
104 |
-
break;
|
105 |
-
case "secured":
|
106 |
-
$strHttp = "https";
|
107 |
-
$iCurrentPort = SECURED_PORT;
|
108 |
-
break;
|
109 |
-
default:
|
110 |
-
$strHttp = "http";
|
111 |
-
$iCurrentPort = UNSECURED_PORT;
|
112 |
-
break;
|
113 |
-
}
|
114 |
-
|
115 |
-
// packetizer
|
116 |
-
$p = new Packetizer("bySize",MAX_PACKET_SIZE);
|
117 |
-
$splitData = $p->Split($RequestData);
|
118 |
-
|
119 |
-
$nSplitIdx = 0;
|
120 |
-
|
121 |
-
foreach ($splitData as $packet) // the split method.
|
122 |
-
{
|
123 |
-
$strLogReq .= "<IMG BORDER='0' NAME='QWISERIMG' WIDTH='1' HEIGHT='1' SRC='" . $strHttp . "://" . $this->DataCollectorIP . ":" . $iCurrentPort . "/QwiserDataCollector/EventListener.aspx";
|
124 |
-
|
125 |
-
// concatenate additional attributes:
|
126 |
-
// source identifier
|
127 |
-
|
128 |
-
$strLogReq .= "?";
|
129 |
-
|
130 |
-
$strLogReq .= "rqt_t=" . $dTimeStamp //Time when the event was fire
|
131 |
-
. "&sys_sm=" . $p->GetSplitMethod() //$p->SplitMethod //split method - byPair | bySize
|
132 |
-
. "&sys_sid=" . $p->SplitID //split guid
|
133 |
-
. "&sys_sx=" . $nSplitIdx //Split indeX - index number of the packet
|
134 |
-
. "&sys_stp=" . $p->TotalPackets; //split total - total number of packets in this split
|
135 |
-
|
136 |
-
$strLogReq .= "&sys_dz=" . $DataLength; //request size (data only.)
|
137 |
-
|
138 |
-
$strLogReq .= "&ctm_id=" . urlencode($this->CustomerID) //celebros customer ID
|
139 |
-
. "&ctm_n=" . urlencode($this->CustomerName) // name of the customer
|
140 |
-
. "&ctm_pkt=" . $this->PublicKeyToken //Public Key Token for encryption
|
141 |
-
. "&rqt_id=" . $this->GetLogRequestID($LogRequestName) //the id of the request predefine / custom //TODO: add GetId mechanizm
|
142 |
-
. "&rqt_g=" . $this->sGroupID //Group ID
|
143 |
-
. "&rqt_s=" . $this->sWebSessionID //Web Session ID
|
144 |
-
. "&rqt_n=" . $this->RqtNmae($LogRequestName) //Name of the request. significant only in customProperty
|
145 |
-
. "&rqt_u=" . urlencode($this->sUserID) //User ID
|
146 |
-
. "&rqt_v=" . $strAsmVer
|
147 |
-
. "&rqt_m=" . $this->iMode($this->Mode) ; //Mode of the request compressed | unprocessed | enctypted
|
148 |
-
|
149 |
-
//check sum number
|
150 |
-
|
151 |
-
// data section
|
152 |
-
// d_dat will hold only split encoded data
|
153 |
-
$strLogReq .= "&d_dat=" . $packet; // actual data of the request
|
154 |
-
|
155 |
-
// close tag
|
156 |
-
$strLogReq .= "'>";
|
157 |
-
|
158 |
-
$strLogReq = str_replace("?&","?",$strLogReq);
|
159 |
-
|
160 |
-
$nSplitIdx++;
|
161 |
-
}
|
162 |
-
return $strLogReq;
|
163 |
-
}
|
164 |
-
|
165 |
-
function GetData($LogRequestName)
|
166 |
-
{
|
167 |
-
switch ($LogRequestName)
|
168 |
-
{
|
169 |
-
case "LogSearchResult":
|
170 |
-
return $this->GetLogSearchResult();
|
171 |
-
break;
|
172 |
-
case "LogProductDetails":
|
173 |
-
return $this->GetLogProductDetails();
|
174 |
-
break;
|
175 |
-
case "LogAddToCart":
|
176 |
-
return $this->GetLogAddToCart();
|
177 |
-
break;
|
178 |
-
case "LogCheckOut":
|
179 |
-
return $this->GetLogCheckOut();
|
180 |
-
break;
|
181 |
-
case "LogVisitInfo":
|
182 |
-
return $this->GetLogVisitInfo();
|
183 |
-
break;
|
184 |
-
case "LogGenericSearchResult":
|
185 |
-
return $this->GetLogGenericSearch();
|
186 |
-
break;
|
187 |
-
default:
|
188 |
-
return $this->GetLogVisitInfo();
|
189 |
-
}
|
190 |
-
}
|
191 |
-
|
192 |
-
//TODO: add implementation in the dbase to hold all extra properties.
|
193 |
-
/// <summary>
|
194 |
-
/// Add Custom Properties to the log.
|
195 |
-
/// </summary>
|
196 |
-
/// <param name="strName">name of the new parameter</param>
|
197 |
-
/// <param name="strValue">value of the new parameter</param>
|
198 |
-
function AddCustomProperty($strName, $strValue)
|
199 |
-
{
|
200 |
-
if ($this->m_customProperty == null )
|
201 |
-
$this->m_customProperty = new DynamicProperty();
|
202 |
-
|
203 |
-
$name = "cd_" . $strName;
|
204 |
-
$this->m_customProperty->SetProperty($name, $strValue);
|
205 |
-
}
|
206 |
-
|
207 |
-
function GetCustomData()
|
208 |
-
{
|
209 |
-
// data in override implementation should be serialized with the string encoder to
|
210 |
-
// prevent char problems and security issues.
|
211 |
-
//... for additional data don't forget the & delimiter between pairs.
|
212 |
-
|
213 |
-
if ($this->m_customProperty == null )
|
214 |
-
return "";
|
215 |
-
|
216 |
-
$strProperties = $this->m_customProperty->BuildString();
|
217 |
-
return UUEncode($strProperties);
|
218 |
-
}
|
219 |
-
|
220 |
-
|
221 |
-
function GetLogProductDetails()
|
222 |
-
{
|
223 |
-
$strCustomData = $this->GetCustomData();
|
224 |
-
$strData = "";
|
225 |
-
$strProductDetails ="";
|
226 |
-
$strReferrerData = $this->GetReferrerData();
|
227 |
-
|
228 |
-
//sProduct p = new sProduct();
|
229 |
-
$Prod = new ProductDetailsHolder();
|
230 |
-
|
231 |
-
//$value = trim($value);
|
232 |
-
if($this->iProductQuantity==null || $this->iProductQuantity=="" || (trim($this->iProductQuantity))=="")
|
233 |
-
$this->iProductQuantity=1;
|
234 |
-
if( $this->fProductPrice==null || $this->fProductPrice=="" || (trim($this->fProductPrice))=="")
|
235 |
-
$this->fProductPrice=0;
|
236 |
-
|
237 |
-
$Prod->ProductList[0]["SKU"] = $this->sProductSKU;
|
238 |
-
$Prod->ProductList[0]["Variant"] = $this->sProductVariant;
|
239 |
-
$Prod->ProductList[0]["Name"] = $this->sProductName;
|
240 |
-
$Prod->ProductList[0]["Price"] = $this->fProductPrice;
|
241 |
-
$Prod->ProductList[0]["Category"] = $this->sProductCategory;
|
242 |
-
$Prod->ProductList[0]["Quantity"] = $this->iProductQuantity;
|
243 |
-
|
244 |
-
|
245 |
-
$strProductDetails =$Prod->ToString();
|
246 |
-
if (!($strProductDetails=="") || (trim($this->fProductPrice))=="")
|
247 |
-
$strData .= "0d_pd=" . $strProductDetails;
|
248 |
-
|
249 |
-
if ( $this->bUsingQwiserSearch == true )
|
250 |
-
{
|
251 |
-
if (!($this->SID == null || $this->SID=="" || (trim($this->SID)) == "" ))
|
252 |
-
$strData .= "0d_sid=" . UUEncode($this->SID);
|
253 |
-
}
|
254 |
-
else
|
255 |
-
{
|
256 |
-
$strData .= "0d_sid=" . UUEncode($this->sWebSessionID);
|
257 |
-
}
|
258 |
-
|
259 |
-
if (!($strReferrerData == null || $strReferrerData=="" || (trim($strReferrerData)) == "" ))
|
260 |
-
$strData .= "0d_ref=" . $strReferrerData;
|
261 |
-
|
262 |
-
if (!( $strCustomData == "" || (trim($strCustomData)) == "" ))
|
263 |
-
$strData .= "0d_cd=" . $strCustomData;
|
264 |
-
|
265 |
-
return $strData;
|
266 |
-
}
|
267 |
-
|
268 |
-
function GetLogSearchResult()
|
269 |
-
{
|
270 |
-
$strCustomData = $this->GetCustomData();
|
271 |
-
$strData = "";
|
272 |
-
$strReferrerData = $this->GetReferrerData();
|
273 |
-
|
274 |
-
if (!($strReferrerData == null || $strReferrerData=="" || (trim($strReferrerData))==""))
|
275 |
-
$strData .= "0d_ref=" . $strReferrerData;
|
276 |
-
|
277 |
-
if (!($this->SID == null || $this->SID == "" || (trim($this->SID)) == "" ))
|
278 |
-
$strData .= "0d_ssid=" . UUencode($this->SID);
|
279 |
-
|
280 |
-
if (!($this->LH == null || $this->LH == "" || (trim($this->LH)) == "" ))
|
281 |
-
$strData .= "0d_lh=" . $this->LH;
|
282 |
-
|
283 |
-
$strData .= "0d_fq=" . $this->BoolToString($this->bFromQwiser);
|
284 |
-
|
285 |
-
|
286 |
-
$ADSearchHolder = new SRAdditionalHolder();
|
287 |
-
$ADSearchHolder->SpellingCorrectionDriven = $this->BoolToString($this->SpellingCorrectionDriven);
|
288 |
-
$ADSearchHolder->CorrectedFrom = $this->CorrectedFrom;
|
289 |
-
$ADSearchHolder->FromBrowse = $this->BoolToString($this->bFromBrowse);
|
290 |
-
|
291 |
-
$strADSearchInfo = $ADSearchHolder->ToString();
|
292 |
-
if (!($strADSearchInfo=="" || (trim($strADSearchInfo)) == "" ))
|
293 |
-
$strData .= "0d_sr=" . $strADSearchInfo;
|
294 |
-
|
295 |
-
// SRAdditionalHolder SRHolder = new SRAdditionalHolder();
|
296 |
-
// SRHolder.SpellingCorrectionDriven = m_bSpellingCorrectionDriven;
|
297 |
-
// SRHolder.CorrectedFrom = m_strCorrectedFrom;
|
298 |
-
// SRHolder.FromBrowse = m_bFromBrowse;
|
299 |
-
// string strSRAdditional = SRHolder.ToString();
|
300 |
-
//
|
301 |
-
// if (!String.Empty.Equals(strSRAdditional))
|
302 |
-
// strData += "0d_sr=" + strSRAdditional;
|
303 |
-
//
|
304 |
-
if (!($strCustomData == "" || (trim($strCustomData)) == "" ))
|
305 |
-
$strData .= "0d_cd=" . $strCustomData;
|
306 |
-
|
307 |
-
return $strData;
|
308 |
-
}
|
309 |
-
|
310 |
-
function GetLogGenericSearch()
|
311 |
-
{
|
312 |
-
$strCustomData = $this->GetCustomData();
|
313 |
-
$strData = "";
|
314 |
-
$strGenericInfo = "";
|
315 |
-
$strReferrerData = $this->GetReferrerData();
|
316 |
-
|
317 |
-
if (!($strReferrerData == null || $strReferrerData=="" || (trim($strReferrerData)) == "" ))
|
318 |
-
$strData .= "0d_ref=" . $strReferrerData;
|
319 |
-
|
320 |
-
$GenericHolder = new GenericSRHolder();
|
321 |
-
$GenericHolder->SearchSession = $this->strSearchSessionID;
|
322 |
-
$GenericHolder->Query = $this->strQuery;
|
323 |
-
$GenericHolder->FromBrowse = $this->BoolToString($this->bFromBrowse);
|
324 |
-
|
325 |
-
$strGenericInfo = $GenericHolder->ToString();
|
326 |
-
if (!($strGenericInfo=="" || (trim($strGenericInfo)) == "" ))
|
327 |
-
$strData .= "0d_gsr=" . $strGenericInfo;
|
328 |
-
|
329 |
-
if (!($strCustomData == "" || (trim($strCustomData)) == "" ))
|
330 |
-
$strData .= "0d_cd=" . $strCustomData;
|
331 |
-
|
332 |
-
return $strData;
|
333 |
-
}
|
334 |
-
|
335 |
-
|
336 |
-
function GetLogAddToCart()
|
337 |
-
{
|
338 |
-
$strCustomData = $this->GetCustomData();
|
339 |
-
$strData = "";
|
340 |
-
$strCartInfo = "";
|
341 |
-
$strProductDetails = "";
|
342 |
-
$strReferrerData = $this->GetReferrerData();
|
343 |
-
|
344 |
-
$Prod = new ProductDetailsHolder();
|
345 |
-
|
346 |
-
if($this->iProductQuantity==null || $this->iProductQuantity=="" || (trim($this->iProductQuantity)) == "" )
|
347 |
-
$this->iProductQuantity=1;
|
348 |
-
|
349 |
-
$Prod->ProductList[0]["SKU"] = $this->sProductSKU;
|
350 |
-
$Prod->ProductList[0]["Variant"] = $this->sProductVariant;
|
351 |
-
$Prod->ProductList[0]["Name"] = $this->sProductName;
|
352 |
-
$Prod->ProductList[0]["Price"] = $this->fProductPrice;
|
353 |
-
$Prod->ProductList[0]["Category"] = $this->sProductCategory;
|
354 |
-
$Prod->ProductList[0]["Quantity"] = $this->iProductQuantity;
|
355 |
-
|
356 |
-
$strProductDetails = $Prod->ToString();
|
357 |
-
if (!($strProductDetails=="" || (trim($strProductDetails)) == "" ))
|
358 |
-
$strData .= "0d_pd=" . $strProductDetails;
|
359 |
-
|
360 |
-
$cartHolder = new CartInfoHolder();
|
361 |
-
$cartHolder->CartID = $this->sCartID;
|
362 |
-
$cartHolder->Coupon = $this->sCartCoupon;
|
363 |
-
$cartHolder->Discount = $this->fCartDiscount;
|
364 |
-
$cartHolder->ProductCount = $this->iCartProductCount;
|
365 |
-
$cartHolder->SubTotal = $this->fCartSubTotal;
|
366 |
-
|
367 |
-
$strCartInfo = $cartHolder->ToString();
|
368 |
-
if (!($strCartInfo=="" || (trim($strCartInfo)) == ""))
|
369 |
-
$strData .= "0d_ci=" . $strCartInfo;
|
370 |
-
|
371 |
-
if ( $this->bUsingQwiserSearch == true )
|
372 |
-
{
|
373 |
-
if (!( $this->SID == null || $this->SID=="" || (trim($this->SID)) == "" ))
|
374 |
-
$strData .= "0d_sid=" . UUEncode($this->SID);
|
375 |
-
}
|
376 |
-
else
|
377 |
-
{
|
378 |
-
$strData .= "0d_sid=" . UUEncode($this->sWebSessionID);
|
379 |
-
}
|
380 |
-
//new code: Ignoring the bUsingQwiserSearch parameter
|
381 |
-
/*
|
382 |
-
if (!( $this->SID == null || $this->SID=="" || (trim($this->SID)) == "" ))
|
383 |
-
$strData .= "0d_sid=" . UUEncode($this->SID);
|
384 |
-
else
|
385 |
-
$strData .= "0d_sid=" . UUEncode($this->sWebSessionID);
|
386 |
-
*/
|
387 |
-
|
388 |
-
if (!($strReferrerData == null || $strReferrerData=="" || (trim($strReferrerData)) == "" ))
|
389 |
-
$strData .= "0d_ref=" . $strReferrerData;
|
390 |
-
|
391 |
-
if (!($strCustomData == "" || (trim($strCustomData)) == "" ))
|
392 |
-
$strData .= "0d_cd=" . $strCustomData;
|
393 |
-
|
394 |
-
return $strData;
|
395 |
-
}
|
396 |
-
|
397 |
-
|
398 |
-
function GetLogCheckOut()
|
399 |
-
{
|
400 |
-
$strCustomData = $this->GetCustomData();
|
401 |
-
$strData = "";
|
402 |
-
$strReferrerData = $this->GetReferrerData();
|
403 |
-
|
404 |
-
// fill all products
|
405 |
-
$Prod = new ProductCOHolder();
|
406 |
-
if(count($this->ProductsArray)>0)
|
407 |
-
{
|
408 |
-
for($i=0;$i<count($this->ProductsArray);$i++)
|
409 |
-
{
|
410 |
-
$Prod->ProductList[$i]["SKU"] = $this->ProductsArray[$i]["SKU"];
|
411 |
-
$Prod->ProductList[$i]["Variant"] = $this->ProductsArray[$i]["Variant"];
|
412 |
-
$Prod->ProductList[$i]["Discount"] = $this->ProductsArray[$i]["Discount"];
|
413 |
-
$Prod->ProductList[$i]["Price"] = $this->ProductsArray[$i]["Price"];
|
414 |
-
$Prod->ProductList[$i]["Quantity"] = $this->ProductsArray[$i]["Quantity"];
|
415 |
-
$Prod->ProductList[$i]["Coupon"] = $this->ProductsArray[$i]["Coupon"];
|
416 |
-
}
|
417 |
-
}
|
418 |
-
$strProductDetails = $Prod->ToString();
|
419 |
-
|
420 |
-
if (!($strProductDetails=="" || (trim($strProductDetails)) == ""))
|
421 |
-
$strData .= "0d_pdco=" . $strProductDetails;
|
422 |
-
|
423 |
-
// fill cart info
|
424 |
-
$cartHolder = new CartInfoHolder();
|
425 |
-
$cartHolder->CartID = $this->sCartID;
|
426 |
-
$cartHolder->Coupon = $this->sCartCoupon;
|
427 |
-
$cartHolder->Discount = $this->fCartDiscount;
|
428 |
-
$cartHolder->ProductCount = $this->iCartProductCount;
|
429 |
-
$cartHolder->SubTotal = $this->fCartSubTotal;
|
430 |
-
|
431 |
-
$strCartInfo = $cartHolder->ToString();
|
432 |
-
|
433 |
-
if (!($strCartInfo=="" || (trim($strCartInfo)) == ""))
|
434 |
-
$strData .= "0d_ci=" . $strCartInfo;
|
435 |
-
|
436 |
-
if (!($this->sOrderID=="" || (trim($this->sOrderID)) == "" ))
|
437 |
-
$strData .= "0d_oid=" . UUEncode($this->sOrderID);
|
438 |
-
|
439 |
-
|
440 |
-
if (!( $strReferrerData == null || $strReferrerData=="" || (trim($strReferrerData)) == "" ))
|
441 |
-
$strData .= "0d_ref=" . $strReferrerData;
|
442 |
-
|
443 |
-
if (!($strCustomData == "" || (trim($strCustomData)) == ""))
|
444 |
-
$strData .= "0d_cd=" . $strCustomData;
|
445 |
-
|
446 |
-
return $strData;
|
447 |
-
}
|
448 |
-
|
449 |
-
|
450 |
-
function GetLogVisitInfo()
|
451 |
-
{
|
452 |
-
$strCustomData = $this->GetCustomData();
|
453 |
-
$strData = "";
|
454 |
-
$strReferrerData = $this->GetReferrerData();
|
455 |
-
$PageInfo = new PageInfoHolder();
|
456 |
-
|
457 |
-
if (!($strReferrerData == null || $strReferrerData=="" || (trim($strReferrerData)) == "" ))
|
458 |
-
$strData .= "0d_ref=" . $strReferrerData;
|
459 |
-
|
460 |
-
$PageInfo->Name = $this->Name;
|
461 |
-
$PageInfo->Url = $this->sCurrentPageURL;
|
462 |
-
$PageInfo->Category = $this->Category;
|
463 |
-
|
464 |
-
$strPage = $PageInfo->ToString();
|
465 |
-
|
466 |
-
if (!($strPage == null || $strPage=="" || (trim($strPage)) == "" ))
|
467 |
-
$strData .= "0d_page=" . $strPage;
|
468 |
-
|
469 |
-
//... for additional data don't forget the & between pairs.*/
|
470 |
-
|
471 |
-
if (!($strCustomData == "" || (trim($strCustomData)) == "" ))
|
472 |
-
$strData .= "0d_cd=" . $strCustomData;
|
473 |
-
|
474 |
-
return $strData;
|
475 |
-
}
|
476 |
-
|
477 |
-
function ValidateLogRequest($LogRequestName)
|
478 |
-
{
|
479 |
-
$Message = "";
|
480 |
-
|
481 |
-
$this->ValidateResult = new sValidateResult();
|
482 |
-
|
483 |
-
// error message
|
484 |
-
$iSeverity = "Error";
|
485 |
-
|
486 |
-
// customer error
|
487 |
-
if ( $this->CustomerID == null || $this->CustomerID == "" || (trim($this->CustomerID)) == "" )
|
488 |
-
{
|
489 |
-
$Message = "evrErrCustomerIDIsMissing";
|
490 |
-
}
|
491 |
-
|
492 |
-
// data collector errors
|
493 |
-
elseif ( $this->DataCollectorIP == null || $this->DataCollectorIP == "" || (trim($this->DataCollectorIP)) == "")
|
494 |
-
{
|
495 |
-
$Message = "evrErrServerNameIsMissing";
|
496 |
-
}
|
497 |
-
|
498 |
-
if ( $Message == "" )
|
499 |
-
{
|
500 |
-
|
501 |
-
switch ($LogRequestName)
|
502 |
-
{
|
503 |
-
case "LogSearchResult":
|
504 |
-
$Message = GetSRValidateResult($this->SID, $this->LH);
|
505 |
-
break;
|
506 |
-
case "LogGenericSearchResult":
|
507 |
-
$Message = GetGRValidateResult($this->strSearchSessionID);
|
508 |
-
break;
|
509 |
-
case "LogProductDetails":
|
510 |
-
$Message = GetPDValidateResult($this->SID, $this->sProductSKU);
|
511 |
-
break;
|
512 |
-
case "LogAddToCart":
|
513 |
-
$Message = GetATCValidateResult($this->SID, $this->sProductSKU, $this->sCartID);
|
514 |
-
break;
|
515 |
-
case "LogCheckOut":
|
516 |
-
$Message = GetCOValidateResult($this->sCartID, $this->sOrderID);
|
517 |
-
break;
|
518 |
-
default:
|
519 |
-
$Message = "";
|
520 |
-
}
|
521 |
-
}
|
522 |
-
|
523 |
-
if ($Message == "")
|
524 |
-
{
|
525 |
-
|
526 |
-
$iSeverity = "Warning";
|
527 |
-
|
528 |
-
/*if ( (DataCollector.Port == UNSECURED_PORT) && (m_Mode == enumRequestMode.secured) )
|
529 |
-
{
|
530 |
-
sCurrValidateRes.MessageID = enumValidateResult.evrWrnConflictInDCParam;
|
531 |
-
return sCurrValidateRes;
|
532 |
-
}*/
|
533 |
-
if ( $this->CustomerName == null || $this->CustomerName = "" || (trim($this->CustomerName)) == "")
|
534 |
-
{
|
535 |
-
$Message = "evrWrnCustomerNameISMissing";
|
536 |
-
|
537 |
-
}
|
538 |
-
}
|
539 |
-
|
540 |
-
if ($Message == "" )
|
541 |
-
{
|
542 |
-
$iSeverity = "RequestOK";
|
543 |
-
}
|
544 |
-
|
545 |
-
$this->ValidateResult->iSeverity = $iSeverity;
|
546 |
-
$this->ValidateResult->strMessage = $Message;
|
547 |
-
|
548 |
-
return $iSeverity;
|
549 |
-
|
550 |
-
}
|
551 |
-
|
552 |
-
function iMode($Mode)
|
553 |
-
{
|
554 |
-
switch ($Mode)
|
555 |
-
{
|
556 |
-
case "plainData":
|
557 |
-
return 0;
|
558 |
-
case "encrypted":
|
559 |
-
return 1;
|
560 |
-
case "secured":
|
561 |
-
return 2;
|
562 |
-
default:
|
563 |
-
return -1;
|
564 |
-
}
|
565 |
-
}
|
566 |
-
|
567 |
-
function RqtNmae($LogRequestName)
|
568 |
-
{
|
569 |
-
switch ($LogRequestName)
|
570 |
-
{
|
571 |
-
CASE "LogSearchResult":
|
572 |
-
return "sr";
|
573 |
-
CASE "LogProductDetails":
|
574 |
-
return "PD";
|
575 |
-
CASE "LogAddToCart":
|
576 |
-
return "ToCRT";
|
577 |
-
CASE "LogCheckOut":
|
578 |
-
return "CkOut";
|
579 |
-
CASE "LogVisitInfo":
|
580 |
-
return "VisitInfo";
|
581 |
-
case "LogGenericSearchResult":
|
582 |
-
return "GSR";
|
583 |
-
default:
|
584 |
-
return -1;//TODO
|
585 |
-
}
|
586 |
-
}
|
587 |
-
|
588 |
-
function GetLogRequestID($LogRequestName)
|
589 |
-
{
|
590 |
-
switch ($LogRequestName)
|
591 |
-
{
|
592 |
-
CASE "LogSearchResult":
|
593 |
-
return "1";
|
594 |
-
CASE "LogProductDetails":
|
595 |
-
return "2";
|
596 |
-
CASE "LogAddToCart":
|
597 |
-
return "3";
|
598 |
-
CASE "LogCheckOut":
|
599 |
-
return "4";
|
600 |
-
CASE "LogVisitInfo":
|
601 |
-
return "5";
|
602 |
-
CASE "LogGenericSearchResult":
|
603 |
-
return "6";
|
604 |
-
default:
|
605 |
-
return -1;//TODO
|
606 |
-
}
|
607 |
-
}
|
608 |
-
|
609 |
-
|
610 |
-
function GetReferrerData()
|
611 |
-
{
|
612 |
-
$RefInfo = new ReferrerInfoHolder();
|
613 |
-
|
614 |
-
$RefInfo->ReferrerUrl = $this->sPreviousPageURL;
|
615 |
-
$RefInfo->CampaignName = $this->sSourceTypeName;
|
616 |
-
$RefInfo->SearchPhrase = $this->SearchPhrase;
|
617 |
-
$RefInfo->CampaignType = $this->iSourceType;
|
618 |
-
|
619 |
-
return $RefInfo->ToString();
|
620 |
-
}
|
621 |
-
|
622 |
-
function GetValidateResult()
|
623 |
-
{
|
624 |
-
return $this->ValidateResult;
|
625 |
-
}
|
626 |
-
|
627 |
-
function BoolToString($bool)
|
628 |
-
{
|
629 |
-
if ($bool == 1 )
|
630 |
-
return "True";
|
631 |
-
else
|
632 |
-
return "False";
|
633 |
-
}
|
634 |
-
}
|
635 |
-
|
636 |
-
|
637 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Celebros/Salesperson/Model/Api/Anlx/RunLogReq.php
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
<? //@-; This file was released in build:QANLX V1.6.0049 Date: 9/20/2006 6:32:27 PM @@@
|
2 |
-
include_once("AnalyticsFunctions.php");
|
3 |
-
|
4 |
-
//$sr =new AnalyticsFunctions();
|
5 |
-
//$sr->Celebros_Analytics_Visit("","","","","");
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
$gr =new LogRequest();
|
10 |
-
$gr->CustomerID = "yfat";
|
11 |
-
$gr->CustomerName = "yfat";
|
12 |
-
$gr->SH = "aaa";
|
13 |
-
$gr->DataCollectorIP = "1";
|
14 |
-
|
15 |
-
$gr->AddCustomProperty("yfat","test");
|
16 |
-
$gr->bFromBrowse="true";
|
17 |
-
$gr->CorrectedFrom = "yfat";
|
18 |
-
$gr->SpellingCorrectionDriven = "true";
|
19 |
-
$a = $gr->GetLogRequest("LogSearchResult");
|
20 |
-
|
21 |
-
$b = $a;
|
22 |
-
|
23 |
-
//$gr->Celebros_Analytics_GenericSearchResults("1","red","true","23","","","","");
|
24 |
-
/*$gr->AddCustomProperty("a","b");
|
25 |
-
$message = $gr->GetLastErrorMessage();
|
26 |
-
$message1 = $gr->GetLastErrorSeverity();
|
27 |
-
*/
|
28 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Celebros/Salesperson/Model/Api/Anlx/StringEncoder.php
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
<? //@-; This file was released in build:QANLX V1.6.0049 Date: 9/20/2006 6:32:27 PM @@@
|
2 |
-
function UUEncode($strString)
|
3 |
-
{
|
4 |
-
$sbCodedString="";
|
5 |
-
|
6 |
-
$strString = utf8_encode($strString); //encode the string to UTF8
|
7 |
-
for ($i=0;$i<strlen($strString);$i++)
|
8 |
-
{
|
9 |
-
$c = $strString[$i];
|
10 |
-
$intHigh = (128 + 64 + 32 + 16) & ord($c);
|
11 |
-
$intLow = (8 + 4 + 2 + 1) & ord($c);
|
12 |
-
$sbCodedString.=chr(($intHigh/16)+65);
|
13 |
-
$sbCodedString.=chr($intLow+65);
|
14 |
-
}
|
15 |
-
return "ZZ" . $sbCodedString;
|
16 |
-
}
|
17 |
-
|
18 |
-
/*
|
19 |
-
/// <summary> FROM .NET
|
20 |
-
/// UUEncode - encode a given string
|
21 |
-
/// </summary>
|
22 |
-
/// <param name="strString"></param>
|
23 |
-
/// <returns></returns>
|
24 |
-
public static string UUEncode(string strString)
|
25 |
-
{
|
26 |
-
StringBuilder sbCodedString = new StringBuilder(strString.Length*2);
|
27 |
-
byte[] byteArr = System.Text.Encoding.UTF8.GetBytes(strString);//Get UTF8Encoding to byte array from string
|
28 |
-
byte b;
|
29 |
-
int i,intHigh,intLow;
|
30 |
-
|
31 |
-
for (i=0;i<byteArr.Length;i++)
|
32 |
-
{
|
33 |
-
b = byteArr[i];
|
34 |
-
intHigh = (128 + 64 + 32 + 16) & b;
|
35 |
-
intLow = (8 + 4 + 2 + 1) & b;
|
36 |
-
sbCodedString.Append((char)((intHigh/16)+65));
|
37 |
-
sbCodedString.Append((char)(intLow+65));
|
38 |
-
}
|
39 |
-
return "ZZ"+sbCodedString.ToString();
|
40 |
-
}
|
41 |
-
*/
|
42 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Celebros/Salesperson/Model/Api/Anlx/ValidateResult.php
DELETED
@@ -1,69 +0,0 @@
|
|
1 |
-
<? //@-; This file was released in build:QANLX V1.6.0049 Date: 9/20/2006 6:32:27 PM @@@
|
2 |
-
function GetSRValidateResult($searchHandle, $logHandle)
|
3 |
-
{
|
4 |
-
if ($searchHandle == "" || $searchHandle == null)
|
5 |
-
{
|
6 |
-
return "evrErrSearchSessionIDIsMissing";
|
7 |
-
}
|
8 |
-
elseif ($logHandle == "" || $logHandle == null)
|
9 |
-
{
|
10 |
-
return "evrErrLogHandleIsMissing";
|
11 |
-
}
|
12 |
-
|
13 |
-
return "";
|
14 |
-
}
|
15 |
-
|
16 |
-
function GetGRValidateResult($sessionID)
|
17 |
-
{
|
18 |
-
if ($sessionID == "" || $sessionID == null)
|
19 |
-
{
|
20 |
-
return "evrErrSearchSessionIDIsMissing";
|
21 |
-
}
|
22 |
-
return "";
|
23 |
-
}
|
24 |
-
|
25 |
-
function GetPDValidateResult($sessionID,$sku)
|
26 |
-
{
|
27 |
-
if ($sessionID == null || $sessionID = "")
|
28 |
-
{
|
29 |
-
return "evrErrSearchSessionIDIsMissing";
|
30 |
-
}
|
31 |
-
elseif ($sku == null || $sku == "")
|
32 |
-
{
|
33 |
-
return "evrErrSKUIsMissing";
|
34 |
-
}
|
35 |
-
return "";
|
36 |
-
}
|
37 |
-
|
38 |
-
function GetATCValidateResult($sessionID, $sku, $cartID)
|
39 |
-
{
|
40 |
-
if ($sessionID == null || $sessionID = "")
|
41 |
-
{
|
42 |
-
return "evrErrSearchSessionIDIsMissing";
|
43 |
-
}
|
44 |
-
elseif ($sku == null || $sku == "")
|
45 |
-
{
|
46 |
-
return "evrErrSKUIsMissing";
|
47 |
-
}
|
48 |
-
elseif ($cartID == null || $cartID = "")
|
49 |
-
{
|
50 |
-
return "evrErrCartIDIsMissing";
|
51 |
-
}
|
52 |
-
return "";
|
53 |
-
|
54 |
-
}
|
55 |
-
|
56 |
-
function GetCOValidateResult($cartID, $orderID)
|
57 |
-
{
|
58 |
-
if ($cartID == null || $cartID = "")
|
59 |
-
{
|
60 |
-
return "evrErrCartIDIsMissing";
|
61 |
-
}
|
62 |
-
elseif ($orderID == null || $orderID == "")
|
63 |
-
{
|
64 |
-
return "evrErrOrderIDIsMissing";
|
65 |
-
}
|
66 |
-
return "";
|
67 |
-
}
|
68 |
-
|
69 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Celebros/Salesperson/Model/Api/Anlx/packetizer.php
DELETED
@@ -1,53 +0,0 @@
|
|
1 |
-
<? //@-; This file was released in build:QANLX V1.6.0049 Date: 9/20/2006 6:32:27 PM @@@
|
2 |
-
class packetizer
|
3 |
-
{
|
4 |
-
var $SplitMethod;
|
5 |
-
var $PacketSize;
|
6 |
-
var $SplitID;
|
7 |
-
var $TotalPackets;
|
8 |
-
|
9 |
-
function packetizer($SplitMethod,$PacketSize)
|
10 |
-
{
|
11 |
-
$this->SplitMethod=$SplitMethod;
|
12 |
-
$this->PacketSize=$PacketSize;
|
13 |
-
$this->SplitID=uniqid(rand(), true);
|
14 |
-
}
|
15 |
-
|
16 |
-
function Split($Data)
|
17 |
-
{
|
18 |
-
if($this->PacketSize<strlen($Data))
|
19 |
-
{
|
20 |
-
$len=strlen($Data)/$this->PacketSize;
|
21 |
-
$len=ceil($len);
|
22 |
-
$this->TotalPackets=$len;
|
23 |
-
for($i=0;$i<$len;$i++)
|
24 |
-
{
|
25 |
-
$splitArray[$i]=substr($Data,$i*$this->PacketSize,$this->PacketSize);
|
26 |
-
}
|
27 |
-
|
28 |
-
}
|
29 |
-
else
|
30 |
-
{
|
31 |
-
$splitArray[0]=$Data;
|
32 |
-
$this->TotalPackets=1;
|
33 |
-
}
|
34 |
-
|
35 |
-
return $splitArray;
|
36 |
-
|
37 |
-
}
|
38 |
-
|
39 |
-
function GetSplitMethod()
|
40 |
-
{
|
41 |
-
switch ($this->SplitMethod)
|
42 |
-
{
|
43 |
-
CASE "bySize":
|
44 |
-
return "2";
|
45 |
-
default:
|
46 |
-
return "-1";//TODO
|
47 |
-
}
|
48 |
-
|
49 |
-
|
50 |
-
}
|
51 |
-
|
52 |
-
}
|
53 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Celebros/Salesperson/Model/Api/QwiserQuestion.php
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
<?
|
2 |
-
class Celebros_Salesperson_Model_Api_QwiserQuestion
|
3 |
-
{
|
4 |
-
var $Id;
|
5 |
-
var $Rank;
|
6 |
-
var $SideText;
|
7 |
-
var $Text;
|
8 |
-
var $Type;
|
9 |
-
var $HasMoreAnswers;
|
10 |
-
var $ExtraAnswers;
|
11 |
-
var $DynamicProperties;
|
12 |
-
var $Answers;
|
13 |
-
|
14 |
-
Function Celebros_Salesperson_Model_Api_QwiserQuestion($QuestionNode)
|
15 |
-
{
|
16 |
-
if(is_object($QuestionNode))
|
17 |
-
{
|
18 |
-
$this->Id = $QuestionNode->get_attribute("Id");
|
19 |
-
$this->Rank = $QuestionNode->get_attribute("Rank");
|
20 |
-
$this->SideText = $QuestionNode->get_attribute("SideText");
|
21 |
-
$this->Text = $QuestionNode->get_attribute("Text");
|
22 |
-
$this->Type = $QuestionNode->get_attribute("Type");
|
23 |
-
$this->Answers = new Celebros_Salesperson_Model_Api_QwiserAnswers(current($QuestionNode->get_elements_by_tagname("Answers")));
|
24 |
-
$this->ExtraAnswers = new Celebros_Salesperson_Model_Api_QwiserAnswers(current($QuestionNode->get_elements_by_tagname("ExtraAnswers")));
|
25 |
-
$this->HasMoreAnswers = ($this->ExtraAnswers->Count > 0) ? true : false;
|
26 |
-
$this->DynamicProperties = GetQwiserSimpleStringDictionary(current($QuestionNode->get_elements_by_tagname("DynamicProperties")));
|
27 |
-
}
|
28 |
-
}
|
29 |
-
}
|
30 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Celebros/Salesperson/Model/Api/SearchInformation.php
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
<?
|
2 |
-
class Celebros_Salesperson_Model_Api_SearchInformation
|
3 |
-
{
|
4 |
-
var $Query;
|
5 |
-
var $OriginalQuery;
|
6 |
-
var $SearchProfileName;
|
7 |
-
var $PriceFieldName;
|
8 |
-
var $NumberOfPages;
|
9 |
-
var $CurrentPage;
|
10 |
-
var $PageSize;
|
11 |
-
var $IsDefaultPageSize;
|
12 |
-
var $IsDefaultSearchProfileName;
|
13 |
-
var $SkuSearchOccured;
|
14 |
-
var $DeadEndOccurred;
|
15 |
-
var $FirstQuestionId;
|
16 |
-
var $SessionId;
|
17 |
-
var $Stage;
|
18 |
-
var $SortingOptions;
|
19 |
-
|
20 |
-
|
21 |
-
Function Celebros_Salesperson_Model_Api_SearchInformation($xml_SearchInformation)
|
22 |
-
{
|
23 |
-
if(is_object($xml_SearchInformation))
|
24 |
-
{
|
25 |
-
$this->Query = $xml_SearchInformation->get_attribute("Query");
|
26 |
-
$this->OriginalQuery = $xml_SearchInformation->get_attribute("OriginalQuery");
|
27 |
-
$this->SearchProfileName = $xml_SearchInformation->get_attribute("SearchProfileName");
|
28 |
-
$this->PriceFieldName = $xml_SearchInformation->get_attribute("PriceFieldName");
|
29 |
-
$this->NumberOfPages = $xml_SearchInformation->get_attribute("NumberOfPages");
|
30 |
-
$this->CurrentPage = $xml_SearchInformation->get_attribute("CurrentPage");
|
31 |
-
$this->PageSize = $xml_SearchInformation->get_attribute("PageSize");
|
32 |
-
$this->IsDefaultPageSize = $xml_SearchInformation->get_attribute("IsDefaultPageSize");
|
33 |
-
$this->SkuSearchOccured = $xml_SearchInformation->get_attribute("SkuSearchOccured");
|
34 |
-
$this->DeadEndOccurred = $xml_SearchInformation->get_attribute("DeadEndOccurred");
|
35 |
-
$this->FirstQuestionId = $xml_SearchInformation->get_attribute("FirstQuestionId");
|
36 |
-
$this->SessionId = $xml_SearchInformation->get_attribute("SessionId");
|
37 |
-
$this->Stage = $xml_SearchInformation->get_attribute("Stage");
|
38 |
-
|
39 |
-
$this->SortingOptions = new Celebros_Salesperson_Model_Api_SortingOptions(current($xml_SearchInformation->get_elements_by_tagname("SortingOptions")));
|
40 |
-
}
|
41 |
-
}
|
42 |
-
}
|
43 |
-
|
44 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Celebros/Salesperson/Model/Api/SortingOptions.php
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
<?
|
2 |
-
class Celebros_Salesperson_Model_Api_SortingOptions
|
3 |
-
{
|
4 |
-
var $Ascending;
|
5 |
-
var $FieldName;
|
6 |
-
var $NumericSort;
|
7 |
-
var $Method;
|
8 |
-
|
9 |
-
Function Celebros_Salesperson_Model_Api_SortingOptions($xml_SortingOptions)
|
10 |
-
{
|
11 |
-
if(is_object($xml_SortingOptions))
|
12 |
-
{
|
13 |
-
$this->Ascending = $xml_SortingOptions->get_attribute("Ascending");
|
14 |
-
$this->FieldName = $xml_SortingOptions->get_attribute("FieldName");
|
15 |
-
$this->NumericSort = $xml_SortingOptions->get_attribute("NumericSort");
|
16 |
-
$this->Method = $xml_SortingOptions->get_attribute("Method");
|
17 |
-
}
|
18 |
-
}
|
19 |
-
}
|
20 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Celebros/Salesperson/Model/Convert/Parser/Csv.php
DELETED
@@ -1,287 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_Model_Convert_Parser_Csv extends Mage_Dataflow_Model_Convert_Parser_Abstract
|
11 |
-
{
|
12 |
-
protected $_fields;
|
13 |
-
|
14 |
-
protected $_mapfields = array();
|
15 |
-
|
16 |
-
public function parse()
|
17 |
-
{
|
18 |
-
// fixed for multibyte characters
|
19 |
-
setlocale(LC_ALL, Mage::app()->getLocale()->getLocaleCode().'.UTF-8');
|
20 |
-
|
21 |
-
$fDel = Mage::getStoreConfig('salesperson/export_settings/delimiter');
|
22 |
-
if ($fDel == ''){
|
23 |
-
$fDel = $this->getVar('delimiter', '\t');
|
24 |
-
}
|
25 |
-
$fEnc = Mage::getStoreConfig('salesperson/export_settings/enclosed_values');
|
26 |
-
// if ($fEnc == ''){
|
27 |
-
// $fEnc = $this->getVar('enclose', '');
|
28 |
-
// }
|
29 |
-
if ($fDel == '\t') {
|
30 |
-
$fDel = "\t";
|
31 |
-
}
|
32 |
-
|
33 |
-
$adapterName = $this->getVar('adapter', null);
|
34 |
-
$adapterMethod = $this->getVar('method', 'saveRow');
|
35 |
-
|
36 |
-
if (!$adapterName || !$adapterMethod) {
|
37 |
-
$message = Mage::helper('dataflow')->__('Please declare "adapter" and "method" node first');
|
38 |
-
$this->addException($message, Mage_Dataflow_Model_Convert_Exception::FATAL);
|
39 |
-
return $this;
|
40 |
-
}
|
41 |
-
|
42 |
-
try {
|
43 |
-
$adapter = Mage::getModel($adapterName);
|
44 |
-
}
|
45 |
-
catch (Exception $e) {
|
46 |
-
$message = Mage::helper('dataflow')->__('Declared adapter %s not found', $adapterName);
|
47 |
-
$this->addException($message, Mage_Dataflow_Model_Convert_Exception::FATAL);
|
48 |
-
return $this;
|
49 |
-
}
|
50 |
-
|
51 |
-
if (!is_callable(array($adapter, $adapterMethod))) {
|
52 |
-
$message = Mage::helper('dataflow')->__('Method "%s" not defined in adapter %s', $adapterMethod, $adapterName);
|
53 |
-
$this->addException($message, Mage_Dataflow_Model_Convert_Exception::FATAL);
|
54 |
-
return $this;
|
55 |
-
}
|
56 |
-
|
57 |
-
$batchModel = $this->getBatchModel();
|
58 |
-
$batchIoAdapter = $this->getBatchModel()->getIoAdapter();
|
59 |
-
|
60 |
-
if (Mage::app()->getRequest()->getParam('files')) {
|
61 |
-
$file = Mage::app()->getConfig()->getTempVarDir().'/import/'
|
62 |
-
. urldecode(Mage::app()->getRequest()->getParam('files'));
|
63 |
-
$this->_copy($file);
|
64 |
-
}
|
65 |
-
|
66 |
-
$batchIoAdapter->open(false);
|
67 |
-
|
68 |
-
$isFieldNames = $this->getVar('fieldnames', '') == 'true' ? true : false;
|
69 |
-
if (!$isFieldNames && is_array($this->getVar('map'))) {
|
70 |
-
$fieldNames = $this->getVar('map');
|
71 |
-
}
|
72 |
-
else {
|
73 |
-
$fieldNames = array();
|
74 |
-
foreach ($batchIoAdapter->read(true, $fDel, $fEnc) as $v) {
|
75 |
-
$fieldNames[$v] = $v;
|
76 |
-
}
|
77 |
-
}
|
78 |
-
|
79 |
-
$countRows = 0;
|
80 |
-
while (($csvData = $batchIoAdapter->read(true, $fDel, $fEnc)) !== false) {
|
81 |
-
if (count($csvData) == 1 && $csvData[0] === null) {
|
82 |
-
continue;
|
83 |
-
}
|
84 |
-
|
85 |
-
$itemData = array();
|
86 |
-
$countRows ++; $i = 0;
|
87 |
-
foreach ($fieldNames as $field) {
|
88 |
-
$itemData[$field] = isset($csvData[$i]) ? $csvData[$i] : null;
|
89 |
-
$i ++;
|
90 |
-
}
|
91 |
-
|
92 |
-
$batchImportModel = $this->getBatchImportModel()
|
93 |
-
->setId(null)
|
94 |
-
->setBatchId($this->getBatchModel()->getId())
|
95 |
-
->setBatchData($itemData)
|
96 |
-
->setStatus(1)
|
97 |
-
->save();
|
98 |
-
}
|
99 |
-
|
100 |
-
$this->addException(Mage::helper('dataflow')->__('Found %d rows', $countRows));
|
101 |
-
$this->addException(Mage::helper('dataflow')->__('Starting %s :: %s', $adapterName, $adapterMethod));
|
102 |
-
|
103 |
-
$batchModel->setParams($this->getVars())
|
104 |
-
->setAdapter($adapterName)
|
105 |
-
->save();
|
106 |
-
|
107 |
-
//$adapter->$adapterMethod();
|
108 |
-
|
109 |
-
return $this;
|
110 |
-
|
111 |
-
// // fix for field mapping
|
112 |
-
// if ($mapfields = $this->getProfile()->getDataflowProfile()) {
|
113 |
-
// $this->_mapfields = array_values($mapfields['gui_data']['map'][$mapfields['entity_type']]['db']);
|
114 |
-
// } // end
|
115 |
-
//
|
116 |
-
// if (!$this->getVar('fieldnames') && !$this->_mapfields) {
|
117 |
-
// $this->addException('Please define field mapping', Mage_Dataflow_Model_Convert_Exception::FATAL);
|
118 |
-
// return;
|
119 |
-
// }
|
120 |
-
//
|
121 |
-
// if ($this->getVar('adapter') && $this->getVar('method')) {
|
122 |
-
// $adapter = Mage::getModel($this->getVar('adapter'));
|
123 |
-
// }
|
124 |
-
//
|
125 |
-
// $i = 0;
|
126 |
-
// while (($line = fgetcsv($fh, null, $fDel, $fEnc)) !== FALSE) {
|
127 |
-
// $row = $this->parseRow($i, $line);
|
128 |
-
//
|
129 |
-
// if (!$this->getVar('fieldnames') && $i == 0 && $row) {
|
130 |
-
// $i = 1;
|
131 |
-
// }
|
132 |
-
//
|
133 |
-
// if ($row) {
|
134 |
-
// $loadMethod = $this->getVar('method');
|
135 |
-
// $adapter->$loadMethod(compact('i', 'row'));
|
136 |
-
// }
|
137 |
-
// $i++;
|
138 |
-
// }
|
139 |
-
//
|
140 |
-
// return $this;
|
141 |
-
}
|
142 |
-
|
143 |
-
public function parseRow($i, $line)
|
144 |
-
{
|
145 |
-
if (sizeof($line) == 1) return false;
|
146 |
-
|
147 |
-
if (0==$i) {
|
148 |
-
if ($this->getVar('fieldnames')) {
|
149 |
-
$this->_fields = $line;
|
150 |
-
return;
|
151 |
-
} else {
|
152 |
-
foreach ($line as $j=>$f) {
|
153 |
-
// $this->_fields[$j] = 'column'.($j+1);
|
154 |
-
$this->_fields[$j] = $this->_mapfields[$j];
|
155 |
-
}
|
156 |
-
}
|
157 |
-
}
|
158 |
-
|
159 |
-
$resultRow = array();
|
160 |
-
|
161 |
-
foreach ($this->_fields as $j=>$f) {
|
162 |
-
$resultRow[$f] = isset($line[$j]) ? $line[$j] : '';
|
163 |
-
}
|
164 |
-
return $resultRow;
|
165 |
-
}
|
166 |
-
|
167 |
-
/**
|
168 |
-
* Read data collection and write to temporary file
|
169 |
-
*
|
170 |
-
* @return Mage_Dataflow_Model_Convert_Parser_Csv
|
171 |
-
*/
|
172 |
-
public function unparse()
|
173 |
-
{
|
174 |
-
$batchExport = $this->getBatchExportModel()
|
175 |
-
->setBatchId($this->getBatchModel()->getId());
|
176 |
-
$fieldList = $this->getBatchModel()->getFieldList();
|
177 |
-
$batchExportIds = $batchExport->getIdCollection();
|
178 |
-
|
179 |
-
if (!$batchExportIds) {
|
180 |
-
return $this;
|
181 |
-
}
|
182 |
-
|
183 |
-
$io = $this->getBatchModel()->getIoAdapter();
|
184 |
-
$io->open();
|
185 |
-
|
186 |
-
if ($this->getVar('fieldnames')) {
|
187 |
-
$csvData = $this->getCsvString($fieldList);
|
188 |
-
$io->write($csvData);
|
189 |
-
}
|
190 |
-
|
191 |
-
foreach ($batchExportIds as $batchExportId) {
|
192 |
-
$csvData = array();
|
193 |
-
$batchExport->load($batchExportId);
|
194 |
-
$row = $batchExport->getBatchData();
|
195 |
-
|
196 |
-
foreach ($fieldList as $field) {
|
197 |
-
$csvData[] = isset($row[$field]) ? $row[$field] : '';
|
198 |
-
}
|
199 |
-
$csvData = $this->getCsvString($csvData);
|
200 |
-
$io->write($csvData);
|
201 |
-
}
|
202 |
-
|
203 |
-
$io->close();
|
204 |
-
|
205 |
-
return $this;
|
206 |
-
}
|
207 |
-
|
208 |
-
public function unparseRow($args)
|
209 |
-
{
|
210 |
-
$i = $args['i'];
|
211 |
-
$row = $args['row'];
|
212 |
-
|
213 |
-
|
214 |
-
$fDel = Mage::getStoreConfig('salesperson/export_settings/delimiter');
|
215 |
-
if ($fDel == ''){
|
216 |
-
$fDel = $this->getVar('delimiter', '\t');
|
217 |
-
}
|
218 |
-
$fEnc = Mage::getStoreConfig('salesperson/export_settings/enclosed_values');
|
219 |
-
// if ($fEnc == ''){
|
220 |
-
//$fEnc = $this->getVar('enclose', '');
|
221 |
-
// }
|
222 |
-
$fEsc = $this->getVar('escape', '\\');
|
223 |
-
$lDel = "\r\n";
|
224 |
-
|
225 |
-
if ($fDel == '\t') {
|
226 |
-
$fDel = "\t";
|
227 |
-
}
|
228 |
-
|
229 |
-
$line = array();
|
230 |
-
foreach ($this->_fields as $f) {
|
231 |
-
$v = isset($row[$f]) ? str_replace(array('"', '\\'), array($fEnc.'"', $fEsc.'\\'), $row[$f]) : '';
|
232 |
-
$line[] = $fEnc.$v.$fEnc;
|
233 |
-
}
|
234 |
-
|
235 |
-
return join($fDel, $line);
|
236 |
-
}
|
237 |
-
|
238 |
-
/**
|
239 |
-
* Retrieve csv string from array
|
240 |
-
*
|
241 |
-
* @param array $fields
|
242 |
-
* @return sting
|
243 |
-
*/
|
244 |
-
public function getCsvString($fields = array()) {
|
245 |
-
$delimiter = Mage::getStoreConfig('salesperson/export_settings/delimiter');
|
246 |
-
if ($delimiter == ''){
|
247 |
-
$delimiter = $this->getVar('delimiter', '\t');
|
248 |
-
}
|
249 |
-
$enclosure = Mage::getStoreConfig('salesperson/export_settings/enclosed_values');//$this->getVar('enclose', '');
|
250 |
-
$escapeChar = $this->getVar('escape', '\\');
|
251 |
-
|
252 |
-
if ($delimiter == '\t') {
|
253 |
-
$delimiter = "\t";
|
254 |
-
}
|
255 |
-
|
256 |
-
$str = '';
|
257 |
-
|
258 |
-
foreach ($fields as $value) {
|
259 |
-
if (strpos($value, $delimiter) !== false ||
|
260 |
-
empty($enclosure) ||
|
261 |
-
strpos($value, $enclosure) !== false ||
|
262 |
-
strpos($value, "\n") !== false ||
|
263 |
-
strpos($value, "\r") !== false ||
|
264 |
-
strpos($value, "\t") !== false ||
|
265 |
-
strpos($value, ' ') !== false) {
|
266 |
-
$str2 = $enclosure;
|
267 |
-
$escaped = 0;
|
268 |
-
$len = strlen($value);
|
269 |
-
for ($i=0;$i<$len;$i++) {
|
270 |
-
if ($value[$i] == $escapeChar) {
|
271 |
-
$escaped = 1;
|
272 |
-
} else if (!$escaped && $value[$i] == $enclosure) {
|
273 |
-
$str2 .= $enclosure;
|
274 |
-
} else {
|
275 |
-
$escaped = 0;
|
276 |
-
}
|
277 |
-
$str2 .= $value[$i];
|
278 |
-
}
|
279 |
-
$str2 .= $enclosure;
|
280 |
-
$str .= $str2.$delimiter;
|
281 |
-
} else {
|
282 |
-
$str .= $enclosure.$value.$enclosure.$delimiter;
|
283 |
-
}
|
284 |
-
}
|
285 |
-
return substr($str, 0, -1) . "\n";
|
286 |
-
}
|
287 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Celebros/Salesperson/Model/SalespersonAnalyticsApi.php
DELETED
@@ -1,118 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
*
|
8 |
-
*/
|
9 |
-
|
10 |
-
class Celebros_Salesperson_Model_SalespersonAnalyticsApi extends Mage_Core_Model_Abstract
|
11 |
-
{
|
12 |
-
protected function _construct()
|
13 |
-
{
|
14 |
-
$this->_init('salesperson/salespersonAnalyticsApi');
|
15 |
-
}
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Retrieve salesperson session
|
19 |
-
*
|
20 |
-
* @return Mage_Catalog_Model_Session
|
21 |
-
*/
|
22 |
-
protected function _getSession()
|
23 |
-
{
|
24 |
-
return Mage::getSingleton('salesperson/session');
|
25 |
-
}
|
26 |
-
|
27 |
-
public function getAnlxSearchResultFunction(){
|
28 |
-
|
29 |
-
if (Mage::getStoreConfig('salesperson/anlx_settings/ai_writer_address') == ""||
|
30 |
-
Mage::getStoreConfig('salesperson/anlx_settings/cid') == "")
|
31 |
-
return "";
|
32 |
-
|
33 |
-
/*$observer = array('ssid' => Mage::Helper('salesperson')->getSalespersonApi()->results->SearchInformation->SessionId, 'logHandle' => Mage::Helper('salesperson')->getSalespersonApi()->results->GetLogHandle());
|
34 |
-
Mage::getModel('salesperson/observer')->sendResultAnlxInfo($observer);*/
|
35 |
-
|
36 |
-
$dca = Mage::getStoreConfig('salesperson/anlx_settings/ai_writer_address');
|
37 |
-
$cid = Mage::getStoreConfig('salesperson/anlx_settings/cid');
|
38 |
-
$results = Mage::Helper('salesperson')->getSalespersonApi()->results;
|
39 |
-
$sessionId = $this->_getSession()->getSessionId();
|
40 |
-
|
41 |
-
return Mage::getModel('salesperson/api_anlx_analyticsFunctions', array("G_DATA_COLLECTOR_ADDRESS" => $dca, "G_CUSTOMER_ID" => $cid, "G_CUSTOMER_NAME" => $cid, "G_PUBLIC_KEY" => "" ) )
|
42 |
-
->Celebros_Analytics_SearchResults(
|
43 |
-
$results->SearchInformation->SessionId,//sSearchHandle
|
44 |
-
$results->GetLogHandle(),//sLogHandle
|
45 |
-
$sessionId,//sUserID
|
46 |
-
'1',//sGroupID
|
47 |
-
$sessionId,//sWebSessionID
|
48 |
-
$_SERVER['HTTP_REFERER'],//sReferrer
|
49 |
-
(bool)Mage::getStoreConfig('salesperson/anlx_settings/protocol_connection'),//bIsSSL
|
50 |
-
true//bFromQwiser
|
51 |
-
);
|
52 |
-
}
|
53 |
-
|
54 |
-
public function getAnlxResultProductClickFunction($product_id){
|
55 |
-
|
56 |
-
$dca = Mage::getStoreConfig('salesperson/anlx_settings/ai_writer_address');
|
57 |
-
$cid = Mage::getStoreConfig('salesperson/anlx_settings/cid');
|
58 |
-
|
59 |
-
if ($dca == ""|| $cid == "") return "";
|
60 |
-
|
61 |
-
$product = Mage::getSingleton('catalog/product')->load($product_id);
|
62 |
-
|
63 |
-
$categoryIds = $product->getCategoryIds();
|
64 |
-
$categoryName = Mage::getModel('catalog/category')->load($categoryIds[0])->getName();
|
65 |
-
|
66 |
-
$sessionId = $this->_getSession()->getSessionId();
|
67 |
-
$search_session_id = $this->_getSession()->getSearchSessionId();
|
68 |
-
$search_session_id = $search_session_id ? $search_session_id : 'none';
|
69 |
-
|
70 |
-
$pixel = Mage::getModel('salesperson/api_anlx_analyticsFunctions', array("G_DATA_COLLECTOR_ADDRESS" => $dca, "G_CUSTOMER_ID" => $cid, "G_CUSTOMER_NAME" => $cid, "G_PUBLIC_KEY" => "" ) )
|
71 |
-
->Celebros_Analytics_ProductDetails(
|
72 |
-
$product->getSku(), //sSKU
|
73 |
-
"", //sVariant
|
74 |
-
$product->getName(), //sName
|
75 |
-
$product->getFinalPrice(), //fPrice
|
76 |
-
$categoryName, //sCategory
|
77 |
-
$search_session_id ,//sSearchHandle
|
78 |
-
$sessionId,//sUserID
|
79 |
-
'1',//sGroupID
|
80 |
-
$sessionId,//sWebSessionID
|
81 |
-
$_SERVER['HTTP_REFERER'],//sReferrer
|
82 |
-
"", //iSourceType
|
83 |
-
"", //sSourceTypeName
|
84 |
-
(bool)Mage::getStoreConfig('salesperson/anlx_settings/protocol_connection')//bIsSSL
|
85 |
-
);
|
86 |
-
//var_dump($pixel);
|
87 |
-
|
88 |
-
if($pixel!="") {
|
89 |
-
$arr = explode("'>", $pixel);
|
90 |
-
for($i = 0; $i < count($arr); $i++) {
|
91 |
-
if($arr[$i] == "") continue;
|
92 |
-
$start = strrpos($arr[$i], "SRC='");
|
93 |
-
$url = substr($arr[$i], $start + 5);
|
94 |
-
//var_dump($url); exit();
|
95 |
-
$this->makeWebRequest($url);
|
96 |
-
}
|
97 |
-
}
|
98 |
-
|
99 |
-
return $pixel;
|
100 |
-
}
|
101 |
-
|
102 |
-
protected function makeWebRequest($url) {
|
103 |
-
|
104 |
-
$curl = curl_init();
|
105 |
-
curl_setopt($curl, CURLOPT_URL, $url);
|
106 |
-
curl_setopt($curl, CURLOPT_FAILONERROR, true);
|
107 |
-
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
108 |
-
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
|
109 |
-
curl_setopt($curl, CURLOPT_TIMEOUT,1);
|
110 |
-
$curlResult = curl_exec($curl);
|
111 |
-
$curlError = curl_error($curl);
|
112 |
-
$curlInfo = curl_getinfo($curl);
|
113 |
-
curl_close($curl);
|
114 |
-
if(!empty($curlError)) {
|
115 |
-
Mage::throwException('Celebros Analytics: ' . $curlError .' Request Url: ' . $uri);
|
116 |
-
}
|
117 |
-
}
|
118 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Celebros/Salesperson/Model/createZip.php
DELETED
@@ -1,181 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class createZip {
|
3 |
-
public $compressedData = array();
|
4 |
-
public $centralDirectory = array(); // central directory
|
5 |
-
public $endOfCentralDirectory = "\x50\x4b\x05\x06\x00\x00\x00\x00"; //end of Central directory record
|
6 |
-
public $oldOffset = 0;
|
7 |
-
|
8 |
-
public function addDirectory($directoryName) {
|
9 |
-
$directoryName = str_replace("\\", "/", $directoryName);
|
10 |
-
|
11 |
-
$feedArrayRow = "\x50\x4b\x03\x04";
|
12 |
-
$feedArrayRow .= "\x0a\x00";
|
13 |
-
$feedArrayRow .= "\x00\x00";
|
14 |
-
$feedArrayRow .= "\x00\x00";
|
15 |
-
$feedArrayRow .= "\x00\x00\x00\x00";
|
16 |
-
|
17 |
-
$feedArrayRow .= pack("V",0);
|
18 |
-
$feedArrayRow .= pack("V",0);
|
19 |
-
$feedArrayRow .= pack("V",0);
|
20 |
-
$feedArrayRow .= pack("v", strlen($directoryName) );
|
21 |
-
$feedArrayRow .= pack("v", 0 );
|
22 |
-
$feedArrayRow .= $directoryName;
|
23 |
-
|
24 |
-
$feedArrayRow .= pack("V",0);
|
25 |
-
$feedArrayRow .= pack("V",0);
|
26 |
-
$feedArrayRow .= pack("V",0);
|
27 |
-
|
28 |
-
$this -> compressedData[] = $feedArrayRow;
|
29 |
-
|
30 |
-
$newOffset = strlen(implode("", $this->compressedData));
|
31 |
-
|
32 |
-
$addCentralRecord = "\x50\x4b\x01\x02";
|
33 |
-
$addCentralRecord .="\x00\x00";
|
34 |
-
$addCentralRecord .="\x0a\x00";
|
35 |
-
$addCentralRecord .="\x00\x00";
|
36 |
-
$addCentralRecord .="\x00\x00";
|
37 |
-
$addCentralRecord .="\x00\x00\x00\x00";
|
38 |
-
$addCentralRecord .= pack("V",0);
|
39 |
-
$addCentralRecord .= pack("V",0);
|
40 |
-
$addCentralRecord .= pack("V",0);
|
41 |
-
$addCentralRecord .= pack("v", strlen($directoryName) );
|
42 |
-
$addCentralRecord .= pack("v", 0 );
|
43 |
-
$addCentralRecord .= pack("v", 0 );
|
44 |
-
$addCentralRecord .= pack("v", 0 );
|
45 |
-
$addCentralRecord .= pack("v", 0 );
|
46 |
-
$ext = "\x00\x00\x10\x00";
|
47 |
-
$ext = "\xff\xff\xff\xff";
|
48 |
-
$addCentralRecord .= pack("V", 16 );
|
49 |
-
|
50 |
-
$addCentralRecord .= pack("V", $this -> oldOffset );
|
51 |
-
$this -> oldOffset = $newOffset;
|
52 |
-
|
53 |
-
$addCentralRecord .= $directoryName;
|
54 |
-
|
55 |
-
$this -> centralDirectory[] = $addCentralRecord;
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Function to add file(s) to the specified directory in the archive
|
60 |
-
*
|
61 |
-
* @param $directoryName string
|
62 |
-
*
|
63 |
-
*/
|
64 |
-
|
65 |
-
public function addFile($data, $directoryName) {
|
66 |
-
|
67 |
-
$directoryName = str_replace("\\", "/", $directoryName);
|
68 |
-
|
69 |
-
$feedArrayRow = "\x50\x4b\x03\x04";
|
70 |
-
$feedArrayRow .= "\x14\x00";
|
71 |
-
$feedArrayRow .= "\x00\x00";
|
72 |
-
$feedArrayRow .= "\x08\x00";
|
73 |
-
$feedArrayRow .= "\x00\x00\x00\x00";
|
74 |
-
|
75 |
-
$uncompressedLength = strlen($data);
|
76 |
-
$compression = crc32($data);
|
77 |
-
$gzCompressedData = gzcompress($data);
|
78 |
-
$gzCompressedData = substr( substr($gzCompressedData, 0, strlen($gzCompressedData) - 4), 2);
|
79 |
-
$compressedLength = strlen($gzCompressedData);
|
80 |
-
$feedArrayRow .= pack("V",$compression);
|
81 |
-
$feedArrayRow .= pack("V",$compressedLength);
|
82 |
-
$feedArrayRow .= pack("V",$uncompressedLength);
|
83 |
-
$feedArrayRow .= pack("v", strlen($directoryName) );
|
84 |
-
$feedArrayRow .= pack("v", 0 );
|
85 |
-
$feedArrayRow .= $directoryName;
|
86 |
-
|
87 |
-
$feedArrayRow .= $gzCompressedData;
|
88 |
-
|
89 |
-
$feedArrayRow .= pack("V",$compression);
|
90 |
-
$feedArrayRow .= pack("V",$compressedLength);
|
91 |
-
$feedArrayRow .= pack("V",$uncompressedLength);
|
92 |
-
|
93 |
-
$this -> compressedData[] = $feedArrayRow;
|
94 |
-
|
95 |
-
$newOffset = strlen(implode("", $this->compressedData));
|
96 |
-
|
97 |
-
$addCentralRecord = "\x50\x4b\x01\x02";
|
98 |
-
$addCentralRecord .="\x00\x00";
|
99 |
-
$addCentralRecord .="\x14\x00";
|
100 |
-
$addCentralRecord .="\x00\x00";
|
101 |
-
$addCentralRecord .="\x08\x00";
|
102 |
-
$addCentralRecord .="\x00\x00\x00\x00";
|
103 |
-
$addCentralRecord .= pack("V",$compression);
|
104 |
-
$addCentralRecord .= pack("V",$compressedLength);
|
105 |
-
$addCentralRecord .= pack("V",$uncompressedLength);
|
106 |
-
$addCentralRecord .= pack("v", strlen($directoryName) );
|
107 |
-
$addCentralRecord .= pack("v", 0 );
|
108 |
-
$addCentralRecord .= pack("v", 0 );
|
109 |
-
$addCentralRecord .= pack("v", 0 );
|
110 |
-
$addCentralRecord .= pack("v", 0 );
|
111 |
-
$addCentralRecord .= pack("V", 32 );
|
112 |
-
|
113 |
-
$addCentralRecord .= pack("V", $this -> oldOffset );
|
114 |
-
$this -> oldOffset = $newOffset;
|
115 |
-
|
116 |
-
$addCentralRecord .= $directoryName;
|
117 |
-
|
118 |
-
$this -> centralDirectory[] = $addCentralRecord;
|
119 |
-
}
|
120 |
-
|
121 |
-
/**
|
122 |
-
* Fucntion to return the zip file
|
123 |
-
*
|
124 |
-
* @return zipfile (archive)
|
125 |
-
*/
|
126 |
-
|
127 |
-
public function getZippedfile() {
|
128 |
-
|
129 |
-
$data = implode("", $this -> compressedData);
|
130 |
-
$controlDirectory = implode("", $this -> centralDirectory);
|
131 |
-
|
132 |
-
return
|
133 |
-
$data.
|
134 |
-
$controlDirectory.
|
135 |
-
$this -> endOfCentralDirectory.
|
136 |
-
pack("v", sizeof($this -> centralDirectory)).
|
137 |
-
pack("v", sizeof($this -> centralDirectory)).
|
138 |
-
pack("V", strlen($controlDirectory)).
|
139 |
-
pack("V", strlen($data)).
|
140 |
-
"\x00\x00";
|
141 |
-
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
*
|
145 |
-
* Function to force the download of the archive as soon as it is created
|
146 |
-
*
|
147 |
-
* @param archiveName string - name of the created archive file
|
148 |
-
*/
|
149 |
-
|
150 |
-
public function forceDownload($archiveName) {
|
151 |
-
$headerInfo = '';
|
152 |
-
|
153 |
-
if(ini_get('zlib.output_compression')) {
|
154 |
-
ini_set('zlib.output_compression', 'Off');
|
155 |
-
}
|
156 |
-
|
157 |
-
// Security checks
|
158 |
-
if( $archiveName == "" ) {
|
159 |
-
echo "<html><title>Public Photo Directory - Download </title><body><BR><B>ERROR:</B> The download file was NOT SPECIFIED.</body></html>";
|
160 |
-
exit;
|
161 |
-
}
|
162 |
-
elseif ( ! file_exists( $archiveName ) ) {
|
163 |
-
echo "<html><title>Public Photo Directory - Download </title><body><BR><B>ERROR:</B> File not found.</body></html>";
|
164 |
-
exit;
|
165 |
-
}
|
166 |
-
|
167 |
-
header("Pragma: public");
|
168 |
-
header("Expires: 0");
|
169 |
-
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
170 |
-
header("Cache-Control: private",false);
|
171 |
-
header("Content-Type: application/zip");
|
172 |
-
header("Content-Disposition: attachment; filename=".basename($archiveName).";" );
|
173 |
-
header("Content-Transfer-Encoding: binary");
|
174 |
-
header("Content-Length: ".filesize($archiveName));
|
175 |
-
readfile("$archiveName");
|
176 |
-
|
177 |
-
}
|
178 |
-
|
179 |
-
}
|
180 |
-
|
181 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Celebros/Salesperson/controllers/ExportController.php
DELETED
@@ -1,426 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Celebros Qwiser - Magento Extension
|
4 |
-
*
|
5 |
-
* @category Celebros
|
6 |
-
* @package Celebros_Salesperson
|
7 |
-
* @author (this controller only) 3BaseGroup Co. - Miri Meltzer & Shulamit Tal (email: mirim@3basegroup.com)
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class Celebros_Salesperson_ExportController extends Mage_Core_Controller_Front_Action
|
11 |
-
{
|
12 |
-
// protected $_config;
|
13 |
-
// protected $_conn;
|
14 |
-
public function export_celebrosAction()
|
15 |
-
{
|
16 |
-
$model=Mage::getModel('salesperson/observer');
|
17 |
-
$model->export_celebros();
|
18 |
-
// $this->comments_style(1,0);
|
19 |
-
// flush();
|
20 |
-
// //-------------------
|
21 |
-
// //get the configuration
|
22 |
-
// $this->export_config($fDel,$fEnclose,$fPath,$fType,$fStore_id);
|
23 |
-
// //---------------------
|
24 |
-
// //Connect to the database
|
25 |
-
// $read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
26 |
-
// //------------------------
|
27 |
-
//
|
28 |
-
// //Create the Query to get the products:getCategory_ids
|
29 |
-
// $sql="select DISTINCT entity_id,value
|
30 |
-
// from catalog_category_entity_varchar
|
31 |
-
// where attribute_id=33";
|
32 |
-
// $result=$read->fetchAll($sql);
|
33 |
-
// $categories=array();
|
34 |
-
// foreach($result as $category)
|
35 |
-
// {
|
36 |
-
// $categories[$category["entity_id"]]=$category["value"];
|
37 |
-
// }
|
38 |
-
// //------------------------------
|
39 |
-
//
|
40 |
-
// //Create the Query to get the products:getrating
|
41 |
-
// $sql="select option_id,value
|
42 |
-
// from rating_option";
|
43 |
-
// $result=$read->fetchAll($sql);
|
44 |
-
// $points=array();
|
45 |
-
// foreach($result as $option)
|
46 |
-
// {
|
47 |
-
// $points[$option["option_id"]]=$option["value"];
|
48 |
-
// }
|
49 |
-
// //select the name of the attributes
|
50 |
-
// $this->select_attributes($attributes);
|
51 |
-
// //-------------------------------
|
52 |
-
// //try
|
53 |
-
//
|
54 |
-
// $sql="select min(entity_id) as min,max(entity_id) as max
|
55 |
-
// from catalog_product_entity";
|
56 |
-
// $result=$read->fetchAll($sql);
|
57 |
-
// $min=$result[0]["min"];
|
58 |
-
// $count=$result[0]["max"]-$min+1;
|
59 |
-
// $count=$count/1000;
|
60 |
-
// if(!is_int($count))
|
61 |
-
// $count=ceil($count);
|
62 |
-
// //Begin the output
|
63 |
-
// $rat=5;
|
64 |
-
// $cate=8;
|
65 |
-
// $stock=16;
|
66 |
-
// $num=0;
|
67 |
-
// $s="";
|
68 |
-
// //print the header
|
69 |
-
// $s=$this->header($attributes,$rat,$cate,$stock,$fDel,$fEnclose);
|
70 |
-
// //select the product with the attributes
|
71 |
-
// while($count>0)
|
72 |
-
// {
|
73 |
-
// $max=$min+999;
|
74 |
-
// $select='$products_collection=Mage::getModel("catalog/product")->getCollection()';
|
75 |
-
// foreach($attributes as $key=>$value)
|
76 |
-
// $select.='->addAttributeToSelect("'.$key.'")';
|
77 |
-
// $select.='->addAttributeToSelect("category_ids")
|
78 |
-
// ->addFieldToFilter("entity_id",array("from"=>'.$min.',"to"=>'.$max.'));';
|
79 |
-
// eval($select);
|
80 |
-
// $min=$max+1;
|
81 |
-
// $count--;
|
82 |
-
// //print the content
|
83 |
-
// $num+=count($products_collection);
|
84 |
-
// foreach($products_collection as $product)
|
85 |
-
// {
|
86 |
-
// $s.=$this->content($product,$attributes,$rat,$cate,$stock,$fDel,$fEnclose,$fStore_id,$read);
|
87 |
-
// $s.="\r\n";
|
88 |
-
// }
|
89 |
-
// unset($products_collection);
|
90 |
-
// }
|
91 |
-
//
|
92 |
-
// $this->comments_style(2,$num);
|
93 |
-
// //-------------------------------
|
94 |
-
// //export
|
95 |
-
// $s=substr_replace($s,"",strlen($s)-2);
|
96 |
-
// $f=1;
|
97 |
-
// if($fType==="ftp")
|
98 |
-
// {
|
99 |
-
// $f=$this->ftpfile($fPath,$s);
|
100 |
-
// }
|
101 |
-
// else
|
102 |
-
// {
|
103 |
-
// $file='';
|
104 |
-
// if($fPath!='')
|
105 |
-
// {
|
106 |
-
// mkdir($fPath);
|
107 |
-
// $file = $fPath.'/';
|
108 |
-
// }
|
109 |
-
// $file.='products.txt';
|
110 |
-
// $writer=fopen($file,"w");
|
111 |
-
// fwrite($writer,$s);
|
112 |
-
// // Finish output
|
113 |
-
// fclose($writer);
|
114 |
-
// }
|
115 |
-
// if($f==1)
|
116 |
-
// $this->comments_style(3,0);
|
117 |
-
// $this->comments_style(4,0);
|
118 |
-
}
|
119 |
-
// //-------------------------------------------------------------------
|
120 |
-
// public function export_config(&$fDel,&$fEnclose,&$fPath,&$fType,&$fStore_id)
|
121 |
-
// {
|
122 |
-
// $fDel = Mage::getStoreConfig('salesperson/export_settings/delimiter');
|
123 |
-
// $fEnclose=Mage::getStoreConfig('salesperson/export_settings/enclosed_values');
|
124 |
-
// $fType=Mage::getStoreConfig('salesperson/export_settings/type');
|
125 |
-
// $fPath= Mage::getStoreConfig('salesperson/export_settings/path');
|
126 |
-
// $fStore_id=Mage::getStoreConfig('salesperson/export_settings/store_id');
|
127 |
-
//
|
128 |
-
//
|
129 |
-
//
|
130 |
-
// }
|
131 |
-
// //-------------------------------------------------------------------
|
132 |
-
// public function select_attributes(&$attributes)
|
133 |
-
// {
|
134 |
-
// //select requied attributes
|
135 |
-
//
|
136 |
-
// $attributesreq=array('name'=>array('text',3),'price'=>array('price',4),'url_path'=>array("",6),
|
137 |
-
// 'image'=>array('media_image',7),'type_id'=>array('text',9),'weight'=>array('text',10),
|
138 |
-
// 'manufacturer'=>array('select',11),'color'=>array('select',12),'thumbnail'=>array('media_image',13),
|
139 |
-
// 'description'=>array('textarea',14),'short_description'=>array('textarea',15),
|
140 |
-
// 'news_from_date'=>array('date',17),'news_to_date'=>array('date',18),
|
141 |
-
// 'sku'=>array('text',19),'status'=>array('select',20),'tax_class_id'=>array('select',21));
|
142 |
-
// $i=count($attributesreq)+6;//store_1d,websites,entity_id,rating,category_ides,is_in_stock
|
143 |
-
// //select searchable or filterable attribute
|
144 |
-
//
|
145 |
-
// $attributesInfo = Mage::getResourceModel('eav/entity_attribute_collection')
|
146 |
-
// ->setEntityTypeFilter(4)
|
147 |
-
// ->AddFieldToFilter("is_searchable","1" or "is_filterable",array("in"=>array("1","2")))
|
148 |
-
// ->addSetInfo()
|
149 |
-
// ->getData();
|
150 |
-
// $attributessf=array();
|
151 |
-
// foreach($attributesInfo as $attribute)
|
152 |
-
// {
|
153 |
-
// $attributessf[$attribute["attribute_code"]]=array($attribute["frontend_input"],$i);
|
154 |
-
// $i++;
|
155 |
-
// }
|
156 |
-
// //Union 2 array
|
157 |
-
// $attributes=array_merge($attributessf,$attributesreq);
|
158 |
-
// }
|
159 |
-
// //-------------------------------------------------------------------
|
160 |
-
// public function comments_style($flg,$c)
|
161 |
-
// {
|
162 |
-
// switch($flg)
|
163 |
-
// {
|
164 |
-
// case 1:
|
165 |
-
// echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
|
166 |
-
// echo '<html><head><style type="text/css">
|
167 |
-
// ul { list-style-type:none; padding:0; margin:0; }
|
168 |
-
// li { margin-left:0; border:1px solid #ccc; margin:2px; padding:2px 2px 2px 2px; font:normal 12px sans-serif; }
|
169 |
-
// img { margin-right:5px; }
|
170 |
-
// </style><title>Salesperson Exporter</title></head>';
|
171 |
-
// echo '<body><ul>';
|
172 |
-
// echo '<li>
|
173 |
-
// <img style="margin-right: 5px;" src="'.Mage::getBaseUrl().'../skin/adminhtml/default/default/images/note_msg_icon.gif" alt="start"/>
|
174 |
-
// Starting profile execution, please wait...
|
175 |
-
// </li>';
|
176 |
-
// echo '<li style="background-color: rgb(255, 255, 221);">
|
177 |
-
// <img style="margin-right: 5px;" src="'.Mage::getBaseUrl().'../skin/adminhtml/default/default/images/fam_bullet_error.gif" alt="warnung"/>
|
178 |
-
// Warning: Please don\'t close window during importing/exporting data
|
179 |
-
// </li>';
|
180 |
-
// break;
|
181 |
-
//
|
182 |
-
// case 2:
|
183 |
-
// echo '<li style="background-color: rgb(221, 221, 255);">
|
184 |
-
// <img src="'.Mage::getBaseUrl().'../skin/adminhtml/default/default/images/fam_bullet_success.gif" alt="load"/>
|
185 |
-
// Loaded '.$c.' records
|
186 |
-
// </li>';
|
187 |
-
// break;
|
188 |
-
// case 3:
|
189 |
-
// echo '<li style="background-color: rgb(221, 221, 255);">
|
190 |
-
// <img src="'.Mage::getBaseUrl().'../skin/adminhtml/default/default/images/fam_bullet_success.gif" alt="save"/>
|
191 |
-
// Saved successfully: "products.txt"
|
192 |
-
// </li>';
|
193 |
-
// break;
|
194 |
-
// default:
|
195 |
-
// echo '<li>
|
196 |
-
// <img style="margin-right: 5px; "src="'.Mage::getBaseUrl().'../skin/adminhtml/default/default/images/note_msg_icon.gif" alt="finished"/>
|
197 |
-
// Finished profile execution.
|
198 |
-
// </li>
|
199 |
-
// </ul>
|
200 |
-
// </body>
|
201 |
-
// </html>';
|
202 |
-
//
|
203 |
-
// }
|
204 |
-
// }
|
205 |
-
// //-------------------------------------------------------------------
|
206 |
-
// public function header($attributes,$rat,$cate,$stock,$fDel,$fEnclose)
|
207 |
-
// {
|
208 |
-
// $str="";
|
209 |
-
// $header=array();
|
210 |
-
// $name=3;
|
211 |
-
// $url_path=6;
|
212 |
-
// $image=7;
|
213 |
-
// $type_id=9;
|
214 |
-
// $manufacturer=11;
|
215 |
-
// $thumbnail=13;
|
216 |
-
// foreach($attributes as $key=>$value)
|
217 |
-
// $header[$value[1]]=$fEnclose.$key.$fEnclose;
|
218 |
-
// //---------------------------
|
219 |
-
// $header[$name]=$fEnclose.'title'.$fEnclose;
|
220 |
-
// $header[$url_path]=$fEnclose.'link'.$fEnclose;
|
221 |
-
// $header[$image]=$fEnclose.'image_link'.$fEnclose;
|
222 |
-
// $header[$type_id]=$fEnclose.'type'.$fEnclose;
|
223 |
-
// $header[$manufacturer]=$fEnclose.'brand'.$fEnclose;
|
224 |
-
// $header[$thumbnail]=$fEnclose.'thumbnail_label'.$fEnclose;
|
225 |
-
// $str.=$fEnclose.'store_id'.$fEnclose.$fDel.$fEnclose.'websites'.$fEnclose.$fDel.$fEnclose.'id'.$fEnclose.$fDel;
|
226 |
-
// $header[$rat]=$fEnclose.'rating'.$fEnclose;
|
227 |
-
// $header[$cate]=$fEnclose.'category'.$fEnclose;
|
228 |
-
// $header[$stock]=$fEnclose.'is_in_stock'.$fEnclose;
|
229 |
-
// ksort($header);
|
230 |
-
// $att= implode($fDel,$header);
|
231 |
-
// $str.=$att."\r\n";
|
232 |
-
// return $str;
|
233 |
-
// }
|
234 |
-
// //------------------------------------------------------------------
|
235 |
-
// public function content($product,$attributes,$rat,$cate,$stock,$fDel,$fEnclose,$fStore_id,$read)
|
236 |
-
// {
|
237 |
-
// $products=array();
|
238 |
-
// foreach($attributes as $key=>$value)
|
239 |
-
// {
|
240 |
-
// if($value[0]==="select")
|
241 |
-
// {
|
242 |
-
// $products[$value[1]]=$fEnclose.$product->getAttributeText($key).$fEnclose;
|
243 |
-
// }
|
244 |
-
// elseif($value[0]==="media_image")
|
245 |
-
// {
|
246 |
-
// $func='get'.$key;
|
247 |
-
// $temp=$product->{$func}();
|
248 |
-
// if($temp==='no_selection')
|
249 |
-
// $products[$value[1]]=$fEnclose.$fEnclose;
|
250 |
-
// else
|
251 |
-
// $products[$value[1]]=$fEnclose.$temp.$fEnclose;
|
252 |
-
// }
|
253 |
-
// else
|
254 |
-
// {
|
255 |
-
// $func='get'.$key;
|
256 |
-
// $products[$value[1]]=$fEnclose.$product->{$func}().$fEnclose;
|
257 |
-
// }
|
258 |
-
//
|
259 |
-
//
|
260 |
-
// }
|
261 |
-
// //------------------------------
|
262 |
-
// $sql="select website_id
|
263 |
-
// from core_store
|
264 |
-
// where store_id=".$fStore_id;
|
265 |
-
// $result=$read->fetchAll($sql);
|
266 |
-
// $website_id=$result[0]["website_id"];
|
267 |
-
// $entity_id=$product->getentity_id();
|
268 |
-
//
|
269 |
-
// //Create the Query to get the products:getWebsites
|
270 |
-
//
|
271 |
-
// $products[1]=$fEnclose;
|
272 |
-
// $sql="select web.code
|
273 |
-
// from core_website web inner join catalog_product_website product
|
274 |
-
// on web.website_id=product.website_id
|
275 |
-
// where web.website_id=".$website_id." and product.product_id=".$entity_id;
|
276 |
-
// $result=$read->fetchAll($sql);
|
277 |
-
// if(!empty($result))
|
278 |
-
// {
|
279 |
-
// foreach($result as $website)
|
280 |
-
// $products[1].=$website["code"].',';
|
281 |
-
// $products[1]=substr_replace($products[1],"",strlen($products[1])-1);
|
282 |
-
// $products[1].=$fEnclose;
|
283 |
-
//
|
284 |
-
// //Create the Query to get the products:getstore_ids
|
285 |
-
// $products[0]=$fEnclose;
|
286 |
-
// $sql="select cs.store_id
|
287 |
-
// from core_store cs inner join catalogsearch_fulltext cf
|
288 |
-
// on cs.store_id=cf.store_id
|
289 |
-
// where cs.website_id=".$website_id." and cf.product_id=".$entity_id;
|
290 |
-
// $result=$read->fetchAll($sql);
|
291 |
-
// if(!empty($result))
|
292 |
-
// {
|
293 |
-
// foreach($result as $store)
|
294 |
-
// $products[0].=$store["store_id"].',';
|
295 |
-
// $products[0]=substr_replace( $products[0],"",strlen( $products[0])-1);
|
296 |
-
// }
|
297 |
-
// $products[0].=$fEnclose;
|
298 |
-
// }
|
299 |
-
// else
|
300 |
-
// {
|
301 |
-
// $products[0]=$fEnclose.$fEnclose;
|
302 |
-
// $products[1].=$fEnclose;
|
303 |
-
// }
|
304 |
-
// $products[2]=$fEnclose.$entity_id.$fEnclose;
|
305 |
-
// //Create the Query to get the products:getRating
|
306 |
-
// $products[$rat]=$fEnclose;
|
307 |
-
// $sum=0;
|
308 |
-
// $sql="select option_id
|
309 |
-
// from rating_option_vote
|
310 |
-
// where entity_pk_value=".$entity_id;
|
311 |
-
// $result=$read->fetchAll($sql);
|
312 |
-
// if(!empty($result))
|
313 |
-
// {
|
314 |
-
// foreach($result as $option)
|
315 |
-
// $sum=$sum+$points[$option["option_id"]];
|
316 |
-
// $products[$rat].=$sum;
|
317 |
-
// }
|
318 |
-
// $products[$rat].=$fEnclose;
|
319 |
-
// //Create the Query to get the products:getcategoty
|
320 |
-
// $products[$cate]=$fEnclose;
|
321 |
-
// $getcategoties=$product->getCategory_ids();
|
322 |
-
// if(!empty($getcategoties))
|
323 |
-
// {
|
324 |
-
// foreach($getcategoties as $getcategory)
|
325 |
-
// $products[$cate].=$categories[$getcategory].',';
|
326 |
-
// $products[$cate]=substr_replace($products[$cate],"",strlen($products[$cate])-1);
|
327 |
-
// }
|
328 |
-
// $products[$cate].=$fEnclose;
|
329 |
-
// //Is_in_stock
|
330 |
-
// $products[$stock]=$fEnclose.$product->getData('stock_item')->getData('is_in_stock').$fEnclose;
|
331 |
-
// //-----------------------
|
332 |
-
// ksort($products);
|
333 |
-
// $att= implode($fDel, $products);
|
334 |
-
// return $att;
|
335 |
-
// }
|
336 |
-
// //----------------------------------------------------------------
|
337 |
-
// public function ftpfile(&$fPath,$s)
|
338 |
-
// {
|
339 |
-
// $ioConfig=array();
|
340 |
-
// $ioConfig['port']='21';
|
341 |
-
// $ioConfig['passive']='false';
|
342 |
-
// $ioConfig['password']='';
|
343 |
-
// //$ioConfig['path']='';
|
344 |
-
// if (Mage::getStoreConfig('salesperson/export_settings/ftp_host')!= '')
|
345 |
-
// {
|
346 |
-
// $ioConfig['host'] =Mage::getStoreConfig('salesperson/export_settings/ftp_host');
|
347 |
-
// }
|
348 |
-
// else
|
349 |
-
// {
|
350 |
-
// echo '<li style="background-color: rgb(255, 187, 187);"><img src="'.Mage::getBaseUrl().'../skin/adminhtml/default/default/images/error_msg_icon.gif"/> Empty host specified</li>';
|
351 |
-
// return 0;
|
352 |
-
// }
|
353 |
-
// if (Mage::getStoreConfig('salesperson/export_settings/ftp_port')!= '')
|
354 |
-
// {
|
355 |
-
// $ioConfig['port'] = Mage::getStoreConfig('salesperson/export_settings/ftp_port');
|
356 |
-
// }
|
357 |
-
//
|
358 |
-
// if (Mage::getStoreConfig('salesperson/export_settings/ftp_user')!= '')
|
359 |
-
// {
|
360 |
-
// $ioConfig['user'] = Mage::getStoreConfig('salesperson/export_settings/ftp_user');
|
361 |
-
// }
|
362 |
-
// else
|
363 |
-
// {
|
364 |
-
// $ioConfig['user']='anonymous';
|
365 |
-
// $ioConfig['password']='anonymous@noserver.com';
|
366 |
-
// }
|
367 |
-
// if (Mage::getStoreConfig('salesperson/export_settings/ftp_password')!= '')
|
368 |
-
// {
|
369 |
-
// $ioConfig['password'] = Mage::getStoreConfig('salesperson/export_settings/ftp_password');
|
370 |
-
// }
|
371 |
-
//
|
372 |
-
// $ioConfig['passive'] = Mage::getStoreConfig('salesperson/export_settings/passive');
|
373 |
-
//
|
374 |
-
// if (Mage::getStoreConfig('salesperson/export_settings/path')!= '')
|
375 |
-
// {
|
376 |
-
// $ioConfig['path']= Mage::getStoreConfig('salesperson/export_settings/path');
|
377 |
-
// }
|
378 |
-
// $this->_config = $ioConfig;
|
379 |
-
// $this->_conn =ftp_connect($this->_config['host'], $this->_config['port']);
|
380 |
-
// if (!$this->_conn){
|
381 |
-
// echo '<li style="background-color: rgb(255, 187, 187);"><img src="'.Mage::getBaseUrl().'../skin/adminhtml/default/default/images/error_msg_icon.gif"/> Could not establish FTP connection, invalid host or port </li>';
|
382 |
-
// return 0;
|
383 |
-
// }
|
384 |
-
// if (!ftp_login($this->_conn, $this->_config['user'], $this->_config['password']))
|
385 |
-
// {
|
386 |
-
// $this->close();
|
387 |
-
// echo '<li style="background-color: rgb(255, 187, 187);"><img src="'.Mage::getBaseUrl().'../skin/adminhtml/default/default/images/error_msg_icon.gif"/> Invalid user name or password</li>';
|
388 |
-
// return 0;
|
389 |
-
// }
|
390 |
-
// if (!empty($this->_config['path']))
|
391 |
-
// {
|
392 |
-
// if (!ftp_chdir($this->_conn, $this->_config['path']))
|
393 |
-
// {
|
394 |
-
// $this->close();
|
395 |
-
// echo '<li style="background-color: rgb(255, 187, 187);"><img src="'.Mage::getBaseUrl().'../skin/adminhtml/default/default/images/error_msg_icon.gif"/>Invalid path</li>';
|
396 |
-
// return 0;
|
397 |
-
// }
|
398 |
-
// }
|
399 |
-
//
|
400 |
-
// if (!ftp_pasv($this->_conn, true)) {
|
401 |
-
// $this->close();
|
402 |
-
// echo '<li style="background-color: rgb(255, 187, 187);"><img src="'.Mage::getBaseUrl().'../skin/adminhtml/default/default/images/error_msg_icon.gif"/>Invalid file transfer mode</li>';
|
403 |
-
// return 0;
|
404 |
-
// }
|
405 |
-
// $stream = tmpfile();
|
406 |
-
// fputs($stream,$s);
|
407 |
-
// fseek($stream, 0);
|
408 |
-
// $file = 'products.txt';
|
409 |
-
// ftp_fput($this->_conn,$file,$stream,FTP_BINARY);
|
410 |
-
// // Finish output
|
411 |
-
// fclose($stream);
|
412 |
-
// $this->close();
|
413 |
-
// return 1;
|
414 |
-
// }
|
415 |
-
// //----------------------------------------------------
|
416 |
-
// public function close()
|
417 |
-
// {
|
418 |
-
// return ftp_close($this->_conn);
|
419 |
-
// }
|
420 |
-
}
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Celebros/Salesperson/etc/config.xml
DELETED
@@ -1,258 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* Celebros Qwiser - Magento Extension
|
5 |
-
*
|
6 |
-
* @category Celebros
|
7 |
-
* @package Celebros_Qwiser
|
8 |
-
* @author Omniscience Co. - Dan Aharon-Shalom (email: dan@omniscience.co.il)
|
9 |
-
* svn version 318
|
10 |
-
*/
|
11 |
-
-->
|
12 |
-
<config>
|
13 |
-
<modules>
|
14 |
-
<Celebros_Salesperson>
|
15 |
-
<version>0.1.1</version>
|
16 |
-
</Celebros_Salesperson>
|
17 |
-
</modules>
|
18 |
-
<global>
|
19 |
-
<models>
|
20 |
-
<salesperson>
|
21 |
-
<class>Celebros_Salesperson_Model</class>
|
22 |
-
<resourceModel>salesperson_mysql4</resourceModel>
|
23 |
-
</salesperson>
|
24 |
-
<core>
|
25 |
-
<rewrite>
|
26 |
-
<layout>Celebros_Salesperson_Model_Layout</layout>
|
27 |
-
</rewrite>
|
28 |
-
</core>
|
29 |
-
<salesperson_mysql4>
|
30 |
-
<class>Celebros_Salesperson_Model_Mysql4</class>
|
31 |
-
<entities>
|
32 |
-
<mapping>
|
33 |
-
<table>celebrosfieldsmapping</table>
|
34 |
-
</mapping>
|
35 |
-
</entities>
|
36 |
-
</salesperson_mysql4>
|
37 |
-
</models>
|
38 |
-
<blocks>
|
39 |
-
<salesperson>
|
40 |
-
<class>Celebros_Salesperson_Block</class>
|
41 |
-
</salesperson>
|
42 |
-
<adminhtml>
|
43 |
-
<rewrite>
|
44 |
-
<system_convert_profile_edit_tab_run>Celebros_Salesperson_Block_System_Convert_Profile_Edit_Tab_Run</system_convert_profile_edit_tab_run>
|
45 |
-
</rewrite>
|
46 |
-
</adminhtml>
|
47 |
-
</blocks>
|
48 |
-
<helpers>
|
49 |
-
<salesperson>
|
50 |
-
<class>Celebros_Salesperson_Helper</class>
|
51 |
-
</salesperson>
|
52 |
-
</helpers>
|
53 |
-
<resources>
|
54 |
-
<salesperson_setup>
|
55 |
-
<setup>
|
56 |
-
<module>Celebros_Salesperson</module>
|
57 |
-
</setup>
|
58 |
-
<connection>
|
59 |
-
<use>core_setup</use>
|
60 |
-
</connection>
|
61 |
-
</salesperson_setup>
|
62 |
-
<salesperson_write>
|
63 |
-
<connection>
|
64 |
-
<use>core_write</use>
|
65 |
-
</connection>
|
66 |
-
</salesperson_write>
|
67 |
-
<salesperson_read>
|
68 |
-
<connection>
|
69 |
-
<use>core_read</use>
|
70 |
-
</connection>
|
71 |
-
</salesperson_read>
|
72 |
-
</resources>
|
73 |
-
<events>
|
74 |
-
<!--<catalog_product_save_after>-->
|
75 |
-
<!-- <observers>-->
|
76 |
-
<!-- <Celebros_Salesperson_observer>-->
|
77 |
-
<!-- <type>singleton</type>-->
|
78 |
-
<!-- <class>salesperson/observer</class>-->
|
79 |
-
<!-- <method>updateStockConfig</method>-->
|
80 |
-
<!-- </Celebros_Salesperson_observer>-->
|
81 |
-
<!-- </observers>-->
|
82 |
-
<!--</catalog_product_save_after>-->
|
83 |
-
<!-- <sales_order_shipment_save_after>-->
|
84 |
-
<!-- <observers>-->
|
85 |
-
<!-- <Celebros_Salesperson_observer>-->
|
86 |
-
<!-- <type>singleton</type>-->
|
87 |
-
<!-- <class>salesperson/observer</class>-->
|
88 |
-
<!-- <method>updateStockShipment</method>-->
|
89 |
-
<!-- </Celebros_Salesperson_observer>-->
|
90 |
-
<!-- </observers>-->
|
91 |
-
<!-- </sales_order_shipment_save_after>-->
|
92 |
-
<!--<checkout_type_onepage_save_order_after>-->
|
93 |
-
<!-- <observers>-->
|
94 |
-
<!-- <Celebros_Salesperson_observer>-->
|
95 |
-
<!-- <type>singleton</type>-->
|
96 |
-
<!-- <class>salesperson/observer</class>-->
|
97 |
-
<!-- <method>updateStockOrder</method>-->
|
98 |
-
<!-- </Celebros_Salesperson_observer>-->
|
99 |
-
<!-- </observers>-->
|
100 |
-
<!--</checkout_type_onepage_save_order_after>-->
|
101 |
-
<catalog_controller_product_view>
|
102 |
-
<observers>
|
103 |
-
<Celebros_Salesperson_observer>
|
104 |
-
<type>singleton</type>
|
105 |
-
<class>salesperson/observer</class>
|
106 |
-
<method>sendProductAnlxInfo</method>
|
107 |
-
</Celebros_Salesperson_observer>
|
108 |
-
</observers>
|
109 |
-
</catalog_controller_product_view>
|
110 |
-
<salesperson_result_event>
|
111 |
-
<observers>
|
112 |
-
<Celebros_Salesperson_observer>
|
113 |
-
<type>singleton</type>
|
114 |
-
<class>salesperson/observer</class>
|
115 |
-
<method>sendResultAnlxInfo</method>
|
116 |
-
</Celebros_Salesperson_observer>
|
117 |
-
</observers>
|
118 |
-
</salesperson_result_event>
|
119 |
-
</events>
|
120 |
-
</global>
|
121 |
-
<admin>
|
122 |
-
<routers>
|
123 |
-
<salesperson>
|
124 |
-
<use>admin</use>
|
125 |
-
<args>
|
126 |
-
<module>Celebros_Salesperson</module>
|
127 |
-
<frontName>salesperson</frontName>
|
128 |
-
</args>
|
129 |
-
</salesperson>
|
130 |
-
</routers>
|
131 |
-
</admin>
|
132 |
-
<frontend>
|
133 |
-
<routers>
|
134 |
-
<salesperson>
|
135 |
-
<use>standard</use>
|
136 |
-
<args>
|
137 |
-
<module>Celebros_Salesperson</module>
|
138 |
-
<frontName>salesperson</frontName>
|
139 |
-
</args>
|
140 |
-
</salesperson>
|
141 |
-
</routers>
|
142 |
-
<!-- <translate>-->
|
143 |
-
<!-- <modules>-->
|
144 |
-
<!-- <Celebros_Salesperson>-->
|
145 |
-
<!-- <files>-->
|
146 |
-
<!-- <default>Celebros_Salesperson.csv</default>-->
|
147 |
-
<!-- </files>-->
|
148 |
-
<!-- </Celebros_Salesperson>-->
|
149 |
-
<!-- </modules>-->
|
150 |
-
<!-- </translate>-->
|
151 |
-
<layout>
|
152 |
-
<updates>
|
153 |
-
<salesperson>
|
154 |
-
<file>salesperson.xml</file>
|
155 |
-
</salesperson>
|
156 |
-
</updates>
|
157 |
-
</layout>
|
158 |
-
</frontend>
|
159 |
-
<adminhtml>
|
160 |
-
<translate>
|
161 |
-
<modules>
|
162 |
-
<Celebros_Salesperson>
|
163 |
-
<files>
|
164 |
-
<default>Celebros_Salesperson.csv</default>
|
165 |
-
</files>
|
166 |
-
</Celebros_Salesperson>
|
167 |
-
</modules>
|
168 |
-
</translate>
|
169 |
-
<menu>
|
170 |
-
<catalog>
|
171 |
-
<children>
|
172 |
-
<salesperson_mapping translate="title" module="salesperson">
|
173 |
-
<title>Salesperson Mapping</title>
|
174 |
-
<action>salesperson/adminhtml_mapping</action>
|
175 |
-
</salesperson_mapping>
|
176 |
-
</children>
|
177 |
-
</catalog>
|
178 |
-
</menu>
|
179 |
-
<acl>
|
180 |
-
<resources>
|
181 |
-
<all>
|
182 |
-
<title>Allow Everything</title>
|
183 |
-
</all>
|
184 |
-
<admin>
|
185 |
-
<children>
|
186 |
-
<system>
|
187 |
-
<children>
|
188 |
-
<config>
|
189 |
-
<children>
|
190 |
-
<salesperson>
|
191 |
-
<title>Celebros Salesperson Section</title>
|
192 |
-
</salesperson>
|
193 |
-
</children>
|
194 |
-
</config>
|
195 |
-
</children>
|
196 |
-
</system>
|
197 |
-
<catalog>
|
198 |
-
<children>
|
199 |
-
<salesperson_mapping>
|
200 |
-
<title>Salesperson Mapping</title>
|
201 |
-
</salesperson_mapping>
|
202 |
-
</children>
|
203 |
-
</catalog>
|
204 |
-
</children>
|
205 |
-
</admin>
|
206 |
-
</resources>
|
207 |
-
</acl>
|
208 |
-
<layout>
|
209 |
-
<updates>
|
210 |
-
<salesperson>
|
211 |
-
<file>salesperson.xml</file>
|
212 |
-
</salesperson>
|
213 |
-
</updates>
|
214 |
-
</layout>
|
215 |
-
</adminhtml>
|
216 |
-
|
217 |
-
<default>
|
218 |
-
<salesperson>
|
219 |
-
<general_settings>
|
220 |
-
<host></host>
|
221 |
-
<port></port>
|
222 |
-
<sitekey></sitekey>
|
223 |
-
</general_settings>
|
224 |
-
<export_settings>
|
225 |
-
<delimiter>\t</delimiter>
|
226 |
-
<enclosed_values>"</enclosed_values>
|
227 |
-
<type>file</type>
|
228 |
-
<path></path>
|
229 |
-
</export_settings>
|
230 |
-
<display_settings>
|
231 |
-
<layout>salesperson/3columns.phtml</layout>
|
232 |
-
<display_lead_top>On top</display_lead_top>
|
233 |
-
<display_non_lead>left</display_non_lead>
|
234 |
-
<breadcrumbs>1</breadcrumbs>
|
235 |
-
<display_image_lead_question>1</display_image_lead_question>
|
236 |
-
<max_lead_answers>4</max_lead_answers>
|
237 |
-
<max_non_lead_questions>4</max_non_lead_questions>
|
238 |
-
<max_non_lead_answers>4</max_non_lead_answers>
|
239 |
-
<max_non_lead_answers_side_nav>10</max_non_lead_answers_side_nav>
|
240 |
-
<show_product_count_in_lead_answers>1</show_product_count_in_lead_answers>
|
241 |
-
<show_product_count_in_non_lead_answers>1</show_product_count_in_non_lead_answers>
|
242 |
-
<alt_message>We do not have {{query}}, maybe you will be interested in {{new_query}}</alt_message>
|
243 |
-
<page_size_selector>dropdown</page_size_selector>
|
244 |
-
<sorting_selector>dropdown</sorting_selector>
|
245 |
-
<page_nav_type>multipage</page_nav_type>
|
246 |
-
<go_to_product_on_one_result>1</go_to_product_on_one_result>
|
247 |
-
</display_settings>
|
248 |
-
</salesperson>
|
249 |
-
</default>
|
250 |
-
<crontab>
|
251 |
-
<jobs>
|
252 |
-
<salesperson_export>
|
253 |
-
<schedule></schedule>
|
254 |
-
<run><model>salesperson/observer::catalogUpdate</model></run>
|
255 |
-
</salesperson_export>
|
256 |
-
</jobs>
|
257 |
-
</crontab>
|
258 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/adminhtml/default/default/layout/salesperson.xml
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<layout>
|
3 |
-
<
|
4 |
-
<update handle="
|
5 |
<reference name="content">
|
6 |
<block type="salesperson/adminhtml_mapping" name="mapping" template="salesperson/mapping.phtml"/>
|
7 |
</reference>
|
8 |
-
</
|
9 |
</layout>
|
1 |
<?xml version="1.0"?>
|
2 |
<layout>
|
3 |
+
<salesperson_admin_adminhtml_mapping_index>
|
4 |
+
<update handle="salesperson_admin_mapping_index"/>
|
5 |
<reference name="content">
|
6 |
<block type="salesperson/adminhtml_mapping" name="mapping" template="salesperson/mapping.phtml"/>
|
7 |
</reference>
|
8 |
+
</salesperson_admin_adminhtml_mapping_index>
|
9 |
</layout>
|
app/etc/modules/Celebros_Salesperson.xml
CHANGED
@@ -13,7 +13,7 @@
|
|
13 |
<modules>
|
14 |
<Celebros_Salesperson>
|
15 |
<active>true</active>
|
16 |
-
<codePool>
|
17 |
</Celebros_Salesperson>
|
18 |
</modules>
|
19 |
</config>
|
13 |
<modules>
|
14 |
<Celebros_Salesperson>
|
15 |
<active>true</active>
|
16 |
+
<codePool>community</codePool>
|
17 |
</Celebros_Salesperson>
|
18 |
</modules>
|
19 |
</config>
|
package.xml
CHANGED
@@ -1,18 +1,67 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Celebros_Salesperson_Site_Search</name>
|
4 |
-
<version>2.
|
5 |
<stability>stable</stability>
|
6 |
-
<license uri="http://www.
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>
|
10 |
-
<description
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
<compatible/>
|
17 |
-
<dependencies
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Celebros_Salesperson_Site_Search</name>
|
4 |
+
<version>2.1.1</version>
|
5 |
<stability>stable</stability>
|
6 |
+
<license uri="http://www.celebros.com/magento">ConversionPro V8</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>ConversionPro V8 for Magento is the leading Semantic Site Search, Merchandizing and Navigation for Magento</summary>
|
10 |
+
<description><p><h3>Boost your conversions 300-800% with ConversionPro V8 – Unlimited Conversion Power in One Easy to Use Suite!</h3></p>
|
11 |
+

|
12 |
+
***Celebros is the first industry partner with <a href="http://www.magentocommerce.com/consulting/">Magento ECG</a> approved plugin/code!***<p></p>
|
13 |
+
<p>
|
14 |
+

|
15 |
+
The <a href="http://www.celebros.com/magento">ConversionPro V8</a> suite of conversion technologies combines the most advanced set of tools with an easy to operate user interface to help e-commerce merchants get the most out of their site and turn more browsers into paying customers.<p /></p>
|
16 |
+

|
17 |
+
Shattering the e-commerce industry’s status quo, Celebros’ ConversionPro V8 feature rich suite of conversion technologies includes 9 conversion enhancing tools, products and features designed for e-commerce professionals by e-commerce professionals with the sole goal of conversions in-mind.
|
18 |
+

|
19 |
+
The new Celebros ConversionPro V8 is the ultimate solution for optimal site-search, navigation, dynamic merchandizing campaign building and management, on-site analytics including user action based reports, cross sell and product finder tools, and many other action rich features specifically designed to provide e-commerce professionals the best tools for their daily conversion management.<p></p>
|
20 |
+
“Site-search technology can affect the majority of a store’s traffic, making a critical impact on the store’s performance,” Roy Rubin, CEO and Founder of Magento said. “Celebros has further created the toolset for our Solution Partners to effectively integrate site-search with reviews, ratings, and other compelling content into a unique shopping experience.”
|
21 |
+
<p><strong><h3>The ConversionPro V8 suite includes the following 9 features plus more:</h3></strong>
|
22 |
+
<br>Affordable plans start at $1,500/month
|
23 |
+
<p /><h3><a href="http://www.celebros.com/products/site-search//">Semantic Site-Search:</a></h3></p>
|
24 |
+
Celebros intelligent, concept- based Site Search understands a shopper’s intent and returns relevant and accurate results every time — on the first page. This means increased Conversion Rates and revenue for online stores. The search engine response time is 0.05 seconds or less, every time!
|
25 |
+
<p><h3><a href="http://www.celebros.com/products/guided-navigation//">Guided Navigation:</a></h3></p>
|
26 |
+
Navigation is the most popular tool for online shoppers this streamlined shopping experience empowers your customers to search for products they want with the least amount of effort and the most positive results. They will be able to find products via navigation normally not accessible with navigation alone.
|
27 |
+
<p><h3><a href="http://www.celebros.com/products/auto-complete//">Auto-Complete:</a></h3></p>
|
28 |
+
AutoComplete completes your customer’s sentences as they type, returning accurate results instantly, with lightening fast speed. Your most popular products are matched to the most popular queries, showcasing the inventory you want to showcase.
|
29 |
+
<p><h3><a href="http://www.celebros.com/products/guided-navigation//">Multi-Select Navigation:</a></h3></p>
|
30 |
+
Make your store navigation even more flexible and user-friendly by enabling customer to select multiple values or attributes of the same search. the multi-select approach provides the ability to express search queries that both expand and narrow results by flexibly combining the inclusion (“AND”) and (“OR”) across all product variables, attributes and other selected information.
|
31 |
+
<p><h3><a href="http://www.celebros.com/products/merchandizing//">Dynamic Merchandizing Engine:</a></h3></p>
|
32 |
+
Promote profitable products and redirect customers where you want them to shop. In just minutes, this powerful feature allows you to create banner campaigns and redirected landing pages. For example, you can create a banner promoting free shipping for the 50 most popular search queries on your site.
|
33 |
+
<p><h3><a href="http://www.celebros.com/products/virtual-categories//">Virtual Categories:</a></h3></p>
|
34 |
+
With Conversion Pro V8′s cutting edge conversion technologies, you can create a Virtual Category to instantly introduce products as soon as a new trend hits the market or to meet a demand. Creating a Virtual Category is as easy as re-grouping products and creating new points of interest on your site.
|
35 |
+
<p><h3><a href="http://www.celebros.com/products/cross-sell//">Cross-Sell:</a></h3></p>
|
36 |
+
Imagine a feature that knows your inventory better than you do. Expose customers to more products, increase average order size! Like any good salesperson, Cross Sell’s powerful recommendation engine “knows” your inventory and suggests additional items that may be of interest to your customers while they’re shopping.
|
37 |
+
<p><h3><a href="http://www.celebros.com/products/gift-finder//">Product Finders:</a></h3></p>
|
38 |
+
Even before shoppers start their search, Gift Finder asks them specific questions in order to best direct them to what they are looking for, immediately delivering useful and personalized results based on the user input. This module helps relieve shopping related stress and increases the chances of a conversion!
|
39 |
+
<p><h3><a href="http://www.celebros.com/products/livesight-analytics//">LiveSight Analytics:</a></h3></p>
|
40 |
+
Not only will you benefit from an “under the hood” look at what’s bringing your visitors to your site you will see what those visitors are doing and why they are not converting into paid customers. With this information, you’ll be able to keep your site current, relevant and optimized.
|
41 |
+
<p></p>
|
42 |
+
</br>
|
43 |
+
<h3>About Celebros:</h3> Celebros, Inc. is the global leader in e-commerce site-search, merchandizing and conversion technologies for online retailers.
|
44 |
+

|
45 |
+
Founded in 2000, Celebros revolutionized e-commerce by creating intelligent, concept-based search for online stores. Since that time, Celebros has emerged as the industry leader in conversion technologies, developing a cutting edge search solution that employs the most advanced Natural Language Processing (NLP) technology available. Celebros is the only provider of conversion technologies that is available in seven languages.
|
46 |
+

|
47 |
+
Celebros customers include over 1,200 e-commerce retailers and merchants in eleven countries, including the United States, Europe and Asia. A number of these are among Internet Retailer’s Top 100/500 companies and represent a broad range of industry segments, revenue and catalog sizes.
|
48 |
+

|
49 |
+
The privately held Celebros is headquartered in northern New Jersey, with a Customer Management office in California. Celebros maintains its Research and Development center in Israel and has Sales and Customer Support offices in London, Munich and Paris. The Celebros management team has extensive international experience in technology, finance and sales. Currently the company has 50 employees, including professionals in the fields of software development, mathematics, computer science, linguistics and marketing.
|
50 |
+

|
51 |
+
Celebros prides itself on providing multi-language solutions, excellent service and customized solutions to fit specific customer needs using a SaaS business model.
|
52 |
+
<p></p>
|
53 |
+

|
54 |
+

|
55 |
+

|
56 |
+

|
57 |
+
<p><strong>Request a Free Demo call us today: 888-445-3266 or simply send us an email to: sales@celebros.com</strong></p>
|
58 |
+
<p> As always feel free to visit our website to learn more at: <a href="http://www.celebros.com/magento">celebros.com/magento</a></p>
|
59 |
+
<p></p>This is a licensed product a monthly fee is associated. If downloaded, the extension will not work!</description>
|
60 |
+
<notes>Version 2.1.1</notes>
|
61 |
+
<authors><author><name>Celebros LTD</name><user>jtower</user><email>jeffreyt@celebros.com</email></author></authors>
|
62 |
+
<date>2013-06-14</date>
|
63 |
+
<time>06:18:17</time>
|
64 |
+
<contents><target name="magecommunity"><dir name="Celebros"><dir name="Salesperson"><dir name="Block"><dir name="Adminhtml"><file name="Mapping.php" hash="ff801865d3918a6cae4d8fc2a6802869"/></dir><dir name="Analytics"><file name="View.php" hash="541d1cd45d57f1324c37d93b49cbaba6"/></dir><dir name="Checkout"><dir name="Cart"><file name="Crosssell.php" hash="8686564a5f5021580bb6dd8c10b65949"/></dir></dir><dir name="Giftfinder"><file name="View.php" hash="ba2790c97e216e20453aeb3b096eebbf"/></dir><dir name="Layer"><file name="State.php" hash="b6ae1b1a5cfd6c3091aa0f2bbdc0ae1d"/><file name="View.php" hash="14aefc0899a2640257b200bf6f47dcfe"/><dir name="Widget"><file name="RadioButtonQuestion.php" hash="49adf09bd4a92aab77e017af070f2327"/></dir></dir><file name="Layer.php" hash="e71b707aa7a39cd5b007f2da245ef7d8"/><file name="Navigation.php" hash="715b57ac8b7b3e118bf60a7c0837ac08"/><dir name="Product"><file name="Abstract.php" hash="52c5f91e418135040aee2e29bd5afeb3"/><dir name="List"><dir name="Toolbar"><file name="Pager.php" hash="2ee0468ad0b78621c4946053b8ab69f0"/></dir><file name="Toolbar.php" hash="c2a8e7babbe04f68fd467b5415600447"/></dir><file name="List.php" hash="d3a98ebec74903f71f9a816028ce1e7d"/></dir><file name="Result.php" hash="86c3890802b46192f7c3020bdb4a2008"/><dir name="Review"><file name="Helper.php" hash="f024d969bb1b4004033c1ec0bc64c561"/></dir><dir name="System"><dir name="Convert"><dir name="Profile"><dir name="Edit"><dir name="Tab"><file name="Run.php" hash="4eedd0d1ef6aff044f2dfc941abec6f9"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><dir name="Checkout"><file name="Cart.php" hash="6c179d121f6b065081c040f175648952"/></dir><file name="Data.php" hash="f5d959df02e2b4b4e21f0d622be32f7c"/><file name="Mapping.php" hash="e49786a02e0bb81f0a78d2828178ca07"/><dir name="Product"><file name="Compare.php" hash="86578b78e459de1375dbb568e21f63e5"/></dir><dir name="Wishlist"><file name="Data.php" hash="192f51e3491838efb8e5bd4ef84788e3"/></dir></dir><dir name="Model"><dir name="Api"><file name="DomXMLPhp4ToPhp5.php" hash="b4f9ad082b5f338eaebefa79dfafe9e9"/><file name="QwiserAnswer.php" hash="da15cd6ef546d30ebd4bca915e8c00fc"/><file name="QwiserAnsweredAnswer.php" hash="78a779727d3be36a21ab412e78d7bfff"/><file name="QwiserAnsweredAnswers.php" hash="547cf47c57131af1f65666363ae9df1c"/><file name="QwiserAnswers.php" hash="df77175156d61b092313d1714c523dca"/><file name="QwiserConcept.php" hash="8f0a9e5bbb1a7888c36a8db217afbc22"/><file name="QwiserConcepts.php" hash="cfb4b6edc6d7e75c07c5e71f19a098c1"/><file name="QwiserProduct.php" hash="d7d88d266375c0f88964ca9761afbb91"/><file name="QwiserProductAnswer.php" hash="51e33c92e2652f471700d7846984d82a"/><file name="QwiserProductAnswers.php" hash="48adfa28c92220ce73dd786b172cd239"/><file name="QwiserProductField.php" hash="36b899eb283690ceafe04df07b59e522"/><file name="QwiserProductFields.php" hash="446d11763a5c9302f454a04a162e25e7"/><file name="QwiserProducts.php" hash="11cc9fd76808ee5bb245021960634a83"/><file name="QwiserQuestion.php" hash="1368de732ca3ac0d3574658c09bea9cb"/><file name="QwiserQuestions.php" hash="f6860769118e0cc37ad3b17a39aea0ba"/><file name="QwiserSearchPath.php" hash="1f64a392724b8389ceb7aa41d199133c"/><file name="QwiserSearchPathEntry.php" hash="351dae7b52175a76fdb69a17128bf163"/><file name="QwiserSearchResults.php" hash="a89f75edb49a174113a7a6a202285d94"/><file name="QwiserSpellerInformation.php" hash="681c52e16cfcc286a24e733f903f0851"/><file name="SearchInformation.php" hash="9fb8632e4db8cb6fd41964392881753f"/><file name="SortingOptions.php" hash="c17b7df2af2c01e2769820019489f048"/><file name="SpecialCasesDetectedInThisSession.php" hash="ac43ee6ad9c726d5514f2e6a2ccd6a2b"/></dir><dir name="Catalog"><file name="Category.php" hash="c03504165d71448a8eafa8a5e1b886f6"/><file name="Url.php" hash="82fc851713cb25082ab7ef6864389c36"/></dir><dir name="Convert"><dir name="Adapter"><file name="Io.php" hash="d0b997ed57057a8060260c68097ee0e9"/></dir><dir name="Mapper"><file name="Column.php" hash="91f964c6d2c68f7a6e6a6139443017f0"/></dir><dir name="Parser"><file name="Product.php" hash="6937803cbac8891a5999e65d3af53f38"/></dir></dir><dir name="Layer"><file name="State.php" hash="2064b364ae837c88cda02a6b0f5105e1"/></dir><file name="Layer.php" hash="5afe1c11364dd2e9ab159d78519fbfe3"/><file name="Layout.php" hash="c65cc6d4a86a43a0304ab381614fd836"/><file name="Mapping.php" hash="28526c794d7c95c7084933732ac446ff"/><dir name="Mysql4"><dir name="Mapping"><file name="Collection.php" hash="387432302e021e933f9b2e3c01714948"/></dir><file name="Mapping.php" hash="fc87ace7111c20efcfa37c311510f274"/><file name="Qwiser.php" hash="80f3910b4f001fbca8d7699905e23965"/></dir><file name="Observer.php" hash="31e7d4cbcaa3f873bfd07541a1a625af"/><file name="ObserverLarge.php" hash="0b82ed1fc8fd7d5131aac6f93bb99631"/><file name="Product.php" hash="12fde5caf6fd2e39b20690ff00bb1905"/><file name="SalespersonCrossSellApi.php" hash="41933110cdcd7efeae715a1e2f5fb3d1"/><file name="SalespersonSearchApi.php" hash="933e6cff8bbf9c5ed30c8efed2e7c0c8"/><file name="Session.php" hash="e5a917b466729cd6e70682cbcd2e06d0"/><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Export"><file name="Cron.php" hash="7231f0c3b9b43575636117b62c76bf87"/></dir><dir name="Navigationtosearch"><file name="Enable.php" hash="7811660900b37258674fbf0a12a634a4"/></dir></dir><dir name="Source"><file name="Fileftp.php" hash="3c1440c0fcb2325479e3c6527c536173"/><file name="Giftfindertypes.php" hash="08c4a9fb9c2a3ea9687762c44876e73d"/><file name="Layouts.php" hash="bdb3180c40ad790e9a3b4b5ef85f21fc"/><file name="Lead.php" hash="db71b8a3e3dd0fb700a163170a7b16ce"/><file name="Navigationtosearch.php" hash="76ed5efe7b1f7409f2b445376474a72d"/><file name="Nonlead.php" hash="34ccbfab09a460b6e060a4477a83b5b5"/><file name="Pagenavtype.php" hash="c9a117852c1574a4177843cec93086d1"/><file name="Pricetype.php" hash="4e71009c0edbf8c7c95eb2952b4f506d"/><file name="Selectortype.php" hash="1fbb4bb1fad68e0e3feb41161530f417"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="MappingController.php" hash="e097b0583c6fa21104b82ec291f4cdb0"/></dir><file name="ExportController.php" hash="d3fdecb2e5ade72ca68e0b0b6b23765d"/><file name="GiftfinderController.php" hash="d1bbf08a928c89fd24b4a367972bb19c"/><file name="IndexController.php" hash="90874343e84b7f96ef5bdb0a177b1c6c"/><file name="ResultController.php" hash="0d2947998a42afc1949063d5cd6495b1"/><file name="TestController.php" hash="4303e9da7c6b40b6d141594deb1cc00a"/></dir><dir name="docs"><file name="Celebros Salesperson - Magento plugin configuration manual 2011 extension.pdf" hash="9264005cd901706b571e3d26882674df"/><file name="Release_notes.txt" hash="6802986bec70139f0ec4bfdfb16e7c7b"/></dir><dir name="etc"><file name="config.xml" hash="5555deb472991c78b30ee332bac28049"/><file name="config.xml.gpg" hash="a566ec387f20167268f5c67a9be2b349"/><file name="system.xml" hash="0b73c7ae13b6c6e8b348476c6974881e"/></dir><dir name="sql"><dir name="salesperson_setup"><file name="mysql4-install-0.1.0.php" hash="9384bfb835477b5a95cb761455942674"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="234be34ebf9a1f92f4a92b0cca4e72cd"/><file name="mysql4-upgrade-0.1.1-0.1.2.php" hash="d08e30994e0bef3ad166274166fc1446"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="salesperson.xml" hash="b901ac6618ff5f115dd135781e778d6c"/></dir><dir name="template"><dir name="salesperson"><file name="mapping.phtml" hash="6c0eb3afa5ebec9adaa46fa1a8bde389"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Celebros_Salesperson.xml" hash="1314435f34ded9e59a6554404785cbdf"/></dir></target></contents>
|
65 |
<compatible/>
|
66 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.4.0.0</min><max>1.7</max></package><package><name>Mage_Core_Modules</name><channel>enterprise</channel><min>1.10</min><max>1.12</max></package></required></dependencies>
|
67 |
</package>
|