Version Notes
The M2E Pro extension fully integrates Magento into eBay, Amazon and Rakuten platforms. This allows quick and simple creation as well as management of product listings (inc. automated synchronization of stock levels, pricing, and product details), import of eBay and Amazon order, automated feedback posting for buyers and many other tasks which significantly reduce time required for listing maintenance.
The extension interacts with all 23 major eBay and 7 Amazon marketplaces. It supports multiple eBay/Amazon accounts and multiple Magento stores.
Download this release
Release Info
Developer | Magento Core Team |
Extension | m2epro_ebay_magento |
Version | 6.3.1 |
Comparing to | |
See all releases |
Code changes from version 1.0.3 to 6.3.1
- app/code/community/Ess/M2ePro/Block/Adminhtml/Account/Grid.php +147 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Account/Switcher.php +63 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Category/Grid.php +104 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Account.php +71 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Account/Grid.php +105 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Account/Help.php +18 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Account/Edit.php +144 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Account/Edit/Form.php +33 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Account/Edit/Tabs.php +49 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Account/Edit/Tabs/General.php +50 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Account/Edit/Tabs/ListingOther.php +27 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Account/Edit/Tabs/Order.php +85 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing.php +128 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/Form.php +22 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/NewAsin.php +130 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/NewAsin/Category.php +159 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/NewAsin/Category/Grid.php +342 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/NewAsin/Manual.php +161 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/NewAsin/Manual/Grid.php +356 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/NewAsin/Manual/SkipPopup.php +38 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/Review.php +28 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/SearchAsin.php +270 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/SearchAsin/Grid.php +684 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/SearchAsin/Help.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/SearchAsin/NewAsinPopup.php +38 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/SearchAsin/SearchSettings.php +71 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/Tabs/General.php +25 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/Tabs/Search.php +45 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/Tabs/Selling.php +82 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/AutoAction/Mode.php +11 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/AutoAction/Mode/Category.php +23 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/AutoAction/Mode/Category/Form.php +35 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/AutoAction/Mode/Category/Group/Grid.php +16 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/AutoAction/Mode/Global.php +21 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/AutoAction/Mode/Website.php +21 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Edit.php +166 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Edit/Form.php +35 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Edit/Tabs.php +44 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Filter.php +114 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Grid.php +325 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Other/Grid.php +567 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Product.php +97 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Product/Help.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/ProductSearch/Grid.php +529 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/ProductSearch/Main.php +61 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/ProductSearch/Menu.php +88 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/ProductSearch/SuggestedAsinGridHelp.php +21 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Search.php +161 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Search/Grid.php +531 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/TemplateDescription/Grid.php +416 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/TemplateDescription/Main.php +79 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Variation/Product/Manage/Tabs.php +143 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Variation/Product/Manage/Tabs/Settings.php +682 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Variation/Product/Manage/Tabs/Variations.php +37 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Variation/Product/Manage/Tabs/Variations/Child/Form.php +398 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Variation/Product/Manage/Tabs/Variations/Grid.php +1512 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Variation/Product/Manage/Tabs/Variations/Help.php +21 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Variation/Product/SwitchToIndividualPopup.php +47 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Variation/Product/SwitchToParentPopup.php +47 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View.php +744 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View/Amazon/Grid.php +1421 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View/Help.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View/ListingSwitcher.php +18 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View/Magento/Grid.php +336 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View/ModeSwitcher.php +41 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View/Sellercentral/Grid.php +920 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Marketplace/Form.php +90 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Order/Edit/ShippingAddress.php +65 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Order/Edit/ShippingAddress/Form.php +55 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Order/Grid.php +558 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Order/View.php +105 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Order/View/Form.php +110 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Order/View/Item.php +302 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Synchronization/Form.php +234 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description.php +70 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Category/Chooser/Edit.php +99 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Category/Chooser/Tabs.php +71 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Category/Chooser/Tabs/Browse.php +28 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Category/Chooser/Tabs/Recent.php +42 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Category/Chooser/Tabs/Search.php +28 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Category/Specific/Add.php +71 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Category/Specific/Add/Grid.php +248 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Edit.php +103 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Edit/Form.php +39 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Edit/Tabs.php +58 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Edit/Tabs/Definition.php +135 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Edit/Tabs/General.php +60 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Edit/Tabs/Specifics.php +36 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Grid.php +223 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Help.php +18 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/SellingFormat/Edit.php +101 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/SellingFormat/Edit/Form.php +54 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Synchronization/Edit.php +106 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Synchronization/Edit/Form.php +34 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Synchronization/Edit/Tabs.php +61 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Synchronization/Edit/Tabs/List.php +21 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Synchronization/Edit/Tabs/Relist.php +21 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Synchronization/Edit/Tabs/Revise.php +21 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Synchronization/Edit/Tabs/Stop.php +21 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Account/Edit.php +150 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Account/Edit/Form.php +33 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Account/Edit/Tabs.php +52 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Account/Edit/Tabs/General.php +76 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Account/Edit/Tabs/ListingOther.php +27 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Account/Edit/Tabs/Order.php +85 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing.php +135 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Add/Form.php +22 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Add/Tabs/General.php +25 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Add/Tabs/Search.php +42 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Add/Tabs/Selling.php +84 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/AutoAction/Mode.php +11 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/AutoAction/Mode/Category.php +23 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/AutoAction/Mode/Category/Form.php +11 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/AutoAction/Mode/Category/Group/Grid.php +16 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/AutoAction/Mode/Global.php +11 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/AutoAction/Mode/Website.php +11 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Edit.php +166 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Edit/Form.php +35 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Edit/Tabs.php +44 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Filter.php +114 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Grid.php +320 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Other/Grid.php +530 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Product.php +96 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Product/Help.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/ProductSearch/Grid.php +254 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/ProductSearch/Main.php +50 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/ProductSearch/Menu.php +30 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Search.php +160 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Search/Grid.php +458 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/View.php +596 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/View/Grid.php +972 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/View/Help.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/View/ListingSwitcher.php +18 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Order/Edit/ShippingAddress.php +65 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Order/Edit/ShippingAddress/Form.php +56 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Order/Grid.php +434 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Order/View.php +72 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Order/View/Form.php +112 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Order/View/Item.php +238 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Synchronization/Form.php +236 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct.php +78 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Edit.php +87 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Edit/Form.php +66 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Edit/Tabs.php +52 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Edit/Tabs/Attributes.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Edit/Tabs/Description.php +73 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Edit/Tabs/General.php +122 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Grid.php +195 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Help.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Search/Grid.php +158 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/SellingFormat/Edit.php +101 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/SellingFormat/Edit/Form.php +50 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/Synchronization/Edit.php +102 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/Synchronization/Edit/Form.php +33 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/Synchronization/Edit/Tabs.php +56 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/Synchronization/Edit/Tabs/List.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/Synchronization/Edit/Tabs/Relist.php +21 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/Synchronization/Edit/Tabs/Revise.php +21 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/Synchronization/Edit/Tabs/Stop.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Component/Abstract.php +322 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Component/Grid/Container.php +91 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Component/Tabs.php +35 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Component/Tabs/Container.php +19 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing.php +264 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/Form.php +93 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/Main.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/Review.php +92 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/SourceCategory.php +127 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/SourceMode.php +64 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/SourceMode/Form.php +56 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/SourceProduct.php +126 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/StepOne.php +57 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/StepThree.php +70 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/StepTwo.php +72 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/Tabs/General.php +54 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/Tabs/Search.php +73 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/Tabs/Selling.php +137 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Breadcrumb.php +21 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Category/Tree.php +379 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Help.php +14 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Log.php +241 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Log/Grid.php +51 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Log/Help.php +18 -0
app/code/community/Ess/M2ePro/Block/Adminhtml/Account/Grid.php
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
abstract class Ess_M2ePro_Block_Adminhtml_Account_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
protected $viewComponentHelper = NULL;
|
10 |
+
|
11 |
+
// ####################################
|
12 |
+
|
13 |
+
public function __construct()
|
14 |
+
{
|
15 |
+
parent::__construct();
|
16 |
+
|
17 |
+
// Initialize view
|
18 |
+
//------------------------------
|
19 |
+
$view = Mage::helper('M2ePro/View')->getCurrentView();
|
20 |
+
$this->viewComponentHelper = Mage::helper('M2ePro/View')->getComponentHelper($view);
|
21 |
+
//------------------------------
|
22 |
+
|
23 |
+
// Initialization block
|
24 |
+
//------------------------------
|
25 |
+
$this->setId($view . 'AccountGrid');
|
26 |
+
//------------------------------
|
27 |
+
|
28 |
+
// Set default values
|
29 |
+
//------------------------------
|
30 |
+
$this->setDefaultSort('title');
|
31 |
+
$this->setDefaultDir('ASC');
|
32 |
+
$this->setSaveParametersInSession(true);
|
33 |
+
$this->setUseAjax(true);
|
34 |
+
//------------------------------
|
35 |
+
}
|
36 |
+
|
37 |
+
// ####################################
|
38 |
+
|
39 |
+
protected function _prepareCollection()
|
40 |
+
{
|
41 |
+
// Get collection of accounts
|
42 |
+
$collection = $this->getCollection();
|
43 |
+
if (is_null($collection)) {
|
44 |
+
$collection = Mage::getModel('M2ePro/Account')->getCollection();
|
45 |
+
}
|
46 |
+
|
47 |
+
$components = $this->viewComponentHelper->getActiveComponents();
|
48 |
+
$collection->addFieldToFilter('main_table.component_mode', array('in'=>$components));
|
49 |
+
|
50 |
+
// Set collection to grid
|
51 |
+
$this->setCollection($collection);
|
52 |
+
|
53 |
+
return parent::_prepareCollection();
|
54 |
+
}
|
55 |
+
|
56 |
+
protected function _prepareColumns()
|
57 |
+
{
|
58 |
+
$this->addColumn('create_date', array(
|
59 |
+
'header' => Mage::helper('M2ePro')->__('Creation Date'),
|
60 |
+
'align' => 'left',
|
61 |
+
'width' => '150px',
|
62 |
+
'type' => 'datetime',
|
63 |
+
'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM),
|
64 |
+
'index' => 'create_date',
|
65 |
+
'filter_index' => 'main_table.create_date'
|
66 |
+
));
|
67 |
+
|
68 |
+
$this->addColumn('update_date', array(
|
69 |
+
'header' => Mage::helper('M2ePro')->__('Update Date'),
|
70 |
+
'align' => 'left',
|
71 |
+
'width' => '150px',
|
72 |
+
'type' => 'datetime',
|
73 |
+
'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM),
|
74 |
+
'index' => 'update_date',
|
75 |
+
'filter_index' => 'main_table.update_date'
|
76 |
+
));
|
77 |
+
|
78 |
+
$confirm = 'Attention! By Deleting Account you delete all information on it from M2E Pro Server. ';
|
79 |
+
$confirm .= 'This will cause inappropriate work of all Accounts\' copies.';
|
80 |
+
$confirm = Mage::helper('M2ePro')->__($confirm);
|
81 |
+
|
82 |
+
$this->addColumn('actions', array(
|
83 |
+
'header' => Mage::helper('M2ePro')->__('Actions'),
|
84 |
+
'align' => 'left',
|
85 |
+
'width' => '150px',
|
86 |
+
'type' => 'action',
|
87 |
+
'index' => 'actions',
|
88 |
+
'filter' => false,
|
89 |
+
'sortable' => false,
|
90 |
+
'getter' => 'getId',
|
91 |
+
'actions' => array(
|
92 |
+
array(
|
93 |
+
'caption' => Mage::helper('M2ePro')->__('Edit'),
|
94 |
+
'url' => array('base'=> '*/*/edit'),
|
95 |
+
'field' => 'id'
|
96 |
+
),
|
97 |
+
array(
|
98 |
+
'caption' => Mage::helper('M2ePro')->__('Delete'),
|
99 |
+
'url' => array('base'=> '*/*/delete'),
|
100 |
+
'field' => 'id',
|
101 |
+
'confirm' => $confirm
|
102 |
+
)
|
103 |
+
)
|
104 |
+
));
|
105 |
+
|
106 |
+
return parent::_prepareColumns();
|
107 |
+
}
|
108 |
+
|
109 |
+
protected function _prepareMassaction()
|
110 |
+
{
|
111 |
+
// Set massaction identifiers
|
112 |
+
//--------------------------------
|
113 |
+
$this->setMassactionIdField('main_table.id');
|
114 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
115 |
+
//--------------------------------
|
116 |
+
|
117 |
+
// Set delete action
|
118 |
+
//--------------------------------
|
119 |
+
$confirm = 'Attention! By deleting Account you delete all information on it from M2E Pro Server. ';
|
120 |
+
$confirm .= 'This will cause inappropriate work of all Accounts\' copies.';
|
121 |
+
$confirm = Mage::helper('M2ePro')->__($confirm);
|
122 |
+
|
123 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
124 |
+
'label' => Mage::helper('M2ePro')->__('Delete'),
|
125 |
+
'url' => $this->getUrl('*/*/delete'),
|
126 |
+
'confirm' => $confirm
|
127 |
+
));
|
128 |
+
//--------------------------------
|
129 |
+
|
130 |
+
return parent::_prepareMassaction();
|
131 |
+
}
|
132 |
+
|
133 |
+
// ####################################
|
134 |
+
|
135 |
+
public function getGridUrl()
|
136 |
+
{
|
137 |
+
return $this->getUrl('*/*/accountGrid', array('_current'=>true));
|
138 |
+
}
|
139 |
+
|
140 |
+
public function getRowUrl($row)
|
141 |
+
{
|
142 |
+
return Mage::helper('M2ePro/View')
|
143 |
+
->getUrl($row, 'account', 'edit', array('id' => $row->getData('id')));
|
144 |
+
}
|
145 |
+
|
146 |
+
// ####################################
|
147 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Account/Switcher.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Account_Switcher extends Ess_M2ePro_Block_Adminhtml_Component_Switcher
|
8 |
+
{
|
9 |
+
protected $paramName = 'account';
|
10 |
+
|
11 |
+
// ########################################
|
12 |
+
|
13 |
+
public function getLabel()
|
14 |
+
{
|
15 |
+
return Mage::helper('M2ePro')->__($this->getComponentLabel('%component% Account'));
|
16 |
+
}
|
17 |
+
|
18 |
+
public function getItems()
|
19 |
+
{
|
20 |
+
$collection = Mage::getModel('M2ePro/Account')->getCollection()
|
21 |
+
->setOrder('component_mode', 'ASC')
|
22 |
+
->setOrder('title', 'ASC');
|
23 |
+
|
24 |
+
if (!is_null($this->getData('component_mode'))) {
|
25 |
+
$collection->addFieldToFilter('component_mode', $this->getData('component_mode'));
|
26 |
+
}
|
27 |
+
|
28 |
+
if ($collection->getSize() < 2) {
|
29 |
+
return array();
|
30 |
+
}
|
31 |
+
|
32 |
+
$items = array();
|
33 |
+
|
34 |
+
foreach ($collection as $account) {
|
35 |
+
/** @var $account Ess_M2ePro_Model_Account */
|
36 |
+
|
37 |
+
if (!isset($items[$account->getComponentMode()]['label'])) {
|
38 |
+
$label = '';
|
39 |
+
if (isset($componentTitles[$account->getComponentMode()])) {
|
40 |
+
$label = $componentTitles[$account->getComponentMode()];
|
41 |
+
}
|
42 |
+
|
43 |
+
$items[$account->getComponentMode()]['label'] = $label;
|
44 |
+
}
|
45 |
+
|
46 |
+
$items[$account->getComponentMode()]['value'][] = array(
|
47 |
+
'value' => $account->getId(),
|
48 |
+
'label' => $account->getTitle()
|
49 |
+
);
|
50 |
+
}
|
51 |
+
|
52 |
+
return $items;
|
53 |
+
}
|
54 |
+
|
55 |
+
// ########################################
|
56 |
+
|
57 |
+
public function getDefaultOptionName()
|
58 |
+
{
|
59 |
+
return Mage::helper('M2ePro')->__('All Accounts');
|
60 |
+
}
|
61 |
+
|
62 |
+
// ########################################
|
63 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Category/Grid.php
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Category_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
// ####################################
|
10 |
+
|
11 |
+
public function getStoreId()
|
12 |
+
{
|
13 |
+
return !is_null($this->getData('store_id')) ? $this->getData('store_id') : Mage_Core_Model_App::ADMIN_STORE_ID;
|
14 |
+
}
|
15 |
+
|
16 |
+
public function setStoreId($storeId)
|
17 |
+
{
|
18 |
+
$this->setData('store_id',$storeId);
|
19 |
+
return $this;
|
20 |
+
}
|
21 |
+
|
22 |
+
// ####################################
|
23 |
+
|
24 |
+
public function setCollection($collection)
|
25 |
+
{
|
26 |
+
$this->_prepareCache(clone $collection);
|
27 |
+
parent::setCollection($collection);
|
28 |
+
}
|
29 |
+
|
30 |
+
protected function _prepareCache($collection)
|
31 |
+
{
|
32 |
+
$stmt = $collection->getSelect()->query();
|
33 |
+
|
34 |
+
$ids = array();
|
35 |
+
foreach ($stmt as $item) {
|
36 |
+
$ids = array_merge($ids,array_map('intval',explode('/',$item['path'])));
|
37 |
+
}
|
38 |
+
$ids = array_unique($ids);
|
39 |
+
|
40 |
+
if (empty($ids)) {
|
41 |
+
return;
|
42 |
+
}
|
43 |
+
|
44 |
+
/* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
|
45 |
+
$attribute = $collection->getFirstItem()->getResource()->getAttribute('name');
|
46 |
+
|
47 |
+
$connRead = Mage::getSingleton('core/resource')->getConnection('core_read');
|
48 |
+
|
49 |
+
$tableName = Mage_Catalog_Model_Category::ENTITY . '_entity_' . $attribute->getBackendType();
|
50 |
+
|
51 |
+
$dbSelect1 = $connRead
|
52 |
+
->select()
|
53 |
+
->from(Mage::getSingleton('core/resource')->getTableName($tableName), new Zend_Db_Expr('MAX(`store_id`)'))
|
54 |
+
->where("`entity_id` = `ccev`.`entity_id`")
|
55 |
+
->where("`attribute_id` = `ccev`.`attribute_id`")
|
56 |
+
->where("`store_id` = 0 OR `store_id` = ?",$this->getStoreId());
|
57 |
+
|
58 |
+
$dbSelect2 = $connRead
|
59 |
+
->select()
|
60 |
+
->from(
|
61 |
+
array('ccev' => Mage::getSingleton('core/resource')->getTableName($tableName)),
|
62 |
+
array('name' => 'value','category_id' => 'entity_id')
|
63 |
+
)
|
64 |
+
->where('ccev.entity_id IN ('.implode(',',$ids).')')
|
65 |
+
->where('ccev.attribute_id = ?', $attribute->getAttributeId())
|
66 |
+
->where('ccev.entity_type_id = ?', $attribute->getEntityTypeId())
|
67 |
+
->where('ccev.store_id = ('.$dbSelect1->__toString().')');
|
68 |
+
|
69 |
+
$cacheData = array();
|
70 |
+
|
71 |
+
foreach ($connRead->fetchAll($dbSelect2) as $row) {
|
72 |
+
$cacheData[$row['category_id']] = $row['name'];
|
73 |
+
}
|
74 |
+
$this->setData('categories_cache', $cacheData);
|
75 |
+
}
|
76 |
+
|
77 |
+
// ####################################
|
78 |
+
|
79 |
+
public function callbackColumnMagentoCategory($value, $row, $column, $isExport)
|
80 |
+
{
|
81 |
+
$ids = explode('/',$row->getPath());
|
82 |
+
|
83 |
+
$categoriesCache = $this->getData('categories_cache');
|
84 |
+
$path = '';
|
85 |
+
foreach ($ids as $id) {
|
86 |
+
if (!isset($categoriesCache[$id])) {
|
87 |
+
continue;
|
88 |
+
}
|
89 |
+
$path != '' && $path .= ' > ';
|
90 |
+
$path .= $categoriesCache[$id];
|
91 |
+
}
|
92 |
+
|
93 |
+
return Mage::helper('M2ePro')->escapeHtml($path);
|
94 |
+
}
|
95 |
+
|
96 |
+
// ####################################
|
97 |
+
|
98 |
+
public function getMultipleRows($item)
|
99 |
+
{
|
100 |
+
return false;
|
101 |
+
}
|
102 |
+
|
103 |
+
// ####################################
|
104 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Account.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Account extends Ess_M2ePro_Block_Adminhtml_Common_Component_Grid_Container
|
8 |
+
{
|
9 |
+
// ########################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('account');
|
18 |
+
$this->_blockGroup = 'M2ePro';
|
19 |
+
$this->_controller = 'adminhtml_common_account';
|
20 |
+
//------------------------------
|
21 |
+
|
22 |
+
// Set header text
|
23 |
+
//------------------------------
|
24 |
+
$this->_headerText = Mage::helper('M2ePro')->__('Accounts');
|
25 |
+
//------------------------------
|
26 |
+
|
27 |
+
// Set buttons actions
|
28 |
+
//------------------------------
|
29 |
+
$this->removeButton('back');
|
30 |
+
$this->removeButton('reset');
|
31 |
+
$this->removeButton('delete');
|
32 |
+
$this->removeButton('add');
|
33 |
+
$this->removeButton('save');
|
34 |
+
$this->removeButton('edit');
|
35 |
+
|
36 |
+
//------------------------------
|
37 |
+
$this->_addButton('add', array(
|
38 |
+
'label' => Mage::helper('M2ePro')->__('Add Account'),
|
39 |
+
'onclick' => $this->getAddButtonOnClickAction(),
|
40 |
+
'class' => 'add add-button-drop-down'
|
41 |
+
));
|
42 |
+
//------------------------------
|
43 |
+
}
|
44 |
+
|
45 |
+
// ########################################
|
46 |
+
|
47 |
+
protected function getAmazonNewUrl()
|
48 |
+
{
|
49 |
+
return $this->getUrl('*/adminhtml_common_amazon_account/new');
|
50 |
+
}
|
51 |
+
|
52 |
+
protected function getBuyNewUrl()
|
53 |
+
{
|
54 |
+
return $this->getUrl('*/adminhtml_common_buy_account/new');
|
55 |
+
}
|
56 |
+
|
57 |
+
protected function getPlayNewUrl()
|
58 |
+
{
|
59 |
+
return $this->getUrl('*/adminhtml_common_play_account/new');
|
60 |
+
}
|
61 |
+
|
62 |
+
// ########################################
|
63 |
+
|
64 |
+
public function getGridHtml()
|
65 |
+
{
|
66 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_account_help');
|
67 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
68 |
+
}
|
69 |
+
|
70 |
+
// ########################################
|
71 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Account/Grid.php
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Account_Grid extends Ess_M2ePro_Block_Adminhtml_Account_Grid
|
8 |
+
{
|
9 |
+
|
10 |
+
protected function _prepareCollection()
|
11 |
+
{
|
12 |
+
// Get collection of accounts
|
13 |
+
$collection = Mage::getModel('M2ePro/Account')->getCollection();
|
14 |
+
|
15 |
+
$collection->getSelect()
|
16 |
+
->joinLeft(array('aa'=>Mage::getResourceModel('M2ePro/Amazon_Account')->getMainTable()),
|
17 |
+
'(`aa`.`account_id` = `main_table`.`id`)',
|
18 |
+
array())
|
19 |
+
->joinLeft(array('m'=>Mage::getResourceModel('M2ePro/Marketplace')->getMainTable()),
|
20 |
+
'(`m`.`id` = `aa`.`marketplace_id`)',
|
21 |
+
array('marketplace_title'=>'title'));
|
22 |
+
|
23 |
+
// Set collection to grid
|
24 |
+
$this->setCollection($collection);
|
25 |
+
|
26 |
+
return parent::_prepareCollection();
|
27 |
+
}
|
28 |
+
|
29 |
+
// ####################################
|
30 |
+
|
31 |
+
protected function _prepareColumns()
|
32 |
+
{
|
33 |
+
$this->addColumn('id', array(
|
34 |
+
'header' => Mage::helper('M2ePro')->__('ID'),
|
35 |
+
'align' => 'right',
|
36 |
+
'width' => '100px',
|
37 |
+
'type' => 'number',
|
38 |
+
'index' => 'id',
|
39 |
+
'filter_index' => 'main_table.id'
|
40 |
+
));
|
41 |
+
|
42 |
+
$this->addColumn('title', array(
|
43 |
+
'header' => Mage::helper('M2ePro')->__('Title / Info'),
|
44 |
+
'align' => 'left',
|
45 |
+
//'width' => '200px',
|
46 |
+
'type' => 'text',
|
47 |
+
'index' => 'title',
|
48 |
+
'escape' => true,
|
49 |
+
'filter_index' => 'main_table.title',
|
50 |
+
'frame_callback' => array($this, 'callbackColumnTitle'),
|
51 |
+
'filter_condition_callback' => array($this, 'callbackFilterTitle')
|
52 |
+
));
|
53 |
+
|
54 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
55 |
+
$this->addColumn('component_mode', array(
|
56 |
+
'header' => Mage::helper('M2ePro')->__('Channel'),
|
57 |
+
'align' => 'left',
|
58 |
+
'width' => '120px',
|
59 |
+
'type' => 'options',
|
60 |
+
'index' => 'component_mode',
|
61 |
+
'filter_index' => 'main_table.component_mode',
|
62 |
+
'sortable' => false,
|
63 |
+
'options' => Mage::helper('M2ePro/View_Common_Component')->getActiveComponentsTitles()
|
64 |
+
));
|
65 |
+
}
|
66 |
+
|
67 |
+
return parent::_prepareColumns();
|
68 |
+
}
|
69 |
+
|
70 |
+
// ####################################
|
71 |
+
|
72 |
+
public function callbackColumnTitle($value, $row, $column, $isExport)
|
73 |
+
{
|
74 |
+
if ($row->isComponentModeAmazon()) {
|
75 |
+
$account = Mage::helper('M2ePro')->__('Account');
|
76 |
+
$marketplace = Mage::helper('M2ePro')->__('Marketplace');
|
77 |
+
|
78 |
+
$marketplaceTitle = $row->getData('marketplace_title');
|
79 |
+
$value = <<<HTML
|
80 |
+
<div>
|
81 |
+
{$value}<br/>
|
82 |
+
<span style="font-weight: bold">{$marketplace}</span>: <span style="color: #505050">{$marketplaceTitle}</span><br/>
|
83 |
+
</div>
|
84 |
+
HTML;
|
85 |
+
}
|
86 |
+
|
87 |
+
return $value;
|
88 |
+
}
|
89 |
+
|
90 |
+
// ####################################
|
91 |
+
|
92 |
+
protected function callbackFilterTitle($collection, $column)
|
93 |
+
{
|
94 |
+
$value = $column->getFilter()->getValue();
|
95 |
+
|
96 |
+
if ($value == null) {
|
97 |
+
return;
|
98 |
+
}
|
99 |
+
|
100 |
+
$where = "main_table.title LIKE '%{$value}%' OR m.title LIKE '%{$value}%'";
|
101 |
+
$collection->getSelect()->where($where);
|
102 |
+
}
|
103 |
+
|
104 |
+
// ####################################
|
105 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Account/Help.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Account_Help extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
// ########################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
$this->setTemplate('M2ePro/common/account/help.phtml');
|
15 |
+
}
|
16 |
+
|
17 |
+
// ########################################
|
18 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Account/Edit.php
ADDED
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Account_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonAccountEdit');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_amazon_account';
|
18 |
+
$this->_mode = 'edit';
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
// Set header text
|
22 |
+
//------------------------------
|
23 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
24 |
+
$componentName = Mage::helper('M2ePro/Component_Amazon')->getTitle();
|
25 |
+
$headerTextEdit = Mage::helper('M2ePro')->__("Edit %component_name% Account", $componentName);
|
26 |
+
$headerTextAdd = Mage::helper('M2ePro')->__("Add %component_name% Account", $componentName);
|
27 |
+
} else {
|
28 |
+
$headerTextEdit = Mage::helper('M2ePro')->__("Edit Account");
|
29 |
+
$headerTextAdd = Mage::helper('M2ePro')->__("Add Account");
|
30 |
+
}
|
31 |
+
|
32 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data') &&
|
33 |
+
Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()
|
34 |
+
) {
|
35 |
+
$this->_headerText = $headerTextEdit;
|
36 |
+
$this->_headerText .= ' "'.$this->escapeHtml(Mage::helper('M2ePro/Data_Global')->getValue('temp_data')
|
37 |
+
->getTitle()).'"';
|
38 |
+
} else {
|
39 |
+
$this->_headerText = $headerTextAdd;
|
40 |
+
}
|
41 |
+
//------------------------------
|
42 |
+
|
43 |
+
// Set buttons actions
|
44 |
+
//------------------------------
|
45 |
+
$this->removeButton('back');
|
46 |
+
$this->removeButton('reset');
|
47 |
+
$this->removeButton('delete');
|
48 |
+
$this->removeButton('add');
|
49 |
+
$this->removeButton('save');
|
50 |
+
$this->removeButton('edit');
|
51 |
+
//------------------------------
|
52 |
+
|
53 |
+
/* @var $wizardHelper Ess_M2ePro_Helper_Module_Wizard */
|
54 |
+
$wizardHelper = Mage::helper('M2ePro/Module_Wizard');
|
55 |
+
|
56 |
+
if ($wizardHelper->isActive('amazon') &&
|
57 |
+
$wizardHelper->getStep('amazon') == 'account') {
|
58 |
+
|
59 |
+
//------------------------------
|
60 |
+
$this->_addButton('save_and_continue', array(
|
61 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
62 |
+
'onclick' => 'AmazonAccountHandlerObj.save_and_edit_click(\'\',\'amazonAccountEditTabs\')',
|
63 |
+
'class' => 'save'
|
64 |
+
));
|
65 |
+
//------------------------------
|
66 |
+
|
67 |
+
if ($this->getRequest()->getParam('id')) {
|
68 |
+
//------------------------------
|
69 |
+
$url = $this->getUrl('*/adminhtml_common_amazon_account/new', array('wizard' => true));
|
70 |
+
$this->_addButton('add_new_account', array(
|
71 |
+
'label' => Mage::helper('M2ePro')->__('Add New Account'),
|
72 |
+
'onclick' => 'setLocation(\''. $url .'\')',
|
73 |
+
'class' => 'add_new_account'
|
74 |
+
));
|
75 |
+
//------------------------------
|
76 |
+
|
77 |
+
//------------------------------
|
78 |
+
$this->_addButton('close', array(
|
79 |
+
'label' => Mage::helper('M2ePro')->__('Complete This Step'),
|
80 |
+
'onclick' => 'AmazonAccountHandlerObj.completeStep();',
|
81 |
+
'class' => 'close'
|
82 |
+
));
|
83 |
+
//------------------------------
|
84 |
+
}
|
85 |
+
} else {
|
86 |
+
|
87 |
+
if ((bool)$this->getRequest()->getParam('close_on_save',false)) {
|
88 |
+
|
89 |
+
if ($this->getRequest()->getParam('id')) {
|
90 |
+
$this->_addButton('save', array(
|
91 |
+
'label' => Mage::helper('M2ePro')->__('Save And Close'),
|
92 |
+
'onclick' => 'AmazonAccountHandlerObj.saveAndClose()',
|
93 |
+
'class' => 'save'
|
94 |
+
));
|
95 |
+
} else {
|
96 |
+
$this->_addButton('save_and_continue', array(
|
97 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
98 |
+
'onclick' => 'AmazonAccountHandlerObj.save_and_edit_click(\'\',\'amazonAccountEditTabs\')',
|
99 |
+
'class' => 'save'
|
100 |
+
));
|
101 |
+
}
|
102 |
+
return;
|
103 |
+
}
|
104 |
+
|
105 |
+
//------------------------------
|
106 |
+
$url = Mage::helper('M2ePro')->getBackUrl('list');
|
107 |
+
$this->_addButton('back', array(
|
108 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
109 |
+
'onclick' => 'AmazonAccountHandlerObj.back_click(\''. $url .'\')',
|
110 |
+
'class' => 'back'
|
111 |
+
));
|
112 |
+
//------------------------------
|
113 |
+
|
114 |
+
//------------------------------
|
115 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data') &&
|
116 |
+
Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()
|
117 |
+
) {
|
118 |
+
//------------------------------
|
119 |
+
$this->_addButton('delete', array(
|
120 |
+
'label' => Mage::helper('M2ePro')->__('Delete'),
|
121 |
+
'onclick' => 'AmazonAccountHandlerObj.delete_click()',
|
122 |
+
'class' => 'delete M2ePro_delete_button'
|
123 |
+
));
|
124 |
+
//------------------------------
|
125 |
+
}
|
126 |
+
|
127 |
+
//------------------------------
|
128 |
+
$this->_addButton('save', array(
|
129 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
130 |
+
'onclick' => 'AmazonAccountHandlerObj.save_click()',
|
131 |
+
'class' => 'save'
|
132 |
+
));
|
133 |
+
//------------------------------
|
134 |
+
|
135 |
+
//------------------------------
|
136 |
+
$this->_addButton('save_and_continue', array(
|
137 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
138 |
+
'onclick' => 'AmazonAccountHandlerObj.save_and_edit_click(\'\',\'amazonAccountEditTabs\')',
|
139 |
+
'class' => 'save'
|
140 |
+
));
|
141 |
+
//------------------------------
|
142 |
+
}
|
143 |
+
}
|
144 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Account/Edit/Form.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Account_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonAccountEditForm');
|
16 |
+
//------------------------------
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _prepareForm()
|
20 |
+
{
|
21 |
+
$form = new Varien_Data_Form(array(
|
22 |
+
'id' => 'edit_form',
|
23 |
+
'action' => $this->getUrl('*/*/save'),
|
24 |
+
'method' => 'post',
|
25 |
+
'enctype' => 'multipart/form-data'
|
26 |
+
));
|
27 |
+
|
28 |
+
$form->setUseContainer(true);
|
29 |
+
$this->setForm($form);
|
30 |
+
|
31 |
+
return parent::_prepareForm();
|
32 |
+
}
|
33 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Account/Edit/Tabs.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Account_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonAccountEditTabs');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTitle(Mage::helper('M2ePro')->__('Configuration'));
|
19 |
+
$this->setDestElementId('edit_form');
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _beforeToHtml()
|
23 |
+
{
|
24 |
+
$this->addTab('general', array(
|
25 |
+
'label' => Mage::helper('M2ePro')->__('General'),
|
26 |
+
'title' => Mage::helper('M2ePro')->__('General'),
|
27 |
+
'content' => $this->getLayout()
|
28 |
+
->createBlock('M2ePro/adminhtml_common_amazon_account_edit_tabs_general')->toHtml(),
|
29 |
+
));
|
30 |
+
|
31 |
+
$this->addTab('listingOther', array(
|
32 |
+
'label' => Mage::helper('M2ePro')->__('3rd Party Listings'),
|
33 |
+
'title' => Mage::helper('M2ePro')->__('3rd Party Listings'),
|
34 |
+
'content' => $this->getLayout()
|
35 |
+
->createBlock('M2ePro/adminhtml_common_amazon_account_edit_tabs_listingOther')->toHtml(),
|
36 |
+
));
|
37 |
+
|
38 |
+
$this->addTab('orders', array(
|
39 |
+
'label' => Mage::helper('M2ePro')->__('Orders'),
|
40 |
+
'title' => Mage::helper('M2ePro')->__('Orders'),
|
41 |
+
'content' => $this->getLayout()
|
42 |
+
->createBlock('M2ePro/adminhtml_common_amazon_account_edit_tabs_order')->toHtml(),
|
43 |
+
));
|
44 |
+
|
45 |
+
$this->setActiveTab($this->getRequest()->getParam('tab', 'general'));
|
46 |
+
|
47 |
+
return parent::_beforeToHtml();
|
48 |
+
}
|
49 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Account/Edit/Tabs/General.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Account_Edit_Tabs_General extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonAccountEditTabsGeneral');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/amazon/account/tabs/general.phtml');
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _beforeToHtml()
|
22 |
+
{
|
23 |
+
$this->synchronizeProcessing = false;
|
24 |
+
|
25 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data') &&
|
26 |
+
Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()) {
|
27 |
+
|
28 |
+
/** @var $accountObj Ess_M2ePro_Model_Account */
|
29 |
+
$accountObj = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
30 |
+
|
31 |
+
$this->synchronizeProcessing = $accountObj->isLockedObject('server_synchronize');
|
32 |
+
|
33 |
+
if (!$this->synchronizeProcessing) {
|
34 |
+
$accountId = $accountObj->getId();
|
35 |
+
|
36 |
+
Mage::helper('M2ePro/Data_Global')->unsetValue('temp_data');
|
37 |
+
Mage::helper('M2ePro/Data_Global')->setValue(
|
38 |
+
'temp_data',
|
39 |
+
Mage::helper('M2ePro/Component_Amazon')->getCachedObject('Account',$accountId)
|
40 |
+
);
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
$marketplaces = Mage::helper('M2ePro/Component_Amazon')->getMarketplacesAvailableForApiCreation();
|
45 |
+
$marketplaces = $marketplaces->toArray();
|
46 |
+
$this->marketplaces = $marketplaces['items'];
|
47 |
+
|
48 |
+
return parent::_beforeToHtml();
|
49 |
+
}
|
50 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Account/Edit/Tabs/ListingOther.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Account_Edit_Tabs_ListingOther extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonAccountEditTabsListingOther');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/amazon/account/tabs/listing_other.phtml');
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _beforeToHtml()
|
22 |
+
{
|
23 |
+
$this->attributes = Mage::helper('M2ePro/Magento_Attribute')->getGeneralFromAllAttributeSets();
|
24 |
+
|
25 |
+
return parent::_beforeToHtml();
|
26 |
+
}
|
27 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Account/Edit/Tabs/Order.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Account_Edit_Tabs_Order extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
protected $_possibleMagentoStatuses = null;
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('amazonAccountEditTabsOrder');
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$this->setTemplate('M2ePro/common/amazon/account/tabs/order.phtml');
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _beforeToHtml()
|
24 |
+
{
|
25 |
+
$data = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
26 |
+
$magentoOrdersSettings = !empty($data['magento_orders_settings'])
|
27 |
+
? json_decode($data['magento_orders_settings'], true) : array();
|
28 |
+
|
29 |
+
//----------------------------
|
30 |
+
$temp = Mage::getModel('core/website')->getCollection()->setOrder('sort_order','ASC')->toArray();
|
31 |
+
$this->websites = $temp['items'];
|
32 |
+
//----------------------------
|
33 |
+
|
34 |
+
//----------------------------
|
35 |
+
$temp = Mage::getModel('customer/group')->getCollection()->toArray();
|
36 |
+
$this->groups = $temp['items'];
|
37 |
+
//----------------------------
|
38 |
+
|
39 |
+
//----------------------------
|
40 |
+
$selectedStore = !empty($magentoOrdersSettings['listing']['store_id'])
|
41 |
+
? $magentoOrdersSettings['listing']['store_id'] : '';
|
42 |
+
$blockStoreSwitcher = $this->getLayout()->createBlock('M2ePro/adminhtml_storeSwitcher', '', array(
|
43 |
+
'id' => 'magento_orders_listings_store_id',
|
44 |
+
'name' => 'magento_orders_settings[listing][store_id]',
|
45 |
+
'selected' => $selectedStore
|
46 |
+
));
|
47 |
+
$blockStoreSwitcher->hasDefaultOption(false);
|
48 |
+
$this->setChild('magento_orders_listings_store_id', $blockStoreSwitcher);
|
49 |
+
//----------------------------
|
50 |
+
|
51 |
+
//----------------------------
|
52 |
+
$selectedStore = !empty($magentoOrdersSettings['listing_other']['store_id'])
|
53 |
+
? $magentoOrdersSettings['listing_other']['store_id'] : '';
|
54 |
+
$blockStoreSwitcher = $this->getLayout()->createBlock('M2ePro/adminhtml_storeSwitcher', '', array(
|
55 |
+
'id' => 'magento_orders_listings_other_store_id',
|
56 |
+
'name' => 'magento_orders_settings[listing_other][store_id]',
|
57 |
+
'selected' => $selectedStore
|
58 |
+
));
|
59 |
+
$blockStoreSwitcher->hasDefaultOption(false);
|
60 |
+
$this->setChild('magento_orders_listings_other_store_id', $blockStoreSwitcher);
|
61 |
+
//----------------------------
|
62 |
+
|
63 |
+
//----------------------------
|
64 |
+
$productTaxClasses = Mage::getModel('tax/class')->getCollection()
|
65 |
+
->addFieldToFilter('class_type', Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT)
|
66 |
+
->toOptionArray();
|
67 |
+
|
68 |
+
$none = array('value' => Ess_M2ePro_Model_Magento_Product::TAX_CLASS_ID_NONE, 'label' => 'None');
|
69 |
+
array_unshift($productTaxClasses, $none);
|
70 |
+
|
71 |
+
$this->productTaxClasses = $productTaxClasses;
|
72 |
+
//----------------------------
|
73 |
+
|
74 |
+
return parent::_beforeToHtml();
|
75 |
+
}
|
76 |
+
|
77 |
+
public function getMagentoOrderStatusList()
|
78 |
+
{
|
79 |
+
if (is_null($this->_possibleMagentoStatuses)) {
|
80 |
+
$this->_possibleMagentoStatuses = Mage::getSingleton('sales/order_config')->getStatuses();
|
81 |
+
}
|
82 |
+
|
83 |
+
return $this->_possibleMagentoStatuses;
|
84 |
+
}
|
85 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing.php
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing extends Mage_Adminhtml_Block_Widget_Grid_Container
|
8 |
+
{
|
9 |
+
// ####################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('amazonListing');
|
18 |
+
$this->_blockGroup = 'M2ePro';
|
19 |
+
$this->_controller = 'adminhtml_common_amazon_listing';
|
20 |
+
//------------------------------
|
21 |
+
|
22 |
+
// Set header text
|
23 |
+
//------------------------------
|
24 |
+
$this->_headerText = '';
|
25 |
+
//------------------------------
|
26 |
+
|
27 |
+
// Set buttons actions
|
28 |
+
//------------------------------
|
29 |
+
$this->removeButton('back');
|
30 |
+
$this->removeButton('reset');
|
31 |
+
$this->removeButton('delete');
|
32 |
+
$this->removeButton('add');
|
33 |
+
$this->removeButton('save');
|
34 |
+
$this->removeButton('edit');
|
35 |
+
//------------------------------
|
36 |
+
|
37 |
+
//------------------------------
|
38 |
+
|
39 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
40 |
+
'*/adminhtml_common_listing/index',
|
41 |
+
array(
|
42 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON
|
43 |
+
)
|
44 |
+
);
|
45 |
+
|
46 |
+
//------------------------------
|
47 |
+
$url = $this->getUrl(
|
48 |
+
'*/adminhtml_common_log/listing',
|
49 |
+
array(
|
50 |
+
'channel' => Ess_M2ePro_Block_Adminhtml_Common_Log_Tabs::TAB_ID_AMAZON
|
51 |
+
)
|
52 |
+
);
|
53 |
+
$this->_addButton('view_log', array(
|
54 |
+
'label' => Mage::helper('M2ePro')->__('View Log'),
|
55 |
+
'onclick' => 'window.open(\'' . $url . '\')',
|
56 |
+
'class' => 'button_link'
|
57 |
+
));
|
58 |
+
//------------------------------
|
59 |
+
|
60 |
+
//------------------------------
|
61 |
+
$url = $this->getUrl(
|
62 |
+
'*/adminhtml_common_amazon_listing/search',
|
63 |
+
array(
|
64 |
+
'back' => $backUrl
|
65 |
+
)
|
66 |
+
);
|
67 |
+
$this->_addButton('search_amazon_products', array(
|
68 |
+
'label' => Mage::helper('M2ePro')->__('Search'),
|
69 |
+
'onclick' => 'setLocation(\'' . $url . '\')',
|
70 |
+
'class' => 'button_link search'
|
71 |
+
));
|
72 |
+
//------------------------------
|
73 |
+
|
74 |
+
//------------------------------
|
75 |
+
$url = $this->getUrl('*/adminhtml_common_listing_create/index', array(
|
76 |
+
'step' => '1',
|
77 |
+
'clear' => 'yes',
|
78 |
+
'component' => Ess_M2ePro_Helper_Component_Amazon::NICK
|
79 |
+
));
|
80 |
+
$this->_addButton('add', array(
|
81 |
+
'label' => Mage::helper('M2ePro')->__('Add Listing'),
|
82 |
+
'onclick' => 'setLocation(\'' . $url . '\')',
|
83 |
+
'class' => 'add'
|
84 |
+
));
|
85 |
+
//------------------------------
|
86 |
+
}
|
87 |
+
|
88 |
+
// ####################################
|
89 |
+
|
90 |
+
public function getTemplatesButtonJavascript()
|
91 |
+
{
|
92 |
+
$dropDownBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_button_dropDown', '', array(
|
93 |
+
'target_css_class' => 'amazon-templates-drop-down',
|
94 |
+
'items' => $this->getTemplatesButtonDropDownItems()
|
95 |
+
));
|
96 |
+
|
97 |
+
return $dropDownBlock->toHtml();
|
98 |
+
}
|
99 |
+
|
100 |
+
protected function getTemplatesButtonDropDownItems()
|
101 |
+
{
|
102 |
+
$items = array();
|
103 |
+
|
104 |
+
$filter = base64_encode('component_mode=' . Ess_M2ePro_Helper_Component_Amazon::NICK);
|
105 |
+
|
106 |
+
//------------------------------
|
107 |
+
$url = $this->getUrl('*/adminhtml_common_template_sellingFormat/index', array('filter' => $filter));
|
108 |
+
$items[] = array(
|
109 |
+
'url' => $url,
|
110 |
+
'label' => Mage::helper('M2ePro')->__('Selling Format Policies'),
|
111 |
+
'target' => '_blank'
|
112 |
+
);
|
113 |
+
//------------------------------
|
114 |
+
|
115 |
+
//------------------------------
|
116 |
+
$url = $this->getUrl('*/adminhtml_common_template_synchronization/index', array('filter' => $filter));
|
117 |
+
$items[] = array(
|
118 |
+
'url' => $url,
|
119 |
+
'label' => Mage::helper('M2ePro')->__('Synchronization Policies'),
|
120 |
+
'target' => '_blank'
|
121 |
+
);
|
122 |
+
//------------------------------
|
123 |
+
|
124 |
+
return $items;
|
125 |
+
}
|
126 |
+
|
127 |
+
// ####################################
|
128 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/Form.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Add_Form
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_Form
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
//------------------------------
|
16 |
+
$this->component = Ess_M2ePro_Helper_Component_Amazon::NICK;
|
17 |
+
$this->setId('amazonListingEditForm');
|
18 |
+
//------------------------------
|
19 |
+
}
|
20 |
+
|
21 |
+
// ########################################
|
22 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/NewAsin.php
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2011 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Add_NewAsin extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
// ####################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('amazonListingAddNewAsin');
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$this->_headerText = Mage::helper('M2ePro')->__('New ASIN/ISBN Creation');
|
21 |
+
|
22 |
+
$url = $this->getUrl('*/*/index', array(
|
23 |
+
'step' => 1,
|
24 |
+
'_current' => true
|
25 |
+
));
|
26 |
+
$this->_addButton('back', array(
|
27 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
28 |
+
'class' => 'back',
|
29 |
+
'onclick' => 'setLocation(\''.$url.'\');'
|
30 |
+
));
|
31 |
+
|
32 |
+
$this->_addButton('next', array(
|
33 |
+
'label' => Mage::helper('M2ePro')->__('Continue'),
|
34 |
+
'class' => 'scalable next',
|
35 |
+
'onclick' => "descriptionTemplateModeFormSubmit()"
|
36 |
+
));
|
37 |
+
|
38 |
+
$this->setTemplate('M2ePro/common/amazon/listing/add/new_asin.phtml');
|
39 |
+
}
|
40 |
+
|
41 |
+
// ####################################
|
42 |
+
|
43 |
+
public function getHeaderCssClass()
|
44 |
+
{
|
45 |
+
return 'icon-head ' . parent::getHeaderCssClass();
|
46 |
+
}
|
47 |
+
|
48 |
+
public function getHeaderWidth()
|
49 |
+
{
|
50 |
+
return 'width:50%;';
|
51 |
+
}
|
52 |
+
|
53 |
+
// ####################################
|
54 |
+
|
55 |
+
protected function _beforeToHtml()
|
56 |
+
{
|
57 |
+
parent::_beforeToHtml();
|
58 |
+
|
59 |
+
$listing = Mage::helper('M2ePro/Component_Amazon')->getCachedObject(
|
60 |
+
'Listing', $this->getRequest()->getParam('id')
|
61 |
+
);
|
62 |
+
|
63 |
+
$viewHeaderBlock = $this->getLayout()->createBlock(
|
64 |
+
'M2ePro/adminhtml_listing_view_header','',
|
65 |
+
array('listing' => $listing)
|
66 |
+
);
|
67 |
+
|
68 |
+
$this->setChild('view_header', $viewHeaderBlock);
|
69 |
+
|
70 |
+
// ------------------------------------------------
|
71 |
+
$buttonBlock = $this->getLayout()
|
72 |
+
->createBlock('adminhtml/widget_button')
|
73 |
+
->setData( array(
|
74 |
+
'label' => Mage::helper('M2ePro')->__('Continue'),
|
75 |
+
'onclick' => '',
|
76 |
+
) );
|
77 |
+
$this->setChild('mode_same_remember_pop_up_confirm_button',$buttonBlock);
|
78 |
+
}
|
79 |
+
|
80 |
+
// ####################################
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @return Ess_M2ePro_Model_Listing
|
84 |
+
* @throws Exception
|
85 |
+
*/
|
86 |
+
public function getListing()
|
87 |
+
{
|
88 |
+
if (!$listingId = $this->getRequest()->getParam('id')) {
|
89 |
+
throw new Exception('Listing is not defined');
|
90 |
+
}
|
91 |
+
|
92 |
+
if (is_null($this->listing)) {
|
93 |
+
$this->listing = Mage::helper('M2ePro/Component_Amazon')
|
94 |
+
->getObject('Listing', $listingId);
|
95 |
+
}
|
96 |
+
|
97 |
+
return $this->listing;
|
98 |
+
}
|
99 |
+
|
100 |
+
// ####################################
|
101 |
+
|
102 |
+
public function getProductsIds()
|
103 |
+
{
|
104 |
+
return $this->getListing()->getSetting('additional_data', 'adding_new_asin_listing_products_ids');
|
105 |
+
}
|
106 |
+
|
107 |
+
// ####################################
|
108 |
+
|
109 |
+
public function getDescriptionTemplateMode()
|
110 |
+
{
|
111 |
+
$listingAdditionalData = $this->getListing()->getData('additional_data');
|
112 |
+
$listingAdditionalData = json_decode($listingAdditionalData, true);
|
113 |
+
|
114 |
+
$mode = 'same';
|
115 |
+
|
116 |
+
$sessionMode = Mage::helper('M2ePro/Data_Session')->getValue('products_source');
|
117 |
+
if ($sessionMode == 'category') {
|
118 |
+
$mode = $sessionMode;
|
119 |
+
}
|
120 |
+
|
121 |
+
if (!empty($listingAdditionalData['new_asin_mode'])) {
|
122 |
+
$mode = $listingAdditionalData['new_asin_mode'];
|
123 |
+
}
|
124 |
+
|
125 |
+
return $mode;
|
126 |
+
}
|
127 |
+
|
128 |
+
// ####################################
|
129 |
+
|
130 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/NewAsin/Category.php
ADDED
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Add_NewAsin_Category
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Container
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
//------------------------------
|
16 |
+
$this->setId('newAsinDescriptionTemplateCategory');
|
17 |
+
//------------------------------
|
18 |
+
|
19 |
+
// Set header text
|
20 |
+
//------------------------------
|
21 |
+
$this->_headerText = Mage::helper('M2ePro')->__("Set Description Policy for New ASIN/ISBN Creation");
|
22 |
+
$this->_blockGroup = 'M2ePro';
|
23 |
+
$this->_controller = 'adminhtml_common_amazon_listing_add_newAsin_category';
|
24 |
+
//------------------------------
|
25 |
+
|
26 |
+
// Set buttons actions
|
27 |
+
//------------------------------
|
28 |
+
$this->removeButton('back');
|
29 |
+
$this->removeButton('reset');
|
30 |
+
$this->removeButton('delete');
|
31 |
+
$this->removeButton('add');
|
32 |
+
$this->removeButton('save');
|
33 |
+
$this->removeButton('edit');
|
34 |
+
//------------------------------
|
35 |
+
|
36 |
+
//------------------------------
|
37 |
+
$url = $this->getUrl('*/*/resetNewAsin', array(
|
38 |
+
'_current' => true
|
39 |
+
));
|
40 |
+
$this->_addButton('back', array(
|
41 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
42 |
+
'onclick' => 'ListingGridHandlerObj.back_click(\'' . $url . '\')',
|
43 |
+
'class' => 'back'
|
44 |
+
));
|
45 |
+
//------------------------------
|
46 |
+
|
47 |
+
$url = $this->getUrl('*/*/index', array('_current' => true, 'step' => 3));
|
48 |
+
//------------------------------
|
49 |
+
$this->_addButton('save_and_go_to_listing_view', array(
|
50 |
+
'id' => 'save_and_go_to_listing_view',
|
51 |
+
'label' => Mage::helper('M2ePro')->__('Continue'),
|
52 |
+
'onclick' => 'ListingGridHandlerObj.checkCategoryProducts(\''.$url.'\')',
|
53 |
+
'class' => 'scalable next'
|
54 |
+
));
|
55 |
+
//------------------------------
|
56 |
+
}
|
57 |
+
|
58 |
+
public function getGridHtml()
|
59 |
+
{
|
60 |
+
$listing = Mage::helper('M2ePro/Component')
|
61 |
+
->getCachedUnknownObject('Listing', $this->getRequest()->getParam('id'));
|
62 |
+
|
63 |
+
$viewHeaderBlock = $this->getLayout()->createBlock(
|
64 |
+
'M2ePro/adminhtml_listing_view_header','',
|
65 |
+
array('listing' => $listing)
|
66 |
+
);
|
67 |
+
|
68 |
+
return $viewHeaderBlock->toHtml() . parent::getGridHtml();
|
69 |
+
}
|
70 |
+
|
71 |
+
protected function _toHtml()
|
72 |
+
{
|
73 |
+
$helper = Mage::helper('M2ePro');
|
74 |
+
|
75 |
+
// --------TEXT------------------
|
76 |
+
$templateDescriptionPopupTitle = $helper->escapeJs($helper->__('Assign Description Policy'));
|
77 |
+
// -------------------------------
|
78 |
+
|
79 |
+
// ---------URL-------------------
|
80 |
+
$mapToTemplateDescription = $this->getUrl('*/adminhtml_common_amazon_listing/mapToTemplateDescription');
|
81 |
+
$unmapFromTemplateDescription = $this->getUrl('*/adminhtml_common_amazon_listing/unmapFromTemplateDescription');
|
82 |
+
$validateProductsForTemplateDescriptionAssign = $this->getUrl(
|
83 |
+
'*/adminhtml_common_amazon_listing/validateProductsForTemplateDescriptionAssign');
|
84 |
+
$viewTemplateDescriptionsGrid = $this->getUrl('*/*/viewTemplateDescriptionsGrid');
|
85 |
+
|
86 |
+
$mapToNewAsin = $this->getUrl('*/adminhtml_common_amazon_listing/mapToNewAsin');
|
87 |
+
$unmapFromNewAsin = $this->getUrl('*/adminhtml_common_amazon_listing/unmapFromAsin');
|
88 |
+
|
89 |
+
$checkNewAsinCategoryProducts = $this->getUrl('*/*/checkNewAsinCategoryProducts', array('_current' => true));
|
90 |
+
// -------------------------------
|
91 |
+
|
92 |
+
$javascript = <<<HTML
|
93 |
+
<script type="text/javascript">
|
94 |
+
selectTemplateDescription = function (el, templateId, mapToGeneralId)
|
95 |
+
{
|
96 |
+
ListingGridHandlerObj.mapToTemplateDescription(el, templateId, mapToGeneralId);
|
97 |
+
};
|
98 |
+
|
99 |
+
if (typeof M2ePro == 'undefined') {
|
100 |
+
M2ePro = {};
|
101 |
+
M2ePro.url = {};
|
102 |
+
M2ePro.formData = {};
|
103 |
+
M2ePro.customData = {};
|
104 |
+
M2ePro.text = {};
|
105 |
+
}
|
106 |
+
|
107 |
+
M2ePro.text.templateDescriptionPopupTitle = '{$templateDescriptionPopupTitle}';
|
108 |
+
|
109 |
+
M2ePro.url.mapToTemplateDescription = '{$mapToTemplateDescription}';
|
110 |
+
M2ePro.url.unmapFromTemplateDescription = '{$unmapFromTemplateDescription}';
|
111 |
+
M2ePro.url.validateProductsForTemplateDescriptionAssign = '{$validateProductsForTemplateDescriptionAssign}';
|
112 |
+
M2ePro.url.viewTemplateDescriptionsGrid = '{$viewTemplateDescriptionsGrid}';
|
113 |
+
|
114 |
+
M2ePro.url.mapToNewAsin = '{$mapToNewAsin}';
|
115 |
+
M2ePro.url.unmapFromNewAsin = '{$unmapFromNewAsin}';
|
116 |
+
|
117 |
+
M2ePro.url.checkNewAsinCategoryProducts = '{$checkNewAsinCategoryProducts}';
|
118 |
+
|
119 |
+
Event.observe(window, 'load', function() {
|
120 |
+
|
121 |
+
CommonHandler.prototype.scroll_page_to_top = function() { return; }
|
122 |
+
|
123 |
+
ListingGridHandlerObj = new NewAsinTemplateDescriptionGridHandler(
|
124 |
+
'{$this->getChild('grid')->getId()}',
|
125 |
+
{$this->getListing()->getId()}
|
126 |
+
);
|
127 |
+
|
128 |
+
ListingGridHandlerObj.actionHandler.setOptions(M2ePro);
|
129 |
+
ListingGridHandlerObj.templateDescriptionHandler.setOptions(M2ePro);
|
130 |
+
});
|
131 |
+
|
132 |
+
</script>
|
133 |
+
HTML;
|
134 |
+
|
135 |
+
return $javascript .
|
136 |
+
'<div id="search_asin_products_container">' .
|
137 |
+
parent::_toHtml() .
|
138 |
+
'</div>';
|
139 |
+
}
|
140 |
+
|
141 |
+
// ####################################
|
142 |
+
|
143 |
+
public function getListing()
|
144 |
+
{
|
145 |
+
if (!$listingId = $this->getRequest()->getParam('id')) {
|
146 |
+
throw new Exception('Listing is not defined');
|
147 |
+
}
|
148 |
+
|
149 |
+
if (is_null($this->listing)) {
|
150 |
+
$this->listing = Mage::helper('M2ePro/Component_Amazon')
|
151 |
+
->getObject('Listing', $listingId)->getChildObject();
|
152 |
+
}
|
153 |
+
|
154 |
+
return $this->listing;
|
155 |
+
}
|
156 |
+
|
157 |
+
// ####################################
|
158 |
+
|
159 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/NewAsin/Category/Grid.php
ADDED
@@ -0,0 +1,342 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Add_NewAsin_Category_Grid
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Category_Grid
|
9 |
+
{
|
10 |
+
/** @var Ess_M2ePro_Model_Listing */
|
11 |
+
private $listing = NULL;
|
12 |
+
|
13 |
+
public function __construct()
|
14 |
+
{
|
15 |
+
parent::__construct();
|
16 |
+
|
17 |
+
// Initialization block
|
18 |
+
//------------------------------
|
19 |
+
$this->setId('newAsinCategoryGrid');
|
20 |
+
//------------------------------
|
21 |
+
|
22 |
+
// Set default values
|
23 |
+
//------------------------------
|
24 |
+
$this->setDefaultSort('id');
|
25 |
+
$this->setDefaultDir('DESC');
|
26 |
+
$this->setUseAjax(true);
|
27 |
+
//------------------------------
|
28 |
+
|
29 |
+
$this->prepareDataByCategories();
|
30 |
+
}
|
31 |
+
|
32 |
+
// ####################################
|
33 |
+
|
34 |
+
protected function _prepareCollection()
|
35 |
+
{
|
36 |
+
/* @var $collection Mage_Catalog_Model_Resource_Category_Collection */
|
37 |
+
$collection = Mage::getModel('catalog/category')->getCollection();
|
38 |
+
$collection->addAttributeToSelect('name');
|
39 |
+
|
40 |
+
$collection->addFieldToFilter(array(
|
41 |
+
array('attribute' => 'entity_id', 'in' => array_keys($this->getData('categories_data')))
|
42 |
+
));
|
43 |
+
|
44 |
+
$this->setCollection($collection);
|
45 |
+
|
46 |
+
return parent::_prepareCollection();
|
47 |
+
}
|
48 |
+
|
49 |
+
// ####################################
|
50 |
+
|
51 |
+
protected function _prepareColumns()
|
52 |
+
{
|
53 |
+
$this->addColumn('magento_category', array(
|
54 |
+
'header' => Mage::helper('M2ePro')->__('Magento Category'),
|
55 |
+
'align' => 'left',
|
56 |
+
'width' => '500px',
|
57 |
+
'type' => 'text',
|
58 |
+
'index' => 'name',
|
59 |
+
'filter' => false,
|
60 |
+
'sortable' => false,
|
61 |
+
'frame_callback' => array($this, 'callbackColumnMagentoCategory')
|
62 |
+
));
|
63 |
+
|
64 |
+
$this->addColumn('description_template', array(
|
65 |
+
'header' => Mage::helper('M2ePro')->__('Description Policy'),
|
66 |
+
'align' => 'left',
|
67 |
+
'width' => '*',
|
68 |
+
'sortable' => false,
|
69 |
+
'type' => 'options',
|
70 |
+
'index' => 'description_template_id',
|
71 |
+
'filter_index' => 'description_template_id',
|
72 |
+
'options' => array(
|
73 |
+
1 => Mage::helper('M2ePro')->__('Description Policy Selected'),
|
74 |
+
0 => Mage::helper('M2ePro')->__('Description Policy Not Selected')
|
75 |
+
),
|
76 |
+
'frame_callback' => array($this, 'callbackColumnDescriptionTemplateCallback'),
|
77 |
+
'filter_condition_callback' => array($this, 'callbackColumnDescriptionTemplateFilterCallback')
|
78 |
+
));
|
79 |
+
|
80 |
+
$actionsColumn = array(
|
81 |
+
'header' => Mage::helper('M2ePro')->__('Actions'),
|
82 |
+
'renderer' => 'M2ePro/adminhtml_grid_column_renderer_action',
|
83 |
+
'align' => 'center',
|
84 |
+
'width' => '130px',
|
85 |
+
'type' => 'text',
|
86 |
+
'sortable' => false,
|
87 |
+
'filter' => false,
|
88 |
+
'actions' => array()
|
89 |
+
);
|
90 |
+
|
91 |
+
$actions = array(
|
92 |
+
array(
|
93 |
+
'caption' => Mage::helper('M2ePro')->__('Set Description Policy'),
|
94 |
+
'field' => 'entity_id',
|
95 |
+
'onclick_action' => 'ListingGridHandlerObj.setDescriptionTemplateByCategoryRowAction'
|
96 |
+
),
|
97 |
+
array(
|
98 |
+
'caption' => Mage::helper('M2ePro')->__('Reset Description Policy'),
|
99 |
+
'field' => 'entity_id',
|
100 |
+
'onclick_action' => 'ListingGridHandlerObj.resetDescriptionTemplateByCategoryRowAction'
|
101 |
+
)
|
102 |
+
);
|
103 |
+
|
104 |
+
$actionsColumn['actions'] = $actions;
|
105 |
+
|
106 |
+
$this->addColumn('actions', $actionsColumn);
|
107 |
+
|
108 |
+
return parent::_prepareColumns();
|
109 |
+
}
|
110 |
+
|
111 |
+
// ####################################
|
112 |
+
|
113 |
+
protected function _prepareMassaction()
|
114 |
+
{
|
115 |
+
$this->setMassactionIdField('entity_id');
|
116 |
+
$this->setMassactionIdFieldOnlyIndexValue(true);
|
117 |
+
|
118 |
+
//--------------------------------
|
119 |
+
$this->getMassactionBlock()->addItem('setDescriptionTemplateByCategory', array(
|
120 |
+
'label' => Mage::helper('M2ePro')->__('Set Description Policy'),
|
121 |
+
'url' => ''
|
122 |
+
));
|
123 |
+
|
124 |
+
$this->getMassactionBlock()->addItem('resetDescriptionTemplateByCategory', array(
|
125 |
+
'label' => Mage::helper('M2ePro')->__('Reset Description Policy'),
|
126 |
+
'url' => ''
|
127 |
+
));
|
128 |
+
//--------------------------------
|
129 |
+
|
130 |
+
return parent::_prepareMassaction();
|
131 |
+
}
|
132 |
+
|
133 |
+
// ########################################
|
134 |
+
|
135 |
+
public function callbackColumnDescriptionTemplateCallback($value, $row, $column, $isExport)
|
136 |
+
{
|
137 |
+
$categoriesData = $this->getData('categories_data');
|
138 |
+
$productsIds = implode(',', $categoriesData[$row->getData('entity_id')]);
|
139 |
+
|
140 |
+
$descriptionTemplatesData = $this->getData('description_templates_data');
|
141 |
+
$descriptionTemplatesIds = array();
|
142 |
+
foreach ($categoriesData[$row->getData('entity_id')] as $productId) {
|
143 |
+
if (empty($descriptionTemplatesIds[$descriptionTemplatesData[$productId]])) {
|
144 |
+
$descriptionTemplatesIds[$descriptionTemplatesData[$productId]] = 0;
|
145 |
+
}
|
146 |
+
$descriptionTemplatesIds[$descriptionTemplatesData[$productId]]++;
|
147 |
+
}
|
148 |
+
|
149 |
+
arsort($descriptionTemplatesIds);
|
150 |
+
|
151 |
+
reset($descriptionTemplatesIds);
|
152 |
+
$descriptionTemplateId = key($descriptionTemplatesIds);
|
153 |
+
|
154 |
+
if (empty($descriptionTemplateId)) {
|
155 |
+
$iconSrc = $this->getSkinUrl('M2ePro/images/warning.png');
|
156 |
+
$label = Mage::helper('M2ePro')->__('Not Selected');
|
157 |
+
|
158 |
+
return <<<HTML
|
159 |
+
<img src="{$iconSrc}" alt=""> <span style="color: gray; font-style: italic;">{$label}</span>
|
160 |
+
<input type="hidden" id="products_ids_{$row->getData('entity_id')}" value="{$productsIds}">
|
161 |
+
HTML;
|
162 |
+
}
|
163 |
+
|
164 |
+
$templateDescriptionEditUrl = $this->getUrl('*/adminhtml_common_amazon_template_description/edit', array(
|
165 |
+
'id' => $descriptionTemplateId
|
166 |
+
));
|
167 |
+
|
168 |
+
/** @var Ess_M2ePro_Model_Amazon_Template_Description $descriptionTemplate */
|
169 |
+
$descriptionTemplate = Mage::helper('M2ePro/Component_Amazon')
|
170 |
+
->getModel('Template_Description')->load($descriptionTemplateId);
|
171 |
+
|
172 |
+
$title = Mage::helper('M2ePro')->escapeHtml($descriptionTemplate->getData('title'));
|
173 |
+
|
174 |
+
return <<<HTML
|
175 |
+
<a target="_blank" href="{$templateDescriptionEditUrl}">{$title}</a>
|
176 |
+
<input type="hidden" id="products_ids_{$row->getData('entity_id')}" value="{$productsIds}">
|
177 |
+
HTML;
|
178 |
+
}
|
179 |
+
|
180 |
+
// ########################################
|
181 |
+
|
182 |
+
protected function callbackColumnDescriptionTemplateFilterCallback($collection, $column)
|
183 |
+
{
|
184 |
+
$value = $column->getFilter()->getValue();
|
185 |
+
|
186 |
+
if ($value == null) {
|
187 |
+
return;
|
188 |
+
}
|
189 |
+
|
190 |
+
$filteredProductsCategories = array();
|
191 |
+
$filteredListingProductsIds = array();
|
192 |
+
|
193 |
+
$categoriesData = $this->getData('categories_data');
|
194 |
+
$descriptionTemplatesIds = $this->getData('description_templates_data');
|
195 |
+
|
196 |
+
foreach ($descriptionTemplatesIds as $listingProductId => $descriptionTemplateId) {
|
197 |
+
if ($descriptionTemplateId !== NULL) {
|
198 |
+
$filteredListingProductsIds[] = $listingProductId;
|
199 |
+
}
|
200 |
+
}
|
201 |
+
|
202 |
+
foreach ($categoriesData as $categoryId => $listingProducts) {
|
203 |
+
foreach ($filteredListingProductsIds as $listingProductId) {
|
204 |
+
if (in_array($listingProductId, $listingProducts)) {
|
205 |
+
$filteredProductsCategories[] = $categoryId;
|
206 |
+
}
|
207 |
+
}
|
208 |
+
}
|
209 |
+
|
210 |
+
$filteredProductsCategories = array_unique($filteredProductsCategories);
|
211 |
+
|
212 |
+
if ($value) {
|
213 |
+
$collection->addFieldToFilter('entity_id', array('in' => $filteredProductsCategories));
|
214 |
+
} else if (!empty($filteredProductsCategories)){
|
215 |
+
$collection->addFieldToFilter('entity_id', array('nin' => $filteredProductsCategories));
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
// ########################################
|
220 |
+
|
221 |
+
public function getRowUrl($row)
|
222 |
+
{
|
223 |
+
return false;
|
224 |
+
}
|
225 |
+
|
226 |
+
// ####################################
|
227 |
+
|
228 |
+
protected function _toHtml()
|
229 |
+
{
|
230 |
+
$addErrorJs = '';
|
231 |
+
|
232 |
+
if (count($this->getData('categories_data')) === 0) {
|
233 |
+
$msg = Mage::helper('M2ePro')
|
234 |
+
->__('Magento Categories are not specified for Products you are adding.');
|
235 |
+
|
236 |
+
$addErrorJs = <<<JS
|
237 |
+
MagentoMessageObj['addError']('{$msg}');
|
238 |
+
$('save_and_go_to_listing_view').addClassName('disabled').onclick = function() {
|
239 |
+
return null;
|
240 |
+
};
|
241 |
+
JS;
|
242 |
+
|
243 |
+
}
|
244 |
+
|
245 |
+
$javascriptsMain = <<<JAVASCRIPT
|
246 |
+
<script type="text/javascript">
|
247 |
+
|
248 |
+
if (typeof ListingGridHandlerObj != 'undefined') {
|
249 |
+
ListingGridHandlerObj.afterInitPage();
|
250 |
+
}
|
251 |
+
|
252 |
+
{$addErrorJs}
|
253 |
+
|
254 |
+
Event.observe(window, 'load', function() {
|
255 |
+
setTimeout(function() {
|
256 |
+
ListingGridHandlerObj.afterInitPage();
|
257 |
+
}, 350);
|
258 |
+
});
|
259 |
+
|
260 |
+
</script>
|
261 |
+
JAVASCRIPT;
|
262 |
+
|
263 |
+
return parent::_toHtml() . $javascriptsMain;
|
264 |
+
}
|
265 |
+
|
266 |
+
// ####################################
|
267 |
+
|
268 |
+
/**
|
269 |
+
* @return Ess_M2ePro_Model_Amazon_Listing
|
270 |
+
* @throws Exception
|
271 |
+
*/
|
272 |
+
public function getListing()
|
273 |
+
{
|
274 |
+
if (!$listingId = $this->getRequest()->getParam('id')) {
|
275 |
+
throw new Exception('Listing is not defined');
|
276 |
+
}
|
277 |
+
|
278 |
+
if (is_null($this->listing)) {
|
279 |
+
$this->listing = Mage::helper('M2ePro/Component_Amazon')
|
280 |
+
->getObject('Listing', $listingId);
|
281 |
+
}
|
282 |
+
|
283 |
+
return $this->listing;
|
284 |
+
}
|
285 |
+
|
286 |
+
// ####################################
|
287 |
+
|
288 |
+
private function prepareDataByCategories()
|
289 |
+
{
|
290 |
+
$listingProductsIds = $this->getListing()
|
291 |
+
->getSetting('additional_data', 'adding_new_asin_listing_products_ids');
|
292 |
+
|
293 |
+
$listingProductCollection = Mage::helper('M2ePro/Component_Amazon')
|
294 |
+
->getCollection('Listing_Product')
|
295 |
+
->addFieldToFilter('id',array('in' => $listingProductsIds));
|
296 |
+
|
297 |
+
$productsIds = array();
|
298 |
+
$descriptionTemplatesIds = array();
|
299 |
+
foreach ($listingProductCollection->getData() as $item) {
|
300 |
+
$productsIds[$item['id']] = $item['product_id'];
|
301 |
+
$descriptionTemplatesIds[$item['id']] = $item['template_description_id'];
|
302 |
+
}
|
303 |
+
$productsIds = array_unique($productsIds);
|
304 |
+
|
305 |
+
$categoriesIds = Mage::helper('M2ePro/Magento_Category')->getLimitedCategoriesByProducts(
|
306 |
+
$productsIds,
|
307 |
+
$this->getListing()->getStoreId()
|
308 |
+
);
|
309 |
+
|
310 |
+
$categoriesData = array();
|
311 |
+
|
312 |
+
foreach ($categoriesIds as $categoryId) {
|
313 |
+
/* @var $collection Mage_Catalog_Model_Resource_Product_Collection */
|
314 |
+
$collection = Mage::getModel('catalog/product')->getCollection();
|
315 |
+
$collection->addFieldToFilter('entity_id', array('in' => $productsIds));
|
316 |
+
|
317 |
+
$collection->joinTable(
|
318 |
+
array('ccp' => 'catalog/category_product'),
|
319 |
+
'product_id=entity_id',
|
320 |
+
array('category_id' => 'category_id')
|
321 |
+
);
|
322 |
+
$collection->addFieldToFilter('category_id', $categoryId);
|
323 |
+
|
324 |
+
$data = $collection->getData();
|
325 |
+
|
326 |
+
foreach ($data as $item) {
|
327 |
+
$categoriesData[$categoryId][] = array_search($item['entity_id'], $productsIds);
|
328 |
+
}
|
329 |
+
|
330 |
+
$categoriesData[$categoryId] = array_unique($categoriesData[$categoryId]);
|
331 |
+
}
|
332 |
+
|
333 |
+
$this->setData('categories_data', $categoriesData);
|
334 |
+
$this->setData('description_templates_data', $descriptionTemplatesIds);
|
335 |
+
|
336 |
+
$this->getListing()
|
337 |
+
->setSetting('additional_data', 'adding_new_asin_description_templates_data', $descriptionTemplatesIds);
|
338 |
+
$this->getListing()->save();
|
339 |
+
}
|
340 |
+
|
341 |
+
// ####################################
|
342 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/NewAsin/Manual.php
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Add_NewAsin_Manual
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Container
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
$listingId = $this->getRequest()->getParam('id');
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->setId('newAsinDescriptionTemplateManual');
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
// Set header text
|
22 |
+
//------------------------------
|
23 |
+
$this->_headerText = Mage::helper('M2ePro')->__("Set Description Policy for New ASIN/ISBN Creation");
|
24 |
+
$this->_blockGroup = 'M2ePro';
|
25 |
+
$this->_controller = 'adminhtml_common_amazon_listing_add_newAsin_manual';
|
26 |
+
//------------------------------
|
27 |
+
|
28 |
+
// Set buttons actions
|
29 |
+
//------------------------------
|
30 |
+
$this->removeButton('back');
|
31 |
+
$this->removeButton('reset');
|
32 |
+
$this->removeButton('delete');
|
33 |
+
$this->removeButton('add');
|
34 |
+
$this->removeButton('save');
|
35 |
+
$this->removeButton('edit');
|
36 |
+
//------------------------------
|
37 |
+
|
38 |
+
//------------------------------
|
39 |
+
$url = $this->getUrl('*/*/resetNewAsin', array(
|
40 |
+
'_current' => true
|
41 |
+
));
|
42 |
+
$this->_addButton('back', array(
|
43 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
44 |
+
'onclick' => 'ListingGridHandlerObj.back_click(\'' . $url . '\')',
|
45 |
+
'class' => 'back'
|
46 |
+
));
|
47 |
+
|
48 |
+
$url = $this->getUrl('*/*/index', array('_current' => true, 'step' => 3));
|
49 |
+
//------------------------------
|
50 |
+
$this->_addButton('save_and_go_to_listing_view', array(
|
51 |
+
'label' => Mage::helper('M2ePro')->__('Continue'),
|
52 |
+
'onclick' => 'ListingGridHandlerObj.checkManualProducts(\''.$url.'\')',
|
53 |
+
'class' => 'scalable next'
|
54 |
+
));
|
55 |
+
//------------------------------
|
56 |
+
}
|
57 |
+
|
58 |
+
public function getGridHtml()
|
59 |
+
{
|
60 |
+
$listing = Mage::helper('M2ePro/Component')
|
61 |
+
->getCachedUnknownObject('Listing', $this->getRequest()->getParam('id'));
|
62 |
+
|
63 |
+
$viewHeaderBlock = $this->getLayout()->createBlock(
|
64 |
+
'M2ePro/adminhtml_listing_view_header','',
|
65 |
+
array('listing' => $listing)
|
66 |
+
);
|
67 |
+
|
68 |
+
return $viewHeaderBlock->toHtml() . parent::getGridHtml();
|
69 |
+
}
|
70 |
+
|
71 |
+
protected function _toHtml()
|
72 |
+
{
|
73 |
+
$helper = Mage::helper('M2ePro');
|
74 |
+
|
75 |
+
// --------TEXT------------------
|
76 |
+
$templateDescriptionPopupTitle = $helper->escapeJs($helper->__('Assign Description Policy'));
|
77 |
+
$setDescriptionPolicy = $helper->escapeJs($helper->__('Set Description Policy.'));
|
78 |
+
// -------------------------------
|
79 |
+
|
80 |
+
// ---------URL-------------------
|
81 |
+
$mapToTemplateDescription = $this->getUrl('*/adminhtml_common_amazon_listing/mapToTemplateDescription');
|
82 |
+
$unmapFromTemplateDescription = $this->getUrl('*/adminhtml_common_amazon_listing/unmapFromTemplateDescription');
|
83 |
+
$validateProductsForTemplateDescriptionAssign = $this->getUrl(
|
84 |
+
'*/adminhtml_common_amazon_listing/validateProductsForTemplateDescriptionAssign');
|
85 |
+
$viewTemplateDescriptionsGrid = $this->getUrl('*/*/viewTemplateDescriptionsGrid');
|
86 |
+
|
87 |
+
$mapToNewAsin = $this->getUrl('*/adminhtml_common_amazon_listing/mapToNewAsin');
|
88 |
+
$unmapFromNewAsin = $this->getUrl('*/adminhtml_common_amazon_listing/unmapFromAsin');
|
89 |
+
|
90 |
+
$checkNewAsinManualProducts = $this->getUrl('*/*/checkNewAsinManualProducts', array('_current' => true));
|
91 |
+
// -------------------------------
|
92 |
+
|
93 |
+
$javascript = <<<HTML
|
94 |
+
<script type="text/javascript">
|
95 |
+
selectTemplateDescription = function (el, templateId, mapToGeneralId)
|
96 |
+
{
|
97 |
+
ListingGridHandlerObj.mapToTemplateDescription(el, templateId, mapToGeneralId);
|
98 |
+
};
|
99 |
+
|
100 |
+
if (typeof M2ePro == 'undefined') {
|
101 |
+
M2ePro = {};
|
102 |
+
M2ePro.url = {};
|
103 |
+
M2ePro.formData = {};
|
104 |
+
M2ePro.customData = {};
|
105 |
+
M2ePro.text = {};
|
106 |
+
}
|
107 |
+
|
108 |
+
M2ePro.text.templateDescriptionPopupTitle = '{$templateDescriptionPopupTitle}';
|
109 |
+
M2ePro.text.setDescriptionPolicy = '{$setDescriptionPolicy}';
|
110 |
+
|
111 |
+
M2ePro.url.mapToTemplateDescription = '{$mapToTemplateDescription}';
|
112 |
+
M2ePro.url.unmapFromTemplateDescription = '{$unmapFromTemplateDescription}';
|
113 |
+
M2ePro.url.validateProductsForTemplateDescriptionAssign = '{$validateProductsForTemplateDescriptionAssign}';
|
114 |
+
M2ePro.url.viewTemplateDescriptionsGrid = '{$viewTemplateDescriptionsGrid}';
|
115 |
+
|
116 |
+
M2ePro.url.mapToNewAsin = '{$mapToNewAsin}';
|
117 |
+
M2ePro.url.unmapFromNewAsin = '{$unmapFromNewAsin}';
|
118 |
+
|
119 |
+
M2ePro.url.checkNewAsinManualProducts = '{$checkNewAsinManualProducts}';
|
120 |
+
|
121 |
+
Event.observe(window, 'load', function() {
|
122 |
+
|
123 |
+
CommonHandler.prototype.scroll_page_to_top = function() { return; }
|
124 |
+
|
125 |
+
ListingGridHandlerObj = new NewAsinTemplateDescriptionGridHandler(
|
126 |
+
'{$this->getChild('grid')->getId()}',
|
127 |
+
{$this->getListing()->getId()}
|
128 |
+
);
|
129 |
+
|
130 |
+
ListingGridHandlerObj.actionHandler.setOptions(M2ePro);
|
131 |
+
ListingGridHandlerObj.templateDescriptionHandler.setOptions(M2ePro);
|
132 |
+
});
|
133 |
+
|
134 |
+
</script>
|
135 |
+
HTML;
|
136 |
+
|
137 |
+
return $javascript .
|
138 |
+
'<div id="search_asin_products_container">' .
|
139 |
+
parent::_toHtml() .
|
140 |
+
'</div>';
|
141 |
+
}
|
142 |
+
|
143 |
+
// ####################################
|
144 |
+
|
145 |
+
public function getListing()
|
146 |
+
{
|
147 |
+
if (!$listingId = $this->getRequest()->getParam('id')) {
|
148 |
+
throw new Exception('Listing is not defined');
|
149 |
+
}
|
150 |
+
|
151 |
+
if (is_null($this->listing)) {
|
152 |
+
$this->listing = Mage::helper('M2ePro/Component_Amazon')
|
153 |
+
->getObject('Listing', $listingId)->getChildObject();
|
154 |
+
}
|
155 |
+
|
156 |
+
return $this->listing;
|
157 |
+
}
|
158 |
+
|
159 |
+
// ####################################
|
160 |
+
|
161 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/NewAsin/Manual/Grid.php
ADDED
@@ -0,0 +1,356 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Add_NewAsin_Manual_Grid
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
9 |
+
{
|
10 |
+
/** @var Ess_M2ePro_Model_Listing */
|
11 |
+
private $listing = NULL;
|
12 |
+
|
13 |
+
public function __construct()
|
14 |
+
{
|
15 |
+
parent::__construct();
|
16 |
+
|
17 |
+
// Initialization block
|
18 |
+
//------------------------------
|
19 |
+
$this->setId('newAsinManualGrid');
|
20 |
+
//------------------------------
|
21 |
+
|
22 |
+
// Set default values
|
23 |
+
//------------------------------
|
24 |
+
$this->setDefaultSort('product_id');
|
25 |
+
$this->setDefaultDir('DESC');
|
26 |
+
$this->setUseAjax(true);
|
27 |
+
//------------------------------
|
28 |
+
}
|
29 |
+
|
30 |
+
// ####################################
|
31 |
+
|
32 |
+
protected function _prepareCollection()
|
33 |
+
{
|
34 |
+
// Get collection
|
35 |
+
//----------------------------
|
36 |
+
/* @var $collection Mage_Core_Model_Mysql4_Collection_Abstract */
|
37 |
+
$collection = Mage::getConfig()->getModelInstance('Ess_M2ePro_Model_Mysql4_Magento_Product_Collection',
|
38 |
+
Mage::getModel('catalog/product')->getResource())
|
39 |
+
->setStoreId($this->getListing()->getData('store_id'))
|
40 |
+
->setListingProductModeOn()
|
41 |
+
->addAttributeToSelect('name')
|
42 |
+
->addAttributeToSelect('sku');
|
43 |
+
//----------------------------
|
44 |
+
|
45 |
+
//------------------------------
|
46 |
+
$listingProductsIds = $this->getListing()
|
47 |
+
->getSetting('additional_data', 'adding_new_asin_listing_products_ids');
|
48 |
+
|
49 |
+
$collection->joinTable(
|
50 |
+
array('lp' => 'M2ePro/Listing_Product'),
|
51 |
+
'product_id=entity_id',
|
52 |
+
array(
|
53 |
+
'id' => 'id'
|
54 |
+
),
|
55 |
+
'{{table}}.listing_id='.(int)$this->getListing()->getId()
|
56 |
+
);
|
57 |
+
$collection->joinTable(
|
58 |
+
array('elp' => 'M2ePro/Amazon_Listing_Product'),
|
59 |
+
'listing_product_id=id',
|
60 |
+
array(
|
61 |
+
'listing_product_id' => 'listing_product_id',
|
62 |
+
'template_description_id' => 'template_description_id'
|
63 |
+
)
|
64 |
+
);
|
65 |
+
|
66 |
+
$collection->getSelect()->where('lp.id IN (?)', $listingProductsIds);
|
67 |
+
$collection->getSelect()->where('elp.search_settings_status != ? OR elp.search_settings_status IS NULL',
|
68 |
+
Ess_M2ePro_Model_Amazon_Listing_Product::SEARCH_SETTINGS_STATUS_IN_PROGRESS);
|
69 |
+
$collection->getSelect()->where('elp.general_id IS NULL');
|
70 |
+
//------------------------------
|
71 |
+
|
72 |
+
//exit($collection->getSelect()->__toString());
|
73 |
+
|
74 |
+
// Set collection to grid
|
75 |
+
$this->setCollection($collection);
|
76 |
+
|
77 |
+
parent::_prepareCollection();
|
78 |
+
|
79 |
+
return $this;
|
80 |
+
}
|
81 |
+
|
82 |
+
protected function _prepareColumns()
|
83 |
+
{
|
84 |
+
$this->addColumn('product_id', array(
|
85 |
+
'header' => Mage::helper('M2ePro')->__('Product ID'),
|
86 |
+
'align' => 'right',
|
87 |
+
'width' => '100px',
|
88 |
+
'type' => 'number',
|
89 |
+
'index' => 'entity_id',
|
90 |
+
'filter_index' => 'entity_id',
|
91 |
+
'frame_callback' => array($this, 'callbackColumnProductId')
|
92 |
+
));
|
93 |
+
|
94 |
+
$this->addColumn('name', array(
|
95 |
+
'header' => Mage::helper('M2ePro')->__('Product Title / Product SKU'),
|
96 |
+
'align' => 'left',
|
97 |
+
'width' => '400px',
|
98 |
+
'type' => 'text',
|
99 |
+
'index' => 'name',
|
100 |
+
'filter_index' => 'name',
|
101 |
+
'frame_callback' => array($this, 'callbackColumnProductTitle'),
|
102 |
+
'filter_condition_callback' => array($this, 'callbackFilterProductTitle')
|
103 |
+
));
|
104 |
+
|
105 |
+
$this->addColumn('description_template', array(
|
106 |
+
'header' => Mage::helper('M2ePro')->__('Description Policy'),
|
107 |
+
'align' => 'left',
|
108 |
+
'width' => '*',
|
109 |
+
'sortable' => false,
|
110 |
+
'type' => 'options',
|
111 |
+
'index' => 'description_template_id',
|
112 |
+
'filter_index' => 'description_template_id',
|
113 |
+
'options' => array(
|
114 |
+
1 => Mage::helper('M2ePro')->__('Description Policy Selected'),
|
115 |
+
0 => Mage::helper('M2ePro')->__('Description Policy Not Selected')
|
116 |
+
),
|
117 |
+
'frame_callback' => array($this, 'callbackColumnDescriptionTemplateCallback'),
|
118 |
+
'filter_condition_callback' => array($this, 'callbackColumnDescriptionTemplateFilterCallback')
|
119 |
+
));
|
120 |
+
|
121 |
+
$actionsColumn = array(
|
122 |
+
'header' => Mage::helper('M2ePro')->__('Actions'),
|
123 |
+
'renderer' => 'M2ePro/adminhtml_grid_column_renderer_action',
|
124 |
+
'align' => 'center',
|
125 |
+
'width' => '130px',
|
126 |
+
'type' => 'text',
|
127 |
+
'field' => 'id',
|
128 |
+
'sortable' => false,
|
129 |
+
'filter' => false,
|
130 |
+
'actions' => array()
|
131 |
+
);
|
132 |
+
|
133 |
+
$actions = array(
|
134 |
+
array(
|
135 |
+
'caption' => Mage::helper('M2ePro')->__('Set Description Policy'),
|
136 |
+
'field' => 'id',
|
137 |
+
'onclick_action' => 'ListingGridHandlerObj.setDescriptionTemplateRowAction'
|
138 |
+
),
|
139 |
+
array(
|
140 |
+
'caption' => Mage::helper('M2ePro')->__('Reset Description Policy'),
|
141 |
+
'field' => 'id',
|
142 |
+
'onclick_action' => 'ListingGridHandlerObj.resetDescriptionTemplateRowAction'
|
143 |
+
)
|
144 |
+
);
|
145 |
+
|
146 |
+
$actionsColumn['actions'] = $actions;
|
147 |
+
|
148 |
+
$this->addColumn('actions', $actionsColumn);
|
149 |
+
|
150 |
+
return parent::_prepareColumns();
|
151 |
+
}
|
152 |
+
|
153 |
+
protected function _prepareMassaction()
|
154 |
+
{
|
155 |
+
$this->setMassactionIdField('listing_product_id');
|
156 |
+
$this->setMassactionIdFieldOnlyIndexValue(true);
|
157 |
+
|
158 |
+
//--------------------------------
|
159 |
+
$this->getMassactionBlock()->addItem('setDescriptionTemplate', array(
|
160 |
+
'label' => Mage::helper('M2ePro')->__('Set Description Policy'),
|
161 |
+
'url' => ''
|
162 |
+
));
|
163 |
+
|
164 |
+
$this->getMassactionBlock()->addItem('resetDescriptionTemplate', array(
|
165 |
+
'label' => Mage::helper('M2ePro')->__('Reset Description Policy'),
|
166 |
+
'url' => ''
|
167 |
+
));
|
168 |
+
//--------------------------------
|
169 |
+
|
170 |
+
return parent::_prepareMassaction();
|
171 |
+
}
|
172 |
+
|
173 |
+
// ########################################
|
174 |
+
|
175 |
+
public function callbackColumnProductId($value, $row, $column, $isExport)
|
176 |
+
{
|
177 |
+
$productId = (int)$row->getData('entity_id');
|
178 |
+
$storeId = (int)$this->listing->getData('store_id');
|
179 |
+
|
180 |
+
$url = $this->getUrl('adminhtml/catalog_product/edit', array('id' => $productId));
|
181 |
+
$htmlWithoutThumbnail = '<a href="' . $url . '" target="_blank">'.$productId.'</a>';
|
182 |
+
|
183 |
+
$showProductsThumbnails = (bool)(int)Mage::helper('M2ePro/Module')->getConfig()
|
184 |
+
->getGroupValue('/view/','show_products_thumbnails');
|
185 |
+
|
186 |
+
if (!$showProductsThumbnails) {
|
187 |
+
return $htmlWithoutThumbnail;
|
188 |
+
}
|
189 |
+
|
190 |
+
/** @var $magentoProduct Ess_M2ePro_Model_Magento_Product */
|
191 |
+
$magentoProduct = Mage::getModel('M2ePro/Magento_Product');
|
192 |
+
$magentoProduct->setProductId($productId);
|
193 |
+
$magentoProduct->setStoreId($storeId);
|
194 |
+
|
195 |
+
$thumbnail = $magentoProduct->getThumbnailImageLink();
|
196 |
+
if (is_null($thumbnail)) {
|
197 |
+
return $htmlWithoutThumbnail;
|
198 |
+
}
|
199 |
+
|
200 |
+
return <<<HTML
|
201 |
+
<a href="{$url}" target="_blank">
|
202 |
+
{$productId}
|
203 |
+
<hr style="border: 1px solid silver; border-bottom: none;">
|
204 |
+
<img src="{$thumbnail}" />
|
205 |
+
</a>
|
206 |
+
HTML;
|
207 |
+
}
|
208 |
+
|
209 |
+
public function callbackColumnProductTitle($productTitle, $row, $column, $isExport)
|
210 |
+
{
|
211 |
+
if (strlen($productTitle) > 60) {
|
212 |
+
$productTitle = substr($productTitle, 0, 60) . '...';
|
213 |
+
}
|
214 |
+
|
215 |
+
$productTitle = Mage::helper('M2ePro')->escapeHtml($productTitle);
|
216 |
+
|
217 |
+
$value = '<span>'.$productTitle.'</span>';
|
218 |
+
|
219 |
+
$sku = $row->getData('sku');
|
220 |
+
|
221 |
+
$value .= '<br/><strong>'.Mage::helper('M2ePro')->__('SKU') .
|
222 |
+
':</strong> '.Mage::helper('M2ePro')->escapeHtml($sku) . '<br/>';
|
223 |
+
|
224 |
+
$listingProductId = (int)$row->getData('id');
|
225 |
+
/** @var Ess_M2ePro_Model_Listing_Product $listingProduct */
|
226 |
+
$listingProduct = Mage::helper('M2ePro/Component_Amazon')->getObject('Listing_Product',$listingProductId);
|
227 |
+
|
228 |
+
if (!$listingProduct->getChildObject()->getVariationManager()->isVariationProduct()) {
|
229 |
+
return $value;
|
230 |
+
}
|
231 |
+
|
232 |
+
$productOptions = $listingProduct->getChildObject()->getVariationManager()
|
233 |
+
->getTypeModel()->getProductAttributes();
|
234 |
+
|
235 |
+
$value .= '<div style="font-size: 11px; font-weight: bold; color: grey; margin-left: 7px"><br/>';
|
236 |
+
$value .= implode(', ', $productOptions);
|
237 |
+
$value .= '</div>';
|
238 |
+
|
239 |
+
return $value;
|
240 |
+
}
|
241 |
+
|
242 |
+
public function callbackColumnDescriptionTemplateCallback($value, $row, $column, $isExport)
|
243 |
+
{
|
244 |
+
$descriptionTemplateId = $row->getData('template_description_id');
|
245 |
+
|
246 |
+
if (empty($descriptionTemplateId)) {
|
247 |
+
$iconSrc = $this->getSkinUrl('M2ePro/images/warning.png');
|
248 |
+
$label = Mage::helper('M2ePro')->__('Not Selected');
|
249 |
+
|
250 |
+
return <<<HTML
|
251 |
+
<img src="{$iconSrc}" alt=""> <span style="color: gray; font-style: italic;">{$label}</span>
|
252 |
+
HTML;
|
253 |
+
}
|
254 |
+
|
255 |
+
$templateDescriptionEditUrl = $this->getUrl('*/adminhtml_common_amazon_template_description/edit', array(
|
256 |
+
'id' => $descriptionTemplateId
|
257 |
+
));
|
258 |
+
|
259 |
+
/** @var Ess_M2ePro_Model_Amazon_Template_Description $descriptionTemplate */
|
260 |
+
$descriptionTemplate = Mage::helper('M2ePro/Component_Amazon')
|
261 |
+
->getModel('Template_Description')->load($descriptionTemplateId);
|
262 |
+
|
263 |
+
$title = Mage::helper('M2ePro')->escapeHtml($descriptionTemplate->getData('title'));
|
264 |
+
|
265 |
+
return <<<HTML
|
266 |
+
<a target="_blank" href="{$templateDescriptionEditUrl}">{$title}</a>
|
267 |
+
HTML;
|
268 |
+
}
|
269 |
+
|
270 |
+
// ########################################
|
271 |
+
|
272 |
+
protected function callbackFilterProductTitle($collection, $column)
|
273 |
+
{
|
274 |
+
$value = $column->getFilter()->getValue();
|
275 |
+
|
276 |
+
if ($value == null) {
|
277 |
+
return;
|
278 |
+
}
|
279 |
+
|
280 |
+
$collection->addFieldToFilter(
|
281 |
+
array(
|
282 |
+
array('attribute'=>'sku','like'=>'%'.$value.'%'),
|
283 |
+
array('attribute'=>'name', 'like'=>'%'.$value.'%')
|
284 |
+
)
|
285 |
+
);
|
286 |
+
}
|
287 |
+
|
288 |
+
// ----------------------------------------
|
289 |
+
|
290 |
+
protected function callbackColumnDescriptionTemplateFilterCallback($collection, $column)
|
291 |
+
{
|
292 |
+
$value = $column->getFilter()->getValue();
|
293 |
+
|
294 |
+
if ($value == null) {
|
295 |
+
return;
|
296 |
+
}
|
297 |
+
|
298 |
+
if ($value) {
|
299 |
+
$collection->addFieldToFilter('template_description_id', array('notnull' => null));
|
300 |
+
} else {
|
301 |
+
$collection->addFieldToFilter('template_description_id', array('null' => null));
|
302 |
+
}
|
303 |
+
}
|
304 |
+
|
305 |
+
// ########################################
|
306 |
+
|
307 |
+
public function getRowUrl($row)
|
308 |
+
{
|
309 |
+
return false;
|
310 |
+
}
|
311 |
+
|
312 |
+
// ####################################
|
313 |
+
|
314 |
+
protected function _toHtml()
|
315 |
+
{
|
316 |
+
$javascriptsMain = <<<JAVASCRIPT
|
317 |
+
<script type="text/javascript">
|
318 |
+
|
319 |
+
if (typeof ListingGridHandlerObj != 'undefined') {
|
320 |
+
ListingGridHandlerObj.afterInitPage();
|
321 |
+
}
|
322 |
+
|
323 |
+
Event.observe(window, 'load', function() {
|
324 |
+
setTimeout(function() {
|
325 |
+
ListingGridHandlerObj.afterInitPage();
|
326 |
+
}, 350);
|
327 |
+
});
|
328 |
+
|
329 |
+
</script>
|
330 |
+
JAVASCRIPT;
|
331 |
+
|
332 |
+
return parent::_toHtml() . $javascriptsMain;
|
333 |
+
}
|
334 |
+
|
335 |
+
// ####################################
|
336 |
+
|
337 |
+
/**
|
338 |
+
* @return Ess_M2ePro_Model_Amazon_Listing
|
339 |
+
* @throws Exception
|
340 |
+
*/
|
341 |
+
public function getListing()
|
342 |
+
{
|
343 |
+
if (!$listingId = $this->getRequest()->getParam('id')) {
|
344 |
+
throw new Exception('Listing is not defined');
|
345 |
+
}
|
346 |
+
|
347 |
+
if (is_null($this->listing)) {
|
348 |
+
$this->listing = Mage::helper('M2ePro/Component_Amazon')
|
349 |
+
->getObject('Listing', $listingId)->getChildObject();
|
350 |
+
}
|
351 |
+
|
352 |
+
return $this->listing;
|
353 |
+
}
|
354 |
+
|
355 |
+
// ####################################
|
356 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/NewAsin/Manual/SkipPopup.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2011 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Add_NewAsin_Manual_SkipPopup
|
8 |
+
extends Mage_Adminhtml_Block_Template
|
9 |
+
{
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('amazonListingAddNewAsinManualPopup');
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$this->setTemplate('M2ePro/common/amazon/listing/add/search_asin/manual/skip_popup.phtml');
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _beforeToHtml()
|
24 |
+
{
|
25 |
+
parent::_beforeToHtml();
|
26 |
+
|
27 |
+
$url = $this->getUrl('*/*/index', array('_current' => true, 'step' => 3));
|
28 |
+
|
29 |
+
$data = array(
|
30 |
+
'class' => 'next',
|
31 |
+
'label' => Mage::helper('M2ePro')->__('Continue'),
|
32 |
+
'onclick' => 'setLocation(\''.$url.'\')',
|
33 |
+
);
|
34 |
+
$this->setChild('continue_button',$this->getLayout()->createBlock('adminhtml/widget_button')->setData($data));
|
35 |
+
|
36 |
+
return $this;
|
37 |
+
}
|
38 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/Review.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2011 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Add_Review
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_Review
|
9 |
+
{
|
10 |
+
// ####################################
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->setId('listingProductReview');
|
19 |
+
$this->setData('component', Ess_M2ePro_Helper_Component_Amazon::NICK);
|
20 |
+
//------------------------------
|
21 |
+
|
22 |
+
$this->_headerText = Mage::helper('M2ePro')->__('Congratulations');
|
23 |
+
|
24 |
+
$this->setTemplate('M2ePro/common/amazon/listing/add/review.phtml');
|
25 |
+
}
|
26 |
+
|
27 |
+
// ####################################
|
28 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/SearchAsin.php
ADDED
@@ -0,0 +1,270 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Add_SearchAsin
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Container
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
$listingId = $this->getRequest()->getParam('id');
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->setId('searchAsinForListingProducts');
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
// Set header text
|
22 |
+
//------------------------------
|
23 |
+
$this->_headerText = Mage::helper('M2ePro')->__("Search Existing Amazon Products (ASIN/ISBN)");
|
24 |
+
$this->_blockGroup = 'M2ePro';
|
25 |
+
$this->_controller = 'adminhtml_common_amazon_listing_add_searchAsin';
|
26 |
+
//------------------------------
|
27 |
+
|
28 |
+
// Set buttons actions
|
29 |
+
//------------------------------
|
30 |
+
$this->removeButton('back');
|
31 |
+
$this->removeButton('reset');
|
32 |
+
$this->removeButton('delete');
|
33 |
+
$this->removeButton('add');
|
34 |
+
$this->removeButton('save');
|
35 |
+
$this->removeButton('edit');
|
36 |
+
//------------------------------
|
37 |
+
|
38 |
+
//------------------------------
|
39 |
+
$url = $this->getUrl('*/*/removeAddedProducts', array(
|
40 |
+
'id' => $listingId,
|
41 |
+
'_current' => true
|
42 |
+
));
|
43 |
+
$this->_addButton('back', array(
|
44 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
45 |
+
'onclick' => 'ListingGridHandlerObj.back_click(\'' . $url . '\')',
|
46 |
+
'class' => 'back'
|
47 |
+
));
|
48 |
+
|
49 |
+
//------------------------------
|
50 |
+
$this->_addButton('auto_action', array(
|
51 |
+
'label' => Mage::helper('M2ePro')->__('Edit Search Settings'),
|
52 |
+
'onclick' => 'ListingGridHandlerObj.editSearchSettings(\'' .
|
53 |
+
Mage::helper('M2ePro')->__('Listing Search Settings') . '\' ,' .
|
54 |
+
$this->getListing()->getId() .
|
55 |
+
');'
|
56 |
+
));
|
57 |
+
//------------------------------
|
58 |
+
|
59 |
+
//------------------------------
|
60 |
+
$this->_addButton('save_and_go_to_listing_view', array(
|
61 |
+
'label' => Mage::helper('M2ePro')->__('Continue'),
|
62 |
+
'onclick' => 'ListingGridHandlerObj.checkSearchResults('.$listingId.')',
|
63 |
+
'class' => 'scalable next'
|
64 |
+
));
|
65 |
+
//------------------------------
|
66 |
+
}
|
67 |
+
|
68 |
+
public function getGridHtml()
|
69 |
+
{
|
70 |
+
$listing = Mage::helper('M2ePro/Component')
|
71 |
+
->getCachedUnknownObject('Listing', $this->getRequest()->getParam('id'));
|
72 |
+
|
73 |
+
$viewHeaderBlock = $this->getLayout()->createBlock(
|
74 |
+
'M2ePro/adminhtml_listing_view_header','',
|
75 |
+
array('listing' => $listing)
|
76 |
+
);
|
77 |
+
|
78 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_listing_add_searchAsin_help');
|
79 |
+
|
80 |
+
$productSearchBlock = $this->getLayout()
|
81 |
+
->createBlock('M2ePro/adminhtml_common_amazon_listing_productSearch_main');
|
82 |
+
|
83 |
+
return $helpBlock->toHtml()
|
84 |
+
. $viewHeaderBlock->toHtml()
|
85 |
+
. $productSearchBlock->toHtml()
|
86 |
+
. parent::getGridHtml();
|
87 |
+
}
|
88 |
+
|
89 |
+
protected function _toHtml()
|
90 |
+
{
|
91 |
+
$helper = Mage::helper('M2ePro');
|
92 |
+
|
93 |
+
// --------TEXT------------------
|
94 |
+
$createEmptyListingMessage = $helper->escapeJs($helper->__('Are you sure you want to create empty Listing?'));
|
95 |
+
|
96 |
+
$taskCompletedMessage = $helper->escapeJs($helper->__('Task completed. Please wait ...'));
|
97 |
+
$taskCompletedSuccessMessage = $helper->escapeJs(
|
98 |
+
$helper->__('"%task_title%" Task has successfully submitted to be processed.')
|
99 |
+
);
|
100 |
+
$taskCompletedWarningMessage = $helper->escapeJs($helper->__(
|
101 |
+
'"%task_title%" Task has completed with warnings. <a target="_blank" href="%url%">View Log</a> for details.'
|
102 |
+
));
|
103 |
+
$taskCompletedErrorMessage = $helper->escapeJs($helper->__(
|
104 |
+
'"%task_title%" Task has completed with errors. <a target="_blank" href="%url%">View Log</a> for details.'
|
105 |
+
));
|
106 |
+
|
107 |
+
$sendingDataToAmazonMessage = $helper->escapeJs($helper->__(
|
108 |
+
'Sending %product_title% Product(s) data on Amazon.')
|
109 |
+
);
|
110 |
+
|
111 |
+
$selectItemsMessage = $helper->escapeJs(
|
112 |
+
$helper->__('Please select the Products you want to perform the Action on.')
|
113 |
+
);
|
114 |
+
|
115 |
+
$assignString = Mage::helper('M2ePro')->__('Assign');
|
116 |
+
$textConfirm = $helper->escapeJs($helper->__('Are you sure?'));
|
117 |
+
|
118 |
+
$enterProductSearchQueryMessage = $helper->escapeJs(
|
119 |
+
$helper->__('Please enter Product Title or ASIN/ISBN/UPC/EAN.')
|
120 |
+
);
|
121 |
+
$autoMapAsinSearchProducts = $helper->escapeJs($helper->__('Search %product_title% Product(s) on Amazon.'));
|
122 |
+
$autoMapAsinProgressTitle = $helper->escapeJs($helper->__('Automatic Assigning ASIN/ISBN to Item(s)'));
|
123 |
+
$autoMapAsinErrorMessage = $helper->escapeJs(
|
124 |
+
$helper->__('Server is currently unavailable. Please try again later.')
|
125 |
+
);
|
126 |
+
$newAsinNotAvailable = $helper->escapeJs(
|
127 |
+
$helper->__('The new ASIN/ISBN creation functionality is not available in %code% Marketplace yet.')
|
128 |
+
);
|
129 |
+
$notSynchronizedMarketplace = $helper->escapeJs(
|
130 |
+
$helper->__(
|
131 |
+
'In order to use New ASIN/ISBN functionality, please re-synchronize Marketplace data.'
|
132 |
+
).' '.
|
133 |
+
$helper->__(
|
134 |
+
'Press "Save And Update" Button after redirect on Marketplace Page.'
|
135 |
+
)
|
136 |
+
);
|
137 |
+
|
138 |
+
$newAsinPopupTitle = $helper->escapeJs($helper->__('New ASIN/ISBN creation'));
|
139 |
+
// -------------------------------
|
140 |
+
|
141 |
+
// ---------URL-------------------
|
142 |
+
$searchAsinManual = $this->getUrl('*/adminhtml_common_amazon_listing/searchAsinManual');
|
143 |
+
$getSearchAsinMenu = $this->getUrl('*/adminhtml_common_amazon_listing/getSearchAsinMenu');
|
144 |
+
$suggestedAsinGridHmtl = $this->getUrl('*/adminhtml_common_amazon_listing/getSuggestedAsinGrid');
|
145 |
+
$searchAsinAuto = $this->getUrl('*/adminhtml_common_amazon_listing/searchAsinAuto');
|
146 |
+
$getProductsSearchStatus = $this->getUrl('*/adminhtml_common_amazon_listing/getProductsSearchStatus');
|
147 |
+
$mapToAsin = $this->getUrl('*/adminhtml_common_amazon_listing/mapToAsin');
|
148 |
+
$unmapFromAsin = $this->getUrl('*/adminhtml_common_amazon_listing/unmapFromAsin');
|
149 |
+
$mapToNewAsin = $this->getUrl('*/adminhtml_common_amazon_listing/mapToNewAsin');
|
150 |
+
|
151 |
+
$viewSearchSettings = $this->getUrl('*/adminhtml_common_amazon_listing_productAdd/viewSearchSettings');
|
152 |
+
$saveSearchSettings = $this->getUrl('*/adminhtml_common_amazon_listing_productAdd/saveSearchSettings');
|
153 |
+
|
154 |
+
$checkSearchResults = $this->getUrl('*/adminhtml_common_amazon_listing_productAdd/checkSearchResults', array(
|
155 |
+
'id' => $this->getListing()->getId()
|
156 |
+
));
|
157 |
+
|
158 |
+
$showNewAsinStep = $this->getUrl('*/adminhtml_common_amazon_listing_productAdd/showNewAsinStep', array(
|
159 |
+
'id' => $this->getListing()->getId()
|
160 |
+
));
|
161 |
+
|
162 |
+
$getProductsUrl = $this->getUrl(
|
163 |
+
'*/adminhtml_common_' . $this->getData('component') . '_listing/getProductsFromCategories'
|
164 |
+
);
|
165 |
+
$addProductsUrl = $this->getUrl(
|
166 |
+
'*/adminhtml_common_listing_productAdd/addProducts', array(
|
167 |
+
'component' => $this->getData('component')
|
168 |
+
)
|
169 |
+
);
|
170 |
+
$backUrl = $this->getUrl('*/*/index');
|
171 |
+
// -------------------------------
|
172 |
+
|
173 |
+
$javascript = <<<JAVASCRIPT
|
174 |
+
<script type="text/javascript">
|
175 |
+
if (typeof M2ePro == 'undefined') {
|
176 |
+
M2ePro = {};
|
177 |
+
M2ePro.url = {};
|
178 |
+
M2ePro.formData = {};
|
179 |
+
M2ePro.customData = {};
|
180 |
+
M2ePro.text = {};
|
181 |
+
}
|
182 |
+
|
183 |
+
M2ePro.text.select_items_message = '{$selectItemsMessage}';
|
184 |
+
M2ePro.text.create_empty_listing_message = '{$createEmptyListingMessage}';
|
185 |
+
|
186 |
+
M2ePro.text.sending_data_message = '{$sendingDataToAmazonMessage}';
|
187 |
+
|
188 |
+
M2ePro.text.new_asin_not_available = '{$newAsinNotAvailable}';
|
189 |
+
M2ePro.text.not_synchronized_marketplace = '{$notSynchronizedMarketplace}';
|
190 |
+
|
191 |
+
M2ePro.text.enter_productSearch_query = '{$enterProductSearchQueryMessage}';
|
192 |
+
M2ePro.text.automap_asin_search_products = '{$autoMapAsinSearchProducts}';
|
193 |
+
M2ePro.text.automap_asin_progress_title = '{$autoMapAsinProgressTitle}';
|
194 |
+
M2ePro.text.automap_error_message = '{$autoMapAsinErrorMessage}';
|
195 |
+
|
196 |
+
M2ePro.text.task_completed_message = '{$taskCompletedMessage}';
|
197 |
+
M2ePro.text.task_completed_success_message = '{$taskCompletedSuccessMessage}';
|
198 |
+
M2ePro.text.task_completed_warning_message = '{$taskCompletedWarningMessage}';
|
199 |
+
M2ePro.text.task_completed_error_message = '{$taskCompletedErrorMessage}';
|
200 |
+
|
201 |
+
M2ePro.text.assign = '{$assignString}';
|
202 |
+
M2ePro.text.confirm = '{$textConfirm}';
|
203 |
+
|
204 |
+
M2ePro.text.new_asin_popup_title = '{$newAsinPopupTitle}';
|
205 |
+
|
206 |
+
M2ePro.url.get_products_from_categories = '{$getProductsUrl}';
|
207 |
+
M2ePro.url.add_products = '{$addProductsUrl}';
|
208 |
+
M2ePro.url.back = '{$backUrl}';
|
209 |
+
|
210 |
+
M2ePro.url.searchAsinManual = '{$searchAsinManual}';
|
211 |
+
M2ePro.url.getSearchAsinMenu = '{$getSearchAsinMenu}';
|
212 |
+
M2ePro.url.searchAsinAuto = '{$searchAsinAuto}';
|
213 |
+
M2ePro.url.getProductsSearchStatus = '{$getProductsSearchStatus}';
|
214 |
+
M2ePro.url.suggestedAsinGrid = '{$suggestedAsinGridHmtl}';
|
215 |
+
M2ePro.url.mapToAsin = '{$mapToAsin}';
|
216 |
+
M2ePro.url.unmapFromAsin = '{$unmapFromAsin}';
|
217 |
+
M2ePro.url.mapToNewAsin = '{$mapToNewAsin}';
|
218 |
+
|
219 |
+
M2ePro.url.viewSearchSettings = '{$viewSearchSettings}';
|
220 |
+
M2ePro.url.saveSearchSettings = '{$saveSearchSettings}';
|
221 |
+
|
222 |
+
M2ePro.url.checkSearchResults = '{$checkSearchResults}';
|
223 |
+
M2ePro.url.showNewAsinStep = '{$showNewAsinStep}';
|
224 |
+
|
225 |
+
Event.observe(window, 'load', function() {
|
226 |
+
|
227 |
+
CommonHandler.prototype.scroll_page_to_top = function() { return; }
|
228 |
+
|
229 |
+
ListingGridHandlerObj = new SearchAsinGridHandler(
|
230 |
+
'{$this->getChild('grid')->getId()}',
|
231 |
+
{$this->getListing()->getId()}
|
232 |
+
);
|
233 |
+
|
234 |
+
// todo next (temp solution)
|
235 |
+
ListingGridHandlerObj.actionHandler.setOptions(M2ePro);
|
236 |
+
ListingGridHandlerObj.productSearchHandler.setOptions(M2ePro);
|
237 |
+
|
238 |
+
ListingProgressBarObj = new ProgressBar('search_asin_progress_bar');
|
239 |
+
GridWrapperObj = new AreaWrapper('search_asin_products_container');
|
240 |
+
});
|
241 |
+
|
242 |
+
</script>
|
243 |
+
JAVASCRIPT;
|
244 |
+
|
245 |
+
return $javascript .
|
246 |
+
'<div id="search_asin_progress_bar"></div>' .
|
247 |
+
'<div id="search_asin_products_container">' .
|
248 |
+
parent::_toHtml() .
|
249 |
+
'</div>';
|
250 |
+
}
|
251 |
+
|
252 |
+
// ####################################
|
253 |
+
|
254 |
+
public function getListing()
|
255 |
+
{
|
256 |
+
if (!$listingId = $this->getRequest()->getParam('id')) {
|
257 |
+
throw new Exception('Listing is not defined');
|
258 |
+
}
|
259 |
+
|
260 |
+
if (is_null($this->listing)) {
|
261 |
+
$this->listing = Mage::helper('M2ePro/Component_Amazon')
|
262 |
+
->getObject('Listing', $listingId)->getChildObject();
|
263 |
+
}
|
264 |
+
|
265 |
+
return $this->listing;
|
266 |
+
}
|
267 |
+
|
268 |
+
// ####################################
|
269 |
+
|
270 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/SearchAsin/Grid.php
ADDED
@@ -0,0 +1,684 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Add_SearchAsin_Grid
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
9 |
+
{
|
10 |
+
/** @var Ess_M2ePro_Model_Listing */
|
11 |
+
private $listing = NULL;
|
12 |
+
|
13 |
+
const SEARCH_SETTINGS_STATUS_NONE = 'none';
|
14 |
+
const SEARCH_SETTINGS_STATUS_COMPLETED = 'completed';
|
15 |
+
|
16 |
+
public function __construct()
|
17 |
+
{
|
18 |
+
parent::__construct();
|
19 |
+
|
20 |
+
$listingData = $this->getListing()->getData();
|
21 |
+
|
22 |
+
// Initialization block
|
23 |
+
//------------------------------
|
24 |
+
$this->setId('searchAsinForListingProductsGrid'.$listingData['id']);
|
25 |
+
//------------------------------
|
26 |
+
|
27 |
+
// Set default values
|
28 |
+
//------------------------------
|
29 |
+
$this->setDefaultSort('product_id');
|
30 |
+
$this->setDefaultDir('DESC');
|
31 |
+
$this->setUseAjax(true);
|
32 |
+
//------------------------------
|
33 |
+
}
|
34 |
+
|
35 |
+
// ####################################
|
36 |
+
|
37 |
+
protected function _prepareCollection()
|
38 |
+
{
|
39 |
+
$listingProductsIds = $this->getListing()->getSetting('additional_data', 'adding_listing_products_ids');
|
40 |
+
$listingData = $this->getListing()->getData();
|
41 |
+
|
42 |
+
// Get collection
|
43 |
+
//----------------------------
|
44 |
+
/* @var $collection Mage_Core_Model_Mysql4_Collection_Abstract */
|
45 |
+
$collection = Mage::getConfig()->getModelInstance('Ess_M2ePro_Model_Mysql4_Magento_Product_Collection',
|
46 |
+
Mage::getModel('catalog/product')->getResource());
|
47 |
+
$collection->setStoreId($listingData['store_id'])
|
48 |
+
->setListingProductModeOn()
|
49 |
+
->addAttributeToSelect('name')
|
50 |
+
->addAttributeToSelect('sku')
|
51 |
+
->joinTable(
|
52 |
+
array('cisi' => 'cataloginventory/stock_item'),
|
53 |
+
'product_id=entity_id',
|
54 |
+
array('qty' => 'qty'),
|
55 |
+
'{{table}}.stock_id=1',
|
56 |
+
'left'
|
57 |
+
);
|
58 |
+
|
59 |
+
//----------------------------
|
60 |
+
|
61 |
+
$collection->joinTable(
|
62 |
+
array('lp' => 'M2ePro/Listing_Product'),
|
63 |
+
'product_id=entity_id',
|
64 |
+
array(
|
65 |
+
'id' => 'id',
|
66 |
+
'component_mode' => 'component_mode',
|
67 |
+
'amazon_status' => 'status',
|
68 |
+
'additional_data' => 'additional_data'
|
69 |
+
),
|
70 |
+
array(
|
71 |
+
'listing_id' => (int)$listingData['id']
|
72 |
+
)
|
73 |
+
);
|
74 |
+
$collection->joinTable(
|
75 |
+
array('alp' => 'M2ePro/Amazon_Listing_Product'),
|
76 |
+
'listing_product_id=id',
|
77 |
+
array(
|
78 |
+
'general_id' => 'general_id',
|
79 |
+
'general_id_search_info' => 'general_id_search_info',
|
80 |
+
'search_settings_status' => 'search_settings_status',
|
81 |
+
'search_settings_data' => 'search_settings_data',
|
82 |
+
'variation_child_statuses' => 'variation_child_statuses',
|
83 |
+
'amazon_sku' => 'sku',
|
84 |
+
'online_qty' => 'online_qty',
|
85 |
+
'online_price' => 'online_price',
|
86 |
+
'online_sale_price' => 'online_sale_price',
|
87 |
+
'is_afn_channel' => 'is_afn_channel',
|
88 |
+
'is_general_id_owner' => 'is_general_id_owner',
|
89 |
+
'is_variation_parent' => 'is_variation_parent',
|
90 |
+
),
|
91 |
+
'{{table}}.variation_parent_id is NULL'
|
92 |
+
);
|
93 |
+
|
94 |
+
$collection->getSelect()->where('id IN (?)', $listingProductsIds);
|
95 |
+
|
96 |
+
//----------------------------
|
97 |
+
// exit($collection->getSelect()->__toString());
|
98 |
+
|
99 |
+
// Set collection to grid
|
100 |
+
$this->setCollection($collection);
|
101 |
+
|
102 |
+
return parent::_prepareCollection();
|
103 |
+
}
|
104 |
+
|
105 |
+
protected function _prepareColumns()
|
106 |
+
{
|
107 |
+
$this->addColumn('product_id', array(
|
108 |
+
'header' => Mage::helper('M2ePro')->__('Product ID'),
|
109 |
+
'align' => 'right',
|
110 |
+
'width' => '100px',
|
111 |
+
'type' => 'number',
|
112 |
+
'index' => 'entity_id',
|
113 |
+
'filter_index' => 'entity_id',
|
114 |
+
'frame_callback' => array($this, 'callbackColumnProductId')
|
115 |
+
));
|
116 |
+
|
117 |
+
$this->addColumn('name', array(
|
118 |
+
'header' => Mage::helper('M2ePro')->__('Product Title / Product SKU'),
|
119 |
+
'align' => 'left',
|
120 |
+
'type' => 'text',
|
121 |
+
'index' => 'name',
|
122 |
+
'filter_index' => 'name',
|
123 |
+
'frame_callback' => array($this, 'callbackColumnProductTitle'),
|
124 |
+
'filter_condition_callback' => array($this, 'callbackFilterTitle')
|
125 |
+
));
|
126 |
+
|
127 |
+
$this->addColumn('general_id', array(
|
128 |
+
'header' => Mage::helper('M2ePro')->__('ASIN / ISBN'),
|
129 |
+
'align' => 'left',
|
130 |
+
'width' => '140px',
|
131 |
+
'type' => 'text',
|
132 |
+
'index' => 'general_id',
|
133 |
+
'filter_index' => 'general_id',
|
134 |
+
'frame_callback' => array($this, 'callbackColumnGeneralId')
|
135 |
+
));
|
136 |
+
|
137 |
+
if ($this->getListing()->getChildObject()->isGeneralIdAttributeMode() ||
|
138 |
+
$this->getListing()->getChildObject()->isWorldwideIdAttributeMode()) {
|
139 |
+
|
140 |
+
$this->addColumn('settings', array(
|
141 |
+
'header' => Mage::helper('M2ePro')->__('Search Settings Values'),
|
142 |
+
'align' => 'left',
|
143 |
+
'width' => '240px',
|
144 |
+
'filter' => false,
|
145 |
+
'sortable' => false,
|
146 |
+
'type' => 'text',
|
147 |
+
'index' => 'id',
|
148 |
+
'frame_callback' => array($this, 'callbackColumnSettings')
|
149 |
+
));
|
150 |
+
}
|
151 |
+
|
152 |
+
$this->addColumn('status', array(
|
153 |
+
'header' => Mage::helper('M2ePro')->__('Status'),
|
154 |
+
'width' => '200px',
|
155 |
+
'index' => 'search_settings_status',
|
156 |
+
'filter_index' => 'search_settings_status',
|
157 |
+
'sortable' => false,
|
158 |
+
'type' => 'options',
|
159 |
+
'options' => array(
|
160 |
+
self::SEARCH_SETTINGS_STATUS_NONE => Mage::helper('M2ePro')->__('None'),
|
161 |
+
Ess_M2ePro_Model_Amazon_Listing_Product::SEARCH_SETTINGS_STATUS_IN_PROGRESS =>
|
162 |
+
Mage::helper('M2ePro')->__('In Progress'),
|
163 |
+
Ess_M2ePro_Model_Amazon_Listing_Product::SEARCH_SETTINGS_STATUS_NOT_FOUND =>
|
164 |
+
Mage::helper('M2ePro')->__('Not Found'),
|
165 |
+
Ess_M2ePro_Model_Amazon_Listing_Product::SEARCH_SETTINGS_STATUS_ACTION_REQUIRED =>
|
166 |
+
Mage::helper('M2ePro')->__('Action Required'),
|
167 |
+
self::SEARCH_SETTINGS_STATUS_COMPLETED => Mage::helper('M2ePro')->__('Completed')
|
168 |
+
),
|
169 |
+
'frame_callback' => array($this, 'callbackColumnStatus'),
|
170 |
+
'filter_condition_callback' => array($this, 'callbackFilterStatus')
|
171 |
+
));
|
172 |
+
|
173 |
+
return parent::_prepareColumns();
|
174 |
+
}
|
175 |
+
|
176 |
+
protected function _prepareMassaction()
|
177 |
+
{
|
178 |
+
$this->setMassactionIdField('id');
|
179 |
+
$this->setMassactionIdFieldOnlyIndexValue(true);
|
180 |
+
|
181 |
+
//--------------------------------
|
182 |
+
$this->getMassactionBlock()->addItem('assignGeneralId', array(
|
183 |
+
'label' => Mage::helper('M2ePro')->__('Search ASIN/ISBN automatically'),
|
184 |
+
'url' => '',
|
185 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
186 |
+
));
|
187 |
+
|
188 |
+
$this->getMassactionBlock()->addItem('unassignGeneralId', array(
|
189 |
+
'label' => Mage::helper('M2ePro')->__('Reset ASIN/ISBN information'),
|
190 |
+
'url' => '',
|
191 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
192 |
+
));
|
193 |
+
//--------------------------------
|
194 |
+
|
195 |
+
return parent::_prepareMassaction();
|
196 |
+
}
|
197 |
+
|
198 |
+
// ####################################
|
199 |
+
|
200 |
+
public function callbackColumnProductId($value, $row, $column, $isExport)
|
201 |
+
{
|
202 |
+
$listingData = $this->getListing()->getData();
|
203 |
+
|
204 |
+
$productId = (int)$value;
|
205 |
+
$storeId = (int)$listingData['store_id'];
|
206 |
+
|
207 |
+
$withoutImageHtml = '<a href="'
|
208 |
+
.$this->getUrl('adminhtml/catalog_product/edit',
|
209 |
+
array('id' => $productId))
|
210 |
+
.'" target="_blank">'
|
211 |
+
.$productId
|
212 |
+
.'</a>';
|
213 |
+
|
214 |
+
$showProductsThumbnails = (bool)(int)Mage::helper('M2ePro/Module')
|
215 |
+
->getConfig()
|
216 |
+
->getGroupValue('/view/','show_products_thumbnails');
|
217 |
+
if (!$showProductsThumbnails) {
|
218 |
+
return $withoutImageHtml;
|
219 |
+
}
|
220 |
+
|
221 |
+
/** @var $magentoProduct Ess_M2ePro_Model_Magento_Product */
|
222 |
+
$magentoProduct = Mage::getModel('M2ePro/Magento_Product');
|
223 |
+
$magentoProduct->setProductId($productId);
|
224 |
+
$magentoProduct->setStoreId($storeId);
|
225 |
+
|
226 |
+
$imageUrlResized = $magentoProduct->getThumbnailImageLink();
|
227 |
+
if (is_null($imageUrlResized)) {
|
228 |
+
return $withoutImageHtml;
|
229 |
+
}
|
230 |
+
|
231 |
+
$imageHtml = $productId.'<hr/><img src="'.$imageUrlResized.'" />';
|
232 |
+
$withImageHtml = str_replace('>'.$productId.'<','>'.$imageHtml.'<',$withoutImageHtml);
|
233 |
+
|
234 |
+
return $withImageHtml;
|
235 |
+
}
|
236 |
+
|
237 |
+
public function callbackColumnProductTitle($productTitle, $row, $column, $isExport)
|
238 |
+
{
|
239 |
+
if (strlen($productTitle) > 60) {
|
240 |
+
$productTitle = substr($productTitle, 0, 60) . '...';
|
241 |
+
}
|
242 |
+
|
243 |
+
$productTitle = Mage::helper('M2ePro')->escapeHtml($productTitle);
|
244 |
+
|
245 |
+
$value = '<span>'.$productTitle.'</span>';
|
246 |
+
|
247 |
+
$tempSku = $row->getData('sku');
|
248 |
+
is_null($tempSku)
|
249 |
+
&& $tempSku = Mage::getModel('M2ePro/Magento_Product')->setProductId($row->getData('entity_id'))->getSku();
|
250 |
+
|
251 |
+
$value .= '<br/><strong>'.Mage::helper('M2ePro')->__('SKU') .
|
252 |
+
':</strong> '.Mage::helper('M2ePro')->escapeHtml($tempSku) . '<br/>';
|
253 |
+
|
254 |
+
$listingProductId = (int)$row->getData('id');
|
255 |
+
/** @var Ess_M2ePro_Model_Listing_Product $listingProduct */
|
256 |
+
$listingProduct = Mage::helper('M2ePro/Component_Amazon')->getObject('Listing_Product',$listingProductId);
|
257 |
+
|
258 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager $variationManager */
|
259 |
+
$variationManager = $listingProduct->getChildObject()->getVariationManager();
|
260 |
+
|
261 |
+
if (!$variationManager->isRelationParentType()) {
|
262 |
+
return $value;
|
263 |
+
}
|
264 |
+
|
265 |
+
$productAttributes = (array)$variationManager->getTypeModel()->getProductAttributes();
|
266 |
+
|
267 |
+
$value .= '<div style="font-size: 11px; font-weight: bold; color: grey; margin-left: 7px"><br/>';
|
268 |
+
$value .= implode(', ', $productAttributes);
|
269 |
+
$value .= '</div>';
|
270 |
+
|
271 |
+
return $value;
|
272 |
+
}
|
273 |
+
|
274 |
+
public function callbackColumnGeneralId($generalId, $row, $column, $isExport)
|
275 |
+
{
|
276 |
+
if (empty($generalId)) {
|
277 |
+
return $this->getGeneralIdColumnValueEmptyGeneralId($row);
|
278 |
+
}
|
279 |
+
|
280 |
+
return $this->getGeneralIdColumnValueNotEmptyGeneralId($row);
|
281 |
+
}
|
282 |
+
|
283 |
+
public function callbackColumnSettings($id, $row, $column, $isExport)
|
284 |
+
{
|
285 |
+
$value = '';
|
286 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product $listingProduct */
|
287 |
+
$listingProduct = Mage::helper('M2ePro/Component_Amazon')->getObject('Listing_Product', $id)->getChildObject();
|
288 |
+
|
289 |
+
if ($this->getListing()->getChildObject()->isGeneralIdAttributeMode()) {
|
290 |
+
$attrValue = $listingProduct->getListingSource()->getSearchGeneralId();
|
291 |
+
|
292 |
+
if (empty($attrValue)) {
|
293 |
+
$attrValue = Mage::helper('M2ePro')->__('Not set');
|
294 |
+
} else if (!Mage::helper('M2ePro/Component_Amazon')->isASIN($attrValue) &&
|
295 |
+
!Mage::helper('M2ePro')->isISBN($attrValue)) {
|
296 |
+
$attrValue = Mage::helper('M2ePro')->__('Inappropriate value');
|
297 |
+
}
|
298 |
+
|
299 |
+
$value .= '<b>' . Mage::helper('M2ePro')->__('ASIN/ISBN') . '</b>: ' . $attrValue . '<br/>';
|
300 |
+
}
|
301 |
+
|
302 |
+
if ($this->getListing()->getChildObject()->isWorldwideIdAttributeMode()) {
|
303 |
+
$attrValue = $listingProduct->getListingSource()->getSearchWorldwideId();
|
304 |
+
|
305 |
+
if (empty($attrValue)) {
|
306 |
+
$attrValue = Mage::helper('M2ePro')->__('Not Set');
|
307 |
+
} else if (!Mage::helper('M2ePro')->isUPC($attrValue) && !Mage::helper('M2ePro')->isEAN($attrValue)) {
|
308 |
+
$attrValue = Mage::helper('M2ePro')->__('Inappropriate value');
|
309 |
+
}
|
310 |
+
|
311 |
+
$value .= '<b>' . Mage::helper('M2ePro')->__('UPC/EAN') . '</b>: ' . $attrValue;
|
312 |
+
}
|
313 |
+
|
314 |
+
return $value;
|
315 |
+
}
|
316 |
+
|
317 |
+
public function callbackColumnStatus($value, $row, $column, $isExport)
|
318 |
+
{
|
319 |
+
$generalId = $row->getData('general_id');
|
320 |
+
$searchSettingsStatus = $row->getData('search_settings_status');
|
321 |
+
$skinUrl = $this->getSkinUrl('M2ePro');
|
322 |
+
$style = 'display: inline-block; vertical-align: middle;';
|
323 |
+
|
324 |
+
if (empty($generalId) && empty($searchSettingsStatus)) {
|
325 |
+
|
326 |
+
$msg = Mage::helper('M2ePro')->__('None');
|
327 |
+
$tip = Mage::helper('M2ePro')->__('The Search of Product was not performed yet');
|
328 |
+
|
329 |
+
return <<<HTML
|
330 |
+
<span style="color: gray; {$style}">{$msg}</span>
|
331 |
+
<img class="tool-tip-image" style="{$style}" src="{$skinUrl}/images/tool-tip-icon.png">
|
332 |
+
<span class="tool-tip-message tip-left" style="left: 528px; top: 249px; display: none; min-width: 230px;">
|
333 |
+
<img src="{$skinUrl}/images/help.png">
|
334 |
+
<span>{$tip}</span>
|
335 |
+
</span><br/>
|
336 |
+
HTML;
|
337 |
+
}
|
338 |
+
|
339 |
+
switch ($searchSettingsStatus) {
|
340 |
+
case Ess_M2ePro_Model_Amazon_Listing_Product::SEARCH_SETTINGS_STATUS_IN_PROGRESS:
|
341 |
+
$searchData = json_decode($row->getData('search_settings_data'), true);
|
342 |
+
|
343 |
+
$msg = Mage::helper('M2ePro')->__('In Progress');
|
344 |
+
$tip = Mage::helper('M2ePro')->__(
|
345 |
+
'The Search is being performed now by %type% "%value%"',
|
346 |
+
$this->prepareSearchType($searchData['type']), $searchData['value']
|
347 |
+
);
|
348 |
+
|
349 |
+
return <<<HTML
|
350 |
+
<span style="color: orange; {$style}">{$msg}</span>
|
351 |
+
<img class="tool-tip-image" style="{$style}" src="{$skinUrl}/images/tool-tip-icon.png">
|
352 |
+
<span class="tool-tip-message tip-left" style="left: 528px; top: 249px; display: none; min-width: 230px;">
|
353 |
+
<img src="{$skinUrl}/images/help.png">
|
354 |
+
<span>{$tip}</span>
|
355 |
+
</span><br/>
|
356 |
+
HTML;
|
357 |
+
|
358 |
+
case Ess_M2ePro_Model_Amazon_Listing_Product::SEARCH_SETTINGS_STATUS_NOT_FOUND:
|
359 |
+
|
360 |
+
$msg = Mage::helper('M2ePro')->__('Product was not found');
|
361 |
+
$tip = Mage::helper('M2ePro')->__('There are no Products found on Amazon after the Automatic Search
|
362 |
+
was performed according to Listing Search Settings.');
|
363 |
+
|
364 |
+
return <<<HTML
|
365 |
+
<span style="color: red; {$style}">{$msg}</span>
|
366 |
+
<img class="tool-tip-image" style="{$style}" src="{$skinUrl}/images/tool-tip-icon.png">
|
367 |
+
<span class="tool-tip-message tip-left" style="left: 528px; top: 249px; display: none; min-width: 230px;">
|
368 |
+
<img src="{$skinUrl}/images/help.png">
|
369 |
+
<span>{$tip}</span>
|
370 |
+
</span><br/>
|
371 |
+
HTML;
|
372 |
+
case Ess_M2ePro_Model_Amazon_Listing_Product::SEARCH_SETTINGS_STATUS_ACTION_REQUIRED:
|
373 |
+
|
374 |
+
$searchData = json_decode($row->getData('search_settings_data'), true);
|
375 |
+
|
376 |
+
$lpId = $row->getData('id');
|
377 |
+
|
378 |
+
$productTitle = Mage::helper('M2ePro')->escapeHtml($row->getData('name'));
|
379 |
+
if (strlen($productTitle) > 60) {
|
380 |
+
$productTitle = substr($productTitle, 0, 60) . '...';
|
381 |
+
}
|
382 |
+
$productTitle = Mage::helper('M2ePro')->__(
|
383 |
+
'Search ASIN/ISBN For "%product_title%"',
|
384 |
+
$productTitle
|
385 |
+
);
|
386 |
+
$productTitle = Mage::helper('M2ePro')->escapeJs($productTitle);
|
387 |
+
|
388 |
+
$linkTxt = Mage::helper('M2ePro')->__('Choose ASIN/ISBN');
|
389 |
+
|
390 |
+
$msg = Mage::helper('M2ePro')->__('Action Required');
|
391 |
+
$tip = Mage::helper('M2ePro')->__(
|
392 |
+
'Please choose one of the Results that were found by %type% "%value%"',
|
393 |
+
$this->prepareSearchType($searchData['type']), $searchData['value']
|
394 |
+
);
|
395 |
+
|
396 |
+
return <<<HTML
|
397 |
+
<span style="color: orange; {$style}">{$msg}</span>
|
398 |
+
<img class="tool-tip-image" style="{$style}" src="{$skinUrl}/images/tool-tip-icon.png">
|
399 |
+
<span class="tool-tip-message tip-left" style="left: 528px; top: 249px; display: none; min-width: 230px;">
|
400 |
+
<img src="{$skinUrl}/images/help.png">
|
401 |
+
<span>{$tip}</span>
|
402 |
+
</span><br/>
|
403 |
+
<a href="javascript:;" title="{$linkTxt}"
|
404 |
+
onclick="ListingGridHandlerObj.productSearchHandler.openPopUp(1,'{$productTitle}',{$lpId})">{$linkTxt}</a>
|
405 |
+
HTML;
|
406 |
+
}
|
407 |
+
|
408 |
+
$searchInfo = json_decode($row->getData('general_id_search_info'), true);
|
409 |
+
|
410 |
+
$msg = Mage::helper('M2ePro')->__('Completed');
|
411 |
+
$tip = Mage::helper('M2ePro')->__(
|
412 |
+
'Product was found by %type% "%value%"',
|
413 |
+
$this->prepareSearchType($searchInfo['type']), $searchInfo['value']
|
414 |
+
);
|
415 |
+
|
416 |
+
return <<<HTML
|
417 |
+
<span style="color: green; {$style}">{$msg}</span>
|
418 |
+
<img class="tool-tip-image" style="{$style}" src="{$skinUrl}/images/tool-tip-icon.png">
|
419 |
+
<span class="tool-tip-message tip-left" style="left: 528px; top: 249px; display: none; min-width: 230px;">
|
420 |
+
<img src="{$skinUrl}/images/help.png">
|
421 |
+
<span>{$tip}</span>
|
422 |
+
</span><br/>
|
423 |
+
HTML;
|
424 |
+
}
|
425 |
+
|
426 |
+
private function prepareSearchType($searchType)
|
427 |
+
{
|
428 |
+
if ($searchType == 'string') {
|
429 |
+
return 'query';
|
430 |
+
}
|
431 |
+
|
432 |
+
return strtoupper($searchType);
|
433 |
+
}
|
434 |
+
|
435 |
+
// ####################################
|
436 |
+
|
437 |
+
private function getGeneralIdColumnValueEmptyGeneralId($row)
|
438 |
+
{
|
439 |
+
// ---------------------------------
|
440 |
+
$iconPath = $this->getSkinUrl('M2ePro/images/search_statuses/');
|
441 |
+
// ---------------------------------
|
442 |
+
|
443 |
+
// ---------------------------------
|
444 |
+
$lpId = $row->getData('id');
|
445 |
+
|
446 |
+
$productTitle = Mage::helper('M2ePro')->escapeHtml($row->getData('name'));
|
447 |
+
if (strlen($productTitle) > 60) {
|
448 |
+
$productTitle = substr($productTitle, 0, 60) . '...';
|
449 |
+
}
|
450 |
+
$productTitle = Mage::helper('M2ePro')->__('Search ASIN/ISBN For "%product_title%"', $productTitle);
|
451 |
+
$productTitle = Mage::helper('M2ePro')->escapeJs($productTitle);
|
452 |
+
// ---------------------------------
|
453 |
+
|
454 |
+
// ---------------------------------
|
455 |
+
|
456 |
+
$searchSettingsStatus = $row->getData('search_settings_status');
|
457 |
+
|
458 |
+
// ---------------------------------
|
459 |
+
if ($searchSettingsStatus == Ess_M2ePro_Model_Amazon_Listing_Product::SEARCH_SETTINGS_STATUS_IN_PROGRESS) {
|
460 |
+
|
461 |
+
$tip = Mage::helper('M2ePro')->__('Automatic ASIN/ISBN Search in Progress.');
|
462 |
+
$iconSrc = $iconPath.'processing.gif';
|
463 |
+
|
464 |
+
return <<<HTML
|
465 |
+
|
466 |
+
<a href="javascript: void(0);" title="{$tip}">
|
467 |
+
<img src="{$iconSrc}" alt="">
|
468 |
+
</a>
|
469 |
+
HTML;
|
470 |
+
}
|
471 |
+
// ---------------------------------
|
472 |
+
|
473 |
+
$na = Mage::helper('M2ePro')->__('N/A');
|
474 |
+
$tip = Mage::helper('M2ePro')->__('Search for ASIN/ISBN');
|
475 |
+
$iconSrc = $iconPath.'search.png';
|
476 |
+
|
477 |
+
return <<<HTML
|
478 |
+
{$na}
|
479 |
+
<a href="javascript:;" title="{$tip}"
|
480 |
+
onclick="ListingGridHandlerObj.productSearchHandler.showSearchManualPrompt('{$productTitle}',{$lpId});">
|
481 |
+
<img src="{$iconSrc}" alt="" width="16" height="16">
|
482 |
+
</a>
|
483 |
+
HTML;
|
484 |
+
}
|
485 |
+
|
486 |
+
private function getGeneralIdColumnValueNotEmptyGeneralId($row)
|
487 |
+
{
|
488 |
+
$generalId = $row->getData('general_id');
|
489 |
+
$marketplaceId = Mage::helper('M2ePro/Data_Global')->getValue('marketplace_id');
|
490 |
+
|
491 |
+
$url = Mage::helper('M2ePro/Component_Amazon')->getItemUrl(
|
492 |
+
$generalId,
|
493 |
+
$marketplaceId
|
494 |
+
);
|
495 |
+
|
496 |
+
$iconPath = $this->getSkinUrl('M2ePro/images/search_statuses/');
|
497 |
+
|
498 |
+
$generalIdSearchInfo = $row->getData('general_id_search_info');
|
499 |
+
|
500 |
+
if (!empty($generalIdSearchInfo)) {
|
501 |
+
$generalIdSearchInfo = @json_decode($generalIdSearchInfo, true);
|
502 |
+
}
|
503 |
+
|
504 |
+
if (!empty($generalIdSearchInfo['is_set_automatic'])) {
|
505 |
+
|
506 |
+
$tip = Mage::helper('M2ePro')->__('ASIN/ISBN was found automatically');
|
507 |
+
|
508 |
+
$text = <<<HTML
|
509 |
+
<a href="{$url}" target="_blank" title="{$tip}" style="color:#40AADB;">{$generalId}</a>
|
510 |
+
HTML;
|
511 |
+
|
512 |
+
} else {
|
513 |
+
|
514 |
+
$text = <<<HTML
|
515 |
+
<a href="{$url}" target="_blank">{$generalId}</a>
|
516 |
+
HTML;
|
517 |
+
|
518 |
+
}
|
519 |
+
|
520 |
+
// ---------------------------------
|
521 |
+
$hasInActionLock = $this->getLockedData($row);
|
522 |
+
$hasInActionLock = $hasInActionLock['in_action'];
|
523 |
+
// ---------------------------------
|
524 |
+
|
525 |
+
if ($hasInActionLock) {
|
526 |
+
return $text;
|
527 |
+
}
|
528 |
+
|
529 |
+
$listingProductId = (int)$row->getData('id');
|
530 |
+
|
531 |
+
$tip = Mage::helper('M2ePro')->__('Unassign ASIN/ISBN');
|
532 |
+
$iconSrc = $iconPath.'unassign.png';
|
533 |
+
|
534 |
+
$text .= <<<HTML
|
535 |
+
<a href="javascript:;"
|
536 |
+
onclick="ListingGridHandlerObj.productSearchHandler.showUnmapFromGeneralIdPrompt({$listingProductId});"
|
537 |
+
title="{$tip}">
|
538 |
+
<img src="{$iconSrc}" width="16" height="16"/>
|
539 |
+
</a>
|
540 |
+
HTML;
|
541 |
+
|
542 |
+
return $text;
|
543 |
+
}
|
544 |
+
|
545 |
+
// ####################################
|
546 |
+
|
547 |
+
protected function callbackFilterTitle($collection, $column)
|
548 |
+
{
|
549 |
+
$value = $column->getFilter()->getValue();
|
550 |
+
|
551 |
+
if ($value == null) {
|
552 |
+
return;
|
553 |
+
}
|
554 |
+
|
555 |
+
$collection->addFieldToFilter(
|
556 |
+
array(
|
557 |
+
array('attribute'=>'sku','like'=>'%'.$value.'%'),
|
558 |
+
array('attribute'=>'name', 'like'=>'%'.$value.'%')
|
559 |
+
)
|
560 |
+
);
|
561 |
+
}
|
562 |
+
|
563 |
+
protected function callbackFilterStatus($collection, $column)
|
564 |
+
{
|
565 |
+
$value = $column->getFilter()->getValue();
|
566 |
+
|
567 |
+
if ($value == null) {
|
568 |
+
return;
|
569 |
+
}
|
570 |
+
|
571 |
+
if ($value == self::SEARCH_SETTINGS_STATUS_NONE) {
|
572 |
+
$collection->addFieldToFilter('general_id', array('null' => NULL));
|
573 |
+
$collection->addFieldToFilter('search_settings_status', array('null' => NULL));
|
574 |
+
return;
|
575 |
+
}
|
576 |
+
|
577 |
+
if ($value == self::SEARCH_SETTINGS_STATUS_COMPLETED) {
|
578 |
+
$collection->addFieldToFilter(
|
579 |
+
array(
|
580 |
+
array('attribute'=>'general_id', 'notnull' => NULL)
|
581 |
+
)
|
582 |
+
);
|
583 |
+
|
584 |
+
return;
|
585 |
+
}
|
586 |
+
|
587 |
+
$collection->addFieldToFilter(
|
588 |
+
array(
|
589 |
+
array('attribute' => 'search_settings_status', 'eq' => $value)
|
590 |
+
)
|
591 |
+
);
|
592 |
+
}
|
593 |
+
|
594 |
+
// ####################################
|
595 |
+
|
596 |
+
public function getRowUrl($row)
|
597 |
+
{
|
598 |
+
return false;
|
599 |
+
}
|
600 |
+
|
601 |
+
// ####################################
|
602 |
+
|
603 |
+
protected function _toHtml()
|
604 |
+
{
|
605 |
+
$disableMassactionSearch = '';
|
606 |
+
$startSearch = '';
|
607 |
+
|
608 |
+
$listing = $this->getListing();
|
609 |
+
|
610 |
+
if (!$listing->getChildObject()->isGeneralIdAttributeMode() &&
|
611 |
+
!$listing->getChildObject()->isWorldwideIdAttributeMode()) {
|
612 |
+
|
613 |
+
if (!$listing->getChildObject()->isSearchByMagentoTitleModeEnabled()) {
|
614 |
+
$gridId = $this->getId();
|
615 |
+
|
616 |
+
$disableMassactionSearch = <<<JS
|
617 |
+
var mmassActionEl = $("{$gridId}_massaction-select");
|
618 |
+
|
619 |
+
if (mmassActionEl && mmassActionEl.select('option[value="assignGeneralId"]').length > 0) {
|
620 |
+
var assignGeneralIdOption = mmassActionEl.select('option[value="assignGeneralId"]')[0];
|
621 |
+
assignGeneralIdOption.disabled = true;
|
622 |
+
|
623 |
+
mmassActionEl.insert({bottom: assignGeneralIdOption.remove()});
|
624 |
+
}
|
625 |
+
JS;
|
626 |
+
}
|
627 |
+
|
628 |
+
} else {
|
629 |
+
$autoSearchSetting = $listing->getSetting('additional_data', 'auto_search_was_performed');
|
630 |
+
|
631 |
+
if (!$autoSearchSetting) {
|
632 |
+
$listing->setSetting('additional_data', 'auto_search_was_performed', 1);
|
633 |
+
$listing->save();
|
634 |
+
|
635 |
+
$startSearch = <<<JS
|
636 |
+
ListingGridHandlerObj.getGridMassActionObj().selectAll();
|
637 |
+
ListingGridHandlerObj.productSearchHandler.searchGeneralIdAuto(ListingGridHandlerObj.getSelectedProductsString());
|
638 |
+
JS;
|
639 |
+
}
|
640 |
+
}
|
641 |
+
|
642 |
+
$javascriptsMain = <<<JAVASCRIPT
|
643 |
+
<script type="text/javascript">
|
644 |
+
|
645 |
+
if (typeof ListingGridHandlerObj != 'undefined') {
|
646 |
+
ListingGridHandlerObj.afterInitPage();
|
647 |
+
{$disableMassactionSearch}
|
648 |
+
}
|
649 |
+
|
650 |
+
Event.observe(window, 'load', function() {
|
651 |
+
setTimeout(function() {
|
652 |
+
ListingGridHandlerObj.afterInitPage();
|
653 |
+
{$disableMassactionSearch}
|
654 |
+
{$startSearch}
|
655 |
+
}, 350);
|
656 |
+
});
|
657 |
+
|
658 |
+
</script>
|
659 |
+
JAVASCRIPT;
|
660 |
+
|
661 |
+
return parent::_toHtml() . $javascriptsMain;
|
662 |
+
}
|
663 |
+
|
664 |
+
// ####################################
|
665 |
+
|
666 |
+
/**
|
667 |
+
* @return Ess_M2ePro_Model_Amazon_Listing
|
668 |
+
* @throws Exception
|
669 |
+
*/
|
670 |
+
public function getListing()
|
671 |
+
{
|
672 |
+
if (!$listingId = $this->getRequest()->getParam('id')) {
|
673 |
+
throw new Exception('Listing is not defined');
|
674 |
+
}
|
675 |
+
|
676 |
+
if (is_null($this->listing)) {
|
677 |
+
$this->listing = Mage::helper('M2ePro/Component_Amazon')->getObject('Listing', $listingId);
|
678 |
+
}
|
679 |
+
|
680 |
+
return $this->listing;
|
681 |
+
}
|
682 |
+
|
683 |
+
// ####################################
|
684 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/SearchAsin/Help.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Add_SearchAsin_Help extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonListingViewHelp');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/amazon/listing/add/search_asin/help.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/SearchAsin/NewAsinPopup.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Add_SearchAsin_NewAsinPopup extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('searchAsinNewAsinPopup');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/amazon/listing/add/search_asin/new_asin_popup.phtml');
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _beforeToHtml()
|
22 |
+
{
|
23 |
+
$data = array(
|
24 |
+
'label' => Mage::helper('M2ePro')->__('Yes'),
|
25 |
+
'onclick' => 'ListingGridHandlerObj.newAsinPopupYesClick()'
|
26 |
+
);
|
27 |
+
$yesButton = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
28 |
+
$this->setChild('yesBtn', $yesButton);
|
29 |
+
|
30 |
+
$data = array(
|
31 |
+
'label' => Mage::helper('M2ePro')->__('No'),
|
32 |
+
'onclick' => 'ListingGridHandlerObj.noAsinPopupNoClick()'
|
33 |
+
);
|
34 |
+
$noButton = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
35 |
+
$this->setChild('noBtn', $noButton);
|
36 |
+
}
|
37 |
+
|
38 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/SearchAsin/SearchSettings.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Add_SearchAsin_SearchSettings
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Form
|
9 |
+
{
|
10 |
+
protected $component;
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->setId('searchSettings');
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
$this->setTemplate('M2ePro/common/amazon/listing/add/search_asin/search_settings.phtml');
|
22 |
+
}
|
23 |
+
|
24 |
+
protected function _prepareForm()
|
25 |
+
{
|
26 |
+
// Prepare action
|
27 |
+
// -------------------
|
28 |
+
$action = $this->getUrl('*/adminhtml_common_amazon_listing_productAdd/saveSearchSettings', array(
|
29 |
+
'id' => (int)$this->getRequest()->getParam('id')
|
30 |
+
));
|
31 |
+
// -------------------
|
32 |
+
|
33 |
+
$form = new Varien_Data_Form(array(
|
34 |
+
'id' => 'search_settings_form',
|
35 |
+
'action' => $action,
|
36 |
+
'method' => 'post'
|
37 |
+
));
|
38 |
+
|
39 |
+
$form->setUseContainer(true);
|
40 |
+
$this->setForm($form);
|
41 |
+
|
42 |
+
return parent::_prepareForm();
|
43 |
+
}
|
44 |
+
|
45 |
+
protected function _beforeToHtml()
|
46 |
+
{
|
47 |
+
$child = $this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_listing_add_tabs_search');
|
48 |
+
|
49 |
+
$this->setChild('content', $child);
|
50 |
+
|
51 |
+
return parent::_beforeToHtml();
|
52 |
+
}
|
53 |
+
|
54 |
+
// ########################################
|
55 |
+
|
56 |
+
protected function _toHtml()
|
57 |
+
{
|
58 |
+
$buttonSave = $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
|
59 |
+
'id' => 'save_search_settings',
|
60 |
+
'label' => Mage::helper('M2ePro')->__('Confirm'),
|
61 |
+
'style' => 'float: right; margin: 0 0 7px 5px;',
|
62 |
+
'onclick' => 'ListingGridHandlerObj.saveSearchSettings()'
|
63 |
+
));
|
64 |
+
|
65 |
+
$this->setChild('save_search_settings', $buttonSave);
|
66 |
+
|
67 |
+
return parent::_toHtml();
|
68 |
+
}
|
69 |
+
|
70 |
+
// ########################################
|
71 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/Tabs/General.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Add_Tabs_General
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_Tabs_General
|
9 |
+
{
|
10 |
+
// #############################################
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->sessionKey = 'amazon_listing_create';
|
19 |
+
$this->setId('amazonListingAddTabsGeneral');
|
20 |
+
$this->setTemplate('M2ePro/common/amazon/listing/add/tabs/general.phtml');
|
21 |
+
//------------------------------
|
22 |
+
}
|
23 |
+
|
24 |
+
// #############################################
|
25 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/Tabs/Search.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Add_Tabs_Search
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_Tabs_Search
|
9 |
+
{
|
10 |
+
// #############################################
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->sessionKey = 'amazon_listing_create';
|
19 |
+
$this->setId('amazonListingAddTabsGeneral');
|
20 |
+
$this->setTemplate('M2ePro/common/amazon/listing/add/tabs/search.phtml');
|
21 |
+
//------------------------------
|
22 |
+
}
|
23 |
+
|
24 |
+
// #############################################
|
25 |
+
|
26 |
+
protected function getDefaults()
|
27 |
+
{
|
28 |
+
return self::getDefaultFieldsValues();
|
29 |
+
}
|
30 |
+
|
31 |
+
static function getDefaultFieldsValues()
|
32 |
+
{
|
33 |
+
return array(
|
34 |
+
'general_id_mode' => Ess_M2ePro_Model_Amazon_Listing::GENERAL_ID_MODE_NOT_SET,
|
35 |
+
'general_id_custom_attribute' => '',
|
36 |
+
|
37 |
+
'worldwide_id_mode' => Ess_M2ePro_Model_Amazon_Listing::WORLDWIDE_ID_MODE_NOT_SET,
|
38 |
+
'worldwide_id_custom_attribute' => '',
|
39 |
+
|
40 |
+
'search_by_magento_title_mode' => Ess_M2ePro_Model_Amazon_Listing::SEARCH_BY_MAGENTO_TITLE_MODE_NONE
|
41 |
+
);
|
42 |
+
}
|
43 |
+
|
44 |
+
// ####################################
|
45 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/Tabs/Selling.php
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Add_Tabs_Selling
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_Tabs_Selling
|
9 |
+
{
|
10 |
+
// #############################################
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->component = Ess_M2ePro_Helper_Component_Amazon::NICK;
|
19 |
+
$this->sessionKey = 'amazon_listing_create';
|
20 |
+
$this->setId('amazonListingAddTabsSelling');
|
21 |
+
$this->setTemplate('M2ePro/common/amazon/listing/add/tabs/selling.phtml');
|
22 |
+
//------------------------------
|
23 |
+
}
|
24 |
+
|
25 |
+
// #############################################
|
26 |
+
|
27 |
+
protected function _beforeToHtml()
|
28 |
+
{
|
29 |
+
$buttonBlock = $this->getLayout()
|
30 |
+
->createBlock('adminhtml/widget_button')
|
31 |
+
->setData( array(
|
32 |
+
'label' => Mage::helper('M2ePro')->__('Insert'),
|
33 |
+
'onclick' => "AmazonListingChannelSettingsHandlerObj.appendToText"
|
34 |
+
."('condition_note_custom_attribute', 'condition_note_value');",
|
35 |
+
'class' => 'condition_note_value_insert_button'
|
36 |
+
) );
|
37 |
+
$this->setChild('condition_note_value_insert_button',$buttonBlock);
|
38 |
+
|
39 |
+
return parent::_beforeToHtml();
|
40 |
+
}
|
41 |
+
|
42 |
+
// #############################################
|
43 |
+
|
44 |
+
protected function getDefaults()
|
45 |
+
{
|
46 |
+
return self::getDefaultFieldsValues();
|
47 |
+
}
|
48 |
+
|
49 |
+
static function getDefaultFieldsValues()
|
50 |
+
{
|
51 |
+
return array(
|
52 |
+
'sku_mode' => Ess_M2ePro_Model_Amazon_Listing::SKU_MODE_DEFAULT,
|
53 |
+
'sku_custom_attribute' => '',
|
54 |
+
'generate_sku_mode' => Ess_M2ePro_Model_Amazon_Listing::GENERATE_SKU_MODE_NO,
|
55 |
+
|
56 |
+
'template_selling_format_id' => '',
|
57 |
+
'template_synchronization_id' => '',
|
58 |
+
|
59 |
+
'condition_mode' => Ess_M2ePro_Model_Amazon_Listing::CONDITION_MODE_DEFAULT,
|
60 |
+
'condition_value' => Ess_M2ePro_Model_Amazon_Listing::CONDITION_NEW,
|
61 |
+
'condition_custom_attribute' => '',
|
62 |
+
'condition_note_mode' => Ess_M2ePro_Model_Amazon_Listing::CONDITION_NOTE_MODE_NONE,
|
63 |
+
'condition_note_value' => '',
|
64 |
+
|
65 |
+
'image_main_mode' => Ess_M2ePro_Model_Amazon_Listing::IMAGE_MAIN_MODE_NONE,
|
66 |
+
'image_main_attribute' => '',
|
67 |
+
'gallery_images_mode' => Ess_M2ePro_Model_Amazon_Listing::GALLERY_IMAGES_MODE_NONE,
|
68 |
+
'gallery_images_limit' => '',
|
69 |
+
'gallery_images_attribute' => '',
|
70 |
+
|
71 |
+
'handling_time_mode' => Ess_M2ePro_Model_Amazon_Listing::HANDLING_TIME_MODE_NONE,
|
72 |
+
'handling_time_value' => '',
|
73 |
+
'handling_time_custom_attribute' => '',
|
74 |
+
|
75 |
+
'restock_date_mode' => Ess_M2ePro_Model_Amazon_Listing::RESTOCK_DATE_MODE_NONE,
|
76 |
+
'restock_date_value' => Mage::helper('M2ePro')->getCurrentTimezoneDate(),
|
77 |
+
'restock_date_custom_attribute' => ''
|
78 |
+
);
|
79 |
+
}
|
80 |
+
|
81 |
+
// ####################################
|
82 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/AutoAction/Mode.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2011 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_AutoAction_Mode
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Listing_AutoAction_Mode
|
9 |
+
{
|
10 |
+
|
11 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/AutoAction/Mode/Category.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2011 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_AutoAction_Mode_Category
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Listing_AutoAction_Mode_Category
|
9 |
+
{
|
10 |
+
// ####################################
|
11 |
+
|
12 |
+
protected function prepareGroupsGrid()
|
13 |
+
{
|
14 |
+
$groupGrid = $this->getLayout()
|
15 |
+
->createBlock('M2ePro/adminhtml_common_amazon_listing_autoAction_mode_category_group_grid');
|
16 |
+
$groupGrid->prepareGrid();
|
17 |
+
$this->setChild('group_grid', $groupGrid);
|
18 |
+
|
19 |
+
return $groupGrid;
|
20 |
+
}
|
21 |
+
|
22 |
+
// ####################################
|
23 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/AutoAction/Mode/Category/Form.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2011 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_AutoAction_Mode_Category_Form
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Listing_AutoAction_Mode_Category_Form
|
9 |
+
{
|
10 |
+
|
11 |
+
// ####################################
|
12 |
+
|
13 |
+
public function __construct()
|
14 |
+
{
|
15 |
+
parent::__construct();
|
16 |
+
|
17 |
+
$this->setTemplate('M2ePro/common/amazon/listing/auto_action/mode/category/form.phtml');
|
18 |
+
}
|
19 |
+
|
20 |
+
// ####################################
|
21 |
+
|
22 |
+
public function getDefault()
|
23 |
+
{
|
24 |
+
return array(
|
25 |
+
'id' => NULL,
|
26 |
+
'title' => NULL,
|
27 |
+
'category_id' => NULL,
|
28 |
+
'adding_mode' => Ess_M2ePro_Model_Listing::ADDING_MODE_NONE,
|
29 |
+
'deleting_mode' => Ess_M2ePro_Model_Listing::DELETING_MODE_NONE,
|
30 |
+
'adding_description_template_id' => NULL
|
31 |
+
);
|
32 |
+
}
|
33 |
+
|
34 |
+
// ####################################
|
35 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/AutoAction/Mode/Category/Group/Grid.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_AutoAction_Mode_Category_Group_Grid
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Listing_AutoAction_Mode_Category_Group_Grid
|
9 |
+
{
|
10 |
+
|
11 |
+
public function getGridUrl()
|
12 |
+
{
|
13 |
+
return $this->getUrl('*/adminhtml_common_listing_autoAction/getCategoryGroupGrid', array('_current' => true));
|
14 |
+
}
|
15 |
+
|
16 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/AutoAction/Mode/Global.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2011 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_AutoAction_Mode_Global
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Listing_AutoAction_Mode_Global
|
9 |
+
{
|
10 |
+
// ####################################
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
$this->setTemplate('M2ePro/common/amazon/listing/auto_action/mode/global.phtml');
|
17 |
+
}
|
18 |
+
|
19 |
+
// ####################################
|
20 |
+
|
21 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/AutoAction/Mode/Website.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2011 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_AutoAction_Mode_Website
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Listing_AutoAction_Mode_Website
|
9 |
+
{
|
10 |
+
// ####################################
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
$this->setTemplate('M2ePro/common/amazon/listing/auto_action/mode/website.phtml');
|
17 |
+
}
|
18 |
+
|
19 |
+
// ####################################
|
20 |
+
|
21 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Edit.php
ADDED
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2011 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
8 |
+
{
|
9 |
+
|
10 |
+
// ####################################
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->setId('amazonListingEdit');
|
19 |
+
$this->_blockGroup = 'M2ePro';
|
20 |
+
$this->_controller = 'adminhtml_common_amazon_listing';
|
21 |
+
$this->_mode = 'edit';
|
22 |
+
//------------------------------
|
23 |
+
|
24 |
+
// Set header text
|
25 |
+
//------------------------------
|
26 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
27 |
+
|
28 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
29 |
+
$headerText = Mage::helper('M2ePro')->__(
|
30 |
+
'Edit %component_name% Listing Settings "%listing_title%"',
|
31 |
+
Mage::helper('M2ePro/Component_Amazon')->getTitle(),
|
32 |
+
$this->escapeHtml($listingData['title'])
|
33 |
+
);
|
34 |
+
} else {
|
35 |
+
$headerText = Mage::helper('M2ePro')->__(
|
36 |
+
'Edit Listing Settings "%listing_title%"',
|
37 |
+
$this->escapeHtml($listingData['title'])
|
38 |
+
);
|
39 |
+
}
|
40 |
+
|
41 |
+
$this->_headerText = $headerText;
|
42 |
+
//------------------------------
|
43 |
+
|
44 |
+
// Set buttons actions
|
45 |
+
//------------------------------
|
46 |
+
$this->removeButton('back');
|
47 |
+
$this->removeButton('reset');
|
48 |
+
$this->removeButton('delete');
|
49 |
+
$this->removeButton('add');
|
50 |
+
$this->removeButton('save');
|
51 |
+
$this->removeButton('edit');
|
52 |
+
//------------------------------
|
53 |
+
|
54 |
+
if (!is_null($this->getRequest()->getParam('back'))) {
|
55 |
+
//------------------------------
|
56 |
+
$url = Mage::helper('M2ePro')->getBackUrl(
|
57 |
+
'*/adminhtml_common_listing/index',
|
58 |
+
array(
|
59 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON
|
60 |
+
)
|
61 |
+
);
|
62 |
+
$this->_addButton('back', array(
|
63 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
64 |
+
'onclick' => 'CommonListingSettingsHandlerObj.back_click(\''.$url.'\')',
|
65 |
+
'class' => 'back'
|
66 |
+
));
|
67 |
+
//------------------------------
|
68 |
+
}
|
69 |
+
|
70 |
+
//------------------------------
|
71 |
+
$this->_addButton('auto_action', array(
|
72 |
+
'label' => Mage::helper('M2ePro')->__('Auto Add/Remove Rules'),
|
73 |
+
'onclick' => 'ListingAutoActionHandlerObj.loadAutoActionHtml();'
|
74 |
+
));
|
75 |
+
//------------------------------
|
76 |
+
|
77 |
+
$backUrl = Mage::helper('M2ePro')->getBackUrlParam('list');
|
78 |
+
|
79 |
+
//------------------------------
|
80 |
+
$url = $this->getUrl(
|
81 |
+
'*/adminhtml_common_amazon_listing/save',
|
82 |
+
array(
|
83 |
+
'id' => $listingData['id'],
|
84 |
+
'back' => $backUrl
|
85 |
+
)
|
86 |
+
);
|
87 |
+
$this->_addButton('save', array(
|
88 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
89 |
+
'onclick' => 'CommonListingSettingsHandlerObj.save_click(\'' . $url . '\')',
|
90 |
+
'class' => 'save'
|
91 |
+
));
|
92 |
+
//------------------------------
|
93 |
+
|
94 |
+
//------------------------------
|
95 |
+
$this->_addButton('save_and_continue', array(
|
96 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
97 |
+
'onclick' => 'CommonListingSettingsHandlerObj.save_and_edit_click(\''.$url.'\', 1)',
|
98 |
+
'class' => 'save'
|
99 |
+
));
|
100 |
+
//------------------------------
|
101 |
+
}
|
102 |
+
|
103 |
+
// ####################################
|
104 |
+
|
105 |
+
protected function _beforeToHtml()
|
106 |
+
{
|
107 |
+
parent::_beforeToHtml();
|
108 |
+
|
109 |
+
//------------------------------
|
110 |
+
$tabs = $this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_listing_edit_tabs');
|
111 |
+
$this->setChild('tabs', $tabs);
|
112 |
+
//------------------------------
|
113 |
+
|
114 |
+
return $this;
|
115 |
+
}
|
116 |
+
|
117 |
+
// ####################################
|
118 |
+
|
119 |
+
public function getFormHtml()
|
120 |
+
{
|
121 |
+
$listing = Mage::helper('M2ePro/Component_Amazon')->getCachedObject(
|
122 |
+
'Listing', $this->getRequest()->getParam('id')
|
123 |
+
);
|
124 |
+
|
125 |
+
$viewHeaderBlock = $this->getLayout()->createBlock(
|
126 |
+
'M2ePro/adminhtml_listing_view_header','',
|
127 |
+
array('listing' => $listing)
|
128 |
+
);
|
129 |
+
|
130 |
+
$tabs = $this->getChild('tabs');
|
131 |
+
|
132 |
+
$urls = Mage::helper('M2ePro')->getControllerActions(
|
133 |
+
'adminhtml_common_listing_autoAction',
|
134 |
+
array(
|
135 |
+
'listing_id' => $this->getRequest()->getParam('id'),
|
136 |
+
'component' => Ess_M2ePro_Helper_Component_Amazon::NICK
|
137 |
+
)
|
138 |
+
);
|
139 |
+
$urls = json_encode($urls);
|
140 |
+
|
141 |
+
/** @var $helper Ess_M2ePro_Helper_Data */
|
142 |
+
$helper = Mage::helper('M2ePro');
|
143 |
+
|
144 |
+
$translations = json_encode(array(
|
145 |
+
'Auto Add/Remove Rules' => $helper->__('Auto Add/Remove Rules'),
|
146 |
+
'Based on Magento Categories' => $helper->__('Based on Magento Categories'),
|
147 |
+
'You must select at least 1 Category.' => $helper->__('You must select at least 1 Category.'),
|
148 |
+
'Rule with the same Title already exists.' => $helper->__('Rule with the same Title already exists.')
|
149 |
+
));
|
150 |
+
|
151 |
+
$js = <<<HTML
|
152 |
+
<script type="text/javascript">
|
153 |
+
|
154 |
+
M2ePro.url.add({$urls});
|
155 |
+
M2ePro.translator.add({$translations});
|
156 |
+
|
157 |
+
ListingAutoActionHandlerObj = new ListingAutoActionHandler();
|
158 |
+
|
159 |
+
</script>
|
160 |
+
HTML;
|
161 |
+
|
162 |
+
return $viewHeaderBlock->toHtml() . $tabs->toHtml() . parent::getFormHtml() . $js;
|
163 |
+
}
|
164 |
+
|
165 |
+
// ####################################
|
166 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Edit/Form.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonListingEditForm');
|
16 |
+
//------------------------------
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _prepareForm()
|
20 |
+
{
|
21 |
+
$form = new Varien_Data_Form(array(
|
22 |
+
'id' => 'edit_form',
|
23 |
+
'action' => $this->getUrl('*/adminhtml_common_amazon_listing/save'),
|
24 |
+
'method' => 'post',
|
25 |
+
'enctype' => 'multipart/form-data'
|
26 |
+
));
|
27 |
+
|
28 |
+
$form->setUseContainer(true);
|
29 |
+
$this->setForm($form);
|
30 |
+
|
31 |
+
return parent::_prepareForm();
|
32 |
+
}
|
33 |
+
|
34 |
+
// ####################################
|
35 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Edit/Tabs.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonListingEditTabs');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('widget/tabshoriz.phtml');
|
19 |
+
$this->setDestElementId('edit_form');
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _beforeToHtml()
|
23 |
+
{
|
24 |
+
$this->addTab('selling', array(
|
25 |
+
'label' => Mage::helper('M2ePro')->__('Selling Settings'),
|
26 |
+
'title' => Mage::helper('M2ePro')->__('Selling Settings'),
|
27 |
+
'content' => $this->getLayout()
|
28 |
+
->createBlock('M2ePro/adminhtml_common_amazon_listing_add_tabs_selling')
|
29 |
+
->toHtml(),
|
30 |
+
));
|
31 |
+
|
32 |
+
$this->addTab('search', array(
|
33 |
+
'label' => Mage::helper('M2ePro')->__('Search Settings'),
|
34 |
+
'title' => Mage::helper('M2ePro')->__('Search Settings'),
|
35 |
+
'content' => $this->getLayout()
|
36 |
+
->createBlock('M2ePro/adminhtml_common_amazon_listing_add_tabs_search')
|
37 |
+
->toHtml(),
|
38 |
+
));
|
39 |
+
|
40 |
+
$this->setActiveTab($this->getRequest()->getParam('tab', 'selling'));
|
41 |
+
|
42 |
+
return parent::_beforeToHtml();
|
43 |
+
}
|
44 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Filter.php
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Filter extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonListingFilter');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/amazon/listing/filter.phtml');
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _beforeToHtml()
|
22 |
+
{
|
23 |
+
//-------------------------------
|
24 |
+
$maxRecordsQuantity = Mage::helper('M2ePro/View_Common')->getAutocompleteMaxItems();
|
25 |
+
//-------------------------------
|
26 |
+
|
27 |
+
//-------------------------------
|
28 |
+
$this->selectedSellingFormatTemplate = (int)$this->getRequest()
|
29 |
+
->getParam('filter_amazon_selling_format_template');
|
30 |
+
$sellingFormatTemplatesCollection = Mage::helper('M2ePro/Component_Amazon')
|
31 |
+
->getCollection('Template_SellingFormat')
|
32 |
+
->setOrder('title', 'ASC');
|
33 |
+
|
34 |
+
if ($sellingFormatTemplatesCollection->getSize() < $maxRecordsQuantity) {
|
35 |
+
$this->sellingFormatTemplatesDropDown = true;
|
36 |
+
$sellingFormatTemplates = array();
|
37 |
+
|
38 |
+
foreach ($sellingFormatTemplatesCollection->getItems() as $item) {
|
39 |
+
$sellingFormatTemplates[$item->getId()] = Mage::helper('M2ePro')->escapeHtml($item->getTitle());
|
40 |
+
}
|
41 |
+
$this->sellingFormatTemplates = $sellingFormatTemplates;
|
42 |
+
} else {
|
43 |
+
$this->sellingFormatTemplatesDropDown = false;
|
44 |
+
$this->sellingFormatTemplates = array();
|
45 |
+
|
46 |
+
if ($this->selectedSellingFormatTemplate > 0) {
|
47 |
+
$this->selectedSellingFormatTemplateValue = Mage::helper('M2ePro/Component_Amazon')
|
48 |
+
->getCachedObject('Template_SellingFormat',
|
49 |
+
$this->selectedSellingFormatTemplate, NULL,
|
50 |
+
array('template'))
|
51 |
+
->getTitle();
|
52 |
+
} else {
|
53 |
+
$this->selectedSellingFormatTemplateValue = '';
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
$this->sellingFormatTemplateUrl = $this->makeCutUrlForTemplate('filter_amazon_selling_format_template');
|
58 |
+
//-------------------------------
|
59 |
+
|
60 |
+
//-------------------------------
|
61 |
+
$this->selectedSynchronizationTemplate = (int)$this->getRequest()
|
62 |
+
->getParam('filter_amazon_synchronization_template');
|
63 |
+
$synchronizationsTemplatesCollection = Mage::helper('M2ePro/Component_Amazon')
|
64 |
+
->getCollection('Template_Synchronization')
|
65 |
+
->setOrder('title', 'ASC');
|
66 |
+
|
67 |
+
if ($synchronizationsTemplatesCollection->getSize() < $maxRecordsQuantity) {
|
68 |
+
$this->synchronizationsTemplatesDropDown = true;
|
69 |
+
$synchronizationsTemplates = array();
|
70 |
+
|
71 |
+
foreach ($synchronizationsTemplatesCollection->getItems() as $item) {
|
72 |
+
$synchronizationsTemplates[$item->getId()] = Mage::helper('M2ePro')->escapeHtml($item->getTitle());
|
73 |
+
}
|
74 |
+
$this->synchronizationsTemplates = $synchronizationsTemplates;
|
75 |
+
} else {
|
76 |
+
$this->synchronizationsTemplatesDropDown = false;
|
77 |
+
$this->synchronizationsTemplates = array();
|
78 |
+
|
79 |
+
if ($this->selectedSynchronizationTemplate > 0) {
|
80 |
+
$this->selectedSynchronizationTemplateValue = Mage::helper('M2ePro/Component_Amazon')
|
81 |
+
->getCachedObject('Template_Synchronization',
|
82 |
+
$this->selectedSynchronizationTemplate, NULL,
|
83 |
+
array('template'))
|
84 |
+
->getTitle();
|
85 |
+
} else {
|
86 |
+
$this->selectedSynchronizationTemplateValue = '';
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
$this->synchronizationTemplateUrl = $this->makeCutUrlForTemplate('filter_amazon_synchronization_template');
|
91 |
+
//-------------------------------
|
92 |
+
|
93 |
+
return parent::_beforeToHtml();
|
94 |
+
}
|
95 |
+
|
96 |
+
protected function makeCutUrlForTemplate($templateUrlParamName)
|
97 |
+
{
|
98 |
+
$paramsFilters = array(
|
99 |
+
'filter_amazon_selling_format_template',
|
100 |
+
'filter_amazon_synchronization_template'
|
101 |
+
);
|
102 |
+
|
103 |
+
$params = array();
|
104 |
+
foreach ($paramsFilters as $value) {
|
105 |
+
if ($value != $templateUrlParamName) {
|
106 |
+
$params[$value] = $this->getRequest()->getParam($value);
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
$params['tab'] = Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON;
|
111 |
+
|
112 |
+
return $this->getUrl('*/adminhtml_common_listing/*',$params);
|
113 |
+
}
|
114 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Grid.php
ADDED
@@ -0,0 +1,325 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Grid extends Ess_M2ePro_Block_Adminhtml_Listing_Grid
|
8 |
+
{
|
9 |
+
// ########################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('amazonListingGrid');
|
18 |
+
//------------------------------
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _prepareCollection()
|
22 |
+
{
|
23 |
+
// Update statistic table values
|
24 |
+
Mage::getResourceModel('M2ePro/Amazon_Listing')->updateStatisticColumns();
|
25 |
+
|
26 |
+
// Get collection of listings
|
27 |
+
$collection = Mage::helper('M2ePro/Component_Amazon')->getCollection('Listing');
|
28 |
+
|
29 |
+
// Set global filters
|
30 |
+
//--------------------------
|
31 |
+
$filterSellingFormatTemplate = $this->getRequest()->getParam('filter_amazon_selling_format_template');
|
32 |
+
$filterSynchronizationTemplate = $this->getRequest()->getParam('filter_amazon_synchronization_template');
|
33 |
+
|
34 |
+
if ($filterSellingFormatTemplate != 0) {
|
35 |
+
$collection->addFieldToFilter(
|
36 |
+
'second_table.template_selling_format_id', (int)$filterSellingFormatTemplate
|
37 |
+
);
|
38 |
+
}
|
39 |
+
|
40 |
+
if ($filterSynchronizationTemplate != 0) {
|
41 |
+
$collection->addFieldToFilter(
|
42 |
+
'second_table.template_synchronization_id', (int)$filterSynchronizationTemplate
|
43 |
+
);
|
44 |
+
}
|
45 |
+
//--------------------------
|
46 |
+
|
47 |
+
// join marketplace and accounts
|
48 |
+
//--------------------------
|
49 |
+
$collection->getSelect()
|
50 |
+
->join(array('a'=>Mage::getResourceModel('M2ePro/Account')->getMainTable()),
|
51 |
+
'(`a`.`id` = `main_table`.`account_id`)',
|
52 |
+
array('account_title'=>'title'))
|
53 |
+
->join(array('m'=>Mage::getResourceModel('M2ePro/Marketplace')->getMainTable()),
|
54 |
+
'(`m`.`id` = `main_table`.`marketplace_id`)',
|
55 |
+
array('marketplace_title'=>'title'));
|
56 |
+
//--------------------------
|
57 |
+
|
58 |
+
//exit($collection->getSelect()->__toString());
|
59 |
+
|
60 |
+
// Set collection to grid
|
61 |
+
$this->setCollection($collection);
|
62 |
+
|
63 |
+
return parent::_prepareCollection();
|
64 |
+
}
|
65 |
+
|
66 |
+
// ####################################
|
67 |
+
|
68 |
+
protected function _prepareMassaction()
|
69 |
+
{
|
70 |
+
// Set massaction identifiers
|
71 |
+
//--------------------------------
|
72 |
+
$this->setMassactionIdField('main_table.id');
|
73 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
74 |
+
//--------------------------------
|
75 |
+
|
76 |
+
// Set clear log action
|
77 |
+
//--------------------------------
|
78 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
79 |
+
'*/adminhtml_common_listing/index',
|
80 |
+
array(
|
81 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON
|
82 |
+
)
|
83 |
+
);
|
84 |
+
|
85 |
+
$this->getMassactionBlock()->addItem('clear_logs', array(
|
86 |
+
'label' => Mage::helper('M2ePro')->__('Clear Log(s)'),
|
87 |
+
'url' => $this->getUrl('*/adminhtml_listing/clearLog', array('back' => $backUrl)),
|
88 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
89 |
+
));
|
90 |
+
//--------------------------------
|
91 |
+
|
92 |
+
// Set remove listings action
|
93 |
+
//--------------------------------
|
94 |
+
$this->getMassactionBlock()->addItem('delete_listings', array(
|
95 |
+
'label' => Mage::helper('M2ePro')->__('Delete Listing(s)'),
|
96 |
+
'url' => $this->getUrl('*/adminhtml_common_amazon_listing/delete'),
|
97 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
98 |
+
));
|
99 |
+
//--------------------------------
|
100 |
+
|
101 |
+
return parent::_prepareMassaction();
|
102 |
+
}
|
103 |
+
|
104 |
+
// ####################################
|
105 |
+
|
106 |
+
protected function getColumnActionsItems()
|
107 |
+
{
|
108 |
+
$helper = Mage::helper('M2ePro');
|
109 |
+
$backUrl = $helper->makeBackUrlParam(
|
110 |
+
'*/adminhtml_common_listing/index',
|
111 |
+
array(
|
112 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON
|
113 |
+
)
|
114 |
+
);
|
115 |
+
|
116 |
+
$actions = array(
|
117 |
+
'manageProducts' => array(
|
118 |
+
'caption' => $helper->__('Manage'),
|
119 |
+
'group' => 'products_actions',
|
120 |
+
'field' => 'id',
|
121 |
+
'url' => array(
|
122 |
+
'base' => '*/adminhtml_common_amazon_listing/view',
|
123 |
+
'params' => array('back' => $backUrl)
|
124 |
+
)
|
125 |
+
),
|
126 |
+
|
127 |
+
'addProductsFromProductsList' => array(
|
128 |
+
'caption' => $helper->__('Add From Products List'),
|
129 |
+
'group' => 'products_actions',
|
130 |
+
'field' => 'id',
|
131 |
+
'url' => array(
|
132 |
+
'base' => '*/adminhtml_common_listing_productAdd/index',
|
133 |
+
'params' => array(
|
134 |
+
'back' => $backUrl,
|
135 |
+
'component' => Ess_M2ePro_Helper_Component_Amazon::NICK,
|
136 |
+
'step' => 2,
|
137 |
+
'source' => Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_SourceMode::SOURCE_LIST
|
138 |
+
)
|
139 |
+
)
|
140 |
+
),
|
141 |
+
|
142 |
+
'addProductsFromCategories' => array(
|
143 |
+
'caption' => $helper->__('Add From Categories'),
|
144 |
+
'group' => 'products_actions',
|
145 |
+
'field' => 'id',
|
146 |
+
'url' => array(
|
147 |
+
'base' => '*/adminhtml_common_listing_productAdd/index',
|
148 |
+
'params' => array(
|
149 |
+
'back' => $backUrl,
|
150 |
+
'component' => Ess_M2ePro_Helper_Component_Amazon::NICK,
|
151 |
+
'step' => 2,
|
152 |
+
'source' => Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_SourceMode::SOURCE_CATEGORIES
|
153 |
+
)
|
154 |
+
)
|
155 |
+
),
|
156 |
+
|
157 |
+
'automaticActions' => array(
|
158 |
+
'caption' => $helper->__('Auto Add/Remove Rules'),
|
159 |
+
'group' => 'products_actions',
|
160 |
+
'field' => 'id',
|
161 |
+
'url' => array(
|
162 |
+
'base' => '*/adminhtml_common_amazon_listing/view',
|
163 |
+
'params' => array(
|
164 |
+
'back' => $backUrl,
|
165 |
+
'auto_actions' => 1
|
166 |
+
)
|
167 |
+
)
|
168 |
+
),
|
169 |
+
|
170 |
+
'viewLog' => array(
|
171 |
+
'caption' => $helper->__('View Log'),
|
172 |
+
'group' => 'other',
|
173 |
+
'field' => 'id',
|
174 |
+
'url' => array(
|
175 |
+
'base' => '*/adminhtml_common_log/listing',
|
176 |
+
'params' => array(
|
177 |
+
'back' => $backUrl,
|
178 |
+
'channel' => Ess_M2ePro_Block_Adminhtml_Common_Log_Tabs::TAB_ID_AMAZON
|
179 |
+
)
|
180 |
+
)
|
181 |
+
),
|
182 |
+
|
183 |
+
'clearLogs' => array(
|
184 |
+
'caption' => $helper->__('Clear Log'),
|
185 |
+
'confirm' => $helper->__('Are you sure?'),
|
186 |
+
'group' => 'other',
|
187 |
+
'field' => 'id',
|
188 |
+
'url' => array(
|
189 |
+
'base' => '*/adminhtml_listing/clearLog',
|
190 |
+
'params' => array(
|
191 |
+
'back' => $backUrl
|
192 |
+
)
|
193 |
+
)
|
194 |
+
),
|
195 |
+
|
196 |
+
'deleteListing' => array(
|
197 |
+
'caption' => $helper->__('Delete Listing'),
|
198 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?'),
|
199 |
+
'group' => 'other',
|
200 |
+
'field' => 'id',
|
201 |
+
'url' => array(
|
202 |
+
'base' => '*/adminhtml_common_amazon_listing/delete',
|
203 |
+
)
|
204 |
+
),
|
205 |
+
|
206 |
+
'editListingTitle' => array(
|
207 |
+
'caption' => $helper->__('Title'),
|
208 |
+
'group' => 'edit_actions',
|
209 |
+
'confirm' => $helper->__('Are you sure?'),
|
210 |
+
'field' => 'id',
|
211 |
+
'onclick_action' => 'editListingTitle'
|
212 |
+
),
|
213 |
+
|
214 |
+
'sellingSetting' => array(
|
215 |
+
'caption' => $helper->__('Selling'),
|
216 |
+
'group' => 'edit_actions',
|
217 |
+
'field' => 'id',
|
218 |
+
'url' => array(
|
219 |
+
'base' => '*/adminhtml_common_amazon_listing/edit',
|
220 |
+
'params' => array(
|
221 |
+
'back' => $backUrl,
|
222 |
+
'tab' => 'selling'
|
223 |
+
)
|
224 |
+
)
|
225 |
+
),
|
226 |
+
|
227 |
+
'searchSetting' => array(
|
228 |
+
'caption' => $helper->__('Search'),
|
229 |
+
'group' => 'edit_actions',
|
230 |
+
'field' => 'id',
|
231 |
+
'url' => array(
|
232 |
+
'base' => '*/adminhtml_common_amazon_listing/edit',
|
233 |
+
'params' => array(
|
234 |
+
'back' => $backUrl,
|
235 |
+
'tab' => 'search'
|
236 |
+
)
|
237 |
+
)
|
238 |
+
)
|
239 |
+
);
|
240 |
+
|
241 |
+
return $actions;
|
242 |
+
}
|
243 |
+
|
244 |
+
// ####################################
|
245 |
+
|
246 |
+
public function callbackColumnSoldProducts($value, $row, $column, $isExport)
|
247 |
+
{
|
248 |
+
return $this->getColumnValue($value);
|
249 |
+
}
|
250 |
+
|
251 |
+
public function callbackColumnTitle($value, $row, $column, $isExport)
|
252 |
+
{
|
253 |
+
$value = '<span id="listing_title_'.$row->getId().'">' .
|
254 |
+
Mage::helper('M2ePro')->escapeHtml($value) .
|
255 |
+
'</span>';
|
256 |
+
|
257 |
+
/* @var $row Ess_M2ePro_Model_Listing */
|
258 |
+
$accountTitle = $row->getData('account_title');
|
259 |
+
$marketplaceTitle = $row->getData('marketplace_title');
|
260 |
+
|
261 |
+
$storeModel = Mage::getModel('core/store')->load($row->getStoreId());
|
262 |
+
$storeView = $storeModel->getWebsite()->getName();
|
263 |
+
if (strtolower($storeView) != 'admin') {
|
264 |
+
$storeView .= ' > '.$storeModel->getGroup()->getName();
|
265 |
+
$storeView .= ' > '.$storeModel->getName();
|
266 |
+
} else {
|
267 |
+
$storeView = Mage::helper('M2ePro')->__('Admin (Default Values)');
|
268 |
+
}
|
269 |
+
|
270 |
+
$account = Mage::helper('M2ePro')->__('Account');
|
271 |
+
$marketplace = Mage::helper('M2ePro')->__('Marketplace');
|
272 |
+
$store = Mage::helper('M2ePro')->__('Magento Store View');
|
273 |
+
|
274 |
+
$value .= <<<HTML
|
275 |
+
<div>
|
276 |
+
<span style="font-weight: bold">{$account}</span>: <span style="color: #505050">{$accountTitle}</span><br/>
|
277 |
+
<span style="font-weight: bold">{$marketplace}</span>: <span style="color: #505050">{$marketplaceTitle}</span><br/>
|
278 |
+
<span style="font-weight: bold">{$store}</span>: <span style="color: #505050">{$storeView}</span>
|
279 |
+
</div>
|
280 |
+
HTML;
|
281 |
+
|
282 |
+
return $value;
|
283 |
+
}
|
284 |
+
|
285 |
+
// ####################################
|
286 |
+
|
287 |
+
protected function callbackFilterTitle($collection, $column)
|
288 |
+
{
|
289 |
+
$value = $column->getFilter()->getValue();
|
290 |
+
|
291 |
+
if ($value == null) {
|
292 |
+
return;
|
293 |
+
}
|
294 |
+
|
295 |
+
$where = "main_table.title LIKE '%{$value}%' OR m.title LIKE '%{$value}%' OR a.title LIKE '%{$value}%'";
|
296 |
+
$collection->getSelect()->where($where);
|
297 |
+
}
|
298 |
+
|
299 |
+
// ####################################
|
300 |
+
|
301 |
+
public function getGridUrl()
|
302 |
+
{
|
303 |
+
return $this->getUrl('*/adminhtml_common_amazon_listing/listingGrid', array('_current'=>true));
|
304 |
+
}
|
305 |
+
|
306 |
+
public function getRowUrl($row)
|
307 |
+
{
|
308 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
309 |
+
'*/adminhtml_common_listing/index',
|
310 |
+
array(
|
311 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON
|
312 |
+
)
|
313 |
+
);
|
314 |
+
|
315 |
+
return $this->getUrl(
|
316 |
+
'*/adminhtml_common_amazon_listing/view',
|
317 |
+
array(
|
318 |
+
'id' => $row->getId(),
|
319 |
+
'back' => $backUrl
|
320 |
+
)
|
321 |
+
);
|
322 |
+
}
|
323 |
+
|
324 |
+
// ####################################
|
325 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Other/Grid.php
ADDED
@@ -0,0 +1,567 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Other_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
// ####################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
/** @var $this->connRead Varien_Db_Adapter_Pdo_Mysql */
|
16 |
+
$this->connRead = Mage::getSingleton('core/resource')->getConnection('core_read');
|
17 |
+
|
18 |
+
// Initialization block
|
19 |
+
//------------------------------
|
20 |
+
$this->setId('amazonListingOtherGrid');
|
21 |
+
//------------------------------
|
22 |
+
|
23 |
+
// Set default values
|
24 |
+
//------------------------------
|
25 |
+
$this->setDefaultSort('id');
|
26 |
+
$this->setDefaultDir('DESC');
|
27 |
+
$this->setSaveParametersInSession(true);
|
28 |
+
$this->setUseAjax(true);
|
29 |
+
//------------------------------
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getMassactionBlockName()
|
33 |
+
{
|
34 |
+
return 'M2ePro/adminhtml_grid_massaction';
|
35 |
+
}
|
36 |
+
|
37 |
+
// ####################################
|
38 |
+
|
39 |
+
protected function _prepareCollection()
|
40 |
+
{
|
41 |
+
$collection = Mage::helper('M2ePro/Component_Amazon')->getCollection('Listing_Other');
|
42 |
+
|
43 |
+
$collection->getSelect()->joinLeft(
|
44 |
+
array('mp' => Mage::getResourceModel('M2ePro/Marketplace')->getMainTable()),
|
45 |
+
'mp.id = main_table.marketplace_id',
|
46 |
+
array('marketplace_title' => 'mp.title')
|
47 |
+
)->joinLeft(
|
48 |
+
array('am' => Mage::getResourceModel('M2ePro/Amazon_Marketplace')->getMainTable()),
|
49 |
+
'am.marketplace_id = main_table.marketplace_id',
|
50 |
+
array('currency' => 'am.default_currency'));
|
51 |
+
|
52 |
+
// Add Filter By Account
|
53 |
+
if ($this->getRequest()->getParam('amazonAccount')) {
|
54 |
+
$collection->addFieldToFilter('main_table.account_id',
|
55 |
+
$this->getRequest()->getParam('amazonAccount'));
|
56 |
+
}
|
57 |
+
|
58 |
+
// Add Filter By Marketplace
|
59 |
+
if ($this->getRequest()->getParam('amazonMarketplace')) {
|
60 |
+
$collection->addFieldToFilter('main_table.marketplace_id',
|
61 |
+
$this->getRequest()->getParam('amazonMarketplace'));
|
62 |
+
}
|
63 |
+
|
64 |
+
//var_dump($collection->getSelect()->__toString()); exit();
|
65 |
+
|
66 |
+
$this->setCollection($collection);
|
67 |
+
|
68 |
+
return parent::_prepareCollection();
|
69 |
+
}
|
70 |
+
|
71 |
+
protected function _prepareColumns()
|
72 |
+
{
|
73 |
+
$this->addColumn('product_id', array(
|
74 |
+
'header' => Mage::helper('M2ePro')->__('Product ID'),
|
75 |
+
'align' => 'left',
|
76 |
+
'width' => '80px',
|
77 |
+
'type' => 'number',
|
78 |
+
'index' => 'product_id',
|
79 |
+
'filter_index' => 'product_id',
|
80 |
+
'frame_callback' => array($this, 'callbackColumnProductId')
|
81 |
+
));
|
82 |
+
|
83 |
+
$this->addColumn('title', array(
|
84 |
+
'header' => Mage::helper('M2ePro')->__('Title / SKU'),
|
85 |
+
'align' => 'left',
|
86 |
+
'type' => 'text',
|
87 |
+
'index' => 'title',
|
88 |
+
'filter_index' => 'second_table.title',
|
89 |
+
'frame_callback' => array($this, 'callbackColumnProductTitle'),
|
90 |
+
'filter_condition_callback' => array($this, 'callbackFilterTitle')
|
91 |
+
));
|
92 |
+
|
93 |
+
$this->addColumn('general_id', array(
|
94 |
+
'header' => Mage::helper('M2ePro')->__('ASIN / ISBN'),
|
95 |
+
'align' => 'left',
|
96 |
+
'width' => '100px',
|
97 |
+
'type' => 'text',
|
98 |
+
'index' => 'general_id',
|
99 |
+
'filter_index' => 'general_id',
|
100 |
+
'frame_callback' => array($this, 'callbackColumnGeneralId')
|
101 |
+
));
|
102 |
+
|
103 |
+
$this->addColumn('online_qty', array(
|
104 |
+
'header' => Mage::helper('M2ePro')->__('QTY'),
|
105 |
+
'align' => 'right',
|
106 |
+
'width' => '100px',
|
107 |
+
'type' => 'number',
|
108 |
+
'index' => 'online_qty',
|
109 |
+
'filter_index' => 'online_qty',
|
110 |
+
'frame_callback' => array($this, 'callbackColumnAvailableQty')
|
111 |
+
));
|
112 |
+
|
113 |
+
$this->addColumn('online_price', array(
|
114 |
+
'header' => Mage::helper('M2ePro')->__('Price'),
|
115 |
+
'align' => 'right',
|
116 |
+
'width' => '100px',
|
117 |
+
'type' => 'number',
|
118 |
+
'index' => 'online_price',
|
119 |
+
'filter_index' => 'online_price',
|
120 |
+
'frame_callback' => array($this, 'callbackColumnPrice')
|
121 |
+
));
|
122 |
+
|
123 |
+
$this->addColumn('is_afn_channel', array(
|
124 |
+
'header' => Mage::helper('M2ePro')->__('Fulfillment'),
|
125 |
+
'width' => '100px',
|
126 |
+
'index' => 'is_afn_channel',
|
127 |
+
'filter_index' => 'second_table.is_afn_channel',
|
128 |
+
'type' => 'options',
|
129 |
+
'sortable' => false,
|
130 |
+
'options' => array(
|
131 |
+
0 => Mage::helper('M2ePro')->__('Merchant'),
|
132 |
+
1 => Mage::helper('M2ePro')->__('Amazon')
|
133 |
+
),
|
134 |
+
'frame_callback' => array($this, 'callbackColumnAfnChannel')
|
135 |
+
));
|
136 |
+
|
137 |
+
$this->addColumn('status', array(
|
138 |
+
'header' => Mage::helper('M2ePro')->__('Status'),
|
139 |
+
'width' => '60px',
|
140 |
+
'index' => 'status',
|
141 |
+
'filter_index' => 'main_table.status',
|
142 |
+
'type' => 'options',
|
143 |
+
'sortable' => false,
|
144 |
+
'options' => array(
|
145 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_UNKNOWN => Mage::helper('M2ePro')->__('Unknown'),
|
146 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_LISTED => Mage::helper('M2ePro')->__('Active'),
|
147 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED => Mage::helper('M2ePro')->__('Inactive'),
|
148 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_BLOCKED => Mage::helper('M2ePro')->__('Inactive (Blocked)')
|
149 |
+
),
|
150 |
+
'frame_callback' => array($this, 'callbackColumnStatus')
|
151 |
+
));
|
152 |
+
|
153 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
154 |
+
'*/adminhtml_common_listing_other/index',
|
155 |
+
array(
|
156 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON
|
157 |
+
)
|
158 |
+
);
|
159 |
+
|
160 |
+
$this->addColumn('actions', array(
|
161 |
+
'header' => Mage::helper('M2ePro')->__('Actions'),
|
162 |
+
'align' => 'left',
|
163 |
+
'width' => '70px',
|
164 |
+
'type' => 'action',
|
165 |
+
'index' => 'actions',
|
166 |
+
'filter' => false,
|
167 |
+
'sortable' => false,
|
168 |
+
'getter' => 'getId',
|
169 |
+
'actions' => array(
|
170 |
+
array(
|
171 |
+
'caption' => Mage::helper('M2ePro')->__('View Log'),
|
172 |
+
'field' => 'id',
|
173 |
+
'url' => array(
|
174 |
+
'base' => '*/adminhtml_common_log/listingOther',
|
175 |
+
'params' => array(
|
176 |
+
'back' => $backUrl,
|
177 |
+
'channel' => Ess_M2ePro_Helper_Component_Amazon::NICK
|
178 |
+
)
|
179 |
+
)
|
180 |
+
),
|
181 |
+
array(
|
182 |
+
'caption' => Mage::helper('M2ePro')->__('Clear Log'),
|
183 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?'),
|
184 |
+
'field' => 'id',
|
185 |
+
'url' => array(
|
186 |
+
'base' => '*/adminhtml_listing_other/clearLog',
|
187 |
+
'params' => array(
|
188 |
+
'back' => $backUrl
|
189 |
+
)
|
190 |
+
)
|
191 |
+
)
|
192 |
+
)
|
193 |
+
));
|
194 |
+
|
195 |
+
return parent::_prepareColumns();
|
196 |
+
}
|
197 |
+
|
198 |
+
protected function _prepareMassaction()
|
199 |
+
{
|
200 |
+
// Set mass-action identifiers
|
201 |
+
//--------------------------------
|
202 |
+
$this->setMassactionIdField('`main_table`.id');
|
203 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
204 |
+
//--------------------------------
|
205 |
+
|
206 |
+
$this->getMassactionBlock()->setGroups(array(
|
207 |
+
'mapping' => Mage::helper('M2ePro')->__('Mapping'),
|
208 |
+
'other' => Mage::helper('M2ePro')->__('Other')
|
209 |
+
));
|
210 |
+
|
211 |
+
// Set mass-action
|
212 |
+
//--------------------------------
|
213 |
+
$this->getMassactionBlock()->addItem('autoMapping', array(
|
214 |
+
'label' => Mage::helper('M2ePro')->__('Map Item(s) Automatically'),
|
215 |
+
'url' => '',
|
216 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
217 |
+
), 'mapping');
|
218 |
+
$this->getMassactionBlock()->addItem('moving', array(
|
219 |
+
'label' => Mage::helper('M2ePro')->__('Move Item(s) to Listing'),
|
220 |
+
'url' => '',
|
221 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
222 |
+
), 'other');
|
223 |
+
$this->getMassactionBlock()->addItem('removing', array(
|
224 |
+
'label' => Mage::helper('M2ePro')->__('Remove Item(s)'),
|
225 |
+
'url' => '',
|
226 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
227 |
+
), 'other');
|
228 |
+
$this->getMassactionBlock()->addItem('unmapping', array(
|
229 |
+
'label' => Mage::helper('M2ePro')->__('Unmap Item(s)'),
|
230 |
+
'url' => '',
|
231 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
232 |
+
), 'mapping');
|
233 |
+
//--------------------------------
|
234 |
+
|
235 |
+
return parent::_prepareMassaction();
|
236 |
+
}
|
237 |
+
|
238 |
+
// ####################################
|
239 |
+
|
240 |
+
public function callbackColumnProductId($value, $row, $column, $isExport)
|
241 |
+
{
|
242 |
+
if (empty($value)) {
|
243 |
+
$productTitle = Mage::helper('M2ePro')->escapeHtml($row->getData('title'));
|
244 |
+
$productTitle = Mage::helper('M2ePro')->escapeJs($productTitle);
|
245 |
+
if (strlen($productTitle) > 60) {
|
246 |
+
$productTitle = substr($productTitle, 0, 60) . '...';
|
247 |
+
}
|
248 |
+
$htmlValue = ' <a href="javascript:void(0);"
|
249 |
+
onclick="AmazonListingOtherMappingHandlerObj.openPopUp(\''.
|
250 |
+
$productTitle.
|
251 |
+
'\','.
|
252 |
+
(int)$row->getId().
|
253 |
+
');">' . Mage::helper('M2ePro')->__('Map') . '</a>';
|
254 |
+
|
255 |
+
if (Mage::helper('M2ePro/Module')->isDevelopmentMode()) {
|
256 |
+
$htmlValue .= '<br/>' . $row->getId();
|
257 |
+
}
|
258 |
+
return $htmlValue;
|
259 |
+
}
|
260 |
+
|
261 |
+
$htmlValue = ' <a href="'
|
262 |
+
.$this->getUrl('adminhtml/catalog_product/edit',
|
263 |
+
array('id' => $row->getData('product_id')))
|
264 |
+
.'" target="_blank">'
|
265 |
+
.$row->getData('product_id')
|
266 |
+
.'</a>';
|
267 |
+
|
268 |
+
$htmlValue .= '   <a href="javascript:void(0);"'
|
269 |
+
.' onclick="AmazonListingOtherGridHandlerObj.movingHandler.getGridHtml('
|
270 |
+
.json_encode(array((int)$row->getData('id')))
|
271 |
+
.')">'
|
272 |
+
.Mage::helper('M2ePro')->__('Move')
|
273 |
+
.'</a>';
|
274 |
+
|
275 |
+
if (Mage::helper('M2ePro/Module')->isDevelopmentMode()) {
|
276 |
+
$htmlValue .= '<br/>' . $row->getId();
|
277 |
+
}
|
278 |
+
|
279 |
+
return $htmlValue;
|
280 |
+
}
|
281 |
+
|
282 |
+
public function callbackColumnProductTitle($value, $row, $column, $isExport)
|
283 |
+
{
|
284 |
+
$value = '<span>' . Mage::helper('M2ePro')->escapeHtml($value) . '</span>';
|
285 |
+
|
286 |
+
$tempSku = $row->getData('sku');
|
287 |
+
empty($tempSku) && $tempSku = 'N/A';
|
288 |
+
|
289 |
+
$value .= '<br/><strong>'
|
290 |
+
.Mage::helper('M2ePro')->__('SKU')
|
291 |
+
.':</strong> '
|
292 |
+
.Mage::helper('M2ePro')->escapeHtml($tempSku);
|
293 |
+
|
294 |
+
return $value;
|
295 |
+
}
|
296 |
+
|
297 |
+
public function callbackColumnGeneralId($value, $row, $column, $isExport)
|
298 |
+
{
|
299 |
+
$url = Mage::helper('M2ePro/Component_Amazon')->getItemUrl($value, $row->getData('marketplace_id'));
|
300 |
+
return '<a href="'.$url.'" target="_blank">'.$value.'</a>';
|
301 |
+
}
|
302 |
+
|
303 |
+
public function callbackColumnAvailableQty($value, $row, $column, $isExport)
|
304 |
+
{
|
305 |
+
if (is_null($value) || $value === '') {
|
306 |
+
return Mage::helper('M2ePro')->__('N/A');
|
307 |
+
}
|
308 |
+
|
309 |
+
if ((bool)$row->getData('is_afn_channel')) {
|
310 |
+
return '--';
|
311 |
+
}
|
312 |
+
|
313 |
+
if ($value <= 0) {
|
314 |
+
return '<span style="color: red;">0</span>';
|
315 |
+
}
|
316 |
+
|
317 |
+
return $value;
|
318 |
+
}
|
319 |
+
|
320 |
+
public function callbackColumnPrice($value, $row, $column, $isExport)
|
321 |
+
{
|
322 |
+
if (is_null($value) || $value === '') {
|
323 |
+
return Mage::helper('M2ePro')->__('N/A');
|
324 |
+
}
|
325 |
+
|
326 |
+
if ((float)$value <= 0) {
|
327 |
+
return '<span style="color: #f00;">0</span>';
|
328 |
+
}
|
329 |
+
|
330 |
+
$currency = Mage::helper('M2ePro/Component_Amazon')
|
331 |
+
->getCachedObject('Marketplace',$row->getData('marketplace_id'))
|
332 |
+
->getChildObject()
|
333 |
+
->getDefaultCurrency();
|
334 |
+
|
335 |
+
return Mage::app()->getLocale()->currency($currency)->toCurrency($value);
|
336 |
+
}
|
337 |
+
|
338 |
+
public function callbackColumnAfnChannel($value, $row, $column, $isExport)
|
339 |
+
{
|
340 |
+
switch ($row->getData('is_afn_channel')) {
|
341 |
+
case Ess_M2ePro_Model_Amazon_Listing_Product::IS_ISBN_GENERAL_ID_YES:
|
342 |
+
$value = '<span style="font-weight: bold;">' . $value . '</span>';
|
343 |
+
break;
|
344 |
+
|
345 |
+
default:
|
346 |
+
break;
|
347 |
+
}
|
348 |
+
|
349 |
+
return $value;
|
350 |
+
}
|
351 |
+
|
352 |
+
public function callbackColumnStatus($value, $row, $column, $isExport)
|
353 |
+
{
|
354 |
+
switch ($row->getData('status')) {
|
355 |
+
|
356 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_UNKNOWN:
|
357 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED:
|
358 |
+
$value = '<span style="color: gray;">' . $value . '</span>';
|
359 |
+
break;
|
360 |
+
|
361 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_LISTED:
|
362 |
+
$value = '<span style="color: green;">' . $value . '</span>';
|
363 |
+
break;
|
364 |
+
|
365 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED:
|
366 |
+
$value = '<span style="color: red;">' . $value . '</span>';
|
367 |
+
break;
|
368 |
+
|
369 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_BLOCKED:
|
370 |
+
$value = '<span style="color: orange; font-weight: bold;">' . $value . '</span>';
|
371 |
+
break;
|
372 |
+
|
373 |
+
default:
|
374 |
+
break;
|
375 |
+
}
|
376 |
+
|
377 |
+
return $value.$this->getViewLogIconHtml($row->getId());
|
378 |
+
}
|
379 |
+
|
380 |
+
protected function callbackFilterTitle($collection, $column)
|
381 |
+
{
|
382 |
+
$value = $column->getFilter()->getValue();
|
383 |
+
|
384 |
+
if ($value == null) {
|
385 |
+
return;
|
386 |
+
}
|
387 |
+
|
388 |
+
$collection->getSelect()->where('second_table.title LIKE ? OR second_table.sku LIKE ?', '%'.$value.'%');
|
389 |
+
}
|
390 |
+
|
391 |
+
// ####################################
|
392 |
+
|
393 |
+
public function getViewLogIconHtml($listingOtherId)
|
394 |
+
{
|
395 |
+
$listingOtherId = (int)$listingOtherId;
|
396 |
+
|
397 |
+
// Get last messages
|
398 |
+
//--------------------------
|
399 |
+
$dbSelect = $this->connRead->select()
|
400 |
+
->from(
|
401 |
+
Mage::getResourceModel('M2ePro/Listing_Other_Log')->getMainTable(),
|
402 |
+
array('action_id','action','type','description','create_date','initiator')
|
403 |
+
)
|
404 |
+
->where('`listing_other_id` = ?', $listingOtherId)
|
405 |
+
->where('`action_id` IS NOT NULL')
|
406 |
+
->order(array('id DESC'))
|
407 |
+
->limit(30);
|
408 |
+
|
409 |
+
$logRows = $this->connRead->fetchAll($dbSelect);
|
410 |
+
//--------------------------
|
411 |
+
|
412 |
+
// Get grouped messages by action_id
|
413 |
+
//--------------------------
|
414 |
+
$actionsRows = array();
|
415 |
+
$tempActionRows = array();
|
416 |
+
$lastActionId = false;
|
417 |
+
|
418 |
+
foreach ($logRows as $row) {
|
419 |
+
|
420 |
+
$row['description'] = Mage::helper('M2ePro/View')->getModifiedLogMessage($row['description']);
|
421 |
+
|
422 |
+
if ($row['action_id'] !== $lastActionId) {
|
423 |
+
if (count($tempActionRows) > 0) {
|
424 |
+
$actionsRows[] = array(
|
425 |
+
'type' => $this->getMainTypeForActionId($tempActionRows),
|
426 |
+
'date' => $this->getMainDateForActionId($tempActionRows),
|
427 |
+
'action' => $this->getActionForAction($tempActionRows[0]),
|
428 |
+
'initiator' => $this->getInitiatorForAction($tempActionRows[0]),
|
429 |
+
'items' => $tempActionRows
|
430 |
+
);
|
431 |
+
$tempActionRows = array();
|
432 |
+
}
|
433 |
+
$lastActionId = $row['action_id'];
|
434 |
+
}
|
435 |
+
$tempActionRows[] = $row;
|
436 |
+
}
|
437 |
+
|
438 |
+
if (count($tempActionRows) > 0) {
|
439 |
+
$actionsRows[] = array(
|
440 |
+
'type' => $this->getMainTypeForActionId($tempActionRows),
|
441 |
+
'date' => $this->getMainDateForActionId($tempActionRows),
|
442 |
+
'action' => $this->getActionForAction($tempActionRows[0]),
|
443 |
+
'initiator' => $this->getInitiatorForAction($tempActionRows[0]),
|
444 |
+
'items' => $tempActionRows
|
445 |
+
);
|
446 |
+
}
|
447 |
+
|
448 |
+
if (count($actionsRows) <= 0) {
|
449 |
+
return '';
|
450 |
+
}
|
451 |
+
|
452 |
+
$tips = array(
|
453 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'Last Action was completed successfully.',
|
454 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'Last Action was completed with error(s).',
|
455 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'Last Action was completed with warning(s).'
|
456 |
+
);
|
457 |
+
|
458 |
+
$icons = array(
|
459 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'normal',
|
460 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'error',
|
461 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'warning'
|
462 |
+
);
|
463 |
+
|
464 |
+
$summary = $this->getLayout()->createBlock('M2ePro/adminhtml_log_grid_summary', '', array(
|
465 |
+
'entity_id' => $listingOtherId,
|
466 |
+
'rows' => $actionsRows,
|
467 |
+
'tips' => $tips,
|
468 |
+
'icons' => $icons,
|
469 |
+
'view_help_handler' => 'AmazonListingOtherGridHandlerObj.viewItemHelp',
|
470 |
+
'hide_help_handler' => 'AmazonListingOtherGridHandlerObj.hideItemHelp',
|
471 |
+
));
|
472 |
+
|
473 |
+
return $summary->toHtml();
|
474 |
+
}
|
475 |
+
|
476 |
+
public function getActionForAction($actionRows)
|
477 |
+
{
|
478 |
+
$string = '';
|
479 |
+
|
480 |
+
switch ((int)$actionRows['action']) {
|
481 |
+
case Ess_M2ePro_Model_Listing_Other_Log::ACTION_CHANGE_STATUS_ON_CHANNEL:
|
482 |
+
$string = Mage::helper('M2ePro')->__('Status Change');
|
483 |
+
break;
|
484 |
+
}
|
485 |
+
|
486 |
+
return $string;
|
487 |
+
}
|
488 |
+
|
489 |
+
public function getInitiatorForAction($actionRows)
|
490 |
+
{
|
491 |
+
$string = '';
|
492 |
+
|
493 |
+
switch ($actionRows['initiator']) {
|
494 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_UNKNOWN:
|
495 |
+
$string = '';
|
496 |
+
break;
|
497 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_USER:
|
498 |
+
$string = Mage::helper('M2ePro')->__('Manual');
|
499 |
+
break;
|
500 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION:
|
501 |
+
$string = Mage::helper('M2ePro')->__('Automatic');
|
502 |
+
break;
|
503 |
+
}
|
504 |
+
|
505 |
+
return $string;
|
506 |
+
}
|
507 |
+
|
508 |
+
public function getMainTypeForActionId($actionRows)
|
509 |
+
{
|
510 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS;
|
511 |
+
|
512 |
+
foreach ($actionRows as $row) {
|
513 |
+
if ($row['type'] == Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR) {
|
514 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR;
|
515 |
+
break;
|
516 |
+
}
|
517 |
+
if ($row['type'] == Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING) {
|
518 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING;
|
519 |
+
}
|
520 |
+
}
|
521 |
+
|
522 |
+
return $type;
|
523 |
+
}
|
524 |
+
|
525 |
+
public function getMainDateForActionId($actionRows)
|
526 |
+
{
|
527 |
+
$format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
|
528 |
+
return Mage::app()->getLocale()->date(strtotime($actionRows[0]['create_date']))->toString($format);
|
529 |
+
}
|
530 |
+
|
531 |
+
// ####################################
|
532 |
+
|
533 |
+
protected function _toHtml()
|
534 |
+
{
|
535 |
+
$javascriptsMain = <<<JAVASCRIPT
|
536 |
+
<script type="text/javascript">
|
537 |
+
|
538 |
+
if (typeof AmazonListingOtherGridHandlerObj != 'undefined') {
|
539 |
+
AmazonListingOtherGridHandlerObj.afterInitPage();
|
540 |
+
}
|
541 |
+
|
542 |
+
Event.observe(window, 'load', function() {
|
543 |
+
setTimeout(function() {
|
544 |
+
AmazonListingOtherGridHandlerObj.afterInitPage();
|
545 |
+
}, 350);
|
546 |
+
});
|
547 |
+
|
548 |
+
</script>
|
549 |
+
JAVASCRIPT;
|
550 |
+
|
551 |
+
return parent::_toHtml().$javascriptsMain;
|
552 |
+
}
|
553 |
+
|
554 |
+
// ####################################
|
555 |
+
|
556 |
+
public function getGridUrl()
|
557 |
+
{
|
558 |
+
return $this->getUrl('*/adminhtml_common_amazon_listing_other/grid', array('_current' => true));
|
559 |
+
}
|
560 |
+
|
561 |
+
public function getRowUrl($row)
|
562 |
+
{
|
563 |
+
return false;
|
564 |
+
}
|
565 |
+
|
566 |
+
// ####################################
|
567 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Product.php
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Product extends Mage_Adminhtml_Block_Widget_Grid_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonListingProduct');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_amazon_listing_product';
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
// Set header text
|
21 |
+
//------------------------------
|
22 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
23 |
+
|
24 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
25 |
+
$headerText = Mage::helper('M2ePro')->__(
|
26 |
+
'Add Products To %component_name% Listing "%listing_title%"',
|
27 |
+
Mage::helper('M2ePro/Component_Amazon')->getTitle(),
|
28 |
+
$this->escapeHtml($listingData['title'])
|
29 |
+
);
|
30 |
+
} else {
|
31 |
+
$headerText = Mage::helper('M2ePro')->__(
|
32 |
+
'Add Products To Listing "%listing_title%"',
|
33 |
+
$this->escapeHtml($listingData['title'])
|
34 |
+
);
|
35 |
+
}
|
36 |
+
|
37 |
+
$this->_headerText = $headerText;
|
38 |
+
//------------------------------
|
39 |
+
|
40 |
+
// Set buttons actions
|
41 |
+
//------------------------------
|
42 |
+
$this->removeButton('back');
|
43 |
+
$this->removeButton('reset');
|
44 |
+
$this->removeButton('delete');
|
45 |
+
$this->removeButton('add');
|
46 |
+
$this->removeButton('save');
|
47 |
+
$this->removeButton('edit');
|
48 |
+
//------------------------------
|
49 |
+
|
50 |
+
//------------------------------
|
51 |
+
if (is_null($this->getRequest()->getParam('back'))) {
|
52 |
+
$url = $this->getUrl(
|
53 |
+
'*/adminhtml_common_amazon_listing/categoryProduct',
|
54 |
+
array(
|
55 |
+
'id' => $listingData['id'],
|
56 |
+
'save_categories' => $this->getRequest()->getParam('save_categories', 1),
|
57 |
+
'selected_categories' => $this->getRequest()->getParam('selected_categories')
|
58 |
+
)
|
59 |
+
);
|
60 |
+
} else {
|
61 |
+
$url = Mage::helper('M2ePro')->getBackUrl(
|
62 |
+
'*/adminhtml_common_listing/index',
|
63 |
+
array(
|
64 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON
|
65 |
+
)
|
66 |
+
);
|
67 |
+
}
|
68 |
+
$this->_addButton('back', array(
|
69 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
70 |
+
'onclick' => 'ProductGridHandlerObj.back_click(\''.$url.'\')',
|
71 |
+
'class' => 'back'
|
72 |
+
));
|
73 |
+
//------------------------------
|
74 |
+
|
75 |
+
//------------------------------
|
76 |
+
$this->_addButton('save', array(
|
77 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
78 |
+
'onclick' => 'ProductGridHandlerObj.save_click(\'view\')',
|
79 |
+
'class' => 'save'
|
80 |
+
));
|
81 |
+
//------------------------------
|
82 |
+
}
|
83 |
+
|
84 |
+
public function getGridHtml()
|
85 |
+
{
|
86 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_listing_product_help');
|
87 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
88 |
+
}
|
89 |
+
|
90 |
+
protected function _toHtml()
|
91 |
+
{
|
92 |
+
return '<div id="add_products_progress_bar"></div>'.
|
93 |
+
'<div id="add_products_container">'.
|
94 |
+
parent::_toHtml().
|
95 |
+
'</div>';
|
96 |
+
}
|
97 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Product/Help.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Product_Help extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonListingProductHelp');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/amazon/listing/product/help.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/ProductSearch/Grid.php
ADDED
@@ -0,0 +1,529 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_ProductSearch_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
private $productId;
|
10 |
+
private $currency;
|
11 |
+
|
12 |
+
/** @var Ess_M2ePro_Model_Listing_Product $listingProduct */
|
13 |
+
private $listingProduct;
|
14 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Matcher_Attribute $matcherAttributes */
|
15 |
+
private $matcherAttributes;
|
16 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Matcher_Option $matcherOptions */
|
17 |
+
private $matcherOptions;
|
18 |
+
|
19 |
+
public function __construct()
|
20 |
+
{
|
21 |
+
parent::__construct();
|
22 |
+
|
23 |
+
$this->productId = Mage::helper('M2ePro/Data_Global')->getValue('product_id');
|
24 |
+
$this->listingProduct = Mage::getModel('M2ePro/Listing_Product')->load($this->productId);
|
25 |
+
|
26 |
+
$this->matcherAttributes = Mage::getModel('M2ePro/Amazon_Listing_Product_Variation_Matcher_Attribute');
|
27 |
+
$this->matcherAttributes->setMarketplaceId(Mage::helper('M2ePro/Data_Global')->getValue('marketplace_id'));
|
28 |
+
|
29 |
+
$this->matcherOptions = Mage::getModel('M2ePro/Amazon_Listing_Product_Variation_Matcher_Option');
|
30 |
+
$this->matcherOptions->setMarketplaceId(Mage::helper('M2ePro/Data_Global')->getValue('marketplace_id'));
|
31 |
+
|
32 |
+
$this->currency = Mage::helper('M2ePro/Component_Amazon')
|
33 |
+
->getCachedObject('Marketplace', Mage::helper('M2ePro/Data_Global')->getValue('marketplace_id'))
|
34 |
+
->getChildObject()
|
35 |
+
->getDefaultCurrency();
|
36 |
+
|
37 |
+
// Initialization block
|
38 |
+
//------------------------------
|
39 |
+
$this->setId('amazonProductSearchGrid');
|
40 |
+
//------------------------------
|
41 |
+
|
42 |
+
// Set default values
|
43 |
+
//------------------------------
|
44 |
+
$this->setFilterVisibility(false);
|
45 |
+
$this->setPagerVisibility(false);
|
46 |
+
$this->setDefaultSort('id');
|
47 |
+
$this->setDefaultDir('ASC');
|
48 |
+
$this->setSaveParametersInSession(true);
|
49 |
+
$this->setUseAjax(true);
|
50 |
+
//------------------------------
|
51 |
+
}
|
52 |
+
|
53 |
+
protected function _prepareCollection()
|
54 |
+
{
|
55 |
+
$data = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
56 |
+
|
57 |
+
$results = new Varien_Data_Collection();
|
58 |
+
foreach ($data['data'] as $index => $item) {
|
59 |
+
$temp = array(
|
60 |
+
'id' => $index,
|
61 |
+
'general_id' => $item['general_id'],
|
62 |
+
'brand' => $item['brand'],
|
63 |
+
'title' => $item['title'],
|
64 |
+
'image_url' => $item['image_url'],
|
65 |
+
'price' => isset($item['list_price']['amount']) ? $item['list_price']['amount'] : null,
|
66 |
+
'is_variation_product' => $item['is_variation_product']
|
67 |
+
);
|
68 |
+
|
69 |
+
if ($temp['is_variation_product']) {
|
70 |
+
if(!$item['bad_parent']) {
|
71 |
+
$temp += array(
|
72 |
+
'parentage' => $item['parentage'],
|
73 |
+
'variations' => $item['variations'],
|
74 |
+
'bad_parent' => $item['bad_parent']
|
75 |
+
);
|
76 |
+
} else {
|
77 |
+
$temp['bad_parent'] = $item['bad_parent'];
|
78 |
+
}
|
79 |
+
|
80 |
+
if (!empty($item['requested_child_id'])) {
|
81 |
+
$temp['requested_child_id'] = $item['requested_child_id'];
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
+
$results->addItem(new Varien_Object($temp));
|
86 |
+
}
|
87 |
+
|
88 |
+
$this->setCollection($results);
|
89 |
+
|
90 |
+
return parent::_prepareCollection();
|
91 |
+
}
|
92 |
+
|
93 |
+
protected function _prepareColumns()
|
94 |
+
{
|
95 |
+
$this->addColumn('image', array(
|
96 |
+
'header' => Mage::helper('M2ePro')->__('Image'),
|
97 |
+
'align' => 'center',
|
98 |
+
'type' => 'text',
|
99 |
+
'width' => '80px',
|
100 |
+
'index' => 'image_url',
|
101 |
+
'filter' => false,
|
102 |
+
'sortable' => false,
|
103 |
+
'frame_callback' => array($this, 'callbackColumnImage')
|
104 |
+
));
|
105 |
+
|
106 |
+
$this->addColumn('title', array(
|
107 |
+
'header' => Mage::helper('M2ePro')->__('Title'),
|
108 |
+
'align' => 'left',
|
109 |
+
'type' => 'text',
|
110 |
+
'string_limit' => 10000,
|
111 |
+
'width' => '375px',
|
112 |
+
'index' => 'title',
|
113 |
+
'filter' => false,
|
114 |
+
'sortable' => false,
|
115 |
+
'frame_callback' => array($this, 'callbackColumnTitle'),
|
116 |
+
));
|
117 |
+
|
118 |
+
$this->addColumn('price',array(
|
119 |
+
'header' => Mage::helper('catalog')->__('Price'),
|
120 |
+
'width' => '60px',
|
121 |
+
'align' => 'right',
|
122 |
+
'index' => 'price',
|
123 |
+
'filter' => false,
|
124 |
+
'sortable' => false,
|
125 |
+
'type' => 'number',
|
126 |
+
'frame_callback' => array($this, 'callbackColumnPrice')
|
127 |
+
));
|
128 |
+
|
129 |
+
$this->addColumn('general_id', array(
|
130 |
+
'header' => Mage::helper('M2ePro')->__('ASIN / ISBN'),
|
131 |
+
'align' => 'center',
|
132 |
+
'type' => 'text',
|
133 |
+
'width' => '75px',
|
134 |
+
'index' => 'general_id',
|
135 |
+
'filter' => false,
|
136 |
+
'sortable' => false,
|
137 |
+
'frame_callback' => array($this, 'callbackColumnGeneralId')
|
138 |
+
));
|
139 |
+
|
140 |
+
$this->addColumn('actions', array(
|
141 |
+
'header' => Mage::helper('M2ePro')->__('Action'),
|
142 |
+
'align' => 'center',
|
143 |
+
'type' => 'text',
|
144 |
+
'width' => '78px',
|
145 |
+
'filter' => false,
|
146 |
+
'sortable' => false,
|
147 |
+
'frame_callback' => array($this, 'callbackColumnActions'),
|
148 |
+
));
|
149 |
+
|
150 |
+
}
|
151 |
+
|
152 |
+
// ####################################
|
153 |
+
|
154 |
+
public function callbackColumnImage($value, $product, $column, $isExport)
|
155 |
+
{
|
156 |
+
return '<img src="'.$value.'" />';
|
157 |
+
}
|
158 |
+
|
159 |
+
public function callbackColumnGeneralId($value, $product, $column, $isExport)
|
160 |
+
{
|
161 |
+
$url = Mage::helper('M2ePro/Component_Amazon')
|
162 |
+
->getItemUrl($value, Mage::helper('M2ePro/Data_Global')->getValue('marketplace_id'));
|
163 |
+
|
164 |
+
$parentAsinText = Mage::helper('M2ePro')->__('parent ASIN/ISBN');
|
165 |
+
|
166 |
+
return <<<HTML
|
167 |
+
<a id="asin_link_{$product->getData('id')}" href="{$url}" target="_blank">{$value}</a>
|
168 |
+
<div id="parent_asin_text_{$product->getData('id')}" style="font-size: 9px; color: grey; display: none">
|
169 |
+
{$parentAsinText}
|
170 |
+
</div>
|
171 |
+
HTML;
|
172 |
+
|
173 |
+
}
|
174 |
+
|
175 |
+
public function callbackColumnTitle($value, $row, $column, $isExport)
|
176 |
+
{
|
177 |
+
$value = '<div style="margin-left: 3px; margin-bottom: 10px;">'.
|
178 |
+
Mage::helper('M2ePro')->escapeHtml($value)."</div>";
|
179 |
+
|
180 |
+
if(!$this->listingProduct->getChildObject()->getVariationManager()->isVariationProduct()
|
181 |
+
|| $this->listingProduct->getChildObject()->getVariationManager()->isIndividualType()) {
|
182 |
+
if(!$row->getData('is_variation_product')) {
|
183 |
+
return $value;
|
184 |
+
}
|
185 |
+
} else {
|
186 |
+
if(!$row->getData('is_variation_product')) {
|
187 |
+
return $value;
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
if($row->getData('is_variation_product') && $row->getData('bad_parent')) {
|
192 |
+
return $value;
|
193 |
+
}
|
194 |
+
|
195 |
+
$id = $row->getId();
|
196 |
+
$variations = $row->getData('variations');
|
197 |
+
|
198 |
+
if($this->listingProduct->getChildObject()->getVariationManager()->isRelationParentType()) {
|
199 |
+
|
200 |
+
$magentoProductAttributesHtml = '';
|
201 |
+
$magentoProductAttributesJs = '';
|
202 |
+
|
203 |
+
$destinationAttributes = array_keys($variations['set']);
|
204 |
+
|
205 |
+
$this->matcherAttributes->setMagentoProduct($this->listingProduct->getMagentoProduct());
|
206 |
+
$this->matcherAttributes->setDestinationAttributes($destinationAttributes);
|
207 |
+
|
208 |
+
if($this->matcherAttributes->isAmountEqual()) {
|
209 |
+
$magentoProductAttributesJs .= '<script type="text/javascript">';
|
210 |
+
$magentoProductAttributesHtml .= '<div><span style="margin-left: 10px;
|
211 |
+
font-size: 11px;
|
212 |
+
font-weight: bold;
|
213 |
+
color: #808080;
|
214 |
+
display: inline-block;
|
215 |
+
width: 170px;">' .
|
216 |
+
Mage::helper('M2ePro')->__('Magento Attributes') .
|
217 |
+
'</span><span style="margin-left: 10px;
|
218 |
+
font-size: 11px;
|
219 |
+
font-weight: bold;
|
220 |
+
color: #808080;
|
221 |
+
display: inline-block;">' .
|
222 |
+
Mage::helper('M2ePro')->__('Amazon Attributes') .
|
223 |
+
'</span></div>';
|
224 |
+
|
225 |
+
$matchedAttributes = $this->matcherAttributes->getMatchedAttributes();
|
226 |
+
$attributeId = 0;
|
227 |
+
foreach($matchedAttributes as $magentoAttr => $amazonAttr){
|
228 |
+
|
229 |
+
$magentoProductAttributesHtml .= '<span style="margin-left: 10px;
|
230 |
+
font-size: 11px;
|
231 |
+
color: #808080;
|
232 |
+
display: inline-block;
|
233 |
+
width: 170px;">'.
|
234 |
+
ucfirst(strtolower($magentoAttr)).
|
235 |
+
'</span>';
|
236 |
+
$magentoProductAttributesHtml .= '<input type="hidden" value="' .
|
237 |
+
Mage::helper('M2ePro')->escapeHtml($magentoAttr) . '"
|
238 |
+
id="magento_product_attribute_'.$attributeId.'_'.$id.'">';
|
239 |
+
$magentoProductAttributesHtml .= '<select class="amazon_product_attribute_'.$id.'"
|
240 |
+
onchange="ListingGridHandlerObj.productSearchHandler.attributesChange(this)"
|
241 |
+
style="width: 170px; margin-left: 5px; margin-right: 5px;
|
242 |
+
margin-bottom: 7px; font-size: 10px;"
|
243 |
+
id="amazon_product_attribute_'.$attributeId.'_'.$id.'">';
|
244 |
+
|
245 |
+
if (!array_key_exists($amazonAttr,$variations['set']))
|
246 |
+
{
|
247 |
+
$magentoProductAttributesHtml .= '<option class="empty" value=""></option>';
|
248 |
+
}
|
249 |
+
|
250 |
+
foreach ($variations['set'] as $attrKey => $attrData) {
|
251 |
+
|
252 |
+
$selected = '';
|
253 |
+
if ($attrKey == $amazonAttr) {
|
254 |
+
$selected = 'selected';
|
255 |
+
$magentoProductAttributesJs .= <<<JS
|
256 |
+
ListingGridHandlerObj.productSearchHandler.attributesChange({id:"magento_product_attribute_{$magentoAttr}_{$id}"});
|
257 |
+
JS;
|
258 |
+
}
|
259 |
+
|
260 |
+
$attrKey = Mage::helper('M2ePro')->escapeHtml($attrKey);
|
261 |
+
$magentoProductAttributesHtml .= '<option value="'.$attrKey.'" '.$selected.'>'
|
262 |
+
.$attrKey.'</option>';
|
263 |
+
}
|
264 |
+
$magentoProductAttributesHtml .= '</select><br/>';
|
265 |
+
$attributeId++;
|
266 |
+
}
|
267 |
+
|
268 |
+
$magentoProductAttributesJs .= '</script>';
|
269 |
+
|
270 |
+
$magentoProductAttributesHtml .= '<div id="variations_'.$id.'" style="display: none;">'.
|
271 |
+
json_encode($variations).
|
272 |
+
'</div>';
|
273 |
+
} else {
|
274 |
+
$value .= '<div style="font-size: 11px; font-weight: bold; color: grey; margin-left: 7px"><br/>';
|
275 |
+
$value .= implode(', ', $destinationAttributes);
|
276 |
+
$value .= '</div>';
|
277 |
+
}
|
278 |
+
|
279 |
+
return $value . $magentoProductAttributesHtml . $magentoProductAttributesJs;
|
280 |
+
}
|
281 |
+
|
282 |
+
$specificsHtml = '';
|
283 |
+
$specificsJs = '<script type="text/javascript">';
|
284 |
+
|
285 |
+
//match options for individual
|
286 |
+
if ($this->listingProduct->getChildObject()->getVariationManager()->isIndividualType() &&
|
287 |
+
$this->listingProduct->getChildObject()->getVariationManager()->getTypeModel()->isVariationProductMatched()
|
288 |
+
) {
|
289 |
+
$channelVariations = array();
|
290 |
+
foreach($variations['asins'] as $asin => $asinAttributes) {
|
291 |
+
$channelVariations[$asin] = $asinAttributes['specifics'];
|
292 |
+
}
|
293 |
+
|
294 |
+
$this->matcherAttributes->setMagentoProduct($this->listingProduct->getMagentoProduct());
|
295 |
+
$this->matcherAttributes->setDestinationAttributes(array_keys($variations['set']));
|
296 |
+
|
297 |
+
if ($this->matcherAttributes->isAmountEqual() && $this->matcherAttributes->isFullyMatched()) {
|
298 |
+
$matchedAttributes = $this->matcherAttributes->getMatchedAttributes();
|
299 |
+
|
300 |
+
$this->matcherOptions->setMagentoProduct($this->listingProduct->getMagentoProduct());
|
301 |
+
$this->matcherOptions->setDestinationOptions($channelVariations);
|
302 |
+
$this->matcherOptions->setMatchedAttributes($matchedAttributes);
|
303 |
+
|
304 |
+
$productOptions = $this->listingProduct->getChildObject()->getVariationManager()
|
305 |
+
->getTypeModel()->getProductOptions();
|
306 |
+
|
307 |
+
$requestedChildAsin = $this->matcherOptions->getMatchedOptionGeneralId($productOptions);
|
308 |
+
}
|
309 |
+
}
|
310 |
+
|
311 |
+
if (empty($requestedChildAsin)) {
|
312 |
+
$requestedChildAsin = $row->getData('requested_child_id');
|
313 |
+
}
|
314 |
+
|
315 |
+
$selectedOptions = array();
|
316 |
+
if ($requestedChildAsin) {
|
317 |
+
$selectedOptions = $variations['asins'][$requestedChildAsin]['specifics'];
|
318 |
+
}
|
319 |
+
|
320 |
+
$attributesNames = '<span style="margin-left: 10px;
|
321 |
+
min-width: 100px;
|
322 |
+
max-width: 170px;
|
323 |
+
font-size: 11px;
|
324 |
+
color: #808080;
|
325 |
+
display: inline-block;">';
|
326 |
+
$attributeValues = '<span style="margin-left: 5px; display: inline-block;">';
|
327 |
+
foreach ($variations['set'] as $specificName => $specific) {
|
328 |
+
$attributesNames .= '<span style="margin-bottom: 5px; display: inline-block;">'.
|
329 |
+
ucfirst(strtolower($specificName)).
|
330 |
+
'</span><br/>';
|
331 |
+
$attributeValues .= '<select class="specifics_'.$id.'"
|
332 |
+
onchange="ListingGridHandlerObj.productSearchHandler.specificsChange(this)"
|
333 |
+
style="width: 170px; margin-bottom: 5px; font-size: 10px;"
|
334 |
+
id="specific_'.$specificName.'_'.$id.'">';
|
335 |
+
$attributeValues .= '<option class="empty" value=""></option>';
|
336 |
+
foreach ($specific as $option) {
|
337 |
+
|
338 |
+
$selected = '';
|
339 |
+
if ($requestedChildAsin && $selectedOptions[$specificName] == $option) {
|
340 |
+
$selected = 'selected';
|
341 |
+
}
|
342 |
+
|
343 |
+
$option = Mage::helper('M2ePro')->escapeHtml($option);
|
344 |
+
$attributeValues .= '<option value="'.$option.'" '.$selected.'>'.$option.'</option>';
|
345 |
+
}
|
346 |
+
$attributeValues .= '</select><br/>';
|
347 |
+
|
348 |
+
$specificsJs .= <<<JS
|
349 |
+
ListingGridHandlerObj.productSearchHandler.specificsChange({id:"specific_{$specificName}_{$id}"});
|
350 |
+
JS;
|
351 |
+
}
|
352 |
+
|
353 |
+
$specificsHtml .= $attributesNames . '</span>';
|
354 |
+
$specificsHtml .= $attributeValues . '</span>';
|
355 |
+
|
356 |
+
$specificsJs .= '</script>';
|
357 |
+
|
358 |
+
$specificsJsonContainer = '<div id="parent_asin_'.$row->getId().'" style="display: none">'.
|
359 |
+
$row->getData('general_id').
|
360 |
+
'</div>'.
|
361 |
+
'<div id="asins_'.$id.'" style="display: none;">'.
|
362 |
+
json_encode($variations['asins']).
|
363 |
+
'</div>';
|
364 |
+
|
365 |
+
return $value . $specificsHtml . $specificsJsonContainer . $specificsJs;
|
366 |
+
}
|
367 |
+
|
368 |
+
public function callbackColumnPrice($value, $row, $column, $isExport)
|
369 |
+
{
|
370 |
+
if (empty($value) || $row->getData('is_variation_product')) {
|
371 |
+
$value = Mage::helper('M2ePro')->__('N/A');
|
372 |
+
} else {
|
373 |
+
$value = Mage::app()->getLocale()->currency($this->currency)->toCurrency($value);
|
374 |
+
}
|
375 |
+
|
376 |
+
return '<div style="margin-right: 5px;">'.$value.'</div>';
|
377 |
+
}
|
378 |
+
|
379 |
+
public function callbackColumnActions($value, $row, $column, $isExport)
|
380 |
+
{
|
381 |
+
$assignText = Mage::helper('M2ePro')->__('Assign');
|
382 |
+
$iconWarningPath = $this->getSkinUrl('M2ePro/images/warning.png');
|
383 |
+
$iconHelpPath = $this->getSkinUrl('M2ePro/images/i_notice.gif');
|
384 |
+
|
385 |
+
if(!$this->listingProduct->getChildObject()->getVariationManager()->isVariationProduct()
|
386 |
+
|| $this->listingProduct->getChildObject()->getVariationManager()->isIndividualType()) {
|
387 |
+
if (!$row->getData('is_variation_product')) {
|
388 |
+
|
389 |
+
return <<<HTML
|
390 |
+
<a href="javascript:void(0);" onclick="ListingGridHandlerObj.productSearchHandler.mapToGeneralId(
|
391 |
+
{$this->productId}, '{$row->getData('general_id')}');">{$assignText}</a>
|
392 |
+
HTML;
|
393 |
+
}
|
394 |
+
|
395 |
+
if(!$row->getData('bad_parent')) {
|
396 |
+
|
397 |
+
$msg = Mage::helper('M2ePro')->__(
|
398 |
+
'Please select necessary Options for this Amazon Product to be able to assign ASIN/ISBN.'
|
399 |
+
);
|
400 |
+
|
401 |
+
return <<<HTML
|
402 |
+
<span>
|
403 |
+
<span id="map_link_{$row->getId()}"><span style="color: #808080">{$assignText}</span></span>
|
404 |
+
<img id="map_link_error_icon_{$row->getId()}"
|
405 |
+
class="tool-tip-image"
|
406 |
+
style="vertical-align: middle; display: none;"
|
407 |
+
src="{$iconWarningPath}">
|
408 |
+
<span class="tool-tip-message tool-tip-warning tip-left" style="display:none;">
|
409 |
+
<img src="{$iconHelpPath}">
|
410 |
+
<span>{$msg}</span>
|
411 |
+
</span>
|
412 |
+
</span>
|
413 |
+
<div id="template_map_link_{$row->getId()}" style="display: none;">
|
414 |
+
<a href="javascript:void(0);" onclick="ListingGridHandlerObj.productSearchHandler.mapToGeneralId(
|
415 |
+
{$this->productId}, '%general_id%', '%options_data%'
|
416 |
+
);">{$assignText}</a>
|
417 |
+
</div>
|
418 |
+
HTML;
|
419 |
+
}
|
420 |
+
}
|
421 |
+
|
422 |
+
if($row->getData('is_variation_product') && !$row->getData('bad_parent')) {
|
423 |
+
|
424 |
+
$msg = Mage::helper('M2ePro')->__(
|
425 |
+
'Please map Amazon and Magento Attributes for this Amazon Product to be able to assign ASIN/ISBN.'
|
426 |
+
);
|
427 |
+
|
428 |
+
$variations = $row->getData('variations');
|
429 |
+
$this->matcherAttributes->setMagentoProduct($this->listingProduct->getMagentoProduct());
|
430 |
+
$this->matcherAttributes->setDestinationAttributes(array_keys($variations['set']));
|
431 |
+
|
432 |
+
if(!$this->matcherAttributes->isAmountEqual()) {
|
433 |
+
$msg = Mage::helper('M2ePro')->__(
|
434 |
+
'This ASIN/ISBN cannot be assigned to selected Magento Product. <br/>
|
435 |
+
The number of Magento Attributes is different from Amazon Attributes.'
|
436 |
+
);
|
437 |
+
}
|
438 |
+
|
439 |
+
return <<<HTML
|
440 |
+
<span>
|
441 |
+
<span id="map_link_{$row->getId()}"><span style="color: #808080">{$assignText}</span></span>
|
442 |
+
<img id="map_link_error_icon_{$row->getId()}"
|
443 |
+
class="tool-tip-image"
|
444 |
+
style="vertical-align: middle;"
|
445 |
+
src="{$iconWarningPath}">
|
446 |
+
<span class="tool-tip-message tool-tip-warning tip-left" style="display:none;">
|
447 |
+
<img src="{$iconHelpPath}">
|
448 |
+
<span>{$msg}</span>
|
449 |
+
</span>
|
450 |
+
</span>
|
451 |
+
<div id="template_map_link_{$row->getId()}" style="display: none;">
|
452 |
+
<a href="javascript:void(0);" onclick="ListingGridHandlerObj.productSearchHandler.mapToGeneralId(
|
453 |
+
{$this->productId}, '{$row->getData('general_id')}', '%options_data%'
|
454 |
+
);">{$assignText}</a>
|
455 |
+
</div>
|
456 |
+
HTML;
|
457 |
+
|
458 |
+
}
|
459 |
+
|
460 |
+
$msg = Mage::helper('M2ePro')->__(
|
461 |
+
'This ASIN/ISBN cannot be assigned to selected Magento Product. <br/>
|
462 |
+
This Amazon Product has no Variations. <br/>
|
463 |
+
Only Amazon Parent/Child Products can be assigned in "All Variations" Mode.'
|
464 |
+
);
|
465 |
+
|
466 |
+
if ($row->getData('is_variation_product') && $row->getData('bad_parent')) {
|
467 |
+
$msg = Mage::helper('M2ePro')->__(
|
468 |
+
'This ASIN/ISBN cannot be assigned to selected Magento Product. <br/>
|
469 |
+
Amazon Service (API) does not return all required information about this Amazon Product.'
|
470 |
+
);
|
471 |
+
}
|
472 |
+
|
473 |
+
return <<<HTML
|
474 |
+
<span>
|
475 |
+
<span id="map_link_{$row->getId()}"><span style="color: #808080">{$assignText}</span></span>
|
476 |
+
<img id="map_link_error_icon_{$row->getId()}"
|
477 |
+
class="tool-tip-image"
|
478 |
+
style="vertical-align: middle;"
|
479 |
+
src="{$iconWarningPath}">
|
480 |
+
<span class="tool-tip-message tool-tip-warning tip-left" style="display:none;">
|
481 |
+
<img src="{$iconHelpPath}">
|
482 |
+
<span>{$msg}</span>
|
483 |
+
</span>
|
484 |
+
</span>
|
485 |
+
HTML;
|
486 |
+
}
|
487 |
+
|
488 |
+
// ####################################
|
489 |
+
|
490 |
+
protected function _toHtml()
|
491 |
+
{
|
492 |
+
$javascriptsMain = <<<JAVASCRIPT
|
493 |
+
<script type="text/javascript">
|
494 |
+
|
495 |
+
$$('#amazonProductSearchGrid div.grid th').each(function(el){
|
496 |
+
el.style.padding = '2px 2px';
|
497 |
+
});
|
498 |
+
|
499 |
+
$$('#amazonProductSearchGrid div.grid td').each(function(el){
|
500 |
+
el.style.padding = '2px 2px';
|
501 |
+
});
|
502 |
+
|
503 |
+
</script>
|
504 |
+
JAVASCRIPT;
|
505 |
+
|
506 |
+
$searchData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
507 |
+
|
508 |
+
$searchParamsHtml = <<<HTML
|
509 |
+
<input id="amazon_asin_search_type" type="hidden" value="{$searchData['type']}">
|
510 |
+
<input id="amazon_asin_search_value" type="hidden" value="{$searchData['value']}">
|
511 |
+
HTML;
|
512 |
+
|
513 |
+
return parent::_toHtml() . $javascriptsMain . $searchParamsHtml;
|
514 |
+
}
|
515 |
+
|
516 |
+
// ####################################
|
517 |
+
|
518 |
+
public function getGridUrl()
|
519 |
+
{
|
520 |
+
return $this->getUrl('*/adminhtml_common_amazon_listing/getSuggestedAsinGrid', array('_current'=>true));
|
521 |
+
}
|
522 |
+
|
523 |
+
public function getRowUrl($row)
|
524 |
+
{
|
525 |
+
return false;
|
526 |
+
}
|
527 |
+
|
528 |
+
// ####################################
|
529 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/ProductSearch/Main.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_ProductSearch_Main extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
$this->setTemplate('M2ePro/common/amazon/listing/product_search/main.phtml');
|
14 |
+
}
|
15 |
+
|
16 |
+
protected function _beforeToHtml()
|
17 |
+
{
|
18 |
+
//------------------------------
|
19 |
+
$data = array(
|
20 |
+
'id' => 'productSearch_submit_button',
|
21 |
+
'label' => Mage::helper('M2ePro')->__('Search'),
|
22 |
+
'class' => 'productSearch_submit_button submit'
|
23 |
+
);
|
24 |
+
$buttonSubmitBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
25 |
+
$this->setChild('productSearch_submit_button', $buttonSubmitBlock);
|
26 |
+
//------------------------------
|
27 |
+
|
28 |
+
//------------------------------
|
29 |
+
$data = array(
|
30 |
+
'id' => 'productSearch_back_button',
|
31 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
32 |
+
'class' => 'productSearch_back_button'
|
33 |
+
);
|
34 |
+
$buttonBackBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
35 |
+
$this->setChild('productSearch_back_button', $buttonBackBlock);
|
36 |
+
//------------------------------
|
37 |
+
|
38 |
+
//------------------------------
|
39 |
+
$data = array(
|
40 |
+
'id' => 'productSearch_cancel_button',
|
41 |
+
'label' => Mage::helper('M2ePro')->__('Close'),
|
42 |
+
'class' => 'productSearch_cancel_button'
|
43 |
+
);
|
44 |
+
$buttonCancelBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
45 |
+
$this->setChild('productSearch_cancel_button', $buttonCancelBlock);
|
46 |
+
//------------------------------
|
47 |
+
|
48 |
+
//------------------------------
|
49 |
+
$data = array(
|
50 |
+
'id' => 'productSearch_cleanSuggest_button',
|
51 |
+
'label' => Mage::helper('M2ePro')->__('Clear Search Results'),
|
52 |
+
'class' => 'productSearch_cleanSuggest_button',
|
53 |
+
'onclick' => 'ListingGridHandlerObj.productSearchHandler.clearSearchResultsAndOpenSearchMenu()'
|
54 |
+
);
|
55 |
+
$buttonResetBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
56 |
+
$this->setChild('productSearch_cleanSuggest_button', $buttonResetBlock);
|
57 |
+
//------------------------------
|
58 |
+
|
59 |
+
parent::_beforeToHtml();
|
60 |
+
}
|
61 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/ProductSearch/Menu.php
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_ProductSearch_Menu extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
protected $listingProductId;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @param mixed $listingProductId
|
13 |
+
* @return $this
|
14 |
+
*/
|
15 |
+
public function setListingProductId($listingProductId)
|
16 |
+
{
|
17 |
+
$this->listingProductId = $listingProductId;
|
18 |
+
|
19 |
+
return $this;
|
20 |
+
}
|
21 |
+
/**
|
22 |
+
* @return mixed
|
23 |
+
*/
|
24 |
+
public function getListingProductId()
|
25 |
+
{
|
26 |
+
return $this->listingProductId;
|
27 |
+
}
|
28 |
+
|
29 |
+
//------------------------------
|
30 |
+
|
31 |
+
/** @var Ess_M2ePro_Model_Listing_Product $listingProduct */
|
32 |
+
protected $listingProduct = null;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @return Ess_M2ePro_Model_Listing_Product|null
|
36 |
+
*/
|
37 |
+
public function getListingProduct()
|
38 |
+
{
|
39 |
+
if(is_null($this->listingProduct)) {
|
40 |
+
$this->listingProduct = Mage::helper('M2ePro/Component_Amazon')
|
41 |
+
->getObject('Listing_Product', $this->getListingProductId());
|
42 |
+
}
|
43 |
+
|
44 |
+
return $this->listingProduct;
|
45 |
+
}
|
46 |
+
|
47 |
+
public function isIndividualFromBundleOrSimpleWithCustome()
|
48 |
+
{
|
49 |
+
if (!$this->getListingProduct()->getChildObject()->getVariationManager()->isIndividualType()) {
|
50 |
+
return false;
|
51 |
+
}
|
52 |
+
|
53 |
+
return $this->getListingProduct()->getMagentoProduct()->isBundleType() ||
|
54 |
+
$this->getListingProduct()->getMagentoProduct()->isSimpleTypeWithCustomOptions();
|
55 |
+
}
|
56 |
+
|
57 |
+
public function isParentFromBundleOrSimpleWithCustome()
|
58 |
+
{
|
59 |
+
if (!$this->getListingProduct()->getChildObject()->getVariationManager()->isRelationParentType()) {
|
60 |
+
return false;
|
61 |
+
}
|
62 |
+
|
63 |
+
return $this->getListingProduct()->getMagentoProduct()->isBundleType() ||
|
64 |
+
$this->getListingProduct()->getMagentoProduct()->isSimpleTypeWithCustomOptions();
|
65 |
+
}
|
66 |
+
|
67 |
+
public function __construct()
|
68 |
+
{
|
69 |
+
parent::__construct();
|
70 |
+
|
71 |
+
$this->setTemplate('M2ePro/common/amazon/listing/product_search/menu.phtml');
|
72 |
+
}
|
73 |
+
|
74 |
+
protected function _beforeToHtml()
|
75 |
+
{
|
76 |
+
//------------------------------
|
77 |
+
$data = array(
|
78 |
+
'id' => 'productSearchMenu_cancel_button',
|
79 |
+
'label' => Mage::helper('M2ePro')->__('Close'),
|
80 |
+
'class' => 'productSearchMenu_cancel_button'
|
81 |
+
);
|
82 |
+
$buttonCancelBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
83 |
+
$this->setChild('productSearchMenu_cancel_button', $buttonCancelBlock);
|
84 |
+
//------------------------------
|
85 |
+
|
86 |
+
parent::_beforeToHtml();
|
87 |
+
}
|
88 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/ProductSearch/SuggestedAsinGridHelp.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_ProductSearch_SuggestedAsinGridHelp
|
8 |
+
extends Mage_Adminhtml_Block_Widget
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
//------------------------------
|
16 |
+
$this->setId('amazonSuggestedAsinGridHelp');
|
17 |
+
//------------------------------
|
18 |
+
|
19 |
+
$this->setTemplate('M2ePro/common/amazon/listing/product_search/suggested_asin_grid_help.phtml');
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Search.php
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Search extends Mage_Adminhtml_Block_Widget_Grid_Container
|
8 |
+
{
|
9 |
+
// ########################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('listingAmazonSearch');
|
18 |
+
$this->_blockGroup = 'M2ePro';
|
19 |
+
$this->_controller = 'adminhtml_common_amazon_listing_search';
|
20 |
+
//------------------------------
|
21 |
+
|
22 |
+
// Set header text
|
23 |
+
//------------------------------
|
24 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
25 |
+
$componentName = Mage::helper('M2ePro/Component_Amazon')->getTitle();
|
26 |
+
$headerText = Mage::helper('M2ePro')->__("Search %component_name% Listings Items", $componentName);
|
27 |
+
} else {
|
28 |
+
$headerText = Mage::helper('M2ePro')->__("Search Listings Items");
|
29 |
+
}
|
30 |
+
|
31 |
+
$this->_headerText = $headerText;
|
32 |
+
//------------------------------
|
33 |
+
|
34 |
+
// Set buttons actions
|
35 |
+
//------------------------------
|
36 |
+
$this->removeButton('back');
|
37 |
+
$this->removeButton('reset');
|
38 |
+
$this->removeButton('delete');
|
39 |
+
$this->removeButton('add');
|
40 |
+
$this->removeButton('save');
|
41 |
+
$this->removeButton('edit');
|
42 |
+
//------------------------------
|
43 |
+
|
44 |
+
if (!is_null($this->getRequest()->getParam('back'))) {
|
45 |
+
//------------------------------
|
46 |
+
$url = Mage::helper('M2ePro')->getBackUrl('*/adminhtml_common_amazon_listing/search');
|
47 |
+
$this->_addButton('back', array(
|
48 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
49 |
+
'onclick' => 'CommonHandlerObj.back_click(\'' . $url . '\')',
|
50 |
+
'class' => 'back'
|
51 |
+
));
|
52 |
+
//------------------------------
|
53 |
+
}
|
54 |
+
|
55 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_amazon_listing/search');
|
56 |
+
|
57 |
+
//------------------------------
|
58 |
+
$url = $this->getUrl(
|
59 |
+
'*/adminhtml_common_listing/index',
|
60 |
+
array(
|
61 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON,
|
62 |
+
'back'=> $backUrl
|
63 |
+
)
|
64 |
+
);
|
65 |
+
$this->_addButton('goto_listings', array(
|
66 |
+
'label' => Mage::helper('M2ePro')->__('Listings'),
|
67 |
+
'onclick' => 'setLocation(\'' . $url . '\')',
|
68 |
+
'class' => 'button_link'
|
69 |
+
));
|
70 |
+
//------------------------------
|
71 |
+
|
72 |
+
//------------------------------
|
73 |
+
$this->_addButton('goto_templates', array(
|
74 |
+
'label' => Mage::helper('M2ePro')->__('Policies'),
|
75 |
+
'onclick' => '',
|
76 |
+
'class' => 'button_link drop_down templates-drop-down'
|
77 |
+
));
|
78 |
+
//------------------------------
|
79 |
+
|
80 |
+
//------------------------------
|
81 |
+
$url = $this->getUrl(
|
82 |
+
'*/adminhtml_common_log/listing',
|
83 |
+
array(
|
84 |
+
'channel' => Ess_M2ePro_Block_Adminhtml_Common_Log_Tabs::TAB_ID_AMAZON
|
85 |
+
)
|
86 |
+
);
|
87 |
+
$this->_addButton('view_log', array(
|
88 |
+
'label' => Mage::helper('M2ePro')->__('View Log'),
|
89 |
+
'onclick' => 'window.open(\'' . $url . '\')',
|
90 |
+
'class' => 'button_link'
|
91 |
+
));
|
92 |
+
//------------------------------
|
93 |
+
}
|
94 |
+
|
95 |
+
// ########################################
|
96 |
+
|
97 |
+
protected function _toHtml()
|
98 |
+
{
|
99 |
+
return $this->getTemplatesButtonJavascript() . parent::_toHtml();
|
100 |
+
}
|
101 |
+
|
102 |
+
public function getGridHtml()
|
103 |
+
{
|
104 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_listing_search_help');
|
105 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
106 |
+
}
|
107 |
+
|
108 |
+
// ########################################
|
109 |
+
|
110 |
+
protected function getTemplatesButtonJavascript()
|
111 |
+
{
|
112 |
+
$data = array(
|
113 |
+
'target_css_class' => 'templates-drop-down',
|
114 |
+
'items' => $this->getTemplatesButtonDropDownItems()
|
115 |
+
);
|
116 |
+
$dropDownBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_button_dropDown');
|
117 |
+
$dropDownBlock->setData($data);
|
118 |
+
|
119 |
+
return $dropDownBlock->toHtml();
|
120 |
+
}
|
121 |
+
|
122 |
+
protected function getTemplatesButtonDropDownItems()
|
123 |
+
{
|
124 |
+
$items = array();
|
125 |
+
|
126 |
+
$filter = base64_encode('component_mode=' . Ess_M2ePro_Helper_Component_Amazon::NICK);
|
127 |
+
|
128 |
+
//------------------------------
|
129 |
+
$url = $this->getUrl('*/adminhtml_common_template_sellingFormat/index', array('filter' => $filter));
|
130 |
+
$items[] = array(
|
131 |
+
'url' => $url,
|
132 |
+
'label' => Mage::helper('M2ePro')->__('Selling Format Policies'),
|
133 |
+
'target' => '_blank'
|
134 |
+
);
|
135 |
+
//------------------------------
|
136 |
+
|
137 |
+
//------------------------------
|
138 |
+
$url = $this->getUrl('*/adminhtml_common_template_synchronization/index', array('filter' => $filter));
|
139 |
+
$items[] = array(
|
140 |
+
'url' => $url,
|
141 |
+
'label' => Mage::helper('M2ePro')->__('Synchronization Policies'),
|
142 |
+
'target' => '_blank'
|
143 |
+
);
|
144 |
+
//------------------------------
|
145 |
+
|
146 |
+
//------------------------------
|
147 |
+
$url = $this->getUrl(
|
148 |
+
'*/adminhtml_common_amazon_template_description/index'
|
149 |
+
);
|
150 |
+
$items[] = array(
|
151 |
+
'url' => $url,
|
152 |
+
'label' => Mage::helper('M2ePro')->__('Amazon Description Policies'),
|
153 |
+
'target' => '_blank'
|
154 |
+
);
|
155 |
+
//------------------------------
|
156 |
+
|
157 |
+
return $items;
|
158 |
+
}
|
159 |
+
|
160 |
+
// ########################################
|
161 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Search/Grid.php
ADDED
@@ -0,0 +1,531 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Search_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
// ####################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('amazonListingSearchGrid');
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
// Set default values
|
21 |
+
//------------------------------
|
22 |
+
$this->setDefaultSort('id');
|
23 |
+
$this->setDefaultDir('DESC');
|
24 |
+
$this->setSaveParametersInSession(true);
|
25 |
+
$this->setUseAjax(true);
|
26 |
+
//------------------------------
|
27 |
+
}
|
28 |
+
|
29 |
+
// ####################################
|
30 |
+
|
31 |
+
protected function _prepareCollection()
|
32 |
+
{
|
33 |
+
// Get collection products in listing
|
34 |
+
//--------------------------------
|
35 |
+
$collection = Mage::helper('M2ePro/Component_Amazon')->getCollection('Listing_Product');
|
36 |
+
$collection->getSelect()->distinct();
|
37 |
+
$collection->getSelect()
|
38 |
+
->join(array('l'=>Mage::getResourceModel('M2ePro/Listing')->getMainTable()),
|
39 |
+
'(`l`.`id` = `main_table`.`listing_id`)',
|
40 |
+
array('listing_title'=>'title','store_id','marketplace_id'))
|
41 |
+
->join(array('al'=>Mage::getResourceModel('M2ePro/Amazon_Listing')->getMainTable()),
|
42 |
+
'(`al`.`listing_id` = `l`.`id`)',
|
43 |
+
array('template_selling_format_id'));
|
44 |
+
//--------------------------------
|
45 |
+
|
46 |
+
// only parents and individuals
|
47 |
+
$collection->getSelect()->where('second_table.variation_parent_id IS NULL');
|
48 |
+
|
49 |
+
// Communicate with magento product table
|
50 |
+
//--------------------------------
|
51 |
+
$dbSelect = Mage::getResourceModel('core/config')->getReadConnection()
|
52 |
+
->select()
|
53 |
+
->from(Mage::getSingleton('core/resource')
|
54 |
+
->getTableName('catalog_product_entity_varchar'),
|
55 |
+
new Zend_Db_Expr('MAX(`store_id`)'))
|
56 |
+
->where("`entity_id` = `main_table`.`product_id`")
|
57 |
+
->where("`attribute_id` = `ea`.`attribute_id`")
|
58 |
+
->where("`store_id` = 0 OR `store_id` = `l`.`store_id`");
|
59 |
+
|
60 |
+
$collection->getSelect()
|
61 |
+
//->join(array('csi'=>Mage::getSingleton('core/resource')->getTableName('cataloginventory_stock_item')),
|
62 |
+
// '(csi.product_id = `main_table`.product_id)',array('qty'))
|
63 |
+
->join(array('cpe'=>Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')),
|
64 |
+
'(cpe.entity_id = `main_table`.product_id)',
|
65 |
+
array('magento_sku'=>'sku'))
|
66 |
+
->join(array('cisi'=>Mage::getSingleton('core/resource')
|
67 |
+
->getTableName('cataloginventory_stock_item')),
|
68 |
+
'(cisi.product_id = `main_table`.product_id AND cisi.stock_id = 1)',
|
69 |
+
array('is_in_stock'))
|
70 |
+
->join(array('cpev'=>Mage::getSingleton('core/resource')
|
71 |
+
->getTableName('catalog_product_entity_varchar')),
|
72 |
+
"(`cpev`.`entity_id` = `main_table`.product_id)",
|
73 |
+
array('value'))
|
74 |
+
->join(array('ea'=>Mage::getSingleton('core/resource')->getTableName('eav_attribute')),
|
75 |
+
'(`cpev`.`attribute_id` = `ea`.`attribute_id` AND `ea`.`attribute_code` = \'name\')',
|
76 |
+
array())
|
77 |
+
->where('`cpev`.`store_id` = ('.$dbSelect->__toString().')');
|
78 |
+
//--------------------------------
|
79 |
+
|
80 |
+
//exit($collection->getSelect()->__toString());
|
81 |
+
|
82 |
+
// Set collection to grid
|
83 |
+
$this->setCollection($collection);
|
84 |
+
|
85 |
+
return parent::_prepareCollection();
|
86 |
+
}
|
87 |
+
|
88 |
+
protected function _prepareColumns()
|
89 |
+
{
|
90 |
+
$this->addColumn('product_id', array(
|
91 |
+
'header' => Mage::helper('M2ePro')->__('Product ID'),
|
92 |
+
'align' => 'right',
|
93 |
+
'width' => '100px',
|
94 |
+
'type' => 'number',
|
95 |
+
'index' => 'product_id',
|
96 |
+
'filter_index' => 'main_table.product_id',
|
97 |
+
'frame_callback' => array($this, 'callbackColumnProductId')
|
98 |
+
));
|
99 |
+
|
100 |
+
$this->addColumn('name', array(
|
101 |
+
'header' => Mage::helper('M2ePro')->__('Product Title / Listing / Product SKU'),
|
102 |
+
'align' => 'left',
|
103 |
+
//'width' => '300px',
|
104 |
+
'type' => 'text',
|
105 |
+
'index' => 'value',
|
106 |
+
'filter_index' => 'cpev.value',
|
107 |
+
'frame_callback' => array($this, 'callbackColumnProductTitle'),
|
108 |
+
'filter_condition_callback' => array($this, 'callbackFilterTitle')
|
109 |
+
));
|
110 |
+
|
111 |
+
$this->addColumn('stock_availability',
|
112 |
+
array(
|
113 |
+
'header'=> Mage::helper('M2ePro')->__('Stock Availability'),
|
114 |
+
'width' => '100px',
|
115 |
+
'index' => 'is_in_stock',
|
116 |
+
'filter_index' => 'cisi.is_in_stock',
|
117 |
+
'type' => 'options',
|
118 |
+
'sortable' => false,
|
119 |
+
'options' => array(
|
120 |
+
1 => Mage::helper('M2ePro')->__('In Stock'),
|
121 |
+
0 => Mage::helper('M2ePro')->__('Out of Stock')
|
122 |
+
),
|
123 |
+
'frame_callback' => array($this, 'callbackColumnStockAvailability')
|
124 |
+
));
|
125 |
+
|
126 |
+
$this->addColumn('sku', array(
|
127 |
+
'header' => Mage::helper('M2ePro')->__('SKU'),
|
128 |
+
'align' => 'left',
|
129 |
+
'width' => '150px',
|
130 |
+
'type' => 'text',
|
131 |
+
'index' => 'sku',
|
132 |
+
'filter_index' => 'second_table.sku',
|
133 |
+
'frame_callback' => array($this, 'callbackColumnAmazonSku')
|
134 |
+
));
|
135 |
+
|
136 |
+
$this->addColumn('general_id', array(
|
137 |
+
'header' => Mage::helper('M2ePro')->__('ASIN / ISBN'),
|
138 |
+
'align' => 'left',
|
139 |
+
'width' => '90px',
|
140 |
+
'type' => 'text',
|
141 |
+
'index' => 'general_id',
|
142 |
+
'filter_index' => 'second_table.general_id',
|
143 |
+
'frame_callback' => array($this, 'callbackColumnGeneralId')
|
144 |
+
));
|
145 |
+
|
146 |
+
$this->addColumn('online_qty', array(
|
147 |
+
'header' => Mage::helper('M2ePro')->__('QTY'),
|
148 |
+
'align' => 'right',
|
149 |
+
'width' => '70px',
|
150 |
+
'type' => 'number',
|
151 |
+
'index' => 'online_qty',
|
152 |
+
'filter_index' => 'second_table.online_qty',
|
153 |
+
'frame_callback' => array($this, 'callbackColumnAvailableQty')
|
154 |
+
));
|
155 |
+
|
156 |
+
$this->addColumn('online_price', array(
|
157 |
+
'header' => Mage::helper('M2ePro')->__('Price'),
|
158 |
+
'align' => 'right',
|
159 |
+
'width' => '70px',
|
160 |
+
'type' => 'number',
|
161 |
+
'index' => 'online_price',
|
162 |
+
'filter_index' => 'second_table.online_price',
|
163 |
+
'frame_callback' => array($this, 'callbackColumnPrice')
|
164 |
+
));
|
165 |
+
|
166 |
+
$this->addColumn('is_afn_channel', array(
|
167 |
+
'header' => Mage::helper('M2ePro')->__('Fulfillment'),
|
168 |
+
'width' => '90px',
|
169 |
+
'index' => 'is_afn_channel',
|
170 |
+
'filter_index' => 'second_table.is_afn_channel',
|
171 |
+
'type' => 'options',
|
172 |
+
'sortable' => false,
|
173 |
+
'options' => array(
|
174 |
+
0 => Mage::helper('M2ePro')->__('Merchant'),
|
175 |
+
1 => Mage::helper('M2ePro')->__('Amazon')
|
176 |
+
),
|
177 |
+
'frame_callback' => array($this, 'callbackColumnAfnChannel')
|
178 |
+
));
|
179 |
+
|
180 |
+
$this->addColumn('status', array(
|
181 |
+
'header' => Mage::helper('M2ePro')->__('Status'),
|
182 |
+
'width' => '125px',
|
183 |
+
'index' => 'status',
|
184 |
+
'filter_index' => 'main_table.status',
|
185 |
+
'type' => 'options',
|
186 |
+
'sortable' => false,
|
187 |
+
'options' => array(
|
188 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_UNKNOWN => Mage::helper('M2ePro')->__('Unknown'),
|
189 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED => Mage::helper('M2ePro')->__('Not Listed'),
|
190 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_LISTED => Mage::helper('M2ePro')->__('Active'),
|
191 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED => Mage::helper('M2ePro')->__('Inactive'),
|
192 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_BLOCKED => Mage::helper('M2ePro')->__('Inactive (Blocked)')
|
193 |
+
),
|
194 |
+
'frame_callback' => array($this, 'callbackColumnStatus')
|
195 |
+
));
|
196 |
+
|
197 |
+
$this->addColumn('goto_listing_item', array(
|
198 |
+
'header' => Mage::helper('M2ePro')->__('Manage'),
|
199 |
+
'align' => 'center',
|
200 |
+
'width' => '50px',
|
201 |
+
'type' => 'text',
|
202 |
+
'filter' => false,
|
203 |
+
'sortable' => false,
|
204 |
+
'frame_callback' => array($this, 'callbackColumnActions')
|
205 |
+
));
|
206 |
+
|
207 |
+
return parent::_prepareColumns();
|
208 |
+
}
|
209 |
+
|
210 |
+
// ####################################
|
211 |
+
|
212 |
+
public function callbackColumnProductId($value, $row, $column, $isExport)
|
213 |
+
{
|
214 |
+
$productId = (int)$row->getData('product_id');
|
215 |
+
$storeId = (int)$row->getData('store_id');
|
216 |
+
|
217 |
+
$withoutImageHtml = '<a href="'
|
218 |
+
.$this->getUrl('adminhtml/catalog_product/edit',
|
219 |
+
array('id' => $productId))
|
220 |
+
.'" target="_blank">'
|
221 |
+
.$productId
|
222 |
+
.'</a>';
|
223 |
+
|
224 |
+
$showProductsThumbnails = (bool)(int)Mage::helper('M2ePro/Module')->getConfig()
|
225 |
+
->getGroupValue('/view/',
|
226 |
+
'show_products_thumbnails');
|
227 |
+
if (!$showProductsThumbnails) {
|
228 |
+
return $withoutImageHtml;
|
229 |
+
}
|
230 |
+
|
231 |
+
/** @var $magentoProduct Ess_M2ePro_Model_Magento_Product */
|
232 |
+
$magentoProduct = Mage::getModel('M2ePro/Magento_Product');
|
233 |
+
$magentoProduct->setProductId($productId);
|
234 |
+
$magentoProduct->setStoreId($storeId);
|
235 |
+
|
236 |
+
$imageUrlResized = $magentoProduct->getThumbnailImageLink();
|
237 |
+
if (is_null($imageUrlResized)) {
|
238 |
+
return $withoutImageHtml;
|
239 |
+
}
|
240 |
+
|
241 |
+
$imageHtml = $productId.'<hr/><img src="'.$imageUrlResized.'" />';
|
242 |
+
$withImageHtml = str_replace('>'.$productId.'<','>'.$imageHtml.'<',$withoutImageHtml);
|
243 |
+
|
244 |
+
return $withImageHtml;
|
245 |
+
}
|
246 |
+
|
247 |
+
public function callbackColumnProductTitle($value, $row, $column, $isExport)
|
248 |
+
{
|
249 |
+
$value = '<span>'.Mage::helper('M2ePro')->escapeHtml($value).'</span>';
|
250 |
+
|
251 |
+
$urlParams = array();
|
252 |
+
$urlParams['id'] = $row->getData('listing_id');
|
253 |
+
$urlParams['back'] = Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_amazon_listing/search');
|
254 |
+
|
255 |
+
$listingUrl = $this->getUrl('*/adminhtml_common_amazon_listing/view',$urlParams);
|
256 |
+
$listingTitle = Mage::helper('M2ePro')->escapeHtml($row->getData('listing_title'));
|
257 |
+
|
258 |
+
if (strlen($listingTitle) > 50) {
|
259 |
+
$listingTitle = substr($listingTitle, 0, 50) . '...';
|
260 |
+
}
|
261 |
+
|
262 |
+
$value .= '<br/><hr style="border:none; border-top:1px solid silver; margin: 2px 0px;"/>';
|
263 |
+
$value .= '<strong>'
|
264 |
+
.Mage::helper('M2ePro')->__('Listing')
|
265 |
+
.': </strong> <a href="'
|
266 |
+
.$listingUrl
|
267 |
+
.'">'
|
268 |
+
.$listingTitle
|
269 |
+
.'</a>';
|
270 |
+
|
271 |
+
$tempSku = $row->getData('magento_sku');
|
272 |
+
is_null($tempSku)
|
273 |
+
&& $tempSku = Mage::getModel('M2ePro/Magento_Product')->setProductId($row->getData('product_id'))->getSku();
|
274 |
+
|
275 |
+
$value .= '<br/><strong>'
|
276 |
+
.Mage::helper('M2ePro')->__('SKU')
|
277 |
+
.':</strong> '
|
278 |
+
.Mage::helper('M2ePro')->escapeHtml($tempSku);
|
279 |
+
|
280 |
+
if ($row->getChildObject()->getVariationManager()->isVariationParent()) {
|
281 |
+
$productOptions = $row->getChildObject()->getVariationManager()
|
282 |
+
->getTypeModel()->getProductAttributes();
|
283 |
+
|
284 |
+
$value .= '<div style="font-size: 11px; font-weight: bold; color: grey;"><br/>';
|
285 |
+
$value .= implode(', ', $productOptions);
|
286 |
+
$value .= '</div>';
|
287 |
+
}
|
288 |
+
|
289 |
+
if ($row->getChildObject()->getVariationManager()->isIndividualType() &&
|
290 |
+
$row->getChildObject()->getVariationManager()->getTypeModel()->isVariationProductMatched()
|
291 |
+
) {
|
292 |
+
$productOptions = $row->getChildObject()->getVariationManager()->getTypeModel()->getProductOptions();
|
293 |
+
|
294 |
+
$value .= '<br/>';
|
295 |
+
$value .= '<div style="font-size: 11px; color: grey;"><br/>';
|
296 |
+
foreach ($productOptions as $attribute => $option) {
|
297 |
+
!$option && $option = '--';
|
298 |
+
$value .= '<strong>' . Mage::helper('M2ePro')->escapeHtml($attribute) .
|
299 |
+
'</strong>: ' . Mage::helper('M2ePro')->escapeHtml($option) . '<br/>';
|
300 |
+
}
|
301 |
+
$value .= '</div>';
|
302 |
+
$value .= '<br/>';
|
303 |
+
}
|
304 |
+
|
305 |
+
return $value;
|
306 |
+
}
|
307 |
+
|
308 |
+
public function callbackColumnStockAvailability($value, $row, $column, $isExport)
|
309 |
+
{
|
310 |
+
if ((int)$row->getData('is_in_stock') <= 0) {
|
311 |
+
return '<span style="color: red;">'.$value.'</span>';
|
312 |
+
}
|
313 |
+
|
314 |
+
return $value;
|
315 |
+
}
|
316 |
+
|
317 |
+
public function callbackColumnAmazonSku($value, $row, $column, $isExport)
|
318 |
+
{
|
319 |
+
if (is_null($value) || $value === '') {
|
320 |
+
return Mage::helper('M2ePro')->__('N/A');
|
321 |
+
}
|
322 |
+
return $value;
|
323 |
+
}
|
324 |
+
|
325 |
+
public function callbackColumnGeneralId($value, $row, $column, $isExport)
|
326 |
+
{
|
327 |
+
if ((int)$row->getData('status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
328 |
+
if (is_null($value) || $value === '') {
|
329 |
+
return Mage::helper('M2ePro')->__('N/A');
|
330 |
+
}
|
331 |
+
} else {
|
332 |
+
if (is_null($value) || $value === '') {
|
333 |
+
return '<i style="color:gray;">receiving...</i>';
|
334 |
+
}
|
335 |
+
}
|
336 |
+
|
337 |
+
$url = Mage::helper('M2ePro/Component_Amazon')->getItemUrl($value, $row->getData('marketplace_id'));
|
338 |
+
|
339 |
+
return '<a href="'.$url.'" target="_blank">'.$value.'</a>';
|
340 |
+
}
|
341 |
+
|
342 |
+
public function callbackColumnAvailableQty($value, $row, $column, $isExport)
|
343 |
+
{
|
344 |
+
if ((int)$row->getData('status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
345 |
+
if (is_null($value) || $value === '') {
|
346 |
+
return Mage::helper('M2ePro')->__('N/A');
|
347 |
+
}
|
348 |
+
} else {
|
349 |
+
if (is_null($value) || $value === '') {
|
350 |
+
return '<i style="color:gray;">receiving...</i>';
|
351 |
+
}
|
352 |
+
}
|
353 |
+
|
354 |
+
if ((bool)$row->getData('is_afn_channel')) {
|
355 |
+
return '--';
|
356 |
+
}
|
357 |
+
|
358 |
+
if ($value <= 0) {
|
359 |
+
return '<span style="color: red;">0</span>';
|
360 |
+
}
|
361 |
+
|
362 |
+
return $value;
|
363 |
+
}
|
364 |
+
|
365 |
+
public function callbackColumnPrice($value, $row, $column, $isExport)
|
366 |
+
{
|
367 |
+
if ((int)$row->getData('status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
368 |
+
if (is_null($value) || $value === '') {
|
369 |
+
return Mage::helper('M2ePro')->__('N/A');
|
370 |
+
}
|
371 |
+
} else {
|
372 |
+
if (is_null($value) || $value === '') {
|
373 |
+
return '<i style="color:gray;">receiving...</i>';
|
374 |
+
}
|
375 |
+
}
|
376 |
+
|
377 |
+
if ((float)$value <= 0) {
|
378 |
+
return '<span style="color: #f00;">0</span>';
|
379 |
+
}
|
380 |
+
|
381 |
+
$marketplaceId = Mage::helper('M2ePro/Component_Amazon')
|
382 |
+
->getCachedObject('Listing',
|
383 |
+
$row->getData('listing_id'), NULL,
|
384 |
+
array('listing'))
|
385 |
+
->getMarketplaceId();
|
386 |
+
|
387 |
+
$currency = Mage::helper('M2ePro/Component_Amazon')
|
388 |
+
->getCachedObject('Marketplace',$marketplaceId)
|
389 |
+
->getChildObject()
|
390 |
+
->getDefaultCurrency();
|
391 |
+
|
392 |
+
$value = Mage::app()->getLocale()->currency($currency)->toCurrency($value);
|
393 |
+
|
394 |
+
$salePriceValue = $row->getData('online_sale_price');
|
395 |
+
if (!is_null($salePriceValue) &&
|
396 |
+
(float)$salePriceValue > 0) {
|
397 |
+
$salePriceValue = Mage::app()->getLocale()->currency($currency)->toCurrency($salePriceValue);
|
398 |
+
$value .= '<br/><span style="color:gray;">'.$salePriceValue.'</span>';
|
399 |
+
}
|
400 |
+
|
401 |
+
return $value;
|
402 |
+
}
|
403 |
+
|
404 |
+
public function callbackColumnAfnChannel($value, $row, $column, $isExport)
|
405 |
+
{
|
406 |
+
if (is_null($value) || $value === '') {
|
407 |
+
return Mage::helper('M2ePro')->__('N/A');
|
408 |
+
}
|
409 |
+
|
410 |
+
switch ($row->getData('is_afn_channel')) {
|
411 |
+
case Ess_M2ePro_Model_Amazon_Listing_Product::IS_ISBN_GENERAL_ID_YES:
|
412 |
+
$value = '<span style="font-weight: bold;">' . $value . '</span>';
|
413 |
+
break;
|
414 |
+
|
415 |
+
default:
|
416 |
+
break;
|
417 |
+
}
|
418 |
+
|
419 |
+
return $value;
|
420 |
+
}
|
421 |
+
|
422 |
+
public function callbackColumnStatus($value, $row, $column, $isExport)
|
423 |
+
{
|
424 |
+
switch ($row->getData('status')) {
|
425 |
+
|
426 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_UNKNOWN:
|
427 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED:
|
428 |
+
$value = '<span style="color: gray;">' . $value . '</span>';
|
429 |
+
break;
|
430 |
+
|
431 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_LISTED:
|
432 |
+
$value = '<span style="color: green;">' . $value . '</span>';
|
433 |
+
break;
|
434 |
+
|
435 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED:
|
436 |
+
$value = '<span style="color: red;">'.$value.'</span>';
|
437 |
+
break;
|
438 |
+
|
439 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_BLOCKED:
|
440 |
+
$value = '<span style="color: orange; font-weight: bold;">'.$value.'</span>';
|
441 |
+
break;
|
442 |
+
|
443 |
+
default:
|
444 |
+
break;
|
445 |
+
}
|
446 |
+
|
447 |
+
$tempLocks = $row->getObjectLocks();
|
448 |
+
|
449 |
+
foreach ($tempLocks as $lock) {
|
450 |
+
|
451 |
+
switch ($lock->getTag()) {
|
452 |
+
|
453 |
+
case 'list_action':
|
454 |
+
$value .= '<br/><span style="color: #605fff">[List in Progress...]</span>';
|
455 |
+
break;
|
456 |
+
|
457 |
+
case 'relist_action':
|
458 |
+
$value .= '<br/><span style="color: #605fff">[Relist in Progress...]</span>';
|
459 |
+
break;
|
460 |
+
|
461 |
+
case 'revise_action':
|
462 |
+
$value .= '<br/><span style="color: #605fff">[Revise in Progress...]</span>';
|
463 |
+
break;
|
464 |
+
|
465 |
+
case 'stop_action':
|
466 |
+
$value .= '<br/><span style="color: #605fff">[Stop in Progress...]</span>';
|
467 |
+
break;
|
468 |
+
|
469 |
+
case 'stop_and_remove_action':
|
470 |
+
$value .= '<br/><span style="color: #605fff">[Stop And Remove in Progress...]</span>';
|
471 |
+
break;
|
472 |
+
|
473 |
+
case 'delete_and_remove_action':
|
474 |
+
$value .= '<br/><span style="color: #605fff">[Remove in Progress...]</span>';
|
475 |
+
break;
|
476 |
+
|
477 |
+
default:
|
478 |
+
break;
|
479 |
+
|
480 |
+
}
|
481 |
+
}
|
482 |
+
|
483 |
+
return $value;
|
484 |
+
}
|
485 |
+
|
486 |
+
public function callbackColumnActions($value, $row, $column, $isExport)
|
487 |
+
{
|
488 |
+
$altTitle = Mage::helper('M2ePro')->escapeHtml(Mage::helper('M2ePro')->__('Go to Listing'));
|
489 |
+
$iconSrc = $this->getSkinUrl('M2ePro/images/goto_listing.png');
|
490 |
+
$url = $this->getUrl('*/adminhtml_common_amazon_listing/view/',array(
|
491 |
+
'id' => $row->getData('listing_id'),
|
492 |
+
'filter' => base64_encode(
|
493 |
+
'product_id[from]='.(int)$row->getData('product_id')
|
494 |
+
.'&product_id[to]='.(int)$row->getData('product_id')
|
495 |
+
)
|
496 |
+
));
|
497 |
+
|
498 |
+
$html = <<<HTML
|
499 |
+
<div style="float:right; margin:5px 15px 0 0;">
|
500 |
+
<a title="{$altTitle}" target="_blank" href="{$url}"><img src="{$iconSrc}" alt="{$altTitle}" /></a>
|
501 |
+
</div>
|
502 |
+
HTML;
|
503 |
+
|
504 |
+
return $html;
|
505 |
+
}
|
506 |
+
|
507 |
+
protected function callbackFilterTitle($collection, $column)
|
508 |
+
{
|
509 |
+
$value = $column->getFilter()->getValue();
|
510 |
+
|
511 |
+
if ($value == null) {
|
512 |
+
return;
|
513 |
+
}
|
514 |
+
|
515 |
+
$collection->getSelect()->where('cpev.value LIKE ? OR cpe.sku LIKE ? OR l.title LIKE ?', '%'.$value.'%');
|
516 |
+
}
|
517 |
+
|
518 |
+
// ####################################
|
519 |
+
|
520 |
+
public function getGridUrl()
|
521 |
+
{
|
522 |
+
return $this->getUrl('*/adminhtml_common_amazon_listing/searchGrid', array('_current'=>true));
|
523 |
+
}
|
524 |
+
|
525 |
+
public function getRowUrl($row)
|
526 |
+
{
|
527 |
+
return false;
|
528 |
+
}
|
529 |
+
|
530 |
+
// ####################################
|
531 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/TemplateDescription/Grid.php
ADDED
@@ -0,0 +1,416 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_TemplateDescription_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
protected $attributesSetsIds;
|
10 |
+
protected $marketplaceId;
|
11 |
+
protected $listingProduct;
|
12 |
+
protected $productsAttributesCountVariations;
|
13 |
+
|
14 |
+
protected $checkNewAsinAccepted = false;
|
15 |
+
protected $productsIds;
|
16 |
+
protected $mapToTemplateJsFn = 'ListingGridHandlerObj.templateDescriptionHandler.mapToTemplateDescription';
|
17 |
+
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @return string
|
22 |
+
*/
|
23 |
+
public function getMapToTemplateJsFn()
|
24 |
+
{
|
25 |
+
return $this->mapToTemplateJsFn;
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @param string $mapToTemplateLink
|
30 |
+
*/
|
31 |
+
public function setMapToTemplateJsFn($mapToTemplateLink)
|
32 |
+
{
|
33 |
+
$this->mapToTemplateJsFn = $mapToTemplateLink;
|
34 |
+
}
|
35 |
+
|
36 |
+
//------------------------------
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @param boolean $checkNewAsinAccepted
|
40 |
+
*/
|
41 |
+
public function setCheckNewAsinAccepted($checkNewAsinAccepted)
|
42 |
+
{
|
43 |
+
$this->checkNewAsinAccepted = $checkNewAsinAccepted;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @return boolean
|
48 |
+
*/
|
49 |
+
public function getCheckNewAsinAccepted()
|
50 |
+
{
|
51 |
+
return (bool) $this->checkNewAsinAccepted;
|
52 |
+
}
|
53 |
+
|
54 |
+
//------------------------------
|
55 |
+
|
56 |
+
/**
|
57 |
+
* @param mixed $productsIds
|
58 |
+
*/
|
59 |
+
public function setProductsIds($productsIds)
|
60 |
+
{
|
61 |
+
$this->productsIds = $productsIds;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* @return mixed
|
66 |
+
*/
|
67 |
+
public function getProductsIds()
|
68 |
+
{
|
69 |
+
return $this->productsIds;
|
70 |
+
}
|
71 |
+
|
72 |
+
//------------------------------
|
73 |
+
|
74 |
+
public function __construct()
|
75 |
+
{
|
76 |
+
parent::__construct();
|
77 |
+
|
78 |
+
$this->setId('amazonTemplateDescriptionGrid');
|
79 |
+
|
80 |
+
// Set default values
|
81 |
+
//------------------------------
|
82 |
+
$this->setFilterVisibility(false);
|
83 |
+
//$this->setPagerVisibility(false);
|
84 |
+
$this->setDefaultSort('id');
|
85 |
+
$this->setDefaultDir('ASC');
|
86 |
+
$this->setSaveParametersInSession(false);
|
87 |
+
$this->setUseAjax(true);
|
88 |
+
//------------------------------
|
89 |
+
}
|
90 |
+
|
91 |
+
//------------------------------
|
92 |
+
|
93 |
+
protected function _prepareCollection()
|
94 |
+
{
|
95 |
+
$this->setNoTemplatesText();
|
96 |
+
|
97 |
+
/** @var Ess_M2ePro_Model_Mysql4_Amazon_Template_Description_Collection $collection */
|
98 |
+
$collection = Mage::helper('M2ePro/Component_Amazon')->getCollection('Template_Description');
|
99 |
+
$collection->addFieldToFilter('marketplace_id', $this->getMarketplaceId());
|
100 |
+
|
101 |
+
$this->setCollection($collection);
|
102 |
+
|
103 |
+
return parent::_prepareCollection();
|
104 |
+
}
|
105 |
+
|
106 |
+
protected function _prepareColumns()
|
107 |
+
{
|
108 |
+
$this->addColumn('title', array(
|
109 |
+
'header' => Mage::helper('M2ePro')->__('Title'),
|
110 |
+
'align' => 'left',
|
111 |
+
'type' => 'text',
|
112 |
+
'index' => 'title',
|
113 |
+
'filter' => false,
|
114 |
+
'sortable' => false,
|
115 |
+
'frame_callback' => array($this, 'callbackColumnTitle')
|
116 |
+
));
|
117 |
+
|
118 |
+
$this->addColumn('status', array(
|
119 |
+
'header' => Mage::helper('M2ePro')->__('Status/Reason'),
|
120 |
+
'align' => 'left',
|
121 |
+
'type' => 'text',
|
122 |
+
'width' => '140px',
|
123 |
+
'index' => 'title',
|
124 |
+
'filter' => false,
|
125 |
+
'sortable' => false,
|
126 |
+
'frame_callback' => array($this, 'callbackColumnStatus')
|
127 |
+
));
|
128 |
+
|
129 |
+
$this->addColumn('action', array(
|
130 |
+
'header' => Mage::helper('M2ePro')->__('Action'),
|
131 |
+
'align' => 'left',
|
132 |
+
'type' => 'number',
|
133 |
+
'width' => '55px',
|
134 |
+
'index' => 'id',
|
135 |
+
'filter' => false,
|
136 |
+
'sortable' => false,
|
137 |
+
'frame_callback' => array($this, 'callbackColumnAction')
|
138 |
+
));
|
139 |
+
}
|
140 |
+
|
141 |
+
protected function _prepareLayout()
|
142 |
+
{
|
143 |
+
$this->setChild('refresh_button',
|
144 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
145 |
+
->setData(array(
|
146 |
+
'id' => 'description_template_refresh_btn',
|
147 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
148 |
+
'onclick' => $this->getJsObjectName().'.reload()'
|
149 |
+
))
|
150 |
+
);
|
151 |
+
|
152 |
+
return parent::_prepareLayout();
|
153 |
+
}
|
154 |
+
|
155 |
+
// ####################################
|
156 |
+
|
157 |
+
public function getRefreshButtonHtml()
|
158 |
+
{
|
159 |
+
return $this->getChildHtml('refresh_button');
|
160 |
+
}
|
161 |
+
|
162 |
+
// ####################################
|
163 |
+
|
164 |
+
public function getMainButtonsHtml()
|
165 |
+
{
|
166 |
+
return $this->getRefreshButtonHtml() . parent::getMainButtonsHtml();
|
167 |
+
}
|
168 |
+
|
169 |
+
// ####################################
|
170 |
+
|
171 |
+
public function callbackColumnTitle($value, $row, $column, $isExport)
|
172 |
+
{
|
173 |
+
$templateDescriptionEditUrl = $this->getUrl('*/adminhtml_common_amazon_template_description/edit', array(
|
174 |
+
'id' => $row->getData('id')
|
175 |
+
));
|
176 |
+
|
177 |
+
$title = Mage::helper('M2ePro')->escapeHtml($row->getData('title'));
|
178 |
+
|
179 |
+
$categoryWord = Mage::helper('M2ePro')->__('Category');
|
180 |
+
$categoryPath = !empty($row['category_path']) ? "{$row['category_path']} ({$row['browsenode_id']})"
|
181 |
+
: Mage::helper('M2ePro')->__('N/A');
|
182 |
+
|
183 |
+
return <<<HTML
|
184 |
+
<a target="_blank" href="{$templateDescriptionEditUrl}">{$title}</a>
|
185 |
+
<div>
|
186 |
+
<span style="font-weight: bold">{$categoryWord}</span>: <span style="color: #505050">{$categoryPath}</span><br/>
|
187 |
+
</div>
|
188 |
+
HTML;
|
189 |
+
|
190 |
+
}
|
191 |
+
|
192 |
+
public function callbackColumnStatus($value, $row, $column, $isExport)
|
193 |
+
{
|
194 |
+
if ($this->getCheckNewAsinAccepted()) {
|
195 |
+
if (!$row->getChildObject()->isNewAsinAccepted()) {
|
196 |
+
return '<span style="color: #808080;">' .
|
197 |
+
Mage::helper('M2ePro')->__('New ASIN/ISBN feature is disabled') . '</span>';
|
198 |
+
}
|
199 |
+
|
200 |
+
$productAttrCounts = $this->getProductAttributesCountVariations();
|
201 |
+
|
202 |
+
if (!empty($productAttrCounts)) {
|
203 |
+
$detailsModel = Mage::getModel('M2ePro/Amazon_Marketplace_Details');
|
204 |
+
$detailsModel->setMarketplaceId($this->getMarketplaceId());
|
205 |
+
$themes = $detailsModel->getVariationThemes($row->getProductDataNick());
|
206 |
+
|
207 |
+
if (empty($themes)) {
|
208 |
+
return '<span style="color: #808080;">' .
|
209 |
+
Mage::helper('M2ePro')->__(
|
210 |
+
'Selected Category doesn\'t support Variational Products'
|
211 |
+
) . '</span>';
|
212 |
+
}
|
213 |
+
|
214 |
+
$themeAttrCounts = array();
|
215 |
+
foreach ($themes as $theme) {
|
216 |
+
$themeAttrCounts[] = count($theme['attributes']);
|
217 |
+
}
|
218 |
+
|
219 |
+
if (count(array_intersect($productAttrCounts, $themeAttrCounts)) !== count($productAttrCounts)) {
|
220 |
+
return '<span style="color: #808080;">' .
|
221 |
+
Mage::helper('M2ePro')->__(
|
222 |
+
'This number of Variation Attributes cannot be used in chosen Category'
|
223 |
+
) . '</span>';
|
224 |
+
}
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
return '<span style="color: green;">' . Mage::helper('M2ePro')->__('Ready to be assigned') . '</span>';
|
229 |
+
}
|
230 |
+
|
231 |
+
public function callbackColumnAction($value, $row, $column, $isExport)
|
232 |
+
{
|
233 |
+
$assignText = Mage::helper('M2ePro')->__('Assign');
|
234 |
+
$mapToAsin = '';
|
235 |
+
|
236 |
+
if ($this->getCheckNewAsinAccepted()) {
|
237 |
+
if (!$row->getChildObject()->isNewAsinAccepted()) {
|
238 |
+
return '<span style="color: #808080;">' . $assignText . '</span>';
|
239 |
+
}
|
240 |
+
|
241 |
+
$productAttrCounts = $this->getProductAttributesCountVariations();
|
242 |
+
|
243 |
+
if (!empty($productAttrCounts)) {
|
244 |
+
$detailsModel = Mage::getModel('M2ePro/Amazon_Marketplace_Details');
|
245 |
+
$detailsModel->setMarketplaceId($this->getMarketplaceId());
|
246 |
+
$themes = $detailsModel->getVariationThemes($row->getProductDataNick());
|
247 |
+
|
248 |
+
if (empty($themes)) {
|
249 |
+
return '<span style="color: #808080;">' . $assignText . '</span>';
|
250 |
+
}
|
251 |
+
|
252 |
+
$themeAttrCounts = array();
|
253 |
+
foreach ($themes as $theme) {
|
254 |
+
$themeAttrCounts[] = count($theme['attributes']);
|
255 |
+
}
|
256 |
+
|
257 |
+
if (count(array_intersect($productAttrCounts, $themeAttrCounts)) !== count($productAttrCounts)) {
|
258 |
+
return '<span style="color: #808080;">' . $assignText . '</span>';
|
259 |
+
}
|
260 |
+
}
|
261 |
+
|
262 |
+
$mapToAsin = ',1';
|
263 |
+
}
|
264 |
+
|
265 |
+
return '<a href="javascript:void(0);"'
|
266 |
+
. 'onclick="' . $this->getMapToTemplateJsFn() . '(this, '
|
267 |
+
. $value . $mapToAsin .');">'.$assignText.'</a>';
|
268 |
+
}
|
269 |
+
|
270 |
+
// ####################################
|
271 |
+
|
272 |
+
protected function _toHtml()
|
273 |
+
{
|
274 |
+
$javascriptsMain = <<<JAVASCRIPT
|
275 |
+
<script type="text/javascript">
|
276 |
+
|
277 |
+
$$('#amazonTemplateDescriptionGrid div.grid th').each(function(el){
|
278 |
+
el.style.padding = '5px 5px';
|
279 |
+
});
|
280 |
+
|
281 |
+
$$('#amazonTemplateDescriptionGrid div.grid td').each(function(el){
|
282 |
+
el.style.padding = '5px 5px';
|
283 |
+
});
|
284 |
+
|
285 |
+
</script>
|
286 |
+
JAVASCRIPT;
|
287 |
+
|
288 |
+
//------------------------------
|
289 |
+
$templateDescriptionNewUrl = $this->getNewTemplateDescriptionUrl();
|
290 |
+
|
291 |
+
$data = array(
|
292 |
+
'id' => 'templateDescription_addNew_button',
|
293 |
+
'label' => Mage::helper('M2ePro')->__('Add New Description Policy'),
|
294 |
+
'class' => 'templateDescription_addNew_button',
|
295 |
+
'style' => 'float: right;',
|
296 |
+
'onclick' => 'ListingGridHandlerObj.templateDescriptionHandler'
|
297 |
+
. '.createTemplateDescriptionInNewTab(\'' . $templateDescriptionNewUrl . '\')'
|
298 |
+
);
|
299 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
300 |
+
//------------------------------
|
301 |
+
|
302 |
+
$buttonBlockHtml = ($this->canDisplayContainer()) ? $buttonBlock->toHtml(): '';
|
303 |
+
|
304 |
+
return parent::_toHtml() . $buttonBlockHtml . $javascriptsMain;
|
305 |
+
}
|
306 |
+
|
307 |
+
// ####################################
|
308 |
+
|
309 |
+
public function getGridUrl()
|
310 |
+
{
|
311 |
+
return $this->getUrl('*/*/viewTemplateDescriptionsGrid', array(
|
312 |
+
'_current' => true,
|
313 |
+
'_query' => array(
|
314 |
+
'products_ids' => $this->getProductsIds(),
|
315 |
+
'check_is_new_asin_accepted' => $this->getCheckNewAsinAccepted()
|
316 |
+
)
|
317 |
+
));
|
318 |
+
}
|
319 |
+
|
320 |
+
public function getRowUrl($row)
|
321 |
+
{
|
322 |
+
return false;
|
323 |
+
}
|
324 |
+
|
325 |
+
// ####################################
|
326 |
+
|
327 |
+
protected function getMarketplaceId()
|
328 |
+
{
|
329 |
+
if(empty($this->marketplaceId)) {
|
330 |
+
/** @var Ess_M2ePro_Model_Listing_Product $listingProduct */
|
331 |
+
$productsIds = $this->getProductsIds();
|
332 |
+
$listingProduct = Mage::helper('M2ePro/Component_Amazon')->getObject('Listing_Product', $productsIds[0]);
|
333 |
+
$this->marketplaceId = $listingProduct->getListing()->getMarketplaceId();
|
334 |
+
}
|
335 |
+
|
336 |
+
return $this->marketplaceId;
|
337 |
+
}
|
338 |
+
|
339 |
+
//---------------------------------------
|
340 |
+
|
341 |
+
protected function setNoTemplatesText()
|
342 |
+
{
|
343 |
+
$templateDescriptionEditUrl = $this->getNewTemplateDescriptionUrl();
|
344 |
+
|
345 |
+
$messageTxt = Mage::helper('M2ePro')->__('Description Policies are not found for current Marketplace.');
|
346 |
+
$linkTitle = Mage::helper('M2ePro')->__('Create New Description Policy.');
|
347 |
+
|
348 |
+
$message = <<<HTML
|
349 |
+
<p>{$messageTxt} <a href="javascript:void(0);"
|
350 |
+
id="templateDescription_addNew_link"
|
351 |
+
onclick="ListingGridHandlerObj.templateDescriptionHandler.createTemplateDescriptionInNewTab(
|
352 |
+
'{$templateDescriptionEditUrl}');">{$linkTitle}</a>
|
353 |
+
</p>
|
354 |
+
HTML;
|
355 |
+
|
356 |
+
$this->setEmptyText($message);
|
357 |
+
}
|
358 |
+
|
359 |
+
protected function getNewTemplateDescriptionUrl()
|
360 |
+
{
|
361 |
+
return $this->getUrl('*/adminhtml_common_amazon_template_description/new', array(
|
362 |
+
'is_new_asin_accepted' => $this->getCheckNewAsinAccepted(),
|
363 |
+
'marketplace_id' => $this->getMarketplaceId()
|
364 |
+
));
|
365 |
+
}
|
366 |
+
|
367 |
+
//---------------------------------------
|
368 |
+
|
369 |
+
protected function getParentListingProduct()
|
370 |
+
{
|
371 |
+
$productIds = $this->getProductsIds();
|
372 |
+
if (count($productIds) == 1 && empty($this->listingProduct)) {
|
373 |
+
$listingProduct = Mage::helper('M2ePro/Component_Amazon')->getObject('Listing_Product', $productIds[0]);
|
374 |
+
if ($listingProduct->getChildObject()->getVariationManager()->isVariationParent()) {
|
375 |
+
$this->listingProduct = $listingProduct;
|
376 |
+
}
|
377 |
+
}
|
378 |
+
return $this->listingProduct;
|
379 |
+
}
|
380 |
+
|
381 |
+
//---------------------------------------
|
382 |
+
|
383 |
+
protected function getProductAttributesCountVariations()
|
384 |
+
{
|
385 |
+
if (is_null($this->productsAttributesCountVariations)) {
|
386 |
+
$this->productsAttributesCountVariations = array();
|
387 |
+
|
388 |
+
/** @var Ess_M2ePro_Model_Mysql4_Amazon_Listing_Product_Collection $collection */
|
389 |
+
$collection = Mage::getModel('M2ePro/Listing_Product')->getCollection();
|
390 |
+
$collection->addFieldToFilter('component_mode', Ess_M2ePro_Helper_Component_Amazon::NICK);
|
391 |
+
$collection->addFieldToFilter('additional_data', array('notnull' => true));
|
392 |
+
$collection->addFieldToFilter('id', array('in' => $this->getProductsIds()));
|
393 |
+
$collection->addFieldToSelect('additional_data');
|
394 |
+
|
395 |
+
$collection->join(
|
396 |
+
array('alp' => 'M2ePro/Amazon_Listing_Product'),
|
397 |
+
'listing_product_id=id',
|
398 |
+
null
|
399 |
+
);
|
400 |
+
$collection->addFieldToFilter('is_variation_parent', 1);
|
401 |
+
|
402 |
+
foreach ($collection->getData() as $row) {
|
403 |
+
$data = json_decode($row['additional_data'], true);
|
404 |
+
|
405 |
+
$count = count($data['variation_product_attributes']);
|
406 |
+
if (!in_array($count, $this->productsAttributesCountVariations)) {
|
407 |
+
$this->productsAttributesCountVariations[] = $count;
|
408 |
+
}
|
409 |
+
}
|
410 |
+
}
|
411 |
+
|
412 |
+
return $this->productsAttributesCountVariations;
|
413 |
+
}
|
414 |
+
|
415 |
+
//---------------------------------------
|
416 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/TemplateDescription/Main.php
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_TemplateDescription_Main
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Container
|
9 |
+
{
|
10 |
+
|
11 |
+
protected $newAsin = false;
|
12 |
+
protected $messages = array();
|
13 |
+
/**
|
14 |
+
* @param array $messages
|
15 |
+
*/
|
16 |
+
public function setMessages($messages)
|
17 |
+
{
|
18 |
+
$this->messages = $messages;
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return array
|
23 |
+
*/
|
24 |
+
public function getMessages()
|
25 |
+
{
|
26 |
+
return $this->messages;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @return boolean
|
31 |
+
*/
|
32 |
+
public function isNewAsin()
|
33 |
+
{
|
34 |
+
return $this->newAsin;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @param boolean $newAsin
|
39 |
+
*/
|
40 |
+
public function setNewAsin($newAsin)
|
41 |
+
{
|
42 |
+
$this->newAsin = $newAsin;
|
43 |
+
}
|
44 |
+
|
45 |
+
public function __construct()
|
46 |
+
{
|
47 |
+
parent::__construct();
|
48 |
+
|
49 |
+
$this->setTemplate('M2ePro/common/amazon/listing/template_description/main.phtml');
|
50 |
+
}
|
51 |
+
|
52 |
+
public function getWarnings()
|
53 |
+
{
|
54 |
+
$warnings = '';
|
55 |
+
foreach ($this->getMessages() as $message) {
|
56 |
+
$warnings .= <<<HTML
|
57 |
+
<ul class="messages">
|
58 |
+
<li class="{$message['type']}-msg">
|
59 |
+
<ul>
|
60 |
+
<li>{$message['text']}</li>
|
61 |
+
</ul>
|
62 |
+
</li>
|
63 |
+
</ul>
|
64 |
+
HTML;
|
65 |
+
}
|
66 |
+
return $warnings;
|
67 |
+
}
|
68 |
+
|
69 |
+
public function getReasonMessage()
|
70 |
+
{
|
71 |
+
if ($this->isNewAsin()) {
|
72 |
+
return Mage::helper('M2ePro')->__(
|
73 |
+
'For all Products the Description Policies can be <i class="underline">Assigned</i> from the list below.
|
74 |
+
<br/><br/><b>Note:</b> List of Description Policies available for assigning depends on the
|
75 |
+
combination of the chosen Products.');
|
76 |
+
}
|
77 |
+
return Mage::helper('M2ePro')->__('Please select Description Policy.');
|
78 |
+
}
|
79 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Variation/Product/Manage/Tabs.php
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2014 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Variation_Product_Manage_Tabs
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Tabs
|
9 |
+
{
|
10 |
+
protected $listingProductId;
|
11 |
+
/**
|
12 |
+
* @param mixed $listingProductId
|
13 |
+
*/
|
14 |
+
public function setListingProductId($listingProductId)
|
15 |
+
{
|
16 |
+
$this->listingProductId = $listingProductId;
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @return mixed
|
21 |
+
*/
|
22 |
+
public function getListingProductId()
|
23 |
+
{
|
24 |
+
return $this->listingProductId;
|
25 |
+
}
|
26 |
+
|
27 |
+
//------------------------------
|
28 |
+
|
29 |
+
/** @var Ess_M2ePro_Model_Listing_Product $listingProduct */
|
30 |
+
protected $listingProduct;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @return Ess_M2ePro_Model_Listing_Product|null
|
34 |
+
*/
|
35 |
+
public function getListingProduct()
|
36 |
+
{
|
37 |
+
if(empty($this->listingProduct)) {
|
38 |
+
$this->listingProduct = Mage::helper('M2ePro/Component_Amazon')
|
39 |
+
->getObject('Listing_Product', $this->getListingProductId());
|
40 |
+
}
|
41 |
+
|
42 |
+
return $this->listingProduct;
|
43 |
+
}
|
44 |
+
|
45 |
+
//------------------------------
|
46 |
+
|
47 |
+
public function __construct()
|
48 |
+
{
|
49 |
+
parent::__construct();
|
50 |
+
|
51 |
+
// Initialization block
|
52 |
+
//------------------------------
|
53 |
+
$this->setId('amazonVariationProductManageTabs');
|
54 |
+
//------------------------------
|
55 |
+
|
56 |
+
$this->setTemplate('widget/tabshoriz.phtml');
|
57 |
+
$this->setDestElementId('variation_product_manage_tabs_container');
|
58 |
+
}
|
59 |
+
|
60 |
+
//------------------------------
|
61 |
+
|
62 |
+
protected function _beforeToHtml()
|
63 |
+
{
|
64 |
+
$this->addTab('variations', array(
|
65 |
+
'label' => Mage::helper('M2ePro')->__('Child Products'),
|
66 |
+
'title' => Mage::helper('M2ePro')->__('Child Products'),
|
67 |
+
'content' => $this->getLayout()
|
68 |
+
->createBlock('M2ePro/adminhtml_common_amazon_listing_variation_product_manage_tabs_variations')
|
69 |
+
->setListingProductId($this->getListingProductId())
|
70 |
+
->toHtml()
|
71 |
+
));
|
72 |
+
|
73 |
+
$settingsBlock = $this->getLayout()
|
74 |
+
->createBlock('M2ePro/adminhtml_common_amazon_listing_variation_product_manage_tabs_settings')
|
75 |
+
->setListingProductId($this->getListingProductId());
|
76 |
+
$settingsBlock->calculateWarnings();
|
77 |
+
|
78 |
+
$settingsBlockLabel = Mage::helper('M2ePro')->__('Settings');
|
79 |
+
$settingsBlockTitle = Mage::helper('M2ePro')->__('Settings');
|
80 |
+
|
81 |
+
if(count($settingsBlock->getMessages()) > 0) {
|
82 |
+
$iconPath = $this->getSkinUrl('M2ePro/images/'. $settingsBlock->getMessagesType() .'.png');
|
83 |
+
$problemIcon = '<img style="vertical-align: middle;" src="'
|
84 |
+
. $iconPath . '" alt="" width="16" height="15"> ';
|
85 |
+
$settingsBlockLabel = $problemIcon.$settingsBlockLabel;
|
86 |
+
$settingsBlockTitle = Mage::helper('M2ePro')->__(
|
87 |
+
'Action required.'
|
88 |
+
);
|
89 |
+
}
|
90 |
+
|
91 |
+
$this->addTab('settings', array(
|
92 |
+
'label' => $settingsBlockLabel,
|
93 |
+
'title' => $settingsBlockTitle,
|
94 |
+
'content' => $this->getLayout()
|
95 |
+
->createBlock('M2ePro/adminhtml_common_amazon_listing_variation_product_manage_tabs_settings')
|
96 |
+
->setListingProductId($this->getListingProductId())
|
97 |
+
->toHtml()
|
98 |
+
));
|
99 |
+
|
100 |
+
$generalId = $this->getListingProduct()->getChildObject()->getGeneralId();
|
101 |
+
if(empty($generalId) && $this->getListingProduct()->getChildObject()->isGeneralIdOwner()) {
|
102 |
+
$this->setActiveTab('settings');
|
103 |
+
} else {
|
104 |
+
$this->setActiveTab('variations');
|
105 |
+
}
|
106 |
+
|
107 |
+
return parent::_beforeToHtml();
|
108 |
+
}
|
109 |
+
|
110 |
+
protected function _toHtml()
|
111 |
+
{
|
112 |
+
$generalId = $this->getListingProduct()->getChildObject()->getGeneralId();
|
113 |
+
|
114 |
+
$showMask = 0;
|
115 |
+
if(!(empty($generalId) && $this->getListingProduct()->getChildObject()->isGeneralIdOwner())) {
|
116 |
+
$showMask = 1;
|
117 |
+
}
|
118 |
+
|
119 |
+
$data = array(
|
120 |
+
'style' => 'float: right; margin-top: 7px; ',
|
121 |
+
'label' => Mage::helper('M2ePro')->__('Close'),
|
122 |
+
'onclick' => 'ListingGridHandlerObj.variationProductManageHandler.closeManageVariationsPopup()'
|
123 |
+
);
|
124 |
+
$closeBtn = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
125 |
+
|
126 |
+
$additionalJavascript = <<<JAVASCRIPT
|
127 |
+
<script type="text/javascript">
|
128 |
+
amazonVariationProductManageTabsJsTabs.moveTabContentInDest();
|
129 |
+
|
130 |
+
if (!{$showMask}) {
|
131 |
+
amazonVariationProductManageTabsJsTabs.tabs[0].hide();
|
132 |
+
}
|
133 |
+
|
134 |
+
ListingGridHandlerObj.variationProductManageHandler.loadVariationsGrid({$showMask});
|
135 |
+
</script>
|
136 |
+
JAVASCRIPT;
|
137 |
+
|
138 |
+
return parent::_toHtml() .
|
139 |
+
'<div id="variation_product_manage_tabs_container"></div>' .
|
140 |
+
$additionalJavascript .
|
141 |
+
$closeBtn->toHtml();
|
142 |
+
}
|
143 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Variation/Product/Manage/Tabs/Settings.php
ADDED
@@ -0,0 +1,682 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Variation_Product_Manage_Tabs_Settings
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Container
|
9 |
+
{
|
10 |
+
|
11 |
+
const MESSAGE_TYPE_ERROR = 'error';
|
12 |
+
const MESSAGE_TYPE_WARNING = 'warning';
|
13 |
+
|
14 |
+
protected $warningsCalculated = false;
|
15 |
+
|
16 |
+
protected $channelThemes = null;
|
17 |
+
protected $childListingProducts = null;
|
18 |
+
protected $currentProductVariations = null;
|
19 |
+
protected $productVariationsTree = array();
|
20 |
+
protected $channelVariationsTree = array();
|
21 |
+
|
22 |
+
//------------------------------
|
23 |
+
|
24 |
+
protected $listingProductId;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @param mixed $listingProductId
|
28 |
+
* @return $this
|
29 |
+
*/
|
30 |
+
public function setListingProductId($listingProductId)
|
31 |
+
{
|
32 |
+
$this->listingProductId = $listingProductId;
|
33 |
+
|
34 |
+
return $this;
|
35 |
+
}
|
36 |
+
/**
|
37 |
+
* @return mixed
|
38 |
+
*/
|
39 |
+
public function getListingProductId()
|
40 |
+
{
|
41 |
+
return $this->listingProductId;
|
42 |
+
}
|
43 |
+
|
44 |
+
//------------------------------
|
45 |
+
|
46 |
+
protected $messages = array();
|
47 |
+
/**
|
48 |
+
* @param array $message
|
49 |
+
*/
|
50 |
+
public function addMessage($message, $type = self::MESSAGE_TYPE_ERROR)
|
51 |
+
{
|
52 |
+
$this->messages[] = array(
|
53 |
+
'type' => $type,
|
54 |
+
'msg' => $message
|
55 |
+
);
|
56 |
+
}
|
57 |
+
/**
|
58 |
+
* @param array $messages
|
59 |
+
*/
|
60 |
+
public function setMessages($messages)
|
61 |
+
{
|
62 |
+
$this->messages = $messages;
|
63 |
+
}
|
64 |
+
/**
|
65 |
+
* @return array
|
66 |
+
*/
|
67 |
+
public function getMessages()
|
68 |
+
{
|
69 |
+
return $this->messages;
|
70 |
+
}
|
71 |
+
|
72 |
+
public function getMessagesType()
|
73 |
+
{
|
74 |
+
$type = self::MESSAGE_TYPE_WARNING;
|
75 |
+
foreach ($this->messages as $message) {
|
76 |
+
if($message['type'] === self::MESSAGE_TYPE_ERROR) {
|
77 |
+
$type = $message['type'];
|
78 |
+
break;
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
return $type;
|
83 |
+
}
|
84 |
+
|
85 |
+
//------------------------------
|
86 |
+
/** @var Ess_M2ePro_Model_Listing_Product $listingProduct */
|
87 |
+
protected $listingProduct;
|
88 |
+
|
89 |
+
/**
|
90 |
+
* @return Ess_M2ePro_Model_Listing_Product|null
|
91 |
+
*/
|
92 |
+
public function getListingProduct()
|
93 |
+
{
|
94 |
+
if(empty($this->listingProduct)) {
|
95 |
+
$this->listingProduct = Mage::helper('M2ePro/Component_Amazon')
|
96 |
+
->getObject('Listing_Product', $this->getListingProductId());
|
97 |
+
}
|
98 |
+
|
99 |
+
return $this->listingProduct;
|
100 |
+
}
|
101 |
+
|
102 |
+
//------------------------------
|
103 |
+
|
104 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Matcher_Attribute $matcherAttribute */
|
105 |
+
protected $matcherAttributes;
|
106 |
+
|
107 |
+
/**
|
108 |
+
* @return Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Matcher_Attribute
|
109 |
+
*/
|
110 |
+
public function getMatcherAttributes()
|
111 |
+
{
|
112 |
+
if(empty($this->matcherAttributes)) {
|
113 |
+
$this->matcherAttributes = Mage::getModel('M2ePro/Amazon_Listing_Product_Variation_Matcher_Attribute');
|
114 |
+
$this->matcherAttributes->setMarketplaceId($this->getListingProduct()->getListing()->getMarketplaceId());
|
115 |
+
$this->matcherAttributes->setMagentoProduct($this->getListingProduct()->getMagentoProduct());
|
116 |
+
$this->matcherAttributes->setDestinationAttributes($this->getDestinationAttributes());
|
117 |
+
}
|
118 |
+
|
119 |
+
return $this->matcherAttributes;
|
120 |
+
}
|
121 |
+
|
122 |
+
public function __construct()
|
123 |
+
{
|
124 |
+
parent::__construct();
|
125 |
+
|
126 |
+
$this->setTemplate('M2ePro/common/amazon/listing/variation/product/manage/tabs/settings.phtml');
|
127 |
+
}
|
128 |
+
|
129 |
+
//------------------------------
|
130 |
+
|
131 |
+
public function getWarnings()
|
132 |
+
{
|
133 |
+
$warnings = '';
|
134 |
+
foreach ($this->getMessages() as $message) {
|
135 |
+
$warnings .= <<<HTML
|
136 |
+
<li class="{$message['type']}-msg">
|
137 |
+
<ul>
|
138 |
+
<li>{$message['msg']}</li>
|
139 |
+
</ul>
|
140 |
+
</li>
|
141 |
+
HTML;
|
142 |
+
}
|
143 |
+
return $warnings;
|
144 |
+
}
|
145 |
+
|
146 |
+
public function calculateWarnings()
|
147 |
+
{
|
148 |
+
if(!$this->warningsCalculated) {
|
149 |
+
|
150 |
+
$this->warningsCalculated = true;
|
151 |
+
|
152 |
+
if (!$this->hasGeneralId() && $this->isGeneralIdOwner()) {
|
153 |
+
if(!$this->hasChannelTheme() || !$this->hasMatchedAttributes()) {
|
154 |
+
$this->addMessage(
|
155 |
+
Mage::helper('M2ePro')
|
156 |
+
->__('Creation of New Parent-Child Product is impossible because Variation Theme
|
157 |
+
or correspondence between Magento Product Attributes and Amazon Product Attributes
|
158 |
+
was not set. Please, specify a Variation Theme or correspondence between
|
159 |
+
Variation Attributes.'),
|
160 |
+
self::MESSAGE_TYPE_ERROR
|
161 |
+
);
|
162 |
+
}
|
163 |
+
} elseif ($this->hasGeneralId()) {
|
164 |
+
if (!$this->hasMatchedAttributes()) {
|
165 |
+
$this->addMessage(
|
166 |
+
Mage::helper('M2ePro')->__(
|
167 |
+
'Selling of existing Child Products on Amazon is impossible because correspondence
|
168 |
+
between Magento Product Attributes and Amazon Product Attributes was not set.
|
169 |
+
Please, specify correspondence between Variation Attributes.'
|
170 |
+
),
|
171 |
+
self::MESSAGE_TYPE_ERROR
|
172 |
+
);
|
173 |
+
}
|
174 |
+
if ($this->isGeneralIdOwner() && !$this->hasChannelTheme()) {
|
175 |
+
$this->addMessage(
|
176 |
+
Mage::helper('M2ePro')->__(
|
177 |
+
'Creation of New Amazon Child Products feature is temporary unavailable because
|
178 |
+
Variation Theme was not set. Please, specify Variation Theme.'
|
179 |
+
),
|
180 |
+
self::MESSAGE_TYPE_WARNING
|
181 |
+
);
|
182 |
+
}
|
183 |
+
}
|
184 |
+
|
185 |
+
}
|
186 |
+
}
|
187 |
+
|
188 |
+
//------------------------------
|
189 |
+
|
190 |
+
protected function _beforeToHtml()
|
191 |
+
{
|
192 |
+
$this->calculateWarnings();
|
193 |
+
|
194 |
+
return parent::_beforeToHtml();
|
195 |
+
}
|
196 |
+
|
197 |
+
// ###########################################
|
198 |
+
|
199 |
+
public function isInAction()
|
200 |
+
{
|
201 |
+
$lockedObjects = $this->getListingProduct()->getObjectLocks();
|
202 |
+
return !empty($lockedObjects);
|
203 |
+
}
|
204 |
+
|
205 |
+
// -------------------------------------------
|
206 |
+
|
207 |
+
public function getProductAttributes()
|
208 |
+
{
|
209 |
+
return $this->getListingProduct()->getChildObject()
|
210 |
+
->getVariationManager()->getTypeModel()->getProductAttributes();
|
211 |
+
}
|
212 |
+
|
213 |
+
// -------------------------------------------
|
214 |
+
|
215 |
+
public function showGeneralIdActions()
|
216 |
+
{
|
217 |
+
return !$this->getListingProduct()->getMagentoProduct()->isBundleType() &&
|
218 |
+
!$this->getListingProduct()->getMagentoProduct()->isSimpleTypeWithCustomOptions();
|
219 |
+
}
|
220 |
+
|
221 |
+
// -------------------------------------------
|
222 |
+
|
223 |
+
public function hasGeneralId()
|
224 |
+
{
|
225 |
+
return $this->getListingProduct()->getChildObject()->getGeneralId() !== NULL;
|
226 |
+
}
|
227 |
+
|
228 |
+
public function getGeneralId()
|
229 |
+
{
|
230 |
+
return $this->getListingProduct()->getChildObject()->getGeneralId();
|
231 |
+
}
|
232 |
+
|
233 |
+
public function getGeneralIdLink()
|
234 |
+
{
|
235 |
+
$url = Mage::helper('M2ePro/Component_Amazon')->getItemUrl(
|
236 |
+
$this->getGeneralId(),
|
237 |
+
$this->getListingProduct()->getListing()->getMarketplaceId()
|
238 |
+
);
|
239 |
+
|
240 |
+
return <<<HTML
|
241 |
+
<a href="{$url}" target="_blank" title="{$this->getGeneralId()}" >{$this->getGeneralId()}</a>
|
242 |
+
HTML;
|
243 |
+
}
|
244 |
+
|
245 |
+
public function isGeneralIdOwner()
|
246 |
+
{
|
247 |
+
return $this->getListingProduct()->getChildObject()->isGeneralIdOwner();
|
248 |
+
}
|
249 |
+
|
250 |
+
// -------------------------------------------
|
251 |
+
|
252 |
+
public function getDescriptionTemplateLink()
|
253 |
+
{
|
254 |
+
$url = $this->getUrl('*/adminhtml_common_amazon_template_description/edit', array(
|
255 |
+
'id' => $this->getListingProduct()->getChildObject()->getTemplateDescriptionId()
|
256 |
+
));
|
257 |
+
|
258 |
+
$templateTitle = $this->getListingProduct()->getChildObject()->getDescriptionTemplate()->getTitle();
|
259 |
+
|
260 |
+
return <<<HTML
|
261 |
+
<a href="{$url}" target="_blank" title="{$templateTitle}" >{$templateTitle}</a>
|
262 |
+
HTML;
|
263 |
+
}
|
264 |
+
|
265 |
+
// -------------------------------------------
|
266 |
+
|
267 |
+
public function hasChannelTheme()
|
268 |
+
{
|
269 |
+
return $this->getListingProduct()->getChildObject()->getVariationManager()->getTypeModel()->hasChannelTheme();
|
270 |
+
}
|
271 |
+
|
272 |
+
public function getChannelTheme()
|
273 |
+
{
|
274 |
+
return $this->getListingProduct()->getChildObject()->getVariationManager()->getTypeModel()->getChannelTheme();
|
275 |
+
}
|
276 |
+
|
277 |
+
public function getChannelThemes()
|
278 |
+
{
|
279 |
+
if (!is_null($this->channelThemes)) {
|
280 |
+
return $this->channelThemes;
|
281 |
+
}
|
282 |
+
|
283 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product $amazonListingProduct */
|
284 |
+
$amazonListingProduct = $this->getListingProduct()->getChildObject();
|
285 |
+
$descriptionTemplate = $amazonListingProduct->getAmazonDescriptionTemplate();
|
286 |
+
|
287 |
+
if (!$descriptionTemplate) {
|
288 |
+
return array();
|
289 |
+
}
|
290 |
+
|
291 |
+
$detailsModel = Mage::getModel('M2ePro/Amazon_Marketplace_Details');
|
292 |
+
$detailsModel->setMarketplaceId($this->getListingProduct()->getListing()->getMarketplaceId());
|
293 |
+
|
294 |
+
return $this->channelThemes = $detailsModel->getVariationThemes($descriptionTemplate->getProductDataNick());
|
295 |
+
}
|
296 |
+
|
297 |
+
public function getChannelThemeAttr()
|
298 |
+
{
|
299 |
+
$theme = $this->getChannelTheme();
|
300 |
+
$themes = $this->getChannelThemes();
|
301 |
+
|
302 |
+
if(!empty($themes[$theme])) {
|
303 |
+
return $themes[$theme]['attributes'];
|
304 |
+
}
|
305 |
+
|
306 |
+
return null;
|
307 |
+
}
|
308 |
+
|
309 |
+
public function getChannelThemeNote()
|
310 |
+
{
|
311 |
+
$theme = $this->getChannelTheme();
|
312 |
+
$themes = $this->getChannelThemes();
|
313 |
+
|
314 |
+
if(!empty($themes[$theme])) {
|
315 |
+
return $themes[$theme]['note'];
|
316 |
+
}
|
317 |
+
|
318 |
+
return null;
|
319 |
+
}
|
320 |
+
|
321 |
+
public function getChannelThemeAttrString()
|
322 |
+
{
|
323 |
+
$themesAttributes = $this->getChannelThemeAttr();
|
324 |
+
|
325 |
+
if(!empty($themesAttributes)) {
|
326 |
+
return implode(', ', $themesAttributes);
|
327 |
+
}
|
328 |
+
|
329 |
+
return Mage::helper('M2ePro')->__('Variation Theme not found.');
|
330 |
+
}
|
331 |
+
|
332 |
+
// ----------------------------------------
|
333 |
+
|
334 |
+
public function hasMatchedAttributes()
|
335 |
+
{
|
336 |
+
return $this->getListingProduct()->getChildObject()
|
337 |
+
->getVariationManager()->getTypeModel()->hasMatchedAttributes();
|
338 |
+
}
|
339 |
+
|
340 |
+
public function getMatchedAttributes()
|
341 |
+
{
|
342 |
+
if($this->hasMatchedAttributes()) {
|
343 |
+
return $this->getListingProduct()->getChildObject()
|
344 |
+
->getVariationManager()->getTypeModel()->getMatchedAttributes();
|
345 |
+
}
|
346 |
+
return $this->getMatcherAttributes()->getMatchedAttributes();
|
347 |
+
}
|
348 |
+
|
349 |
+
public function getDestinationAttributes()
|
350 |
+
{
|
351 |
+
if(!$this->hasGeneralId() && $this->isGeneralIdOwner() && $this->hasChannelTheme()) {
|
352 |
+
return $this->getChannelThemeAttr();
|
353 |
+
}
|
354 |
+
return array_keys($this->getListingProduct()->getChildObject()
|
355 |
+
->getVariationManager()->getTypeModel()->getChannelAttributesSets());
|
356 |
+
}
|
357 |
+
|
358 |
+
// ###########################################
|
359 |
+
|
360 |
+
public function getChildListingProducts()
|
361 |
+
{
|
362 |
+
if (!is_null($this->childListingProducts)) {
|
363 |
+
return $this->childListingProducts;
|
364 |
+
}
|
365 |
+
|
366 |
+
return $this->childListingProducts = $this->getListingProduct()->getChildObject()
|
367 |
+
->getVariationManager()->getTypeModel()->getChildListingsProducts();
|
368 |
+
}
|
369 |
+
|
370 |
+
public function getCurrentProductVariations()
|
371 |
+
{
|
372 |
+
if (!is_null($this->currentProductVariations)) {
|
373 |
+
return $this->currentProductVariations;
|
374 |
+
}
|
375 |
+
|
376 |
+
$magentoProductVariations = $this->getListingProduct()
|
377 |
+
->getMagentoProduct()
|
378 |
+
->getVariationInstance()
|
379 |
+
->getVariationsTypeStandard();
|
380 |
+
|
381 |
+
$productVariations = array();
|
382 |
+
|
383 |
+
foreach ($magentoProductVariations['variations'] as $option) {
|
384 |
+
$productOption = array();
|
385 |
+
|
386 |
+
foreach ($option as $attribute) {
|
387 |
+
$productOption[$attribute['attribute']] = $attribute['option'];
|
388 |
+
}
|
389 |
+
|
390 |
+
$productVariations[] = $productOption;
|
391 |
+
}
|
392 |
+
|
393 |
+
return $this->currentProductVariations = $productVariations;
|
394 |
+
}
|
395 |
+
|
396 |
+
public function getChannelVariations()
|
397 |
+
{
|
398 |
+
if (!is_null($this->childListingProducts)) {
|
399 |
+
return $this->childListingProducts;
|
400 |
+
}
|
401 |
+
|
402 |
+
return $this->childListingProducts = $this->getListingProduct()->getChildObject()
|
403 |
+
->getVariationManager()->getTypeModel()->getChildListingsProducts();
|
404 |
+
}
|
405 |
+
|
406 |
+
public function getCurrentChannelVariations()
|
407 |
+
{
|
408 |
+
return $this->getListingProduct()->getChildObject()
|
409 |
+
->getVariationManager()->getTypeModel()->getChannelVariations();
|
410 |
+
}
|
411 |
+
|
412 |
+
// ------------------------------------------
|
413 |
+
|
414 |
+
public function getUsedChannelVariations()
|
415 |
+
{
|
416 |
+
$usedOptions = array();
|
417 |
+
|
418 |
+
foreach ($this->getChildListingProducts() as $childListingProduct) {
|
419 |
+
/** @var Ess_M2ePro_Model_Listing_Product $childListingProduct */
|
420 |
+
|
421 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager_Type_Relation_Child $childTypeModel */
|
422 |
+
$childTypeModel = $childListingProduct->getChildObject()->getVariationManager()->getTypeModel();
|
423 |
+
|
424 |
+
if (!$childTypeModel->isVariationChannelMatched()) {
|
425 |
+
continue;
|
426 |
+
}
|
427 |
+
|
428 |
+
$usedOptions[] = $childTypeModel->getChannelOptions();
|
429 |
+
}
|
430 |
+
|
431 |
+
return $usedOptions;
|
432 |
+
}
|
433 |
+
|
434 |
+
public function getUsedProductVariations()
|
435 |
+
{
|
436 |
+
$usedOptions = array();
|
437 |
+
|
438 |
+
foreach ($this->getChildListingProducts() as $childListingProduct) {
|
439 |
+
/** @var Ess_M2ePro_Model_Listing_Product $childListingProduct */
|
440 |
+
|
441 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager_Type_Relation_Child $childTypeModel */
|
442 |
+
$childTypeModel = $childListingProduct->getChildObject()->getVariationManager()->getTypeModel();
|
443 |
+
|
444 |
+
if (!$childTypeModel->isVariationProductMatched()) {
|
445 |
+
continue;
|
446 |
+
}
|
447 |
+
|
448 |
+
$usedOptions[] = $childTypeModel->getProductOptions();
|
449 |
+
}
|
450 |
+
|
451 |
+
return $usedOptions;
|
452 |
+
}
|
453 |
+
|
454 |
+
// ------------------------------------------
|
455 |
+
|
456 |
+
public function getUnusedProductVariations()
|
457 |
+
{
|
458 |
+
return $this->getUnusedVariations($this->getCurrentProductVariations(), $this->getUsedProductVariations());
|
459 |
+
}
|
460 |
+
|
461 |
+
public function getUnusedChannelVariations()
|
462 |
+
{
|
463 |
+
return $this->getUnusedVariations($this->getCurrentChannelVariations(), $this->getUsedChannelVariations());
|
464 |
+
}
|
465 |
+
|
466 |
+
private function getUnusedVariations($currentVariations, $usedVariations)
|
467 |
+
{
|
468 |
+
if (empty($currentVariations)) {
|
469 |
+
return array();
|
470 |
+
}
|
471 |
+
|
472 |
+
if (empty($usedVariations)) {
|
473 |
+
return $currentVariations;
|
474 |
+
}
|
475 |
+
|
476 |
+
$unusedOptions = array();
|
477 |
+
|
478 |
+
foreach ($currentVariations as $id => $currentOption) {
|
479 |
+
if ($this->isVariationExistsInArray($currentOption, $usedVariations)) {
|
480 |
+
continue;
|
481 |
+
}
|
482 |
+
|
483 |
+
$unusedOptions[$id] = $currentOption;
|
484 |
+
}
|
485 |
+
|
486 |
+
return $unusedOptions;
|
487 |
+
}
|
488 |
+
|
489 |
+
private function isVariationExistsInArray(array $needle, array $haystack)
|
490 |
+
{
|
491 |
+
foreach ($haystack as $option) {
|
492 |
+
if ($option != $needle) {
|
493 |
+
continue;
|
494 |
+
}
|
495 |
+
|
496 |
+
return true;
|
497 |
+
}
|
498 |
+
|
499 |
+
return false;
|
500 |
+
}
|
501 |
+
|
502 |
+
// ------------------------------------------
|
503 |
+
|
504 |
+
public function getAttributesOptionsFromVariations($variations)
|
505 |
+
{
|
506 |
+
$attributesOptions = array();
|
507 |
+
|
508 |
+
foreach ($variations as $variation) {
|
509 |
+
foreach ($variation as $attr => $option) {
|
510 |
+
if (!isset($attributesOptions[$attr])) {
|
511 |
+
$attributesOptions[$attr] = array();
|
512 |
+
}
|
513 |
+
if (!in_array($option, $attributesOptions[$attr])) {
|
514 |
+
$attributesOptions[$attr][] = $option;
|
515 |
+
}
|
516 |
+
}
|
517 |
+
}
|
518 |
+
|
519 |
+
ksort($attributesOptions);
|
520 |
+
|
521 |
+
return $attributesOptions;
|
522 |
+
}
|
523 |
+
|
524 |
+
// ------------------------------------------
|
525 |
+
|
526 |
+
public function getProductVariationsTree()
|
527 |
+
{
|
528 |
+
if (empty($this->productVariationsTree)) {
|
529 |
+
|
530 |
+
$unusedVariations = $this->getUnusedProductVariations();
|
531 |
+
$variationsSets = $this->getAttributesOptionsFromVariations($unusedVariations);
|
532 |
+
$firstAttribute = key($variationsSets);
|
533 |
+
|
534 |
+
$this->productVariationsTree = $this->prepareVariations(
|
535 |
+
$firstAttribute,$unusedVariations,$variationsSets
|
536 |
+
);
|
537 |
+
}
|
538 |
+
|
539 |
+
return $this->productVariationsTree;
|
540 |
+
}
|
541 |
+
|
542 |
+
public function getChannelVariationsTree()
|
543 |
+
{
|
544 |
+
if (empty($this->channelVariationsTree)) {
|
545 |
+
|
546 |
+
$unusedVariations = $this->getUnusedChannelVariations();
|
547 |
+
$variationsSets = $this->getAttributesOptionsFromVariations($unusedVariations);
|
548 |
+
$firstAttribute = key($variationsSets);
|
549 |
+
|
550 |
+
$this->channelVariationsTree = $this->prepareVariations(
|
551 |
+
$firstAttribute,$unusedVariations,$variationsSets
|
552 |
+
);
|
553 |
+
}
|
554 |
+
|
555 |
+
return $this->channelVariationsTree;
|
556 |
+
}
|
557 |
+
|
558 |
+
private function prepareVariations($currentAttribute,$magentoVariations,$variationsSets,$filters = array())
|
559 |
+
{
|
560 |
+
$return = false;
|
561 |
+
|
562 |
+
$temp = array_flip(array_keys($variationsSets));
|
563 |
+
|
564 |
+
$lastAttributePosition = count($variationsSets) - 1;
|
565 |
+
$currentAttributePosition = $temp[$currentAttribute];
|
566 |
+
|
567 |
+
if ($currentAttributePosition != $lastAttributePosition) {
|
568 |
+
|
569 |
+
$temp = array_keys($variationsSets);
|
570 |
+
$nextAttribute = $temp[$currentAttributePosition + 1];
|
571 |
+
|
572 |
+
foreach ($variationsSets[$currentAttribute] as $option) {
|
573 |
+
|
574 |
+
$filters[$currentAttribute] = $option;
|
575 |
+
|
576 |
+
$result = $this->prepareVariations(
|
577 |
+
$nextAttribute,$magentoVariations,$variationsSets,$filters
|
578 |
+
);
|
579 |
+
|
580 |
+
if (!$result) {
|
581 |
+
continue;
|
582 |
+
}
|
583 |
+
|
584 |
+
$return[$currentAttribute][$option] = $result;
|
585 |
+
}
|
586 |
+
|
587 |
+
ksort($return[$currentAttribute]);
|
588 |
+
|
589 |
+
return $return;
|
590 |
+
}
|
591 |
+
|
592 |
+
$return = false;
|
593 |
+
foreach ($magentoVariations as $key => $magentoVariation) {
|
594 |
+
foreach ($magentoVariation as $attribute => $option) {
|
595 |
+
|
596 |
+
if ($attribute == $currentAttribute) {
|
597 |
+
|
598 |
+
if (count($variationsSets) != 1) {
|
599 |
+
continue;
|
600 |
+
}
|
601 |
+
|
602 |
+
$values = array_flip($variationsSets[$currentAttribute]);
|
603 |
+
$return = array($currentAttribute => $values);
|
604 |
+
|
605 |
+
foreach ($return[$currentAttribute] as &$option) {
|
606 |
+
$option = true;
|
607 |
+
}
|
608 |
+
|
609 |
+
return $return;
|
610 |
+
}
|
611 |
+
|
612 |
+
if ($option != $filters[$attribute]) {
|
613 |
+
unset($magentoVariations[$key]);
|
614 |
+
continue;
|
615 |
+
}
|
616 |
+
|
617 |
+
foreach ($magentoVariation as $tempAttribute => $tempOption) {
|
618 |
+
if ($tempAttribute == $currentAttribute) {
|
619 |
+
$option = $tempOption;
|
620 |
+
$return[$currentAttribute][$option] = true;
|
621 |
+
}
|
622 |
+
}
|
623 |
+
}
|
624 |
+
}
|
625 |
+
|
626 |
+
if (count($magentoVariations) < 1) {
|
627 |
+
return false;
|
628 |
+
}
|
629 |
+
|
630 |
+
ksort($return[$currentAttribute]);
|
631 |
+
|
632 |
+
return $return;
|
633 |
+
}
|
634 |
+
|
635 |
+
// ------------------------------------------
|
636 |
+
|
637 |
+
public function hasUnusedProductVariation()
|
638 |
+
{
|
639 |
+
return count($this->getChildListingProducts()) < count($this->getCurrentProductVariations());
|
640 |
+
}
|
641 |
+
|
642 |
+
public function hasUnusedChannelVariations()
|
643 |
+
{
|
644 |
+
return count($this->getUsedChannelVariations()) < count($this->getCurrentChannelVariations());
|
645 |
+
}
|
646 |
+
|
647 |
+
// ------------------------------------------
|
648 |
+
|
649 |
+
public function hasChildWithEmptyProductOptions()
|
650 |
+
{
|
651 |
+
foreach ($this->getChildListingProducts() as $childListingProduct) {
|
652 |
+
/** @var Ess_M2ePro_Model_Listing_Product $childListingProduct */
|
653 |
+
|
654 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager_Type_Relation_Child $childTypeModel */
|
655 |
+
$childTypeModel = $childListingProduct->getChildObject()->getVariationManager()->getTypeModel();
|
656 |
+
|
657 |
+
if (!$childTypeModel->isVariationProductMatched()) {
|
658 |
+
return true;
|
659 |
+
}
|
660 |
+
}
|
661 |
+
|
662 |
+
return false;
|
663 |
+
}
|
664 |
+
|
665 |
+
public function hasChildWithEmptyChannelOptions()
|
666 |
+
{
|
667 |
+
foreach ($this->getChildListingProducts() as $childListingProduct) {
|
668 |
+
/** @var Ess_M2ePro_Model_Listing_Product $childListingProduct */
|
669 |
+
|
670 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager_Type_Relation_Child $childTypeModel */
|
671 |
+
$childTypeModel = $childListingProduct->getChildObject()->getVariationManager()->getTypeModel();
|
672 |
+
|
673 |
+
if (!$childTypeModel->isVariationChannelMatched()) {
|
674 |
+
return true;
|
675 |
+
}
|
676 |
+
}
|
677 |
+
|
678 |
+
return false;
|
679 |
+
}
|
680 |
+
|
681 |
+
// ###########################################
|
682 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Variation/Product/Manage/Tabs/Variations.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Variation_Product_Manage_Tabs_Variations
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Container
|
9 |
+
{
|
10 |
+
protected $listingProductId;
|
11 |
+
/**
|
12 |
+
* @param mixed $listingProductId
|
13 |
+
* @return $this
|
14 |
+
*/
|
15 |
+
public function setListingProductId($listingProductId)
|
16 |
+
{
|
17 |
+
$this->listingProductId = $listingProductId;
|
18 |
+
|
19 |
+
return $this;
|
20 |
+
}
|
21 |
+
/**
|
22 |
+
* @return mixed
|
23 |
+
*/
|
24 |
+
public function getListingProductId()
|
25 |
+
{
|
26 |
+
return $this->listingProductId;
|
27 |
+
}
|
28 |
+
|
29 |
+
public function __construct()
|
30 |
+
{
|
31 |
+
parent::__construct();
|
32 |
+
|
33 |
+
$this->setTemplate('M2ePro/common/amazon/listing/variation/product/manage/tabs/variations.phtml');
|
34 |
+
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Variation/Product/Manage/Tabs/Variations/Child/Form.php
ADDED
@@ -0,0 +1,398 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Variation_Product_Manage_Tabs_Variations_Child_Form
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Form
|
9 |
+
{
|
10 |
+
protected $childListingProducts = null;
|
11 |
+
protected $currentProductVariations = null;
|
12 |
+
protected $productVariationsTree = array();
|
13 |
+
protected $channelVariationsTree = array();
|
14 |
+
|
15 |
+
protected $listingProductId;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @param mixed $listingProductId
|
19 |
+
* @return $this
|
20 |
+
*/
|
21 |
+
public function setListingProductId($listingProductId)
|
22 |
+
{
|
23 |
+
$this->listingProductId = $listingProductId;
|
24 |
+
|
25 |
+
return $this;
|
26 |
+
}
|
27 |
+
/**
|
28 |
+
* @return mixed
|
29 |
+
*/
|
30 |
+
public function getListingProductId()
|
31 |
+
{
|
32 |
+
return $this->listingProductId;
|
33 |
+
}
|
34 |
+
|
35 |
+
/** @var Ess_M2ePro_Model_Listing_Product $listingProduct */
|
36 |
+
protected $listingProduct;
|
37 |
+
|
38 |
+
public function __construct()
|
39 |
+
{
|
40 |
+
parent::__construct();
|
41 |
+
|
42 |
+
$this->setTemplate('M2ePro/common/amazon/listing/variation/product/manage/tabs/variations/child/form.phtml');
|
43 |
+
}
|
44 |
+
|
45 |
+
// ----------------------------------------
|
46 |
+
/**
|
47 |
+
* @return Ess_M2ePro_Model_Listing_Product|null
|
48 |
+
*/
|
49 |
+
public function getListingProduct()
|
50 |
+
{
|
51 |
+
if(empty($this->listingProduct)) {
|
52 |
+
$this->listingProduct = Mage::helper('M2ePro/Component_Amazon')
|
53 |
+
->getObject('Listing_Product', $this->getListingProductId());
|
54 |
+
}
|
55 |
+
|
56 |
+
return $this->listingProduct;
|
57 |
+
}
|
58 |
+
|
59 |
+
// ########################################
|
60 |
+
|
61 |
+
public function isGeneralIdOwner()
|
62 |
+
{
|
63 |
+
return $this->getListingProduct()->getChildObject()->isGeneralIdOwner();
|
64 |
+
}
|
65 |
+
|
66 |
+
// ----------------------------------------
|
67 |
+
|
68 |
+
public function hasChannelTheme()
|
69 |
+
{
|
70 |
+
return $this->getListingProduct()->getChildObject()->getVariationManager()->getTypeModel()->hasChannelTheme();
|
71 |
+
}
|
72 |
+
|
73 |
+
public function hasUnusedChannelVariations()
|
74 |
+
{
|
75 |
+
return count($this->getUsedChannelVariations()) < count($this->getCurrentChannelVariations());
|
76 |
+
}
|
77 |
+
|
78 |
+
// ----------------------------------------
|
79 |
+
|
80 |
+
public function getMatchedAttributes()
|
81 |
+
{
|
82 |
+
return $this->getListingProduct()->getChildObject()
|
83 |
+
->getVariationManager()->getTypeModel()->getMatchedAttributes();
|
84 |
+
}
|
85 |
+
|
86 |
+
// ----------------------------------------
|
87 |
+
|
88 |
+
public function getUnusedProductVariations()
|
89 |
+
{
|
90 |
+
return $this->getUnusedVariations($this->getCurrentProductVariations(), $this->getUsedProductVariations());
|
91 |
+
}
|
92 |
+
|
93 |
+
public function getUnusedChannelVariations()
|
94 |
+
{
|
95 |
+
return $this->getUnusedVariations($this->getCurrentChannelVariations(), $this->getUsedChannelVariations());
|
96 |
+
}
|
97 |
+
|
98 |
+
private function getUnusedVariations($currentVariations, $usedVariations)
|
99 |
+
{
|
100 |
+
if (empty($currentVariations)) {
|
101 |
+
return array();
|
102 |
+
}
|
103 |
+
|
104 |
+
if (empty($usedVariations)) {
|
105 |
+
return $currentVariations;
|
106 |
+
}
|
107 |
+
|
108 |
+
$unusedOptions = array();
|
109 |
+
|
110 |
+
foreach ($currentVariations as $id => $currentOption) {
|
111 |
+
if ($this->isVariationExistsInArray($currentOption, $usedVariations)) {
|
112 |
+
continue;
|
113 |
+
}
|
114 |
+
|
115 |
+
$unusedOptions[$id] = $currentOption;
|
116 |
+
}
|
117 |
+
|
118 |
+
return $unusedOptions;
|
119 |
+
}
|
120 |
+
|
121 |
+
private function isVariationExistsInArray(array $needle, array $haystack)
|
122 |
+
{
|
123 |
+
foreach ($haystack as $option) {
|
124 |
+
if ($option != $needle) {
|
125 |
+
continue;
|
126 |
+
}
|
127 |
+
|
128 |
+
return true;
|
129 |
+
}
|
130 |
+
|
131 |
+
return false;
|
132 |
+
}
|
133 |
+
|
134 |
+
// ----------------------------------------
|
135 |
+
|
136 |
+
public function getChildListingProducts()
|
137 |
+
{
|
138 |
+
if (!is_null($this->childListingProducts)) {
|
139 |
+
return $this->childListingProducts;
|
140 |
+
}
|
141 |
+
|
142 |
+
return $this->childListingProducts = $this->getListingProduct()->getChildObject()
|
143 |
+
->getVariationManager()->getTypeModel()->getChildListingsProducts();
|
144 |
+
}
|
145 |
+
|
146 |
+
public function getCurrentProductVariations()
|
147 |
+
{
|
148 |
+
if (!is_null($this->currentProductVariations)) {
|
149 |
+
return $this->currentProductVariations;
|
150 |
+
}
|
151 |
+
|
152 |
+
$magentoProductVariations = $this->getListingProduct()
|
153 |
+
->getMagentoProduct()
|
154 |
+
->getVariationInstance()
|
155 |
+
->getVariationsTypeStandard();
|
156 |
+
|
157 |
+
$productVariations = array();
|
158 |
+
|
159 |
+
foreach ($magentoProductVariations['variations'] as $option) {
|
160 |
+
$productOption = array();
|
161 |
+
|
162 |
+
foreach ($option as $attribute) {
|
163 |
+
$productOption[$attribute['attribute']] = $attribute['option'];
|
164 |
+
}
|
165 |
+
|
166 |
+
$productVariations[] = $productOption;
|
167 |
+
}
|
168 |
+
|
169 |
+
return $this->currentProductVariations = $productVariations;
|
170 |
+
}
|
171 |
+
|
172 |
+
public function getCurrentChannelVariations()
|
173 |
+
{
|
174 |
+
return $this->getListingProduct()->getChildObject()
|
175 |
+
->getVariationManager()->getTypeModel()->getChannelVariations();
|
176 |
+
}
|
177 |
+
|
178 |
+
// ----------------------------------------
|
179 |
+
|
180 |
+
public function getAttributesOptionsFromVariations($variations)
|
181 |
+
{
|
182 |
+
$attributesOptions = array();
|
183 |
+
|
184 |
+
foreach ($variations as $variation) {
|
185 |
+
foreach ($variation as $attr => $option) {
|
186 |
+
if (!isset($attributesOptions[$attr])) {
|
187 |
+
$attributesOptions[$attr] = array();
|
188 |
+
}
|
189 |
+
if (!in_array($option, $attributesOptions[$attr])) {
|
190 |
+
$attributesOptions[$attr][] = $option;
|
191 |
+
}
|
192 |
+
}
|
193 |
+
}
|
194 |
+
|
195 |
+
ksort($attributesOptions);
|
196 |
+
|
197 |
+
return $attributesOptions;
|
198 |
+
}
|
199 |
+
|
200 |
+
// ----------------------------------------
|
201 |
+
|
202 |
+
public function getUsedChannelVariations()
|
203 |
+
{
|
204 |
+
$usedOptions = array();
|
205 |
+
|
206 |
+
foreach ($this->getChildListingProducts() as $childListingProduct) {
|
207 |
+
/** @var Ess_M2ePro_Model_Listing_Product $childListingProduct */
|
208 |
+
|
209 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager_Type_Relation_Child $childTypeModel */
|
210 |
+
$childTypeModel = $childListingProduct->getChildObject()->getVariationManager()->getTypeModel();
|
211 |
+
|
212 |
+
if (!$childTypeModel->isVariationChannelMatched()) {
|
213 |
+
continue;
|
214 |
+
}
|
215 |
+
|
216 |
+
$usedOptions[] = $childTypeModel->getChannelOptions();
|
217 |
+
}
|
218 |
+
|
219 |
+
return $usedOptions;
|
220 |
+
}
|
221 |
+
|
222 |
+
public function getUsedProductVariations()
|
223 |
+
{
|
224 |
+
$usedOptions = array();
|
225 |
+
|
226 |
+
foreach ($this->getChildListingProducts() as $childListingProduct) {
|
227 |
+
/** @var Ess_M2ePro_Model_Listing_Product $childListingProduct */
|
228 |
+
|
229 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager_Type_Relation_Child $childTypeModel */
|
230 |
+
$childTypeModel = $childListingProduct->getChildObject()->getVariationManager()->getTypeModel();
|
231 |
+
|
232 |
+
if (!$childTypeModel->isVariationProductMatched()) {
|
233 |
+
continue;
|
234 |
+
}
|
235 |
+
|
236 |
+
$usedOptions[] = $childTypeModel->getProductOptions();
|
237 |
+
}
|
238 |
+
|
239 |
+
return $usedOptions;
|
240 |
+
}
|
241 |
+
|
242 |
+
// ----------------------------------------
|
243 |
+
|
244 |
+
public function getProductVariationsTree()
|
245 |
+
{
|
246 |
+
if (empty($this->productVariationsTree)) {
|
247 |
+
|
248 |
+
$matchedAttributes = $this->getMatchedAttributes();
|
249 |
+
$unusedVariations = $this->sortVariationsAttributes(
|
250 |
+
$this->getUnusedProductVariations(),
|
251 |
+
array_keys($matchedAttributes)
|
252 |
+
);
|
253 |
+
$variationsSets = $this->sortVariationAttributes(
|
254 |
+
$this->getAttributesOptionsFromVariations($unusedVariations),
|
255 |
+
array_keys($matchedAttributes)
|
256 |
+
);
|
257 |
+
|
258 |
+
$firstAttribute = key($matchedAttributes);
|
259 |
+
|
260 |
+
$this->productVariationsTree = $this->prepareVariations(
|
261 |
+
$firstAttribute,$unusedVariations,$variationsSets
|
262 |
+
);
|
263 |
+
}
|
264 |
+
|
265 |
+
return $this->productVariationsTree;
|
266 |
+
}
|
267 |
+
|
268 |
+
public function getChannelVariationsTree()
|
269 |
+
{
|
270 |
+
if (empty($this->channelVariationsTree)) {
|
271 |
+
|
272 |
+
$matchedAttributes = $this->getMatchedAttributes();
|
273 |
+
$unusedVariations = $this->sortVariationsAttributes(
|
274 |
+
$this->getUnusedChannelVariations(),
|
275 |
+
array_values($matchedAttributes)
|
276 |
+
);
|
277 |
+
|
278 |
+
if (empty($unusedVariations)) {
|
279 |
+
$this->channelVariationsTree = new stdClass();
|
280 |
+
|
281 |
+
return $this->channelVariationsTree;
|
282 |
+
}
|
283 |
+
|
284 |
+
$variationsSets = $this->sortVariationAttributes(
|
285 |
+
$this->getAttributesOptionsFromVariations($unusedVariations),
|
286 |
+
array_values($matchedAttributes)
|
287 |
+
);
|
288 |
+
|
289 |
+
$firstAttribute = $matchedAttributes[key($matchedAttributes)];
|
290 |
+
|
291 |
+
$this->channelVariationsTree = $this->prepareVariations(
|
292 |
+
$firstAttribute,$unusedVariations,$variationsSets
|
293 |
+
);
|
294 |
+
}
|
295 |
+
|
296 |
+
return $this->channelVariationsTree;
|
297 |
+
}
|
298 |
+
|
299 |
+
private function sortVariationsAttributes($variations, $sortTemplate)
|
300 |
+
{
|
301 |
+
foreach ($variations as $key => $variation) {
|
302 |
+
$variations[$key] = $this->sortVariationAttributes($variation, $sortTemplate);
|
303 |
+
}
|
304 |
+
|
305 |
+
return $variations;
|
306 |
+
}
|
307 |
+
|
308 |
+
private function sortVariationAttributes($variation, $sortTemplate)
|
309 |
+
{
|
310 |
+
$sortedData = array();
|
311 |
+
|
312 |
+
foreach ($sortTemplate as $attr) {
|
313 |
+
$sortedData[$attr] = $variation[$attr];
|
314 |
+
}
|
315 |
+
|
316 |
+
return $sortedData;
|
317 |
+
}
|
318 |
+
|
319 |
+
private function prepareVariations($currentAttribute,$magentoVariations,$variationsSets,$filters = array())
|
320 |
+
{
|
321 |
+
$return = false;
|
322 |
+
|
323 |
+
$temp = array_flip(array_keys($variationsSets));
|
324 |
+
|
325 |
+
$lastAttributePosition = count($variationsSets) - 1;
|
326 |
+
$currentAttributePosition = $temp[$currentAttribute];
|
327 |
+
|
328 |
+
if ($currentAttributePosition != $lastAttributePosition) {
|
329 |
+
|
330 |
+
$temp = array_keys($variationsSets);
|
331 |
+
$nextAttribute = $temp[$currentAttributePosition + 1];
|
332 |
+
|
333 |
+
foreach ($variationsSets[$currentAttribute] as $option) {
|
334 |
+
|
335 |
+
$filters[$currentAttribute] = $option;
|
336 |
+
|
337 |
+
$result = $this->prepareVariations(
|
338 |
+
$nextAttribute,$magentoVariations,$variationsSets,$filters
|
339 |
+
);
|
340 |
+
|
341 |
+
if (!$result) {
|
342 |
+
continue;
|
343 |
+
}
|
344 |
+
|
345 |
+
$return[$currentAttribute][$option] = $result;
|
346 |
+
}
|
347 |
+
|
348 |
+
ksort($return[$currentAttribute]);
|
349 |
+
|
350 |
+
return $return;
|
351 |
+
}
|
352 |
+
|
353 |
+
$return = false;
|
354 |
+
foreach ($magentoVariations as $key => $magentoVariation) {
|
355 |
+
foreach ($magentoVariation as $attribute => $option) {
|
356 |
+
|
357 |
+
if ($attribute == $currentAttribute) {
|
358 |
+
|
359 |
+
if (count($variationsSets) != 1) {
|
360 |
+
continue;
|
361 |
+
}
|
362 |
+
|
363 |
+
$values = array_flip($variationsSets[$currentAttribute]);
|
364 |
+
$return = array($currentAttribute => $values);
|
365 |
+
|
366 |
+
foreach ($return[$currentAttribute] as &$option) {
|
367 |
+
$option = true;
|
368 |
+
}
|
369 |
+
|
370 |
+
return $return;
|
371 |
+
}
|
372 |
+
|
373 |
+
if ($option != $filters[$attribute]) {
|
374 |
+
unset($magentoVariations[$key]);
|
375 |
+
continue;
|
376 |
+
}
|
377 |
+
|
378 |
+
foreach ($magentoVariation as $tempAttribute => $tempOption) {
|
379 |
+
if ($tempAttribute == $currentAttribute) {
|
380 |
+
$option = $tempOption;
|
381 |
+
$return[$currentAttribute][$option] = true;
|
382 |
+
}
|
383 |
+
}
|
384 |
+
}
|
385 |
+
}
|
386 |
+
|
387 |
+
if (count($magentoVariations) < 1) {
|
388 |
+
return false;
|
389 |
+
}
|
390 |
+
|
391 |
+
ksort($return[$currentAttribute]);
|
392 |
+
|
393 |
+
return $return;
|
394 |
+
}
|
395 |
+
|
396 |
+
// ----------------------------------------
|
397 |
+
|
398 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Variation/Product/Manage/Tabs/Variations/Grid.php
ADDED
@@ -0,0 +1,1512 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Variation_Product_Manage_Tabs_Variations_Grid
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
9 |
+
{
|
10 |
+
protected $childListingProducts = null;
|
11 |
+
protected $currentProductVariations = null;
|
12 |
+
protected $usedProductVariations = null;
|
13 |
+
|
14 |
+
protected $listingProductId;
|
15 |
+
/**
|
16 |
+
* @param mixed $listingProductId
|
17 |
+
*/
|
18 |
+
public function setListingProductId($listingProductId)
|
19 |
+
{
|
20 |
+
$this->listingProductId = $listingProductId;
|
21 |
+
}
|
22 |
+
/**
|
23 |
+
* @return mixed
|
24 |
+
*/
|
25 |
+
public function getListingProductId()
|
26 |
+
{
|
27 |
+
return $this->listingProductId;
|
28 |
+
}
|
29 |
+
|
30 |
+
//------------------------------
|
31 |
+
|
32 |
+
/** @var Ess_M2ePro_Model_Listing_Product $listingProduct */
|
33 |
+
protected $listingProduct;
|
34 |
+
|
35 |
+
protected function getListingProduct()
|
36 |
+
{
|
37 |
+
if(empty($this->listingProduct)) {
|
38 |
+
$this->listingProduct = Mage::helper('M2ePro/Component_Amazon')
|
39 |
+
->getObject('Listing_Product', $this->getListingProductId());
|
40 |
+
}
|
41 |
+
|
42 |
+
return $this->listingProduct;
|
43 |
+
}
|
44 |
+
|
45 |
+
//------------------------------
|
46 |
+
|
47 |
+
private $lockedDataCache = array();
|
48 |
+
|
49 |
+
// ####################################
|
50 |
+
|
51 |
+
public function __construct()
|
52 |
+
{
|
53 |
+
parent::__construct();
|
54 |
+
|
55 |
+
// Initialization block
|
56 |
+
//------------------------------
|
57 |
+
$this->setId('amazonVariationProductManageGrid');
|
58 |
+
$this->setDefaultSort('id');
|
59 |
+
$this->setDefaultDir('ASC');
|
60 |
+
$this->setUseAjax(true);
|
61 |
+
//------------------------------
|
62 |
+
}
|
63 |
+
|
64 |
+
// ####################################
|
65 |
+
|
66 |
+
protected function _prepareCollection()
|
67 |
+
{
|
68 |
+
// Get collection
|
69 |
+
//----------------------------
|
70 |
+
/** @var Ess_M2ePro_Model_Mysql4_Amazon_Listing_Product_Collection $collection */
|
71 |
+
$collection = Mage::helper('M2ePro/Component_Amazon')->getCollection('Listing_Product');
|
72 |
+
$collection->getSelect()->distinct();
|
73 |
+
$collection->getSelect()->where("`second_table`.`variation_parent_id` = ?",(int)$this->getListingProductId());
|
74 |
+
//----------------------------
|
75 |
+
|
76 |
+
// Set collection to grid
|
77 |
+
$this->setCollection($collection);
|
78 |
+
|
79 |
+
return parent::_prepareCollection();
|
80 |
+
}
|
81 |
+
|
82 |
+
protected function _prepareColumns()
|
83 |
+
{
|
84 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager_Type_Relation_Parent $parentType */
|
85 |
+
$parentType = $this->getListingProduct()->getChildObject()->getVariationManager()->getTypeModel();
|
86 |
+
|
87 |
+
$channelAttributesSets = $parentType->getChannelAttributesSets();
|
88 |
+
|
89 |
+
if (!empty($channelAttributesSets)) {
|
90 |
+
$channelAttributes = array_keys($channelAttributesSets);
|
91 |
+
} else if ($parentType->hasMatchedAttributes()) {
|
92 |
+
$channelAttributes = array_values($parentType->getMatchedAttributes());
|
93 |
+
} else {
|
94 |
+
$channelAttributes = array();
|
95 |
+
}
|
96 |
+
|
97 |
+
$this->addColumn('product_options', array(
|
98 |
+
'header' => Mage::helper('M2ePro')->__('Magento Variation'),
|
99 |
+
'align' => 'left',
|
100 |
+
'width' => '210px',
|
101 |
+
'sortable' => false,
|
102 |
+
'index' => 'additional_data',
|
103 |
+
'filter_index' => 'additional_data',
|
104 |
+
'frame_callback' => array($this, 'callbackColumnProductOptions'),
|
105 |
+
'filter' => 'M2ePro/adminhtml_grid_column_filter_attributesOptions',
|
106 |
+
'options' => $parentType->getProductAttributes(),
|
107 |
+
'filter_condition_callback' => array($this, 'callbackProductOptions')
|
108 |
+
));
|
109 |
+
|
110 |
+
$this->addColumn('channel_options', array(
|
111 |
+
'header' => Mage::helper('M2ePro')->__('Amazon Variation'),
|
112 |
+
'align' => 'left',
|
113 |
+
'width' => '210px',
|
114 |
+
'sortable' => false,
|
115 |
+
'index' => 'additional_data',
|
116 |
+
'filter_index' => 'additional_data',
|
117 |
+
'frame_callback' => array($this, 'callbackColumnChannelOptions'),
|
118 |
+
'filter' => 'M2ePro/adminhtml_grid_column_filter_attributesOptions',
|
119 |
+
'options' => $channelAttributes,
|
120 |
+
'filter_condition_callback' => array($this, 'callbackChannelOptions')
|
121 |
+
));
|
122 |
+
|
123 |
+
$this->addColumn('sku', array(
|
124 |
+
'header' => Mage::helper('M2ePro')->__('SKU'),
|
125 |
+
'align' => 'left',
|
126 |
+
'type' => 'text',
|
127 |
+
'index' => 'sku',
|
128 |
+
'filter_index' => 'sku',
|
129 |
+
'frame_callback' => array($this, 'callbackColumnAmazonSku')
|
130 |
+
));
|
131 |
+
|
132 |
+
$this->addColumn('general_id', array(
|
133 |
+
'header' => Mage::helper('M2ePro')->__('ASIN / ISBN'),
|
134 |
+
'align' => 'left',
|
135 |
+
'width' => '100px',
|
136 |
+
'type' => 'text',
|
137 |
+
'index' => 'general_id',
|
138 |
+
'filter_index' => 'general_id',
|
139 |
+
'frame_callback' => array($this, 'callbackColumnGeneralId')
|
140 |
+
));
|
141 |
+
|
142 |
+
$this->addColumn('online_qty', array(
|
143 |
+
'header' => Mage::helper('M2ePro')->__('QTY'),
|
144 |
+
'align' => 'right',
|
145 |
+
'width' => '70px',
|
146 |
+
'type' => 'number',
|
147 |
+
'index' => 'online_qty',
|
148 |
+
'filter_index' => 'online_qty',
|
149 |
+
'frame_callback' => array($this, 'callbackColumnAvailableQty')
|
150 |
+
));
|
151 |
+
|
152 |
+
$this->addColumn('online_price', array(
|
153 |
+
'header' => Mage::helper('M2ePro')->__('Price'),
|
154 |
+
'align' => 'right',
|
155 |
+
'width' => '70px',
|
156 |
+
'type' => 'number',
|
157 |
+
'index' => 'online_price',
|
158 |
+
'filter_index' => 'online_price',
|
159 |
+
'frame_callback' => array($this, 'callbackColumnPrice'),
|
160 |
+
'filter_condition_callback' => array($this, 'callbackFilterPrice')
|
161 |
+
));
|
162 |
+
|
163 |
+
$this->addColumn('status', array(
|
164 |
+
'header' => Mage::helper('M2ePro')->__('Status'),
|
165 |
+
'width' => '100px',
|
166 |
+
'index' => 'status',
|
167 |
+
'filter_index' => 'status',
|
168 |
+
'type' => 'options',
|
169 |
+
'sortable' => false,
|
170 |
+
'options' => array(
|
171 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_UNKNOWN => Mage::helper('M2ePro')->__('Unknown'),
|
172 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED => Mage::helper('M2ePro')->__('Not Listed'),
|
173 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_LISTED => Mage::helper('M2ePro')->__('Active'),
|
174 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED => Mage::helper('M2ePro')->__('Inactive'),
|
175 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_BLOCKED => Mage::helper('M2ePro')->__('Inactive (Blocked)')
|
176 |
+
),
|
177 |
+
'frame_callback' => array($this, 'callbackColumnStatus')
|
178 |
+
));
|
179 |
+
|
180 |
+
return parent::_prepareColumns();
|
181 |
+
}
|
182 |
+
|
183 |
+
protected function _prepareMassaction()
|
184 |
+
{
|
185 |
+
// Set massaction identifiers
|
186 |
+
//--------------------------------
|
187 |
+
$this->setMassactionIdField('id');
|
188 |
+
$this->setMassactionIdFieldOnlyIndexValue(true);
|
189 |
+
//--------------------------------
|
190 |
+
|
191 |
+
// Set mass-action
|
192 |
+
//--------------------------------
|
193 |
+
$this->getMassactionBlock()->addItem('list', array(
|
194 |
+
'label' => Mage::helper('M2ePro')->__('List Item(s)'),
|
195 |
+
'url' => '',
|
196 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
197 |
+
));
|
198 |
+
|
199 |
+
$this->getMassactionBlock()->addItem('revise', array(
|
200 |
+
'label' => Mage::helper('M2ePro')->__('Revise Item(s)'),
|
201 |
+
'url' => '',
|
202 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
203 |
+
));
|
204 |
+
|
205 |
+
$this->getMassactionBlock()->addItem('relist', array(
|
206 |
+
'label' => Mage::helper('M2ePro')->__('Relist Item(s)'),
|
207 |
+
'url' => '',
|
208 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
209 |
+
));
|
210 |
+
|
211 |
+
$this->getMassactionBlock()->addItem('stop', array(
|
212 |
+
'label' => Mage::helper('M2ePro')->__('Stop Item(s)'),
|
213 |
+
'url' => '',
|
214 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
215 |
+
));
|
216 |
+
|
217 |
+
$this->getMassactionBlock()->addItem('stopAndRemove', array(
|
218 |
+
'label' => Mage::helper('M2ePro')->__('Stop on Channel / Remove from Listing'),
|
219 |
+
'url' => '',
|
220 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
221 |
+
));
|
222 |
+
|
223 |
+
$this->getMassactionBlock()->addItem('deleteAndRemove', array(
|
224 |
+
'label' => Mage::helper('M2ePro')->__('Remove from Channel & Listing'),
|
225 |
+
'url' => '',
|
226 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
227 |
+
));
|
228 |
+
|
229 |
+
//--------------------------------
|
230 |
+
|
231 |
+
return parent::_prepareMassaction();
|
232 |
+
}
|
233 |
+
|
234 |
+
// ####################################
|
235 |
+
|
236 |
+
public function callbackColumnProductOptions($additionalData, $row, $column, $isExport)
|
237 |
+
{
|
238 |
+
$html = '';
|
239 |
+
|
240 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager_Type_Relation_Child $typeModel */
|
241 |
+
$typeModel = $row->getChildObject()->getVariationManager()->getTypeModel();
|
242 |
+
|
243 |
+
$html .= '<div class="product-options-main" style="font-size: 11px; color: grey; margin-left: 7px">';
|
244 |
+
$productOptions = $typeModel->getProductOptions();
|
245 |
+
if (!empty($productOptions)) {
|
246 |
+
$html .= '<div class="product-options-list">';
|
247 |
+
foreach ($productOptions as $attribute => $option) {
|
248 |
+
!$option && $option = '--';
|
249 |
+
$html .= '<span class="attribute-row"><span class="attribute"><strong>' .
|
250 |
+
Mage::helper('M2ePro')->escapeHtml($attribute) .
|
251 |
+
'</strong></span>: <span class="value">' . Mage::helper('M2ePro')->escapeHtml($option) .
|
252 |
+
'</span></span><br/>';
|
253 |
+
}
|
254 |
+
$html .= '</div>';
|
255 |
+
}
|
256 |
+
|
257 |
+
if ($this->canChangeProductVariation($row)) {
|
258 |
+
|
259 |
+
$listingProductId = $row->getId();
|
260 |
+
$attributes = $this->getListingProduct()->getChildObject()
|
261 |
+
->getVariationManager()->getTypeModel()->getProductAttributes();
|
262 |
+
$variationsTree = $this->getProductVariationsTree($row);
|
263 |
+
|
264 |
+
sort($attributes);
|
265 |
+
|
266 |
+
$linkTitle = Mage::helper('M2ePro')->__('Change Variation');
|
267 |
+
$linkContent = Mage::helper('M2ePro')->__('Change Variation');
|
268 |
+
|
269 |
+
$attributes = Mage::helper('M2ePro')->escapeHtml(json_encode($attributes));
|
270 |
+
$variationsTree = Mage::helper('M2ePro')->escapeHtml(json_encode($variationsTree));
|
271 |
+
|
272 |
+
$html .= <<<HTML
|
273 |
+
<form action="javascript:void(0);" class="product-options-edit"></form>
|
274 |
+
<a href="javascript:"
|
275 |
+
onclick="ListingGridHandlerObj.editProductOptions(this, {$attributes}, {$variationsTree}, {$listingProductId})"
|
276 |
+
title="{$linkTitle}">{$linkContent}</a>
|
277 |
+
HTML;
|
278 |
+
}
|
279 |
+
|
280 |
+
$html .= '</div>';
|
281 |
+
|
282 |
+
return $html;
|
283 |
+
}
|
284 |
+
|
285 |
+
public function callbackColumnChannelOptions($additionalData, $row, $column, $isExport)
|
286 |
+
{
|
287 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product $amazonListingProduct */
|
288 |
+
$amazonListingProduct = $row->getChildObject();
|
289 |
+
|
290 |
+
$typeModel = $amazonListingProduct->getVariationManager()->getTypeModel();
|
291 |
+
|
292 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product $parentAmazonListingProduct */
|
293 |
+
$parentAmazonListingProduct = $typeModel->getParentListingProduct()->getChildObject();
|
294 |
+
|
295 |
+
$matchedAttributes = $parentAmazonListingProduct->getVariationManager()
|
296 |
+
->getTypeModel()
|
297 |
+
->getMatchedAttributes();
|
298 |
+
|
299 |
+
if (!$typeModel->isVariationChannelMatched()) {
|
300 |
+
if (!$typeModel->isVariationProductMatched() || !$amazonListingProduct->isGeneralIdOwner()) {
|
301 |
+
return '';
|
302 |
+
}
|
303 |
+
|
304 |
+
if (empty($matchedAttributes)) {
|
305 |
+
return '';
|
306 |
+
}
|
307 |
+
|
308 |
+
$options = array();
|
309 |
+
|
310 |
+
foreach ($typeModel->getProductOptions() as $attribute => $value) {
|
311 |
+
$options[$matchedAttributes[$attribute]] = $value;
|
312 |
+
}
|
313 |
+
} else {
|
314 |
+
$options = $typeModel->getChannelOptions();
|
315 |
+
|
316 |
+
if (!empty($matchedAttributes)) {
|
317 |
+
|
318 |
+
$sortedOptions = array();
|
319 |
+
|
320 |
+
foreach ($matchedAttributes as $magentoAttr => $amazonAttr) {
|
321 |
+
$sortedOptions[$amazonAttr] = $options[$amazonAttr];
|
322 |
+
}
|
323 |
+
|
324 |
+
$options = $sortedOptions;
|
325 |
+
}
|
326 |
+
}
|
327 |
+
|
328 |
+
if (empty($options)) {
|
329 |
+
return '';
|
330 |
+
}
|
331 |
+
|
332 |
+
$generalId = $amazonListingProduct->getGeneralId();
|
333 |
+
|
334 |
+
$html = '<div style="font-size: 11px; color: grey; margin-left: 7px">';
|
335 |
+
|
336 |
+
foreach ($options as $attribute => $option) {
|
337 |
+
!$option && $option = '--';
|
338 |
+
|
339 |
+
$attrName = Mage::helper('M2ePro')->escapeHtml($attribute);
|
340 |
+
$optionName = Mage::helper('M2ePro')->escapeHtml($option);
|
341 |
+
|
342 |
+
if (empty($generalId) && $amazonListingProduct->isGeneralIdOwner()) {
|
343 |
+
$html .= <<<HTML
|
344 |
+
{$attrName}: {$optionName}<br/>
|
345 |
+
HTML;
|
346 |
+
} else {
|
347 |
+
$html .= <<<HTML
|
348 |
+
<b>{$attrName}</b>: {$optionName}<br/>
|
349 |
+
HTML;
|
350 |
+
}
|
351 |
+
|
352 |
+
}
|
353 |
+
|
354 |
+
$html .= '</div>';
|
355 |
+
|
356 |
+
return $html;
|
357 |
+
}
|
358 |
+
|
359 |
+
public function callbackColumnAmazonSku($sku, $row, $column, $isExport)
|
360 |
+
{
|
361 |
+
if (is_null($sku) || $sku === '') {
|
362 |
+
return Mage::helper('M2ePro')->__('N/A');
|
363 |
+
}
|
364 |
+
return $sku;
|
365 |
+
}
|
366 |
+
|
367 |
+
public function callbackColumnGeneralId($generalId, $row, $column, $isExport)
|
368 |
+
{
|
369 |
+
if (is_null($generalId) || $generalId === '') {
|
370 |
+
|
371 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product $amazonListingProduct */
|
372 |
+
$amazonListingProduct = $this->getListingProduct()->getChildObject();
|
373 |
+
if ($amazonListingProduct->isGeneralIdOwner()) {
|
374 |
+
return Mage::helper('M2ePro')->__('New ASIN/ISBN');
|
375 |
+
}
|
376 |
+
|
377 |
+
return Mage::helper('M2ePro')->__('N/A');
|
378 |
+
}
|
379 |
+
return $this->getGeneralIdLink($generalId);
|
380 |
+
}
|
381 |
+
|
382 |
+
public function callbackColumnAvailableQty($qty, $row, $column, $isExport)
|
383 |
+
{
|
384 |
+
if (is_null($qty) || $qty === '') {
|
385 |
+
return Mage::helper('M2ePro')->__('N/A');
|
386 |
+
}
|
387 |
+
return $qty;
|
388 |
+
}
|
389 |
+
|
390 |
+
public function callbackColumnPrice($value, $row, $column, $isExport)
|
391 |
+
{
|
392 |
+
if (is_null($value) || $value === '') {
|
393 |
+
return Mage::helper('M2ePro')->__('N/A');
|
394 |
+
}
|
395 |
+
|
396 |
+
$marketplaceId = $this->getListingProduct()->getListing()->getMarketplaceId();
|
397 |
+
$currency = Mage::helper('M2ePro/Component_Amazon')
|
398 |
+
->getCachedObject('Marketplace',$marketplaceId)
|
399 |
+
->getChildObject()
|
400 |
+
->getDefaultCurrency();
|
401 |
+
|
402 |
+
if ((float)$value <= 0) {
|
403 |
+
$priceValue = '<span style="color: #f00;">0</span>';
|
404 |
+
} else {
|
405 |
+
$priceValue = Mage::app()->getLocale()->currency($currency)->toCurrency($value);
|
406 |
+
}
|
407 |
+
|
408 |
+
$resultHtml = '';
|
409 |
+
|
410 |
+
$salePriceValue = $row->getData('online_sale_price');
|
411 |
+
if ((float)$salePriceValue > 0) {
|
412 |
+
$startDateTimestamp = strtotime($row->getData('online_sale_price_start_date'));
|
413 |
+
$endDateTimestamp = strtotime($row->getData('online_sale_price_end_date'));
|
414 |
+
|
415 |
+
$currentTimestamp = strtotime(Mage::helper('M2ePro')->getCurrentGmtDate(false,'Y-m-d 00:00:00'));
|
416 |
+
|
417 |
+
if ($currentTimestamp >= $startDateTimestamp &&
|
418 |
+
$currentTimestamp <= $endDateTimestamp &&
|
419 |
+
$salePriceValue < (float)$value
|
420 |
+
) {
|
421 |
+
$resultHtml = '<span style="text-decoration: line-through;">'.$priceValue.'</span>';
|
422 |
+
} else {
|
423 |
+
$resultHtml = $priceValue;
|
424 |
+
}
|
425 |
+
|
426 |
+
$salePriceValue = Mage::app()->getLocale()->currency($currency)->toCurrency($salePriceValue);
|
427 |
+
|
428 |
+
$resultHtml .= ' <br/><br/><span style="color:gray;">'.$salePriceValue.'</span><br/>';
|
429 |
+
|
430 |
+
$resultHtml .= '<span style="color:gray; font-size: 10px;">
|
431 |
+
From: '.date('Y-m-d', $startDateTimestamp).'<br/>
|
432 |
+
To: '.date('Y-m-d', $endDateTimestamp).'
|
433 |
+
</span>';
|
434 |
+
}
|
435 |
+
|
436 |
+
if (empty($resultHtml)) {
|
437 |
+
$resultHtml = $priceValue;
|
438 |
+
}
|
439 |
+
|
440 |
+
return $resultHtml;
|
441 |
+
}
|
442 |
+
|
443 |
+
public function callbackColumnStatus($value, $row, $column, $isExport)
|
444 |
+
{
|
445 |
+
$listingProductId = (int)$row->getData('id');
|
446 |
+
|
447 |
+
$html = $this->getViewLogIconHtml($row);
|
448 |
+
|
449 |
+
/** @var Ess_M2ePro_Model_Listing_Product $listingProduct */
|
450 |
+
$listingProduct = Mage::helper('M2ePro/Component_Amazon')->getObject('Listing_Product',$listingProductId);
|
451 |
+
|
452 |
+
$synchNote = $listingProduct->getSetting('additional_data', 'synch_template_list_rules_note');
|
453 |
+
if (!empty($synchNote)) {
|
454 |
+
|
455 |
+
$synchNote = Mage::helper('M2ePro/View')->getModifiedLogMessage($synchNote);
|
456 |
+
|
457 |
+
if (empty($html)) {
|
458 |
+
$html = <<<HTML
|
459 |
+
<span style="float:right;">
|
460 |
+
<img id="map_link_error_icon_{$row->getId()}"
|
461 |
+
class="tool-tip-image"
|
462 |
+
style="vertical-align: middle;"
|
463 |
+
src="{$this->getSkinUrl('M2ePro/images/warning.png')}">
|
464 |
+
<span class="tool-tip-message tool-tip-warning tip-left" style="display:none;">
|
465 |
+
<img src="{$this->getSkinUrl('M2ePro/images/i_notice.gif')}">
|
466 |
+
<span>{$synchNote}</span>
|
467 |
+
</span>
|
468 |
+
</span>
|
469 |
+
HTML;
|
470 |
+
} else {
|
471 |
+
$html .= <<<HTML
|
472 |
+
<div id="synch_template_list_rules_note_{$listingProductId}" style="display: none">{$synchNote}</div>
|
473 |
+
HTML;
|
474 |
+
}
|
475 |
+
}
|
476 |
+
|
477 |
+
switch ($row->getData('status')) {
|
478 |
+
|
479 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_UNKNOWN:
|
480 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED:
|
481 |
+
$html .= '<span style="color: gray;">' . $value . '</span>';
|
482 |
+
break;
|
483 |
+
|
484 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_LISTED:
|
485 |
+
$html .= '<span style="color: green;">' . $value . '</span>';
|
486 |
+
break;
|
487 |
+
|
488 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED:
|
489 |
+
$html .= '<span style="color: red;">'.$value.'</span>';
|
490 |
+
break;
|
491 |
+
|
492 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_BLOCKED:
|
493 |
+
$html .= '<span style="color: orange; font-weight: bold;">'.$value.'</span>';
|
494 |
+
break;
|
495 |
+
|
496 |
+
default:
|
497 |
+
break;
|
498 |
+
}
|
499 |
+
|
500 |
+
$tempLocks = $this->getLockedData($row);
|
501 |
+
$tempLocks = $tempLocks['object_locks'];
|
502 |
+
|
503 |
+
foreach ($tempLocks as $lock) {
|
504 |
+
|
505 |
+
switch ($lock->getTag()) {
|
506 |
+
|
507 |
+
case 'list_action':
|
508 |
+
$html .= '<br/><span style="color: #605fff">[Listing...]</span>';
|
509 |
+
break;
|
510 |
+
|
511 |
+
case 'relist_action':
|
512 |
+
$html .= '<br/><span style="color: #605fff">[Relisting...]</span>';
|
513 |
+
break;
|
514 |
+
|
515 |
+
case 'revise_action':
|
516 |
+
$html .= '<br/><span style="color: #605fff">[Revising...]</span>';
|
517 |
+
break;
|
518 |
+
|
519 |
+
case 'stop_action':
|
520 |
+
$html .= '<br/><span style="color: #605fff">[Stopping...]</span>';
|
521 |
+
break;
|
522 |
+
|
523 |
+
case 'stop_and_remove_action':
|
524 |
+
$html .= '<br/><span style="color: #605fff">[Stopping...]</span>';
|
525 |
+
break;
|
526 |
+
|
527 |
+
case 'delete_and_remove_action':
|
528 |
+
$html .= '<br/><span style="color: #605fff">[Removing...]</span>';
|
529 |
+
break;
|
530 |
+
|
531 |
+
default:
|
532 |
+
break;
|
533 |
+
|
534 |
+
}
|
535 |
+
}
|
536 |
+
|
537 |
+
return $html;
|
538 |
+
}
|
539 |
+
|
540 |
+
public function callbackProductOptions($collection, $column)
|
541 |
+
{
|
542 |
+
$values = $column->getFilter()->getValue();
|
543 |
+
|
544 |
+
if ($values == null && !is_array($values)) {
|
545 |
+
return;
|
546 |
+
}
|
547 |
+
|
548 |
+
foreach ($values as $value) {
|
549 |
+
if(is_array($value) && isset($value['value'])) {
|
550 |
+
$collection->addFieldToFilter(
|
551 |
+
'additional_data',
|
552 |
+
array('regexp'=> '"variation_product_options":[^}]*'.$value['attr'].'":"' .
|
553 |
+
// trying to screen slashes that in json
|
554 |
+
addslashes(addslashes($value['value'])))
|
555 |
+
);
|
556 |
+
}
|
557 |
+
}
|
558 |
+
}
|
559 |
+
|
560 |
+
public function callbackChannelOptions($collection, $column)
|
561 |
+
{
|
562 |
+
$values = $column->getFilter()->getValue();
|
563 |
+
|
564 |
+
if ($values == null && !is_array($values)) {
|
565 |
+
return;
|
566 |
+
}
|
567 |
+
|
568 |
+
foreach ($values as $value) {
|
569 |
+
if(is_array($value) && isset($value['value'])) {
|
570 |
+
$collection->addFieldToFilter(
|
571 |
+
'additional_data',
|
572 |
+
array('regexp'=> '"variation_channel_options":[^}]*'.$value['attr'].'":"' .
|
573 |
+
// trying to screen slashes that in json
|
574 |
+
addslashes(addslashes($value['value'])))
|
575 |
+
);
|
576 |
+
}
|
577 |
+
}
|
578 |
+
}
|
579 |
+
|
580 |
+
protected function callbackFilterPrice($collection, $column)
|
581 |
+
{
|
582 |
+
$value = $column->getFilter()->getValue();
|
583 |
+
|
584 |
+
if (empty($value)) {
|
585 |
+
return;
|
586 |
+
}
|
587 |
+
|
588 |
+
$from = $value['from'];
|
589 |
+
$to = $value['to'];
|
590 |
+
|
591 |
+
$collection->getSelect()->where(
|
592 |
+
'(online_price >= \''.$from.'\' AND online_price <= \''.$to.'\' AND
|
593 |
+
(
|
594 |
+
online_sale_price IS NULL OR
|
595 |
+
online_sale_price_start_date > NOW() OR
|
596 |
+
online_sale_price_end_date < NOW()
|
597 |
+
)) OR (online_sale_price >= \''.$from.'\' AND online_sale_price <= \''.$to.'\' AND
|
598 |
+
(
|
599 |
+
online_sale_price IS NOT NULL AND
|
600 |
+
online_sale_price_start_date < NOW() AND
|
601 |
+
online_sale_price_end_date > NOW()
|
602 |
+
))'
|
603 |
+
);
|
604 |
+
}
|
605 |
+
|
606 |
+
// ####################################
|
607 |
+
|
608 |
+
/**
|
609 |
+
* @param Ess_M2ePro_Model_Listing_Product $listingProduct
|
610 |
+
* @return string
|
611 |
+
*/
|
612 |
+
public function getViewLogIconHtml($listingProduct)
|
613 |
+
{
|
614 |
+
$listingProductId = (int)$listingProduct->getId();
|
615 |
+
|
616 |
+
// Get last messages
|
617 |
+
//--------------------------
|
618 |
+
/** @var $connRead Varien_Db_Adapter_Pdo_Mysql */
|
619 |
+
$connRead = Mage::getSingleton('core/resource')->getConnection('core_read');
|
620 |
+
|
621 |
+
$dbSelect = $connRead->select()
|
622 |
+
->from(
|
623 |
+
Mage::getResourceModel('M2ePro/Listing_Log')->getMainTable(),
|
624 |
+
array('action_id','action','type','description','create_date','initiator')
|
625 |
+
)
|
626 |
+
->where('`listing_product_id` = ?', $listingProductId)
|
627 |
+
->where('`action_id` IS NOT NULL')
|
628 |
+
->order(array('id DESC'))
|
629 |
+
->limit(30);
|
630 |
+
|
631 |
+
$logRows = $connRead->fetchAll($dbSelect);
|
632 |
+
//--------------------------
|
633 |
+
|
634 |
+
// Get grouped messages by action_id
|
635 |
+
//--------------------------
|
636 |
+
$actionsRows = array();
|
637 |
+
$tempActionRows = array();
|
638 |
+
$lastActionId = false;
|
639 |
+
|
640 |
+
foreach ($logRows as $row) {
|
641 |
+
|
642 |
+
$row['description'] = Mage::helper('M2ePro/View')->getModifiedLogMessage($row['description']);
|
643 |
+
|
644 |
+
if ($row['action_id'] !== $lastActionId) {
|
645 |
+
if (count($tempActionRows) > 0) {
|
646 |
+
$actionsRows[] = array(
|
647 |
+
'type' => $this->getMainTypeForActionId($tempActionRows),
|
648 |
+
'date' => $this->getMainDateForActionId($tempActionRows),
|
649 |
+
'action' => $this->getActionForAction($tempActionRows[0]),
|
650 |
+
'initiator' => $this->getInitiatorForAction($tempActionRows[0]),
|
651 |
+
'items' => $tempActionRows
|
652 |
+
);
|
653 |
+
$tempActionRows = array();
|
654 |
+
}
|
655 |
+
$lastActionId = $row['action_id'];
|
656 |
+
}
|
657 |
+
$tempActionRows[] = $row;
|
658 |
+
}
|
659 |
+
|
660 |
+
if (count($tempActionRows) > 0) {
|
661 |
+
$actionsRows[] = array(
|
662 |
+
'type' => $this->getMainTypeForActionId($tempActionRows),
|
663 |
+
'date' => $this->getMainDateForActionId($tempActionRows),
|
664 |
+
'action' => $this->getActionForAction($tempActionRows[0]),
|
665 |
+
'initiator' => $this->getInitiatorForAction($tempActionRows[0]),
|
666 |
+
'items' => $tempActionRows
|
667 |
+
);
|
668 |
+
}
|
669 |
+
|
670 |
+
if (count($actionsRows) <= 0) {
|
671 |
+
return '';
|
672 |
+
}
|
673 |
+
|
674 |
+
foreach ($actionsRows as &$actionsRow) {
|
675 |
+
usort($actionsRow['items'], function($a, $b)
|
676 |
+
{
|
677 |
+
$sortOrder = array(
|
678 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 1,
|
679 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 2,
|
680 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 3,
|
681 |
+
);
|
682 |
+
|
683 |
+
return $sortOrder[$a["type"]] > $sortOrder[$b["type"]];
|
684 |
+
});
|
685 |
+
}
|
686 |
+
|
687 |
+
$tips = array(
|
688 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'Last Action was completed successfully.',
|
689 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'Last Action was completed with error(s).',
|
690 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'Last Action was completed with warning(s).'
|
691 |
+
);
|
692 |
+
|
693 |
+
$icons = array(
|
694 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'normal',
|
695 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'error',
|
696 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'warning'
|
697 |
+
);
|
698 |
+
|
699 |
+
$summary = $this->getLayout()->createBlock('M2ePro/adminhtml_log_grid_summary', '', array(
|
700 |
+
'entity_id' => (int)$listingProduct->getId(),
|
701 |
+
'rows' => $actionsRows,
|
702 |
+
'tips' => $tips,
|
703 |
+
'icons' => $icons,
|
704 |
+
'view_help_handler' => 'ListingGridHandlerObj.viewItemHelp',
|
705 |
+
'hide_help_handler' => 'ListingGridHandlerObj.hideItemHelp',
|
706 |
+
));
|
707 |
+
|
708 |
+
return $summary->toHtml();
|
709 |
+
}
|
710 |
+
|
711 |
+
public function getActionForAction($actionRows)
|
712 |
+
{
|
713 |
+
$string = '';
|
714 |
+
|
715 |
+
switch ($actionRows['action']) {
|
716 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_LIST_PRODUCT_ON_COMPONENT:
|
717 |
+
$string = Mage::helper('M2ePro')->__('List');
|
718 |
+
break;
|
719 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_RELIST_PRODUCT_ON_COMPONENT:
|
720 |
+
$string = Mage::helper('M2ePro')->__('Relist');
|
721 |
+
break;
|
722 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_REVISE_PRODUCT_ON_COMPONENT:
|
723 |
+
$string = Mage::helper('M2ePro')->__('Revise');
|
724 |
+
break;
|
725 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_STOP_PRODUCT_ON_COMPONENT:
|
726 |
+
$string = Mage::helper('M2ePro')->__('Stop');
|
727 |
+
break;
|
728 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_DELETE_PRODUCT_FROM_COMPONENT:
|
729 |
+
$string = Mage::helper('M2ePro')->__('Remove from Channel');
|
730 |
+
break;
|
731 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_STOP_AND_REMOVE_PRODUCT:
|
732 |
+
$string = Mage::helper('M2ePro')->__('Stop on Channel / Remove from Listing');
|
733 |
+
break;
|
734 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_DELETE_AND_REMOVE_PRODUCT:
|
735 |
+
$string = Mage::helper('M2ePro')->__('Remove from Channel & Listing');
|
736 |
+
break;
|
737 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_CHANGE_STATUS_ON_CHANNEL:
|
738 |
+
$string = Mage::helper('M2ePro')->__('Status Change');
|
739 |
+
break;
|
740 |
+
}
|
741 |
+
|
742 |
+
return $string;
|
743 |
+
}
|
744 |
+
|
745 |
+
public function getInitiatorForAction($actionRows)
|
746 |
+
{
|
747 |
+
$string = '';
|
748 |
+
|
749 |
+
switch ((int)$actionRows['initiator']) {
|
750 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_UNKNOWN:
|
751 |
+
$string = '';
|
752 |
+
break;
|
753 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_USER:
|
754 |
+
$string = Mage::helper('M2ePro')->__('Manual');
|
755 |
+
break;
|
756 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION:
|
757 |
+
$string = Mage::helper('M2ePro')->__('Automatic');
|
758 |
+
break;
|
759 |
+
}
|
760 |
+
|
761 |
+
return $string;
|
762 |
+
}
|
763 |
+
|
764 |
+
public function getMainTypeForActionId($actionRows)
|
765 |
+
{
|
766 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS;
|
767 |
+
|
768 |
+
foreach ($actionRows as $row) {
|
769 |
+
if ($row['type'] == Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR) {
|
770 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR;
|
771 |
+
break;
|
772 |
+
}
|
773 |
+
if ($row['type'] == Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING) {
|
774 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING;
|
775 |
+
}
|
776 |
+
}
|
777 |
+
|
778 |
+
return $type;
|
779 |
+
}
|
780 |
+
|
781 |
+
public function getMainDateForActionId($actionRows)
|
782 |
+
{
|
783 |
+
$format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
|
784 |
+
return Mage::app()->getLocale()->date(strtotime($actionRows[0]['create_date']))->toString($format);
|
785 |
+
}
|
786 |
+
|
787 |
+
// ####################################
|
788 |
+
|
789 |
+
public function getMainButtonsHtml()
|
790 |
+
{
|
791 |
+
$html = '';
|
792 |
+
if($this->getFilterVisibility()){
|
793 |
+
$html.= $this->getAddNewChildButtonsHtml();
|
794 |
+
$html.= $this->getResetFilterButtonHtml();
|
795 |
+
$html.= $this->getSearchButtonHtml();
|
796 |
+
}
|
797 |
+
return $html;
|
798 |
+
}
|
799 |
+
|
800 |
+
public function getMassactionBlockHtml()
|
801 |
+
{
|
802 |
+
if ($this->isNewChildAllowed()) {
|
803 |
+
$blockName = 'adminhtml_common_amazon_listing_variation_product_manage_tabs_variations_child_form';
|
804 |
+
$form = $this->getLayout()->createBlock('M2ePro/'.$blockName);
|
805 |
+
$form->setListingProductId($this->getListingProductId());
|
806 |
+
|
807 |
+
return $form->toHtml() . parent::getMassactionBlockHtml();
|
808 |
+
}
|
809 |
+
|
810 |
+
return parent::getMassactionBlockHtml();
|
811 |
+
}
|
812 |
+
|
813 |
+
private function getAddNewChildButtonsHtml()
|
814 |
+
{
|
815 |
+
if ($this->isNewChildAllowed()) {
|
816 |
+
|
817 |
+
//------------------------------
|
818 |
+
$data = array(
|
819 |
+
'label' => Mage::helper('adminhtml')->__('Add New Child Product'),
|
820 |
+
'onclick' => 'ListingGridHandlerObj.showNewChildForm('. !$this->hasUnusedChannelVariations() .')',
|
821 |
+
'class' => 'task',
|
822 |
+
'id' => 'add_new_child_button'
|
823 |
+
);
|
824 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
825 |
+
$this->setChild('add_new_child_button', $buttonBlock);
|
826 |
+
//------------------------------
|
827 |
+
|
828 |
+
}
|
829 |
+
|
830 |
+
return $this->getChildHtml('add_new_child_button');
|
831 |
+
}
|
832 |
+
|
833 |
+
protected function isNewChildAllowed()
|
834 |
+
{
|
835 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product $amazonListingProduct */
|
836 |
+
$amazonListingProduct = $this->getListingProduct()->getChildObject();
|
837 |
+
|
838 |
+
if (!$amazonListingProduct->getGeneralId()) {
|
839 |
+
return false;
|
840 |
+
}
|
841 |
+
|
842 |
+
if (!$amazonListingProduct->getVariationManager()->getTypeModel()->hasMatchedAttributes()) {
|
843 |
+
return false;
|
844 |
+
}
|
845 |
+
|
846 |
+
if (!$this->hasUnusedProductVariation()) {
|
847 |
+
return false;
|
848 |
+
}
|
849 |
+
|
850 |
+
if ($this->hasChildWithEmptyProductOptions()) {
|
851 |
+
return false;
|
852 |
+
}
|
853 |
+
|
854 |
+
if (!$this->isGeneralIdOwner() && !$this->hasUnusedChannelVariations()) {
|
855 |
+
return false;
|
856 |
+
}
|
857 |
+
|
858 |
+
if (!$this->isGeneralIdOwner() && $this->hasChildWithEmptyChannelOptions()) {
|
859 |
+
return false;
|
860 |
+
}
|
861 |
+
|
862 |
+
return true;
|
863 |
+
}
|
864 |
+
|
865 |
+
public function isGeneralIdOwner()
|
866 |
+
{
|
867 |
+
return $this->getListingProduct()->getChildObject()->isGeneralIdOwner();
|
868 |
+
}
|
869 |
+
|
870 |
+
public function getCurrentChannelVariations()
|
871 |
+
{
|
872 |
+
return $this->getListingProduct()->getChildObject()
|
873 |
+
->getVariationManager()->getTypeModel()->getChannelVariations();
|
874 |
+
}
|
875 |
+
|
876 |
+
public function hasUnusedProductVariation()
|
877 |
+
{
|
878 |
+
return count($this->getChildListingProducts()) < count($this->getCurrentProductVariations());
|
879 |
+
}
|
880 |
+
|
881 |
+
public function hasUnusedChannelVariations()
|
882 |
+
{
|
883 |
+
return count($this->getUsedChannelVariations()) < count($this->getCurrentChannelVariations());
|
884 |
+
}
|
885 |
+
|
886 |
+
public function hasChildWithEmptyProductOptions()
|
887 |
+
{
|
888 |
+
foreach ($this->getChildListingProducts() as $childListingProduct) {
|
889 |
+
/** @var Ess_M2ePro_Model_Listing_Product $childListingProduct */
|
890 |
+
|
891 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager_Type_Relation_Child $childTypeModel */
|
892 |
+
$childTypeModel = $childListingProduct->getChildObject()->getVariationManager()->getTypeModel();
|
893 |
+
|
894 |
+
if (!$childTypeModel->isVariationProductMatched()) {
|
895 |
+
return true;
|
896 |
+
}
|
897 |
+
}
|
898 |
+
|
899 |
+
return false;
|
900 |
+
}
|
901 |
+
|
902 |
+
public function hasChildWithEmptyChannelOptions()
|
903 |
+
{
|
904 |
+
foreach ($this->getChildListingProducts() as $childListingProduct) {
|
905 |
+
/** @var Ess_M2ePro_Model_Listing_Product $childListingProduct */
|
906 |
+
|
907 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager_Type_Relation_Child $childTypeModel */
|
908 |
+
$childTypeModel = $childListingProduct->getChildObject()->getVariationManager()->getTypeModel();
|
909 |
+
|
910 |
+
if (!$childTypeModel->isVariationChannelMatched()) {
|
911 |
+
return true;
|
912 |
+
}
|
913 |
+
}
|
914 |
+
|
915 |
+
return false;
|
916 |
+
}
|
917 |
+
|
918 |
+
public function getUsedChannelVariations()
|
919 |
+
{
|
920 |
+
$usedOptions = array();
|
921 |
+
|
922 |
+
foreach ($this->getChildListingProducts() as $childListingProduct) {
|
923 |
+
/** @var Ess_M2ePro_Model_Listing_Product $childListingProduct */
|
924 |
+
|
925 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager_Type_Relation_Child $childTypeModel */
|
926 |
+
$childTypeModel = $childListingProduct->getChildObject()->getVariationManager()->getTypeModel();
|
927 |
+
|
928 |
+
if (!$childTypeModel->isVariationChannelMatched()) {
|
929 |
+
continue;
|
930 |
+
}
|
931 |
+
|
932 |
+
$usedOptions[] = $childTypeModel->getChannelOptions();
|
933 |
+
}
|
934 |
+
|
935 |
+
return $usedOptions;
|
936 |
+
}
|
937 |
+
|
938 |
+
// ------------------------------------
|
939 |
+
|
940 |
+
public function getGridUrl()
|
941 |
+
{
|
942 |
+
return $this->getUrl('*/adminhtml_common_amazon_listing_variation_product_manage/viewVariationsGridAjax', array(
|
943 |
+
'_current' => true
|
944 |
+
));
|
945 |
+
}
|
946 |
+
|
947 |
+
public function getRowUrl($row)
|
948 |
+
{
|
949 |
+
return false;
|
950 |
+
}
|
951 |
+
|
952 |
+
// ####################################
|
953 |
+
|
954 |
+
protected function _toHtml()
|
955 |
+
{
|
956 |
+
$listingId = $this->getListingProduct()->getListingId();
|
957 |
+
|
958 |
+
/** @var $helper Ess_M2ePro_Helper_Data */
|
959 |
+
$helper = Mage::helper('M2ePro');
|
960 |
+
|
961 |
+
//------------------------------
|
962 |
+
$urls = array();
|
963 |
+
|
964 |
+
$path = 'adminhtml_common_log/listingProduct';
|
965 |
+
$urls[$path] = $this->getUrl('*/' . $path, array(
|
966 |
+
'channel' => Ess_M2ePro_Helper_Component_Amazon::NICK,
|
967 |
+
'back'=>$helper->makeBackUrlParam('*/adminhtml_common_amazon_listing/view',array('id' => $listingId))
|
968 |
+
));
|
969 |
+
|
970 |
+
$urls['adminhtml_common_amazon_listing_variation_product_manage/createNewChild'] = $this->getUrl(
|
971 |
+
'*/adminhtml_common_amazon_listing_variation_product_manage/createNewChild');
|
972 |
+
|
973 |
+
$urls = json_encode($urls);
|
974 |
+
//------------------------------
|
975 |
+
|
976 |
+
$component = Ess_M2ePro_Helper_Component_Amazon::NICK;
|
977 |
+
|
978 |
+
$logViewUrl = $this->getUrl('*/adminhtml_common_log/listing', array(
|
979 |
+
'id' =>$listingId,
|
980 |
+
'channel' => Ess_M2ePro_Block_Adminhtml_Common_Log_Tabs::TAB_ID_AMAZON,
|
981 |
+
'back'=>$helper->makeBackUrlParam('*/adminhtml_common_amazon_listing/view', array('id' => $listingId))
|
982 |
+
));
|
983 |
+
|
984 |
+
$checkLockListing = $this->getUrl('*/adminhtml_listing/checkLockListing', array('component' => $component));
|
985 |
+
$lockListingNow = $this->getUrl('*/adminhtml_listing/lockListingNow', array('component' => $component));
|
986 |
+
$unlockListingNow = $this->getUrl('*/adminhtml_listing/unlockListingNow', array('component' => $component));
|
987 |
+
$getErrorsSummary = $this->getUrl('*/adminhtml_listing/getErrorsSummary');
|
988 |
+
|
989 |
+
$runListProducts = $this->getUrl('*/adminhtml_common_amazon_listing/runListProducts');
|
990 |
+
$runReviseProducts = $this->getUrl('*/adminhtml_common_amazon_listing/runReviseProducts');
|
991 |
+
$runRelistProducts = $this->getUrl('*/adminhtml_common_amazon_listing/runRelistProducts');
|
992 |
+
$runStopProducts = $this->getUrl('*/adminhtml_common_amazon_listing/runStopProducts');
|
993 |
+
$runStopAndRemoveProducts = $this->getUrl('*/adminhtml_common_amazon_listing/runStopAndRemoveProducts');
|
994 |
+
$runDeleteAndRemoveProducts = $this->getUrl('*/adminhtml_common_amazon_listing/runDeleteAndRemoveProducts');
|
995 |
+
|
996 |
+
$setChildListingProductOptions = $this->getUrl(
|
997 |
+
'*/adminhtml_common_amazon_listing_variation_product_manage/setChildListingProductOptions');
|
998 |
+
|
999 |
+
$taskCompletedMessage = $helper->escapeJs($helper->__('Task completed. Please wait ...'));
|
1000 |
+
$taskCompletedSuccessMessage = $helper->escapeJs(
|
1001 |
+
$helper->__('"%task_title%" Task has successfully submitted to be processed.')
|
1002 |
+
);
|
1003 |
+
$taskCompletedWarningMessage = $helper->escapeJs($helper->__(
|
1004 |
+
'"%task_title%" Task has completed with warnings.
|
1005 |
+
<a target="_blank" href="%url%">View Log</a> for details.'
|
1006 |
+
));
|
1007 |
+
$taskCompletedErrorMessage = $helper->escapeJs($helper->__(
|
1008 |
+
'"%task_title%" Task has completed with errors. <a target="_blank" href="%url%">View Log</a> for details.'
|
1009 |
+
));
|
1010 |
+
|
1011 |
+
$lockedObjNoticeMessage = $helper->escapeJs($helper->__('Some Amazon request(s) are being processed now.'));
|
1012 |
+
$sendingDataToAmazonMessage = $helper->escapeJs($helper->__(
|
1013 |
+
'Sending %product_title% Product(s) data on Amazon.'
|
1014 |
+
));
|
1015 |
+
$viewAllProductLogMessage = $helper->escapeJs($helper->__('View All Product Log.'));
|
1016 |
+
|
1017 |
+
$listingLockedMessage = $helper->escapeJs(
|
1018 |
+
$helper->__('The Listing was locked by another process. Please try again later.')
|
1019 |
+
);
|
1020 |
+
$listingEmptyMessage = $helper->escapeJs($helper->__('Listing is empty.'));
|
1021 |
+
|
1022 |
+
$listingAllItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
1023 |
+
->__('Listing All Items On Amazon'));
|
1024 |
+
$listingSelectedItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
1025 |
+
->__('Listing Selected Items On Amazon'));
|
1026 |
+
$revisingSelectedItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
1027 |
+
->__('Revising Selected Items On Amazon'));
|
1028 |
+
$relistingSelectedItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
1029 |
+
->__('Relisting Selected Items On Amazon'));
|
1030 |
+
$stoppingSelectedItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
1031 |
+
->__('Stopping Selected Items On Amazon'));
|
1032 |
+
$stoppingAndRemovingSelectedItemsMessage = Mage::helper('M2ePro')
|
1033 |
+
->escapeJs(Mage::helper('M2ePro')
|
1034 |
+
->__('Stopping On Amazon And Removing From Listing Selected Items'));
|
1035 |
+
$deletingAndRemovingSelectedItemsMessage = Mage::helper('M2ePro')
|
1036 |
+
->escapeJs(Mage::helper('M2ePro')
|
1037 |
+
->__('Removing From Amazon And Listing Selected Items'));
|
1038 |
+
|
1039 |
+
$selectItemsMessage = $helper->escapeJs($helper->__('Please select Items.'));
|
1040 |
+
$selectActionMessage = $helper->escapeJs($helper->__('Please select Action.'));
|
1041 |
+
|
1042 |
+
$errorChangingProductOptions = $helper->escapeJs($helper->__('Please Select Product Options.'));
|
1043 |
+
|
1044 |
+
$successWord = $helper->escapeJs($helper->__('Success'));
|
1045 |
+
$noticeWord = $helper->escapeJs($helper->__('Notice'));
|
1046 |
+
$warningWord = $helper->escapeJs($helper->__('Warning'));
|
1047 |
+
$errorWord = $helper->escapeJs($helper->__('Error'));
|
1048 |
+
$closeWord = $helper->escapeJs($helper->__('Close'));
|
1049 |
+
$confirmWord = $helper->escapeJs($helper->__('Confirm'));
|
1050 |
+
$cancelWord = $helper->escapeJs($helper->__('Cancel'));
|
1051 |
+
|
1052 |
+
$textConfirm = $helper->escapeJs($helper->__('Are you sure?'));
|
1053 |
+
|
1054 |
+
$mapToTemplateDescription = $this->getUrl('*/adminhtml_common_amazon_listing/mapToTemplateDescription');
|
1055 |
+
$unmapFromTemplateDescription = $this->getUrl('*/adminhtml_common_amazon_listing/unmapFromTemplateDescription');
|
1056 |
+
$validateProductsForTemplateDescriptionAssign = $this->getUrl(
|
1057 |
+
'*/adminhtml_common_amazon_listing/validateProductsForTemplateDescriptionAssign');
|
1058 |
+
$viewTemplateDescriptionsGrid = $this->getUrl('*/adminhtml_common_amazon_listing/viewTemplateDescriptionsGrid');
|
1059 |
+
$templateDescriptionPopupTitle = $helper->escapeJs($helper->__('Assign Description Policy for Products'));
|
1060 |
+
|
1061 |
+
$generalId = $this->getListingProduct()->getGeneralId();
|
1062 |
+
$hideMassAction = empty($generalId) ?
|
1063 |
+
'$(\'amazonVariationProductManageGrid_massaction-form\').hide();' : '';
|
1064 |
+
|
1065 |
+
$javascriptMain = <<<JAVASCRIPT
|
1066 |
+
<script type="text/javascript">
|
1067 |
+
|
1068 |
+
if (typeof M2ePro == 'undefined') {
|
1069 |
+
M2ePro = {};
|
1070 |
+
M2ePro.url = {};
|
1071 |
+
M2ePro.formData = {};
|
1072 |
+
M2ePro.customData = {};
|
1073 |
+
M2ePro.text = {};
|
1074 |
+
}
|
1075 |
+
|
1076 |
+
M2ePro.url.add({$urls});
|
1077 |
+
|
1078 |
+
M2ePro.url.logViewUrl = '{$logViewUrl}';
|
1079 |
+
|
1080 |
+
M2ePro.url.checkLockListing = '{$checkLockListing}';
|
1081 |
+
M2ePro.url.lockListingNow = '{$lockListingNow}';
|
1082 |
+
M2ePro.url.unlockListingNow = '{$unlockListingNow}';
|
1083 |
+
M2ePro.url.getErrorsSummary = '{$getErrorsSummary}';
|
1084 |
+
|
1085 |
+
M2ePro.url.runListProducts = '{$runListProducts}';
|
1086 |
+
M2ePro.url.runReviseProducts = '{$runReviseProducts}';
|
1087 |
+
M2ePro.url.runRelistProducts = '{$runRelistProducts}';
|
1088 |
+
M2ePro.url.runStopProducts = '{$runStopProducts}';
|
1089 |
+
M2ePro.url.runStopAndRemoveProducts = '{$runStopAndRemoveProducts}';
|
1090 |
+
M2ePro.url.runDeleteAndRemoveProducts = '{$runDeleteAndRemoveProducts}';
|
1091 |
+
M2ePro.url.setChildListingProductOptions = '{$setChildListingProductOptions}';
|
1092 |
+
|
1093 |
+
M2ePro.url.mapToTemplateDescription = '{$mapToTemplateDescription}';
|
1094 |
+
M2ePro.url.unmapFromTemplateDescription = '{$unmapFromTemplateDescription}';
|
1095 |
+
M2ePro.url.validateProductsForTemplateDescriptionAssign = '{$validateProductsForTemplateDescriptionAssign}';
|
1096 |
+
M2ePro.url.viewTemplateDescriptionsGrid = '{$viewTemplateDescriptionsGrid}';
|
1097 |
+
|
1098 |
+
M2ePro.text.task_completed_message = '{$taskCompletedMessage}';
|
1099 |
+
M2ePro.text.task_completed_success_message = '{$taskCompletedSuccessMessage}';
|
1100 |
+
M2ePro.text.task_completed_warning_message = '{$taskCompletedWarningMessage}';
|
1101 |
+
M2ePro.text.task_completed_error_message = '{$taskCompletedErrorMessage}';
|
1102 |
+
|
1103 |
+
M2ePro.text.locked_obj_notice = '{$lockedObjNoticeMessage}';
|
1104 |
+
M2ePro.text.sending_data_message = '{$sendingDataToAmazonMessage}';
|
1105 |
+
M2ePro.text.view_all_product_log_message = '{$viewAllProductLogMessage}';
|
1106 |
+
|
1107 |
+
M2ePro.text.listing_locked_message = '{$listingLockedMessage}';
|
1108 |
+
M2ePro.text.listing_empty_message = '{$listingEmptyMessage}';
|
1109 |
+
|
1110 |
+
M2ePro.text.listing_all_items_message = '{$listingAllItemsMessage}';
|
1111 |
+
M2ePro.text.listing_selected_items_message = '{$listingSelectedItemsMessage}';
|
1112 |
+
M2ePro.text.revising_selected_items_message = '{$revisingSelectedItemsMessage}';
|
1113 |
+
M2ePro.text.relisting_selected_items_message = '{$relistingSelectedItemsMessage}';
|
1114 |
+
M2ePro.text.stopping_selected_items_message = '{$stoppingSelectedItemsMessage}';
|
1115 |
+
M2ePro.text.stopping_and_removing_selected_items_message = '{$stoppingAndRemovingSelectedItemsMessage}';
|
1116 |
+
M2ePro.text.deleting_and_removing_selected_items_message = '{$deletingAndRemovingSelectedItemsMessage}';
|
1117 |
+
|
1118 |
+
M2ePro.text.select_items_message = '{$selectItemsMessage}';
|
1119 |
+
M2ePro.text.select_action_message = '{$selectActionMessage}';
|
1120 |
+
|
1121 |
+
M2ePro.text.error_changing_product_options = '{$errorChangingProductOptions}';
|
1122 |
+
|
1123 |
+
M2ePro.text.success_word = '{$successWord}';
|
1124 |
+
M2ePro.text.notice_word = '{$noticeWord}';
|
1125 |
+
M2ePro.text.warning_word = '{$warningWord}';
|
1126 |
+
M2ePro.text.error_word = '{$errorWord}';
|
1127 |
+
M2ePro.text.close_word = '{$closeWord}';
|
1128 |
+
M2ePro.text.confirm_word = '{$confirmWord}';
|
1129 |
+
M2ePro.text.cancel_word = '{$cancelWord}';
|
1130 |
+
|
1131 |
+
M2ePro.text.templateDescriptionPopupTitle = '{$templateDescriptionPopupTitle}';
|
1132 |
+
|
1133 |
+
M2ePro.text.confirm = '{$textConfirm}';
|
1134 |
+
|
1135 |
+
M2ePro.customData.componentMode = '{$component}';
|
1136 |
+
M2ePro.customData.gridId = 'amazonVariationProductManageGrid';
|
1137 |
+
|
1138 |
+
Event.observe(window, 'load', function() {
|
1139 |
+
|
1140 |
+
CommonHandler.prototype.scroll_page_to_top = function() { return; }
|
1141 |
+
|
1142 |
+
ListingGridHandlerObj = new AmazonListingVariationProductManageVariationsGridHandler(
|
1143 |
+
'amazonVariationProductManageGrid',
|
1144 |
+
{$listingId}
|
1145 |
+
);
|
1146 |
+
|
1147 |
+
// todo next (temp solution)
|
1148 |
+
ListingGridHandlerObj.actionHandler.setOptions(M2ePro);
|
1149 |
+
ListingGridHandlerObj.templateDescriptionHandler.setOptions(M2ePro);
|
1150 |
+
|
1151 |
+
ListingProgressBarObj = new ProgressBar('listing_view_progress_bar');
|
1152 |
+
GridWrapperObj = new AreaWrapper('listing_view_content_container');
|
1153 |
+
|
1154 |
+
setTimeout(function() {
|
1155 |
+
ListingGridHandlerObj.afterInitPage();
|
1156 |
+
}, 350);
|
1157 |
+
});
|
1158 |
+
|
1159 |
+
if (typeof ListingGridHandlerObj != 'undefined') {
|
1160 |
+
ListingGridHandlerObj.afterInitPage();
|
1161 |
+
}
|
1162 |
+
|
1163 |
+
{$hideMassAction}
|
1164 |
+
|
1165 |
+
</script>
|
1166 |
+
JAVASCRIPT;
|
1167 |
+
|
1168 |
+
$additionalCss = <<<CSS
|
1169 |
+
<style>
|
1170 |
+
body {
|
1171 |
+
background: none;
|
1172 |
+
}
|
1173 |
+
|
1174 |
+
.wrapper {
|
1175 |
+
min-width: inherit;
|
1176 |
+
}
|
1177 |
+
|
1178 |
+
.footer {
|
1179 |
+
display: none;
|
1180 |
+
}
|
1181 |
+
|
1182 |
+
.middle {
|
1183 |
+
padding: 0px;
|
1184 |
+
background: none;
|
1185 |
+
}
|
1186 |
+
|
1187 |
+
td.help_line .hl_close {
|
1188 |
+
margin-top: -6px;
|
1189 |
+
}
|
1190 |
+
|
1191 |
+
td.help_line .hl_header {
|
1192 |
+
padding: 0 0 10px !important;
|
1193 |
+
}
|
1194 |
+
|
1195 |
+
</style>
|
1196 |
+
CSS;
|
1197 |
+
|
1198 |
+
return '<div id="messages"></div>' .
|
1199 |
+
'<div id="listing_view_progress_bar"></div>' .
|
1200 |
+
'<div id="listing_container_errors_summary" class="errors_summary" style="display: none;"></div>' .
|
1201 |
+
'<div id="listing_view_content_container">'.
|
1202 |
+
parent::_toHtml() .
|
1203 |
+
'</div>' . $javascriptMain . $additionalCss;
|
1204 |
+
}
|
1205 |
+
|
1206 |
+
// ####################################
|
1207 |
+
|
1208 |
+
private function canChangeProductVariation(Ess_M2ePro_Model_Listing_Product $childListingProduct)
|
1209 |
+
{
|
1210 |
+
if (!$this->hasUnusedProductVariation()) {
|
1211 |
+
return false;
|
1212 |
+
}
|
1213 |
+
|
1214 |
+
$lockData = $this->getLockedData($childListingProduct);
|
1215 |
+
if ($lockData['in_action']) {
|
1216 |
+
return false;
|
1217 |
+
}
|
1218 |
+
|
1219 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product $amazonChildListingProduct */
|
1220 |
+
$amazonChildListingProduct = $childListingProduct->getChildObject();
|
1221 |
+
|
1222 |
+
if (!$amazonChildListingProduct->getGeneralId()) {
|
1223 |
+
return false;
|
1224 |
+
}
|
1225 |
+
|
1226 |
+
$childTypeModel = $amazonChildListingProduct->getVariationManager()->getTypeModel();
|
1227 |
+
|
1228 |
+
if ($childTypeModel->isVariationProductMatched() && $this->hasChildWithEmptyProductOptions()) {
|
1229 |
+
return false;
|
1230 |
+
}
|
1231 |
+
|
1232 |
+
return true;
|
1233 |
+
}
|
1234 |
+
|
1235 |
+
private function getLockedData($row)
|
1236 |
+
{
|
1237 |
+
$listingProductId = $row->getData('id');
|
1238 |
+
if (!isset($this->lockedDataCache[$listingProductId])) {
|
1239 |
+
$objectLocks = Mage::getModel('M2ePro/Listing_Product')->load($row->getData('id'))->getObjectLocks();
|
1240 |
+
$tempArray = array(
|
1241 |
+
'object_locks' => $objectLocks,
|
1242 |
+
'in_action' => !empty($objectLocks),
|
1243 |
+
);
|
1244 |
+
$this->lockedDataCache[$listingProductId] = $tempArray;
|
1245 |
+
}
|
1246 |
+
|
1247 |
+
return $this->lockedDataCache[$listingProductId];
|
1248 |
+
}
|
1249 |
+
|
1250 |
+
// ####################################
|
1251 |
+
|
1252 |
+
protected function getTemplateDescriptionLinkHtml($listingProduct)
|
1253 |
+
{
|
1254 |
+
$templateDescriptionEditUrl = $this->getUrl('*/adminhtml_common_amazon_template_description/edit', array(
|
1255 |
+
'id' => $listingProduct->getChildObject()->getTemplateDescriptionId()
|
1256 |
+
));
|
1257 |
+
|
1258 |
+
$helper = Mage::helper('M2ePro');
|
1259 |
+
$templateTitle = $listingProduct->getChildObject()->getDescriptionTemplate()->getTitle();
|
1260 |
+
|
1261 |
+
return <<<HTML
|
1262 |
+
<span style="font-size: 9px;">{$helper->__('Description Title')}:
|
1263 |
+
<a target="_blank" href="{$templateDescriptionEditUrl}">
|
1264 |
+
{$helper->escapeHtml($templateTitle)}</a>
|
1265 |
+
</span>
|
1266 |
+
<br/>
|
1267 |
+
HTML;
|
1268 |
+
}
|
1269 |
+
|
1270 |
+
// ####################################
|
1271 |
+
|
1272 |
+
public function getProductVariationsTree($childProduct)
|
1273 |
+
{
|
1274 |
+
$unusedVariations = $this->getUnusedProductVariations();
|
1275 |
+
|
1276 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager_Type_Relation_Child $childTypeModel */
|
1277 |
+
$childTypeModel = $childProduct->getChildObject()->getVariationManager()->getTypeModel();
|
1278 |
+
|
1279 |
+
if ($childTypeModel->isVariationProductMatched()) {
|
1280 |
+
$unusedVariations[] = $childTypeModel->getProductOptions();
|
1281 |
+
}
|
1282 |
+
|
1283 |
+
$variationsSets = $this->getAttributesVariationsSets($unusedVariations);
|
1284 |
+
$firstAttribute = key($variationsSets);
|
1285 |
+
|
1286 |
+
return $this->prepareVariations($firstAttribute,$unusedVariations,$variationsSets);
|
1287 |
+
}
|
1288 |
+
|
1289 |
+
private function prepareVariations($currentAttribute,$unusedVariations,$variationsSets,$filters = array())
|
1290 |
+
{
|
1291 |
+
$return = false;
|
1292 |
+
|
1293 |
+
$temp = array_flip(array_keys($variationsSets));
|
1294 |
+
|
1295 |
+
$lastAttributePosition = count($variationsSets) - 1;
|
1296 |
+
$currentAttributePosition = $temp[$currentAttribute];
|
1297 |
+
|
1298 |
+
if ($currentAttributePosition != $lastAttributePosition) {
|
1299 |
+
|
1300 |
+
$temp = array_keys($variationsSets);
|
1301 |
+
$nextAttribute = $temp[$currentAttributePosition + 1];
|
1302 |
+
|
1303 |
+
foreach ($variationsSets[$currentAttribute] as $option) {
|
1304 |
+
|
1305 |
+
$filters[$currentAttribute] = $option;
|
1306 |
+
|
1307 |
+
$result = $this->prepareVariations(
|
1308 |
+
$nextAttribute,$unusedVariations,$variationsSets,$filters
|
1309 |
+
);
|
1310 |
+
|
1311 |
+
if (!$result) {
|
1312 |
+
continue;
|
1313 |
+
}
|
1314 |
+
|
1315 |
+
$return[$currentAttribute][$option] = $result;
|
1316 |
+
}
|
1317 |
+
|
1318 |
+
ksort($return[$currentAttribute]);
|
1319 |
+
|
1320 |
+
return $return;
|
1321 |
+
}
|
1322 |
+
|
1323 |
+
$return = false;
|
1324 |
+
foreach ($unusedVariations as $key => $magentoVariation) {
|
1325 |
+
foreach ($magentoVariation as $attribute => $option) {
|
1326 |
+
|
1327 |
+
if ($attribute == $currentAttribute) {
|
1328 |
+
|
1329 |
+
if (count($variationsSets) != 1) {
|
1330 |
+
continue;
|
1331 |
+
}
|
1332 |
+
|
1333 |
+
$values = array_flip($variationsSets[$currentAttribute]);
|
1334 |
+
$return = array($currentAttribute => $values);
|
1335 |
+
|
1336 |
+
foreach ($return[$currentAttribute] as &$option) {
|
1337 |
+
$option = true;
|
1338 |
+
}
|
1339 |
+
|
1340 |
+
return $return;
|
1341 |
+
}
|
1342 |
+
|
1343 |
+
if ($option != $filters[$attribute]) {
|
1344 |
+
unset($unusedVariations[$key]);
|
1345 |
+
continue;
|
1346 |
+
}
|
1347 |
+
|
1348 |
+
foreach ($magentoVariation as $tempAttribute => $tempOption) {
|
1349 |
+
if ($tempAttribute == $currentAttribute) {
|
1350 |
+
$option = $tempOption;
|
1351 |
+
$return[$currentAttribute][$option] = true;
|
1352 |
+
}
|
1353 |
+
}
|
1354 |
+
}
|
1355 |
+
}
|
1356 |
+
|
1357 |
+
if (count($unusedVariations) < 1) {
|
1358 |
+
return false;
|
1359 |
+
}
|
1360 |
+
|
1361 |
+
ksort($return[$currentAttribute]);
|
1362 |
+
|
1363 |
+
return $return;
|
1364 |
+
}
|
1365 |
+
|
1366 |
+
// ####################################
|
1367 |
+
|
1368 |
+
public function getCurrentProductVariations()
|
1369 |
+
{
|
1370 |
+
|
1371 |
+
if (!is_null($this->currentProductVariations)) {
|
1372 |
+
return $this->currentProductVariations;
|
1373 |
+
}
|
1374 |
+
|
1375 |
+
$magentoProductVariations = $this->getListingProduct()
|
1376 |
+
->getMagentoProduct()
|
1377 |
+
->getVariationInstance()
|
1378 |
+
->getVariationsTypeStandard();
|
1379 |
+
|
1380 |
+
$productVariations = array();
|
1381 |
+
|
1382 |
+
foreach ($magentoProductVariations['variations'] as $option) {
|
1383 |
+
$productOption = array();
|
1384 |
+
|
1385 |
+
foreach ($option as $attribute) {
|
1386 |
+
$productOption[$attribute['attribute']] = $attribute['option'];
|
1387 |
+
}
|
1388 |
+
|
1389 |
+
$productVariations[] = $productOption;
|
1390 |
+
}
|
1391 |
+
|
1392 |
+
return $this->currentProductVariations = $productVariations;
|
1393 |
+
}
|
1394 |
+
|
1395 |
+
public function getUsedProductVariations()
|
1396 |
+
{
|
1397 |
+
if (is_null($this->usedProductVariations)) {
|
1398 |
+
|
1399 |
+
$usedOptions = array();
|
1400 |
+
|
1401 |
+
foreach ($this->getChildListingProducts() as $childListingProduct) {
|
1402 |
+
/** @var Ess_M2ePro_Model_Listing_Product $childListingProduct */
|
1403 |
+
|
1404 |
+
/**
|
1405 |
+
* @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager_Type_Relation_Child $childTypeModel
|
1406 |
+
*/
|
1407 |
+
$childTypeModel = $childListingProduct->getChildObject()->getVariationManager()->getTypeModel();
|
1408 |
+
|
1409 |
+
if (!$childTypeModel->isVariationProductMatched()) {
|
1410 |
+
continue;
|
1411 |
+
}
|
1412 |
+
|
1413 |
+
$usedOptions[] = $childTypeModel->getProductOptions();
|
1414 |
+
}
|
1415 |
+
|
1416 |
+
$this->usedProductVariations = $usedOptions;
|
1417 |
+
}
|
1418 |
+
|
1419 |
+
return $this->usedProductVariations;
|
1420 |
+
}
|
1421 |
+
|
1422 |
+
// ####################################
|
1423 |
+
|
1424 |
+
public function getUnusedProductVariations()
|
1425 |
+
{
|
1426 |
+
return $this->getUnusedVariations($this->getCurrentProductVariations(), $this->getUsedProductVariations());
|
1427 |
+
}
|
1428 |
+
|
1429 |
+
private function getUnusedVariations($currentVariations, $usedVariations)
|
1430 |
+
{
|
1431 |
+
if (empty($currentVariations)) {
|
1432 |
+
return array();
|
1433 |
+
}
|
1434 |
+
|
1435 |
+
if (empty($usedVariations)) {
|
1436 |
+
return $currentVariations;
|
1437 |
+
}
|
1438 |
+
|
1439 |
+
$unusedOptions = array();
|
1440 |
+
|
1441 |
+
foreach ($currentVariations as $id => $currentOption) {
|
1442 |
+
if ($this->isVariationExistsInArray($currentOption, $usedVariations)) {
|
1443 |
+
continue;
|
1444 |
+
}
|
1445 |
+
|
1446 |
+
$unusedOptions[$id] = $currentOption;
|
1447 |
+
}
|
1448 |
+
|
1449 |
+
return $unusedOptions;
|
1450 |
+
}
|
1451 |
+
|
1452 |
+
private function isVariationExistsInArray(array $needle, array $haystack)
|
1453 |
+
{
|
1454 |
+
foreach ($haystack as $option) {
|
1455 |
+
if ($option != $needle) {
|
1456 |
+
continue;
|
1457 |
+
}
|
1458 |
+
|
1459 |
+
return true;
|
1460 |
+
}
|
1461 |
+
|
1462 |
+
return false;
|
1463 |
+
}
|
1464 |
+
|
1465 |
+
// ####################################
|
1466 |
+
|
1467 |
+
public function getChildListingProducts()
|
1468 |
+
{
|
1469 |
+
if (!is_null($this->childListingProducts)) {
|
1470 |
+
return $this->childListingProducts;
|
1471 |
+
}
|
1472 |
+
|
1473 |
+
return $this->childListingProducts = $this->getListingProduct()->getChildObject()
|
1474 |
+
->getVariationManager()->getTypeModel()->getChildListingsProducts();
|
1475 |
+
}
|
1476 |
+
|
1477 |
+
public function getAttributesVariationsSets($variations)
|
1478 |
+
{
|
1479 |
+
$attributesOptions = array();
|
1480 |
+
|
1481 |
+
foreach ($variations as $variation) {
|
1482 |
+
foreach ($variation as $attr => $option) {
|
1483 |
+
if (!isset($attributesOptions[$attr])) {
|
1484 |
+
$attributesOptions[$attr] = array();
|
1485 |
+
}
|
1486 |
+
if (!in_array($option, $attributesOptions[$attr])) {
|
1487 |
+
$attributesOptions[$attr][] = $option;
|
1488 |
+
}
|
1489 |
+
}
|
1490 |
+
}
|
1491 |
+
|
1492 |
+
ksort($attributesOptions);
|
1493 |
+
|
1494 |
+
return $attributesOptions;
|
1495 |
+
}
|
1496 |
+
|
1497 |
+
// ####################################
|
1498 |
+
|
1499 |
+
protected function getGeneralIdLink($generalId)
|
1500 |
+
{
|
1501 |
+
$url = Mage::helper('M2ePro/Component_Amazon')->getItemUrl(
|
1502 |
+
$generalId,
|
1503 |
+
$this->getListingProduct()->getListing()->getMarketplaceId()
|
1504 |
+
);
|
1505 |
+
|
1506 |
+
return <<<HTML
|
1507 |
+
<a href="{$url}" target="_blank" title="{$generalId}" >{$generalId}</a>
|
1508 |
+
HTML;
|
1509 |
+
}
|
1510 |
+
|
1511 |
+
// ####################################
|
1512 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Variation/Product/Manage/Tabs/Variations/Help.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Variation_Product_Manage_Tabs_Variations_Help
|
8 |
+
extends Mage_Adminhtml_Block_Widget
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
//------------------------------
|
16 |
+
$this->setId('amazonListingViewHelp');
|
17 |
+
//------------------------------
|
18 |
+
|
19 |
+
$this->setTemplate('M2ePro/common/amazon/listing/variation/product/manage/tabs/variations/help.phtml');
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Variation/Product/SwitchToIndividualPopup.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2011 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Variation_Product_SwitchToIndividualPopup
|
8 |
+
extends Mage_Adminhtml_Block_Template
|
9 |
+
{
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('amazonListingAddNewAsinManualPopup');
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$this->setTemplate('M2ePro/common/amazon/listing/variation/product/switch_to_individual_popup.phtml');
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _beforeToHtml()
|
24 |
+
{
|
25 |
+
parent::_beforeToHtml();
|
26 |
+
|
27 |
+
$data = array(
|
28 |
+
'class' => 'switch-to-individual-btn',
|
29 |
+
'label' => Mage::helper('M2ePro')->__('Yes')
|
30 |
+
);
|
31 |
+
$this->setChild(
|
32 |
+
'yes_btn',
|
33 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')->setData($data)
|
34 |
+
);
|
35 |
+
|
36 |
+
$data = array(
|
37 |
+
'class' => 'switch-to-individual-popup-close',
|
38 |
+
'label' => Mage::helper('M2ePro')->__('No')
|
39 |
+
);
|
40 |
+
$this->setChild(
|
41 |
+
'no_btn',
|
42 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')->setData($data)
|
43 |
+
);
|
44 |
+
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Variation/Product/SwitchToParentPopup.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2011 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Variation_Product_SwitchToParentPopup
|
8 |
+
extends Mage_Adminhtml_Block_Template
|
9 |
+
{
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('amazonListingAddNewAsinManualPopup');
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$this->setTemplate('M2ePro/common/amazon/listing/variation/product/switch_to_parent_popup.phtml');
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _beforeToHtml()
|
24 |
+
{
|
25 |
+
parent::_beforeToHtml();
|
26 |
+
|
27 |
+
$data = array(
|
28 |
+
'class' => 'switch-to-parent-btn',
|
29 |
+
'label' => Mage::helper('M2ePro')->__('Yes')
|
30 |
+
);
|
31 |
+
$this->setChild(
|
32 |
+
'yes_btn',
|
33 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')->setData($data)
|
34 |
+
);
|
35 |
+
|
36 |
+
$data = array(
|
37 |
+
'class' => 'switch-to-parent-popup-close',
|
38 |
+
'label' => Mage::helper('M2ePro')->__('No')
|
39 |
+
);
|
40 |
+
$this->setChild(
|
41 |
+
'no_btn',
|
42 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')->setData($data)
|
43 |
+
);
|
44 |
+
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View.php
ADDED
@@ -0,0 +1,744 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_View extends Mage_Adminhtml_Block_Widget_Grid_Container
|
8 |
+
{
|
9 |
+
const VIEW_MODE_AMAZON = 'amazon';
|
10 |
+
const VIEW_MODE_MAGENTO = 'magento';
|
11 |
+
const VIEW_MODE_SELLERCENTRAL = 'sellercentral';
|
12 |
+
|
13 |
+
const DEFAULT_VIEW_MODE = self::VIEW_MODE_AMAZON;
|
14 |
+
|
15 |
+
public function __construct()
|
16 |
+
{
|
17 |
+
parent::__construct();
|
18 |
+
|
19 |
+
// Initialization block
|
20 |
+
//------------------------------
|
21 |
+
$this->setId('amazonListingView');
|
22 |
+
$this->_blockGroup = 'M2ePro';
|
23 |
+
$this->_controller = 'adminhtml_common_amazon_listing_view_' . $this->getViewMode();
|
24 |
+
//------------------------------
|
25 |
+
|
26 |
+
// Set header text
|
27 |
+
//------------------------------
|
28 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
29 |
+
|
30 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
31 |
+
$headerText = Mage::helper('M2ePro')->__(
|
32 |
+
'View %component_name% Listing',
|
33 |
+
Mage::helper('M2ePro/Component_Amazon')->getTitle()
|
34 |
+
);
|
35 |
+
} else {
|
36 |
+
$headerText = Mage::helper('M2ePro')->__('View Listing ');
|
37 |
+
}
|
38 |
+
|
39 |
+
$this->_headerText = $headerText;
|
40 |
+
//------------------------------
|
41 |
+
|
42 |
+
// Set buttons actions
|
43 |
+
//------------------------------
|
44 |
+
$this->removeButton('back');
|
45 |
+
$this->removeButton('reset');
|
46 |
+
$this->removeButton('delete');
|
47 |
+
$this->removeButton('add');
|
48 |
+
$this->removeButton('save');
|
49 |
+
$this->removeButton('edit');
|
50 |
+
//------------------------------
|
51 |
+
|
52 |
+
//------------------------------
|
53 |
+
$url = $this->getUrl('*/adminhtml_common_log/listing', array(
|
54 |
+
'id' => $listingData['id'],
|
55 |
+
'channel' => Ess_M2ePro_Block_Adminhtml_Common_Log_Tabs::TAB_ID_AMAZON
|
56 |
+
));
|
57 |
+
$this->_addButton('view_log', array(
|
58 |
+
'label' => Mage::helper('M2ePro')->__('View Log'),
|
59 |
+
'onclick' => 'window.open(\'' . $url . '\')',
|
60 |
+
'class' => 'button_link'
|
61 |
+
));
|
62 |
+
//------------------------------
|
63 |
+
|
64 |
+
//------------------------------
|
65 |
+
$this->_addButton('edit_settings', array(
|
66 |
+
'label' => Mage::helper('M2ePro')->__('Edit Settings'),
|
67 |
+
'onclick' => '',
|
68 |
+
'class' => 'drop_down edit_settings_drop_down'
|
69 |
+
));
|
70 |
+
//------------------------------
|
71 |
+
|
72 |
+
//------------------------------
|
73 |
+
$this->_addButton('add_products', array(
|
74 |
+
'label' => Mage::helper('M2ePro')->__('Add Products'),
|
75 |
+
'onclick' => '',
|
76 |
+
'class' => 'add drop_down add_products_drop_down'
|
77 |
+
));
|
78 |
+
//------------------------------
|
79 |
+
}
|
80 |
+
|
81 |
+
// ####################################
|
82 |
+
|
83 |
+
public function getViewMode()
|
84 |
+
{
|
85 |
+
$allowedModes = array(self::VIEW_MODE_AMAZON, self::VIEW_MODE_MAGENTO, self::VIEW_MODE_SELLERCENTRAL);
|
86 |
+
$mode = $this->getParam('view_mode', self::DEFAULT_VIEW_MODE);
|
87 |
+
|
88 |
+
if (in_array($mode, $allowedModes)) {
|
89 |
+
return $mode;
|
90 |
+
}
|
91 |
+
|
92 |
+
return self::DEFAULT_VIEW_MODE;
|
93 |
+
}
|
94 |
+
|
95 |
+
protected function getParam($paramName, $default = NULL)
|
96 |
+
{
|
97 |
+
$session = Mage::helper('M2ePro/Data_Session');
|
98 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
99 |
+
$sessionParamName = $this->getId() . $listingData['id'] . $paramName;
|
100 |
+
|
101 |
+
if ($this->getRequest()->has($paramName)) {
|
102 |
+
$param = $this->getRequest()->getParam($paramName);
|
103 |
+
$session->setValue($sessionParamName, $param);
|
104 |
+
return $param;
|
105 |
+
} elseif ($param = $session->getValue($sessionParamName)) {
|
106 |
+
return $param;
|
107 |
+
}
|
108 |
+
|
109 |
+
return $default;
|
110 |
+
}
|
111 |
+
|
112 |
+
// ####################################
|
113 |
+
|
114 |
+
protected function _toHtml()
|
115 |
+
{
|
116 |
+
return '<div id="listing_view_progress_bar"></div>' .
|
117 |
+
'<div id="listing_container_errors_summary" class="errors_summary" style="display: none;"></div>' .
|
118 |
+
'<div id="listing_view_content_container">'.
|
119 |
+
parent::_toHtml() .
|
120 |
+
'</div>';
|
121 |
+
}
|
122 |
+
|
123 |
+
public function getGridHtml()
|
124 |
+
{
|
125 |
+
if ($this->getRequest()->isXmlHttpRequest()) {
|
126 |
+
return parent::getGridHtml();
|
127 |
+
}
|
128 |
+
|
129 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
130 |
+
|
131 |
+
/** @var $helper Ess_M2ePro_Helper_Data */
|
132 |
+
$helper = Mage::helper('M2ePro');
|
133 |
+
|
134 |
+
//------------------------------
|
135 |
+
$urls = $helper->getControllerActions(
|
136 |
+
'adminhtml_common_listing_autoAction', array(
|
137 |
+
'listing_id' => $this->getRequest()->getParam('id'),
|
138 |
+
'component' => Ess_M2ePro_Helper_Component_Amazon::NICK
|
139 |
+
)
|
140 |
+
);
|
141 |
+
$showAutoAction = json_encode((bool)$this->getRequest()->getParam('auto_actions'));
|
142 |
+
|
143 |
+
$path = 'adminhtml_common_log/listingProduct';
|
144 |
+
$urls[$path] = $this->getUrl('*/' . $path, array(
|
145 |
+
'channel' => Ess_M2ePro_Helper_Component_Amazon::NICK,
|
146 |
+
'back' => $helper->makeBackUrlParam('*/adminhtml_common_amazon_listing/view',array(
|
147 |
+
'id' => $listingData['id']
|
148 |
+
))
|
149 |
+
));
|
150 |
+
|
151 |
+
$path = 'adminhtml_common_listing/duplicateProducts';
|
152 |
+
$urls[$path] = $this->getUrl('*/' . $path);
|
153 |
+
|
154 |
+
$urls = json_encode($urls);
|
155 |
+
//------------------------------
|
156 |
+
|
157 |
+
// todo next (change)
|
158 |
+
|
159 |
+
$component = Ess_M2ePro_Helper_Component_Amazon::NICK;
|
160 |
+
|
161 |
+
$temp = Mage::helper('M2ePro/Data_Session')->getValue('products_ids_for_list', true);
|
162 |
+
$productsIdsForList = empty($temp) ? '' : $temp;
|
163 |
+
|
164 |
+
$gridId = $this->getChild('grid')->getId();
|
165 |
+
$ignoreListings = json_encode(array($listingData['id']));
|
166 |
+
|
167 |
+
$marketplaceId = Mage::helper('M2ePro/Data_Global')->getValue('marketplace_id');
|
168 |
+
$marketplaceInstance = Mage::helper('M2ePro/Component_Amazon')->getCachedObject('Marketplace',$marketplaceId);
|
169 |
+
$marketplace = json_encode($marketplaceInstance->getData());
|
170 |
+
$isNewAsinAvailable = json_encode($marketplaceInstance->getChildObject()->isNewAsinAvailable());
|
171 |
+
$isMarketplaceSynchronized = json_encode($marketplaceInstance->getChildObject()->isSynchronized());
|
172 |
+
|
173 |
+
$logViewUrl = $this->getUrl('*/adminhtml_common_log/listing',array(
|
174 |
+
'id' => $listingData['id'],
|
175 |
+
'channel' => Ess_M2ePro_Block_Adminhtml_Common_Log_Tabs::TAB_ID_AMAZON,
|
176 |
+
'back' => $helper->makeBackUrlParam('*/adminhtml_common_amazon_listing/view',
|
177 |
+
array('id' =>$listingData['id']))
|
178 |
+
));
|
179 |
+
$getErrorsSummary = $this->getUrl('*/adminhtml_listing/getErrorsSummary');
|
180 |
+
|
181 |
+
$runListProducts = $this->getUrl('*/adminhtml_common_amazon_listing/runListProducts');
|
182 |
+
$runReviseProducts = $this->getUrl('*/adminhtml_common_amazon_listing/runReviseProducts');
|
183 |
+
$runRelistProducts = $this->getUrl('*/adminhtml_common_amazon_listing/runRelistProducts');
|
184 |
+
$runStopProducts = $this->getUrl('*/adminhtml_common_amazon_listing/runStopProducts');
|
185 |
+
$runStopAndRemoveProducts = $this->getUrl('*/adminhtml_common_amazon_listing/runStopAndRemoveProducts');
|
186 |
+
$runDeleteAndRemoveProducts = $this->getUrl('*/adminhtml_common_amazon_listing/runDeleteAndRemoveProducts');
|
187 |
+
|
188 |
+
$prepareData = $this->getUrl('*/adminhtml_listing_moving/prepareMoveToListing');
|
189 |
+
$getMoveToListingGridHtml = $this->getUrl('*/adminhtml_listing_moving/moveToListingGrid');
|
190 |
+
$getFailedProductsGridHtml = $this->getUrl('*/adminhtml_listing_moving/getFailedProductsGrid');
|
191 |
+
$tryToMoveToListing = $this->getUrl('*/adminhtml_listing_moving/tryToMoveToListing');
|
192 |
+
$moveToListing = $this->getUrl('*/adminhtml_listing_moving/moveToListing');
|
193 |
+
|
194 |
+
$marketplaceSynchUrl = $this->getUrl(
|
195 |
+
'*/adminhtml_common_marketplace/index',
|
196 |
+
array('tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON)
|
197 |
+
);
|
198 |
+
|
199 |
+
$getVariationEditPopupUrl = $this->getUrl('*/adminhtml_common_listing/getVariationEditPopup');
|
200 |
+
$getVariationManagePopupUrl = $this->getUrl('*/adminhtml_common_listing/getVariationManagePopup');
|
201 |
+
|
202 |
+
$variationEditActionUrl = $this->getUrl('*/adminhtml_common_listing/variationEdit');
|
203 |
+
$variationManageActionUrl = $this->getUrl('*/adminhtml_common_listing/variationManage');
|
204 |
+
$variationManageGenerateActionUrl = $this->getUrl('*/adminhtml_common_listing/variationManageGenerate');
|
205 |
+
$variationResetActionUrl = $this->getUrl('*/adminhtml_common_listing/variationReset');
|
206 |
+
|
207 |
+
$saveListingAdditionalDataActionUrl = $this->getUrl('*/adminhtml_listing/saveListingAdditionalData', array(
|
208 |
+
'id' => $listingData['id']
|
209 |
+
));
|
210 |
+
|
211 |
+
$popupTitle = $helper->escapeJs($helper->__('Moving Amazon Items'));
|
212 |
+
$popupTitleSingle = $helper->escapeJs($helper->__('Moving Amazon Item'));
|
213 |
+
$failedProductsPopupTitle = $helper->escapeJs($helper->__('Products failed to move'));
|
214 |
+
|
215 |
+
$taskCompletedMessage = $helper->escapeJs($helper->__('Task completed. Please wait ...'));
|
216 |
+
$taskCompletedSuccessMessage = $helper->escapeJs(
|
217 |
+
$helper->__('"%task_title%" Task has successfully submitted to be processed.')
|
218 |
+
);
|
219 |
+
$taskCompletedWarningMessage = $helper->escapeJs($helper->__(
|
220 |
+
'"%task_title%" Task has completed with warnings. <a target="_blank" href="%url%">View Log</a> for details.'
|
221 |
+
));
|
222 |
+
$taskCompletedErrorMessage = $helper->escapeJs($helper->__(
|
223 |
+
'"%task_title%" Task has completed with errors. <a target="_blank" href="%url%">View Log</a> for details.'
|
224 |
+
));
|
225 |
+
|
226 |
+
$lockedObjNoticeMessage = $helper->escapeJs($helper->__('Some Amazon request(s) are being processed now.'));
|
227 |
+
$sendingDataToAmazonMessage = $helper->escapeJs($helper->__(
|
228 |
+
'Sending %product_title% Product(s) data on Amazon.')
|
229 |
+
);
|
230 |
+
$viewAllProductLogMessage = $helper->escapeJs($helper->__('View All Product Log.'));
|
231 |
+
|
232 |
+
$listingLockedMessage = $helper->escapeJs(
|
233 |
+
$helper->__('The Listing was locked by another process. Please try again later.')
|
234 |
+
);
|
235 |
+
$listingEmptyMessage = $helper->escapeJs($helper->__('Listing is empty.'));
|
236 |
+
|
237 |
+
$listingAllItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
238 |
+
->__('Listing All Items On Amazon'));
|
239 |
+
$listingSelectedItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
240 |
+
->__('Listing Selected Items On Amazon'));
|
241 |
+
$revisingSelectedItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
242 |
+
->__('Revising Selected Items On Amazon'));
|
243 |
+
$relistingSelectedItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
244 |
+
->__('Relisting Selected Items On Amazon'));
|
245 |
+
$stoppingSelectedItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
246 |
+
->__('Stopping Selected Items On Amazon'));
|
247 |
+
$stoppingAndRemovingSelectedItemsMessage = Mage::helper('M2ePro')
|
248 |
+
->escapeJs(Mage::helper('M2ePro')
|
249 |
+
->__('Stopping On Amazon And Removing From Listing Selected Items'));
|
250 |
+
$deletingAndRemovingSelectedItemsMessage = Mage::helper('M2ePro')
|
251 |
+
->escapeJs(Mage::helper('M2ePro')
|
252 |
+
->__('Removing From Amazon And Listing Selected Items'));
|
253 |
+
|
254 |
+
$successfullyMovedMessage = $helper->escapeJs($helper->__('Product(s) was successfully Moved.'));
|
255 |
+
$productsWereNotMovedMessage = $helper->escapeJs(
|
256 |
+
$helper->__('Product(s) was not Moved. <a target="_blank" href="%url%">View Log</a> for details.')
|
257 |
+
);
|
258 |
+
$someProductsWereNotMovedMessage = $helper->escapeJs(
|
259 |
+
$helper->__('Some Product(s) was not Moved. <a target="_blank" href="%url%">View Log</a> for details.')
|
260 |
+
);
|
261 |
+
|
262 |
+
$selectItemsMessage = $helper->escapeJs(
|
263 |
+
$helper->__('Please select the Products you want to perform the Action on.')
|
264 |
+
);
|
265 |
+
$selectActionMessage = $helper->escapeJs($helper->__('Please select Action.'));
|
266 |
+
|
267 |
+
$successWord = $helper->escapeJs($helper->__('Success'));
|
268 |
+
$noticeWord = $helper->escapeJs($helper->__('Notice'));
|
269 |
+
$warningWord = $helper->escapeJs($helper->__('Warning'));
|
270 |
+
$errorWord = $helper->escapeJs($helper->__('Error'));
|
271 |
+
$closeWord = $helper->escapeJs($helper->__('Close'));
|
272 |
+
|
273 |
+
$assignString = Mage::helper('M2ePro')->__('Assign');
|
274 |
+
$textConfirm = $helper->escapeJs($helper->__('Are you sure?'));
|
275 |
+
|
276 |
+
$searchAsinManual = $this->getUrl('*/adminhtml_common_amazon_listing/searchAsinManual');
|
277 |
+
$getSearchAsinMenu = $this->getUrl('*/adminhtml_common_amazon_listing/getSearchAsinMenu');
|
278 |
+
$suggestedAsinGridHmtl = $this->getUrl('*/adminhtml_common_amazon_listing/getSuggestedAsinGrid');
|
279 |
+
$searchAsinAuto = $this->getUrl('*/adminhtml_common_amazon_listing/searchAsinAuto');
|
280 |
+
$getProductsSearchStatus = $this->getUrl('*/adminhtml_common_amazon_listing/getProductsSearchStatus');
|
281 |
+
$mapToAsin = $this->getUrl('*/adminhtml_common_amazon_listing/mapToAsin');
|
282 |
+
$unmapFromAsin = $this->getUrl('*/adminhtml_common_amazon_listing/unmapFromAsin');
|
283 |
+
$mapToNewAsin = $this->getUrl('*/adminhtml_common_amazon_listing/mapToNewAsin');
|
284 |
+
|
285 |
+
$variationProductManage = $this->getUrl(
|
286 |
+
'*/adminhtml_common_amazon_listing_variation_product_manage/index');
|
287 |
+
$variationProductSetGeneralIdOwner = $this->getUrl(
|
288 |
+
'*/adminhtml_common_amazon_listing_variation_product_manage/setGeneralIdOwner');
|
289 |
+
$variationProductSetVariationTheme = $this->getUrl(
|
290 |
+
'*/adminhtml_common_amazon_listing_variation_product_manage/setVariationTheme');
|
291 |
+
$variationProductSetMatchedAttributes = $this->getUrl(
|
292 |
+
'*/adminhtml_common_amazon_listing_variation_product_manage/setMatchedAttributes');
|
293 |
+
$variationProductSetListingProductSku = $this->getUrl(
|
294 |
+
'*/adminhtml_common_amazon_listing_variation_product_manage/setListingProductSku');
|
295 |
+
$manageVariationViewTemplateDescriptionsGrid = $this->getUrl(
|
296 |
+
'*/adminhtml_common_amazon_listing_variation_product_manage/viewTemplateDescriptionsGrid');
|
297 |
+
$manageVariationMapToTemplateDescription = $this->getUrl(
|
298 |
+
'*/adminhtml_common_amazon_listing_variation_product_manage/mapToTemplateDescription');
|
299 |
+
|
300 |
+
$viewVariationsSettingsAjax = $this->getUrl(
|
301 |
+
'*/adminhtml_common_amazon_listing_variation_product_manage/viewVariationsSettingsAjax');
|
302 |
+
|
303 |
+
$newAsinUrl = $this->getUrl('*/adminhtml_common_amazon_template_newProduct',array(
|
304 |
+
'marketplace_id' => Mage::helper('M2ePro/Data_Global')->getValue('marketplace_id'),
|
305 |
+
));
|
306 |
+
|
307 |
+
$mapToTemplateDescription = $this->getUrl('*/adminhtml_common_amazon_listing/mapToTemplateDescription');
|
308 |
+
$unmapFromTemplateDescription = $this->getUrl('*/adminhtml_common_amazon_listing/unmapFromTemplateDescription');
|
309 |
+
$validateProductsForTemplateDescriptionAssign = $this->getUrl(
|
310 |
+
'*/adminhtml_common_amazon_listing/validateProductsForTemplateDescriptionAssign');
|
311 |
+
$viewTemplateDescriptionsGrid = $this->getUrl('*/adminhtml_common_amazon_listing/viewTemplateDescriptionsGrid');
|
312 |
+
$templateDescriptionPopupTitle = $helper->escapeJs($helper->__('Assign Description Policy'));
|
313 |
+
|
314 |
+
$enterProductSearchQueryMessage = $helper->escapeJs(
|
315 |
+
$helper->__('Please enter Product Title or ASIN/ISBN/UPC/EAN.')
|
316 |
+
);
|
317 |
+
$autoMapAsinSearchProducts = $helper->escapeJs($helper->__('Search %product_title% Product(s) on Amazon.'));
|
318 |
+
$autoMapAsinProgressTitle = $helper->escapeJs($helper->__('Automatic Assigning ASIN/ISBN to Item(s)'));
|
319 |
+
$autoMapAsinErrorMessage = $helper->escapeJs(
|
320 |
+
$helper->__('Server is currently unavailable. Please try again later.')
|
321 |
+
);
|
322 |
+
$newAsinNotAvailable = $helper->escapeJs(
|
323 |
+
$helper->__('The new ASIN/ISBN creation functionality is not available in %code% Marketplace yet.')
|
324 |
+
);
|
325 |
+
$notSynchronizedMarketplace = $helper->escapeJs(
|
326 |
+
$helper->__(
|
327 |
+
'In order to use New ASIN/ISBN functionality, please re-synchronize Marketplace data.'
|
328 |
+
).' '.
|
329 |
+
$helper->__(
|
330 |
+
'Press "Save And Update" Button after redirect on Marketplace Page.'
|
331 |
+
)
|
332 |
+
);
|
333 |
+
|
334 |
+
$noVariationsLeftText = $helper->__('All variations are already added.');
|
335 |
+
|
336 |
+
$variationManageMatchedAttributesError = $helper->__('Please choose valid Attributes.');
|
337 |
+
$variationManageMatchedAttributesErrorDuplicateSelection =
|
338 |
+
$helper->__('You can not choose the same Attribute twice.');
|
339 |
+
|
340 |
+
$variationManageSkuPopUpTitle =
|
341 |
+
$helper->__('Enter Amazon Parent Product SKU');
|
342 |
+
|
343 |
+
$switchToIndividualModePopUpTitle = $helper->__('Change "Manage Variations" Mode');
|
344 |
+
$switchToParentModePopUpTitle = $helper->__('Change "Manage Variations" Mode');
|
345 |
+
|
346 |
+
$emptySkuError = $helper->escapeJs($helper->__('Please enter Amazon Parent Product SKU.'));
|
347 |
+
|
348 |
+
$translations = json_encode(array(
|
349 |
+
'Auto Add/Remove Rules' => $helper->__('Auto Add/Remove Rules'),
|
350 |
+
'Based on Magento Categories' => $helper->__('Based on Magento Categories'),
|
351 |
+
'You must select at least 1 Category.' => $helper->__('You must select at least 1 Category.'),
|
352 |
+
'Rule with the same Title already exists.' => $helper->__('Rule with the same Title already exists.')
|
353 |
+
));
|
354 |
+
|
355 |
+
$javascriptsMain = <<<JAVASCRIPT
|
356 |
+
<script type="text/javascript">
|
357 |
+
|
358 |
+
if (typeof M2ePro == 'undefined') {
|
359 |
+
M2ePro = {};
|
360 |
+
M2ePro.url = {};
|
361 |
+
M2ePro.formData = {};
|
362 |
+
M2ePro.customData = {};
|
363 |
+
M2ePro.text = {};
|
364 |
+
}
|
365 |
+
|
366 |
+
M2ePro.url.add({$urls});
|
367 |
+
M2ePro.translator.add({$translations});
|
368 |
+
|
369 |
+
M2ePro.productsIdsForList = '{$productsIdsForList}';
|
370 |
+
|
371 |
+
M2ePro.url.logViewUrl = '{$logViewUrl}';
|
372 |
+
M2ePro.url.getErrorsSummary = '{$getErrorsSummary}';
|
373 |
+
|
374 |
+
M2ePro.url.runListProducts = '{$runListProducts}';
|
375 |
+
M2ePro.url.runReviseProducts = '{$runReviseProducts}';
|
376 |
+
M2ePro.url.runRelistProducts = '{$runRelistProducts}';
|
377 |
+
M2ePro.url.runStopProducts = '{$runStopProducts}';
|
378 |
+
M2ePro.url.runStopAndRemoveProducts = '{$runStopAndRemoveProducts}';
|
379 |
+
M2ePro.url.runDeleteAndRemoveProducts = '{$runDeleteAndRemoveProducts}';
|
380 |
+
|
381 |
+
M2ePro.url.searchAsinManual = '{$searchAsinManual}';
|
382 |
+
M2ePro.url.getSearchAsinMenu = '{$getSearchAsinMenu}';
|
383 |
+
M2ePro.url.searchAsinAuto = '{$searchAsinAuto}';
|
384 |
+
M2ePro.url.getProductsSearchStatus = '{$getProductsSearchStatus}';
|
385 |
+
M2ePro.url.suggestedAsinGrid = '{$suggestedAsinGridHmtl}';
|
386 |
+
M2ePro.url.mapToAsin = '{$mapToAsin}';
|
387 |
+
M2ePro.url.unmapFromAsin = '{$unmapFromAsin}';
|
388 |
+
M2ePro.url.mapToNewAsin = '{$mapToNewAsin}';
|
389 |
+
|
390 |
+
M2ePro.url.variationProductManage = '{$variationProductManage}';
|
391 |
+
M2ePro.url.variationProductSetGeneralIdOwner = '{$variationProductSetGeneralIdOwner}';
|
392 |
+
M2ePro.url.variationProductSetVariationTheme = '{$variationProductSetVariationTheme}';
|
393 |
+
M2ePro.url.variationProductSetMatchedAttributes = '{$variationProductSetMatchedAttributes}';
|
394 |
+
M2ePro.url.variationProductSetListingProductSku = '{$variationProductSetListingProductSku}';
|
395 |
+
M2ePro.url.variationProductSetListingProductSku = '{$variationProductSetListingProductSku}';
|
396 |
+
M2ePro.url.manageVariationViewTemplateDescriptionsGrid = '{$manageVariationViewTemplateDescriptionsGrid}';
|
397 |
+
M2ePro.url.manageVariationMapToTemplateDescription = '{$manageVariationMapToTemplateDescription}';
|
398 |
+
M2ePro.url.viewVariationsSettingsAjax = '{$viewVariationsSettingsAjax}';
|
399 |
+
|
400 |
+
M2ePro.url.newAsin = '{$newAsinUrl}';
|
401 |
+
|
402 |
+
M2ePro.url.mapToTemplateDescription = '{$mapToTemplateDescription}';
|
403 |
+
M2ePro.url.unmapFromTemplateDescription = '{$unmapFromTemplateDescription}';
|
404 |
+
M2ePro.url.validateProductsForTemplateDescriptionAssign = '{$validateProductsForTemplateDescriptionAssign}';
|
405 |
+
M2ePro.url.viewTemplateDescriptionsGrid = '{$viewTemplateDescriptionsGrid}';
|
406 |
+
|
407 |
+
M2ePro.url.prepareData = '{$prepareData}';
|
408 |
+
M2ePro.url.getGridHtml = '{$getMoveToListingGridHtml}';
|
409 |
+
M2ePro.url.getFailedProductsGridHtml = '{$getFailedProductsGridHtml}';
|
410 |
+
M2ePro.url.tryToMoveToListing = '{$tryToMoveToListing}';
|
411 |
+
M2ePro.url.moveToListing = '{$moveToListing}';
|
412 |
+
|
413 |
+
M2ePro.url.marketplace_synch = '{$marketplaceSynchUrl}';
|
414 |
+
|
415 |
+
M2ePro.url.get_variation_edit_popup = '{$getVariationEditPopupUrl}';
|
416 |
+
M2ePro.url.get_variation_manage_popup = '{$getVariationManagePopupUrl}';
|
417 |
+
|
418 |
+
M2ePro.url.variation_edit_action = '{$variationEditActionUrl}';
|
419 |
+
M2ePro.url.variation_manage_action = '{$variationManageActionUrl}';
|
420 |
+
M2ePro.url.variation_manage_generate_action = '{$variationManageGenerateActionUrl}';
|
421 |
+
M2ePro.url.variation_reset_action = '{$variationResetActionUrl}';
|
422 |
+
|
423 |
+
M2ePro.url.save_listing_additional_data = '{$saveListingAdditionalDataActionUrl}';
|
424 |
+
|
425 |
+
M2ePro.text.popup_title = '{$popupTitle}';
|
426 |
+
M2ePro.text.popup_title_single = '{$popupTitleSingle}';
|
427 |
+
M2ePro.text.failed_products_popup_title = '{$failedProductsPopupTitle}';
|
428 |
+
|
429 |
+
M2ePro.text.task_completed_message = '{$taskCompletedMessage}';
|
430 |
+
M2ePro.text.task_completed_success_message = '{$taskCompletedSuccessMessage}';
|
431 |
+
M2ePro.text.task_completed_warning_message = '{$taskCompletedWarningMessage}';
|
432 |
+
M2ePro.text.task_completed_error_message = '{$taskCompletedErrorMessage}';
|
433 |
+
|
434 |
+
M2ePro.text.locked_obj_notice = '{$lockedObjNoticeMessage}';
|
435 |
+
M2ePro.text.sending_data_message = '{$sendingDataToAmazonMessage}';
|
436 |
+
M2ePro.text.view_all_product_log_message = '{$viewAllProductLogMessage}';
|
437 |
+
|
438 |
+
M2ePro.text.listing_locked_message = '{$listingLockedMessage}';
|
439 |
+
M2ePro.text.listing_empty_message = '{$listingEmptyMessage}';
|
440 |
+
|
441 |
+
M2ePro.text.listing_all_items_message = '{$listingAllItemsMessage}';
|
442 |
+
M2ePro.text.listing_selected_items_message = '{$listingSelectedItemsMessage}';
|
443 |
+
M2ePro.text.revising_selected_items_message = '{$revisingSelectedItemsMessage}';
|
444 |
+
M2ePro.text.relisting_selected_items_message = '{$relistingSelectedItemsMessage}';
|
445 |
+
M2ePro.text.stopping_selected_items_message = '{$stoppingSelectedItemsMessage}';
|
446 |
+
M2ePro.text.stopping_and_removing_selected_items_message = '{$stoppingAndRemovingSelectedItemsMessage}';
|
447 |
+
M2ePro.text.deleting_and_removing_selected_items_message = '{$deletingAndRemovingSelectedItemsMessage}';
|
448 |
+
|
449 |
+
M2ePro.text.successfully_moved = '{$successfullyMovedMessage}';
|
450 |
+
M2ePro.text.products_were_not_moved = '{$productsWereNotMovedMessage}';
|
451 |
+
M2ePro.text.some_products_were_not_moved = '{$someProductsWereNotMovedMessage}';
|
452 |
+
|
453 |
+
M2ePro.text.select_items_message = '{$selectItemsMessage}';
|
454 |
+
M2ePro.text.select_action_message = '{$selectActionMessage}';
|
455 |
+
|
456 |
+
M2ePro.text.success_word = '{$successWord}';
|
457 |
+
M2ePro.text.notice_word = '{$noticeWord}';
|
458 |
+
M2ePro.text.warning_word = '{$warningWord}';
|
459 |
+
M2ePro.text.error_word = '{$errorWord}';
|
460 |
+
M2ePro.text.close_word = '{$closeWord}';
|
461 |
+
|
462 |
+
M2ePro.text.templateDescriptionPopupTitle = '{$templateDescriptionPopupTitle}';
|
463 |
+
|
464 |
+
M2ePro.text.assign = '{$assignString}';
|
465 |
+
M2ePro.text.confirm = '{$textConfirm}';
|
466 |
+
|
467 |
+
M2ePro.text.enter_productSearch_query = '{$enterProductSearchQueryMessage}';
|
468 |
+
M2ePro.text.automap_asin_search_products = '{$autoMapAsinSearchProducts}';
|
469 |
+
M2ePro.text.automap_asin_progress_title = '{$autoMapAsinProgressTitle}';
|
470 |
+
M2ePro.text.automap_error_message = '{$autoMapAsinErrorMessage}';
|
471 |
+
|
472 |
+
M2ePro.text.new_asin_not_available = '{$newAsinNotAvailable}';
|
473 |
+
M2ePro.text.not_synchronized_marketplace = '{$notSynchronizedMarketplace}';
|
474 |
+
|
475 |
+
M2ePro.text.no_variations_left = '{$noVariationsLeftText}';
|
476 |
+
|
477 |
+
M2ePro.text.variation_manage_matched_attributes_error = '{$variationManageMatchedAttributesError}';
|
478 |
+
M2ePro.text.variation_manage_matched_attributes_error_duplicate =
|
479 |
+
'{$variationManageMatchedAttributesErrorDuplicateSelection}';
|
480 |
+
|
481 |
+
M2ePro.text.variation_manage_matched_sku_popup_title = '{$variationManageSkuPopUpTitle}';
|
482 |
+
M2ePro.text.empty_sku_error = '{$emptySkuError}';
|
483 |
+
|
484 |
+
M2ePro.text.switch_to_individual_mode_popup_title = '{$switchToIndividualModePopUpTitle}';
|
485 |
+
M2ePro.text.switch_to_parent_mode_popup_title = '{$switchToParentModePopUpTitle}';
|
486 |
+
|
487 |
+
M2ePro.customData.componentMode = '{$component}';
|
488 |
+
M2ePro.customData.gridId = '{$gridId}';
|
489 |
+
M2ePro.customData.ignoreListings = '{$ignoreListings}';
|
490 |
+
|
491 |
+
M2ePro.customData.marketplace = {$marketplace};
|
492 |
+
M2ePro.customData.isNewAsinAvailable = {$isNewAsinAvailable};
|
493 |
+
M2ePro.customData.isMarketplaceSynchronized = {$isMarketplaceSynchronized};
|
494 |
+
|
495 |
+
Event.observe(window, 'load', function() {
|
496 |
+
|
497 |
+
ListingGridHandlerObj = new AmazonListingGridHandler(
|
498 |
+
'{$gridId}',
|
499 |
+
{$listingData['id']}
|
500 |
+
);
|
501 |
+
|
502 |
+
// todo next
|
503 |
+
ListingGridHandlerObj.actionHandler.setOptions(M2ePro);
|
504 |
+
ListingGridHandlerObj.movingHandler.setOptions(M2ePro);
|
505 |
+
ListingGridHandlerObj.productSearchHandler.setOptions(M2ePro);
|
506 |
+
ListingGridHandlerObj.templateDescriptionHandler.setOptions(M2ePro);
|
507 |
+
ListingGridHandlerObj.variationProductManageHandler.setOptions(M2ePro);
|
508 |
+
|
509 |
+
ListingProgressBarObj = new ProgressBar('listing_view_progress_bar');
|
510 |
+
GridWrapperObj = new AreaWrapper('listing_view_content_container');
|
511 |
+
|
512 |
+
ListingProductVariationHandlerObj = new ListingProductVariationHandler(M2ePro,
|
513 |
+
ListingGridHandlerObj);
|
514 |
+
|
515 |
+
if (M2ePro.productsIdsForList) {
|
516 |
+
ListingGridHandlerObj.getGridMassActionObj().checkedString = M2ePro.productsIdsForList;
|
517 |
+
ListingGridHandlerObj.actionHandler.listAction();
|
518 |
+
}
|
519 |
+
|
520 |
+
ListingAutoActionHandlerObj = new ListingAutoActionHandler();
|
521 |
+
if ({$showAutoAction}) {
|
522 |
+
ListingAutoActionHandlerObj.loadAutoActionHtml();
|
523 |
+
}
|
524 |
+
|
525 |
+
});
|
526 |
+
|
527 |
+
</script>
|
528 |
+
JAVASCRIPT;
|
529 |
+
|
530 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_listing_view_help');
|
531 |
+
$productSearchBlock = $this->getLayout()
|
532 |
+
->createBlock('M2ePro/adminhtml_common_amazon_listing_productSearch_main');
|
533 |
+
|
534 |
+
//------------------------------
|
535 |
+
$data = array(
|
536 |
+
'target_css_class' => 'edit_settings_drop_down',
|
537 |
+
'items' => $this->getTemplatesButtonDropDownItems()
|
538 |
+
);
|
539 |
+
$templatesDropDownBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_button_dropDown');
|
540 |
+
$templatesDropDownBlock->setData($data);
|
541 |
+
//------------------------------
|
542 |
+
|
543 |
+
//------------------------------
|
544 |
+
$data = array(
|
545 |
+
'target_css_class' => 'add_products_drop_down',
|
546 |
+
'items' => $this->getAddProductsDropDownItems()
|
547 |
+
);
|
548 |
+
$addProductsDropDownBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_button_dropDown');
|
549 |
+
$addProductsDropDownBlock->setData($data);
|
550 |
+
//------------------------------
|
551 |
+
|
552 |
+
//------------------------------
|
553 |
+
$listingSwitcher = $this->getLayout()->createBlock(
|
554 |
+
'M2ePro/adminhtml_common_amazon_listing_view_listingSwitcher'
|
555 |
+
);
|
556 |
+
//------------------------------
|
557 |
+
|
558 |
+
//------------------------------
|
559 |
+
$viewHeaderBlock = $this->getLayout()->createBlock(
|
560 |
+
'M2ePro/adminhtml_listing_view_header','',
|
561 |
+
array('listing' => Mage::helper('M2ePro/Component_Amazon')->getCachedObject('Listing',$listingData['id']))
|
562 |
+
);
|
563 |
+
//------------------------------
|
564 |
+
|
565 |
+
//------------------------------
|
566 |
+
$switchToIndividualPopup = $this->getLayout()->createBlock(
|
567 |
+
'M2ePro/adminhtml_common_amazon_listing_variation_product_switchToIndividualPopup');
|
568 |
+
//------------------------------
|
569 |
+
|
570 |
+
//------------------------------
|
571 |
+
$switchToParentPopup = $this->getLayout()->createBlock(
|
572 |
+
'M2ePro/adminhtml_common_amazon_listing_variation_product_switchToParentPopup');
|
573 |
+
//------------------------------
|
574 |
+
|
575 |
+
return $javascriptsMain
|
576 |
+
. $templatesDropDownBlock->toHtml()
|
577 |
+
. $listingSwitcher->toHtml()
|
578 |
+
. $addProductsDropDownBlock->toHtml()
|
579 |
+
. $helpBlock->toHtml()
|
580 |
+
. $viewHeaderBlock->toHtml()
|
581 |
+
. $productSearchBlock->toHtml()
|
582 |
+
. $switchToIndividualPopup->toHtml()
|
583 |
+
. $switchToParentPopup->toHtml()
|
584 |
+
. parent::getGridHtml();
|
585 |
+
}
|
586 |
+
|
587 |
+
public function getHeaderHtml()
|
588 |
+
{
|
589 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
590 |
+
|
591 |
+
//------------------------------
|
592 |
+
$collection = Mage::getModel('M2ePro/Listing')->getCollection();
|
593 |
+
$collection->addFieldToFilter('component_mode', Ess_M2ePro_Helper_Component_Amazon::NICK);
|
594 |
+
$collection->addFieldToFilter('id', array('neq' => $listingData['id']));
|
595 |
+
$collection->setPageSize(200);
|
596 |
+
$collection->setOrder('title', 'ASC');
|
597 |
+
|
598 |
+
$items = array();
|
599 |
+
foreach ($collection->getItems() as $item) {
|
600 |
+
$items[] = array(
|
601 |
+
'label' => $item->getTitle(),
|
602 |
+
'url' => $this->getUrl('*/*/view', array('id' => $item->getId()))
|
603 |
+
);
|
604 |
+
}
|
605 |
+
//------------------------------
|
606 |
+
|
607 |
+
if (count($items) == 0) {
|
608 |
+
return parent::getHeaderHtml();
|
609 |
+
}
|
610 |
+
|
611 |
+
//------------------------------
|
612 |
+
$data = array(
|
613 |
+
'target_css_class' => 'listing-profile-title',
|
614 |
+
'style' => 'max-height: 120px; overflow: auto; width: 200px;',
|
615 |
+
'items' => $items
|
616 |
+
);
|
617 |
+
$dropDownBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_button_dropDown');
|
618 |
+
$dropDownBlock->setData($data);
|
619 |
+
//------------------------------
|
620 |
+
|
621 |
+
return parent::getHeaderHtml() . $dropDownBlock->toHtml();
|
622 |
+
}
|
623 |
+
|
624 |
+
public function getHeaderText()
|
625 |
+
{
|
626 |
+
//------------------------------
|
627 |
+
$changeProfile = Mage::helper('M2ePro')->__('Change Listing');
|
628 |
+
$headerText = parent::getHeaderText();
|
629 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
630 |
+
$listingTitle = Mage::helper('M2ePro')->escapeHtml($listingData['title']);
|
631 |
+
//------------------------------
|
632 |
+
|
633 |
+
return <<<HTML
|
634 |
+
{$headerText} <a href="javascript: void(0);"
|
635 |
+
id="listing-profile-title"
|
636 |
+
class="listing-profile-title"
|
637 |
+
style="font-weight: bold;"
|
638 |
+
title="{$changeProfile}"><span class="drop_down_header">"{$listingTitle}"</span></a>
|
639 |
+
HTML;
|
640 |
+
}
|
641 |
+
|
642 |
+
protected function getTemplatesButtonDropDownItems()
|
643 |
+
{
|
644 |
+
$items = array();
|
645 |
+
|
646 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
647 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
648 |
+
'*/adminhtml_common_amazon_listing/view',
|
649 |
+
array(
|
650 |
+
'id' => $listingData['id']
|
651 |
+
)
|
652 |
+
);
|
653 |
+
|
654 |
+
//------------------------------
|
655 |
+
$url = $this->getUrl(
|
656 |
+
'*/adminhtml_common_amazon_listing/edit',
|
657 |
+
array(
|
658 |
+
'id'=>$listingData['id'],
|
659 |
+
'back'=>$backUrl,
|
660 |
+
'tab' => 'selling'
|
661 |
+
)
|
662 |
+
);
|
663 |
+
$items[] = array(
|
664 |
+
'url' => $url,
|
665 |
+
'label' => Mage::helper('M2ePro')->__('Selling'),
|
666 |
+
'target' => '_blank'
|
667 |
+
);
|
668 |
+
//------------------------------
|
669 |
+
|
670 |
+
//------------------------------
|
671 |
+
$url = $this->getUrl(
|
672 |
+
'*/adminhtml_common_amazon_listing/edit',
|
673 |
+
array(
|
674 |
+
'id'=>$listingData['id'],
|
675 |
+
'back'=>$backUrl,
|
676 |
+
'tab' => 'search'
|
677 |
+
)
|
678 |
+
);
|
679 |
+
$items[] = array(
|
680 |
+
'url' => $url,
|
681 |
+
'label' => Mage::helper('M2ePro')->__('Search'),
|
682 |
+
'target' => '_blank'
|
683 |
+
);
|
684 |
+
//------------------------------
|
685 |
+
|
686 |
+
//------------------------------
|
687 |
+
$items[] = array(
|
688 |
+
'url' => 'javascript: void(0);',
|
689 |
+
'onclick' => 'ListingAutoActionHandlerObj.loadAutoActionHtml();',
|
690 |
+
'label' => Mage::helper('M2ePro')->__('Auto Add/Remove Rules')
|
691 |
+
);
|
692 |
+
//------------------------------
|
693 |
+
|
694 |
+
return $items;
|
695 |
+
}
|
696 |
+
|
697 |
+
public function getAddProductsDropDownItems()
|
698 |
+
{
|
699 |
+
$items = array();
|
700 |
+
|
701 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
702 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_amazon_listing/view', array(
|
703 |
+
'id' => $listingData['id']
|
704 |
+
));
|
705 |
+
|
706 |
+
//------------------------------
|
707 |
+
$url = $this->getUrl(
|
708 |
+
'*/adminhtml_common_listing_productAdd/index',
|
709 |
+
array(
|
710 |
+
'id' => $listingData['id'],
|
711 |
+
'back' => $backUrl,
|
712 |
+
'component' => Ess_M2ePro_Helper_Component_Amazon::NICK,
|
713 |
+
'clear' => 1,
|
714 |
+
'step' => 2,
|
715 |
+
'source' => Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_SourceMode::SOURCE_LIST
|
716 |
+
)
|
717 |
+
);
|
718 |
+
$items[] = array(
|
719 |
+
'url' => $url,
|
720 |
+
'label' => Mage::helper('M2ePro')->__('From Products List')
|
721 |
+
);
|
722 |
+
//------------------------------
|
723 |
+
|
724 |
+
//------------------------------
|
725 |
+
$url = $this->getUrl(
|
726 |
+
'*/adminhtml_common_listing_productAdd/index',
|
727 |
+
array(
|
728 |
+
'id' => $listingData['id'],
|
729 |
+
'back' => $backUrl,
|
730 |
+
'component' => Ess_M2ePro_Helper_Component_Amazon::NICK,
|
731 |
+
'clear' => 1,
|
732 |
+
'step' => 2,
|
733 |
+
'source' => Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_SourceMode::SOURCE_CATEGORIES
|
734 |
+
)
|
735 |
+
);
|
736 |
+
$items[] = array(
|
737 |
+
'url' => $url,
|
738 |
+
'label' => Mage::helper('M2ePro')->__('From Categories')
|
739 |
+
);
|
740 |
+
//------------------------------
|
741 |
+
|
742 |
+
return $items;
|
743 |
+
}
|
744 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View/Amazon/Grid.php
ADDED
@@ -0,0 +1,1421 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_View_Amazon_Grid
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Magento_Product_Grid_Abstract
|
9 |
+
{
|
10 |
+
/** @var $sellingFormatTemplate Ess_M2ePro_Model_Amazon_Template_SellingFormat */
|
11 |
+
private $sellingFormatTemplate = NULL;
|
12 |
+
|
13 |
+
private $lockedDataCache = array();
|
14 |
+
|
15 |
+
private $hideSwitchToIndividualConfirm;
|
16 |
+
private $hideSwitchToParentConfirm;
|
17 |
+
|
18 |
+
// ####################################
|
19 |
+
|
20 |
+
public function __construct()
|
21 |
+
{
|
22 |
+
parent::__construct();
|
23 |
+
|
24 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
25 |
+
|
26 |
+
$listing = Mage::helper('M2ePro/Component')->getUnknownObject('Listing', $listingData['id']);
|
27 |
+
|
28 |
+
$this->hideSwitchToIndividualConfirm =
|
29 |
+
$listing->getSetting('additional_data', 'hide_switch_to_individual_confirm', 0);
|
30 |
+
|
31 |
+
$this->hideSwitchToParentConfirm =
|
32 |
+
$listing->getSetting('additional_data', 'hide_switch_to_parent_confirm', 0);
|
33 |
+
|
34 |
+
// Initialization block
|
35 |
+
//------------------------------
|
36 |
+
$this->setId('amazonListingViewAmazonGrid'.$listingData['id']);
|
37 |
+
//------------------------------
|
38 |
+
|
39 |
+
$this->showAdvancedFilterProductsOption = false;
|
40 |
+
|
41 |
+
$this->sellingFormatTemplate = Mage::helper('M2ePro/Component_Amazon')->getCachedObject(
|
42 |
+
'Template_SellingFormat', $listingData['template_selling_format_id'], NULL,
|
43 |
+
array('template')
|
44 |
+
);
|
45 |
+
}
|
46 |
+
|
47 |
+
// ####################################
|
48 |
+
|
49 |
+
public function getMainButtonsHtml()
|
50 |
+
{
|
51 |
+
$data = array(
|
52 |
+
'current_view_mode' => $this->getParentBlock()->getViewMode()
|
53 |
+
);
|
54 |
+
$viewModeSwitcherBlock = $this->getLayout()->createBlock(
|
55 |
+
'M2ePro/adminhtml_common_amazon_listing_view_modeSwitcher'
|
56 |
+
);
|
57 |
+
$viewModeSwitcherBlock->addData($data);
|
58 |
+
|
59 |
+
return $viewModeSwitcherBlock->toHtml() . parent::getMainButtonsHtml();
|
60 |
+
}
|
61 |
+
|
62 |
+
// ####################################
|
63 |
+
|
64 |
+
protected function _prepareCollection()
|
65 |
+
{
|
66 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
67 |
+
|
68 |
+
// Get collection
|
69 |
+
//----------------------------
|
70 |
+
/* @var $collection Mage_Core_Model_Mysql4_Collection_Abstract */
|
71 |
+
$collection = Mage::getConfig()->getModelInstance('Ess_M2ePro_Model_Mysql4_Magento_Product_Collection',
|
72 |
+
Mage::getModel('catalog/product')->getResource());
|
73 |
+
$collection->setListingProductModeOn();
|
74 |
+
$collection
|
75 |
+
->addAttributeToSelect('name')
|
76 |
+
->addAttributeToSelect('sku')
|
77 |
+
->joinTable(
|
78 |
+
array('cisi' => 'cataloginventory/stock_item'),
|
79 |
+
'product_id=entity_id',
|
80 |
+
array('qty' => 'qty'),
|
81 |
+
'{{table}}.stock_id=1',
|
82 |
+
'left'
|
83 |
+
);
|
84 |
+
|
85 |
+
//----------------------------
|
86 |
+
|
87 |
+
$collection->joinTable(
|
88 |
+
array('lp' => 'M2ePro/Listing_Product'),
|
89 |
+
'product_id=entity_id',
|
90 |
+
array(
|
91 |
+
'id' => 'id',
|
92 |
+
'component_mode' => 'component_mode',
|
93 |
+
'amazon_status' => 'status',
|
94 |
+
'additional_data' => 'additional_data'
|
95 |
+
),
|
96 |
+
array(
|
97 |
+
'listing_id' => (int)$listingData['id']
|
98 |
+
)
|
99 |
+
);
|
100 |
+
$collection->joinTable(
|
101 |
+
array('alp' => 'M2ePro/Amazon_Listing_Product'),
|
102 |
+
'listing_product_id=id',
|
103 |
+
array(
|
104 |
+
'general_id' => 'general_id',
|
105 |
+
'general_id_search_info' => 'general_id_search_info',
|
106 |
+
'search_settings_status' => 'search_settings_status',
|
107 |
+
'search_settings_data' => 'search_settings_data',
|
108 |
+
'variation_child_statuses' => 'variation_child_statuses',
|
109 |
+
'amazon_sku' => 'sku',
|
110 |
+
'online_qty' => 'online_qty',
|
111 |
+
'online_price' => 'online_price',
|
112 |
+
'online_sale_price' => 'online_sale_price',
|
113 |
+
'online_sale_price_start_date' => 'online_sale_price_start_date',
|
114 |
+
'online_sale_price_end_date' => 'online_sale_price_end_date',
|
115 |
+
'is_afn_channel' => 'is_afn_channel',
|
116 |
+
'is_general_id_owner' => 'is_general_id_owner',
|
117 |
+
'is_variation_parent' => 'is_variation_parent'
|
118 |
+
),
|
119 |
+
'{{table}}.variation_parent_id is NULL'
|
120 |
+
);
|
121 |
+
//----------------------------
|
122 |
+
// exit($collection->getSelect()->__toString());
|
123 |
+
|
124 |
+
// Set collection to grid
|
125 |
+
$this->setCollection($collection);
|
126 |
+
|
127 |
+
return parent::_prepareCollection();
|
128 |
+
}
|
129 |
+
|
130 |
+
protected function _prepareColumns()
|
131 |
+
{
|
132 |
+
$this->addColumn('product_id', array(
|
133 |
+
'header' => Mage::helper('M2ePro')->__('Product ID'),
|
134 |
+
'align' => 'right',
|
135 |
+
'width' => '100px',
|
136 |
+
'type' => 'number',
|
137 |
+
'index' => 'entity_id',
|
138 |
+
'filter_index' => 'entity_id',
|
139 |
+
'frame_callback' => array($this, 'callbackColumnProductId')
|
140 |
+
));
|
141 |
+
|
142 |
+
$this->addColumn('name', array(
|
143 |
+
'header' => Mage::helper('M2ePro')->__('Product Title / Product SKU'),
|
144 |
+
'align' => 'left',
|
145 |
+
//'width' => '300px',
|
146 |
+
'type' => 'text',
|
147 |
+
'index' => 'name',
|
148 |
+
'filter_index' => 'name',
|
149 |
+
'frame_callback' => array($this, 'callbackColumnProductTitle'),
|
150 |
+
'filter_condition_callback' => array($this, 'callbackFilterTitle')
|
151 |
+
));
|
152 |
+
|
153 |
+
$this->addColumn('sku', array(
|
154 |
+
'header' => Mage::helper('M2ePro')->__('SKU'),
|
155 |
+
'align' => 'left',
|
156 |
+
'width' => '150px',
|
157 |
+
'type' => 'text',
|
158 |
+
'index' => 'amazon_sku',
|
159 |
+
'filter_index' => 'amazon_sku',
|
160 |
+
'frame_callback' => array($this, 'callbackColumnAmazonSku')
|
161 |
+
));
|
162 |
+
|
163 |
+
$this->addColumn('general_id', array(
|
164 |
+
'header' => Mage::helper('M2ePro')->__('ASIN / ISBN'),
|
165 |
+
'align' => 'left',
|
166 |
+
'width' => '140px',
|
167 |
+
'type' => 'text',
|
168 |
+
'index' => 'general_id',
|
169 |
+
'filter_index' => 'general_id',
|
170 |
+
'frame_callback' => array($this, 'callbackColumnGeneralId')
|
171 |
+
));
|
172 |
+
|
173 |
+
$this->addColumn('online_qty', array(
|
174 |
+
'header' => Mage::helper('M2ePro')->__('QTY'),
|
175 |
+
'align' => 'right',
|
176 |
+
'width' => '70px',
|
177 |
+
'type' => 'number',
|
178 |
+
'index' => 'online_qty',
|
179 |
+
'filter_index' => 'online_qty',
|
180 |
+
'frame_callback' => array($this, 'callbackColumnAvailableQty')
|
181 |
+
));
|
182 |
+
|
183 |
+
$this->addColumn('online_price', array(
|
184 |
+
'header' => Mage::helper('M2ePro')->__('Price'),
|
185 |
+
'align' => 'right',
|
186 |
+
'width' => '70px',
|
187 |
+
'type' => 'number',
|
188 |
+
'index' => 'online_price',
|
189 |
+
'filter_index' => 'online_price',
|
190 |
+
'frame_callback' => array($this, 'callbackColumnPrice'),
|
191 |
+
'filter_condition_callback' => array($this, 'callbackFilterPrice')
|
192 |
+
));
|
193 |
+
|
194 |
+
$this->addColumn('is_afn_channel', array(
|
195 |
+
'header' => Mage::helper('M2ePro')->__('Fulfillment'),
|
196 |
+
'align' => 'right',
|
197 |
+
'width' => '90px',
|
198 |
+
'index' => 'is_afn_channel',
|
199 |
+
'filter_index' => 'is_afn_channel',
|
200 |
+
'type' => 'options',
|
201 |
+
'sortable' => false,
|
202 |
+
'options' => array(
|
203 |
+
0 => Mage::helper('M2ePro')->__('Merchant'),
|
204 |
+
1 => Mage::helper('M2ePro')->__('Amazon')
|
205 |
+
),
|
206 |
+
'frame_callback' => array($this, 'callbackColumnAfnChannel')
|
207 |
+
));
|
208 |
+
|
209 |
+
$this->addColumn('status', array(
|
210 |
+
'header' => Mage::helper('M2ePro')->__('Status'),
|
211 |
+
'width' => '145px',
|
212 |
+
'index' => 'amazon_status',
|
213 |
+
'filter_index' => 'amazon_status',
|
214 |
+
'type' => 'options',
|
215 |
+
'sortable' => false,
|
216 |
+
'options' => array(
|
217 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_UNKNOWN => Mage::helper('M2ePro')->__('Unknown'),
|
218 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED => Mage::helper('M2ePro')->__('Not Listed'),
|
219 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_LISTED => Mage::helper('M2ePro')->__('Active'),
|
220 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED => Mage::helper('M2ePro')->__('Inactive'),
|
221 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_BLOCKED => Mage::helper('M2ePro')->__('Inactive (Blocked)')
|
222 |
+
),
|
223 |
+
'frame_callback' => array($this, 'callbackColumnStatus'),
|
224 |
+
'filter_condition_callback' => array($this, 'callbackFilterStatus')
|
225 |
+
));
|
226 |
+
|
227 |
+
if (Mage::helper('M2ePro/Module')->isDevelopmentMode()) {
|
228 |
+
$this->addColumn('developer_action', array(
|
229 |
+
'header' => Mage::helper('M2ePro')->__('Actions'),
|
230 |
+
'align' => 'left',
|
231 |
+
'width' => '100px',
|
232 |
+
'type' => 'text',
|
233 |
+
'renderer' => 'M2ePro/adminhtml_listing_view_grid_column_renderer_developerAction',
|
234 |
+
'index' => 'value',
|
235 |
+
'filter' => false,
|
236 |
+
'sortable' => false,
|
237 |
+
'js_handler' => 'ListingGridHandlerObj'
|
238 |
+
));
|
239 |
+
}
|
240 |
+
|
241 |
+
return parent::_prepareColumns();
|
242 |
+
}
|
243 |
+
|
244 |
+
protected function _prepareMassaction()
|
245 |
+
{
|
246 |
+
// Set massaction identifiers
|
247 |
+
//--------------------------------
|
248 |
+
$this->setMassactionIdField('id');
|
249 |
+
$this->setMassactionIdFieldOnlyIndexValue(true);
|
250 |
+
//--------------------------------
|
251 |
+
|
252 |
+
// Set mass-action
|
253 |
+
//--------------------------------
|
254 |
+
$groups = array(
|
255 |
+
'actions' => Mage::helper('M2ePro')->__('Actions'),
|
256 |
+
'description_policy' => Mage::helper('M2ePro')->__('Description Policy'),
|
257 |
+
'asin_isbn' => Mage::helper('M2ePro')->__('ASIN / ISBN'),
|
258 |
+
'other' => Mage::helper('M2ePro')->__('Other'),
|
259 |
+
);
|
260 |
+
|
261 |
+
$this->getMassactionBlock()->setGroups($groups);
|
262 |
+
|
263 |
+
$this->getMassactionBlock()->addItem('list', array(
|
264 |
+
'label' => Mage::helper('M2ePro')->__('List Item(s)'),
|
265 |
+
'url' => '',
|
266 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
267 |
+
), 'actions');
|
268 |
+
|
269 |
+
$this->getMassactionBlock()->addItem('revise', array(
|
270 |
+
'label' => Mage::helper('M2ePro')->__('Revise Item(s)'),
|
271 |
+
'url' => '',
|
272 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
273 |
+
), 'actions');
|
274 |
+
|
275 |
+
$this->getMassactionBlock()->addItem('relist', array(
|
276 |
+
'label' => Mage::helper('M2ePro')->__('Relist Item(s)'),
|
277 |
+
'url' => '',
|
278 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
279 |
+
), 'actions');
|
280 |
+
|
281 |
+
$this->getMassactionBlock()->addItem('stop', array(
|
282 |
+
'label' => Mage::helper('M2ePro')->__('Stop Item(s)'),
|
283 |
+
'url' => '',
|
284 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
285 |
+
), 'actions');
|
286 |
+
|
287 |
+
$this->getMassactionBlock()->addItem('stopAndRemove', array(
|
288 |
+
'label' => Mage::helper('M2ePro')->__('Stop on Channel / Remove from Listing'),
|
289 |
+
'url' => '',
|
290 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
291 |
+
), 'actions');
|
292 |
+
|
293 |
+
$this->getMassactionBlock()->addItem('deleteAndRemove', array(
|
294 |
+
'label' => Mage::helper('M2ePro')->__('Remove from Channel & Listing'),
|
295 |
+
'url' => '',
|
296 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
297 |
+
), 'actions');
|
298 |
+
|
299 |
+
$this->getMassactionBlock()->addItem('assignTemplateDescriptionId', array(
|
300 |
+
'label' => Mage::helper('M2ePro')->__('Assign'),
|
301 |
+
'url' => '',
|
302 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
303 |
+
), 'description_policy');
|
304 |
+
|
305 |
+
$this->getMassactionBlock()->addItem('unassignTemplateDescriptionId', array(
|
306 |
+
'label' => Mage::helper('M2ePro')->__('Unassign'),
|
307 |
+
'url' => '',
|
308 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
309 |
+
), 'description_policy');
|
310 |
+
|
311 |
+
$this->getMassactionBlock()->addItem('assignGeneralId', array(
|
312 |
+
'label' => Mage::helper('M2ePro')->__('Search Automatically'),
|
313 |
+
'url' => '',
|
314 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
315 |
+
), 'asin_isbn');
|
316 |
+
|
317 |
+
$this->getMassactionBlock()->addItem('newGeneralId', array(
|
318 |
+
'label' => Mage::helper('M2ePro')->__('Assign Settings for New ASIN/ISBN'),
|
319 |
+
'url' => '',
|
320 |
+
), 'asin_isbn');
|
321 |
+
|
322 |
+
$this->getMassactionBlock()->addItem('unassignGeneralId', array(
|
323 |
+
'label' => Mage::helper('M2ePro')->__('Reset Information'),
|
324 |
+
'url' => '',
|
325 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
326 |
+
), 'asin_isbn');
|
327 |
+
|
328 |
+
$this->getMassactionBlock()->addItem('moving', array(
|
329 |
+
'label' => Mage::helper('M2ePro')->__('Move Item(s) to Another Listing'),
|
330 |
+
'url' => '',
|
331 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
332 |
+
), 'other');
|
333 |
+
|
334 |
+
$this->getMassactionBlock()->addItem('duplicate', array(
|
335 |
+
'label' => Mage::helper('M2ePro')->__('Duplicate'),
|
336 |
+
'url' => '',
|
337 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
338 |
+
), 'other');
|
339 |
+
//--------------------------------
|
340 |
+
|
341 |
+
return parent::_prepareMassaction();
|
342 |
+
}
|
343 |
+
|
344 |
+
// ####################################
|
345 |
+
|
346 |
+
public function callbackColumnProductTitle($productTitle, $row, $column, $isExport)
|
347 |
+
{
|
348 |
+
$productTitle = Mage::helper('M2ePro')->escapeHtml($productTitle);
|
349 |
+
|
350 |
+
$value = '<span>'.$productTitle.'</span>';
|
351 |
+
|
352 |
+
$tempSku = $row->getData('sku');
|
353 |
+
is_null($tempSku)
|
354 |
+
&& $tempSku = Mage::getModel('M2ePro/Magento_Product')->setProductId($row->getData('entity_id'))->getSku();
|
355 |
+
|
356 |
+
$value .= '<br/><strong>'.Mage::helper('M2ePro')->__('SKU') .
|
357 |
+
':</strong> '.Mage::helper('M2ePro')->escapeHtml($tempSku) . '<br/>';
|
358 |
+
|
359 |
+
$listingProductId = (int)$row->getData('id');
|
360 |
+
/** @var Ess_M2ePro_Model_Listing_Product $listingProduct */
|
361 |
+
$listingProduct = Mage::helper('M2ePro/Component_Amazon')->getObject('Listing_Product',$listingProductId);
|
362 |
+
|
363 |
+
if ($listingProduct->getChildObject()->isExistDescriptionTemplate()) {
|
364 |
+
$value .= $this->getTemplateDescriptionLinkHtml($listingProduct);
|
365 |
+
}
|
366 |
+
|
367 |
+
if (!$listingProduct->getChildObject()->getVariationManager()->isVariationProduct()) {
|
368 |
+
return $value;
|
369 |
+
}
|
370 |
+
|
371 |
+
$generalId = $row->getData('general_id');
|
372 |
+
|
373 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product $amazonListingProduct */
|
374 |
+
$amazonListingProduct = $listingProduct->getChildObject();
|
375 |
+
$variationManager = $amazonListingProduct->getVariationManager();
|
376 |
+
|
377 |
+
if ($variationManager->isRelationParentType()) {
|
378 |
+
|
379 |
+
$productAttributes = (array)$variationManager->getTypeModel()->getProductAttributes();
|
380 |
+
|
381 |
+
$value .= '<div style="font-size: 11px; font-weight: bold; color: grey; margin-left: 7px"><br/>';
|
382 |
+
$value .= implode(', ', $productAttributes);
|
383 |
+
|
384 |
+
if (empty($generalId) && !$amazonListingProduct->isGeneralIdOwner()) {
|
385 |
+
$popupTitle = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')->escapeHtml(
|
386 |
+
Mage::helper('M2ePro')->__('Manage Magento Product Variations'))
|
387 |
+
);
|
388 |
+
|
389 |
+
$linkTitle = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')->escapeHtml(
|
390 |
+
Mage::helper('M2ePro')->__('Change "Magento Variations" Mode'))
|
391 |
+
);
|
392 |
+
|
393 |
+
$iconSettingsPath = $this->getSkinUrl('M2ePro/images/settings.png');
|
394 |
+
|
395 |
+
$switchToIndividualJsMethod = <<<JS
|
396 |
+
ListingProductVariationHandlerObj
|
397 |
+
.setListingProductId({$listingProductId})
|
398 |
+
.showSwitchToIndividualModePopUp('{$popupTitle}');
|
399 |
+
JS;
|
400 |
+
|
401 |
+
if ($this->hideSwitchToIndividualConfirm) {
|
402 |
+
$switchToIndividualJsMethod = <<<JS
|
403 |
+
ListingProductVariationHandlerObj
|
404 |
+
.setListingProductId({$listingProductId})
|
405 |
+
.showManagePopup('{$popupTitle}');
|
406 |
+
JS;
|
407 |
+
}
|
408 |
+
|
409 |
+
$value .= <<<HTML
|
410 |
+
|
411 |
+
<a href="javascript:"
|
412 |
+
onclick="{$switchToIndividualJsMethod}"
|
413 |
+
title="{$linkTitle}">
|
414 |
+
<img width="12" height="12" style="height: 12px; width: 12px; vertical-align: middle;" src="{$iconSettingsPath}">
|
415 |
+
</a>
|
416 |
+
HTML;
|
417 |
+
}
|
418 |
+
|
419 |
+
$value .= '</div>';
|
420 |
+
|
421 |
+
if (!empty($generalId) || $amazonListingProduct->isGeneralIdOwner()) {
|
422 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager_Type_Relation_Parent $parentType */
|
423 |
+
$parentType = $variationManager->getTypeModel();
|
424 |
+
|
425 |
+
$linkContent = Mage::helper('M2ePro')->__('Manage Variations');
|
426 |
+
$vpmt = Mage::helper('M2ePro')->__('Manage Variations of "%s" ', $productTitle);
|
427 |
+
$vpmt = addslashes($vpmt);
|
428 |
+
|
429 |
+
if (!empty($generalId)) {
|
430 |
+
$vpmt .= '('. $generalId .')';
|
431 |
+
}
|
432 |
+
|
433 |
+
$problemStyle = '';
|
434 |
+
$problemIcon = '';
|
435 |
+
|
436 |
+
$linkTitle = Mage::helper('M2ePro')->__('Open Manage Variations Tool');
|
437 |
+
|
438 |
+
if (empty($generalId) && $amazonListingProduct->isGeneralIdOwner()) {
|
439 |
+
if (!$parentType->hasChannelTheme() || !$parentType->hasMatchedAttributes()) {
|
440 |
+
|
441 |
+
$linkTitle = Mage::helper('M2ePro')->__('Action Required');
|
442 |
+
$problemStyle = 'style="font-weight: bold; color: #FF0000;" ';
|
443 |
+
$iconPath = $this->getSkinUrl('M2ePro/images/error.png');
|
444 |
+
$problemIcon = '<img style="vertical-align: middle;" src="'
|
445 |
+
. $iconPath . '" title="' . $linkTitle . '" alt="" width="16" height="16">';
|
446 |
+
}
|
447 |
+
} elseif (!empty($generalId)) {
|
448 |
+
if (!$parentType->hasMatchedAttributes()) {
|
449 |
+
|
450 |
+
$linkTitle = Mage::helper('M2ePro')->__('Action Required');
|
451 |
+
$problemStyle = 'style="font-weight: bold;color: #FF0000;" ';
|
452 |
+
$iconPath = $this->getSkinUrl('M2ePro/images/error.png');
|
453 |
+
$problemIcon = '<img style="vertical-align: middle;" src="'
|
454 |
+
. $iconPath . '" title="' . $linkTitle . '" alt="" width="16" height="16">';
|
455 |
+
} elseif ($listingProduct->getChildObject()->isGeneralIdOwner() &&
|
456 |
+
!$parentType->hasChannelTheme()) {
|
457 |
+
|
458 |
+
$linkTitle = Mage::helper('M2ePro')->__('Action Required');
|
459 |
+
$problemStyle = 'style="font-weight: bold;" ';
|
460 |
+
$iconPath = $this->getSkinUrl('M2ePro/images/warning.png');
|
461 |
+
$problemIcon = '<img style="vertical-align: middle;" src="'
|
462 |
+
. $iconPath . '" title="' . $linkTitle . '" alt="" width="16" height="16">';
|
463 |
+
}
|
464 |
+
}
|
465 |
+
|
466 |
+
$value .= <<<HTML
|
467 |
+
<div style="float: left; margin: 0 0 0 7px">
|
468 |
+
<a {$problemStyle}href="javascript:"
|
469 |
+
onclick="ListingGridHandlerObj.variationProductManageHandler.openPopUp({$listingProductId}, '{$vpmt}')"
|
470 |
+
title="{$linkTitle}">{$linkContent}</a> {$problemIcon}
|
471 |
+
</div>
|
472 |
+
HTML;
|
473 |
+
}
|
474 |
+
|
475 |
+
return $value;
|
476 |
+
}
|
477 |
+
|
478 |
+
$productOptions = $variationManager->getTypeModel()->getProductOptions();
|
479 |
+
|
480 |
+
if (!empty($productOptions)) {
|
481 |
+
$value .= '<div style="font-size: 11px; color: grey; margin-left: 7px"><br/>';
|
482 |
+
foreach ($productOptions as $attribute => $option) {
|
483 |
+
!$option && $option = '--';
|
484 |
+
$value .= '<strong>' . Mage::helper('M2ePro')->escapeHtml($attribute) .
|
485 |
+
'</strong>: ' . Mage::helper('M2ePro')->escapeHtml($option) . '<br/>';
|
486 |
+
}
|
487 |
+
$value .= '</div>';
|
488 |
+
}
|
489 |
+
|
490 |
+
// ---------------------------------
|
491 |
+
$hasInActionLock = $this->getLockedData($row);
|
492 |
+
$hasInActionLock = $hasInActionLock['in_action'];
|
493 |
+
// ---------------------------------
|
494 |
+
|
495 |
+
if (!$hasInActionLock) {
|
496 |
+
|
497 |
+
$popupTitle = Mage::helper('M2ePro')->__('Manage Magento Product Variation');
|
498 |
+
$linkTitle = Mage::helper('M2ePro')->__('Edit Variation');
|
499 |
+
$linkContent = '<img width="12" height="12" src="'.$this->getSkinUrl('M2ePro/images/pencil.png').'">';
|
500 |
+
|
501 |
+
$value .= <<<HTML
|
502 |
+
<div style="clear: both"></div>
|
503 |
+
<div style="margin: 0 0 0 7px; float: left;">
|
504 |
+
<a href="javascript:"
|
505 |
+
onclick="ListingProductVariationHandlerObj
|
506 |
+
.setListingProductId({$listingProductId})
|
507 |
+
.showEditPopup('{$popupTitle}');"
|
508 |
+
title="{$linkTitle}">{$linkContent}</a>
|
509 |
+
</div>
|
510 |
+
HTML;
|
511 |
+
}
|
512 |
+
|
513 |
+
$popupTitle = Mage::helper('M2ePro')->__('Manage Magento Product Variations') ;
|
514 |
+
$linkTitle = Mage::helper('M2ePro')->__('Add Another Variation(s)');
|
515 |
+
$linkContent = '<img width="12" height="12" src="'.$this->getSkinUrl('M2ePro/images/add.png').'">';
|
516 |
+
|
517 |
+
$value.= <<<HTML
|
518 |
+
<div style="margin: 0 0 0 7px; float: left;">
|
519 |
+
<a href="javascript:"
|
520 |
+
onclick="ListingProductVariationHandlerObj
|
521 |
+
.setListingProductId({$listingProductId})
|
522 |
+
.showManagePopup('{$popupTitle}');"
|
523 |
+
title="{$linkTitle}">{$linkContent}</a>
|
524 |
+
</div>
|
525 |
+
HTML;
|
526 |
+
|
527 |
+
if (empty($generalId) && !$amazonListingProduct->isGeneralIdOwner()) {
|
528 |
+
$linkTitle = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')->escapeHtml(
|
529 |
+
Mage::helper('M2ePro')->__('Change "Magento Variations" Mode'))
|
530 |
+
);
|
531 |
+
|
532 |
+
$iconSettingsPath = $this->getSkinUrl('M2ePro/images/settings.png');
|
533 |
+
|
534 |
+
$switchToParentJsMethod = <<<JS
|
535 |
+
ListingProductVariationHandlerObj
|
536 |
+
.setListingProductId({$listingProductId})
|
537 |
+
.showSwitchToParentModePopUp('{$popupTitle}');
|
538 |
+
JS;
|
539 |
+
|
540 |
+
if ($this->hideSwitchToParentConfirm) {
|
541 |
+
$switchToParentJsMethod = <<<JS
|
542 |
+
ListingProductVariationHandlerObj
|
543 |
+
.setListingProductId({$listingProductId})
|
544 |
+
.resetListingProductVariation();
|
545 |
+
JS;
|
546 |
+
}
|
547 |
+
|
548 |
+
$value .= <<<HTML
|
549 |
+
<div style="margin: 0 0 0 7px; float: left;">
|
550 |
+
<a href="javascript:"
|
551 |
+
onclick="{$switchToParentJsMethod}"
|
552 |
+
title="{$linkTitle}">
|
553 |
+
<img width="12" height="12" src="{$iconSettingsPath}">
|
554 |
+
</a>
|
555 |
+
</div>
|
556 |
+
HTML;
|
557 |
+
}
|
558 |
+
|
559 |
+
return $value;
|
560 |
+
}
|
561 |
+
|
562 |
+
public function callbackColumnAmazonSku($value, $row, $column, $isExport)
|
563 |
+
{
|
564 |
+
if (is_null($value) || $value === '') {
|
565 |
+
return Mage::helper('M2ePro')->__('N/A');
|
566 |
+
}
|
567 |
+
return $value;
|
568 |
+
}
|
569 |
+
|
570 |
+
public function callbackColumnGeneralId($generalId, $row, $column, $isExport)
|
571 |
+
{
|
572 |
+
if (empty($generalId)) {
|
573 |
+
if($row->getData('is_general_id_owner') == 1){
|
574 |
+
return $this->getGeneralIdColumnValueGeneralIdOwner($row);
|
575 |
+
}
|
576 |
+
return $this->getGeneralIdColumnValueEmptyGeneralId($row);
|
577 |
+
}
|
578 |
+
|
579 |
+
return $this->getGeneralIdColumnValueNotEmptyGeneralId($row);
|
580 |
+
}
|
581 |
+
|
582 |
+
public function callbackColumnAvailableQty($value, $row, $column, $isExport)
|
583 |
+
{
|
584 |
+
if ($row->getData('amazon_status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED ||
|
585 |
+
$row->getData('is_variation_parent')
|
586 |
+
) {
|
587 |
+
if (is_null($value) || $value === '') {
|
588 |
+
return Mage::helper('M2ePro')->__('N/A');
|
589 |
+
}
|
590 |
+
} else {
|
591 |
+
if (is_null($value) || $value === '') {
|
592 |
+
return '<i style="color:gray;">receiving...</i>';
|
593 |
+
}
|
594 |
+
}
|
595 |
+
|
596 |
+
if ((bool)$row->getData('is_afn_channel')) {
|
597 |
+
return '--';
|
598 |
+
}
|
599 |
+
|
600 |
+
if ($value <= 0) {
|
601 |
+
return '<span style="color: red;">0</span>';
|
602 |
+
}
|
603 |
+
|
604 |
+
return $value;
|
605 |
+
}
|
606 |
+
|
607 |
+
public function callbackColumnPrice($value, $row, $column, $isExport)
|
608 |
+
{
|
609 |
+
if (is_null($value) || $value === '') {
|
610 |
+
if ($row->getData('amazon_status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED ||
|
611 |
+
$row->getData('is_variation_parent')
|
612 |
+
) {
|
613 |
+
return Mage::helper('M2ePro')->__('N/A');
|
614 |
+
} else {
|
615 |
+
return '<i style="color:gray;">receiving...</i>';
|
616 |
+
}
|
617 |
+
}
|
618 |
+
|
619 |
+
$marketplaceId = Mage::helper('M2ePro/Data_Global')->getValue('marketplace_id');
|
620 |
+
$currency = Mage::helper('M2ePro/Component_Amazon')
|
621 |
+
->getCachedObject('Marketplace',$marketplaceId)
|
622 |
+
->getChildObject()
|
623 |
+
->getDefaultCurrency();
|
624 |
+
|
625 |
+
if ((float)$value <= 0) {
|
626 |
+
$priceValue = '<span style="color: #f00;">0</span>';
|
627 |
+
} else {
|
628 |
+
$priceValue = Mage::app()->getLocale()->currency($currency)->toCurrency($value);
|
629 |
+
}
|
630 |
+
|
631 |
+
$resultHtml = '';
|
632 |
+
|
633 |
+
$salePriceValue = $row->getData('online_sale_price');
|
634 |
+
if ((float)$salePriceValue > 0) {
|
635 |
+
$startDateTimestamp = strtotime($row->getData('online_sale_price_start_date'));
|
636 |
+
$endDateTimestamp = strtotime($row->getData('online_sale_price_end_date'));
|
637 |
+
|
638 |
+
$currentTimestamp = strtotime(Mage::helper('M2ePro')->getCurrentGmtDate(false,'Y-m-d 00:00:00'));
|
639 |
+
|
640 |
+
if ($currentTimestamp >= $startDateTimestamp &&
|
641 |
+
$currentTimestamp <= $endDateTimestamp &&
|
642 |
+
$salePriceValue < (float)$value
|
643 |
+
) {
|
644 |
+
$resultHtml = '<span style="text-decoration: line-through;">'.$priceValue.'</span>';
|
645 |
+
} else {
|
646 |
+
$resultHtml = $priceValue;
|
647 |
+
}
|
648 |
+
|
649 |
+
$salePriceValue = Mage::app()->getLocale()->currency($currency)->toCurrency($salePriceValue);
|
650 |
+
|
651 |
+
$resultHtml .= ' <br/><br/><span style="color:gray;">'.$salePriceValue.'</span><br/>';
|
652 |
+
|
653 |
+
$resultHtml .= '<span style="color:gray; font-size: 10px;">
|
654 |
+
From: '.date('Y-m-d', $startDateTimestamp).'<br/>
|
655 |
+
To: '.date('Y-m-d', $endDateTimestamp).'
|
656 |
+
</span>';
|
657 |
+
}
|
658 |
+
|
659 |
+
if (empty($resultHtml)) {
|
660 |
+
$resultHtml = $priceValue;
|
661 |
+
}
|
662 |
+
|
663 |
+
return $resultHtml;
|
664 |
+
}
|
665 |
+
|
666 |
+
public function callbackColumnAfnChannel($value, $row, $column, $isExport)
|
667 |
+
{
|
668 |
+
if (is_null($value) || $value === '') {
|
669 |
+
return Mage::helper('M2ePro')->__('N/A');
|
670 |
+
}
|
671 |
+
|
672 |
+
switch ($row->getData('is_afn_channel')) {
|
673 |
+
case Ess_M2ePro_Model_Amazon_Listing_Product::IS_ISBN_GENERAL_ID_YES:
|
674 |
+
$value = '<span style="font-weight: bold;">' . $value . '</span>';
|
675 |
+
break;
|
676 |
+
|
677 |
+
default:
|
678 |
+
break;
|
679 |
+
}
|
680 |
+
|
681 |
+
return $value;
|
682 |
+
}
|
683 |
+
|
684 |
+
public function callbackColumnStatus($value, $row, $column, $isExport)
|
685 |
+
{
|
686 |
+
$listingProductId = (int)$row->getData('id');
|
687 |
+
|
688 |
+
$html = $this->getViewLogIconHtml($listingProductId);
|
689 |
+
|
690 |
+
/** @var Ess_M2ePro_Model_Listing_Product $listingProduct */
|
691 |
+
$listingProduct = Mage::helper('M2ePro/Component_Amazon')->getObject('Listing_Product',$listingProductId);
|
692 |
+
$variationManager = $listingProduct->getChildObject()->getVariationManager();
|
693 |
+
|
694 |
+
$synchNote = $listingProduct->getSetting('additional_data', 'synch_template_list_rules_note');
|
695 |
+
if (!empty($synchNote)) {
|
696 |
+
|
697 |
+
$synchNote = Mage::helper('M2ePro/View')->getModifiedLogMessage($synchNote);
|
698 |
+
|
699 |
+
if (empty($html)) {
|
700 |
+
$html = <<<HTML
|
701 |
+
<span style="float:right;">
|
702 |
+
<img id="map_link_error_icon_{$row->getId()}"
|
703 |
+
class="tool-tip-image"
|
704 |
+
style="vertical-align: middle;"
|
705 |
+
src="{$this->getSkinUrl('M2ePro/images/warning.png')}">
|
706 |
+
<span class="tool-tip-message tool-tip-warning tip-left" style="display:none;">
|
707 |
+
<img src="{$this->getSkinUrl('M2ePro/images/i_notice.gif')}">
|
708 |
+
<span>{$synchNote}</span>
|
709 |
+
</span>
|
710 |
+
</span>
|
711 |
+
HTML;
|
712 |
+
} else {
|
713 |
+
$html .= <<<HTML
|
714 |
+
<div id="synch_template_list_rules_note_{$listingProductId}" style="display: none">{$synchNote}</div>
|
715 |
+
HTML;
|
716 |
+
}
|
717 |
+
}
|
718 |
+
|
719 |
+
if (!$variationManager->isVariationParent()) {
|
720 |
+
return $html . $this->getProductStatus($row->getData('amazon_status')). $this->getLockedTag($row);
|
721 |
+
} else {
|
722 |
+
|
723 |
+
$generalId = $listingProduct->getGeneralId();
|
724 |
+
$variationChildStatuses = $row->getData('variation_child_statuses');
|
725 |
+
if (empty($generalId) || empty($variationChildStatuses)) {
|
726 |
+
return $html . $this->getProductStatus(Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) .
|
727 |
+
$this->getLockedTag($row);
|
728 |
+
}
|
729 |
+
|
730 |
+
$variationChildStatuses = json_decode($variationChildStatuses, true);
|
731 |
+
$variationChildStatuses = array(
|
732 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED =>
|
733 |
+
$variationChildStatuses[Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED],
|
734 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_LISTED =>
|
735 |
+
$variationChildStatuses[Ess_M2ePro_Model_Listing_Product::STATUS_LISTED],
|
736 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED =>
|
737 |
+
$variationChildStatuses[Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED],
|
738 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_BLOCKED =>
|
739 |
+
$variationChildStatuses[Ess_M2ePro_Model_Listing_Product::STATUS_BLOCKED]
|
740 |
+
);
|
741 |
+
|
742 |
+
foreach ($variationChildStatuses as $status => $productsCount) {
|
743 |
+
if (empty($productsCount)) {
|
744 |
+
continue;
|
745 |
+
}
|
746 |
+
$html .= '' . $this->getProductStatus($status) . ' ('. $productsCount . ')<br/>';
|
747 |
+
}
|
748 |
+
|
749 |
+
$html .= $this->getLockedTag($row);
|
750 |
+
}
|
751 |
+
|
752 |
+
return $html;
|
753 |
+
}
|
754 |
+
|
755 |
+
private function getProductStatus($status)
|
756 |
+
{
|
757 |
+
switch ($status) {
|
758 |
+
|
759 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_UNKNOWN:
|
760 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED:
|
761 |
+
return '<span style="color: gray;">' . Mage::helper('M2ePro')->__('Not Listed') . '</span>';
|
762 |
+
|
763 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_LISTED:
|
764 |
+
return '<span style="color: green;">' . Mage::helper('M2ePro')->__('Active') . '</span>';
|
765 |
+
|
766 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED:
|
767 |
+
return'<span style="color: red;">' . Mage::helper('M2ePro')->__('Inactive') . '</span>';
|
768 |
+
|
769 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_BLOCKED:
|
770 |
+
return'<span style="color: orange; font-weight: bold;">' .
|
771 |
+
Mage::helper('M2ePro')->__('Inactive (Blocked)') . '</span>';
|
772 |
+
}
|
773 |
+
|
774 |
+
return '';
|
775 |
+
}
|
776 |
+
|
777 |
+
private function getLockedTag($row)
|
778 |
+
{
|
779 |
+
$html = '';
|
780 |
+
|
781 |
+
$tempLocks = $this->getLockedData($row);
|
782 |
+
$tempLocks = $tempLocks['object_locks'];
|
783 |
+
|
784 |
+
$childCount = 0;
|
785 |
+
|
786 |
+
foreach ($tempLocks as $lock) {
|
787 |
+
|
788 |
+
switch ($lock->getTag()) {
|
789 |
+
|
790 |
+
case 'list_action':
|
791 |
+
$html .= '<br/><span style="color: #605fff">[List in Progress...]</span>';
|
792 |
+
break;
|
793 |
+
|
794 |
+
case 'relist_action':
|
795 |
+
$html .= '<br/><span style="color: #605fff">[Relist in Progress...]</span>';
|
796 |
+
break;
|
797 |
+
|
798 |
+
case 'revise_action':
|
799 |
+
$html .= '<br/><span style="color: #605fff">[Revise in Progress...]</span>';
|
800 |
+
break;
|
801 |
+
|
802 |
+
case 'stop_action':
|
803 |
+
$html .= '<br/><span style="color: #605fff">[Stop in Progress...]</span>';
|
804 |
+
break;
|
805 |
+
|
806 |
+
case 'stop_and_remove_action':
|
807 |
+
$html .= '<br/><span style="color: #605fff">[Stop And Remove in Progress...]</span>';
|
808 |
+
break;
|
809 |
+
|
810 |
+
case 'delete_and_remove_action':
|
811 |
+
$html .= '<br/><span style="color: #605fff">[Remove in Progress...]</span>';
|
812 |
+
break;
|
813 |
+
|
814 |
+
case 'child_products_in_action':
|
815 |
+
$childCount++;
|
816 |
+
break;
|
817 |
+
|
818 |
+
default:
|
819 |
+
break;
|
820 |
+
|
821 |
+
}
|
822 |
+
}
|
823 |
+
|
824 |
+
if ($childCount > 0) {
|
825 |
+
$html .= '<br/><span style="color: #605fff">[Children in Action...]</span>';
|
826 |
+
}
|
827 |
+
|
828 |
+
return $html;
|
829 |
+
}
|
830 |
+
|
831 |
+
//----------------------------------------
|
832 |
+
|
833 |
+
protected function callbackFilterTitle($collection, $column)
|
834 |
+
{
|
835 |
+
$value = $column->getFilter()->getValue();
|
836 |
+
|
837 |
+
if ($value == null) {
|
838 |
+
return;
|
839 |
+
}
|
840 |
+
|
841 |
+
$collection->addFieldToFilter(
|
842 |
+
array(
|
843 |
+
array('attribute'=>'sku','like'=>'%'.$value.'%'),
|
844 |
+
array('attribute'=>'name', 'like'=>'%'.$value.'%')
|
845 |
+
)
|
846 |
+
);
|
847 |
+
}
|
848 |
+
|
849 |
+
protected function callbackFilterPrice($collection, $column)
|
850 |
+
{
|
851 |
+
$value = $column->getFilter()->getValue();
|
852 |
+
|
853 |
+
if (empty($value)) {
|
854 |
+
return;
|
855 |
+
}
|
856 |
+
|
857 |
+
$from = $value['from'];
|
858 |
+
$to = $value['to'];
|
859 |
+
|
860 |
+
$collection->getSelect()->where(
|
861 |
+
'(alp.online_price >= \''.$from.'\' AND alp.online_price <= \''.$to.'\' AND
|
862 |
+
(
|
863 |
+
alp.online_sale_price IS NULL OR
|
864 |
+
alp.online_sale_price_start_date > NOW() OR
|
865 |
+
alp.online_sale_price_end_date < NOW()
|
866 |
+
)) OR (alp.online_sale_price >= \''.$from.'\' AND alp.online_sale_price <= \''.$to.'\' AND
|
867 |
+
(
|
868 |
+
alp.online_sale_price IS NOT NULL AND
|
869 |
+
alp.online_sale_price_start_date < NOW() AND
|
870 |
+
alp.online_sale_price_end_date > NOW()
|
871 |
+
))'
|
872 |
+
);
|
873 |
+
}
|
874 |
+
|
875 |
+
protected function callbackFilterStatus($collection, $column)
|
876 |
+
{
|
877 |
+
$value = $column->getFilter()->getValue();
|
878 |
+
|
879 |
+
if ($value == null) {
|
880 |
+
return;
|
881 |
+
}
|
882 |
+
|
883 |
+
$collection->getSelect()->where("lp.status = {$value} OR
|
884 |
+
(alp.variation_child_statuses REGEXP '\"{$value}\":[^0]') AND alp.is_variation_parent = 1");
|
885 |
+
}
|
886 |
+
|
887 |
+
//----------------------------------------
|
888 |
+
|
889 |
+
public function getViewLogIconHtml($listingProductId)
|
890 |
+
{
|
891 |
+
$listingProductId = (int)$listingProductId;
|
892 |
+
|
893 |
+
/** @var Ess_M2ePro_Model_Listing_Product $listingProduct */
|
894 |
+
$listingProduct = Mage::helper('M2ePro/Component_Amazon')->getObject('Listing_Product',$listingProductId);
|
895 |
+
|
896 |
+
/** @var $connRead Varien_Db_Adapter_Pdo_Mysql */
|
897 |
+
$connRead = Mage::getSingleton('core/resource')->getConnection('core_read');
|
898 |
+
|
899 |
+
// Get last messages
|
900 |
+
//--------------------------
|
901 |
+
$dbSelect = $connRead->select()
|
902 |
+
->from(
|
903 |
+
Mage::getResourceModel('M2ePro/Listing_Log')->getMainTable(),
|
904 |
+
array('action_id','action','type','description','create_date','initiator','listing_product_id')
|
905 |
+
)
|
906 |
+
->where('`action_id` IS NOT NULL')
|
907 |
+
->order(array('id DESC'))
|
908 |
+
->limit(30);
|
909 |
+
|
910 |
+
if($listingProduct->getChildObject()->getVariationManager()->isVariationParent()) {
|
911 |
+
$dbSelect->where('listing_product_id = ? OR parent_listing_product_id = ?', $listingProductId);
|
912 |
+
} else {
|
913 |
+
$dbSelect->where('listing_product_id = ?', $listingProductId);
|
914 |
+
}
|
915 |
+
|
916 |
+
$logRows = $connRead->fetchAll($dbSelect);
|
917 |
+
//--------------------------
|
918 |
+
|
919 |
+
// Get grouped messages by action_id
|
920 |
+
//--------------------------
|
921 |
+
$actionsRows = array();
|
922 |
+
$tempActionRows = array();
|
923 |
+
$lastActionId = false;
|
924 |
+
|
925 |
+
foreach ($logRows as $row) {
|
926 |
+
|
927 |
+
$row['description'] = Mage::helper('M2ePro/View')->getModifiedLogMessage($row['description']);
|
928 |
+
|
929 |
+
if ($row['action_id'] !== $lastActionId) {
|
930 |
+
if (count($tempActionRows) > 0) {
|
931 |
+
$actionsRows[] = array(
|
932 |
+
'action_id' => $lastActionId,
|
933 |
+
'type' => $this->getMainTypeForActionId($tempActionRows),
|
934 |
+
'date' => $this->getMainDateForActionId($tempActionRows),
|
935 |
+
'action' => $this->getActionForAction($tempActionRows[0]),
|
936 |
+
'initiator' => $this->getInitiatorForAction($tempActionRows[0]),
|
937 |
+
'items' => $tempActionRows
|
938 |
+
);
|
939 |
+
$tempActionRows = array();
|
940 |
+
}
|
941 |
+
$lastActionId = $row['action_id'];
|
942 |
+
}
|
943 |
+
$tempActionRows[] = $row;
|
944 |
+
}
|
945 |
+
|
946 |
+
if (count($tempActionRows) > 0) {
|
947 |
+
$actionsRows[] = array(
|
948 |
+
'action_id' => $lastActionId,
|
949 |
+
'type' => $this->getMainTypeForActionId($tempActionRows),
|
950 |
+
'date' => $this->getMainDateForActionId($tempActionRows),
|
951 |
+
'action' => $this->getActionForAction($tempActionRows[0]),
|
952 |
+
'initiator' => $this->getInitiatorForAction($tempActionRows[0]),
|
953 |
+
'items' => $tempActionRows
|
954 |
+
);
|
955 |
+
}
|
956 |
+
|
957 |
+
if (count($actionsRows) <= 0) {
|
958 |
+
return '';
|
959 |
+
}
|
960 |
+
|
961 |
+
if ($listingProduct->getChildObject()->getVariationManager()->isVariationParent()) {
|
962 |
+
foreach ($actionsRows as &$actionsRow) {
|
963 |
+
if (!empty($actionsRow['items']) && $actionsRow['items'][0]['listing_product_id']==$listingProductId) {
|
964 |
+
continue;
|
965 |
+
}
|
966 |
+
$actionsRow['action_in_progress'] = $this->isActionInProgress($actionsRow['action_id']);
|
967 |
+
|
968 |
+
$descArr = array();
|
969 |
+
foreach ($actionsRow['items'] as $key => &$item) {
|
970 |
+
if (array_key_exists($item['description'], $descArr)) {
|
971 |
+
$descArr[$item['description']]['count']++;
|
972 |
+
unset($actionsRow['items'][$key]);
|
973 |
+
continue;
|
974 |
+
}
|
975 |
+
$item['count'] = 1;
|
976 |
+
$descArr[$item['description']] = $item;
|
977 |
+
}
|
978 |
+
$actionsRow['items'] = array_values($descArr);
|
979 |
+
}
|
980 |
+
}
|
981 |
+
|
982 |
+
foreach ($actionsRows as &$actionsRow) {
|
983 |
+
usort($actionsRow['items'], function($a, $b)
|
984 |
+
{
|
985 |
+
$sortOrder = array(
|
986 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 1,
|
987 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 2,
|
988 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 3,
|
989 |
+
);
|
990 |
+
|
991 |
+
return $sortOrder[$a["type"]] > $sortOrder[$b["type"]];
|
992 |
+
});
|
993 |
+
}
|
994 |
+
|
995 |
+
$tips = array(
|
996 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'Last Action was completed successfully.',
|
997 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'Last Action was completed with error(s).',
|
998 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'Last Action was completed with warning(s).'
|
999 |
+
);
|
1000 |
+
|
1001 |
+
$icons = array(
|
1002 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'normal',
|
1003 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'error',
|
1004 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'warning'
|
1005 |
+
);
|
1006 |
+
|
1007 |
+
$summary = $this->getLayout()->createBlock('M2ePro/adminhtml_log_grid_summary', '', array(
|
1008 |
+
'entity_id' => $listingProductId,
|
1009 |
+
'rows' => $actionsRows,
|
1010 |
+
'tips' => $tips,
|
1011 |
+
'icons' => $icons,
|
1012 |
+
'view_help_handler' => 'ListingGridHandlerObj.viewItemHelp',
|
1013 |
+
'hide_help_handler' => 'ListingGridHandlerObj.hideItemHelp',
|
1014 |
+
));
|
1015 |
+
|
1016 |
+
return $summary->toHtml();
|
1017 |
+
}
|
1018 |
+
|
1019 |
+
public function getActionForAction($actionRows)
|
1020 |
+
{
|
1021 |
+
$string = '';
|
1022 |
+
|
1023 |
+
switch ($actionRows['action']) {
|
1024 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_LIST_PRODUCT_ON_COMPONENT:
|
1025 |
+
$string = Mage::helper('M2ePro')->__('List');
|
1026 |
+
break;
|
1027 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_RELIST_PRODUCT_ON_COMPONENT:
|
1028 |
+
$string = Mage::helper('M2ePro')->__('Relist');
|
1029 |
+
break;
|
1030 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_REVISE_PRODUCT_ON_COMPONENT:
|
1031 |
+
$string = Mage::helper('M2ePro')->__('Revise');
|
1032 |
+
break;
|
1033 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_STOP_PRODUCT_ON_COMPONENT:
|
1034 |
+
$string = Mage::helper('M2ePro')->__('Stop');
|
1035 |
+
break;
|
1036 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_DELETE_PRODUCT_FROM_COMPONENT:
|
1037 |
+
$string = Mage::helper('M2ePro')->__('Remove from Channel');
|
1038 |
+
break;
|
1039 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_STOP_AND_REMOVE_PRODUCT:
|
1040 |
+
$string = Mage::helper('M2ePro')->__('Stop on Channel / Remove from Listing');
|
1041 |
+
break;
|
1042 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_DELETE_AND_REMOVE_PRODUCT:
|
1043 |
+
$string = Mage::helper('M2ePro')->__('Remove from Channel & Listing');
|
1044 |
+
break;
|
1045 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_CHANGE_STATUS_ON_CHANNEL:
|
1046 |
+
$string = Mage::helper('M2ePro')->__('Status Change');
|
1047 |
+
break;
|
1048 |
+
}
|
1049 |
+
|
1050 |
+
return $string;
|
1051 |
+
}
|
1052 |
+
|
1053 |
+
public function getInitiatorForAction($actionRows)
|
1054 |
+
{
|
1055 |
+
$string = '';
|
1056 |
+
|
1057 |
+
switch ((int)$actionRows['initiator']) {
|
1058 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_UNKNOWN:
|
1059 |
+
$string = '';
|
1060 |
+
break;
|
1061 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_USER:
|
1062 |
+
$string = Mage::helper('M2ePro')->__('Manual');
|
1063 |
+
break;
|
1064 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION:
|
1065 |
+
$string = Mage::helper('M2ePro')->__('Automatic');
|
1066 |
+
break;
|
1067 |
+
}
|
1068 |
+
|
1069 |
+
return $string;
|
1070 |
+
}
|
1071 |
+
|
1072 |
+
public function getMainTypeForActionId($actionRows)
|
1073 |
+
{
|
1074 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS;
|
1075 |
+
|
1076 |
+
foreach ($actionRows as $row) {
|
1077 |
+
if ($row['type'] == Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR) {
|
1078 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR;
|
1079 |
+
break;
|
1080 |
+
}
|
1081 |
+
if ($row['type'] == Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING) {
|
1082 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING;
|
1083 |
+
}
|
1084 |
+
}
|
1085 |
+
|
1086 |
+
return $type;
|
1087 |
+
}
|
1088 |
+
|
1089 |
+
public function getMainDateForActionId($actionRows)
|
1090 |
+
{
|
1091 |
+
$format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
|
1092 |
+
return Mage::app()->getLocale()->date(strtotime($actionRows[0]['create_date']))->toString($format);
|
1093 |
+
}
|
1094 |
+
|
1095 |
+
public function isActionInProgress($actionId)
|
1096 |
+
{
|
1097 |
+
/** @var $connRead Varien_Db_Adapter_Pdo_Mysql */
|
1098 |
+
$connRead = Mage::getSingleton('core/resource')->getConnection('core_read');
|
1099 |
+
|
1100 |
+
// Get last messages
|
1101 |
+
//--------------------------
|
1102 |
+
$dbSelect = $connRead->select()
|
1103 |
+
->from(
|
1104 |
+
Mage::getResourceModel('M2ePro/Processing_Request')->getMainTable()
|
1105 |
+
)
|
1106 |
+
->where('responser_params REGEXP \'"logs_action_id":'.$actionId.'\'');
|
1107 |
+
|
1108 |
+
$result = $connRead->fetchAll($dbSelect);
|
1109 |
+
|
1110 |
+
return !empty($result);
|
1111 |
+
}
|
1112 |
+
|
1113 |
+
// ####################################
|
1114 |
+
|
1115 |
+
public function getGridUrl()
|
1116 |
+
{
|
1117 |
+
return $this->getUrl('*/adminhtml_common_amazon_listing/viewGrid', array('_current'=>true));
|
1118 |
+
}
|
1119 |
+
|
1120 |
+
public function getRowUrl($row)
|
1121 |
+
{
|
1122 |
+
return false;
|
1123 |
+
}
|
1124 |
+
|
1125 |
+
// ####################################
|
1126 |
+
|
1127 |
+
protected function _getStore()
|
1128 |
+
{
|
1129 |
+
$listing = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
1130 |
+
|
1131 |
+
// Get store filter
|
1132 |
+
//----------------------------
|
1133 |
+
$storeId = $listing['store_id'];
|
1134 |
+
//----------------------------
|
1135 |
+
|
1136 |
+
return Mage::app()->getStore((int)$storeId);
|
1137 |
+
}
|
1138 |
+
|
1139 |
+
// ####################################
|
1140 |
+
|
1141 |
+
protected function _toHtml()
|
1142 |
+
{
|
1143 |
+
$javascriptsMain = <<<JAVASCRIPT
|
1144 |
+
<script type="text/javascript">
|
1145 |
+
|
1146 |
+
if (typeof ListingGridHandlerObj != 'undefined') {
|
1147 |
+
ListingGridHandlerObj.afterInitPage();
|
1148 |
+
}
|
1149 |
+
|
1150 |
+
Event.observe(window, 'load', function() {
|
1151 |
+
setTimeout(function() {
|
1152 |
+
ListingGridHandlerObj.afterInitPage();
|
1153 |
+
}, 350);
|
1154 |
+
});
|
1155 |
+
|
1156 |
+
</script>
|
1157 |
+
JAVASCRIPT;
|
1158 |
+
|
1159 |
+
return parent::_toHtml().$javascriptsMain;
|
1160 |
+
}
|
1161 |
+
|
1162 |
+
// ####################################
|
1163 |
+
|
1164 |
+
private function getLockedData($row)
|
1165 |
+
{
|
1166 |
+
$listingProductId = $row->getData('id');
|
1167 |
+
if (!isset($this->lockedDataCache[$listingProductId])) {
|
1168 |
+
$objectLocks = Mage::getModel('M2ePro/Listing_Product')->load($listingProductId)->getObjectLocks();
|
1169 |
+
$tempArray = array(
|
1170 |
+
'object_locks' => $objectLocks,
|
1171 |
+
'in_action' => !empty($objectLocks),
|
1172 |
+
);
|
1173 |
+
$this->lockedDataCache[$listingProductId] = $tempArray;
|
1174 |
+
}
|
1175 |
+
|
1176 |
+
return $this->lockedDataCache[$listingProductId];
|
1177 |
+
}
|
1178 |
+
|
1179 |
+
// ####################################
|
1180 |
+
|
1181 |
+
private function getGeneralIdColumnValueEmptyGeneralId($row)
|
1182 |
+
{
|
1183 |
+
// ---------------------------------
|
1184 |
+
if ((int)$row->getData('amazon_status') != Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
1185 |
+
return '<i style="color:gray;">'.Mage::helper('M2ePro')->__('receiving...').'</i>';
|
1186 |
+
}
|
1187 |
+
// ---------------------------------
|
1188 |
+
|
1189 |
+
// ---------------------------------
|
1190 |
+
$iconPath = $this->getSkinUrl('M2ePro/images/search_statuses/');
|
1191 |
+
// ---------------------------------
|
1192 |
+
|
1193 |
+
// ---------------------------------
|
1194 |
+
$lpId = $row->getData('id');
|
1195 |
+
|
1196 |
+
$productTitle = Mage::helper('M2ePro')->escapeHtml($row->getData('name'));
|
1197 |
+
if (strlen($productTitle) > 60) {
|
1198 |
+
$productTitle = substr($productTitle, 0, 60) . '...';
|
1199 |
+
}
|
1200 |
+
$productTitle = Mage::helper('M2ePro')->__('Assign ASIN/ISBN For "%product_title%"', $productTitle);
|
1201 |
+
$productTitle = Mage::helper('M2ePro')->escapeJs($productTitle);
|
1202 |
+
// ---------------------------------
|
1203 |
+
|
1204 |
+
// ---------------------------------
|
1205 |
+
|
1206 |
+
$searchSettingsStatus = $row->getData('search_settings_status');
|
1207 |
+
|
1208 |
+
// ---------------------------------
|
1209 |
+
if ($searchSettingsStatus == Ess_M2ePro_Model_Amazon_Listing_Product::SEARCH_SETTINGS_STATUS_IN_PROGRESS) {
|
1210 |
+
|
1211 |
+
$tip = Mage::helper('M2ePro')->__('Automatic ASIN/ISBN Search in Progress.');
|
1212 |
+
$iconSrc = $iconPath.'processing.gif';
|
1213 |
+
|
1214 |
+
return <<<HTML
|
1215 |
+
|
1216 |
+
<a href="javascript: void(0);" title="{$tip}">
|
1217 |
+
<img src="{$iconSrc}" alt="">
|
1218 |
+
</a>
|
1219 |
+
HTML;
|
1220 |
+
}
|
1221 |
+
// ---------------------------------
|
1222 |
+
|
1223 |
+
// ---------------------------------
|
1224 |
+
$searchSettingsData = $row->getData('search_settings_data');
|
1225 |
+
|
1226 |
+
$suggestData = array();
|
1227 |
+
if (!is_null($searchSettingsData)) {
|
1228 |
+
$searchSettingsData = @json_decode($searchSettingsData,true);
|
1229 |
+
!empty($searchSettingsData['data']) && $suggestData = $searchSettingsData['data'];
|
1230 |
+
|
1231 |
+
}
|
1232 |
+
// ---------------------------------
|
1233 |
+
|
1234 |
+
$na = Mage::helper('M2ePro')->__('N/A');
|
1235 |
+
|
1236 |
+
if (!empty($suggestData)) {
|
1237 |
+
|
1238 |
+
$tip = Mage::helper('M2ePro')->__('Choose ASIN/ISBN from the list');
|
1239 |
+
$iconSrc = $iconPath.'list.png';
|
1240 |
+
|
1241 |
+
return <<<HTML
|
1242 |
+
{$na}
|
1243 |
+
<a href="javascript:;" title="{$tip}"
|
1244 |
+
onclick="ListingGridHandlerObj.productSearchHandler.openPopUp(1,'{$productTitle}',{$lpId})">
|
1245 |
+
<img src="{$iconSrc}" alt="" width="16" height="16">
|
1246 |
+
</a>
|
1247 |
+
HTML;
|
1248 |
+
}
|
1249 |
+
|
1250 |
+
if ($searchSettingsStatus == Ess_M2ePro_Model_Amazon_Listing_Product::SEARCH_SETTINGS_STATUS_NOT_FOUND) {
|
1251 |
+
|
1252 |
+
$tip = Mage::helper('M2ePro')->__(
|
1253 |
+
'There were no Products found on Amazon according to the Listing Search Settings.'
|
1254 |
+
);
|
1255 |
+
$tip = Mage::helper('M2ePro')->escapeJs($tip);
|
1256 |
+
|
1257 |
+
$iconSrc = $iconPath.'error.png';
|
1258 |
+
|
1259 |
+
return <<<HTML
|
1260 |
+
{$na}
|
1261 |
+
<a href="javascript: void(0);" title="{$tip}"
|
1262 |
+
onclick="ListingGridHandlerObj.productSearchHandler.openPopUp(0,'{$productTitle}',{$lpId},'{$tip}');">
|
1263 |
+
<img src="{$iconSrc}" alt="" width="16" height="16">
|
1264 |
+
</a>
|
1265 |
+
HTML;
|
1266 |
+
}
|
1267 |
+
|
1268 |
+
$tip = Mage::helper('M2ePro')->__('Search for ASIN/ISBN');
|
1269 |
+
$iconSrc = $iconPath.'search.png';
|
1270 |
+
|
1271 |
+
return <<<HTML
|
1272 |
+
{$na}
|
1273 |
+
<a href="javascript:;" title="{$tip}"
|
1274 |
+
onclick="ListingGridHandlerObj.productSearchHandler.openPopUp(0,'{$productTitle}',{$lpId});">
|
1275 |
+
<img src="{$iconSrc}" alt="" width="16" height="16">
|
1276 |
+
</a>
|
1277 |
+
HTML;
|
1278 |
+
}
|
1279 |
+
|
1280 |
+
private function getGeneralIdColumnValueNotEmptyGeneralId($row)
|
1281 |
+
{
|
1282 |
+
$generalId = $row->getData('general_id');
|
1283 |
+
$marketplaceId = Mage::helper('M2ePro/Data_Global')->getValue('marketplace_id');
|
1284 |
+
|
1285 |
+
$url = Mage::helper('M2ePro/Component_Amazon')->getItemUrl(
|
1286 |
+
$generalId,
|
1287 |
+
$marketplaceId
|
1288 |
+
);
|
1289 |
+
|
1290 |
+
$generalIdOwnerHtml = '';
|
1291 |
+
if($row->getData('is_general_id_owner') == Ess_M2ePro_Model_Amazon_Listing_Product::IS_GENERAL_ID_OWNER_YES){
|
1292 |
+
|
1293 |
+
$generalIdOwnerHtml = '<br/><span style="font-size: 10px; color: grey;">'.
|
1294 |
+
Mage::helper('M2ePro')->__('creator of ASIN/ISBN').
|
1295 |
+
'</span>';
|
1296 |
+
}
|
1297 |
+
|
1298 |
+
if ((int)$row->getData('amazon_status') != Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
1299 |
+
|
1300 |
+
return <<<HTML
|
1301 |
+
<a href="{$url}" target="_blank">{$generalId}</a>{$generalIdOwnerHtml}
|
1302 |
+
HTML;
|
1303 |
+
}
|
1304 |
+
|
1305 |
+
$iconPath = $this->getSkinUrl('M2ePro/images/search_statuses/');
|
1306 |
+
|
1307 |
+
$generalIdSearchInfo = $row->getData('general_id_search_info');
|
1308 |
+
|
1309 |
+
if (!empty($generalIdSearchInfo)) {
|
1310 |
+
$generalIdSearchInfo = @json_decode($generalIdSearchInfo, true);
|
1311 |
+
}
|
1312 |
+
|
1313 |
+
if (!empty($generalIdSearchInfo['is_set_automatic'])) {
|
1314 |
+
|
1315 |
+
$tip = Mage::helper('M2ePro')->__('ASIN/ISBN was found automatically');
|
1316 |
+
|
1317 |
+
$text = <<<HTML
|
1318 |
+
<a href="{$url}" target="_blank" title="{$tip}" style="color:#40AADB;">{$generalId}</a>
|
1319 |
+
HTML;
|
1320 |
+
|
1321 |
+
} else {
|
1322 |
+
|
1323 |
+
$text = <<<HTML
|
1324 |
+
<a href="{$url}" target="_blank">{$generalId}</a>
|
1325 |
+
HTML;
|
1326 |
+
|
1327 |
+
}
|
1328 |
+
|
1329 |
+
// ---------------------------------
|
1330 |
+
$hasInActionLock = $this->getLockedData($row);
|
1331 |
+
$hasInActionLock = $hasInActionLock['in_action'];
|
1332 |
+
// ---------------------------------
|
1333 |
+
|
1334 |
+
if ($hasInActionLock) {
|
1335 |
+
return $text . $generalIdOwnerHtml;
|
1336 |
+
}
|
1337 |
+
|
1338 |
+
$listingProductId = (int)$row->getData('id');
|
1339 |
+
|
1340 |
+
/** @var Ess_M2ePro_Model_Listing_Product $listingProduct */
|
1341 |
+
$listingProduct = Mage::helper('M2ePro/Component_Amazon')->getObject('Listing_Product',$listingProductId);
|
1342 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager $variationManager */
|
1343 |
+
$variationManager = $listingProduct->getChildObject()->getVariationManager();
|
1344 |
+
$variationChildStatuses = $row->getData('variation_child_statuses');
|
1345 |
+
|
1346 |
+
if ($variationManager->isVariationParent() && !empty($variationChildStatuses)) {
|
1347 |
+
$variationChildStatuses = json_decode($variationChildStatuses, true);
|
1348 |
+
unset($variationChildStatuses[Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED]);
|
1349 |
+
|
1350 |
+
foreach ($variationChildStatuses as $variationChildStatus) {
|
1351 |
+
if (!empty($variationChildStatus)) {
|
1352 |
+
return $text . $generalIdOwnerHtml;
|
1353 |
+
}
|
1354 |
+
}
|
1355 |
+
}
|
1356 |
+
|
1357 |
+
$tip = Mage::helper('M2ePro')->__('Unassign ASIN/ISBN');
|
1358 |
+
$iconSrc = $iconPath.'unassign.png';
|
1359 |
+
|
1360 |
+
$text .= <<<HTML
|
1361 |
+
|
1362 |
+
<a href="javascript:;"
|
1363 |
+
onclick="ListingGridHandlerObj.productSearchHandler.showUnmapFromGeneralIdPrompt({$listingProductId});"
|
1364 |
+
title="{$tip}">
|
1365 |
+
<img src="{$iconSrc}" width="16" height="16"/>
|
1366 |
+
</a>{$generalIdOwnerHtml}
|
1367 |
+
HTML;
|
1368 |
+
|
1369 |
+
return $text;
|
1370 |
+
}
|
1371 |
+
|
1372 |
+
private function getGeneralIdColumnValueGeneralIdOwner($row)
|
1373 |
+
{
|
1374 |
+
$text = Mage::helper('M2ePro')->__('New ASIN/ISBN');
|
1375 |
+
|
1376 |
+
// ---------------------------------
|
1377 |
+
$hasInActionLock = $this->getLockedData($row);
|
1378 |
+
$hasInActionLock = $hasInActionLock['in_action'];
|
1379 |
+
// ---------------------------------
|
1380 |
+
|
1381 |
+
if ($hasInActionLock) {
|
1382 |
+
return $text;
|
1383 |
+
}
|
1384 |
+
|
1385 |
+
$iconPath = $this->getSkinUrl('M2ePro/images/search_statuses/');
|
1386 |
+
|
1387 |
+
$tip = Mage::helper('M2ePro')->__('Unassign ASIN/ISBN');
|
1388 |
+
$iconSrc = $iconPath.'unassign.png';
|
1389 |
+
|
1390 |
+
$lpId = $row->getData('id');
|
1391 |
+
|
1392 |
+
$text .= <<<HTML
|
1393 |
+
|
1394 |
+
<a href="javascript:;"
|
1395 |
+
onclick="ListingGridHandlerObj.productSearchHandler.showUnmapFromGeneralIdPrompt({$lpId});"
|
1396 |
+
title="{$tip}"><img src="{$iconSrc}" width="16" height="16"/>
|
1397 |
+
</a>
|
1398 |
+
HTML;
|
1399 |
+
return $text;
|
1400 |
+
}
|
1401 |
+
|
1402 |
+
// ####################################
|
1403 |
+
|
1404 |
+
protected function getTemplateDescriptionLinkHtml($listingProduct)
|
1405 |
+
{
|
1406 |
+
$templateDescriptionEditUrl = $this->getUrl('*/adminhtml_common_amazon_template_description/edit', array(
|
1407 |
+
'id' => $listingProduct->getChildObject()->getTemplateDescriptionId()
|
1408 |
+
));
|
1409 |
+
|
1410 |
+
$helper = Mage::helper('M2ePro');
|
1411 |
+
$templateTitle = $listingProduct->getChildObject()->getDescriptionTemplate()->getTitle();
|
1412 |
+
|
1413 |
+
return <<<HTML
|
1414 |
+
<span style="font-size: 9px;">{$helper->__('Description Policy')}:
|
1415 |
+
<a target="_blank" href="{$templateDescriptionEditUrl}">
|
1416 |
+
{$helper->escapeHtml($templateTitle)}</a>
|
1417 |
+
</span>
|
1418 |
+
<br/>
|
1419 |
+
HTML;
|
1420 |
+
}
|
1421 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View/Help.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_View_Help extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonListingViewHelp');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/amazon/listing/view/help.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View/ListingSwitcher.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2011 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_View_ListingSwitcher
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Listing_View_ListingSwitcher_Abstract
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
|
16 |
+
$this->setAddListingUrl('*/adminhtml_common_listing_create/index/step/1/component/amazon/');
|
17 |
+
}
|
18 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View/Magento/Grid.php
ADDED
@@ -0,0 +1,336 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_View_Magento_Grid
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Magento_Product_Grid_Abstract
|
9 |
+
{
|
10 |
+
|
11 |
+
// ####################################
|
12 |
+
|
13 |
+
public function __construct()
|
14 |
+
{
|
15 |
+
parent::__construct();
|
16 |
+
|
17 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
18 |
+
|
19 |
+
// Initialization block
|
20 |
+
//------------------------------
|
21 |
+
$this->setId('amazonListingViewMagentoGrid'.$listingData['id']);
|
22 |
+
//------------------------------
|
23 |
+
|
24 |
+
$this->hideMassactionColumn = true;
|
25 |
+
$this->hideMassactionDropDown = true;
|
26 |
+
$this->showAdvancedFilterProductsOption = false;
|
27 |
+
}
|
28 |
+
|
29 |
+
// ####################################
|
30 |
+
|
31 |
+
public function getMainButtonsHtml()
|
32 |
+
{
|
33 |
+
$data = array(
|
34 |
+
'current_view_mode' => $this->getParentBlock()->getViewMode()
|
35 |
+
);
|
36 |
+
$viewModeSwitcherBlock = $this->getLayout()->createBlock(
|
37 |
+
'M2ePro/adminhtml_common_amazon_listing_view_modeSwitcher'
|
38 |
+
);
|
39 |
+
$viewModeSwitcherBlock->addData($data);
|
40 |
+
|
41 |
+
return $viewModeSwitcherBlock->toHtml() . parent::getMainButtonsHtml();
|
42 |
+
}
|
43 |
+
|
44 |
+
// ####################################
|
45 |
+
|
46 |
+
protected function _prepareCollection()
|
47 |
+
{
|
48 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
49 |
+
|
50 |
+
// Get collection
|
51 |
+
//----------------------------
|
52 |
+
/* @var $collection Mage_Core_Model_Mysql4_Collection_Abstract */
|
53 |
+
$collection = Mage::getConfig()->getModelInstance('Ess_M2ePro_Model_Mysql4_Magento_Product_Collection',
|
54 |
+
Mage::getModel('catalog/product')->getResource());
|
55 |
+
$collection->getSelect()->group('e.entity_id');
|
56 |
+
$collection
|
57 |
+
->addAttributeToSelect('name')
|
58 |
+
->joinTable(
|
59 |
+
array('cisi' => 'cataloginventory/stock_item'),
|
60 |
+
'product_id=entity_id',
|
61 |
+
array('qty' => 'qty',
|
62 |
+
'is_in_stock' => 'is_in_stock'),
|
63 |
+
'{{table}}.stock_id=1',
|
64 |
+
'left'
|
65 |
+
);
|
66 |
+
|
67 |
+
//----------------------------
|
68 |
+
|
69 |
+
$collection->joinTable(
|
70 |
+
array('lp' => 'M2ePro/Listing_Product'),
|
71 |
+
'product_id=entity_id',
|
72 |
+
array(
|
73 |
+
'id' => 'id',
|
74 |
+
'amazon_status' => 'status',
|
75 |
+
'additional_data' => 'additional_data'
|
76 |
+
),
|
77 |
+
array(
|
78 |
+
'listing_id' => (int)$listingData['id']
|
79 |
+
)
|
80 |
+
);
|
81 |
+
$collection->joinTable(
|
82 |
+
array('alp' => 'M2ePro/Amazon_Listing_Product'),
|
83 |
+
'listing_product_id=id',
|
84 |
+
array(
|
85 |
+
'general_id' => 'general_id',
|
86 |
+
'amazon_sku' => 'sku',
|
87 |
+
'online_qty' => 'online_qty',
|
88 |
+
'online_price' => 'online_price',
|
89 |
+
'online_sale_price' => 'online_sale_price',
|
90 |
+
'is_afn_channel' => 'is_afn_channel'
|
91 |
+
),
|
92 |
+
NULL,
|
93 |
+
'left'
|
94 |
+
);
|
95 |
+
//----------------------------
|
96 |
+
|
97 |
+
// Set filter store
|
98 |
+
//----------------------------
|
99 |
+
$store = $this->_getStore();
|
100 |
+
|
101 |
+
if ($store->getId()) {
|
102 |
+
$collection->joinAttribute(
|
103 |
+
'price', 'catalog_product/price', 'entity_id', NULL, 'left', $store->getId()
|
104 |
+
);
|
105 |
+
$collection->joinAttribute(
|
106 |
+
'status', 'catalog_product/status', 'entity_id', NULL, 'inner',$store->getId()
|
107 |
+
);
|
108 |
+
$collection->joinAttribute(
|
109 |
+
'visibility', 'catalog_product/visibility', 'entity_id', NULL, 'inner',$store->getId()
|
110 |
+
);
|
111 |
+
$collection->joinAttribute(
|
112 |
+
'thumbnail', 'catalog_product/thumbnail', 'entity_id', NULL, 'left',$store->getId()
|
113 |
+
);
|
114 |
+
} else {
|
115 |
+
$collection->addAttributeToSelect('price');
|
116 |
+
$collection->addAttributeToSelect('status');
|
117 |
+
$collection->addAttributeToSelect('visibility');
|
118 |
+
$collection->addAttributeToSelect('thumbnail');
|
119 |
+
}
|
120 |
+
//----------------------------
|
121 |
+
|
122 |
+
// exit($collection->getSelect()->__toString());
|
123 |
+
|
124 |
+
// Set collection to grid
|
125 |
+
$this->setCollection($collection);
|
126 |
+
|
127 |
+
parent::_prepareCollection();
|
128 |
+
|
129 |
+
$this->getCollection()->addWebsiteNamesToResult();
|
130 |
+
|
131 |
+
return $this;
|
132 |
+
}
|
133 |
+
|
134 |
+
protected function _prepareColumns()
|
135 |
+
{
|
136 |
+
$this->addColumn('product_id', array(
|
137 |
+
'header' => Mage::helper('M2ePro')->__('ID'),
|
138 |
+
'align' => 'right',
|
139 |
+
'width' => '100px',
|
140 |
+
'type' => 'number',
|
141 |
+
'index' => 'entity_id',
|
142 |
+
'filter_index' => 'entity_id',
|
143 |
+
'frame_callback' => array($this, 'callbackColumnProductId')
|
144 |
+
));
|
145 |
+
|
146 |
+
$this->addColumn('name', array(
|
147 |
+
'header' => Mage::helper('M2ePro')->__('Title'),
|
148 |
+
'align' => 'left',
|
149 |
+
//'width' => '100px',
|
150 |
+
'type' => 'text',
|
151 |
+
'index' => 'name',
|
152 |
+
'filter_index' => 'name',
|
153 |
+
'frame_callback' => array($this, 'callbackColumnProductTitle')
|
154 |
+
));
|
155 |
+
|
156 |
+
$tempTypes = Mage::getSingleton('catalog/product_type')->getOptionArray();
|
157 |
+
unset($tempTypes['virtual']);
|
158 |
+
|
159 |
+
$this->addColumn('type', array(
|
160 |
+
'header' => Mage::helper('M2ePro')->__('Type'),
|
161 |
+
'align' => 'left',
|
162 |
+
'width' => '90px',
|
163 |
+
'type' => 'options',
|
164 |
+
'sortable' => false,
|
165 |
+
'index' => 'type_id',
|
166 |
+
'filter_index' => 'type_id',
|
167 |
+
'options' => $tempTypes
|
168 |
+
));
|
169 |
+
|
170 |
+
$this->addColumn('is_in_stock', array(
|
171 |
+
'header' => Mage::helper('M2ePro')->__('Stock Availability'),
|
172 |
+
'align' => 'left',
|
173 |
+
'width' => '90px',
|
174 |
+
'type' => 'options',
|
175 |
+
'sortable' => false,
|
176 |
+
'index' => 'is_in_stock',
|
177 |
+
'filter_index' => 'is_in_stock',
|
178 |
+
'options' => array(
|
179 |
+
'1' => Mage::helper('M2ePro')->__('In Stock'),
|
180 |
+
'0' => Mage::helper('M2ePro')->__('Out of Stock')
|
181 |
+
),
|
182 |
+
'frame_callback' => array($this, 'callbackColumnIsInStock')
|
183 |
+
));
|
184 |
+
|
185 |
+
$this->addColumn('sku', array(
|
186 |
+
'header' => Mage::helper('M2ePro')->__('SKU'),
|
187 |
+
'align' => 'left',
|
188 |
+
'width' => '90px',
|
189 |
+
'type' => 'text',
|
190 |
+
'index' => 'sku',
|
191 |
+
'filter_index' => 'sku'
|
192 |
+
));
|
193 |
+
|
194 |
+
$store = $this->_getStore();
|
195 |
+
|
196 |
+
$this->addColumn('price', array(
|
197 |
+
'header' => Mage::helper('M2ePro')->__('Price'),
|
198 |
+
'align' => 'right',
|
199 |
+
'width' => '100px',
|
200 |
+
'type' => 'price',
|
201 |
+
'currency_code' => $store->getBaseCurrency()->getCode(),
|
202 |
+
'index' => 'price',
|
203 |
+
'filter_index' => 'price',
|
204 |
+
'frame_callback' => array($this, 'callbackColumnPrice')
|
205 |
+
));
|
206 |
+
|
207 |
+
$this->addColumn('qty', array(
|
208 |
+
'header' => Mage::helper('M2ePro')->__('QTY'),
|
209 |
+
'align' => 'right',
|
210 |
+
'width' => '100px',
|
211 |
+
'type' => 'number',
|
212 |
+
'index' => 'qty',
|
213 |
+
'filter_index' => 'qty',
|
214 |
+
'frame_callback' => array($this, 'callbackColumnQty')
|
215 |
+
));
|
216 |
+
|
217 |
+
$this->addColumn('visibility', array(
|
218 |
+
'header' => Mage::helper('M2ePro')->__('Visibility'),
|
219 |
+
'align' => 'left',
|
220 |
+
'width' => '90px',
|
221 |
+
'type' => 'options',
|
222 |
+
'sortable' => false,
|
223 |
+
'index' => 'visibility',
|
224 |
+
'filter_index' => 'visibility',
|
225 |
+
'options' => Mage::getModel('catalog/product_visibility')->getOptionArray()
|
226 |
+
));
|
227 |
+
|
228 |
+
$this->addColumn('status', array(
|
229 |
+
'header' => Mage::helper('M2ePro')->__('Status'),
|
230 |
+
'align' => 'left',
|
231 |
+
'width' => '90px',
|
232 |
+
'type' => 'options',
|
233 |
+
'sortable' => false,
|
234 |
+
'index' => 'status',
|
235 |
+
'filter_index' => 'status',
|
236 |
+
'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
|
237 |
+
'frame_callback' => array($this, 'callbackColumnStatus')
|
238 |
+
));
|
239 |
+
|
240 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
241 |
+
|
242 |
+
$this->addColumn('websites', array(
|
243 |
+
'header' => Mage::helper('M2ePro')->__('Websites'),
|
244 |
+
'align' => 'left',
|
245 |
+
'width' => '90px',
|
246 |
+
'type' => 'options',
|
247 |
+
'sortable' => false,
|
248 |
+
'index' => 'websites',
|
249 |
+
'filter_index' => 'websites',
|
250 |
+
'options' => Mage::getModel('core/website')->getCollection()->toOptionHash()
|
251 |
+
));
|
252 |
+
}
|
253 |
+
|
254 |
+
return parent::_prepareColumns();
|
255 |
+
}
|
256 |
+
|
257 |
+
// ####################################
|
258 |
+
|
259 |
+
public function getGridUrl()
|
260 |
+
{
|
261 |
+
return $this->getUrl('*/adminhtml_common_amazon_listing/viewGrid', array('_current'=>true));
|
262 |
+
}
|
263 |
+
|
264 |
+
public function getRowUrl($row)
|
265 |
+
{
|
266 |
+
return false;
|
267 |
+
}
|
268 |
+
|
269 |
+
// ####################################
|
270 |
+
|
271 |
+
protected function _addColumnFilterToCollection($column)
|
272 |
+
{
|
273 |
+
if ($this->getCollection()) {
|
274 |
+
if ($column->getId() == 'websites') {
|
275 |
+
$this->getCollection()->joinField('websites',
|
276 |
+
'catalog/product_website',
|
277 |
+
'website_id',
|
278 |
+
'product_id=entity_id',
|
279 |
+
null,
|
280 |
+
'left');
|
281 |
+
}
|
282 |
+
}
|
283 |
+
return parent::_addColumnFilterToCollection($column);
|
284 |
+
}
|
285 |
+
|
286 |
+
// ####################################
|
287 |
+
|
288 |
+
protected function _getStore()
|
289 |
+
{
|
290 |
+
$listing = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
291 |
+
|
292 |
+
// Get store filter
|
293 |
+
//----------------------------
|
294 |
+
$storeId = $listing['store_id'];
|
295 |
+
//----------------------------
|
296 |
+
|
297 |
+
return Mage::app()->getStore((int)$storeId);
|
298 |
+
}
|
299 |
+
|
300 |
+
protected function _toHtml()
|
301 |
+
{
|
302 |
+
$javascriptsMain = <<<JAVASCRIPT
|
303 |
+
<script type="text/javascript">
|
304 |
+
|
305 |
+
if (typeof ListingGridHandlerObj != 'undefined') {
|
306 |
+
ListingGridHandlerObj.afterInitPage();
|
307 |
+
}
|
308 |
+
|
309 |
+
Event.observe(window, 'load', function() {
|
310 |
+
setTimeout(function() {
|
311 |
+
ListingGridHandlerObj.afterInitPage();
|
312 |
+
}, 350);
|
313 |
+
});
|
314 |
+
|
315 |
+
</script>
|
316 |
+
JAVASCRIPT;
|
317 |
+
|
318 |
+
return parent::_toHtml().$javascriptsMain;
|
319 |
+
}
|
320 |
+
|
321 |
+
// ####################################
|
322 |
+
|
323 |
+
protected function isShowRuleBlock()
|
324 |
+
{
|
325 |
+
/** @var $ruleModel Ess_M2ePro_Model_Magento_Product_Rule */
|
326 |
+
$ruleModel = Mage::helper('M2ePro/Data_Global')->getValue('rule_model');
|
327 |
+
if ($ruleModel->isEmpty()) {
|
328 |
+
return false;
|
329 |
+
}
|
330 |
+
|
331 |
+
return parent::isShowRuleBlock();
|
332 |
+
}
|
333 |
+
|
334 |
+
// ####################################
|
335 |
+
|
336 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View/ModeSwitcher.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_View_ModeSwitcher
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Listing_View_ModeSwitcher_Abstract
|
9 |
+
{
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('amazonListingViewModeSwitcher');
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$this->setData('component_nick', 'amazon');
|
21 |
+
$this->setData('component_label', 'Amazon');
|
22 |
+
}
|
23 |
+
|
24 |
+
protected function getMenuItems()
|
25 |
+
{
|
26 |
+
return array(
|
27 |
+
array(
|
28 |
+
'value' => Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_View::VIEW_MODE_AMAZON,
|
29 |
+
'label' => Mage::helper('M2ePro')->__($this->getComponentLabel())
|
30 |
+
),
|
31 |
+
array(
|
32 |
+
'value' => Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_View::VIEW_MODE_SELLERCENTRAL,
|
33 |
+
'label' => Mage::helper('M2ePro')->__('Seller Сentral')
|
34 |
+
),
|
35 |
+
array(
|
36 |
+
'value' => Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_View::VIEW_MODE_MAGENTO,
|
37 |
+
'label' => Mage::helper('M2ePro')->__('Magento')
|
38 |
+
)
|
39 |
+
);
|
40 |
+
}
|
41 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View/Sellercentral/Grid.php
ADDED
@@ -0,0 +1,920 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_View_Sellercentral_Grid
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Magento_Product_Grid_Abstract
|
9 |
+
{
|
10 |
+
/** @var $sellingFormatTemplate Ess_M2ePro_Model_Amazon_Template_SellingFormat */
|
11 |
+
private $sellingFormatTemplate = NULL;
|
12 |
+
|
13 |
+
private $lockedDataCache = array();
|
14 |
+
|
15 |
+
private $parentAsins;
|
16 |
+
|
17 |
+
// ####################################
|
18 |
+
|
19 |
+
public function __construct()
|
20 |
+
{
|
21 |
+
parent::__construct();
|
22 |
+
|
23 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
24 |
+
|
25 |
+
// Initialization block
|
26 |
+
//------------------------------
|
27 |
+
$this->setId('amazonListingViewSellercentralGrid'.$listingData['id']);
|
28 |
+
//------------------------------
|
29 |
+
|
30 |
+
$this->showAdvancedFilterProductsOption = false;
|
31 |
+
|
32 |
+
$this->sellingFormatTemplate = Mage::helper('M2ePro/Component_Amazon')->getCachedObject(
|
33 |
+
'Template_SellingFormat', $listingData['template_selling_format_id'], NULL,
|
34 |
+
array('template')
|
35 |
+
);
|
36 |
+
}
|
37 |
+
|
38 |
+
// ####################################
|
39 |
+
|
40 |
+
public function getMainButtonsHtml()
|
41 |
+
{
|
42 |
+
$data = array(
|
43 |
+
'current_view_mode' => $this->getParentBlock()->getViewMode()
|
44 |
+
);
|
45 |
+
$viewModeSwitcherBlock = $this->getLayout()->createBlock(
|
46 |
+
'M2ePro/adminhtml_common_amazon_listing_view_modeSwitcher'
|
47 |
+
);
|
48 |
+
$viewModeSwitcherBlock->addData($data);
|
49 |
+
|
50 |
+
return $viewModeSwitcherBlock->toHtml() . parent::getMainButtonsHtml();
|
51 |
+
}
|
52 |
+
|
53 |
+
// ####################################
|
54 |
+
|
55 |
+
protected function _prepareCollection()
|
56 |
+
{
|
57 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
58 |
+
|
59 |
+
// Get collection
|
60 |
+
//----------------------------
|
61 |
+
/* @var $collection Mage_Core_Model_Mysql4_Collection_Abstract */
|
62 |
+
$collection = Mage::getConfig()->getModelInstance('Ess_M2ePro_Model_Mysql4_Magento_Product_Collection',
|
63 |
+
Mage::getModel('catalog/product')->getResource());
|
64 |
+
$collection
|
65 |
+
->setListingProductModeOn()
|
66 |
+
->addAttributeToSelect('name')
|
67 |
+
->addAttributeToSelect('sku')
|
68 |
+
->joinTable(
|
69 |
+
array('cisi' => 'cataloginventory/stock_item'),
|
70 |
+
'product_id=entity_id',
|
71 |
+
array('qty' => 'qty',
|
72 |
+
'is_in_stock' => 'is_in_stock'),
|
73 |
+
'{{table}}.stock_id=1',
|
74 |
+
'left'
|
75 |
+
);
|
76 |
+
|
77 |
+
//----------------------------
|
78 |
+
|
79 |
+
$collection->joinTable(
|
80 |
+
array('lp' => 'M2ePro/Listing_Product'),
|
81 |
+
'product_id=entity_id',
|
82 |
+
array(
|
83 |
+
'id' => 'id',
|
84 |
+
'amazon_status' => 'status',
|
85 |
+
'component_mode' => 'component_mode',
|
86 |
+
'additional_data' => 'additional_data'
|
87 |
+
),
|
88 |
+
array(
|
89 |
+
'listing_id' => (int)$listingData['id'],
|
90 |
+
'status' => array(
|
91 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_LISTED,
|
92 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED,
|
93 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_BLOCKED
|
94 |
+
)
|
95 |
+
)
|
96 |
+
);
|
97 |
+
$collection->joinTable(
|
98 |
+
array('alp' => 'M2ePro/Amazon_Listing_Product'),
|
99 |
+
'listing_product_id=id',
|
100 |
+
array(
|
101 |
+
'general_id' => 'general_id',
|
102 |
+
'search_settings_status' => 'search_settings_status',
|
103 |
+
'amazon_sku' => 'sku',
|
104 |
+
'online_qty' => 'online_qty',
|
105 |
+
'online_price' => 'online_price',
|
106 |
+
'online_sale_price' => 'online_sale_price',
|
107 |
+
'online_sale_price_start_date' => 'online_sale_price_start_date',
|
108 |
+
'online_sale_price_end_date' => 'online_sale_price_end_date',
|
109 |
+
'is_afn_channel' => 'is_afn_channel',
|
110 |
+
'is_general_id_owner' => 'is_general_id_owner',
|
111 |
+
'variation_child_statuses' => 'variation_child_statuses',
|
112 |
+
'is_variation_parent' => 'is_variation_parent',
|
113 |
+
'variation_parent_id' => 'variation_parent_id'
|
114 |
+
),
|
115 |
+
'{{table}}.is_variation_parent = 0'
|
116 |
+
);
|
117 |
+
//----------------------------
|
118 |
+
// exit($collection->getSelect()->__toString());
|
119 |
+
|
120 |
+
// Change default Magento message when items count is zero
|
121 |
+
$collectionForCounting = clone $collection;
|
122 |
+
|
123 |
+
if (count($collectionForCounting) === 0) {
|
124 |
+
$this->setEmptyText(
|
125 |
+
Mage::helper('M2ePro')->__(
|
126 |
+
'Only Simple and Child Products listed on Amazon will be shown in Seller Сentral View Mode.'
|
127 |
+
)
|
128 |
+
);
|
129 |
+
}
|
130 |
+
|
131 |
+
// Set collection to grid
|
132 |
+
$this->setCollection($collection);
|
133 |
+
|
134 |
+
return parent::_prepareCollection();
|
135 |
+
}
|
136 |
+
|
137 |
+
protected function _prepareColumns()
|
138 |
+
{
|
139 |
+
$this->addColumn('product_id', array(
|
140 |
+
'header' => Mage::helper('M2ePro')->__('Product ID'),
|
141 |
+
'align' => 'right',
|
142 |
+
'width' => '100px',
|
143 |
+
'type' => 'number',
|
144 |
+
'index' => 'entity_id',
|
145 |
+
'filter_index' => 'entity_id',
|
146 |
+
'frame_callback' => array($this, 'callbackColumnProductId')
|
147 |
+
));
|
148 |
+
|
149 |
+
$this->addColumn('name', array(
|
150 |
+
'header' => Mage::helper('M2ePro')->__('Product Title / Product SKU'),
|
151 |
+
'align' => 'left',
|
152 |
+
'width' => '300px',
|
153 |
+
'type' => 'text',
|
154 |
+
'index' => 'name',
|
155 |
+
'filter_index' => 'name',
|
156 |
+
'frame_callback' => array($this, 'callbackColumnProductTitle'),
|
157 |
+
'filter_condition_callback' => array($this, 'callbackFilterTitle')
|
158 |
+
));
|
159 |
+
|
160 |
+
$this->addColumn('general_id', array(
|
161 |
+
'header' => Mage::helper('M2ePro')->__('ASIN / ISBN'),
|
162 |
+
'align' => 'left',
|
163 |
+
'width' => '100px',
|
164 |
+
'type' => 'text',
|
165 |
+
'index' => 'general_id',
|
166 |
+
'filter_index' => 'general_id',
|
167 |
+
'frame_callback' => array($this, 'callbackColumnGeneralId')
|
168 |
+
));
|
169 |
+
|
170 |
+
$this->addColumn('online_qty', array(
|
171 |
+
'header' => Mage::helper('M2ePro')->__('QTY'),
|
172 |
+
'align' => 'right',
|
173 |
+
'width' => '70px',
|
174 |
+
'type' => 'number',
|
175 |
+
'index' => 'online_qty',
|
176 |
+
'filter_index' => 'online_qty',
|
177 |
+
'frame_callback' => array($this, 'callbackColumnAvailableQty')
|
178 |
+
));
|
179 |
+
|
180 |
+
$this->addColumn('online_price', array(
|
181 |
+
'header' => Mage::helper('M2ePro')->__('Price'),
|
182 |
+
'align' => 'right',
|
183 |
+
'width' => '70px',
|
184 |
+
'type' => 'number',
|
185 |
+
'index' => 'online_price',
|
186 |
+
'filter_index' => 'online_price',
|
187 |
+
'frame_callback' => array($this, 'callbackColumnPrice'),
|
188 |
+
'filter_condition_callback' => array($this, 'callbackFilterPrice')
|
189 |
+
));
|
190 |
+
|
191 |
+
$this->addColumn('is_afn_channel', array(
|
192 |
+
'header' => Mage::helper('M2ePro')->__('Fulfillment'),
|
193 |
+
'align' => 'right',
|
194 |
+
'width' => '90px',
|
195 |
+
'index' => 'is_afn_channel',
|
196 |
+
'filter_index' => 'is_afn_channel',
|
197 |
+
'type' => 'options',
|
198 |
+
'sortable' => false,
|
199 |
+
'options' => array(
|
200 |
+
0 => Mage::helper('M2ePro')->__('Merchant'),
|
201 |
+
1 => Mage::helper('M2ePro')->__('Amazon')
|
202 |
+
),
|
203 |
+
'frame_callback' => array($this, 'callbackColumnAfnChannel')
|
204 |
+
));
|
205 |
+
|
206 |
+
$this->addColumn('status', array(
|
207 |
+
'header' => Mage::helper('M2ePro')->__('Status'),
|
208 |
+
'width' => '125px',
|
209 |
+
'index' => 'amazon_status',
|
210 |
+
'filter_index' => 'amazon_status',
|
211 |
+
'type' => 'options',
|
212 |
+
'sortable' => false,
|
213 |
+
'options' => array(
|
214 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_LISTED => Mage::helper('M2ePro')->__('Active'),
|
215 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED => Mage::helper('M2ePro')->__('Inactive'),
|
216 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_BLOCKED => Mage::helper('M2ePro')->__('Inactive (Blocked)')
|
217 |
+
),
|
218 |
+
'frame_callback' => array($this, 'callbackColumnStatus')
|
219 |
+
));
|
220 |
+
|
221 |
+
if (Mage::helper('M2ePro/Module')->isDevelopmentMode()) {
|
222 |
+
$this->addColumn('developer_action', array(
|
223 |
+
'header' => Mage::helper('M2ePro')->__('Actions'),
|
224 |
+
'align' => 'left',
|
225 |
+
'width' => '100px',
|
226 |
+
'type' => 'text',
|
227 |
+
'renderer' => 'M2ePro/adminhtml_listing_view_grid_column_renderer_developerAction',
|
228 |
+
'index' => 'value',
|
229 |
+
'filter' => false,
|
230 |
+
'sortable' => false,
|
231 |
+
'js_handler' => 'ListingGridHandlerObj'
|
232 |
+
));
|
233 |
+
}
|
234 |
+
|
235 |
+
return parent::_prepareColumns();
|
236 |
+
}
|
237 |
+
|
238 |
+
protected function _prepareMassaction()
|
239 |
+
{
|
240 |
+
// Set massaction identifiers
|
241 |
+
//--------------------------------
|
242 |
+
$this->setMassactionIdField('id');
|
243 |
+
$this->setMassactionIdFieldOnlyIndexValue(true);
|
244 |
+
//--------------------------------
|
245 |
+
|
246 |
+
// Set mass-action
|
247 |
+
//--------------------------------
|
248 |
+
$this->getMassactionBlock()->addItem('revise', array(
|
249 |
+
'label' => Mage::helper('M2ePro')->__('Revise Item(s)'),
|
250 |
+
'url' => '',
|
251 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
252 |
+
));
|
253 |
+
|
254 |
+
$this->getMassactionBlock()->addItem('relist', array(
|
255 |
+
'label' => Mage::helper('M2ePro')->__('Relist Item(s)'),
|
256 |
+
'url' => '',
|
257 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
258 |
+
));
|
259 |
+
|
260 |
+
$this->getMassactionBlock()->addItem('stop', array(
|
261 |
+
'label' => Mage::helper('M2ePro')->__('Stop Item(s)'),
|
262 |
+
'url' => '',
|
263 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
264 |
+
));
|
265 |
+
|
266 |
+
$this->getMassactionBlock()->addItem('stopAndRemove', array(
|
267 |
+
'label' => Mage::helper('M2ePro')->__('Stop on Channel / Remove from Listing'),
|
268 |
+
'url' => '',
|
269 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
270 |
+
));
|
271 |
+
|
272 |
+
$this->getMassactionBlock()->addItem('deleteAndRemove', array(
|
273 |
+
'label' => Mage::helper('M2ePro')->__('Remove from Channel & Listing'),
|
274 |
+
'url' => '',
|
275 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
276 |
+
));
|
277 |
+
//--------------------------------
|
278 |
+
|
279 |
+
return parent::_prepareMassaction();
|
280 |
+
}
|
281 |
+
|
282 |
+
// ####################################
|
283 |
+
|
284 |
+
public function callbackColumnProductId($value, $row, $column, $isExport)
|
285 |
+
{
|
286 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
287 |
+
|
288 |
+
$storeId = (int)$listingData['store_id'];
|
289 |
+
|
290 |
+
$withoutImageHtml = '<a href="'
|
291 |
+
.$this->getUrl('adminhtml/catalog_product/edit',
|
292 |
+
array('id' => $value))
|
293 |
+
.'" target="_blank">'.$value.'</a>';
|
294 |
+
|
295 |
+
$showProductsThumbnails = (bool)(int)Mage::helper('M2ePro/Module')->getConfig()
|
296 |
+
->getGroupValue('/view/',
|
297 |
+
'show_products_thumbnails');
|
298 |
+
if (!$showProductsThumbnails) {
|
299 |
+
return $withoutImageHtml;
|
300 |
+
}
|
301 |
+
|
302 |
+
/** @var $magentoProduct Ess_M2ePro_Model_Magento_Product */
|
303 |
+
$magentoProduct = Mage::getModel('M2ePro/Magento_Product');
|
304 |
+
$magentoProduct->setProductId($value);
|
305 |
+
$magentoProduct->setStoreId($storeId);
|
306 |
+
|
307 |
+
$imageUrlResized = $magentoProduct->getThumbnailImageLink();
|
308 |
+
if (is_null($imageUrlResized)) {
|
309 |
+
return $withoutImageHtml;
|
310 |
+
}
|
311 |
+
|
312 |
+
$imageHtml = $value.'<hr style="border: 1px solid silver; border-bottom: none;"><img src="'.
|
313 |
+
$imageUrlResized.'" />';
|
314 |
+
$withImageHtml = str_replace('>'.$value.'<','>'.$imageHtml.'<',$withoutImageHtml);
|
315 |
+
|
316 |
+
return $withImageHtml;
|
317 |
+
}
|
318 |
+
|
319 |
+
public function callbackColumnProductTitle($productTitle, $row, $column, $isExport)
|
320 |
+
{
|
321 |
+
$productTitle = Mage::helper('M2ePro')->escapeHtml($productTitle);
|
322 |
+
|
323 |
+
$value = '<span>'.$productTitle.'</span>';
|
324 |
+
|
325 |
+
$tempSku = $row->getData('sku');
|
326 |
+
is_null($tempSku)
|
327 |
+
&& $tempSku = Mage::getModel('M2ePro/Magento_Product')->setProductId($row->getData('entity_id'))->getSku();
|
328 |
+
|
329 |
+
$value .= '<br/><strong>'.Mage::helper('M2ePro')->__('SKU') .
|
330 |
+
':</strong> '.Mage::helper('M2ePro')->escapeHtml($tempSku) . '<br/>';
|
331 |
+
|
332 |
+
$listingProduct = Mage::getModel('M2ePro/Listing_Product')->load($row->getData('id'));
|
333 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager $variationManager */
|
334 |
+
$variationManager = $listingProduct->getChildObject()->getVariationManager();
|
335 |
+
|
336 |
+
if (!$variationManager->isVariationProduct()) {
|
337 |
+
return $value;
|
338 |
+
}
|
339 |
+
|
340 |
+
if ($variationManager->isRelationChildType()) {
|
341 |
+
$typeModel = $variationManager->getTypeModel();
|
342 |
+
|
343 |
+
$productOptions = $typeModel->getProductOptions();
|
344 |
+
$channelOptions = $typeModel->getChannelOptions();
|
345 |
+
|
346 |
+
/** @var Ess_M2ePro_Model_Amazon_Listing_Product $parentAmazonListingProduct */
|
347 |
+
$parentAmazonListingProduct = $typeModel->getParentListingProduct()->getChildObject();
|
348 |
+
|
349 |
+
$matchedAttributes = $parentAmazonListingProduct->getVariationManager()
|
350 |
+
->getTypeModel()
|
351 |
+
->getMatchedAttributes();
|
352 |
+
|
353 |
+
if (!empty($matchedAttributes)) {
|
354 |
+
|
355 |
+
$sortedOptions = array();
|
356 |
+
|
357 |
+
foreach ($matchedAttributes as $magentoAttr => $amazonAttr) {
|
358 |
+
$sortedOptions[$amazonAttr] = $channelOptions[$amazonAttr];
|
359 |
+
}
|
360 |
+
|
361 |
+
$channelOptions = $sortedOptions;
|
362 |
+
}
|
363 |
+
|
364 |
+
$value .= '<div style="font-weight:bold;font-size: 11px;color: grey;margin-left: 7px;margin-top: 5px;">'.
|
365 |
+
Mage::helper('M2ePro')->__('Magento Variation') . '</div>';
|
366 |
+
$value .= '<div style="font-size: 11px; color: grey; margin-left: 24px">';
|
367 |
+
foreach ($productOptions as $attribute => $option) {
|
368 |
+
!$option && $option = '--';
|
369 |
+
$value .= '<b>' . Mage::helper('M2ePro')->escapeHtml($attribute) .
|
370 |
+
'</b>: ' . Mage::helper('M2ePro')->escapeHtml($option) . '</br>';
|
371 |
+
}
|
372 |
+
$value .= '</div>';
|
373 |
+
|
374 |
+
$value .= '<div style="font-weight:bold;font-size: 11px;color: grey;margin-left: 7px;margin-top: 5px;">'.
|
375 |
+
Mage::helper('M2ePro')->__('Amazon Variation') . '</div>';
|
376 |
+
$value .= '<div style="font-size: 11px; color: grey; margin-left: 24px">';
|
377 |
+
foreach ($channelOptions as $attribute => $option) {
|
378 |
+
!$option && $option = '--';
|
379 |
+
$value .= '<b>' . Mage::helper('M2ePro')->escapeHtml($attribute) .
|
380 |
+
'</b>: ' . Mage::helper('M2ePro')->escapeHtml($option) . '</br>';
|
381 |
+
}
|
382 |
+
$value .= '</div>';
|
383 |
+
|
384 |
+
return $value;
|
385 |
+
}
|
386 |
+
|
387 |
+
$productOptions = array();
|
388 |
+
if ($listingProduct->getChildObject()->getVariationManager()->getTypeModel()->isVariationProductMatched()) {
|
389 |
+
$productOptions = $listingProduct->getChildObject()->getVariationManager()
|
390 |
+
->getTypeModel()->getProductOptions();
|
391 |
+
}
|
392 |
+
|
393 |
+
$value .= '<div style="font-size: 11px; color: grey; margin-left: 7px"><br/>';
|
394 |
+
foreach ($productOptions as $attribute => $option) {
|
395 |
+
!$option && $option = '--';
|
396 |
+
$value .= '<b>' . Mage::helper('M2ePro')->escapeHtml($attribute) .
|
397 |
+
'</b>: ' . Mage::helper('M2ePro')->escapeHtml($option) . '<br/>';
|
398 |
+
}
|
399 |
+
$value .= '</div>';
|
400 |
+
|
401 |
+
return $value;
|
402 |
+
}
|
403 |
+
|
404 |
+
public function callbackColumnGeneralId($value, $row, $column, $isExport)
|
405 |
+
{
|
406 |
+
if (is_null($value) || $value === '') {
|
407 |
+
return Mage::helper('M2ePro')->__('N/A');
|
408 |
+
}
|
409 |
+
|
410 |
+
$marketplaceId = Mage::helper('M2ePro/Data_Global')->getValue('marketplace_id');
|
411 |
+
|
412 |
+
$url = Mage::helper('M2ePro/Component_Amazon')->getItemUrl(
|
413 |
+
$value,
|
414 |
+
$marketplaceId
|
415 |
+
);
|
416 |
+
|
417 |
+
$parentAsinHtml = '';
|
418 |
+
$variationParentId = $row->getData('variation_parent_id');
|
419 |
+
if(!empty($variationParentId)){
|
420 |
+
$parentAsinHtml = '<br><span style="display: block;
|
421 |
+
margin-bottom: 5px;
|
422 |
+
font-size: 10px;
|
423 |
+
color: grey;">'.
|
424 |
+
Mage::helper('M2ePro')->__('child ASIN/ISBN</br>of parent %parent_asin%',
|
425 |
+
$this->getParentAsin($row->getData('id'))) . '</span>';
|
426 |
+
}
|
427 |
+
|
428 |
+
$generalIdOwnerHtml = '';
|
429 |
+
if($row->getData('is_general_id_owner') == 1){
|
430 |
+
$generalIdOwnerHtml = '<span style="font-size: 10px; color: grey; display: block;">'.
|
431 |
+
Mage::helper('M2ePro')->__('creator of ASIN/ISBN').
|
432 |
+
'</span>';
|
433 |
+
}
|
434 |
+
return <<<HTML
|
435 |
+
<a href="{$url}" target="_blank">{$value}</a>{$parentAsinHtml}{$generalIdOwnerHtml}
|
436 |
+
HTML;
|
437 |
+
}
|
438 |
+
|
439 |
+
public function callbackColumnStockAvailability($value, $row, $column, $isExport)
|
440 |
+
{
|
441 |
+
if ((int)$row->getData('is_in_stock') <= 0) {
|
442 |
+
return '<span style="color: red;">'.$value.'</span>';
|
443 |
+
}
|
444 |
+
|
445 |
+
return $value;
|
446 |
+
}
|
447 |
+
|
448 |
+
public function callbackColumnAvailableQty($value, $row, $column, $isExport)
|
449 |
+
{
|
450 |
+
if ((int)$row->getData('amazon_status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
451 |
+
if (is_null($value) || $value === '') {
|
452 |
+
return Mage::helper('M2ePro')->__('N/A');
|
453 |
+
}
|
454 |
+
} else {
|
455 |
+
if (is_null($value) || $value === '') {
|
456 |
+
return '<i style="color:gray;">receiving...</i>';
|
457 |
+
}
|
458 |
+
}
|
459 |
+
|
460 |
+
if ((bool)$row->getData('is_afn_channel')) {
|
461 |
+
return '--';
|
462 |
+
}
|
463 |
+
|
464 |
+
if ($value <= 0) {
|
465 |
+
return '<span style="color: red;">0</span>';
|
466 |
+
}
|
467 |
+
|
468 |
+
return $value;
|
469 |
+
}
|
470 |
+
|
471 |
+
public function callbackColumnPrice($value, $row, $column, $isExport)
|
472 |
+
{
|
473 |
+
if (is_null($value) || $value === '') {
|
474 |
+
if ($row->getData('amazon_status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
475 |
+
return Mage::helper('M2ePro')->__('N/A');
|
476 |
+
} else {
|
477 |
+
return '<i style="color:gray;">receiving...</i>';
|
478 |
+
}
|
479 |
+
}
|
480 |
+
|
481 |
+
$marketplaceId = Mage::helper('M2ePro/Data_Global')->getValue('marketplace_id');
|
482 |
+
$currency = Mage::helper('M2ePro/Component_Amazon')
|
483 |
+
->getCachedObject('Marketplace',$marketplaceId)
|
484 |
+
->getChildObject()
|
485 |
+
->getDefaultCurrency();
|
486 |
+
|
487 |
+
if ((float)$value <= 0) {
|
488 |
+
$priceValue = '<span style="color: #f00;">0</span>';
|
489 |
+
} else {
|
490 |
+
$priceValue = Mage::app()->getLocale()->currency($currency)->toCurrency($value);
|
491 |
+
}
|
492 |
+
|
493 |
+
$resultHtml = '';
|
494 |
+
|
495 |
+
$salePriceValue = $row->getData('online_sale_price');
|
496 |
+
if ((float)$salePriceValue > 0) {
|
497 |
+
$startDateTimestamp = strtotime($row->getData('online_sale_price_start_date'));
|
498 |
+
$endDateTimestamp = strtotime($row->getData('online_sale_price_end_date'));
|
499 |
+
|
500 |
+
$currentTimestamp = strtotime(Mage::helper('M2ePro')->getCurrentGmtDate(false,'Y-m-d 00:00:00'));
|
501 |
+
|
502 |
+
if ($currentTimestamp >= $startDateTimestamp &&
|
503 |
+
$currentTimestamp <= $endDateTimestamp &&
|
504 |
+
$salePriceValue < (float)$value
|
505 |
+
) {
|
506 |
+
$resultHtml = '<span style="text-decoration: line-through;">'.$priceValue.'</span>';
|
507 |
+
} else {
|
508 |
+
$resultHtml = $priceValue;
|
509 |
+
}
|
510 |
+
|
511 |
+
$salePriceValue = Mage::app()->getLocale()->currency($currency)->toCurrency($salePriceValue);
|
512 |
+
|
513 |
+
$resultHtml .= ' <br/><br/><span style="color:gray;">'.$salePriceValue.'</span><br/>';
|
514 |
+
|
515 |
+
$resultHtml .= '<span style="color:gray; font-size: 10px;">
|
516 |
+
From: '.date('Y-m-d', $startDateTimestamp).'<br/>
|
517 |
+
To: '.date('Y-m-d', $endDateTimestamp).'
|
518 |
+
</span>';
|
519 |
+
}
|
520 |
+
|
521 |
+
if (empty($resultHtml)) {
|
522 |
+
$resultHtml = $priceValue;
|
523 |
+
}
|
524 |
+
|
525 |
+
return $resultHtml;
|
526 |
+
}
|
527 |
+
|
528 |
+
public function callbackColumnAfnChannel($value, $row, $column, $isExport)
|
529 |
+
{
|
530 |
+
if (is_null($value) || $value === '') {
|
531 |
+
return Mage::helper('M2ePro')->__('N/A');
|
532 |
+
}
|
533 |
+
|
534 |
+
switch ($row->getData('is_afn_channel')) {
|
535 |
+
case Ess_M2ePro_Model_Amazon_Listing_Product::IS_ISBN_GENERAL_ID_YES:
|
536 |
+
$value = '<span style="font-weight: bold;">' . $value . '</span>';
|
537 |
+
break;
|
538 |
+
|
539 |
+
default:
|
540 |
+
break;
|
541 |
+
}
|
542 |
+
|
543 |
+
return $value;
|
544 |
+
}
|
545 |
+
|
546 |
+
public function callbackColumnStatus($value, $row, $column, $isExport)
|
547 |
+
{
|
548 |
+
switch ($row->getData('amazon_status')) {
|
549 |
+
|
550 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_UNKNOWN:
|
551 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED:
|
552 |
+
$value = '<span style="color: gray;">' . $value . '</span>';
|
553 |
+
break;
|
554 |
+
|
555 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_LISTED:
|
556 |
+
$value = '<span style="color: green;">' . $value . '</span>';
|
557 |
+
break;
|
558 |
+
|
559 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED:
|
560 |
+
$value = '<span style="color: red;">'.$value.'</span>';
|
561 |
+
break;
|
562 |
+
|
563 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_BLOCKED:
|
564 |
+
$value = '<span style="color: orange; font-weight: bold;">'.$value.'</span>';
|
565 |
+
break;
|
566 |
+
|
567 |
+
default:
|
568 |
+
break;
|
569 |
+
}
|
570 |
+
|
571 |
+
$value .= $this->getViewLogIconHtml($row->getData('id'));
|
572 |
+
|
573 |
+
$tempLocks = $this->getLockedData($row);
|
574 |
+
$tempLocks = $tempLocks['object_locks'];
|
575 |
+
|
576 |
+
foreach ($tempLocks as $lock) {
|
577 |
+
|
578 |
+
switch ($lock->getTag()) {
|
579 |
+
|
580 |
+
case 'list_action':
|
581 |
+
$value .= '<br/><span style="color: #605fff">[List in Progress...]</span>';
|
582 |
+
break;
|
583 |
+
|
584 |
+
case 'relist_action':
|
585 |
+
$value .= '<br/><span style="color: #605fff">[Relist in Progress...]</span>';
|
586 |
+
break;
|
587 |
+
|
588 |
+
case 'revise_action':
|
589 |
+
$value .= '<br/><span style="color: #605fff">[Revise in Progress...]</span>';
|
590 |
+
break;
|
591 |
+
|
592 |
+
case 'stop_action':
|
593 |
+
$value .= '<br/><span style="color: #605fff">[Stop in Progress...]</span>';
|
594 |
+
break;
|
595 |
+
|
596 |
+
case 'stop_and_remove_action':
|
597 |
+
$value .= '<br/><span style="color: #605fff">[Stop And Remove in Progress...]</span>';
|
598 |
+
break;
|
599 |
+
|
600 |
+
case 'delete_and_remove_action':
|
601 |
+
$value .= '<br/><span style="color: #605fff">[Remove in Progress...]</span>';
|
602 |
+
break;
|
603 |
+
|
604 |
+
default:
|
605 |
+
break;
|
606 |
+
|
607 |
+
}
|
608 |
+
}
|
609 |
+
|
610 |
+
return $value;
|
611 |
+
}
|
612 |
+
|
613 |
+
protected function callbackFilterTitle($collection, $column)
|
614 |
+
{
|
615 |
+
$value = $column->getFilter()->getValue();
|
616 |
+
|
617 |
+
if ($value == null) {
|
618 |
+
return;
|
619 |
+
}
|
620 |
+
|
621 |
+
$collection->addFieldToFilter(
|
622 |
+
array(
|
623 |
+
array('attribute'=>'sku','like'=>'%'.$value.'%'),
|
624 |
+
array('attribute'=>'name', 'like'=>'%'.$value.'%')
|
625 |
+
)
|
626 |
+
);
|
627 |
+
}
|
628 |
+
|
629 |
+
protected function callbackFilterPrice($collection, $column)
|
630 |
+
{
|
631 |
+
$value = $column->getFilter()->getValue();
|
632 |
+
|
633 |
+
if (empty($value)) {
|
634 |
+
return;
|
635 |
+
}
|
636 |
+
|
637 |
+
$from = $value['from'];
|
638 |
+
$to = $value['to'];
|
639 |
+
|
640 |
+
$collection->getSelect()->where(
|
641 |
+
'(alp.online_price >= \''.$from.'\' AND alp.online_price <= \''.$to.'\' AND
|
642 |
+
(
|
643 |
+
alp.online_sale_price IS NULL OR
|
644 |
+
alp.online_sale_price_start_date > NOW() OR
|
645 |
+
alp.online_sale_price_end_date < NOW()
|
646 |
+
)) OR (alp.online_sale_price >= \''.$from.'\' AND alp.online_sale_price <= \''.$to.'\' AND
|
647 |
+
(
|
648 |
+
alp.online_sale_price IS NOT NULL AND
|
649 |
+
alp.online_sale_price_start_date < NOW() AND
|
650 |
+
alp.online_sale_price_end_date > NOW()
|
651 |
+
))'
|
652 |
+
);
|
653 |
+
}
|
654 |
+
|
655 |
+
//----------------------------------------
|
656 |
+
|
657 |
+
public function getViewLogIconHtml($listingProductId)
|
658 |
+
{
|
659 |
+
$listingProductId = (int)$listingProductId;
|
660 |
+
|
661 |
+
// Get last messages
|
662 |
+
//--------------------------
|
663 |
+
/** @var $connRead Varien_Db_Adapter_Pdo_Mysql */
|
664 |
+
$connRead = Mage::getSingleton('core/resource')->getConnection('core_read');
|
665 |
+
|
666 |
+
$dbSelect = $connRead->select()
|
667 |
+
->from(
|
668 |
+
Mage::getResourceModel('M2ePro/Listing_Log')->getMainTable(),
|
669 |
+
array('action_id','action','type','description','create_date','initiator')
|
670 |
+
)
|
671 |
+
->where('`listing_product_id` = ?',$listingProductId)
|
672 |
+
->where('`action_id` IS NOT NULL')
|
673 |
+
->order(array('id DESC'))
|
674 |
+
->limit(30);
|
675 |
+
|
676 |
+
$logRows = $connRead->fetchAll($dbSelect);
|
677 |
+
//--------------------------
|
678 |
+
|
679 |
+
// Get grouped messages by action_id
|
680 |
+
//--------------------------
|
681 |
+
$actionsRows = array();
|
682 |
+
$tempActionRows = array();
|
683 |
+
$lastActionId = false;
|
684 |
+
|
685 |
+
foreach ($logRows as $row) {
|
686 |
+
|
687 |
+
$row['description'] = Mage::helper('M2ePro/View')->getModifiedLogMessage($row['description']);
|
688 |
+
|
689 |
+
if ($row['action_id'] !== $lastActionId) {
|
690 |
+
if (count($tempActionRows) > 0) {
|
691 |
+
$actionsRows[] = array(
|
692 |
+
'type' => $this->getMainTypeForActionId($tempActionRows),
|
693 |
+
'date' => $this->getMainDateForActionId($tempActionRows),
|
694 |
+
'action' => $this->getActionForAction($tempActionRows[0]),
|
695 |
+
'initiator' => $this->getInitiatorForAction($tempActionRows[0]),
|
696 |
+
'items' => $tempActionRows
|
697 |
+
);
|
698 |
+
$tempActionRows = array();
|
699 |
+
}
|
700 |
+
$lastActionId = $row['action_id'];
|
701 |
+
}
|
702 |
+
$tempActionRows[] = $row;
|
703 |
+
}
|
704 |
+
|
705 |
+
if (count($tempActionRows) > 0) {
|
706 |
+
$actionsRows[] = array(
|
707 |
+
'type' => $this->getMainTypeForActionId($tempActionRows),
|
708 |
+
'date' => $this->getMainDateForActionId($tempActionRows),
|
709 |
+
'action' => $this->getActionForAction($tempActionRows[0]),
|
710 |
+
'initiator' => $this->getInitiatorForAction($tempActionRows[0]),
|
711 |
+
'items' => $tempActionRows
|
712 |
+
);
|
713 |
+
}
|
714 |
+
|
715 |
+
if (count($actionsRows) <= 0) {
|
716 |
+
return '';
|
717 |
+
}
|
718 |
+
|
719 |
+
foreach ($actionsRows as &$actionsRow) {
|
720 |
+
usort($actionsRow['items'], function($a, $b)
|
721 |
+
{
|
722 |
+
$sortOrder = array(
|
723 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 1,
|
724 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 2,
|
725 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 3,
|
726 |
+
);
|
727 |
+
|
728 |
+
return $sortOrder[$a["type"]] > $sortOrder[$b["type"]];
|
729 |
+
});
|
730 |
+
}
|
731 |
+
|
732 |
+
$tips = array(
|
733 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'Last Action was completed successfully.',
|
734 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'Last Action was completed with error(s).',
|
735 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'Last Action was completed with warning(s).'
|
736 |
+
);
|
737 |
+
|
738 |
+
$icons = array(
|
739 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'normal',
|
740 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'error',
|
741 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'warning'
|
742 |
+
);
|
743 |
+
|
744 |
+
$summary = $this->getLayout()->createBlock('M2ePro/adminhtml_log_grid_summary', '', array(
|
745 |
+
'entity_id' => $listingProductId,
|
746 |
+
'rows' => $actionsRows,
|
747 |
+
'tips' => $tips,
|
748 |
+
'icons' => $icons,
|
749 |
+
'view_help_handler' => 'ListingGridHandlerObj.viewItemHelp',
|
750 |
+
'hide_help_handler' => 'ListingGridHandlerObj.hideItemHelp',
|
751 |
+
));
|
752 |
+
|
753 |
+
return $summary->toHtml();
|
754 |
+
}
|
755 |
+
|
756 |
+
public function getActionForAction($actionRows)
|
757 |
+
{
|
758 |
+
$string = '';
|
759 |
+
|
760 |
+
switch ($actionRows['action']) {
|
761 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_LIST_PRODUCT_ON_COMPONENT:
|
762 |
+
$string = Mage::helper('M2ePro')->__('List');
|
763 |
+
break;
|
764 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_RELIST_PRODUCT_ON_COMPONENT:
|
765 |
+
$string = Mage::helper('M2ePro')->__('Relist');
|
766 |
+
break;
|
767 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_REVISE_PRODUCT_ON_COMPONENT:
|
768 |
+
$string = Mage::helper('M2ePro')->__('Revise');
|
769 |
+
break;
|
770 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_STOP_PRODUCT_ON_COMPONENT:
|
771 |
+
$string = Mage::helper('M2ePro')->__('Stop');
|
772 |
+
break;
|
773 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_DELETE_PRODUCT_FROM_COMPONENT:
|
774 |
+
$string = Mage::helper('M2ePro')->__('Remove from Channel');
|
775 |
+
break;
|
776 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_STOP_AND_REMOVE_PRODUCT:
|
777 |
+
$string = Mage::helper('M2ePro')->__('Stop on Channel / Remove from Listing');
|
778 |
+
break;
|
779 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_DELETE_AND_REMOVE_PRODUCT:
|
780 |
+
$string = Mage::helper('M2ePro')->__('Remove from Channel & Listing');
|
781 |
+
break;
|
782 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_CHANGE_STATUS_ON_CHANNEL:
|
783 |
+
$string = Mage::helper('M2ePro')->__('Status Change');
|
784 |
+
break;
|
785 |
+
}
|
786 |
+
|
787 |
+
return $string;
|
788 |
+
}
|
789 |
+
|
790 |
+
public function getInitiatorForAction($actionRows)
|
791 |
+
{
|
792 |
+
$string = '';
|
793 |
+
|
794 |
+
switch ((int)$actionRows['initiator']) {
|
795 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_UNKNOWN:
|
796 |
+
$string = '';
|
797 |
+
break;
|
798 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_USER:
|
799 |
+
$string = Mage::helper('M2ePro')->__('Manual');
|
800 |
+
break;
|
801 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION:
|
802 |
+
$string = Mage::helper('M2ePro')->__('Automatic');
|
803 |
+
break;
|
804 |
+
}
|
805 |
+
|
806 |
+
return $string;
|
807 |
+
}
|
808 |
+
|
809 |
+
public function getMainTypeForActionId($actionRows)
|
810 |
+
{
|
811 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS;
|
812 |
+
|
813 |
+
foreach ($actionRows as $row) {
|
814 |
+
if ($row['type'] == Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR) {
|
815 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR;
|
816 |
+
break;
|
817 |
+
}
|
818 |
+
if ($row['type'] == Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING) {
|
819 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING;
|
820 |
+
}
|
821 |
+
}
|
822 |
+
|
823 |
+
return $type;
|
824 |
+
}
|
825 |
+
|
826 |
+
public function getMainDateForActionId($actionRows)
|
827 |
+
{
|
828 |
+
$format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
|
829 |
+
return Mage::app()->getLocale()->date(strtotime($actionRows[0]['create_date']))->toString($format);
|
830 |
+
}
|
831 |
+
|
832 |
+
// ####################################
|
833 |
+
|
834 |
+
public function getGridUrl()
|
835 |
+
{
|
836 |
+
return $this->getUrl('*/adminhtml_common_amazon_listing/viewGrid', array('_current'=>true));
|
837 |
+
}
|
838 |
+
|
839 |
+
public function getRowUrl($row)
|
840 |
+
{
|
841 |
+
return false;
|
842 |
+
}
|
843 |
+
|
844 |
+
// ####################################
|
845 |
+
|
846 |
+
protected function _toHtml()
|
847 |
+
{
|
848 |
+
$javascriptsMain = <<<JAVASCRIPT
|
849 |
+
<script type="text/javascript">
|
850 |
+
|
851 |
+
if (typeof ListingGridHandlerObj != 'undefined') {
|
852 |
+
ListingGridHandlerObj.afterInitPage();
|
853 |
+
}
|
854 |
+
|
855 |
+
Event.observe(window, 'load', function() {
|
856 |
+
setTimeout(function() {
|
857 |
+
ListingGridHandlerObj.afterInitPage();
|
858 |
+
}, 350);
|
859 |
+
});
|
860 |
+
|
861 |
+
</script>
|
862 |
+
JAVASCRIPT;
|
863 |
+
|
864 |
+
return parent::_toHtml().$javascriptsMain;
|
865 |
+
}
|
866 |
+
|
867 |
+
// ####################################
|
868 |
+
|
869 |
+
private function getLockedData($row)
|
870 |
+
{
|
871 |
+
$listingProductId = $row->getData('id');
|
872 |
+
if (!isset($this->lockedDataCache[$listingProductId])) {
|
873 |
+
$objectLocks = Mage::getModel('M2ePro/Listing_Product')->load($row->getData('id'))->getObjectLocks();
|
874 |
+
$tempArray = array(
|
875 |
+
'object_locks' => $objectLocks,
|
876 |
+
'in_action' => !empty($objectLocks),
|
877 |
+
);
|
878 |
+
$this->lockedDataCache[$listingProductId] = $tempArray;
|
879 |
+
}
|
880 |
+
|
881 |
+
return $this->lockedDataCache[$listingProductId];
|
882 |
+
}
|
883 |
+
|
884 |
+
// ####################################
|
885 |
+
|
886 |
+
private function getParentAsin($childId)
|
887 |
+
{
|
888 |
+
if (is_null($this->parentAsins)) {
|
889 |
+
$connRead = Mage::getSingleton('core/resource')->getConnection('core_read');
|
890 |
+
$tableAmazonListingProduct = Mage::getSingleton('core/resource')
|
891 |
+
->getTableName('m2epro_amazon_listing_product');
|
892 |
+
|
893 |
+
$select = $connRead->select();
|
894 |
+
$select->from(array('alp' => $tableAmazonListingProduct), array('listing_product_id','variation_parent_id'))
|
895 |
+
->where('listing_product_id IN (?)', $this->getCollection()->getAllIds())
|
896 |
+
->where('variation_parent_id IS NOT NULL');
|
897 |
+
|
898 |
+
$parentIds = Mage::getResourceModel('core/config')
|
899 |
+
->getReadConnection()
|
900 |
+
->fetchPairs($select);
|
901 |
+
|
902 |
+
$select = $connRead->select();
|
903 |
+
$select->from(array('alp' => $tableAmazonListingProduct), array('listing_product_id', 'general_id'))
|
904 |
+
->where('listing_product_id IN (?)', $parentIds);
|
905 |
+
|
906 |
+
$parentAsins = Mage::getResourceModel('core/config')
|
907 |
+
->getReadConnection()
|
908 |
+
->fetchPairs($select);
|
909 |
+
|
910 |
+
$this->parentAsins = array();
|
911 |
+
foreach ($parentIds as $childId => $parentId) {
|
912 |
+
$this->parentAsins[$childId] = $parentAsins[$parentId];
|
913 |
+
}
|
914 |
+
}
|
915 |
+
|
916 |
+
return $this->parentAsins[$childId];
|
917 |
+
}
|
918 |
+
|
919 |
+
// ####################################
|
920 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Marketplace/Form.php
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Marketplace_Form extends Mage_Adminhtml_Block_Widget_Form
|
8 |
+
{
|
9 |
+
// ########################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('amazonMarketplaceForm');
|
18 |
+
$this->setContainerId('magento_block_amazon_marketplaces');
|
19 |
+
$this->setTemplate('M2ePro/common/amazon/marketplace.phtml');
|
20 |
+
//------------------------------
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _prepareForm()
|
24 |
+
{
|
25 |
+
return parent::_prepareForm();
|
26 |
+
}
|
27 |
+
|
28 |
+
// ########################################
|
29 |
+
|
30 |
+
protected function _beforeToHtml()
|
31 |
+
{
|
32 |
+
//----------------------------
|
33 |
+
/** @var Ess_M2ePro_Model_Marketplace[] $marketplaces */
|
34 |
+
$marketplaces = Mage::helper('M2ePro/Component_Amazon')->getCollection('Marketplace')
|
35 |
+
->setOrder('group_title', 'ASC')
|
36 |
+
->setOrder('sorder','ASC')
|
37 |
+
->setOrder('title','ASC')
|
38 |
+
->getItems();
|
39 |
+
$groups = array();
|
40 |
+
$storedStatuses = array();
|
41 |
+
$previewGroup = '';
|
42 |
+
$idGroup = 1;
|
43 |
+
foreach($marketplaces as $marketplace) {
|
44 |
+
|
45 |
+
if ($marketplace->getGroupTitle() != $previewGroup) {
|
46 |
+
$previewGroup = $marketplace->getGroupTitle();
|
47 |
+
$groups[] = array(
|
48 |
+
'id' => $idGroup,
|
49 |
+
'title' => $previewGroup,
|
50 |
+
'marketplaces' => array()
|
51 |
+
);
|
52 |
+
$idGroup++;
|
53 |
+
}
|
54 |
+
|
55 |
+
$storedStatuses[] = array(
|
56 |
+
'marketplace_id' => $marketplace->getId(),
|
57 |
+
'status' => $marketplace->getStatus()
|
58 |
+
);
|
59 |
+
|
60 |
+
$isLocked = (bool)Mage::helper('M2ePro/Component_Amazon')->getCollection('Account')
|
61 |
+
->addFieldToFilter('marketplace_id', $marketplace->getId())
|
62 |
+
->getSize();
|
63 |
+
|
64 |
+
$marketplace = array(
|
65 |
+
'instance' => $marketplace,
|
66 |
+
'params' => array('locked' => $isLocked)
|
67 |
+
);
|
68 |
+
|
69 |
+
$groups[count($groups)-1]['marketplaces'][] = $marketplace;
|
70 |
+
}
|
71 |
+
|
72 |
+
$this->groups = $groups;
|
73 |
+
$this->storedStatuses = $storedStatuses;
|
74 |
+
//----------------------------
|
75 |
+
|
76 |
+
//------------------------------
|
77 |
+
$data = array(
|
78 |
+
'label' => Mage::helper('M2ePro')->__('Update Now'),
|
79 |
+
'onclick' => 'MarketplaceHandlerObj.runSingleSynchronization(this)',
|
80 |
+
'class' => 'run_single_button'
|
81 |
+
);
|
82 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
83 |
+
$this->setChild('run_single_button', $buttonBlock);
|
84 |
+
//------------------------------
|
85 |
+
|
86 |
+
return parent::_beforeToHtml();
|
87 |
+
}
|
88 |
+
|
89 |
+
// ########################################
|
90 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Order/Edit/ShippingAddress.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Order_Edit_ShippingAddress
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Form_Container
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
//------------------------------
|
16 |
+
$this->setId('amazonOrderEditShippingAddress');
|
17 |
+
$this->_blockGroup = 'M2ePro';
|
18 |
+
$this->_controller = 'adminhtml_common_amazon_order_edit';
|
19 |
+
$this->_mode = 'shippingAddress';
|
20 |
+
//------------------------------
|
21 |
+
|
22 |
+
// Set header text
|
23 |
+
//------------------------------
|
24 |
+
$this->_headerText = Mage::helper('M2ePro')->__('Edit Shipping Address');
|
25 |
+
//------------------------------
|
26 |
+
|
27 |
+
// Set buttons actions
|
28 |
+
//------------------------------
|
29 |
+
$this->removeButton('back');
|
30 |
+
$this->removeButton('reset');
|
31 |
+
$this->removeButton('delete');
|
32 |
+
$this->removeButton('add');
|
33 |
+
$this->removeButton('save');
|
34 |
+
$this->removeButton('edit');
|
35 |
+
//------------------------------
|
36 |
+
|
37 |
+
if (!is_null($this->getRequest()->getParam('back'))) {
|
38 |
+
//------------------------------
|
39 |
+
$url = Mage::helper('M2ePro')->getBackUrl('*/adminhtml_common_order/index');
|
40 |
+
$this->_addButton('back', array(
|
41 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
42 |
+
'onclick' => 'CommonHandlerObj.back_click(\''.$url.'\')',
|
43 |
+
'class' => 'back'
|
44 |
+
));
|
45 |
+
//------------------------------
|
46 |
+
} else {
|
47 |
+
//------------------------------
|
48 |
+
$url = $this->getUrl('*/*/view', array('id' => $this->getRequest()->getParam('id')));
|
49 |
+
$this->_addButton('back', array(
|
50 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
51 |
+
'onclick' => 'CommonHandlerObj.back_click(\''.$url.'\')',
|
52 |
+
'class' => 'back'
|
53 |
+
));
|
54 |
+
//------------------------------
|
55 |
+
}
|
56 |
+
|
57 |
+
//------------------------------
|
58 |
+
$this->_addButton('save', array(
|
59 |
+
'label' => Mage::helper('M2ePro')->__('Save Order Address'),
|
60 |
+
'onclick' => 'CommonHandlerObj.save_click()',
|
61 |
+
'class' => 'save'
|
62 |
+
));
|
63 |
+
//------------------------------
|
64 |
+
}
|
65 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Order/Edit/ShippingAddress/Form.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Order_Edit_ShippingAddress_Form extends Mage_Adminhtml_Block_Widget_Form
|
8 |
+
{
|
9 |
+
private $order;
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('amazonOrderEditShippingAddressForm');
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$this->setTemplate('M2ePro/common/amazon/order/edit/shipping_address.phtml');
|
21 |
+
$this->order = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
22 |
+
}
|
23 |
+
|
24 |
+
protected function _prepareForm()
|
25 |
+
{
|
26 |
+
$form = new Varien_Data_Form(array(
|
27 |
+
'id' => 'edit_form',
|
28 |
+
'action' => $this->getUrl('*/*/save'),
|
29 |
+
'method' => 'post',
|
30 |
+
'enctype' => 'multipart/form-data'
|
31 |
+
));
|
32 |
+
|
33 |
+
$form->setUseContainer(true);
|
34 |
+
$this->setForm($form);
|
35 |
+
|
36 |
+
return parent::_prepareForm();
|
37 |
+
}
|
38 |
+
|
39 |
+
protected function _beforeToHtml()
|
40 |
+
{
|
41 |
+
try {
|
42 |
+
$regionCode = $this->order->getShippingAddress()->getRegionCode();
|
43 |
+
} catch (Exception $e) {
|
44 |
+
$regionCode = null;
|
45 |
+
}
|
46 |
+
|
47 |
+
$this->setData('countries', Mage::helper('M2ePro/Magento')->getCountries());
|
48 |
+
$this->setData('buyer_name', $this->order->getData('buyer_name'));
|
49 |
+
$this->setData('buyer_email', $this->order->getData('buyer_email'));
|
50 |
+
$this->setData('address', $this->order->getShippingAddress()->getData());
|
51 |
+
$this->setData('region_code', $regionCode);
|
52 |
+
|
53 |
+
return parent::_beforeToHtml();
|
54 |
+
}
|
55 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Order/Grid.php
ADDED
@@ -0,0 +1,558 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
/** @var $itemsCollection Ess_M2ePro_Model_Mysql4_Order_Item_Collection */
|
10 |
+
private $itemsCollection = NULL;
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->setId('amazonOrderGrid');
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
// Set default values
|
22 |
+
//------------------------------
|
23 |
+
$this->setDefaultSort('purchase_create_date');
|
24 |
+
$this->setDefaultDir('DESC');
|
25 |
+
$this->setSaveParametersInSession(true);
|
26 |
+
$this->setUseAjax(true);
|
27 |
+
//------------------------------
|
28 |
+
}
|
29 |
+
|
30 |
+
public function getMassactionBlockName()
|
31 |
+
{
|
32 |
+
return 'M2ePro/adminhtml_grid_massaction';
|
33 |
+
}
|
34 |
+
|
35 |
+
protected function _prepareCollection()
|
36 |
+
{
|
37 |
+
$collection = Mage::helper('M2ePro/Component_Amazon')->getCollection('Order');
|
38 |
+
|
39 |
+
$collection->getSelect()
|
40 |
+
->joinLeft(
|
41 |
+
array('so' => Mage::getSingleton('core/resource')->getTableName('sales/order')),
|
42 |
+
'(so.entity_id = `main_table`.magento_order_id)',
|
43 |
+
array('magento_order_num' => 'increment_id'));
|
44 |
+
|
45 |
+
// Add Filter By Account
|
46 |
+
//------------------------------
|
47 |
+
if ($accountId = $this->getRequest()->getParam('amazonAccount')) {
|
48 |
+
$collection->addFieldToFilter('`main_table`.account_id', $accountId);
|
49 |
+
}
|
50 |
+
//------------------------------
|
51 |
+
|
52 |
+
// Add Filter By Marketplace
|
53 |
+
//------------------------------
|
54 |
+
if ($marketplaceId = $this->getRequest()->getParam('amazonMarketplace')) {
|
55 |
+
$collection->addFieldToFilter('`main_table`.marketplace_id', $marketplaceId);
|
56 |
+
}
|
57 |
+
//------------------------------
|
58 |
+
|
59 |
+
// Add Not Created Magento Orders Filter
|
60 |
+
//------------------------------
|
61 |
+
if ($this->getRequest()->getParam('not_created_only')) {
|
62 |
+
$collection->addFieldToFilter('magento_order_id', array('null' => true));
|
63 |
+
}
|
64 |
+
//------------------------------
|
65 |
+
|
66 |
+
$this->setCollection($collection);
|
67 |
+
return parent::_prepareCollection();
|
68 |
+
}
|
69 |
+
|
70 |
+
protected function _afterLoadCollection()
|
71 |
+
{
|
72 |
+
$this->itemsCollection = Mage::helper('M2ePro/Component_Amazon')
|
73 |
+
->getCollection('Order_Item')
|
74 |
+
->addFieldToFilter('order_id', array('in' => $this->getCollection()->getColumnValues('id')));
|
75 |
+
|
76 |
+
return parent::_afterLoadCollection();
|
77 |
+
}
|
78 |
+
|
79 |
+
protected function _prepareColumns()
|
80 |
+
{
|
81 |
+
$this->addColumn('purchase_create_date', array(
|
82 |
+
'header' => Mage::helper('M2ePro')->__('Sale Date'),
|
83 |
+
'align' => 'left',
|
84 |
+
'type' => 'datetime',
|
85 |
+
'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM),
|
86 |
+
'index' => 'purchase_create_date',
|
87 |
+
'width' => '170px'
|
88 |
+
));
|
89 |
+
|
90 |
+
$this->addColumn('magento_order_num', array(
|
91 |
+
'header' => Mage::helper('M2ePro')->__('Magento Order #'),
|
92 |
+
'align' => 'left',
|
93 |
+
'index' => 'so.increment_id',
|
94 |
+
'width' => '110px',
|
95 |
+
'frame_callback' => array($this, 'callbackColumnMagentoOrder')
|
96 |
+
));
|
97 |
+
|
98 |
+
$this->addColumn('amazon_order_id', array(
|
99 |
+
'header' => Mage::helper('M2ePro')->__('Amazon Order #'),
|
100 |
+
'align' => 'left',
|
101 |
+
'width' => '110px',
|
102 |
+
'index' => 'amazon_order_id',
|
103 |
+
'frame_callback' => array($this, 'callbackColumnAmazonOrderId')
|
104 |
+
));
|
105 |
+
|
106 |
+
$this->addColumn('amazon_order_items', array(
|
107 |
+
'header' => Mage::helper('M2ePro')->__('Items'),
|
108 |
+
'align' => 'left',
|
109 |
+
'index' => 'amazon_order_items',
|
110 |
+
'sortable' => false,
|
111 |
+
'width' => '*',
|
112 |
+
'frame_callback' => array($this, 'callbackColumnItems'),
|
113 |
+
'filter_condition_callback' => array($this, 'callbackFilterItems')
|
114 |
+
));
|
115 |
+
|
116 |
+
$this->addColumn('buyer', array(
|
117 |
+
'header' => Mage::helper('M2ePro')->__('Buyer'),
|
118 |
+
'align' => 'left',
|
119 |
+
'index' => 'buyer_name',
|
120 |
+
'width' => '120px',
|
121 |
+
'frame_callback' => array($this, 'callbackColumnBuyer'),
|
122 |
+
'filter_condition_callback' => array($this, 'callbackFilterBuyer')
|
123 |
+
));
|
124 |
+
|
125 |
+
$this->addColumn('paid_amount', array(
|
126 |
+
'header' => Mage::helper('M2ePro')->__('Total Paid'),
|
127 |
+
'align' => 'left',
|
128 |
+
'width' => '110px',
|
129 |
+
'index' => 'paid_amount',
|
130 |
+
'type' => 'number',
|
131 |
+
'frame_callback' => array($this, 'callbackColumnTotal')
|
132 |
+
));
|
133 |
+
|
134 |
+
$this->addColumn('is_afn_channel', array(
|
135 |
+
'header' => Mage::helper('M2ePro')->__('Fulfillment'),
|
136 |
+
'width' => '100px',
|
137 |
+
'index' => 'is_afn_channel',
|
138 |
+
'filter_index' => 'second_table.is_afn_channel',
|
139 |
+
'type' => 'options',
|
140 |
+
'sortable' => false,
|
141 |
+
'options' => array(
|
142 |
+
0 => Mage::helper('M2ePro')->__('Merchant'),
|
143 |
+
1 => Mage::helper('M2ePro')->__('Amazon')
|
144 |
+
),
|
145 |
+
'frame_callback' => array($this, 'callbackColumnAfnChannel')
|
146 |
+
));
|
147 |
+
|
148 |
+
$this->addColumn('reservation_state', array(
|
149 |
+
'header' => Mage::helper('M2ePro')->__('Reservation'),
|
150 |
+
'align' => 'left',
|
151 |
+
'width' => '50px',
|
152 |
+
'index' => 'reservation_state',
|
153 |
+
'type' => 'options',
|
154 |
+
'options' => array(
|
155 |
+
Ess_M2ePro_Model_Order_Reserve::STATE_UNKNOWN => Mage::helper('M2ePro')->__('N/A'),
|
156 |
+
Ess_M2ePro_Model_Order_Reserve::STATE_PLACED => Mage::helper('M2ePro')->__('Reserved'),
|
157 |
+
Ess_M2ePro_Model_Order_Reserve::STATE_RELEASED => Mage::helper('M2ePro')->__('Released'),
|
158 |
+
Ess_M2ePro_Model_Order_Reserve::STATE_CANCELED => Mage::helper('M2ePro')->__('Canceled'),
|
159 |
+
)
|
160 |
+
));
|
161 |
+
|
162 |
+
$helper = Mage::helper('M2ePro');
|
163 |
+
|
164 |
+
$this->addColumn('status', array(
|
165 |
+
'header' => Mage::helper('M2ePro')->__('Status'),
|
166 |
+
'align' => 'left',
|
167 |
+
'width' => '50px',
|
168 |
+
'index' => 'status',
|
169 |
+
'filter_index' => 'second_table.status',
|
170 |
+
'type' => 'options',
|
171 |
+
'options' => array(
|
172 |
+
Ess_M2ePro_Model_Amazon_Order::STATUS_PENDING => $helper->__('Pending'),
|
173 |
+
Ess_M2ePro_Model_Amazon_Order::STATUS_UNSHIPPED => $helper->__('Unshipped'),
|
174 |
+
Ess_M2ePro_Model_Amazon_Order::STATUS_SHIPPED_PARTIALLY => $helper->__('Partially Shipped'),
|
175 |
+
Ess_M2ePro_Model_Amazon_Order::STATUS_SHIPPED => $helper->__('Shipped'),
|
176 |
+
Ess_M2ePro_Model_Amazon_Order::STATUS_INVOICE_UNCONFIRMED => $helper->__('Invoice Not Confirmed'),
|
177 |
+
Ess_M2ePro_Model_Amazon_Order::STATUS_UNFULFILLABLE => $helper->__('Unfulfillable'),
|
178 |
+
Ess_M2ePro_Model_Amazon_Order::STATUS_CANCELED => $helper->__('Canceled')
|
179 |
+
),
|
180 |
+
'frame_callback' => array($this, 'callbackColumnStatus')
|
181 |
+
));
|
182 |
+
|
183 |
+
$back = Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_order/index', array(
|
184 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON
|
185 |
+
));
|
186 |
+
|
187 |
+
$this->addColumn('action', array(
|
188 |
+
'header' => Mage::helper('M2ePro')->__('Action'),
|
189 |
+
'width' => '80px',
|
190 |
+
'type' => 'action',
|
191 |
+
'getter' => 'getId',
|
192 |
+
'actions' => array(
|
193 |
+
array(
|
194 |
+
'caption' => Mage::helper('M2ePro')->__('View'),
|
195 |
+
'url' => array('base' => '*/adminhtml_common_amazon_order/view'),
|
196 |
+
'field' => 'id'
|
197 |
+
),
|
198 |
+
array(
|
199 |
+
'caption' => Mage::helper('M2ePro')->__('Edit Shipping Address'),
|
200 |
+
'url' => array('base' => '*/adminhtml_common_amazon_order/editShippingAddress/back/'.$back.'/'),
|
201 |
+
'field' => 'id'
|
202 |
+
),
|
203 |
+
array(
|
204 |
+
'caption' => Mage::helper('M2ePro')->__('Create Order'),
|
205 |
+
'url' => array('base' => '*/adminhtml_common_amazon_order/createMagentoOrder'),
|
206 |
+
'field' => 'id'
|
207 |
+
),
|
208 |
+
array(
|
209 |
+
'caption' => Mage::helper('M2ePro')->__('Mark As Shipped'),
|
210 |
+
'url' => array('base' => '*/adminhtml_common_amazon_order/updateShippingStatus'),
|
211 |
+
'field' => 'id'
|
212 |
+
)
|
213 |
+
),
|
214 |
+
'filter' => false,
|
215 |
+
'sortable' => false,
|
216 |
+
'is_system' => true
|
217 |
+
));
|
218 |
+
|
219 |
+
return parent::_prepareColumns();
|
220 |
+
}
|
221 |
+
|
222 |
+
protected function _prepareMassaction()
|
223 |
+
{
|
224 |
+
// Set massaction identifiers
|
225 |
+
//--------------------------------
|
226 |
+
$this->setMassactionIdField('main_table.id');
|
227 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
228 |
+
//--------------------------------
|
229 |
+
|
230 |
+
// Set mass-action
|
231 |
+
//--------------------------------
|
232 |
+
$this->getMassactionBlock()->addItem('reservation_place', array(
|
233 |
+
'label' => Mage::helper('M2ePro')->__('Reserve QTY'),
|
234 |
+
'url' => $this->getUrl('*/adminhtml_order/reservationPlace'),
|
235 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
236 |
+
));
|
237 |
+
|
238 |
+
$this->getMassactionBlock()->addItem('reservation_cancel', array(
|
239 |
+
'label' => Mage::helper('M2ePro')->__('Cancel QTY Reserve'),
|
240 |
+
'url' => $this->getUrl('*/adminhtml_order/reservationCancel'),
|
241 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
242 |
+
));
|
243 |
+
|
244 |
+
$this->getMassactionBlock()->addItem('ship', array(
|
245 |
+
'label' => Mage::helper('M2ePro')->__('Mark Order(s) as Shipped'),
|
246 |
+
'url' => $this->getUrl('*/adminhtml_common_amazon_order/updateShippingStatus'),
|
247 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
248 |
+
));
|
249 |
+
|
250 |
+
$this->getMassactionBlock()->addItem('resend_shipping', array(
|
251 |
+
'label' => Mage::helper('M2ePro')->__('Resend Shipping Information'),
|
252 |
+
'url' => $this->getUrl('*/adminhtml_order/resubmitShippingInfo'),
|
253 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
254 |
+
));
|
255 |
+
//--------------------------------
|
256 |
+
|
257 |
+
return parent::_prepareMassaction();
|
258 |
+
}
|
259 |
+
|
260 |
+
//##############################################################
|
261 |
+
|
262 |
+
public function callbackColumnAmazonOrderId($value, $row, $column, $isExport)
|
263 |
+
{
|
264 |
+
$orderId = Mage::helper('M2ePro')->escapeHtml($row->getData('amazon_order_id'));
|
265 |
+
$url = Mage::helper('M2ePro/Component_Amazon')->getOrderUrl($orderId, $row->getData('marketplace_id'));
|
266 |
+
|
267 |
+
return <<<HTML
|
268 |
+
<a href="{$url}" target="_blank">{$orderId}</a>
|
269 |
+
HTML;
|
270 |
+
}
|
271 |
+
|
272 |
+
public function callbackColumnMagentoOrder($value, $row, $column, $isExport)
|
273 |
+
{
|
274 |
+
$magentoOrderId = $row['magento_order_id'];
|
275 |
+
$magentoOrderNumber = Mage::helper('M2ePro')->escapeHtml($row['magento_order_num']);
|
276 |
+
|
277 |
+
$returnString = Mage::helper('M2ePro')->__('N/A');
|
278 |
+
|
279 |
+
if ($row['magento_order_id']) {
|
280 |
+
if ($row['magento_order_num']) {
|
281 |
+
$orderUrl = $this->getUrl('adminhtml/sales_order/view', array('order_id' => $magentoOrderId));
|
282 |
+
$returnString = '<a href="' . $orderUrl . '" target="_blank">' . $magentoOrderNumber . '</a>';
|
283 |
+
} else {
|
284 |
+
$returnString = '<span style="color: red;">'.Mage::helper('M2ePro')->__('Deleted').'</span>';
|
285 |
+
}
|
286 |
+
}
|
287 |
+
|
288 |
+
return $returnString.$this->getViewLogIconHtml($row->getId());
|
289 |
+
}
|
290 |
+
|
291 |
+
private function getViewLogIconHtml($orderId)
|
292 |
+
{
|
293 |
+
$orderId = (int)$orderId;
|
294 |
+
|
295 |
+
// Prepare collection
|
296 |
+
// --------------------------------
|
297 |
+
$orderLogsCollection = Mage::getModel('M2ePro/Order_Log')->getCollection()
|
298 |
+
->addFieldToFilter('order_id', $orderId)
|
299 |
+
->setOrder('id', 'DESC');
|
300 |
+
$orderLogsCollection->getSelect()
|
301 |
+
->limit(3);
|
302 |
+
// --------------------------------
|
303 |
+
|
304 |
+
// Prepare logs data
|
305 |
+
// --------------------------------
|
306 |
+
if ($orderLogsCollection->count() <= 0) {
|
307 |
+
return '';
|
308 |
+
}
|
309 |
+
|
310 |
+
$format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
|
311 |
+
|
312 |
+
$logRows = array();
|
313 |
+
foreach ($orderLogsCollection as $log) {
|
314 |
+
$logRows[] = array(
|
315 |
+
'type' => $log->getData('type'),
|
316 |
+
'text' => Mage::helper('M2ePro/View')->getModifiedLogMessage($log->getData('message')),
|
317 |
+
'initiator' => $this->getInitiatorForAction($log->getData('initiator')),
|
318 |
+
'date' => Mage::app()->getLocale()->date(strtotime($log->getData('create_date')))->toString($format)
|
319 |
+
);
|
320 |
+
}
|
321 |
+
// --------------------------------
|
322 |
+
|
323 |
+
$tips = array(
|
324 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'Last Order Action was completed successfully.',
|
325 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'Last Order Action was completed with error(s).',
|
326 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'Last Order Action was completed with warning(s).'
|
327 |
+
);
|
328 |
+
|
329 |
+
$icons = array(
|
330 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'normal',
|
331 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'error',
|
332 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'warning'
|
333 |
+
);
|
334 |
+
|
335 |
+
$summary = $this->getLayout()->createBlock('M2ePro/adminhtml_log_grid_summary', '', array(
|
336 |
+
'entity_id' => $orderId,
|
337 |
+
'rows' => $logRows,
|
338 |
+
'tips' => $tips,
|
339 |
+
'icons' => $icons,
|
340 |
+
'view_help_handler' => 'OrderHandlerObj.viewOrderHelp',
|
341 |
+
'hide_help_handler' => 'OrderHandlerObj.hideOrderHelp',
|
342 |
+
));
|
343 |
+
|
344 |
+
return $summary->toHtml();
|
345 |
+
}
|
346 |
+
|
347 |
+
public function getInitiatorForAction($initiator)
|
348 |
+
{
|
349 |
+
$string = '';
|
350 |
+
|
351 |
+
switch ((int)$initiator) {
|
352 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_UNKNOWN:
|
353 |
+
$string = '';
|
354 |
+
break;
|
355 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_USER:
|
356 |
+
$string = Mage::helper('M2ePro')->__('Manual');
|
357 |
+
break;
|
358 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION:
|
359 |
+
$string = Mage::helper('M2ePro')->__('Automatic');
|
360 |
+
break;
|
361 |
+
}
|
362 |
+
|
363 |
+
return $string;
|
364 |
+
}
|
365 |
+
|
366 |
+
//--------------------------------------------------------------
|
367 |
+
|
368 |
+
public function callbackColumnItems($value, $row, $column, $isExport)
|
369 |
+
{
|
370 |
+
/** @var $items Ess_M2ePro_Model_Order_Item[] */
|
371 |
+
$items = $this->itemsCollection->getItemsByColumnValue('order_id', $row->getData('id'));
|
372 |
+
|
373 |
+
$html = '';
|
374 |
+
$gridId = $this->getId();
|
375 |
+
|
376 |
+
foreach ($items as $item) {
|
377 |
+
if ($html != '') {
|
378 |
+
$html .= '<br/>';
|
379 |
+
}
|
380 |
+
|
381 |
+
$isShowEditLink = false;
|
382 |
+
|
383 |
+
$product = $item->getProduct();
|
384 |
+
if (!is_null($product)) {
|
385 |
+
/** @var Ess_M2ePro_Model_Magento_Product $magentoProduct */
|
386 |
+
$magentoProduct = Mage::getModel('M2ePro/Magento_Product');
|
387 |
+
$magentoProduct->setProduct($product);
|
388 |
+
|
389 |
+
$associatedProducts = $item->getAssociatedProducts();
|
390 |
+
$associatedOptions = $item->getAssociatedOptions();
|
391 |
+
|
392 |
+
if ($magentoProduct->isProductWithVariations()
|
393 |
+
&& empty($associatedOptions)
|
394 |
+
&& empty($associatedProducts)
|
395 |
+
) {
|
396 |
+
$isShowEditLink = true;
|
397 |
+
}
|
398 |
+
}
|
399 |
+
|
400 |
+
$editItemHtml = '';
|
401 |
+
if ($isShowEditLink) {
|
402 |
+
$orderItemId = $item->getId();
|
403 |
+
$orderItemEditLabel = Mage::helper('M2ePro')->__('edit');
|
404 |
+
|
405 |
+
$js = "{OrderEditItemHandlerObj.edit('{$gridId}', {$orderItemId});}";
|
406 |
+
|
407 |
+
$editItemHtml = <<<HTML
|
408 |
+
<span> <a href="javascript:void(0);" onclick="{$js}">[{$orderItemEditLabel}]</a></span>
|
409 |
+
HTML;
|
410 |
+
}
|
411 |
+
|
412 |
+
$skuHtml = '';
|
413 |
+
if ($item->getSku()) {
|
414 |
+
$skuLabel = Mage::helper('M2ePro')->__('SKU');
|
415 |
+
$sku = Mage::helper('M2ePro')->escapeHtml($item->getSku());
|
416 |
+
|
417 |
+
$skuHtml = <<<STRING
|
418 |
+
<span style="padding-left: 10px;"><b>{$skuLabel}:</b> {$sku}</span><br/>
|
419 |
+
STRING;
|
420 |
+
}
|
421 |
+
|
422 |
+
$generalIdLabel = Mage::helper('M2ePro')->__($item->getIsIsbnGeneralId() ? 'ISBN' : 'ASIN');
|
423 |
+
$generalId = Mage::helper('M2ePro')->escapeHtml($item->getGeneralId());
|
424 |
+
|
425 |
+
$itemUrl = Mage::helper('M2ePro/Component_Amazon')->getItemUrl($item->getGeneralId(),
|
426 |
+
$row->getData('marketplace_id'));
|
427 |
+
|
428 |
+
$itemLink = '<a href="'.$itemUrl.'" target="_blank">'.$generalId.'</a>';
|
429 |
+
|
430 |
+
$generalIdHtml = <<<STRING
|
431 |
+
<span style="padding-left: 10px;"><b>{$generalIdLabel}:</b> {$itemLink}</span><br/>
|
432 |
+
STRING;
|
433 |
+
|
434 |
+
$itemTitle = Mage::helper('M2ePro')->escapeHtml($item->getTitle());
|
435 |
+
$qtyLabel = Mage::helper('M2ePro')->__('QTY');
|
436 |
+
$qtyHtml = <<<HTML
|
437 |
+
<span style="padding-left: 10px;"><b>{$qtyLabel}:</b> {$item->getQtyPurchased()}</span>
|
438 |
+
HTML;
|
439 |
+
|
440 |
+
$html .= <<<HTML
|
441 |
+
{$itemTitle} {$editItemHtml}<br/>
|
442 |
+
<small>{$generalIdHtml}{$skuHtml}{$qtyHtml}</small>
|
443 |
+
HTML;
|
444 |
+
}
|
445 |
+
|
446 |
+
return $html;
|
447 |
+
}
|
448 |
+
|
449 |
+
public function callbackColumnBuyer($value, $row, $column, $isExport)
|
450 |
+
{
|
451 |
+
if ($row->getData('buyer_name') == '') {
|
452 |
+
return Mage::helper('M2ePro')->__('N/A');
|
453 |
+
}
|
454 |
+
|
455 |
+
$html = Mage::helper('M2ePro')->escapeHtml($row->getData('buyer_name'));
|
456 |
+
|
457 |
+
if ($row->getData('buyer_email') != '') {
|
458 |
+
$html .= '<br/>';
|
459 |
+
$html .= '<' . Mage::helper('M2ePro')->escapeHtml($row->getData('buyer_email')) . '>';
|
460 |
+
}
|
461 |
+
|
462 |
+
return $html;
|
463 |
+
}
|
464 |
+
|
465 |
+
public function callbackColumnTotal($value, $row, $column, $isExport)
|
466 |
+
{
|
467 |
+
return Mage::getSingleton('M2ePro/Currency')->formatPrice(
|
468 |
+
$row->getData('currency'), $row->getData('paid_amount')
|
469 |
+
);
|
470 |
+
}
|
471 |
+
|
472 |
+
public function callbackColumnAfnChannel($value, $row, $column, $isExport)
|
473 |
+
{
|
474 |
+
switch ($row->getData('is_afn_channel')) {
|
475 |
+
case Ess_M2ePro_Model_Amazon_Listing_Product::IS_ISBN_GENERAL_ID_YES:
|
476 |
+
$value = '<span style="font-weight: bold;">' . $value . '</span>';
|
477 |
+
break;
|
478 |
+
|
479 |
+
default:
|
480 |
+
break;
|
481 |
+
}
|
482 |
+
|
483 |
+
return $value;
|
484 |
+
}
|
485 |
+
|
486 |
+
public function callbackColumnStatus($value, $row, $column, $isExport)
|
487 |
+
{
|
488 |
+
$status = $row->getData('status');
|
489 |
+
|
490 |
+
$statusColors = array(
|
491 |
+
Ess_M2ePro_Model_Amazon_Order::STATUS_PENDING => 'gray',
|
492 |
+
Ess_M2ePro_Model_Amazon_Order::STATUS_SHIPPED => 'green',
|
493 |
+
Ess_M2ePro_Model_Amazon_Order::STATUS_CANCELED => 'red'
|
494 |
+
);
|
495 |
+
|
496 |
+
$color = isset($statusColors[$status]) ? $statusColors[$status] : 'black';
|
497 |
+
$value = '<span style="color: '.$color.';">'.$value.'</span>';
|
498 |
+
|
499 |
+
if ($row->isLockedObject('update_order_status')) {
|
500 |
+
$value .= '<br/>';
|
501 |
+
$value .= '<span style="color: gray;">['
|
502 |
+
.Mage::helper('M2ePro')->__('Status Update in Progress...').']</span>';
|
503 |
+
}
|
504 |
+
|
505 |
+
return $value;
|
506 |
+
}
|
507 |
+
|
508 |
+
//##############################################################
|
509 |
+
|
510 |
+
protected function callbackFilterItems($collection, $column)
|
511 |
+
{
|
512 |
+
$value = $column->getFilter()->getValue();
|
513 |
+
if ($value == null) {
|
514 |
+
return;
|
515 |
+
}
|
516 |
+
|
517 |
+
$orderItemsCollection = Mage::helper('M2ePro/Component_Amazon')->getCollection('Order_Item');
|
518 |
+
|
519 |
+
$orderItemsCollection->getSelect()->reset(Zend_Db_Select::COLUMNS);
|
520 |
+
$orderItemsCollection->getSelect()->columns('order_id');
|
521 |
+
$orderItemsCollection->getSelect()->distinct(true);
|
522 |
+
|
523 |
+
$orderItemsCollection->getSelect()->where('title LIKE ? OR sku LIKE ? or general_id LIKE ?', '%'.$value.'%');
|
524 |
+
|
525 |
+
$totalResult = $orderItemsCollection->getColumnValues('order_id');
|
526 |
+
$collection->addFieldToFilter('`main_table`.id', array('in' => $totalResult));
|
527 |
+
}
|
528 |
+
|
529 |
+
protected function callbackFilterBuyer($collection, $column)
|
530 |
+
{
|
531 |
+
$value = $column->getFilter()->getValue();
|
532 |
+
if ($value == null) {
|
533 |
+
return;
|
534 |
+
}
|
535 |
+
|
536 |
+
$collection
|
537 |
+
->getSelect()
|
538 |
+
->where('buyer_email LIKE ? OR buyer_name LIKE ?', '%'.$value.'%');
|
539 |
+
}
|
540 |
+
|
541 |
+
//##############################################################
|
542 |
+
|
543 |
+
public function getGridUrl()
|
544 |
+
{
|
545 |
+
return $this->getUrl('*/adminhtml_common_amazon_order/grid', array('_current' => true));
|
546 |
+
}
|
547 |
+
|
548 |
+
public function getRowUrl($row)
|
549 |
+
{
|
550 |
+
$back = Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_order/index', array(
|
551 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON
|
552 |
+
));
|
553 |
+
|
554 |
+
return $this->getUrl('*/adminhtml_common_amazon_order/view', array('id' => $row->getId(), 'back' => $back));
|
555 |
+
}
|
556 |
+
|
557 |
+
//##############################################################
|
558 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Order/View.php
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Order_View extends Mage_Adminhtml_Block_Widget_Form_Container
|
8 |
+
{
|
9 |
+
/** @var $order Ess_M2ePro_Model_Order */
|
10 |
+
protected $order = null;
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->setId('amazonOrderView');
|
19 |
+
$this->_blockGroup = 'M2ePro';
|
20 |
+
$this->_controller = 'adminhtml_common_amazon_order';
|
21 |
+
$this->_mode = 'view';
|
22 |
+
//------------------------------
|
23 |
+
|
24 |
+
// Set header text
|
25 |
+
//------------------------------
|
26 |
+
$this->_headerText = Mage::helper('M2ePro')->__('View Order Details');
|
27 |
+
//------------------------------
|
28 |
+
|
29 |
+
$this->order = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
30 |
+
|
31 |
+
// Set buttons actions
|
32 |
+
//------------------------------
|
33 |
+
$this->removeButton('back');
|
34 |
+
$this->removeButton('reset');
|
35 |
+
$this->removeButton('delete');
|
36 |
+
$this->removeButton('add');
|
37 |
+
$this->removeButton('save');
|
38 |
+
$this->removeButton('edit');
|
39 |
+
//------------------------------
|
40 |
+
|
41 |
+
//------------------------------
|
42 |
+
$url = Mage::helper('M2ePro')->getBackUrl('*/adminhtml_common_order/index');
|
43 |
+
$this->_addButton('back', array(
|
44 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
45 |
+
'onclick' => 'CommonHandlerObj.back_click(\''.$url.'\')',
|
46 |
+
'class' => 'back'
|
47 |
+
));
|
48 |
+
//------------------------------
|
49 |
+
|
50 |
+
if ($this->order->getChildObject()->canUpdateShippingStatus()) {
|
51 |
+
//------------------------------
|
52 |
+
$url = $this->getUrl('*/*/updateShippingStatus', array('id' => $this->order->getId()));
|
53 |
+
$this->_addButton('update_shipping_status', array(
|
54 |
+
'label' => Mage::helper('M2ePro')->__('Mark as Shipped'),
|
55 |
+
'onclick' => "setLocation('".$url."');",
|
56 |
+
'class' => 'scalable'
|
57 |
+
));
|
58 |
+
//------------------------------
|
59 |
+
}
|
60 |
+
|
61 |
+
if ($this->order->getReserve()->isPlaced()) {
|
62 |
+
//------------------------------
|
63 |
+
$url = $this->getUrl('*/adminhtml_order/reservationCancel', array('ids' => $this->order->getId()));
|
64 |
+
$this->_addButton('reservation_cancel', array(
|
65 |
+
'label' => Mage::helper('M2ePro')->__('Cancel QTY Reserve'),
|
66 |
+
'onclick' => "confirmSetLocation(M2ePro.translator.translate('Are you sure?'), '".$url."');",
|
67 |
+
'class' => 'scalable'
|
68 |
+
));
|
69 |
+
//------------------------------
|
70 |
+
} elseif ($this->order->isReservable()) {
|
71 |
+
//------------------------------
|
72 |
+
$url = $this->getUrl('*/adminhtml_order/reservationPlace', array('ids' => $this->order->getId()));
|
73 |
+
$this->_addButton('reservation_place', array(
|
74 |
+
'label' => Mage::helper('M2ePro')->__('Reserve QTY'),
|
75 |
+
'onclick' => "confirmSetLocation(M2ePro.translator.translate('Are you sure?'), '".$url."');",
|
76 |
+
'class' => 'scalable'
|
77 |
+
));
|
78 |
+
//------------------------------
|
79 |
+
}
|
80 |
+
|
81 |
+
if (is_null($this->order->getMagentoOrderId())) {
|
82 |
+
//------------------------------
|
83 |
+
$url = $this->getUrl('*/*/createMagentoOrder', array('id' => $this->order->getId()));
|
84 |
+
$this->_addButton('order', array(
|
85 |
+
'label' => Mage::helper('M2ePro')->__('Create Order'),
|
86 |
+
'onclick' => "setLocation('".$url."');",
|
87 |
+
'class' => 'scalable'
|
88 |
+
));
|
89 |
+
//------------------------------
|
90 |
+
} elseif (is_null($this->order->getMagentoOrder()) || $this->order->getMagentoOrder()->isCanceled()) {
|
91 |
+
//------------------------------
|
92 |
+
$url = $this->getUrl('*/*/createMagentoOrder', array('id' => $this->order->getId(), 'force' => 'yes'));
|
93 |
+
$confirm = Mage::helper('M2ePro')->escapeJs(
|
94 |
+
Mage::helper('M2ePro')->__('Are you sure that you want to create new Magento Order?')
|
95 |
+
);
|
96 |
+
|
97 |
+
$this->_addButton('order', array(
|
98 |
+
'label' => Mage::helper('M2ePro')->__('Create Order'),
|
99 |
+
'onclick' => "confirmSetLocation('".$confirm."','".$url."');",
|
100 |
+
'class' => 'scalable'
|
101 |
+
));
|
102 |
+
//------------------------------
|
103 |
+
}
|
104 |
+
}
|
105 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Order/View/Form.php
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Order_View_Form extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
public $shippingAddress = array();
|
10 |
+
|
11 |
+
public $realMagentoOrderId = NULL;
|
12 |
+
|
13 |
+
public function __construct()
|
14 |
+
{
|
15 |
+
parent::__construct();
|
16 |
+
|
17 |
+
// Initialization block
|
18 |
+
//------------------------------
|
19 |
+
$this->setId('amazonOrderViewForm');
|
20 |
+
$this->setTemplate('M2ePro/common/amazon/order.phtml');
|
21 |
+
//------------------------------
|
22 |
+
|
23 |
+
/** @var $order Ess_M2ePro_Model_Order */
|
24 |
+
$this->order = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
25 |
+
}
|
26 |
+
|
27 |
+
protected function _beforeToHtml()
|
28 |
+
{
|
29 |
+
// Magento order data
|
30 |
+
// ---------------
|
31 |
+
$this->realMagentoOrderId = NULL;
|
32 |
+
|
33 |
+
$magentoOrder = $this->order->getMagentoOrder();
|
34 |
+
if (!is_null($magentoOrder)) {
|
35 |
+
$this->realMagentoOrderId = $magentoOrder->getRealOrderId();
|
36 |
+
}
|
37 |
+
// ---------------
|
38 |
+
|
39 |
+
// ---------------
|
40 |
+
if (!is_null($magentoOrder) && $magentoOrder->hasShipments()) {
|
41 |
+
$url = $this->getUrl('*/adminhtml_order/resubmitShippingInfo', array('id' => $this->order->getId()));
|
42 |
+
$data = array(
|
43 |
+
'class' => '',
|
44 |
+
'label' => Mage::helper('M2ePro')->__('Resend Shipping Information'),
|
45 |
+
'onclick' => 'setLocation(\''.$url.'\');',
|
46 |
+
);
|
47 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
48 |
+
$this->setChild('resubmit_shipping_info', $buttonBlock);
|
49 |
+
}
|
50 |
+
// ---------------
|
51 |
+
|
52 |
+
// Shipping data
|
53 |
+
// ---------------
|
54 |
+
/** @var $shippingAddress Ess_M2ePro_Model_Amazon_Order_ShippingAddress */
|
55 |
+
$shippingAddress = $this->order->getShippingAddress();
|
56 |
+
|
57 |
+
$this->shippingAddress = $shippingAddress->getData();
|
58 |
+
$this->shippingAddress['country_name'] = $shippingAddress->getCountryName();
|
59 |
+
// ---------------
|
60 |
+
|
61 |
+
$this->setChild('item', $this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_order_view_item'));
|
62 |
+
$this->setChild('item_edit', $this->getLayout()->createBlock('M2ePro/adminhtml_order_item_edit'));
|
63 |
+
$this->setChild('log', $this->getLayout()->createBlock('M2ePro/adminhtml_order_view_log_grid'));
|
64 |
+
|
65 |
+
return parent::_beforeToHtml();
|
66 |
+
}
|
67 |
+
|
68 |
+
private function getStore()
|
69 |
+
{
|
70 |
+
if (is_null($this->order->getData('store_id'))) {
|
71 |
+
return null;
|
72 |
+
}
|
73 |
+
|
74 |
+
try {
|
75 |
+
$store = Mage::app()->getStore($this->order->getData('store_id'));
|
76 |
+
} catch (Exception $e) {
|
77 |
+
return null;
|
78 |
+
}
|
79 |
+
|
80 |
+
return $store;
|
81 |
+
}
|
82 |
+
|
83 |
+
public function isCurrencyAllowed()
|
84 |
+
{
|
85 |
+
$store = $this->getStore();
|
86 |
+
|
87 |
+
if (is_null($store)) {
|
88 |
+
return true;
|
89 |
+
}
|
90 |
+
|
91 |
+
/** @var $currencyHelper Ess_M2ePro_Model_Currency */
|
92 |
+
$currencyHelper = Mage::getSingleton('M2ePro/Currency');
|
93 |
+
|
94 |
+
return $currencyHelper->isAllowed($this->order->getChildObject()->getCurrency(), $store);
|
95 |
+
}
|
96 |
+
|
97 |
+
public function hasCurrencyConversionRate()
|
98 |
+
{
|
99 |
+
$store = $this->getStore();
|
100 |
+
|
101 |
+
if (is_null($store)) {
|
102 |
+
return true;
|
103 |
+
}
|
104 |
+
|
105 |
+
/** @var $currencyHelper Ess_M2ePro_Model_Currency */
|
106 |
+
$currencyHelper = Mage::getSingleton('M2ePro/Currency');
|
107 |
+
|
108 |
+
return $currencyHelper->getConvertRateFromBase($this->order->getChildObject()->getCurrency(), $store) != 0;
|
109 |
+
}
|
110 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Order/View/Item.php
ADDED
@@ -0,0 +1,302 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Order_View_Item extends Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonOrderViewItem');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
// Set default values
|
19 |
+
//------------------------------
|
20 |
+
$this->setDefaultSort('id');
|
21 |
+
$this->setDefaultDir('DESC');
|
22 |
+
$this->setPagerVisibility(false);
|
23 |
+
$this->setFilterVisibility(false);
|
24 |
+
$this->setUseAjax(true);
|
25 |
+
$this->_defaultLimit = 200;
|
26 |
+
//------------------------------
|
27 |
+
|
28 |
+
/** @var $order Ess_M2ePro_Model_Order */
|
29 |
+
$this->order = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
30 |
+
}
|
31 |
+
|
32 |
+
protected function _prepareCollection()
|
33 |
+
{
|
34 |
+
$collection = Mage::helper('M2ePro/Component_Amazon')
|
35 |
+
->getCollection('Order_Item')
|
36 |
+
->addFieldToFilter('order_id', $this->order->getId());
|
37 |
+
|
38 |
+
$collection->getSelect()->joinLeft(
|
39 |
+
array('cisi' => Mage::getSingleton('core/resource')->getTableName('cataloginventory_stock_item')),
|
40 |
+
'(cisi.product_id = `main_table`.product_id AND cisi.stock_id = 1)',
|
41 |
+
array('is_in_stock')
|
42 |
+
);
|
43 |
+
|
44 |
+
$this->setCollection($collection);
|
45 |
+
|
46 |
+
return parent::_prepareCollection();
|
47 |
+
}
|
48 |
+
|
49 |
+
protected function _prepareColumns()
|
50 |
+
{
|
51 |
+
$this->addColumn('product_id', array(
|
52 |
+
'header' => Mage::helper('M2ePro')->__('Product'),
|
53 |
+
'align' => 'left',
|
54 |
+
'width' => '*',
|
55 |
+
'index' => 'product_id',
|
56 |
+
'frame_callback' => array($this, 'callbackColumnProduct')
|
57 |
+
));
|
58 |
+
|
59 |
+
$this->addColumn('stock_availability', array(
|
60 |
+
'header'=> Mage::helper('M2ePro')->__('Stock Availability'),
|
61 |
+
'width' => '100px',
|
62 |
+
'index' => 'is_in_stock',
|
63 |
+
'filter_index' => 'cisi.is_in_stock',
|
64 |
+
'type' => 'options',
|
65 |
+
'sortable' => false,
|
66 |
+
'options' => array(
|
67 |
+
1 => Mage::helper('M2ePro')->__('In Stock'),
|
68 |
+
0 => Mage::helper('M2ePro')->__('Out of Stock')
|
69 |
+
),
|
70 |
+
'frame_callback' => array($this, 'callbackColumnStockAvailability')
|
71 |
+
));
|
72 |
+
|
73 |
+
$this->addColumn('original_price', array(
|
74 |
+
'header' => Mage::helper('M2ePro')->__('Original Price'),
|
75 |
+
'align' => 'left',
|
76 |
+
'width' => '80px',
|
77 |
+
'filter' => false,
|
78 |
+
'sortable' => false,
|
79 |
+
'frame_callback' => array($this, 'callbackColumnOriginalPrice')
|
80 |
+
));
|
81 |
+
|
82 |
+
$this->addColumn('qty_purchased', array(
|
83 |
+
'header' => Mage::helper('M2ePro')->__('QTY'),
|
84 |
+
'align' => 'left',
|
85 |
+
'width' => '80px',
|
86 |
+
'index' => 'qty_purchased'
|
87 |
+
));
|
88 |
+
|
89 |
+
$this->addColumn('price', array(
|
90 |
+
'header' => Mage::helper('M2ePro')->__('Price'),
|
91 |
+
'align' => 'left',
|
92 |
+
'width' => '80px',
|
93 |
+
'index' => 'price',
|
94 |
+
'frame_callback' => array($this, 'callbackColumnPrice')
|
95 |
+
));
|
96 |
+
|
97 |
+
$this->addColumn('discount_amount', array(
|
98 |
+
'header' => Mage::helper('M2ePro')->__('Promotions'),
|
99 |
+
'align' => 'left',
|
100 |
+
'width' => '80px',
|
101 |
+
'index' => 'discount_amount',
|
102 |
+
'frame_callback' => array($this, 'callbackColumnDiscountAmount')
|
103 |
+
));
|
104 |
+
|
105 |
+
if (Mage::getResourceModel('M2ePro/Amazon_Order')->hasGifts($this->order->getId())) {
|
106 |
+
$this->addColumn('gift_price', array(
|
107 |
+
'header' => Mage::helper('M2ePro')->__('Gift Wrap Price'),
|
108 |
+
'align' => 'left',
|
109 |
+
'width' => '80px',
|
110 |
+
'index' => 'gift_price',
|
111 |
+
'frame_callback' => array($this, 'callbackColumnGiftPrice')
|
112 |
+
));
|
113 |
+
|
114 |
+
$this->addColumn('gift_options', array(
|
115 |
+
'header' => Mage::helper('M2ePro')->__('Gift Options'),
|
116 |
+
'align' => 'left',
|
117 |
+
'width' => '250px',
|
118 |
+
'filter' => false,
|
119 |
+
'sortable' => false,
|
120 |
+
'frame_callback' => array($this, 'callbackColumnGiftOptions')
|
121 |
+
));
|
122 |
+
}
|
123 |
+
|
124 |
+
$this->addColumn('row_total', array(
|
125 |
+
'header' => Mage::helper('M2ePro')->__('Row Total'),
|
126 |
+
'align' => 'left',
|
127 |
+
'width' => '80px',
|
128 |
+
'frame_callback' => array($this, 'callbackColumnRowTotal')
|
129 |
+
));
|
130 |
+
|
131 |
+
return parent::_prepareColumns();
|
132 |
+
}
|
133 |
+
|
134 |
+
//##############################################################
|
135 |
+
|
136 |
+
/**
|
137 |
+
* @param $value
|
138 |
+
* @param $row Ess_M2ePro_Model_Order_Item
|
139 |
+
* @param $column
|
140 |
+
* @param $isExport
|
141 |
+
*
|
142 |
+
* @return string
|
143 |
+
*/
|
144 |
+
public function callbackColumnProduct($value, $row, $column, $isExport)
|
145 |
+
{
|
146 |
+
$skuHtml = '';
|
147 |
+
if ($row->getSku()) {
|
148 |
+
$skuLabel = Mage::helper('M2ePro')->__('SKU');
|
149 |
+
$sku = Mage::helper('M2ePro')->escapeHtml($row->getSku());
|
150 |
+
|
151 |
+
$skuHtml = <<<HTML
|
152 |
+
<b>{$skuLabel}:</b> {$sku}<br/>
|
153 |
+
HTML;
|
154 |
+
}
|
155 |
+
|
156 |
+
$generalIdLabel = Mage::helper('M2ePro')->__($row->getIsIsbnGeneralId() ? 'ISBN' : 'ASIN');
|
157 |
+
$generalId = Mage::helper('M2ePro')->escapeHtml($row->getGeneralId());
|
158 |
+
|
159 |
+
$generalIdHtml = <<<HTML
|
160 |
+
<b>{$generalIdLabel}:</b> {$generalId}<br/>
|
161 |
+
HTML;
|
162 |
+
|
163 |
+
if ($row->getIsIsbnGeneralId() && !Mage::helper('M2ePro')->isISBN($row->getGeneralId())) {
|
164 |
+
$amazonLink = '';
|
165 |
+
} else {
|
166 |
+
$itemLinkText = Mage::helper('M2ePro')->__('View on Amazon');
|
167 |
+
$itemUrl = Mage::helper('M2ePro/Component_Amazon')->getItemUrl(
|
168 |
+
$row->getGeneralId(), $this->order->getData('marketplace_id')
|
169 |
+
);
|
170 |
+
|
171 |
+
$amazonLink = <<<HTML
|
172 |
+
<a href="{$itemUrl}" target="_blank">{$itemLinkText}</a>
|
173 |
+
HTML;
|
174 |
+
}
|
175 |
+
|
176 |
+
$productLink = '';
|
177 |
+
if ($productId = $row->getData('product_id')) {
|
178 |
+
$productUrl = $this->getUrl('adminhtml/catalog_product/edit', array('id' => $productId));
|
179 |
+
$productLink = ' | <a href="'.$productUrl.'" target="_blank">'.Mage::helper('M2ePro')->__('View').'</a>';
|
180 |
+
}
|
181 |
+
|
182 |
+
$orderItemId = (int)$row->getId();
|
183 |
+
$gridId = $this->getId();
|
184 |
+
|
185 |
+
$editLink = '';
|
186 |
+
if (!$row->getProductId() || $row->getMagentoProduct()->hasRequiredOptions()) {
|
187 |
+
|
188 |
+
if (!$row->getProductId()) {
|
189 |
+
$action = Mage::helper('M2ePro')->__('Map to Magento Product');
|
190 |
+
} else {
|
191 |
+
$action = Mage::helper('M2ePro')->__('Set Options');
|
192 |
+
}
|
193 |
+
|
194 |
+
$class = 'class="gray"';
|
195 |
+
|
196 |
+
$js = "{OrderEditItemHandlerObj.edit('{$gridId}', {$orderItemId});}";
|
197 |
+
$editLink = '<a href="javascript:void(0);" onclick="'.$js.'" '.$class.'>'.$action.'</a>';
|
198 |
+
}
|
199 |
+
|
200 |
+
$discardLink = '';
|
201 |
+
if ($row->getProductId()) {
|
202 |
+
$action = Mage::helper('M2ePro')->__('Unmap');
|
203 |
+
|
204 |
+
$js = "{OrderEditItemHandlerObj.unassignProduct('{$gridId}', {$orderItemId});}";
|
205 |
+
$discardLink = '<a href="javascript:void(0);" onclick="'.$js.'" class="gray">'.$action.'</a>';
|
206 |
+
|
207 |
+
if ($editLink) {
|
208 |
+
$discardLink = ' | ' . $discardLink;
|
209 |
+
}
|
210 |
+
}
|
211 |
+
|
212 |
+
$itemTitle = Mage::helper('M2ePro')->escapeHtml($row->getTitle());
|
213 |
+
|
214 |
+
return <<<HTML
|
215 |
+
<b>{$itemTitle}</b><br/>
|
216 |
+
<div style="padding-left: 10px;">
|
217 |
+
{$skuHtml}
|
218 |
+
{$generalIdHtml}
|
219 |
+
</div>
|
220 |
+
<div style="float: left;">{$amazonLink}{$productLink}</div>
|
221 |
+
<div style="float: right;">{$editLink}{$discardLink}</div>
|
222 |
+
HTML;
|
223 |
+
}
|
224 |
+
|
225 |
+
public function callbackColumnStockAvailability($value, $row, $column, $isExport)
|
226 |
+
{
|
227 |
+
if (is_null($row->getData('is_in_stock'))) {
|
228 |
+
return Mage::helper('M2ePro')->__('N/A');
|
229 |
+
}
|
230 |
+
|
231 |
+
if ((int)$row->getData('is_in_stock') <= 0) {
|
232 |
+
return '<span style="color: red;">'.$value.'</span>';
|
233 |
+
}
|
234 |
+
|
235 |
+
return $value;
|
236 |
+
}
|
237 |
+
|
238 |
+
public function callbackColumnOriginalPrice($value, $row, $column, $isExport)
|
239 |
+
{
|
240 |
+
$productId = $row->getData('product_id');
|
241 |
+
$formattedPrice = Mage::helper('M2ePro')->__('N/A');
|
242 |
+
|
243 |
+
if ($productId && $product = Mage::getModel('catalog/product')->load($productId)) {
|
244 |
+
$formattedPrice = $product->getFormatedPrice();
|
245 |
+
}
|
246 |
+
|
247 |
+
return $formattedPrice;
|
248 |
+
}
|
249 |
+
|
250 |
+
public function callbackColumnPrice($value, $row, $column, $isExport)
|
251 |
+
{
|
252 |
+
return Mage::getSingleton('M2ePro/Currency')->formatPrice($row->getData('currency'), $row->getData('price'));
|
253 |
+
}
|
254 |
+
|
255 |
+
public function callbackColumnGiftPrice($value, $row, $column, $isExport)
|
256 |
+
{
|
257 |
+
return Mage::getSingleton('M2ePro/Currency')
|
258 |
+
->formatPrice($row->getData('currency'), $row->getData('gift_price'));
|
259 |
+
}
|
260 |
+
|
261 |
+
public function callbackColumnDiscountAmount($value, $row, $column, $isExport)
|
262 |
+
{
|
263 |
+
return Mage::getSingleton('M2ePro/Currency')
|
264 |
+
->formatPrice($row->getData('currency'), $row->getData('discount_amount'));
|
265 |
+
}
|
266 |
+
|
267 |
+
public function callbackColumnGiftOptions($value, $row, $column, $isExport)
|
268 |
+
{
|
269 |
+
if ($row->getData('gift_type') == '' && $row->getData('gift_message') == '') {
|
270 |
+
return Mage::helper('M2ePro')->__('N/A');
|
271 |
+
}
|
272 |
+
|
273 |
+
$giftType = Mage::helper('M2ePro')->escapeHtml($row->getData('gift_type'));
|
274 |
+
$giftTypeLabel = Mage::helper('M2ePro')->__('Gift Wrap Type');
|
275 |
+
|
276 |
+
$giftMessage = Mage::helper('M2ePro')->escapeHtml($row->getData('gift_message'));
|
277 |
+
$giftMessageLabel = Mage::helper('M2ePro')->__('Gift Message');
|
278 |
+
|
279 |
+
return <<<HTML
|
280 |
+
<strong>{$giftTypeLabel}: </strong>{$giftType}<br/>
|
281 |
+
<strong>{$giftMessageLabel}: </strong>{$giftMessage}
|
282 |
+
HTML;
|
283 |
+
}
|
284 |
+
|
285 |
+
public function callbackColumnRowTotal($value, $row, $column, $isExport)
|
286 |
+
{
|
287 |
+
$price = (float)$row->getData('price') + (float)$row->getData('gift_price');
|
288 |
+
return Mage::getSingleton('M2ePro/Currency')->formatPrice(
|
289 |
+
$row->getData('currency'), $price * $row->getData('qty_purchased')
|
290 |
+
);
|
291 |
+
}
|
292 |
+
|
293 |
+
public function getRowUrl($row)
|
294 |
+
{
|
295 |
+
return '';
|
296 |
+
}
|
297 |
+
|
298 |
+
public function getGridUrl()
|
299 |
+
{
|
300 |
+
return $this->getUrl('*/*/orderItemGrid', array('_current' => true));
|
301 |
+
}
|
302 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Synchronization/Form.php
ADDED
@@ -0,0 +1,234 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Synchronization_Form extends Mage_Adminhtml_Block_Widget_Form
|
8 |
+
{
|
9 |
+
private $component = Ess_M2ePro_Helper_Component_Amazon::NICK;
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('amazonSynchronizationForm');
|
18 |
+
$this->setContainerId('magento_block_amazon_synchronization');
|
19 |
+
$this->setTemplate('M2ePro/common/amazon/synchronization.phtml');
|
20 |
+
//------------------------------
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _beforeToHtml()
|
24 |
+
{
|
25 |
+
//----------------------------
|
26 |
+
$this->templatesMode = Mage::helper('M2ePro/Module')->getSynchronizationConfig()
|
27 |
+
->getGroupValue('/amazon/templates/', 'mode');
|
28 |
+
$this->ordersMode = Mage::helper('M2ePro/Module')->getSynchronizationConfig()
|
29 |
+
->getGroupValue('/amazon/orders/', 'mode');
|
30 |
+
$this->otherListingsMode = Mage::helper('M2ePro/Module')->getSynchronizationConfig()
|
31 |
+
->getGroupValue('/amazon/other_listings/', 'mode');
|
32 |
+
//----------------------------
|
33 |
+
|
34 |
+
//----------------------------
|
35 |
+
$format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
|
36 |
+
|
37 |
+
$this->reviseAllInProcessingState = !is_null(
|
38 |
+
Mage::helper('M2ePro/Module')->getSynchronizationConfig()->getGroupValue(
|
39 |
+
'/amazon/templates/revise/total/', 'last_listing_product_id'
|
40 |
+
)
|
41 |
+
);
|
42 |
+
|
43 |
+
$this->reviseAllStartDate = Mage::helper('M2ePro/Module')->getSynchronizationConfig()->getGroupValue(
|
44 |
+
'/amazon/templates/revise/total/', 'start_date'
|
45 |
+
);
|
46 |
+
$this->reviseAllStartDate && $this->reviseAllStartDate = Mage::app()->getLocale()
|
47 |
+
->date(strtotime($this->reviseAllStartDate))
|
48 |
+
->toString($format);
|
49 |
+
|
50 |
+
$this->reviseAllEndDate = Mage::helper('M2ePro/Module')->getSynchronizationConfig()->getGroupValue(
|
51 |
+
'/amazon/templates/revise/total/', 'end_date'
|
52 |
+
);
|
53 |
+
$this->reviseAllEndDate && $this->reviseAllEndDate = Mage::app()->getLocale()
|
54 |
+
->date(strtotime($this->reviseAllEndDate))
|
55 |
+
->toString($format);
|
56 |
+
//----------------------------
|
57 |
+
|
58 |
+
//----------------------------
|
59 |
+
$component = Ess_M2ePro_Helper_Component_Amazon::NICK;
|
60 |
+
$data = array(
|
61 |
+
'class' => 'ok_button',
|
62 |
+
'label' => Mage::helper('M2ePro')->__('Confirm'),
|
63 |
+
'onclick' => "Windows.getFocusedWindow().close(); SynchronizationHandlerObj.runReviseAll('{$component}');",
|
64 |
+
);
|
65 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
66 |
+
$this->setChild('revise_all_confirm_popup_ok_button', $buttonBlock);
|
67 |
+
//------------------------------
|
68 |
+
|
69 |
+
//-------------------------------
|
70 |
+
$data = array(
|
71 |
+
'label' => Mage::helper('M2ePro')->__('Run Now'),
|
72 |
+
'onclick' => 'SynchronizationHandlerObj.saveSettings(\'runNowTemplates\', \'' . $this->component . '\');',
|
73 |
+
'class' => 'templates_run_now'
|
74 |
+
);
|
75 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
76 |
+
$this->setChild('amazon_templates_run_now', $buttonBlock);
|
77 |
+
//-------------------------------
|
78 |
+
|
79 |
+
//-------------------------------
|
80 |
+
$areYouSure = Mage::helper('M2ePro')->__('Are you sure?');
|
81 |
+
|
82 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
83 |
+
'*/adminhtml_common_synchronization/index',
|
84 |
+
array(
|
85 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON
|
86 |
+
)
|
87 |
+
);
|
88 |
+
//-------------------------------
|
89 |
+
|
90 |
+
//-------------------------------
|
91 |
+
$url = $this->getUrl(
|
92 |
+
'*/adminhtml_common_synchronization/clearLog',
|
93 |
+
array(
|
94 |
+
'task' => Ess_M2ePro_Model_Synchronization_Log::TASK_TEMPLATES,
|
95 |
+
'component' => $this->component,
|
96 |
+
'back'=> $backUrl
|
97 |
+
)
|
98 |
+
);
|
99 |
+
$data = array(
|
100 |
+
'label' => Mage::helper('M2ePro')->__('Clear Log'),
|
101 |
+
'onclick' => 'deleteConfirm(\'' . $areYouSure . '\', \'' . $url . '\')',
|
102 |
+
'class' => 'templates_clear_log'
|
103 |
+
);
|
104 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
105 |
+
$this->setChild('amazon_templates_clear_log', $buttonBlock);
|
106 |
+
//-------------------------------
|
107 |
+
|
108 |
+
//-------------------------------
|
109 |
+
$url = $this->getUrl(
|
110 |
+
'*/adminhtml_common_log/synchronization',
|
111 |
+
array(
|
112 |
+
'task' => Ess_M2ePro_Model_Synchronization_Log::TASK_TEMPLATES,
|
113 |
+
'channel' => $this->component
|
114 |
+
)
|
115 |
+
);
|
116 |
+
$data = array(
|
117 |
+
'label' => Mage::helper('M2ePro')->__('View Log'),
|
118 |
+
'onclick' => 'window.open(\'' . $url . '\')',
|
119 |
+
'class' => 'button_link'
|
120 |
+
);
|
121 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
122 |
+
$this->setChild('amazon_templates_view_log', $buttonBlock);
|
123 |
+
//-------------------------------
|
124 |
+
|
125 |
+
//-------------------------------
|
126 |
+
$data = array(
|
127 |
+
'label' => Mage::helper('M2ePro')->__('Run Now'),
|
128 |
+
'onclick' => 'SynchronizationHandlerObj.saveSettings(\'runNowOrders\', \'' . $this->component . '\');',
|
129 |
+
'class' => 'orders_run_now'
|
130 |
+
);
|
131 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
132 |
+
$this->setChild('amazon_orders_run_now', $buttonBlock);
|
133 |
+
//-------------------------------
|
134 |
+
|
135 |
+
//-------------------------------
|
136 |
+
$url = $this->getUrl(
|
137 |
+
'*/adminhtml_common_synchronization/clearLog',
|
138 |
+
array(
|
139 |
+
'task' => Ess_M2ePro_Model_Synchronization_Log::TASK_ORDERS,
|
140 |
+
'component' => $this->component,
|
141 |
+
'back' => $backUrl
|
142 |
+
)
|
143 |
+
);
|
144 |
+
$data = array(
|
145 |
+
'label' => Mage::helper('M2ePro')->__('Clear Log'),
|
146 |
+
'onclick' => 'deleteConfirm(\'' . $areYouSure . '\', \'' . $url . '\')',
|
147 |
+
'class' => 'orders_clear_log'
|
148 |
+
);
|
149 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
150 |
+
$this->setChild('amazon_orders_clear_log', $buttonBlock);
|
151 |
+
//-------------------------------
|
152 |
+
|
153 |
+
//-------------------------------
|
154 |
+
$url = $this->getUrl(
|
155 |
+
'*/adminhtml_common_log/synchronization',
|
156 |
+
array(
|
157 |
+
'task' => Ess_M2ePro_Model_Synchronization_Log::TASK_ORDERS,
|
158 |
+
'channel' => $this->component,
|
159 |
+
)
|
160 |
+
);
|
161 |
+
$data = array(
|
162 |
+
'label' => Mage::helper('M2ePro')->__('View Log'),
|
163 |
+
'onclick' => 'window.open(\'' . $url . '\')',
|
164 |
+
'class' => 'button_link'
|
165 |
+
);
|
166 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
167 |
+
$this->setChild('amazon_orders_view_log', $buttonBlock);
|
168 |
+
//-------------------------------
|
169 |
+
|
170 |
+
//-------------------------------
|
171 |
+
$data = array(
|
172 |
+
'label' => Mage::helper('M2ePro')->__('Run Now'),
|
173 |
+
'onclick' => 'SynchronizationHandlerObj.saveSettings(\'runNowOtherListings\', \''.$this->component.'\');',
|
174 |
+
'class' => 'other_listings_run_now'
|
175 |
+
);
|
176 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
177 |
+
$this->setChild('amazon_other_listings_run_now', $buttonBlock);
|
178 |
+
//-------------------------------
|
179 |
+
|
180 |
+
//-------------------------------
|
181 |
+
$url = $this->getUrl(
|
182 |
+
'*/adminhtml_common_synchronization/clearLog',
|
183 |
+
array(
|
184 |
+
'task' => Ess_M2ePro_Model_Synchronization_Log::TASK_OTHER_LISTINGS,
|
185 |
+
'component' => $this->component,
|
186 |
+
'back' => $backUrl
|
187 |
+
)
|
188 |
+
);
|
189 |
+
$data = array(
|
190 |
+
'label' => Mage::helper('M2ePro')->__('Clear Log'),
|
191 |
+
'onclick' => 'deleteConfirm(\'' . $areYouSure . '\', \'' . $url . '\')',
|
192 |
+
'class' => 'orders_clear_log'
|
193 |
+
);
|
194 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
195 |
+
$this->setChild('amazon_other_listings_clear_log', $buttonBlock);
|
196 |
+
//-------------------------------
|
197 |
+
|
198 |
+
//-------------------------------
|
199 |
+
$url = $this->getUrl(
|
200 |
+
'*/adminhtml_common_log/synchronization',
|
201 |
+
array(
|
202 |
+
'task' => Ess_M2ePro_Model_Synchronization_Log::TASK_OTHER_LISTINGS,
|
203 |
+
'channel' => $this->component,
|
204 |
+
)
|
205 |
+
);
|
206 |
+
$data = array(
|
207 |
+
'label' => Mage::helper('M2ePro')->__('View Log'),
|
208 |
+
'onclick' => 'window.open(\'' . $url . '\')',
|
209 |
+
'class' => 'button_link'
|
210 |
+
);
|
211 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
212 |
+
$this->setChild('amazon_other_listings_view_log', $buttonBlock);
|
213 |
+
//-------------------------------
|
214 |
+
|
215 |
+
//-------------------------------
|
216 |
+
$this->inspectorMode = (int)Mage::helper('M2ePro/Module')->getSynchronizationConfig()->getGroupValue(
|
217 |
+
'/defaults/inspector/','mode'
|
218 |
+
);
|
219 |
+
//-------------------------------
|
220 |
+
|
221 |
+
return parent::_beforeToHtml();
|
222 |
+
}
|
223 |
+
|
224 |
+
// ####################################
|
225 |
+
|
226 |
+
public function isShowReviseAll()
|
227 |
+
{
|
228 |
+
return Mage::helper('M2ePro/Module')->getConfig()->getGroupValue(
|
229 |
+
'/view/synchronization/revise_total/','show'
|
230 |
+
);
|
231 |
+
}
|
232 |
+
|
233 |
+
// ####################################
|
234 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Description extends Mage_Adminhtml_Block_Widget_Grid_Container
|
8 |
+
{
|
9 |
+
// ####################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('amazonTemplateDescription');
|
18 |
+
$this->_blockGroup = 'M2ePro';
|
19 |
+
$this->_controller = 'adminhtml_common_amazon_template_description';
|
20 |
+
//------------------------------
|
21 |
+
|
22 |
+
// Set header text
|
23 |
+
//------------------------------
|
24 |
+
$componentName = !Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()
|
25 |
+
? Mage::helper('M2ePro/Component_Amazon')->getTitle().' ' : '';
|
26 |
+
|
27 |
+
$this->_headerText = Mage::helper('M2ePro')->__("%sDescription Policies", $componentName);
|
28 |
+
//------------------------------
|
29 |
+
|
30 |
+
// Set buttons actions
|
31 |
+
//------------------------------
|
32 |
+
$this->removeButton('back');
|
33 |
+
$this->removeButton('reset');
|
34 |
+
$this->removeButton('delete');
|
35 |
+
$this->removeButton('add');
|
36 |
+
$this->removeButton('save');
|
37 |
+
$this->removeButton('edit');
|
38 |
+
//------------------------------
|
39 |
+
|
40 |
+
//------------------------------
|
41 |
+
$url = $this->getUrl(
|
42 |
+
'*/adminhtml_common_listing/index', array('tab' => Ess_M2ePro_Helper_Component_Amazon::NICK)
|
43 |
+
);
|
44 |
+
$this->_addButton('goto_listings', array(
|
45 |
+
'label' => Mage::helper('M2ePro')->__('Listings'),
|
46 |
+
'onclick' => 'setLocation(\'' . $url .'\')',
|
47 |
+
'class' => 'button_link'
|
48 |
+
));
|
49 |
+
//------------------------------
|
50 |
+
|
51 |
+
//------------------------------
|
52 |
+
$url = $this->getUrl('*/adminhtml_common_amazon_template_description/new');
|
53 |
+
$this->_addButton('add', array(
|
54 |
+
'label' => Mage::helper('M2ePro')->__('Add Description Policy'),
|
55 |
+
'onclick' => 'setLocation(\'' . $url .'\')',
|
56 |
+
'class' => 'add'
|
57 |
+
));
|
58 |
+
//------------------------------
|
59 |
+
}
|
60 |
+
|
61 |
+
// ####################################
|
62 |
+
|
63 |
+
public function getGridHtml()
|
64 |
+
{
|
65 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_template_description_help');
|
66 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
67 |
+
}
|
68 |
+
|
69 |
+
// ########################################
|
70 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Category/Chooser/Edit.php
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Description_Category_Chooser_Edit
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Container
|
9 |
+
{
|
10 |
+
// ########################################
|
11 |
+
|
12 |
+
protected $_marketplaceId;
|
13 |
+
protected $_selectedCategory = array();
|
14 |
+
|
15 |
+
// ########################################
|
16 |
+
|
17 |
+
public function __construct()
|
18 |
+
{
|
19 |
+
parent::__construct();
|
20 |
+
|
21 |
+
// Initialization block
|
22 |
+
//------------------------------
|
23 |
+
$this->setId('amazonTemplateDescriptionCategoryChooserEdit');
|
24 |
+
//------------------------------
|
25 |
+
|
26 |
+
// Set buttons actions
|
27 |
+
//------------------------------
|
28 |
+
$this->removeButton('back');
|
29 |
+
$this->removeButton('reset');
|
30 |
+
$this->removeButton('delete');
|
31 |
+
$this->removeButton('add');
|
32 |
+
$this->removeButton('save');
|
33 |
+
$this->removeButton('edit');
|
34 |
+
//------------------------------
|
35 |
+
|
36 |
+
//------------------------------
|
37 |
+
$this->setTemplate('M2ePro/common/amazon/template/description/category/chooser/edit.phtml');
|
38 |
+
//------------------------------
|
39 |
+
}
|
40 |
+
|
41 |
+
// ########################################
|
42 |
+
|
43 |
+
protected function _toHtml()
|
44 |
+
{
|
45 |
+
//------------------------------
|
46 |
+
$data = array(
|
47 |
+
'id' => 'category_edit_confirm_button',
|
48 |
+
'class' => '',
|
49 |
+
'label' => Mage::helper('M2ePro')->__('Confirm'),
|
50 |
+
'onclick' => 'AmazonTemplateDescriptionCategoryChooserHandlerObj.confirmCategory();',
|
51 |
+
);
|
52 |
+
$doneButton = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
53 |
+
//------------------------------
|
54 |
+
|
55 |
+
$cancelWord = Mage::helper('M2ePro')->__('Cancel');
|
56 |
+
|
57 |
+
$buttonsContainer = <<< HTML
|
58 |
+
<div id="chooser_buttons_container">
|
59 |
+
<a href="javascript:void(0)"
|
60 |
+
onclick="AmazonTemplateDescriptionCategoryChooserHandlerObj.cancelPopUp()">{$cancelWord}</a>
|
61 |
+
|
62 |
+
{$doneButton->toHtml()}
|
63 |
+
<script type="text/javascript">amazonTemplateDescriptionCategoryChooserTabsJsTabs.moveTabContentInDest();</script>
|
64 |
+
</div>
|
65 |
+
HTML;
|
66 |
+
|
67 |
+
/** @var Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Description_Category_Chooser_Tabs $tabsBlock */
|
68 |
+
$blockName = 'M2ePro/adminhtml_common_amazon_template_description_category_chooser_tabs';
|
69 |
+
$tabsBlock = $this->getLayout()->createBlock($blockName);
|
70 |
+
|
71 |
+
return parent::_toHtml() .
|
72 |
+
$tabsBlock->toHtml() .
|
73 |
+
'<div id="chooser_tabs_container"></div>' .
|
74 |
+
$buttonsContainer;
|
75 |
+
}
|
76 |
+
|
77 |
+
// ########################################
|
78 |
+
|
79 |
+
public function getSelectedCategory()
|
80 |
+
{
|
81 |
+
return $this->_selectedCategory;
|
82 |
+
}
|
83 |
+
|
84 |
+
public function setSelectedCategory(array $selectedCategory)
|
85 |
+
{
|
86 |
+
$this->_selectedCategory = $selectedCategory;
|
87 |
+
return $this;
|
88 |
+
}
|
89 |
+
|
90 |
+
// ----------------------------------------
|
91 |
+
|
92 |
+
public function setMarketplaceId($value)
|
93 |
+
{
|
94 |
+
$this->_marketplaceId = $value;
|
95 |
+
return $this;
|
96 |
+
}
|
97 |
+
|
98 |
+
// ########################################
|
99 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Category/Chooser/Tabs.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Description_Category_Chooser_Tabs
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Tabs
|
9 |
+
{
|
10 |
+
// ########################################
|
11 |
+
|
12 |
+
const TAB_ID_RECENT = 'recent';
|
13 |
+
const TAB_ID_BROWSE = 'browse';
|
14 |
+
const TAB_ID_SEARCH = 'search';
|
15 |
+
|
16 |
+
// ########################################
|
17 |
+
|
18 |
+
public function __construct()
|
19 |
+
{
|
20 |
+
parent::__construct();
|
21 |
+
|
22 |
+
$this->setTemplate('widget/tabshoriz.phtml');
|
23 |
+
$this->setId('amazonTemplateDescriptionCategoryChooserTabs');
|
24 |
+
$this->setDestElementId('chooser_tabs_container');
|
25 |
+
}
|
26 |
+
|
27 |
+
// ########################################
|
28 |
+
|
29 |
+
protected function _prepareLayout()
|
30 |
+
{
|
31 |
+
$blockName = 'M2ePro/adminhtml_common_amazon_template_description_category_chooser_tabs_recent';
|
32 |
+
!$this->isNeedToHideRecent() && $this->addTab(self::TAB_ID_RECENT, array(
|
33 |
+
'label' => Mage::helper('M2ePro')->__('Recently Used'),
|
34 |
+
'title' => Mage::helper('M2ePro')->__('Recently Used'),
|
35 |
+
'content' => $this->getLayout()
|
36 |
+
->createBlock($blockName)
|
37 |
+
->toHtml(),
|
38 |
+
'active' => true
|
39 |
+
));
|
40 |
+
|
41 |
+
$blockName = 'M2ePro/adminhtml_common_amazon_template_description_category_chooser_tabs_browse';
|
42 |
+
$this->addTab(self::TAB_ID_BROWSE, array(
|
43 |
+
'label' => Mage::helper('M2ePro')->__('Browse'),
|
44 |
+
'title' => Mage::helper('M2ePro')->__('Browse'),
|
45 |
+
'content' => $this->getLayout()
|
46 |
+
->createBlock($blockName)
|
47 |
+
->toHtml(),
|
48 |
+
'active' => $this->isNeedToHideRecent() ? true : false
|
49 |
+
));
|
50 |
+
|
51 |
+
$blockName = 'M2ePro/adminhtml_common_amazon_template_description_category_chooser_tabs_search';
|
52 |
+
$this->addTab(self::TAB_ID_SEARCH, array(
|
53 |
+
'label' => Mage::helper('M2ePro')->__('Search'),
|
54 |
+
'title' => Mage::helper('M2ePro')->__('Search'),
|
55 |
+
'content' => $this->getLayout()
|
56 |
+
->createBlock($blockName)
|
57 |
+
->toHtml()
|
58 |
+
));
|
59 |
+
|
60 |
+
return parent::_prepareLayout();
|
61 |
+
}
|
62 |
+
|
63 |
+
// ########################################
|
64 |
+
|
65 |
+
public function isNeedToHideRecent()
|
66 |
+
{
|
67 |
+
return Mage::helper('M2ePro/Data_Global')->getValue('category_chooser_hide_recent', true);
|
68 |
+
}
|
69 |
+
|
70 |
+
// ########################################
|
71 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Category/Chooser/Tabs/Browse.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Description_Category_Chooser_Tabs_Browse
|
8 |
+
extends Mage_Adminhtml_Block_Widget
|
9 |
+
{
|
10 |
+
// ########################################
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->setId('amazonTemplateDescriptionCategoryChooserBrowse');
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
// Set template
|
22 |
+
//------------------------------
|
23 |
+
$this->setTemplate('M2ePro/common/amazon/template/description/category/chooser/tabs/browse.phtml');
|
24 |
+
// -----------------------------
|
25 |
+
}
|
26 |
+
|
27 |
+
// ########################################
|
28 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Category/Chooser/Tabs/Recent.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Description_Category_Chooser_Tabs_Recent
|
8 |
+
extends Mage_Adminhtml_Block_Widget
|
9 |
+
{
|
10 |
+
protected $_selectedCategory = array();
|
11 |
+
|
12 |
+
// ########################################
|
13 |
+
|
14 |
+
public function __construct()
|
15 |
+
{
|
16 |
+
parent::__construct();
|
17 |
+
|
18 |
+
// Initialization block
|
19 |
+
//------------------------------
|
20 |
+
$this->setId('amazonTemplateDescriptionCategoryChooserRecent');
|
21 |
+
//------------------------------
|
22 |
+
|
23 |
+
// Set template
|
24 |
+
//------------------------------
|
25 |
+
$this->setTemplate('M2ePro/common/amazon/template/description/category/chooser/tabs/recent.phtml');
|
26 |
+
// -----------------------------
|
27 |
+
}
|
28 |
+
|
29 |
+
// ########################################
|
30 |
+
|
31 |
+
public function getCategories()
|
32 |
+
{
|
33 |
+
return Mage::helper('M2ePro/Component_Amazon_Category')->getRecent(
|
34 |
+
$this->getRequest()->getPost('marketplace_id'),
|
35 |
+
array('product_data_nick' => $this->getRequest()->getPost('product_data_nick'),
|
36 |
+
'browsenode_id' => $this->getRequest()->getPost('browsenode_id'),
|
37 |
+
'path' => $this->getRequest()->getPost('category_path'))
|
38 |
+
);
|
39 |
+
}
|
40 |
+
|
41 |
+
// ########################################
|
42 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Category/Chooser/Tabs/Search.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Description_Category_Chooser_Tabs_Search
|
8 |
+
extends Mage_Adminhtml_Block_Widget
|
9 |
+
{
|
10 |
+
// ########################################
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->setId('amazonTemplateDescriptionCategoryChooserSearch');
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
// Set template
|
22 |
+
//------------------------------
|
23 |
+
$this->setTemplate('M2ePro/common/amazon/template/description/category/chooser/tabs/search.phtml');
|
24 |
+
// -----------------------------
|
25 |
+
}
|
26 |
+
|
27 |
+
// ########################################
|
28 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Category/Specific/Add.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Description_Category_Specific_Add
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Container
|
9 |
+
{
|
10 |
+
// ########################################
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->setId('amazonTemplateDescriptionCategorySpecificAdd');
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
// Set buttons actions
|
22 |
+
//------------------------------
|
23 |
+
$this->removeButton('back');
|
24 |
+
$this->removeButton('reset');
|
25 |
+
$this->removeButton('delete');
|
26 |
+
$this->removeButton('add');
|
27 |
+
$this->removeButton('save');
|
28 |
+
$this->removeButton('edit');
|
29 |
+
//------------------------------
|
30 |
+
|
31 |
+
//------------------------------
|
32 |
+
$this->setTemplate('M2ePro/common/amazon/template/description/category/specific/add.phtml');
|
33 |
+
//------------------------------
|
34 |
+
}
|
35 |
+
|
36 |
+
// ########################################
|
37 |
+
|
38 |
+
protected function _beforeToHtml()
|
39 |
+
{
|
40 |
+
$additionalTitle = $this->getRequest()->getParam('current_indexed_xpath');
|
41 |
+
$additionalTitle = explode('/', ltrim($additionalTitle, '/'));
|
42 |
+
array_shift($additionalTitle);
|
43 |
+
$additionalTitle = array_map(function($el) { return preg_replace('/-\d+/', '', $el); }, $additionalTitle);
|
44 |
+
$this->setData('additional_title', implode(' > ', $additionalTitle));
|
45 |
+
|
46 |
+
return parent::_beforeToHtml();
|
47 |
+
}
|
48 |
+
|
49 |
+
protected function _toHtml()
|
50 |
+
{
|
51 |
+
//------------------------------
|
52 |
+
$data = array(
|
53 |
+
'class' => 'specifics_done_button',
|
54 |
+
'label' => Mage::helper('M2ePro')->__('Confirm')
|
55 |
+
);
|
56 |
+
$doneButton = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
57 |
+
//------------------------------
|
58 |
+
|
59 |
+
$cancelWord = Mage::helper('M2ePro')->__('Cancel');
|
60 |
+
$buttonsContainer = <<< HTML
|
61 |
+
<div style="margin-top: 17px; text-align: right; position: absolute; left: 86%; top: 90%;">
|
62 |
+
<a href="javascript:void(0)" class="specifics_cancel_button">{$cancelWord}</a>
|
63 |
+
|
64 |
+
{$doneButton->toHtml()}
|
65 |
+
</div>
|
66 |
+
HTML;
|
67 |
+
return parent::_toHtml() . $buttonsContainer;
|
68 |
+
}
|
69 |
+
|
70 |
+
// ########################################
|
71 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Category/Specific/Add/Grid.php
ADDED
@@ -0,0 +1,248 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Description_Category_Specific_Add_Grid
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
9 |
+
{
|
10 |
+
public $marketplaceId;
|
11 |
+
public $productDataNick;
|
12 |
+
|
13 |
+
public $currentXpath;
|
14 |
+
|
15 |
+
public $searchQuery;
|
16 |
+
public $onlyDesired = false;
|
17 |
+
|
18 |
+
public $selectedSpecifics = array();
|
19 |
+
public $renderedSpecifics = array();
|
20 |
+
|
21 |
+
// ####################################
|
22 |
+
|
23 |
+
public function __construct()
|
24 |
+
{
|
25 |
+
parent::__construct();
|
26 |
+
|
27 |
+
// Initialization block
|
28 |
+
//------------------------------
|
29 |
+
$this->setId('amazonTemplateDescriptionCategorySpecificAddGrid');
|
30 |
+
//------------------------------
|
31 |
+
|
32 |
+
// Set default values
|
33 |
+
//------------------------------
|
34 |
+
$this->setFilterVisibility(false);
|
35 |
+
$this->setPagerVisibility(false);
|
36 |
+
$this->setDefaultSort('id');
|
37 |
+
$this->setDefaultDir('ASC');
|
38 |
+
$this->setSaveParametersInSession(true);
|
39 |
+
$this->setUseAjax(true);
|
40 |
+
//------------------------------
|
41 |
+
}
|
42 |
+
|
43 |
+
// ####################################
|
44 |
+
|
45 |
+
protected function _prepareCollection()
|
46 |
+
{
|
47 |
+
/** @var $connRead Varien_Db_Adapter_Pdo_Mysql */
|
48 |
+
$connRead = Mage::getSingleton('core/resource')->getConnection('core_read');
|
49 |
+
|
50 |
+
$select = $connRead->select()
|
51 |
+
->from(Mage::getSingleton('core/resource')->getTableName('m2epro_amazon_dictionary_specific'))
|
52 |
+
->where('marketplace_id = ?', (int)$this->marketplaceId)
|
53 |
+
->where('product_data_nick = ?', $this->productDataNick)
|
54 |
+
->where('type != ?', Ess_M2ePro_Model_Amazon_Template_Description_Specific::DICTIONARY_TYPE_CONTAINER)
|
55 |
+
->where('xpath LIKE ?', "{$this->currentXpath}/%")
|
56 |
+
->order('title ASC');
|
57 |
+
|
58 |
+
if ($this->searchQuery) {
|
59 |
+
$select->where('title LIKE ?', "%{$this->searchQuery}%");
|
60 |
+
}
|
61 |
+
|
62 |
+
$filteredResult = array();
|
63 |
+
|
64 |
+
$queryStmt = $select->query();
|
65 |
+
while ($row = $queryStmt->fetch()) {
|
66 |
+
|
67 |
+
if (in_array($row['xpath'], $this->renderedSpecifics) ||
|
68 |
+
in_array($row['xpath'], $this->selectedSpecifics)) {
|
69 |
+
continue;
|
70 |
+
}
|
71 |
+
|
72 |
+
$row['data_definition'] = (array)json_decode($row['data_definition'], true);
|
73 |
+
$row['is_desired'] = !empty($row['data_definition']['is_desired']) && $row['data_definition']['is_desired'];
|
74 |
+
|
75 |
+
if ($this->onlyDesired && !$row['is_desired']) {
|
76 |
+
continue;
|
77 |
+
}
|
78 |
+
|
79 |
+
$filteredResult[] = $row;
|
80 |
+
}
|
81 |
+
|
82 |
+
usort($filteredResult, function($a, $b) {
|
83 |
+
|
84 |
+
if ($a['is_desired'] && !$b['is_desired']) {
|
85 |
+
return -1;
|
86 |
+
}
|
87 |
+
|
88 |
+
if ($b['is_desired'] && !$a['is_desired']) {
|
89 |
+
return 1;
|
90 |
+
}
|
91 |
+
|
92 |
+
return $a['title'] == $b['title'] ? 0 : ($a['title'] > $b['title'] ? 1 : -1);
|
93 |
+
});
|
94 |
+
|
95 |
+
$collection = new Varien_Data_Collection();
|
96 |
+
foreach ($filteredResult as $item) {
|
97 |
+
$collection->addItem(new Varien_Object($item));
|
98 |
+
}
|
99 |
+
$this->setCollection($collection);
|
100 |
+
|
101 |
+
return parent::_prepareCollection();
|
102 |
+
}
|
103 |
+
|
104 |
+
protected function _prepareColumns()
|
105 |
+
{
|
106 |
+
$this->addColumn('title', array(
|
107 |
+
'header' => Mage::helper('M2ePro')->__('Specific'),
|
108 |
+
'align' => 'left',
|
109 |
+
'type' => 'text',
|
110 |
+
'index' => 'title',
|
111 |
+
'width' => '700px',
|
112 |
+
'filter' => false,
|
113 |
+
'sortable' => false,
|
114 |
+
'frame_callback' => array($this, 'callbackColumnTitle')
|
115 |
+
));
|
116 |
+
|
117 |
+
$this->addColumn('is_desired', array(
|
118 |
+
'header' => Mage::helper('M2ePro')->__('Desired'),
|
119 |
+
'align' => 'center',
|
120 |
+
'type' => 'text',
|
121 |
+
'index' => 'is_desired',
|
122 |
+
'width' => '80px',
|
123 |
+
'filter' => false,
|
124 |
+
'sortable' => false,
|
125 |
+
'frame_callback' => array($this, 'callbackColumnIsDesired')
|
126 |
+
));
|
127 |
+
|
128 |
+
$this->addColumn('actions', array(
|
129 |
+
'header' => Mage::helper('M2ePro')->__('Action'),
|
130 |
+
'align' => 'center',
|
131 |
+
'type' => 'text',
|
132 |
+
'width' => '80px',
|
133 |
+
'filter' => false,
|
134 |
+
'sortable' => false,
|
135 |
+
'frame_callback' => array($this, 'callbackColumnActions'),
|
136 |
+
));
|
137 |
+
}
|
138 |
+
|
139 |
+
// ####################################
|
140 |
+
|
141 |
+
public function callbackColumnTitle($title, $row, $column, $isExport)
|
142 |
+
{
|
143 |
+
strlen($title) > 60 && $title = substr($title, 0, 60) . '...';
|
144 |
+
$title = Mage::helper('M2ePro')->escapeHtml($title);
|
145 |
+
|
146 |
+
$path = explode('/', ltrim($row->getData('xpath'), '/'));
|
147 |
+
array_pop($path);
|
148 |
+
$path = implode(' > ', $path);
|
149 |
+
$path = Mage::helper('M2ePro')->escapeHtml($path);
|
150 |
+
|
151 |
+
$fullPath = $path;
|
152 |
+
strlen($path) > 135 && $path = substr($path, 0, 135) . '...';
|
153 |
+
|
154 |
+
$foundInWord = Mage::helper('M2ePro')->__('Found In: ');
|
155 |
+
|
156 |
+
return <<<HTML
|
157 |
+
<div style="margin-left: 3px">
|
158 |
+
<a href="javascript:void(0);" class="specific_search_result_row" xpath ="{$row->getData('xpath')}"
|
159 |
+
xml_tag = {$row->getData('xml_tag')}>
|
160 |
+
{$title}
|
161 |
+
</a><br/>
|
162 |
+
<span style="font-weight: bold;">{$foundInWord}</span>
|
163 |
+
<span title="{$fullPath}">{$path}</span><br/>
|
164 |
+
</div>
|
165 |
+
HTML;
|
166 |
+
}
|
167 |
+
|
168 |
+
public function callbackColumnIsDesired($value, $row, $column, $isExport)
|
169 |
+
{
|
170 |
+
return $value ? Mage::helper('M2ePro')->__('Yes') : Mage::helper('M2ePro')->__('No');
|
171 |
+
}
|
172 |
+
|
173 |
+
public function callbackColumnActions($value, $row, $column, $isExport)
|
174 |
+
{
|
175 |
+
$select = Mage::helper('M2ePro')->__('Select');
|
176 |
+
return <<<HTML
|
177 |
+
<a href="javascript:void(0);" class="specific_search_result_row" xpath = {$row->getData('xpath')}
|
178 |
+
xml_tag = {$row->getData('xml_tag')}>
|
179 |
+
{$select}
|
180 |
+
</a>
|
181 |
+
HTML;
|
182 |
+
}
|
183 |
+
|
184 |
+
// ####################################
|
185 |
+
|
186 |
+
public function setMarketplaceId($marketplaceId)
|
187 |
+
{
|
188 |
+
$this->marketplaceId = $marketplaceId;
|
189 |
+
return $this;
|
190 |
+
}
|
191 |
+
|
192 |
+
public function setProductDataNick($productDataNick)
|
193 |
+
{
|
194 |
+
$this->productDataNick = $productDataNick;
|
195 |
+
return $this;
|
196 |
+
}
|
197 |
+
|
198 |
+
public function setCurrentXpath($indexedXpath)
|
199 |
+
{
|
200 |
+
$this->currentXpath = preg_replace('/-\d+/', '', $indexedXpath);
|
201 |
+
return $this;
|
202 |
+
}
|
203 |
+
|
204 |
+
public function setRenderedSpecifics(array $specifics)
|
205 |
+
{
|
206 |
+
$this->renderedSpecifics = $this->replaceWithDictionaryXpathes($specifics);
|
207 |
+
return $this;
|
208 |
+
}
|
209 |
+
|
210 |
+
public function setSelectedSpecifics(array $specifics)
|
211 |
+
{
|
212 |
+
$this->selectedSpecifics = $this->replaceWithDictionaryXpathes($specifics);
|
213 |
+
return $this;
|
214 |
+
}
|
215 |
+
|
216 |
+
public function setOnlyDesired($value)
|
217 |
+
{
|
218 |
+
$this->onlyDesired = $value;
|
219 |
+
return $this;
|
220 |
+
}
|
221 |
+
|
222 |
+
public function setSearchQuery($searchQuery)
|
223 |
+
{
|
224 |
+
$this-> searchQuery = $searchQuery;
|
225 |
+
return $this;
|
226 |
+
}
|
227 |
+
|
228 |
+
// ------------------------------------
|
229 |
+
|
230 |
+
private function replaceWithDictionaryXpathes(array $xPathes)
|
231 |
+
{
|
232 |
+
return array_map(function($el) { return preg_replace('/-\d+/', '', $el); }, $xPathes);
|
233 |
+
}
|
234 |
+
|
235 |
+
// ####################################
|
236 |
+
|
237 |
+
public function getGridUrl()
|
238 |
+
{
|
239 |
+
return false;
|
240 |
+
}
|
241 |
+
|
242 |
+
public function getRowUrl($row)
|
243 |
+
{
|
244 |
+
return false;
|
245 |
+
}
|
246 |
+
|
247 |
+
// ####################################
|
248 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Edit.php
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Description_Edit
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Form_Container
|
9 |
+
{
|
10 |
+
// ####################################
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->setId('amazonTemplateDescriptionEdit');
|
19 |
+
$this->_blockGroup = 'M2ePro';
|
20 |
+
$this->_controller = 'adminhtml_common_amazon_template_description';
|
21 |
+
$this->_mode = 'edit';
|
22 |
+
//------------------------------
|
23 |
+
|
24 |
+
// Set header text
|
25 |
+
//------------------------------
|
26 |
+
$componentName = !Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()
|
27 |
+
? ' ' . Mage::helper('M2ePro/Component_Amazon')->getTitle() : '';
|
28 |
+
|
29 |
+
if ($this->isEditMode()) {
|
30 |
+
$this->_headerText = Mage::helper('M2ePro')->__("Edit%s Description Policy", $componentName);
|
31 |
+
$this->_headerText .= ' "'.$this->escapeHtml(
|
32 |
+
Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getTitle()).'"';
|
33 |
+
} else {
|
34 |
+
$this->_headerText = Mage::helper('M2ePro')->__("Add%s Description Policy", $componentName);
|
35 |
+
}
|
36 |
+
//------------------------------
|
37 |
+
|
38 |
+
// Set buttons actions
|
39 |
+
//------------------------------
|
40 |
+
$this->removeButton('back');
|
41 |
+
$this->removeButton('reset');
|
42 |
+
$this->removeButton('delete');
|
43 |
+
$this->removeButton('add');
|
44 |
+
$this->removeButton('save');
|
45 |
+
$this->removeButton('edit');
|
46 |
+
//------------------------------
|
47 |
+
|
48 |
+
//------------------------------
|
49 |
+
$url = Mage::helper('M2ePro')->getBackUrl('list');
|
50 |
+
$this->_addButton('back', array(
|
51 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
52 |
+
'onclick' => 'CommonHandlerObj.back_click(\'' . $url . '\')',
|
53 |
+
'class' => 'back'
|
54 |
+
));
|
55 |
+
//------------------------------
|
56 |
+
|
57 |
+
if ($this->isEditMode()) {
|
58 |
+
|
59 |
+
$headId = 'common-amazon-template-description';
|
60 |
+
//------------------------------
|
61 |
+
$this->_addButton('duplicate', array(
|
62 |
+
'label' => Mage::helper('M2ePro')->__('Duplicate'),
|
63 |
+
'onclick' => "AmazonTemplateDescriptionHandlerObj.duplicate_click('{$headId}')",
|
64 |
+
'class' => 'add M2ePro_duplicate_button'
|
65 |
+
));
|
66 |
+
//------------------------------
|
67 |
+
|
68 |
+
//------------------------------
|
69 |
+
$this->_addButton('delete', array(
|
70 |
+
'label' => Mage::helper('M2ePro')->__('Delete'),
|
71 |
+
'onclick' => 'CommonHandlerObj.delete_click()',
|
72 |
+
'class' => 'delete M2ePro_delete_button'
|
73 |
+
));
|
74 |
+
//------------------------------
|
75 |
+
}
|
76 |
+
|
77 |
+
//------------------------------
|
78 |
+
$this->_addButton('save', array(
|
79 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
80 |
+
'onclick' => 'AmazonTemplateDescriptionHandlerObj.save_click()',
|
81 |
+
'class' => 'save'
|
82 |
+
));
|
83 |
+
//------------------------------
|
84 |
+
|
85 |
+
//------------------------------
|
86 |
+
$this->_addButton('save_and_continue', array(
|
87 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
88 |
+
'onclick' => 'AmazonTemplateDescriptionHandlerObj.save_and_edit_click()',
|
89 |
+
'class' => 'save'
|
90 |
+
));
|
91 |
+
//------------------------------
|
92 |
+
}
|
93 |
+
|
94 |
+
// ####################################
|
95 |
+
|
96 |
+
private function isEditMode()
|
97 |
+
{
|
98 |
+
$templateModel = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
99 |
+
return $templateModel && $templateModel->getId();
|
100 |
+
}
|
101 |
+
|
102 |
+
// ####################################
|
103 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Edit/Form.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Description_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
8 |
+
{
|
9 |
+
// ####################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('amazonTemplateDescriptionEditForm');
|
18 |
+
//------------------------------
|
19 |
+
}
|
20 |
+
|
21 |
+
// ####################################
|
22 |
+
|
23 |
+
protected function _prepareForm()
|
24 |
+
{
|
25 |
+
$form = new Varien_Data_Form(array(
|
26 |
+
'id' => 'edit_form',
|
27 |
+
'method' => 'post',
|
28 |
+
'action' => $this->getUrl('*/*/save'),
|
29 |
+
'enctype' => 'multipart/form-data'
|
30 |
+
));
|
31 |
+
|
32 |
+
$form->setUseContainer(true);
|
33 |
+
$this->setForm($form);
|
34 |
+
|
35 |
+
return parent::_prepareForm();
|
36 |
+
}
|
37 |
+
|
38 |
+
// ####################################
|
39 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Edit/Tabs.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Description_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
8 |
+
{
|
9 |
+
// ####################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('amazonTemplateDescriptionEditTabs');
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$this->setTitle(Mage::helper('M2ePro')->__('Configuration'));
|
21 |
+
$this->setDestElementId('edit_form');
|
22 |
+
}
|
23 |
+
|
24 |
+
// ####################################
|
25 |
+
|
26 |
+
protected function _beforeToHtml()
|
27 |
+
{
|
28 |
+
$this->addTab('general', array(
|
29 |
+
'label' => Mage::helper('M2ePro')->__('General'),
|
30 |
+
'title' => Mage::helper('M2ePro')->__('General'),
|
31 |
+
'content' => $this->getLayout()->createBlock(
|
32 |
+
'M2ePro/adminhtml_common_amazon_template_description_edit_tabs_general'
|
33 |
+
)->toHtml(),
|
34 |
+
));
|
35 |
+
|
36 |
+
$this->addTab('definition', array(
|
37 |
+
'label' => Mage::helper('M2ePro')->__('Definition'),
|
38 |
+
'title' => Mage::helper('M2ePro')->__('Definition'),
|
39 |
+
'content' => $this->getLayout()->createBlock(
|
40 |
+
'M2ePro/adminhtml_common_amazon_template_description_edit_tabs_definition'
|
41 |
+
)->toHtml(),
|
42 |
+
));
|
43 |
+
|
44 |
+
$this->addTab('specifics', array(
|
45 |
+
'label' => Mage::helper('M2ePro')->__('Specifics'),
|
46 |
+
'title' => Mage::helper('M2ePro')->__('Specifics'),
|
47 |
+
'content' => $this->getLayout()->createBlock(
|
48 |
+
'M2ePro/adminhtml_common_amazon_template_description_edit_tabs_specifics'
|
49 |
+
)->toHtml(),
|
50 |
+
));
|
51 |
+
|
52 |
+
$this->setActiveTab($this->getRequest()->getParam('tab', 'general'));
|
53 |
+
|
54 |
+
return parent::_beforeToHtml();
|
55 |
+
}
|
56 |
+
|
57 |
+
// ####################################
|
58 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Edit/Tabs/Definition.php
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Description_Edit_Tabs_Definition
|
8 |
+
extends Mage_Adminhtml_Block_Widget
|
9 |
+
{
|
10 |
+
// ####################################
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->setId('amazonTemplateDescriptionEditTabsDefinition');
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
$this->setTemplate('M2ePro/common/amazon/template/description/tabs/definition.phtml');
|
22 |
+
}
|
23 |
+
|
24 |
+
// ####################################
|
25 |
+
|
26 |
+
protected function _beforeToHtml()
|
27 |
+
{
|
28 |
+
//------------------------------
|
29 |
+
$data = array(
|
30 |
+
'label' => Mage::helper('M2ePro')->__('Insert'),
|
31 |
+
'onclick' => "AttributeHandlerObj.appendToText('select_attributes_for_title', 'title_template');",
|
32 |
+
'class' => 'select_attributes_for_title_button'
|
33 |
+
);
|
34 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
35 |
+
$this->setChild('select_attributes_for_title_button', $buttonBlock);
|
36 |
+
//------------------------------
|
37 |
+
|
38 |
+
//------------------------------
|
39 |
+
$data = array(
|
40 |
+
'label' => Mage::helper('M2ePro')->__('Insert'),
|
41 |
+
'onclick' => "AttributeHandlerObj.appendToTextarea('#' + $('select_attributes').value + '#');",
|
42 |
+
'class' => 'add_product_attribute_button',
|
43 |
+
);
|
44 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
45 |
+
$this->setChild('add_product_attribute_button', $buttonBlock);
|
46 |
+
//------------------------------
|
47 |
+
|
48 |
+
//------------------------------
|
49 |
+
for ($i = 0; $i < 4; $i++) {
|
50 |
+
$button = $this->getMultiElementButton('target_audience', $i);
|
51 |
+
$this->setChild("select_attributes_for_target_audience_{$i}_button", $button);
|
52 |
+
}
|
53 |
+
//------------------------------
|
54 |
+
|
55 |
+
//------------------------------
|
56 |
+
for ($i = 0; $i < 5; $i++) {
|
57 |
+
$button = $this->getMultiElementButton('bullet_points', $i);
|
58 |
+
$this->setChild("select_attributes_for_bullet_points_{$i}_button", $button);
|
59 |
+
}
|
60 |
+
//------------------------------
|
61 |
+
|
62 |
+
//------------------------------
|
63 |
+
for ($i = 0; $i < 5; $i++) {
|
64 |
+
$button = $this->getMultiElementButton('search_terms', $i);
|
65 |
+
$this->setChild("select_attributes_for_search_terms_{$i}_button", $button);
|
66 |
+
}
|
67 |
+
//------------------------------
|
68 |
+
|
69 |
+
//--
|
70 |
+
$attributeHelper = Mage::helper('M2ePro/Magento_Attribute');
|
71 |
+
$this->setData('all_attributes', $attributeHelper->getAll());
|
72 |
+
$this->setData('general_attributes', $attributeHelper->getGeneralFromAllAttributeSets());
|
73 |
+
//--
|
74 |
+
|
75 |
+
return parent::_beforeToHtml();
|
76 |
+
}
|
77 |
+
|
78 |
+
// ####################################
|
79 |
+
|
80 |
+
private function getMultiElementButton($type, $index)
|
81 |
+
{
|
82 |
+
$onClick = <<<JS
|
83 |
+
AttributeHandlerObj.appendToText('select_attributes_for_{$type}_{$index}', '{$type}_{$index}');
|
84 |
+
AmazonTemplateDescriptionDefinitionHandlerObj.multi_element_keyup('{$type}',{value:' '});
|
85 |
+
JS;
|
86 |
+
$data = array(
|
87 |
+
'label' => Mage::helper('M2ePro')->__('Insert'),
|
88 |
+
'onclick' => $onClick,
|
89 |
+
'class' => "select_attributes_for_{$type}_{$index}_button"
|
90 |
+
);
|
91 |
+
return $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
92 |
+
}
|
93 |
+
|
94 |
+
// ####################################
|
95 |
+
|
96 |
+
public function getForceAddedAttributeOptionHtml($attributeCode, $availableValues, $value = null)
|
97 |
+
{
|
98 |
+
if (empty($attributeCode) ||
|
99 |
+
Mage::helper('M2ePro/Magento_Attribute')->isExistInAttributesArray($attributeCode, $availableValues)) {
|
100 |
+
return '';
|
101 |
+
}
|
102 |
+
|
103 |
+
$attributeLabel = Mage::helper('M2ePro/Magento_Attribute')->getAttributeLabel($attributeCode);
|
104 |
+
$html = "<option %s selected=\"selected\">{$attributeLabel}</option>";
|
105 |
+
|
106 |
+
return is_null($value) ? sprintf($html, "value='{$attributeCode}'")
|
107 |
+
: sprintf($html, "attribute_code='{$attributeCode}' value='{$value}'");
|
108 |
+
}
|
109 |
+
|
110 |
+
// ------------------------------------
|
111 |
+
|
112 |
+
public function getWeightUnits()
|
113 |
+
{
|
114 |
+
return array(
|
115 |
+
'GR',
|
116 |
+
'KG',
|
117 |
+
'OZ',
|
118 |
+
'LB',
|
119 |
+
'MG'
|
120 |
+
);
|
121 |
+
}
|
122 |
+
|
123 |
+
public function getDimensionsUnits()
|
124 |
+
{
|
125 |
+
return array(
|
126 |
+
'MM',
|
127 |
+
'CM',
|
128 |
+
'M',
|
129 |
+
'IN',
|
130 |
+
'FT'
|
131 |
+
);
|
132 |
+
}
|
133 |
+
|
134 |
+
// ####################################
|
135 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Edit/Tabs/General.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Description_Edit_Tabs_General
|
8 |
+
extends Mage_Adminhtml_Block_Widget
|
9 |
+
{
|
10 |
+
// ####################################
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->setId('amazonTemplateDescriptionEditTabsGeneral');
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
$this->setTemplate('M2ePro/common/amazon/template/description/tabs/general.phtml');
|
22 |
+
}
|
23 |
+
|
24 |
+
// ####################################
|
25 |
+
|
26 |
+
protected function _beforeToHtml()
|
27 |
+
{
|
28 |
+
$templateModel = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
29 |
+
|
30 |
+
//--
|
31 |
+
$marketplaces = Mage::helper('M2ePro/Component_Amazon')->getMarketplacesAvailableForAsinCreation();
|
32 |
+
$marketplaces = $marketplaces->toArray();
|
33 |
+
$this->setData('marketplaces', $marketplaces['items']);
|
34 |
+
//--
|
35 |
+
|
36 |
+
//--
|
37 |
+
$marketplaceLocked = $categoryLocked = $newAsinSwitcherLocked = false;
|
38 |
+
|
39 |
+
if ($templateModel && $templateModel->getId()) {
|
40 |
+
$marketplaceLocked = $templateModel->isLocked();
|
41 |
+
$categoryLocked = $templateModel->getChildObject()->isLockedForCategoryChange();
|
42 |
+
$newAsinSwitcherLocked = $templateModel->getChildObject()->isLockedForNewAsinCreation();
|
43 |
+
}
|
44 |
+
|
45 |
+
$this->setData('marketplace_locked', $marketplaceLocked);
|
46 |
+
$this->setData('category_locked', $categoryLocked);
|
47 |
+
$this->setData('new_asin_switcher_locked', $newAsinSwitcherLocked);
|
48 |
+
//--
|
49 |
+
|
50 |
+
//--
|
51 |
+
$attributeHelper = Mage::helper('M2ePro/Magento_Attribute');
|
52 |
+
$this->setData('all_attributes', $attributeHelper->getAll());
|
53 |
+
$this->setData('general_attributes', $attributeHelper->getGeneralFromAllAttributeSets());
|
54 |
+
//--
|
55 |
+
|
56 |
+
return parent::_beforeToHtml();
|
57 |
+
}
|
58 |
+
|
59 |
+
// ####################################
|
60 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Edit/Tabs/Specifics.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Description_Edit_Tabs_Specifics
|
8 |
+
extends Mage_Adminhtml_Block_Widget
|
9 |
+
{
|
10 |
+
// ####################################
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->setId('amazonTemplateDescriptionEditTabsSpecifics');
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
$this->setTemplate('M2ePro/common/amazon/template/description/tabs/specifics.phtml');
|
22 |
+
}
|
23 |
+
|
24 |
+
// ####################################
|
25 |
+
|
26 |
+
protected function _beforeToHtml()
|
27 |
+
{
|
28 |
+
//--
|
29 |
+
$this->setData('attributes', Mage::helper('M2ePro/Magento_Attribute')->getAll());
|
30 |
+
//--
|
31 |
+
|
32 |
+
return parent::_beforeToHtml();
|
33 |
+
}
|
34 |
+
|
35 |
+
// ####################################
|
36 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Grid.php
ADDED
@@ -0,0 +1,223 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Description_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
// ####################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('templateDescriptionGrid');
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
// Set default values
|
21 |
+
//------------------------------
|
22 |
+
$this->setDefaultSort('id');
|
23 |
+
$this->setDefaultDir('ASC');
|
24 |
+
$this->setSaveParametersInSession(true);
|
25 |
+
$this->setUseAjax(true);
|
26 |
+
//------------------------------
|
27 |
+
}
|
28 |
+
|
29 |
+
// ####################################
|
30 |
+
|
31 |
+
protected function _prepareCollection()
|
32 |
+
{
|
33 |
+
$collection = Mage::getModel('M2ePro/Template_Description')->getCollection();
|
34 |
+
$collection->addFieldToFilter('main_table.component_mode', Ess_M2ePro_Helper_Component_Amazon::NICK);
|
35 |
+
|
36 |
+
$collection->getSelect()->join(
|
37 |
+
array('atd' => Mage::getModel('M2ePro/Amazon_Template_Description')->getResource()->getMainTable()),
|
38 |
+
'atd.template_description_id=main_table.id',
|
39 |
+
array('marketplace_id','category_path','browsenode_id','is_new_asin_accepted')
|
40 |
+
);
|
41 |
+
|
42 |
+
$collection->getSelect()->join(
|
43 |
+
array('mm' => Mage::getModel('M2ePro/Marketplace')->getResource()->getMainTable()),
|
44 |
+
'mm.id=atd.marketplace_id',
|
45 |
+
array('status')
|
46 |
+
);
|
47 |
+
|
48 |
+
$collection->addFieldToFilter('mm.status', Ess_M2ePro_Model_Marketplace::STATUS_ENABLE);
|
49 |
+
|
50 |
+
$this->setCollection($collection);
|
51 |
+
return parent::_prepareCollection();
|
52 |
+
}
|
53 |
+
|
54 |
+
protected function _prepareColumns()
|
55 |
+
{
|
56 |
+
$this->addColumn('id', array(
|
57 |
+
'header' => Mage::helper('M2ePro')->__('ID'),
|
58 |
+
'align' => 'right',
|
59 |
+
'type' => 'number',
|
60 |
+
'width' => '50px',
|
61 |
+
'index' => 'id',
|
62 |
+
'filter_index' => 'main_table.id',
|
63 |
+
'frame_callback' => array($this, 'callbackColumnId')
|
64 |
+
));
|
65 |
+
|
66 |
+
$this->addColumn('title', array(
|
67 |
+
'header' => Mage::helper('M2ePro')->__('Title / Category'),
|
68 |
+
'align' => 'left',
|
69 |
+
'type' => 'text',
|
70 |
+
'width' => '500px',
|
71 |
+
'index' => 'title',
|
72 |
+
'filter_index' => 'main_table.title',
|
73 |
+
'frame_callback' => array($this, 'callbackColumnTitle'),
|
74 |
+
'filter_condition_callback' => array($this, 'callbackFilterTitle')
|
75 |
+
));
|
76 |
+
|
77 |
+
$this->addColumn('new_asin', array(
|
78 |
+
'header' => Mage::helper('M2ePro')->__('New ASIN / ISBN'),
|
79 |
+
'align' => 'left',
|
80 |
+
'type' => 'options',
|
81 |
+
'options' => array(
|
82 |
+
'1' => Mage::helper('M2ePro')->__('Yes'),
|
83 |
+
'0' => Mage::helper('M2ePro')->__('No')
|
84 |
+
),
|
85 |
+
'width' => '50px',
|
86 |
+
'index' => 'is_new_asin_accepted',
|
87 |
+
'filter_index' => 'atd.is_new_asin_accepted'
|
88 |
+
));
|
89 |
+
|
90 |
+
$this->addColumn('marketplace', array(
|
91 |
+
'header' => Mage::helper('M2ePro')->__('Marketplace'),
|
92 |
+
'align' => 'left',
|
93 |
+
'type' => 'options',
|
94 |
+
'options' => Mage::helper('M2ePro/Component_Amazon')->getMarketplacesAvailableForAsinCreation()
|
95 |
+
->toOptionHash(),
|
96 |
+
'width' => '100px',
|
97 |
+
'index' => 'marketplace_id',
|
98 |
+
'filter_index' => 'atd.marketplace_id'
|
99 |
+
));
|
100 |
+
|
101 |
+
$this->addColumn('update_date', array(
|
102 |
+
'header' => Mage::helper('M2ePro')->__('Update Date'),
|
103 |
+
'align' => 'left',
|
104 |
+
'width' => '80px',
|
105 |
+
'type' => 'datetime',
|
106 |
+
'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM),
|
107 |
+
'index' => 'update_date',
|
108 |
+
'filter_index' => 'main_table.update_date'
|
109 |
+
));
|
110 |
+
|
111 |
+
$this->addColumn('create_date', array(
|
112 |
+
'header' => Mage::helper('M2ePro')->__('Creation Date'),
|
113 |
+
'align' => 'left',
|
114 |
+
'width' => '80px',
|
115 |
+
'type' => 'datetime',
|
116 |
+
'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM),
|
117 |
+
'index' => 'create_date',
|
118 |
+
'filter_index' => 'main_table.create_date'
|
119 |
+
));
|
120 |
+
|
121 |
+
$this->addColumn('actions', array(
|
122 |
+
'header' => Mage::helper('M2ePro')->__('Actions'),
|
123 |
+
'align' => 'left',
|
124 |
+
'width' => '100px',
|
125 |
+
'type' => 'action',
|
126 |
+
'index' => 'actions',
|
127 |
+
'filter' => false,
|
128 |
+
'sortable' => false,
|
129 |
+
'getter' => 'getId',
|
130 |
+
'actions' => array(
|
131 |
+
array(
|
132 |
+
'caption' => Mage::helper('M2ePro')->__('Edit'),
|
133 |
+
'url' => array('base'=> '*/*/edit'),
|
134 |
+
'field' => 'id'
|
135 |
+
),
|
136 |
+
array(
|
137 |
+
'caption' => Mage::helper('M2ePro')->__('Delete'),
|
138 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?'),
|
139 |
+
'url' => array('base' => '*/*/delete'),
|
140 |
+
'field' => 'ids'
|
141 |
+
),
|
142 |
+
)
|
143 |
+
));
|
144 |
+
}
|
145 |
+
|
146 |
+
// ####################################
|
147 |
+
|
148 |
+
protected function _prepareMassaction()
|
149 |
+
{
|
150 |
+
// Set massaction identifiers
|
151 |
+
//--------------------------------
|
152 |
+
$this->setMassactionIdField('main_table.id');
|
153 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
154 |
+
//--------------------------------
|
155 |
+
|
156 |
+
// Set delete action
|
157 |
+
//--------------------------------
|
158 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
159 |
+
'label' => Mage::helper('M2ePro')->__('Delete'),
|
160 |
+
'url' => $this->getUrl('*/*/delete'),
|
161 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
162 |
+
));
|
163 |
+
//--------------------------------
|
164 |
+
|
165 |
+
return parent::_prepareMassaction();
|
166 |
+
}
|
167 |
+
|
168 |
+
// ####################################
|
169 |
+
|
170 |
+
public function callbackColumnId($value, $row, $column, $isExport)
|
171 |
+
{
|
172 |
+
return $value.' ';
|
173 |
+
}
|
174 |
+
|
175 |
+
//--------------------------------
|
176 |
+
|
177 |
+
public function callbackColumnTitle($value, $row, $column, $isExport)
|
178 |
+
{
|
179 |
+
$titleWord = Mage::helper('M2ePro')->__('Title');
|
180 |
+
$title = Mage::helper('M2ePro')->escapeHtml($value);
|
181 |
+
|
182 |
+
$categoryWord = Mage::helper('M2ePro')->__('Category');
|
183 |
+
$categoryPath = !empty($row['category_path']) ? "{$row['category_path']} ({$row['browsenode_id']})"
|
184 |
+
: Mage::helper('M2ePro')->__('Not Set');
|
185 |
+
return <<<HTML
|
186 |
+
<span style="font-weight: bold">{$titleWord}</span>: {$title}
|
187 |
+
<div>
|
188 |
+
<span style="font-weight: bold">{$categoryWord}</span>: <span style="color: #505050">{$categoryPath}</span><br/>
|
189 |
+
</div>
|
190 |
+
HTML;
|
191 |
+
}
|
192 |
+
|
193 |
+
// ####################################
|
194 |
+
|
195 |
+
protected function callbackFilterTitle($collection, $column)
|
196 |
+
{
|
197 |
+
$value = $column->getFilter()->getValue();
|
198 |
+
|
199 |
+
if ($value == null) {
|
200 |
+
return;
|
201 |
+
}
|
202 |
+
|
203 |
+
$collection->getSelect()->where(
|
204 |
+
"`atd`.`category_path` LIKE '%{$value}%' OR
|
205 |
+
`atd`.`browsenode_id` LIKE '%{$value}%' OR
|
206 |
+
`main_table`.`title` LIKE '%{$value}%'"
|
207 |
+
);
|
208 |
+
}
|
209 |
+
|
210 |
+
// ####################################
|
211 |
+
|
212 |
+
public function getGridUrl()
|
213 |
+
{
|
214 |
+
return $this->getUrl('*/adminhtml_common_amazon_template_description/grid', array('_current'=>true));
|
215 |
+
}
|
216 |
+
|
217 |
+
public function getRowUrl($row)
|
218 |
+
{
|
219 |
+
return $this->getUrl('*/adminhtml_common_amazon_template_description/edit', array('id' => $row->getData('id')));
|
220 |
+
}
|
221 |
+
|
222 |
+
// ####################################
|
223 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Description/Help.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Description_Help extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
// ########################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
$this->setTemplate('M2ePro/common/amazon/template/description/help.phtml');
|
15 |
+
}
|
16 |
+
|
17 |
+
// ########################################
|
18 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/SellingFormat/Edit.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_SellingFormat_Edit
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Form_Container
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
//------------------------------
|
16 |
+
$this->setId('amazonTemplateSellingFormatEdit');
|
17 |
+
$this->_blockGroup = 'M2ePro';
|
18 |
+
$this->_controller = 'adminhtml_common_amazon_template_sellingFormat';
|
19 |
+
$this->_mode = 'edit';
|
20 |
+
//------------------------------
|
21 |
+
|
22 |
+
// Set header text
|
23 |
+
//------------------------------
|
24 |
+
$helper = Mage::helper('M2ePro');
|
25 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
26 |
+
$componentName = Mage::helper('M2ePro/Component_Amazon')->getTitle();
|
27 |
+
$headerTextEdit = $helper->__("Edit %component_name% Selling Format Policy", $componentName);
|
28 |
+
$headerTextAdd = $helper->__("Add %component_name% Selling Format Policy", $componentName);
|
29 |
+
} else {
|
30 |
+
$headerTextEdit = $helper->__("Edit Selling Format Policy");
|
31 |
+
$headerTextAdd = $helper->__("Add Selling Format Policy" );
|
32 |
+
}
|
33 |
+
|
34 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data')
|
35 |
+
&& Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()
|
36 |
+
) {
|
37 |
+
$this->_headerText = $headerTextEdit;
|
38 |
+
$this->_headerText .= ' "'.$this->escapeHtml(
|
39 |
+
Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getTitle()).'"';
|
40 |
+
} else {
|
41 |
+
$this->_headerText = $headerTextAdd;
|
42 |
+
}
|
43 |
+
//------------------------------
|
44 |
+
|
45 |
+
// Set buttons actions
|
46 |
+
//------------------------------
|
47 |
+
$this->removeButton('back');
|
48 |
+
$this->removeButton('reset');
|
49 |
+
$this->removeButton('delete');
|
50 |
+
$this->removeButton('add');
|
51 |
+
$this->removeButton('save');
|
52 |
+
$this->removeButton('edit');
|
53 |
+
//------------------------------
|
54 |
+
|
55 |
+
//------------------------------
|
56 |
+
$url = Mage::helper('M2ePro')->getBackUrl('list');
|
57 |
+
$this->_addButton('back', array(
|
58 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
59 |
+
'onclick' => 'AmazonTemplateSellingFormatHandlerObj.back_click(\'' . $url . '\')',
|
60 |
+
'class' => 'back'
|
61 |
+
));
|
62 |
+
//------------------------------
|
63 |
+
|
64 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data')
|
65 |
+
&& Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()
|
66 |
+
) {
|
67 |
+
//------------------------------
|
68 |
+
$this->_addButton('duplicate', array(
|
69 |
+
'label' => Mage::helper('M2ePro')->__('Duplicate'),
|
70 |
+
'onclick' => 'AmazonTemplateSellingFormatHandlerObj.duplicate_click'
|
71 |
+
.'(\'common-amazon-template-sellingFormat\')',
|
72 |
+
'class' => 'add M2ePro_duplicate_button'
|
73 |
+
));
|
74 |
+
//------------------------------
|
75 |
+
|
76 |
+
//------------------------------
|
77 |
+
$this->_addButton('delete', array(
|
78 |
+
'label' => Mage::helper('M2ePro')->__('Delete'),
|
79 |
+
'onclick' => 'AmazonTemplateSellingFormatHandlerObj.delete_click()',
|
80 |
+
'class' => 'delete M2ePro_delete_button'
|
81 |
+
));
|
82 |
+
//------------------------------
|
83 |
+
}
|
84 |
+
|
85 |
+
//------------------------------
|
86 |
+
$this->_addButton('save', array(
|
87 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
88 |
+
'onclick' => 'AmazonTemplateSellingFormatHandlerObj.save_click()',
|
89 |
+
'class' => 'save'
|
90 |
+
));
|
91 |
+
//------------------------------
|
92 |
+
|
93 |
+
//------------------------------
|
94 |
+
$this->_addButton('save_and_continue', array(
|
95 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
96 |
+
'onclick' => 'AmazonTemplateSellingFormatHandlerObj.save_and_edit_click()',
|
97 |
+
'class' => 'save'
|
98 |
+
));
|
99 |
+
//------------------------------
|
100 |
+
}
|
101 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/SellingFormat/Edit/Form.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_SellingFormat_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
8 |
+
{
|
9 |
+
const QTY_MODE_PRODUCT_FIXED_VIRTUAL_ATTRIBUTE_VALUE = 'qty_mode_product_fixed';
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('amazonTemplateSellingFormatEditForm');
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$this->setTemplate('M2ePro/common/amazon/template/selling_format/form.phtml');
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _prepareForm()
|
24 |
+
{
|
25 |
+
$form = new Varien_Data_Form(array(
|
26 |
+
'id' => 'edit_form',
|
27 |
+
'action' => $this->getUrl('*/*/save'),
|
28 |
+
'method' => 'post',
|
29 |
+
'enctype' => 'multipart/form-data'
|
30 |
+
));
|
31 |
+
|
32 |
+
$form->setUseContainer(true);
|
33 |
+
$this->setForm($form);
|
34 |
+
|
35 |
+
return parent::_prepareForm();
|
36 |
+
}
|
37 |
+
|
38 |
+
protected function _beforeToHtml()
|
39 |
+
{
|
40 |
+
//------------------------------
|
41 |
+
$this->attributes = Mage::helper('M2ePro/Magento_Attribute')->getGeneralFromAllAttributeSets();
|
42 |
+
//------------------------------
|
43 |
+
|
44 |
+
//------------------------------
|
45 |
+
$this->setData('currencies', Mage::helper('M2ePro/Component_Amazon')->getCurrencies());
|
46 |
+
//------------------------------
|
47 |
+
|
48 |
+
//------------------------------
|
49 |
+
$this->customerGroups = Mage::getModel('customer/group')->getCollection()->toOptionArray();
|
50 |
+
//------------------------------
|
51 |
+
|
52 |
+
return parent::_beforeToHtml();
|
53 |
+
}
|
54 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Synchronization/Edit.php
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Synchronization_Edit
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Form_Container
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
//------------------------------
|
16 |
+
$this->setId('amazonTemplateSynchronizationEdit');
|
17 |
+
$this->_blockGroup = 'M2ePro';
|
18 |
+
$this->_controller = 'adminhtml_common_amazon_template_synchronization';
|
19 |
+
$this->_mode = 'edit';
|
20 |
+
//------------------------------
|
21 |
+
|
22 |
+
// Set header text
|
23 |
+
//------------------------------
|
24 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
25 |
+
$componentName = Mage::helper('M2ePro/Component_Amazon')->getTitle();
|
26 |
+
$headerTextEdit = Mage::helper('M2ePro')->__(
|
27 |
+
"Edit %component_name% Synchronization Policy",
|
28 |
+
$componentName
|
29 |
+
);
|
30 |
+
$headerTextAdd = Mage::helper('M2ePro')->__(
|
31 |
+
"Add %component_name% Synchronization Policy",
|
32 |
+
$componentName);
|
33 |
+
} else {
|
34 |
+
$headerTextEdit = Mage::helper('M2ePro')->__("Edit Synchronization Policy");
|
35 |
+
$headerTextAdd = Mage::helper('M2ePro')->__("Add Synchronization Policy");
|
36 |
+
}
|
37 |
+
|
38 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data')
|
39 |
+
&& Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()
|
40 |
+
) {
|
41 |
+
$this->_headerText = $headerTextEdit;
|
42 |
+
$this->_headerText .= ' "'.$this->escapeHtml(
|
43 |
+
Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getTitle()).'"';
|
44 |
+
} else {
|
45 |
+
$this->_headerText = $headerTextAdd;
|
46 |
+
}
|
47 |
+
//------------------------------
|
48 |
+
|
49 |
+
// Set buttons actions
|
50 |
+
//------------------------------
|
51 |
+
$this->removeButton('back');
|
52 |
+
$this->removeButton('reset');
|
53 |
+
$this->removeButton('delete');
|
54 |
+
$this->removeButton('add');
|
55 |
+
$this->removeButton('save');
|
56 |
+
$this->removeButton('edit');
|
57 |
+
//------------------------------
|
58 |
+
|
59 |
+
//------------------------------
|
60 |
+
$url = Mage::helper('M2ePro')->getBackUrl('list');
|
61 |
+
$this->_addButton('back', array(
|
62 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
63 |
+
'onclick' => 'AmazonTemplateSynchronizationHandlerObj.back_click(\'' . $url . '\')',
|
64 |
+
'class' => 'back'
|
65 |
+
));
|
66 |
+
//------------------------------
|
67 |
+
|
68 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data')
|
69 |
+
&& Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()
|
70 |
+
) {
|
71 |
+
//------------------------------
|
72 |
+
$this->_addButton('duplicate', array(
|
73 |
+
'label' => Mage::helper('M2ePro')->__('Duplicate'),
|
74 |
+
'onclick' => 'AmazonTemplateSynchronizationHandlerObj.duplicate_click'
|
75 |
+
.'(\'common-amazon-template-synchronization\')',
|
76 |
+
'class' => 'add M2ePro_duplicate_button'
|
77 |
+
));
|
78 |
+
//------------------------------
|
79 |
+
|
80 |
+
//------------------------------
|
81 |
+
$this->_addButton('delete', array(
|
82 |
+
'label' => Mage::helper('M2ePro')->__('Delete'),
|
83 |
+
'onclick' => 'AmazonTemplateSynchronizationHandlerObj.delete_click()',
|
84 |
+
'class' => 'delete M2ePro_delete_button'
|
85 |
+
));
|
86 |
+
//------------------------------
|
87 |
+
}
|
88 |
+
|
89 |
+
//------------------------------
|
90 |
+
$this->_addButton('save', array(
|
91 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
92 |
+
'onclick' => 'AmazonTemplateSynchronizationHandlerObj.save_click()',
|
93 |
+
'class' => 'save'
|
94 |
+
));
|
95 |
+
//------------------------------
|
96 |
+
|
97 |
+
//------------------------------
|
98 |
+
$this->_addButton('save_and_continue', array(
|
99 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
100 |
+
'onclick' => 'AmazonTemplateSynchronizationHandlerObj.save_and_edit_click'
|
101 |
+
.'(\'\',\'amazonTemplateSynchronizationEditTabs\')',
|
102 |
+
'class' => 'save'
|
103 |
+
));
|
104 |
+
//------------------------------
|
105 |
+
}
|
106 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Synchronization/Edit/Form.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Synchronization_Edit_Form
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Form
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
//------------------------------
|
16 |
+
$this->setId('amazonTemplateSynchronizationEditForm');
|
17 |
+
//------------------------------
|
18 |
+
}
|
19 |
+
|
20 |
+
protected function _prepareForm()
|
21 |
+
{
|
22 |
+
$form = new Varien_Data_Form(array(
|
23 |
+
'id' => 'edit_form',
|
24 |
+
'action' => $this->getUrl('*/*/save'),
|
25 |
+
'method' => 'post',
|
26 |
+
'enctype' => 'multipart/form-data'
|
27 |
+
));
|
28 |
+
|
29 |
+
$form->setUseContainer(true);
|
30 |
+
$this->setForm($form);
|
31 |
+
|
32 |
+
return parent::_prepareForm();
|
33 |
+
}
|
34 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Synchronization/Edit/Tabs.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Synchronization_Edit_Tabs
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Tabs
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
//------------------------------
|
16 |
+
$this->setId('amazonTemplateSynchronizationEditTabs');
|
17 |
+
//------------------------------
|
18 |
+
|
19 |
+
$this->setTitle(Mage::helper('M2ePro')->__('Configuration'));
|
20 |
+
$this->setDestElementId('edit_form');
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _beforeToHtml()
|
24 |
+
{
|
25 |
+
$this->addTab('list',array(
|
26 |
+
'label' => Mage::helper('M2ePro')->__('List Rules'),
|
27 |
+
'title' => Mage::helper('M2ePro')->__('List Rules'),
|
28 |
+
'content' => $this->getLayout()
|
29 |
+
->createBlock('M2ePro/adminhtml_common_amazon_template_synchronization_edit_tabs_list')
|
30 |
+
->toHtml()
|
31 |
+
));
|
32 |
+
|
33 |
+
$this->addTab('revise',array(
|
34 |
+
'label' => Mage::helper('M2ePro')->__('Revise Rules'),
|
35 |
+
'title' => Mage::helper('M2ePro')->__('Revise Rules'),
|
36 |
+
'content' => $this->getLayout()
|
37 |
+
->createBlock('M2ePro/adminhtml_common_amazon_template_synchronization_edit_tabs_revise')
|
38 |
+
->toHtml()
|
39 |
+
));
|
40 |
+
|
41 |
+
$this->addTab('relist',array(
|
42 |
+
'label' => Mage::helper('M2ePro')->__('Relist Rules'),
|
43 |
+
'title' => Mage::helper('M2ePro')->__('Relist Rules'),
|
44 |
+
'content' => $this->getLayout()
|
45 |
+
->createBlock('M2ePro/adminhtml_common_amazon_template_synchronization_edit_tabs_relist')
|
46 |
+
->toHtml()
|
47 |
+
));
|
48 |
+
|
49 |
+
$this->addTab('stop',array(
|
50 |
+
'label' => Mage::helper('M2ePro')->__('Stop Rules'),
|
51 |
+
'title' => Mage::helper('M2ePro')->__('Stop Rules'),
|
52 |
+
'content' => $this->getLayout()
|
53 |
+
->createBlock('M2ePro/adminhtml_common_amazon_template_synchronization_edit_tabs_stop')
|
54 |
+
->toHtml()
|
55 |
+
));
|
56 |
+
|
57 |
+
$this->setActiveTab($this->getRequest()->getParam('tab', 'list'));
|
58 |
+
|
59 |
+
return parent::_beforeToHtml();
|
60 |
+
}
|
61 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Synchronization/Edit/Tabs/List.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Synchronization_Edit_Tabs_List
|
8 |
+
extends Mage_Adminhtml_Block_Widget
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
//------------------------------
|
16 |
+
$this->setId('amazonTemplateSynchronizationEditTabsList');
|
17 |
+
//------------------------------
|
18 |
+
|
19 |
+
$this->setTemplate('M2ePro/common/amazon/template/synchronization/list.phtml');
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Synchronization/Edit/Tabs/Relist.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Synchronization_Edit_Tabs_Relist
|
8 |
+
extends Mage_Adminhtml_Block_Widget
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
//------------------------------
|
16 |
+
$this->setId('amazonTemplateSynchronizationEditTabsRelist');
|
17 |
+
//------------------------------
|
18 |
+
|
19 |
+
$this->setTemplate('M2ePro/common/amazon/template/synchronization/relist.phtml');
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Synchronization/Edit/Tabs/Revise.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Synchronization_Edit_Tabs_Revise
|
8 |
+
extends Mage_Adminhtml_Block_Widget
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
//------------------------------
|
16 |
+
$this->setId('amazonTemplateSynchronizationEditTabsRevise');
|
17 |
+
//------------------------------
|
18 |
+
|
19 |
+
$this->setTemplate('M2ePro/common/amazon/template/synchronization/revise.phtml');
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Synchronization/Edit/Tabs/Stop.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_Synchronization_Edit_Tabs_Stop
|
8 |
+
extends Mage_Adminhtml_Block_Widget
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
//------------------------------
|
16 |
+
$this->setId('amazonTemplateSynchronizationEditTabsStop');
|
17 |
+
//------------------------------
|
18 |
+
|
19 |
+
$this->setTemplate('M2ePro/common/amazon/template/synchronization/stop.phtml');
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Account/Edit.php
ADDED
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Account_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyAccountEdit');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_buy_account';
|
18 |
+
$this->_mode = 'edit';
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
// Set header text
|
22 |
+
//------------------------------
|
23 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
24 |
+
$componentName = Mage::helper('M2ePro/Component_Buy')->getTitle();
|
25 |
+
$headerTextEdit = $this->_headerText = Mage::helper('M2ePro')->__(
|
26 |
+
"Edit %component_name% Account",
|
27 |
+
$componentName
|
28 |
+
);
|
29 |
+
$headerTextAdd = $this->_headerText = Mage::helper('M2ePro')->__(
|
30 |
+
"Add %component_name% Account",
|
31 |
+
$componentName
|
32 |
+
);
|
33 |
+
} else {
|
34 |
+
$headerTextEdit = $this->_headerText = Mage::helper('M2ePro')->__("Edit Account");
|
35 |
+
$headerTextAdd = $this->_headerText = Mage::helper('M2ePro')->__("Add Account");
|
36 |
+
}
|
37 |
+
|
38 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data') &&
|
39 |
+
Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()
|
40 |
+
) {
|
41 |
+
$this->_headerText = $headerTextEdit;
|
42 |
+
$this->_headerText .= ' "'.$this->escapeHtml(
|
43 |
+
Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getTitle()
|
44 |
+
).'"';
|
45 |
+
} else {
|
46 |
+
$this->_headerText = $headerTextAdd;
|
47 |
+
}
|
48 |
+
//------------------------------
|
49 |
+
|
50 |
+
// Set buttons actions
|
51 |
+
//------------------------------
|
52 |
+
$this->removeButton('back');
|
53 |
+
$this->removeButton('reset');
|
54 |
+
$this->removeButton('delete');
|
55 |
+
$this->removeButton('add');
|
56 |
+
$this->removeButton('save');
|
57 |
+
$this->removeButton('edit');
|
58 |
+
|
59 |
+
/* @var $wizardHelper Ess_M2ePro_Helper_Module_Wizard */
|
60 |
+
$wizardHelper = Mage::helper('M2ePro/Module_Wizard');
|
61 |
+
|
62 |
+
if ($wizardHelper->isActive('buy') &&
|
63 |
+
$wizardHelper->getStep('buy') == 'account'
|
64 |
+
) {
|
65 |
+
|
66 |
+
//------------------------------
|
67 |
+
$this->_addButton('save_and_continue', array(
|
68 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
69 |
+
'onclick' => 'BuyAccountHandlerObj.save_and_edit_click(\'\',\'buyAccountEditTabs\')',
|
70 |
+
'class' => 'save'
|
71 |
+
));
|
72 |
+
//------------------------------
|
73 |
+
|
74 |
+
if ($this->getRequest()->getParam('id')) {
|
75 |
+
//------------------------------
|
76 |
+
$url = $this->getUrl('*/adminhtml_common_buy_account/new', array('wizard' => true));
|
77 |
+
$this->_addButton('add_new_account', array(
|
78 |
+
'label' => Mage::helper('M2ePro')->__('Add New Account'),
|
79 |
+
'onclick' => 'setLocation(\''. $url .'\')',
|
80 |
+
'class' => 'add_new_account'
|
81 |
+
));
|
82 |
+
//------------------------------
|
83 |
+
|
84 |
+
//------------------------------
|
85 |
+
$this->_addButton('close', array(
|
86 |
+
'label' => Mage::helper('M2ePro')->__('Complete This Step'),
|
87 |
+
'onclick' => 'BuyAccountHandlerObj.completeStep();',
|
88 |
+
'class' => 'close'
|
89 |
+
));
|
90 |
+
//------------------------------
|
91 |
+
}
|
92 |
+
} else {
|
93 |
+
|
94 |
+
if ((bool)$this->getRequest()->getParam('close_on_save',false)) {
|
95 |
+
|
96 |
+
if ($this->getRequest()->getParam('id')) {
|
97 |
+
$this->_addButton('save', array(
|
98 |
+
'label' => Mage::helper('M2ePro')->__('Save And Close'),
|
99 |
+
'onclick' => 'BuyAccountHandlerObj.saveAndClose()',
|
100 |
+
'class' => 'save'
|
101 |
+
));
|
102 |
+
} else {
|
103 |
+
$this->_addButton('save_and_continue', array(
|
104 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
105 |
+
'onclick' => 'BuyAccountHandlerObj.save_and_edit_click(\'\',\'buyAccountEditTabs\')',
|
106 |
+
'class' => 'save'
|
107 |
+
));
|
108 |
+
}
|
109 |
+
return;
|
110 |
+
}
|
111 |
+
|
112 |
+
//------------------------------
|
113 |
+
$url = Mage::helper('M2ePro')->getBackUrl('list');
|
114 |
+
$this->_addButton('back', array(
|
115 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
116 |
+
'onclick' => 'BuyAccountHandlerObj.back_click(\'' . $url .'\')',
|
117 |
+
'class' => 'back'
|
118 |
+
));
|
119 |
+
//------------------------------
|
120 |
+
|
121 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data') &&
|
122 |
+
Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()
|
123 |
+
) {
|
124 |
+
//------------------------------
|
125 |
+
$this->_addButton('delete', array(
|
126 |
+
'label' => Mage::helper('M2ePro')->__('Delete'),
|
127 |
+
'onclick' => 'BuyAccountHandlerObj.delete_click()',
|
128 |
+
'class' => 'delete M2ePro_delete_button'
|
129 |
+
));
|
130 |
+
//------------------------------
|
131 |
+
}
|
132 |
+
|
133 |
+
//------------------------------
|
134 |
+
$this->_addButton('save', array(
|
135 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
136 |
+
'onclick' => 'BuyAccountHandlerObj.save_click()',
|
137 |
+
'class' => 'save'
|
138 |
+
));
|
139 |
+
//------------------------------
|
140 |
+
|
141 |
+
//------------------------------
|
142 |
+
$this->_addButton('save_and_continue', array(
|
143 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
144 |
+
'onclick' => 'BuyAccountHandlerObj.save_and_edit_click(\'\',\'buyAccountEditTabs\')',
|
145 |
+
'class' => 'save'
|
146 |
+
));
|
147 |
+
//------------------------------
|
148 |
+
}
|
149 |
+
}
|
150 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Account/Edit/Form.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Account_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyAccountEditForm');
|
16 |
+
//------------------------------
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _prepareForm()
|
20 |
+
{
|
21 |
+
$form = new Varien_Data_Form(array(
|
22 |
+
'id' => 'edit_form',
|
23 |
+
'action' => $this->getUrl('*/*/save'),
|
24 |
+
'method' => 'post',
|
25 |
+
'enctype' => 'multipart/form-data'
|
26 |
+
));
|
27 |
+
|
28 |
+
$form->setUseContainer(true);
|
29 |
+
$this->setForm($form);
|
30 |
+
|
31 |
+
return parent::_prepareForm();
|
32 |
+
}
|
33 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Account/Edit/Tabs.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Account_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyAccountEditTabs');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTitle(Mage::helper('M2ePro')->__('Configuration'));
|
19 |
+
$this->setDestElementId('edit_form');
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _beforeToHtml()
|
23 |
+
{
|
24 |
+
$this->addTab('general', array(
|
25 |
+
'label' => Mage::helper('M2ePro')->__('General'),
|
26 |
+
'title' => Mage::helper('M2ePro')->__('General'),
|
27 |
+
'content' => $this->getLayout()
|
28 |
+
->createBlock('M2ePro/adminhtml_common_buy_account_edit_tabs_general')
|
29 |
+
->toHtml(),
|
30 |
+
));
|
31 |
+
|
32 |
+
$this->addTab('listingOther', array(
|
33 |
+
'label' => Mage::helper('M2ePro')->__('3rd Party Listings'),
|
34 |
+
'title' => Mage::helper('M2ePro')->__('3rd Party Listings'),
|
35 |
+
'content' => $this->getLayout()
|
36 |
+
->createBlock('M2ePro/adminhtml_common_buy_account_edit_tabs_listingOther')
|
37 |
+
->toHtml(),
|
38 |
+
));
|
39 |
+
|
40 |
+
$this->addTab('orders', array(
|
41 |
+
'label' => Mage::helper('M2ePro')->__('Orders'),
|
42 |
+
'title' => Mage::helper('M2ePro')->__('Orders'),
|
43 |
+
'content' => $this->getLayout()
|
44 |
+
->createBlock('M2ePro/adminhtml_common_buy_account_edit_tabs_order')
|
45 |
+
->toHtml(),
|
46 |
+
));
|
47 |
+
|
48 |
+
$this->setActiveTab($this->getRequest()->getParam('tab', 'general'));
|
49 |
+
|
50 |
+
return parent::_beforeToHtml();
|
51 |
+
}
|
52 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Account/Edit/Tabs/General.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Account_Edit_Tabs_General extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyAccountEditTabsGeneral');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/buy/account/tabs/general.phtml');
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _beforeToHtml()
|
22 |
+
{
|
23 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data') &&
|
24 |
+
Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()
|
25 |
+
) {
|
26 |
+
|
27 |
+
/** @var $accountObj Ess_M2ePro_Model_Account */
|
28 |
+
$accountObj = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
29 |
+
|
30 |
+
$this->synchronizeProcessing = $accountObj->isLockedObject('server_synchronize');
|
31 |
+
|
32 |
+
if (!$this->synchronizeProcessing) {
|
33 |
+
$accountId = $accountObj->getId();
|
34 |
+
|
35 |
+
Mage::helper('M2ePro/Data_Global')->unsetValue('temp_data');
|
36 |
+
Mage::helper('M2ePro/Data_Global')->setValue(
|
37 |
+
'temp_data',
|
38 |
+
Mage::helper('M2ePro/Component_Buy')->getCachedObject('Account',$accountId)
|
39 |
+
);
|
40 |
+
}
|
41 |
+
} else {
|
42 |
+
$this->synchronizeProcessing = false;
|
43 |
+
}
|
44 |
+
|
45 |
+
$marketplaces = Mage::helper('M2ePro/Component_Buy')->getCollection('Marketplace')
|
46 |
+
->addFieldToFilter('status', Ess_M2ePro_Model_Marketplace::STATUS_ENABLE);
|
47 |
+
|
48 |
+
$this->marketplace = true;
|
49 |
+
if ($marketplaces->getSize() <= 0) {
|
50 |
+
$this->marketplace = false;
|
51 |
+
}
|
52 |
+
//var_dump($this->marketplace); exit();
|
53 |
+
|
54 |
+
//------------------------------
|
55 |
+
$data = array(
|
56 |
+
'label' => Mage::helper('M2ePro')->__('Update FTP Password'),
|
57 |
+
'onclick' => 'BuyAccountHandlerObj.update_password(\'ftp\')',
|
58 |
+
'class' => 'scalable'
|
59 |
+
);
|
60 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
61 |
+
$this->setChild('buy_update_ftp_password', $buttonBlock);
|
62 |
+
//------------------------------
|
63 |
+
|
64 |
+
//------------------------------
|
65 |
+
$data = array(
|
66 |
+
'label' => Mage::helper('M2ePro')->__('Update Web Password'),
|
67 |
+
'onclick' => 'BuyAccountHandlerObj.update_password(\'web\')',
|
68 |
+
'class' => 'scalable'
|
69 |
+
);
|
70 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
71 |
+
$this->setChild('buy_update_web_password', $buttonBlock);
|
72 |
+
//------------------------------
|
73 |
+
|
74 |
+
return parent::_beforeToHtml();
|
75 |
+
}
|
76 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Account/Edit/Tabs/ListingOther.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Account_Edit_Tabs_ListingOther extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyAccountEditTabsListingOther');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/buy/account/tabs/listing_other.phtml');
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _beforeToHtml()
|
22 |
+
{
|
23 |
+
$this->attributes = Mage::helper('M2ePro/Magento_Attribute')->getGeneralFromAllAttributeSets();
|
24 |
+
|
25 |
+
return parent::_beforeToHtml();
|
26 |
+
}
|
27 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Account/Edit/Tabs/Order.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Account_Edit_Tabs_Order extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
protected $_possibleMagentoStatuses = null;
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('buyAccountEditTabsOrder');
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$this->setTemplate('M2ePro/common/buy/account/tabs/order.phtml');
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _beforeToHtml()
|
24 |
+
{
|
25 |
+
$data = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
26 |
+
$magentoOrdersSettings = !empty($data['magento_orders_settings'])
|
27 |
+
? json_decode($data['magento_orders_settings'], true) : array();
|
28 |
+
|
29 |
+
//----------------------------
|
30 |
+
$temp = Mage::getModel('core/website')->getCollection()->setOrder('sort_order','ASC')->toArray();
|
31 |
+
$this->websites = $temp['items'];
|
32 |
+
//----------------------------
|
33 |
+
|
34 |
+
//----------------------------
|
35 |
+
$temp = Mage::getModel('customer/group')->getCollection()->toArray();
|
36 |
+
$this->groups = $temp['items'];
|
37 |
+
//----------------------------
|
38 |
+
|
39 |
+
//----------------------------
|
40 |
+
$selectedStore = !empty($magentoOrdersSettings['listing']['store_id'])
|
41 |
+
? $magentoOrdersSettings['listing']['store_id'] : '';
|
42 |
+
$blockStoreSwitcher = $this->getLayout()->createBlock('M2ePro/adminhtml_storeSwitcher', '', array(
|
43 |
+
'id' => 'magento_orders_listings_store_id',
|
44 |
+
'name' => 'magento_orders_settings[listing][store_id]',
|
45 |
+
'selected' => $selectedStore
|
46 |
+
));
|
47 |
+
$blockStoreSwitcher->hasDefaultOption(false);
|
48 |
+
$this->setChild('magento_orders_listings_store_id', $blockStoreSwitcher);
|
49 |
+
//----------------------------
|
50 |
+
|
51 |
+
//----------------------------
|
52 |
+
$selectedStore = !empty($magentoOrdersSettings['listing_other']['store_id'])
|
53 |
+
? $magentoOrdersSettings['listing_other']['store_id'] : '';
|
54 |
+
$blockStoreSwitcher = $this->getLayout()->createBlock('M2ePro/adminhtml_storeSwitcher', '', array(
|
55 |
+
'id' => 'magento_orders_listings_other_store_id',
|
56 |
+
'name' => 'magento_orders_settings[listing_other][store_id]',
|
57 |
+
'selected' => $selectedStore
|
58 |
+
));
|
59 |
+
$blockStoreSwitcher->hasDefaultOption(false);
|
60 |
+
$this->setChild('magento_orders_listings_other_store_id', $blockStoreSwitcher);
|
61 |
+
//----------------------------
|
62 |
+
|
63 |
+
//----------------------------
|
64 |
+
$productTaxClasses = Mage::getModel('tax/class')->getCollection()
|
65 |
+
->addFieldToFilter('class_type', Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT)
|
66 |
+
->toOptionArray();
|
67 |
+
|
68 |
+
$none = array('value' => Ess_M2ePro_Model_Magento_Product::TAX_CLASS_ID_NONE, 'label' => 'None');
|
69 |
+
array_unshift($productTaxClasses, $none);
|
70 |
+
|
71 |
+
$this->productTaxClasses = $productTaxClasses;
|
72 |
+
//----------------------------
|
73 |
+
|
74 |
+
return parent::_beforeToHtml();
|
75 |
+
}
|
76 |
+
|
77 |
+
public function getMagentoOrderStatusList()
|
78 |
+
{
|
79 |
+
if (is_null($this->_possibleMagentoStatuses)) {
|
80 |
+
$this->_possibleMagentoStatuses = Mage::getSingleton('sales/order_config')->getStatuses();
|
81 |
+
}
|
82 |
+
|
83 |
+
return $this->_possibleMagentoStatuses;
|
84 |
+
}
|
85 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing.php
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing extends Mage_Adminhtml_Block_Widget_Grid_Container
|
8 |
+
{
|
9 |
+
// ####################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('buyListing');
|
18 |
+
$this->_blockGroup = 'M2ePro';
|
19 |
+
$this->_controller = 'adminhtml_common_buy_listing';
|
20 |
+
//------------------------------
|
21 |
+
|
22 |
+
// Set header text
|
23 |
+
//------------------------------
|
24 |
+
$this->_headerText = '';
|
25 |
+
//------------------------------
|
26 |
+
|
27 |
+
// Set buttons actions
|
28 |
+
//------------------------------
|
29 |
+
$this->removeButton('back');
|
30 |
+
$this->removeButton('reset');
|
31 |
+
$this->removeButton('delete');
|
32 |
+
$this->removeButton('add');
|
33 |
+
$this->removeButton('save');
|
34 |
+
$this->removeButton('edit');
|
35 |
+
//------------------------------
|
36 |
+
|
37 |
+
//------------------------------
|
38 |
+
|
39 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
40 |
+
'*/adminhtml_common_listing/index',
|
41 |
+
array(
|
42 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_BUY
|
43 |
+
)
|
44 |
+
);
|
45 |
+
|
46 |
+
//------------------------------
|
47 |
+
$url = $this->getUrl(
|
48 |
+
'*/adminhtml_common_log/listing',
|
49 |
+
array(
|
50 |
+
'channel' => Ess_M2ePro_Block_Adminhtml_Common_Log_Tabs::TAB_ID_BUY
|
51 |
+
)
|
52 |
+
);
|
53 |
+
$this->_addButton('view_log', array(
|
54 |
+
'label' => Mage::helper('M2ePro')->__('View Log'),
|
55 |
+
'onclick' => 'window.open(\''.$url.'\')',
|
56 |
+
'class' => 'button_link'
|
57 |
+
));
|
58 |
+
//------------------------------
|
59 |
+
|
60 |
+
//------------------------------
|
61 |
+
$url = $this->getUrl('*/adminhtml_common_buy_listing/search', array('back' => $backUrl));
|
62 |
+
$this->_addButton('search_buy_products', array(
|
63 |
+
'label' => Mage::helper('M2ePro')->__('Search'),
|
64 |
+
'onclick' => 'setLocation(\''.$url.'\')',
|
65 |
+
'class' => 'button_link search'
|
66 |
+
));
|
67 |
+
//------------------------------
|
68 |
+
|
69 |
+
//------------------------------
|
70 |
+
$url = $this->getUrl('*/adminhtml_common_listing_create/index', array(
|
71 |
+
'step' => '1',
|
72 |
+
'clear' => 'yes',
|
73 |
+
'component' => Ess_M2ePro_Helper_Component_Buy::NICK
|
74 |
+
));
|
75 |
+
$this->_addButton('add', array(
|
76 |
+
'label' => Mage::helper('M2ePro')->__('Add Listing'),
|
77 |
+
'onclick' => 'setLocation(\'' .$url.'\')',
|
78 |
+
'class' => 'add'
|
79 |
+
));
|
80 |
+
//------------------------------
|
81 |
+
}
|
82 |
+
|
83 |
+
// ####################################
|
84 |
+
|
85 |
+
public function getTemplatesButtonJavascript()
|
86 |
+
{
|
87 |
+
$data = array(
|
88 |
+
'target_css_class' => 'buy-templates-drop-down',
|
89 |
+
'items' => $this->getTemplatesButtonDropDownItems()
|
90 |
+
);
|
91 |
+
$dropDownBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_button_dropDown');
|
92 |
+
$dropDownBlock->setData($data);
|
93 |
+
|
94 |
+
return $dropDownBlock->toHtml();
|
95 |
+
}
|
96 |
+
|
97 |
+
protected function getTemplatesButtonDropDownItems()
|
98 |
+
{
|
99 |
+
$items = array();
|
100 |
+
|
101 |
+
$filter = base64_encode('component_mode=' . Ess_M2ePro_Helper_Component_Buy::NICK);
|
102 |
+
|
103 |
+
//------------------------------
|
104 |
+
$url = $this->getUrl(
|
105 |
+
'*/adminhtml_common_template_sellingFormat/index',
|
106 |
+
array(
|
107 |
+
'filter' => $filter
|
108 |
+
)
|
109 |
+
);
|
110 |
+
$items[] = array(
|
111 |
+
'url' => $url,
|
112 |
+
'label' => Mage::helper('M2ePro')->__('Selling Format Policies'),
|
113 |
+
'target' => '_blank'
|
114 |
+
);
|
115 |
+
//------------------------------
|
116 |
+
|
117 |
+
//------------------------------
|
118 |
+
$url = $this->getUrl(
|
119 |
+
'*/adminhtml_common_template_synchronization/index',
|
120 |
+
array(
|
121 |
+
'filter' => $filter
|
122 |
+
)
|
123 |
+
);
|
124 |
+
$items[] = array(
|
125 |
+
'url' => $url,
|
126 |
+
'label' => Mage::helper('M2ePro')->__('Synchronization Policies'),
|
127 |
+
'target' => '_blank'
|
128 |
+
);
|
129 |
+
//------------------------------
|
130 |
+
|
131 |
+
return $items;
|
132 |
+
}
|
133 |
+
|
134 |
+
// ####################################
|
135 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Add/Form.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_Add_Form
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_Form
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
//------------------------------
|
16 |
+
$this->component = Ess_M2ePro_Helper_Component_Buy::NICK;
|
17 |
+
$this->setId('buyListingEditForm');
|
18 |
+
//------------------------------
|
19 |
+
}
|
20 |
+
|
21 |
+
// ########################################
|
22 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Add/Tabs/General.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_Add_Tabs_General
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_Tabs_General
|
9 |
+
{
|
10 |
+
// #############################################
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->sessionKey = 'buy_listing_create';
|
19 |
+
$this->setId('buyListingAddTabsGeneral');
|
20 |
+
$this->setTemplate('M2ePro/common/buy/listing/add/tabs/general.phtml');
|
21 |
+
//------------------------------
|
22 |
+
}
|
23 |
+
|
24 |
+
// #############################################
|
25 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Add/Tabs/Search.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_Add_Tabs_Search
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_Tabs_Search
|
9 |
+
{
|
10 |
+
// #############################################
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->sessionKey = 'buy_listing_create';
|
19 |
+
$this->setId('buyListingAddTabsGeneral');
|
20 |
+
$this->setTemplate('M2ePro/common/buy/listing/add/tabs/search.phtml');
|
21 |
+
//------------------------------
|
22 |
+
}
|
23 |
+
|
24 |
+
// #############################################
|
25 |
+
|
26 |
+
protected function getDefaults()
|
27 |
+
{
|
28 |
+
return self::getDefaultFieldsValues();
|
29 |
+
}
|
30 |
+
|
31 |
+
static function getDefaultFieldsValues()
|
32 |
+
{
|
33 |
+
return array(
|
34 |
+
'general_id_mode' => Ess_M2ePro_Model_Buy_Listing::GENERAL_ID_MODE_NOT_SET,
|
35 |
+
'general_id_custom_attribute' => '',
|
36 |
+
|
37 |
+
'search_by_magento_title_mode' => Ess_M2ePro_Model_Buy_Listing::SEARCH_BY_MAGENTO_TITLE_MODE_NONE
|
38 |
+
);
|
39 |
+
}
|
40 |
+
|
41 |
+
// #############################################
|
42 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Add/Tabs/Selling.php
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_Add_Tabs_Selling
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_Tabs_Selling
|
9 |
+
{
|
10 |
+
// #############################################
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->component = Ess_M2ePro_Helper_Component_Buy::NICK;
|
19 |
+
$this->sessionKey = 'buy_listing_create';
|
20 |
+
$this->setId('buyListingAddTabsSelling');
|
21 |
+
$this->setTemplate('M2ePro/common/buy/listing/add/tabs/selling.phtml');
|
22 |
+
//------------------------------
|
23 |
+
}
|
24 |
+
|
25 |
+
// #############################################
|
26 |
+
|
27 |
+
protected function _beforeToHtml()
|
28 |
+
{
|
29 |
+
$buttonBlock = $this->getLayout()
|
30 |
+
->createBlock('adminhtml/widget_button')
|
31 |
+
->setData( array(
|
32 |
+
'label' => Mage::helper('M2ePro')->__('Insert'),
|
33 |
+
'onclick' => "BuyListingChannelSettingsHandlerObj.appendToText"
|
34 |
+
."('condition_note_custom_attribute', 'condition_note_value');",
|
35 |
+
'class' => 'condition_note_value_insert_button'
|
36 |
+
) );
|
37 |
+
$this->setChild('condition_note_value_insert_button',$buttonBlock);
|
38 |
+
|
39 |
+
return parent::_beforeToHtml();
|
40 |
+
}
|
41 |
+
|
42 |
+
// #############################################
|
43 |
+
|
44 |
+
protected function getDefaults()
|
45 |
+
{
|
46 |
+
return self::getDefaultFieldsValues();
|
47 |
+
}
|
48 |
+
|
49 |
+
static function getDefaultFieldsValues()
|
50 |
+
{
|
51 |
+
return array(
|
52 |
+
'sku_mode' => Ess_M2ePro_Model_Buy_Listing::SKU_MODE_DEFAULT,
|
53 |
+
'sku_custom_attribute' => '',
|
54 |
+
'generate_sku_mode' => Ess_M2ePro_Model_Buy_Listing::GENERATE_SKU_MODE_NO,
|
55 |
+
|
56 |
+
'template_selling_format_id' => '',
|
57 |
+
'template_synchronization_id' => '',
|
58 |
+
|
59 |
+
'shipping_standard_mode' => Ess_M2ePro_Model_Buy_Listing::SHIPPING_MODE_DEFAULT,
|
60 |
+
'shipping_standard_value' => 0,
|
61 |
+
'shipping_standard_custom_attribute' => '',
|
62 |
+
|
63 |
+
'shipping_expedited_mode' => Ess_M2ePro_Model_Buy_Listing::SHIPPING_MODE_DEFAULT,
|
64 |
+
'shipping_expedited_value' => 0,
|
65 |
+
'shipping_expedited_custom_attribute' => '',
|
66 |
+
|
67 |
+
'shipping_two_day_mode' => Ess_M2ePro_Model_Buy_Listing::SHIPPING_MODE_DEFAULT,
|
68 |
+
'shipping_two_day_value' => 0,
|
69 |
+
'shipping_two_day_custom_attribute' => '',
|
70 |
+
|
71 |
+
'shipping_one_day_mode' => Ess_M2ePro_Model_Buy_Listing::SHIPPING_MODE_DEFAULT,
|
72 |
+
'shipping_one_day_value' => 0,
|
73 |
+
'shipping_one_day_custom_attribute' => '',
|
74 |
+
|
75 |
+
'condition_mode' => Ess_M2ePro_Model_Buy_Listing::CONDITION_MODE_DEFAULT,
|
76 |
+
'condition_value' => Ess_M2ePro_Model_Buy_Listing::CONDITION_NEW,
|
77 |
+
'condition_custom_attribute' => '',
|
78 |
+
'condition_note_mode' => Ess_M2ePro_Model_Buy_Listing::CONDITION_NOTE_MODE_NONE,
|
79 |
+
'condition_note_value' => ''
|
80 |
+
);
|
81 |
+
}
|
82 |
+
|
83 |
+
// ####################################
|
84 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/AutoAction/Mode.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2011 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_AutoAction_Mode
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Listing_AutoAction_Mode
|
9 |
+
{
|
10 |
+
|
11 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/AutoAction/Mode/Category.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2011 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_AutoAction_Mode_Category
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Listing_AutoAction_Mode_Category
|
9 |
+
{
|
10 |
+
// ####################################
|
11 |
+
|
12 |
+
protected function prepareGroupsGrid()
|
13 |
+
{
|
14 |
+
$groupGrid = $this->getLayout()
|
15 |
+
->createBlock('M2ePro/adminhtml_common_buy_listing_autoAction_mode_category_group_grid');
|
16 |
+
$groupGrid->prepareGrid();
|
17 |
+
$this->setChild('group_grid', $groupGrid);
|
18 |
+
|
19 |
+
return $groupGrid;
|
20 |
+
}
|
21 |
+
|
22 |
+
// ####################################
|
23 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/AutoAction/Mode/Category/Form.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2011 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_AutoAction_Mode_Category_Form
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Listing_AutoAction_Mode_Category_Form
|
9 |
+
{
|
10 |
+
|
11 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/AutoAction/Mode/Category/Group/Grid.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_AutoAction_Mode_Category_Group_Grid
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Listing_AutoAction_Mode_Category_Group_Grid
|
9 |
+
{
|
10 |
+
|
11 |
+
public function getGridUrl()
|
12 |
+
{
|
13 |
+
return $this->getUrl('*/adminhtml_common_listing_autoAction/getCategoryGroupGrid', array('_current' => true));
|
14 |
+
}
|
15 |
+
|
16 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/AutoAction/Mode/Global.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2011 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_AutoAction_Mode_Global
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Listing_AutoAction_Mode_Global
|
9 |
+
{
|
10 |
+
|
11 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/AutoAction/Mode/Website.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2011 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_AutoAction_Mode_Website
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Listing_AutoAction_Mode_Website
|
9 |
+
{
|
10 |
+
|
11 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Edit.php
ADDED
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
8 |
+
{
|
9 |
+
|
10 |
+
// ####################################
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->setId('buyListingEdit');
|
19 |
+
$this->_blockGroup = 'M2ePro';
|
20 |
+
$this->_controller = 'adminhtml_common_buy_listing';
|
21 |
+
$this->_mode = 'edit';
|
22 |
+
//------------------------------
|
23 |
+
|
24 |
+
// Set header text
|
25 |
+
//------------------------------
|
26 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
27 |
+
|
28 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
29 |
+
$headerText = Mage::helper('M2ePro')->__(
|
30 |
+
'Edit %component_name% Listing Settings "%listing_title%"',
|
31 |
+
Mage::helper('M2ePro/Component_Buy')->getTitle(),
|
32 |
+
$this->escapeHtml($listingData['title'])
|
33 |
+
);
|
34 |
+
} else {
|
35 |
+
$headerText =Mage::helper('M2ePro')->__(
|
36 |
+
'Edit Listing Settings "%listing_title%"',
|
37 |
+
$this->escapeHtml($listingData['title'])
|
38 |
+
);
|
39 |
+
}
|
40 |
+
|
41 |
+
$this->_headerText = $headerText;
|
42 |
+
//------------------------------
|
43 |
+
|
44 |
+
// Set buttons actions
|
45 |
+
//------------------------------
|
46 |
+
$this->removeButton('back');
|
47 |
+
$this->removeButton('reset');
|
48 |
+
$this->removeButton('delete');
|
49 |
+
$this->removeButton('add');
|
50 |
+
$this->removeButton('save');
|
51 |
+
$this->removeButton('edit');
|
52 |
+
//------------------------------
|
53 |
+
|
54 |
+
if (!is_null($this->getRequest()->getParam('back'))) {
|
55 |
+
//------------------------------
|
56 |
+
$url = Mage::helper('M2ePro')->getBackUrl(
|
57 |
+
'*/adminhtml_common_listing/index',
|
58 |
+
array(
|
59 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_BUY
|
60 |
+
)
|
61 |
+
);
|
62 |
+
$this->_addButton('back', array(
|
63 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
64 |
+
'onclick' => 'CommonListingSettingsHandlerObj.back_click(\''.$url.'\')',
|
65 |
+
'class' => 'back'
|
66 |
+
));
|
67 |
+
//------------------------------
|
68 |
+
}
|
69 |
+
|
70 |
+
//------------------------------
|
71 |
+
$this->_addButton('auto_action', array(
|
72 |
+
'label' => Mage::helper('M2ePro')->__('Auto Add/Remove Rules'),
|
73 |
+
'onclick' => 'ListingAutoActionHandlerObj.loadAutoActionHtml();'
|
74 |
+
));
|
75 |
+
//------------------------------
|
76 |
+
|
77 |
+
$backUrl = Mage::helper('M2ePro')->getBackUrlParam('list');
|
78 |
+
|
79 |
+
//------------------------------
|
80 |
+
$url = $this->getUrl(
|
81 |
+
'*/adminhtml_common_buy_listing/save',
|
82 |
+
array(
|
83 |
+
'id' => $listingData['id'],
|
84 |
+
'back' => Mage::helper('M2ePro')->getBackUrlParam('list')
|
85 |
+
)
|
86 |
+
);
|
87 |
+
$this->_addButton('save', array(
|
88 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
89 |
+
'onclick' => 'CommonListingSettingsHandlerObj.save_click(\'' . $url . '\')',
|
90 |
+
'class' => 'save'
|
91 |
+
));
|
92 |
+
//------------------------------
|
93 |
+
|
94 |
+
//------------------------------
|
95 |
+
$this->_addButton('save_and_continue', array(
|
96 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
97 |
+
'onclick' => 'CommonListingSettingsHandlerObj.save_and_edit_click(\''.$url.'\', 1)',
|
98 |
+
'class' => 'save'
|
99 |
+
));
|
100 |
+
//------------------------------
|
101 |
+
}
|
102 |
+
|
103 |
+
// ####################################
|
104 |
+
|
105 |
+
protected function _beforeToHtml()
|
106 |
+
{
|
107 |
+
parent::_beforeToHtml();
|
108 |
+
|
109 |
+
//------------------------------
|
110 |
+
$tabs = $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_listing_edit_tabs');
|
111 |
+
$this->setChild('tabs', $tabs);
|
112 |
+
//------------------------------
|
113 |
+
|
114 |
+
return $this;
|
115 |
+
}
|
116 |
+
|
117 |
+
// ####################################
|
118 |
+
|
119 |
+
public function getFormHtml()
|
120 |
+
{
|
121 |
+
$listing = Mage::helper('M2ePro/Component_Buy')->getCachedObject(
|
122 |
+
'Listing', $this->getRequest()->getParam('id')
|
123 |
+
);
|
124 |
+
|
125 |
+
$viewHeaderBlock = $this->getLayout()->createBlock(
|
126 |
+
'M2ePro/adminhtml_listing_view_header','',
|
127 |
+
array('listing' => $listing)
|
128 |
+
);
|
129 |
+
|
130 |
+
$tabs = $this->getChild('tabs');
|
131 |
+
|
132 |
+
$urls = Mage::helper('M2ePro')->getControllerActions(
|
133 |
+
'adminhtml_common_listing_autoAction',
|
134 |
+
array(
|
135 |
+
'listing_id' => $this->getRequest()->getParam('id'),
|
136 |
+
'component' => Ess_M2ePro_Helper_Component_Buy::NICK
|
137 |
+
)
|
138 |
+
);
|
139 |
+
$urls = json_encode($urls);
|
140 |
+
|
141 |
+
/** @var $helper Ess_M2ePro_Helper_Data */
|
142 |
+
$helper = Mage::helper('M2ePro');
|
143 |
+
|
144 |
+
$translations = json_encode(array(
|
145 |
+
'Auto Add/Remove Rules' => $helper->__('Auto Add/Remove Rules'),
|
146 |
+
'Based on Magento Categories' => $helper->__('Based on Magento Categories'),
|
147 |
+
'You must select at least 1 Category.' => $helper->__('You must select at least 1 Category.'),
|
148 |
+
'Rule with the same Title already exists.' => $helper->__('Rule with the same Title already exists.')
|
149 |
+
));
|
150 |
+
|
151 |
+
$js = <<<HTML
|
152 |
+
<script type="text/javascript">
|
153 |
+
|
154 |
+
M2ePro.url.add({$urls});
|
155 |
+
M2ePro.translator.add({$translations});
|
156 |
+
|
157 |
+
ListingAutoActionHandlerObj = new ListingAutoActionHandler();
|
158 |
+
|
159 |
+
</script>
|
160 |
+
HTML;
|
161 |
+
|
162 |
+
return $viewHeaderBlock->toHtml() . $tabs->toHtml() . parent::getFormHtml() . $js;
|
163 |
+
}
|
164 |
+
|
165 |
+
// ####################################
|
166 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Edit/Form.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingEditForm');
|
16 |
+
//------------------------------
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _prepareForm()
|
20 |
+
{
|
21 |
+
$form = new Varien_Data_Form(array(
|
22 |
+
'id' => 'edit_form',
|
23 |
+
'action' => $this->getUrl('*/adminhtml_common_buy_listing/save'),
|
24 |
+
'method' => 'post',
|
25 |
+
'enctype' => 'multipart/form-data'
|
26 |
+
));
|
27 |
+
|
28 |
+
$form->setUseContainer(true);
|
29 |
+
$this->setForm($form);
|
30 |
+
|
31 |
+
return parent::_prepareForm();
|
32 |
+
}
|
33 |
+
|
34 |
+
// ####################################
|
35 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Edit/Tabs.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingEditTabs');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('widget/tabshoriz.phtml');
|
19 |
+
$this->setDestElementId('edit_form');
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _beforeToHtml()
|
23 |
+
{
|
24 |
+
$this->addTab('selling', array(
|
25 |
+
'label' => Mage::helper('M2ePro')->__('Selling Settings'),
|
26 |
+
'title' => Mage::helper('M2ePro')->__('Selling Settings'),
|
27 |
+
'content' => $this->getLayout()
|
28 |
+
->createBlock('M2ePro/adminhtml_common_buy_listing_add_tabs_selling')
|
29 |
+
->toHtml(),
|
30 |
+
));
|
31 |
+
|
32 |
+
$this->addTab('search', array(
|
33 |
+
'label' => Mage::helper('M2ePro')->__('Search Settings'),
|
34 |
+
'title' => Mage::helper('M2ePro')->__('Search Settings'),
|
35 |
+
'content' => $this->getLayout()
|
36 |
+
->createBlock('M2ePro/adminhtml_common_buy_listing_add_tabs_search')
|
37 |
+
->toHtml(),
|
38 |
+
));
|
39 |
+
|
40 |
+
$this->setActiveTab($this->getRequest()->getParam('tab', 'selling'));
|
41 |
+
|
42 |
+
return parent::_beforeToHtml();
|
43 |
+
}
|
44 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Filter.php
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_Filter extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingFilter');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/buy/listing/filter.phtml');
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _beforeToHtml()
|
22 |
+
{
|
23 |
+
//-------------------------------
|
24 |
+
$maxRecordsQuantity = Mage::helper('M2ePro/View_Common')->getAutocompleteMaxItems();
|
25 |
+
//-------------------------------
|
26 |
+
|
27 |
+
//-------------------------------
|
28 |
+
$this->selectedSellingFormatTemplate = (int)$this->getRequest()
|
29 |
+
->getParam('filter_buy_selling_format_template');
|
30 |
+
$sellingFormatTemplatesCollection = Mage::helper('M2ePro/Component_Buy')
|
31 |
+
->getCollection('Template_SellingFormat')
|
32 |
+
->setOrder('title', 'ASC');
|
33 |
+
|
34 |
+
if ($sellingFormatTemplatesCollection->getSize() < $maxRecordsQuantity) {
|
35 |
+
$this->sellingFormatTemplatesDropDown = true;
|
36 |
+
$sellingFormatTemplates = array();
|
37 |
+
|
38 |
+
foreach ($sellingFormatTemplatesCollection->getItems() as $item) {
|
39 |
+
$sellingFormatTemplates[$item->getId()] = Mage::helper('M2ePro')->escapeHtml($item->getTitle());
|
40 |
+
}
|
41 |
+
$this->sellingFormatTemplates = $sellingFormatTemplates;
|
42 |
+
} else {
|
43 |
+
$this->sellingFormatTemplatesDropDown = false;
|
44 |
+
$this->sellingFormatTemplates = array();
|
45 |
+
|
46 |
+
if ($this->selectedSellingFormatTemplate > 0) {
|
47 |
+
$this->selectedSellingFormatTemplateValue = Mage::helper('M2ePro/Component_Buy')
|
48 |
+
->getCachedObject('Template_SellingFormat',
|
49 |
+
$this->selectedSellingFormatTemplate, NULL,
|
50 |
+
array('template'))
|
51 |
+
->getTitle();
|
52 |
+
} else {
|
53 |
+
$this->selectedSellingFormatTemplateValue = '';
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
$this->sellingFormatTemplateUrl = $this->makeCutUrlForTemplate('filter_buy_selling_format_template');
|
58 |
+
//-------------------------------
|
59 |
+
|
60 |
+
//-------------------------------
|
61 |
+
$this->selectedSynchronizationTemplate = (int)$this->getRequest()
|
62 |
+
->getParam('filter_buy_synchronization_template');
|
63 |
+
$synchronizationsTemplatesCollection = Mage::helper('M2ePro/Component_Buy')
|
64 |
+
->getCollection('Template_Synchronization')
|
65 |
+
->setOrder('title', 'ASC');
|
66 |
+
|
67 |
+
if ($synchronizationsTemplatesCollection->getSize() < $maxRecordsQuantity) {
|
68 |
+
$this->synchronizationsTemplatesDropDown = true;
|
69 |
+
$synchronizationsTemplates = array();
|
70 |
+
|
71 |
+
foreach ($synchronizationsTemplatesCollection->getItems() as $item) {
|
72 |
+
$synchronizationsTemplates[$item->getId()] = Mage::helper('M2ePro')->escapeHtml($item->getTitle());
|
73 |
+
}
|
74 |
+
$this->synchronizationsTemplates = $synchronizationsTemplates;
|
75 |
+
} else {
|
76 |
+
$this->synchronizationsTemplatesDropDown = false;
|
77 |
+
$this->synchronizationsTemplates = array();
|
78 |
+
|
79 |
+
if ($this->selectedSynchronizationTemplate > 0) {
|
80 |
+
$this->selectedSynchronizationTemplateValue = Mage::helper('M2ePro/Component_Buy')
|
81 |
+
->getCachedObject('Template_Synchronization',
|
82 |
+
$this->selectedSynchronizationTemplate, NULL,
|
83 |
+
array('template'))
|
84 |
+
->getTitle();
|
85 |
+
} else {
|
86 |
+
$this->selectedSynchronizationTemplateValue = '';
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
$this->synchronizationTemplateUrl = $this->makeCutUrlForTemplate('filter_buy_synchronization_template');
|
91 |
+
//-------------------------------
|
92 |
+
|
93 |
+
return parent::_beforeToHtml();
|
94 |
+
}
|
95 |
+
|
96 |
+
protected function makeCutUrlForTemplate($templateUrlParamName)
|
97 |
+
{
|
98 |
+
$paramsFilters = array(
|
99 |
+
'filter_buy_selling_format_template',
|
100 |
+
'filter_buy_synchronization_template'
|
101 |
+
);
|
102 |
+
|
103 |
+
$params = array();
|
104 |
+
foreach ($paramsFilters as $value) {
|
105 |
+
if ($value != $templateUrlParamName) {
|
106 |
+
$params[$value] = $this->getRequest()->getParam($value);
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
$params['tab'] = Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_BUY;
|
111 |
+
|
112 |
+
return $this->getUrl('*/adminhtml_common_listing/*',$params);
|
113 |
+
}
|
114 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Grid.php
ADDED
@@ -0,0 +1,320 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_Grid extends Ess_M2ePro_Block_Adminhtml_Listing_Grid
|
8 |
+
{
|
9 |
+
// ########################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('buyListingGrid');
|
18 |
+
//------------------------------
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _prepareCollection()
|
22 |
+
{
|
23 |
+
// Update statistic table values
|
24 |
+
Mage::getResourceModel('M2ePro/Listing')->updateStatisticColumns();
|
25 |
+
Mage::getResourceModel('M2ePro/Buy_Listing')->updateStatisticColumns();
|
26 |
+
|
27 |
+
// Get collection of listings
|
28 |
+
$collection = Mage::helper('M2ePro/Component_Buy')->getCollection('Listing');
|
29 |
+
|
30 |
+
// Set global filters
|
31 |
+
//--------------------------
|
32 |
+
$filterSellingFormatTemplate = $this->getRequest()->getParam('filter_buy_selling_format_template');
|
33 |
+
$filterSynchronizationTemplate = $this->getRequest()->getParam('filter_buy_synchronization_template');
|
34 |
+
|
35 |
+
if ($filterSellingFormatTemplate != 0) {
|
36 |
+
$collection->addFieldToFilter(
|
37 |
+
'second_table.template_selling_format_id', (int)$filterSellingFormatTemplate
|
38 |
+
);
|
39 |
+
}
|
40 |
+
|
41 |
+
if ($filterSynchronizationTemplate != 0) {
|
42 |
+
$collection->addFieldToFilter(
|
43 |
+
'second_table.template_synchronization_id', (int)$filterSynchronizationTemplate
|
44 |
+
);
|
45 |
+
}
|
46 |
+
//--------------------------
|
47 |
+
|
48 |
+
// join accounts
|
49 |
+
//--------------------------
|
50 |
+
$collection->getSelect()
|
51 |
+
->join(array('a'=>Mage::getResourceModel('M2ePro/Account')->getMainTable()),
|
52 |
+
'(`a`.`id` = `main_table`.`account_id`)',
|
53 |
+
array('account_title'=>'title'));
|
54 |
+
//--------------------------
|
55 |
+
|
56 |
+
//exit($collection->getSelect()->__toString());
|
57 |
+
|
58 |
+
// Set collection to grid
|
59 |
+
$this->setCollection($collection);
|
60 |
+
|
61 |
+
return parent::_prepareCollection();
|
62 |
+
}
|
63 |
+
|
64 |
+
// ####################################
|
65 |
+
|
66 |
+
protected function _prepareMassaction()
|
67 |
+
{
|
68 |
+
// Set massaction identifiers
|
69 |
+
//--------------------------------
|
70 |
+
$this->setMassactionIdField('main_table.id');
|
71 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
72 |
+
//--------------------------------
|
73 |
+
|
74 |
+
// Set clear log action
|
75 |
+
//--------------------------------
|
76 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
77 |
+
'*/adminhtml_common_listing/index',
|
78 |
+
array(
|
79 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_BUY
|
80 |
+
)
|
81 |
+
);
|
82 |
+
|
83 |
+
$this->getMassactionBlock()->addItem('clear_logs', array(
|
84 |
+
'label' => Mage::helper('M2ePro')->__('Clear Log(s)'),
|
85 |
+
'url' => $this->getUrl('*/adminhtml_listing/clearLog', array('back' => $backUrl)),
|
86 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
87 |
+
));
|
88 |
+
//--------------------------------
|
89 |
+
|
90 |
+
// Set remove listings action
|
91 |
+
//--------------------------------
|
92 |
+
$this->getMassactionBlock()->addItem('delete_listings', array(
|
93 |
+
'label' => Mage::helper('M2ePro')->__('Delete Listing(s)'),
|
94 |
+
'url' => $this->getUrl('*/adminhtml_common_buy_listing/delete'),
|
95 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
96 |
+
));
|
97 |
+
//--------------------------------
|
98 |
+
|
99 |
+
return parent::_prepareMassaction();
|
100 |
+
}
|
101 |
+
|
102 |
+
// ####################################
|
103 |
+
|
104 |
+
protected function getColumnActionsItems()
|
105 |
+
{
|
106 |
+
$helper = Mage::helper('M2ePro');
|
107 |
+
$backUrl = $helper->makeBackUrlParam(
|
108 |
+
'*/adminhtml_common_listing/index',
|
109 |
+
array(
|
110 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_BUY
|
111 |
+
)
|
112 |
+
);
|
113 |
+
|
114 |
+
$actions = array(
|
115 |
+
'manageProducts' => array(
|
116 |
+
'caption' => $helper->__('Manage'),
|
117 |
+
'group' => 'products_actions',
|
118 |
+
'field' => 'id',
|
119 |
+
'url' => array(
|
120 |
+
'base' => '*/adminhtml_common_buy_listing/view',
|
121 |
+
'params' => array('back' => $backUrl)
|
122 |
+
)
|
123 |
+
),
|
124 |
+
|
125 |
+
'addProductsFromProductsList' => array(
|
126 |
+
'caption' => $helper->__('Add From Products List'),
|
127 |
+
'group' => 'products_actions',
|
128 |
+
'field' => 'id',
|
129 |
+
'url' => array(
|
130 |
+
'base' => '*/adminhtml_common_listing_productAdd/index',
|
131 |
+
'params' => array(
|
132 |
+
'back' => $backUrl,
|
133 |
+
'component' => Ess_M2ePro_Helper_Component_Buy::NICK,
|
134 |
+
'step' => 2,
|
135 |
+
'source' => Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_SourceMode::SOURCE_LIST
|
136 |
+
)
|
137 |
+
)
|
138 |
+
),
|
139 |
+
|
140 |
+
'addProductsFromCategories' => array(
|
141 |
+
'caption' => $helper->__('Add From Categories'),
|
142 |
+
'group' => 'products_actions',
|
143 |
+
'field' => 'id',
|
144 |
+
'url' => array(
|
145 |
+
'base' => '*/adminhtml_common_listing_productAdd/index',
|
146 |
+
'params' => array(
|
147 |
+
'back' => $backUrl,
|
148 |
+
'component' => Ess_M2ePro_Helper_Component_Buy::NICK,
|
149 |
+
'step' => 2,
|
150 |
+
'source' => Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_SourceMode::SOURCE_CATEGORIES
|
151 |
+
)
|
152 |
+
)
|
153 |
+
),
|
154 |
+
|
155 |
+
'automaticActions' => array(
|
156 |
+
'caption' => $helper->__('Auto Add/Remove Rules'),
|
157 |
+
'group' => 'products_actions',
|
158 |
+
'field' => 'id',
|
159 |
+
'url' => array(
|
160 |
+
'base' => '*/adminhtml_common_buy_listing/view',
|
161 |
+
'params' => array(
|
162 |
+
'back' => $backUrl,
|
163 |
+
'auto_actions' => 1
|
164 |
+
)
|
165 |
+
)
|
166 |
+
),
|
167 |
+
|
168 |
+
'viewLog' => array(
|
169 |
+
'caption' => $helper->__('View Log'),
|
170 |
+
'group' => 'other',
|
171 |
+
'field' => 'id',
|
172 |
+
'url' => array(
|
173 |
+
'base' => '*/adminhtml_common_log/listing',
|
174 |
+
'params' => array(
|
175 |
+
'back' => $backUrl,
|
176 |
+
'channel' => Ess_M2ePro_Block_Adminhtml_Common_Log_Tabs::TAB_ID_BUY
|
177 |
+
)
|
178 |
+
)
|
179 |
+
),
|
180 |
+
|
181 |
+
'clearLogs' => array(
|
182 |
+
'caption' => $helper->__('Clear Log'),
|
183 |
+
'confirm' => $helper->__('Are you sure?'),
|
184 |
+
'group' => 'other',
|
185 |
+
'field' => 'id',
|
186 |
+
'url' => array(
|
187 |
+
'base' => '*/adminhtml_listing/clearLog',
|
188 |
+
'params' => array(
|
189 |
+
'back' => $backUrl
|
190 |
+
)
|
191 |
+
)
|
192 |
+
),
|
193 |
+
|
194 |
+
'deleteListing' => array(
|
195 |
+
'caption' => $helper->__('Delete Listing'),
|
196 |
+
'confirm' => $helper->__('Are you sure?'),
|
197 |
+
'group' => 'other',
|
198 |
+
'field' => 'id',
|
199 |
+
'url' => array(
|
200 |
+
'base' => '*/adminhtml_common_buy_listing/delete',
|
201 |
+
)
|
202 |
+
),
|
203 |
+
|
204 |
+
'editListingTitle' => array(
|
205 |
+
'caption' => $helper->__('Title'),
|
206 |
+
'group' => 'edit_actions',
|
207 |
+
'confirm' => $helper->__('Are you sure?'),
|
208 |
+
'field' => 'id',
|
209 |
+
'onclick_action' => 'editListingTitle'
|
210 |
+
),
|
211 |
+
|
212 |
+
'sellingSetting' => array(
|
213 |
+
'caption' => $helper->__('Selling'),
|
214 |
+
'group' => 'edit_actions',
|
215 |
+
'field' => 'id',
|
216 |
+
'url' => array(
|
217 |
+
'base' => '*/adminhtml_common_buy_listing/edit',
|
218 |
+
'params' => array(
|
219 |
+
'back' => $backUrl,
|
220 |
+
'tab' => 'selling'
|
221 |
+
)
|
222 |
+
)
|
223 |
+
),
|
224 |
+
|
225 |
+
'searchSetting' => array(
|
226 |
+
'caption' => $helper->__('Search'),
|
227 |
+
'group' => 'edit_actions',
|
228 |
+
'field' => 'id',
|
229 |
+
'url' => array(
|
230 |
+
'base' => '*/adminhtml_common_buy_listing/edit',
|
231 |
+
'params' => array(
|
232 |
+
'back' => $backUrl,
|
233 |
+
'tab' => 'search'
|
234 |
+
)
|
235 |
+
)
|
236 |
+
)
|
237 |
+
);
|
238 |
+
|
239 |
+
return $actions;
|
240 |
+
}
|
241 |
+
|
242 |
+
// ####################################
|
243 |
+
|
244 |
+
public function callbackColumnSoldProducts($value, $row, $column, $isExport)
|
245 |
+
{
|
246 |
+
return $this->getColumnValue($value);
|
247 |
+
}
|
248 |
+
|
249 |
+
public function callbackColumnTitle($value, $row, $column, $isExport)
|
250 |
+
{
|
251 |
+
$value = '<span id="listing_title_'.$row->getId().'">' .
|
252 |
+
Mage::helper('M2ePro')->escapeHtml($value) .
|
253 |
+
'</span>';
|
254 |
+
|
255 |
+
/* @var $row Ess_M2ePro_Model_Listing */
|
256 |
+
$accountTitle = $row->getData('account_title');
|
257 |
+
|
258 |
+
$storeModel = Mage::getModel('core/store')->load($row->getStoreId());
|
259 |
+
$storeView = $storeModel->getWebsite()->getName();
|
260 |
+
if (strtolower($storeView) != 'admin') {
|
261 |
+
$storeView .= ' > '.$storeModel->getGroup()->getName();
|
262 |
+
$storeView .= ' > '.$storeModel->getName();
|
263 |
+
} else {
|
264 |
+
$storeView = Mage::helper('M2ePro')->__('Admin (Default Values)');
|
265 |
+
}
|
266 |
+
|
267 |
+
$account = Mage::helper('M2ePro')->__('Account');
|
268 |
+
$store = Mage::helper('M2ePro')->__('Magento Store View');
|
269 |
+
|
270 |
+
$value .= <<<HTML
|
271 |
+
<div>
|
272 |
+
<span style="font-weight: bold">{$account}</span>: <span style="color: #505050">{$accountTitle}</span><br/>
|
273 |
+
<span style="font-weight: bold">{$store}</span>: <span style="color: #505050">{$storeView}</span>
|
274 |
+
</div>
|
275 |
+
HTML;
|
276 |
+
|
277 |
+
return $value;
|
278 |
+
}
|
279 |
+
|
280 |
+
// ####################################
|
281 |
+
|
282 |
+
protected function callbackFilterTitle($collection, $column)
|
283 |
+
{
|
284 |
+
$value = $column->getFilter()->getValue();
|
285 |
+
|
286 |
+
if ($value == null) {
|
287 |
+
return;
|
288 |
+
}
|
289 |
+
|
290 |
+
$where = "main_table.title LIKE '%{$value}%' OR a.title LIKE '%{$value}%'";
|
291 |
+
$collection->getSelect()->where($where);
|
292 |
+
}
|
293 |
+
|
294 |
+
// ####################################
|
295 |
+
|
296 |
+
public function getGridUrl()
|
297 |
+
{
|
298 |
+
return $this->getUrl('*/adminhtml_common_buy_listing/listingGrid', array('_current'=>true));
|
299 |
+
}
|
300 |
+
|
301 |
+
public function getRowUrl($row)
|
302 |
+
{
|
303 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
304 |
+
'*/adminhtml_common_listing/index',
|
305 |
+
array(
|
306 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_BUY
|
307 |
+
)
|
308 |
+
);
|
309 |
+
|
310 |
+
return $this->getUrl(
|
311 |
+
'*/adminhtml_common_buy_listing/view',
|
312 |
+
array(
|
313 |
+
'id' => $row->getId(),
|
314 |
+
'back' => $backUrl
|
315 |
+
)
|
316 |
+
);
|
317 |
+
}
|
318 |
+
|
319 |
+
// ####################################
|
320 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Other/Grid.php
ADDED
@@ -0,0 +1,530 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_Other_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
// ####################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
/** @var $this->connRead Varien_Db_Adapter_Pdo_Mysql */
|
16 |
+
$this->connRead = Mage::getSingleton('core/resource')->getConnection('core_read');
|
17 |
+
|
18 |
+
// Initialization block
|
19 |
+
//------------------------------
|
20 |
+
$this->setId('buyListingOtherGrid');
|
21 |
+
//------------------------------
|
22 |
+
|
23 |
+
// Set default values
|
24 |
+
//------------------------------
|
25 |
+
$this->setDefaultSort('id');
|
26 |
+
$this->setDefaultDir('DESC');
|
27 |
+
$this->setSaveParametersInSession(true);
|
28 |
+
$this->setUseAjax(true);
|
29 |
+
//------------------------------
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getMassactionBlockName()
|
33 |
+
{
|
34 |
+
return 'M2ePro/adminhtml_grid_massaction';
|
35 |
+
}
|
36 |
+
|
37 |
+
// ####################################
|
38 |
+
|
39 |
+
protected function _prepareCollection()
|
40 |
+
{
|
41 |
+
$collection = Mage::helper('M2ePro/Component_Buy')->getCollection('Listing_Other');
|
42 |
+
|
43 |
+
$collection->getSelect()->joinLeft(
|
44 |
+
array('mp' => Mage::getResourceModel('M2ePro/Marketplace')->getMainTable()),
|
45 |
+
'mp.id = main_table.marketplace_id',
|
46 |
+
array('marketplace_title' => 'mp.title')
|
47 |
+
);
|
48 |
+
|
49 |
+
// Add Filter By Account
|
50 |
+
$accountFilter = $this->getRequest()->getParam('buyAccount');
|
51 |
+
if (!empty($accountFilter)) {
|
52 |
+
$collection->addFieldToFilter('account_id', $accountFilter);
|
53 |
+
}
|
54 |
+
|
55 |
+
//var_dump($collection->getSelect()->__toString()); exit();
|
56 |
+
|
57 |
+
$this->setCollection($collection);
|
58 |
+
|
59 |
+
return parent::_prepareCollection();
|
60 |
+
}
|
61 |
+
|
62 |
+
protected function _prepareColumns()
|
63 |
+
{
|
64 |
+
$this->addColumn('product_id', array(
|
65 |
+
'header' => Mage::helper('M2ePro')->__('Product ID'),
|
66 |
+
'align' => 'left',
|
67 |
+
'width' => '80px',
|
68 |
+
'type' => 'number',
|
69 |
+
'index' => 'product_id',
|
70 |
+
'filter_index' => 'product_id',
|
71 |
+
'frame_callback' => array($this, 'callbackColumnProductId')
|
72 |
+
));
|
73 |
+
|
74 |
+
$this->addColumn('title', array(
|
75 |
+
'header' => Mage::helper('M2ePro')->__('Title / Reference ID'),
|
76 |
+
'align' => 'left',
|
77 |
+
'type' => 'text',
|
78 |
+
'index' => 'title',
|
79 |
+
'filter_index' => 'second_table.title',
|
80 |
+
'frame_callback' => array($this, 'callbackColumnProductTitle'),
|
81 |
+
'filter_condition_callback' => array($this, 'callbackFilterTitle')
|
82 |
+
));
|
83 |
+
|
84 |
+
$this->addColumn('general_id', array(
|
85 |
+
'header' => Mage::helper('M2ePro')->__('Rakuten.com SKU'),
|
86 |
+
'align' => 'left',
|
87 |
+
'width' => '100px',
|
88 |
+
'type' => 'text',
|
89 |
+
'index' => 'general_id',
|
90 |
+
'filter_index' => 'general_id',
|
91 |
+
'frame_callback' => array($this, 'callbackColumnGeneralId')
|
92 |
+
));
|
93 |
+
|
94 |
+
$this->addColumn('online_qty', array(
|
95 |
+
'header' => Mage::helper('M2ePro')->__('QTY'),
|
96 |
+
'align' => 'right',
|
97 |
+
'width' => '100px',
|
98 |
+
'type' => 'number',
|
99 |
+
'index' => 'online_qty',
|
100 |
+
'filter_index' => 'online_qty',
|
101 |
+
'frame_callback' => array($this, 'callbackColumnAvailableQty')
|
102 |
+
));
|
103 |
+
|
104 |
+
$this->addColumn('online_price', array(
|
105 |
+
'header' => Mage::helper('M2ePro')->__('Price'),
|
106 |
+
'align' => 'right',
|
107 |
+
'width' => '100px',
|
108 |
+
'type' => 'number',
|
109 |
+
'index' => 'online_price',
|
110 |
+
'filter_index' => 'online_price',
|
111 |
+
'frame_callback' => array($this, 'callbackColumnPrice')
|
112 |
+
));
|
113 |
+
|
114 |
+
$this->addColumn('status', array(
|
115 |
+
'header' => Mage::helper('M2ePro')->__('Status'),
|
116 |
+
'width' => '60px',
|
117 |
+
'index' => 'status',
|
118 |
+
'filter_index' => 'main_table.status',
|
119 |
+
'type' => 'options',
|
120 |
+
'sortable' => false,
|
121 |
+
'options' => array(
|
122 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_LISTED => Mage::helper('M2ePro')->__('Active'),
|
123 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED => Mage::helper('M2ePro')->__('Inactive')
|
124 |
+
),
|
125 |
+
'frame_callback' => array($this, 'callbackColumnStatus')
|
126 |
+
));
|
127 |
+
|
128 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
129 |
+
'*/adminhtml_common_listing_other/index',
|
130 |
+
array(
|
131 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_BUY
|
132 |
+
)
|
133 |
+
);
|
134 |
+
|
135 |
+
$this->addColumn('actions', array(
|
136 |
+
'header' => Mage::helper('M2ePro')->__('Actions'),
|
137 |
+
'align' => 'left',
|
138 |
+
'width' => '70px',
|
139 |
+
'type' => 'action',
|
140 |
+
'index' => 'actions',
|
141 |
+
'filter' => false,
|
142 |
+
'sortable' => false,
|
143 |
+
'getter' => 'getId',
|
144 |
+
'actions' => array(
|
145 |
+
array(
|
146 |
+
'caption' => Mage::helper('M2ePro')->__('View Log'),
|
147 |
+
'field' => 'id',
|
148 |
+
'url' => array(
|
149 |
+
'base' => '*/adminhtml_common_log/listingOther',
|
150 |
+
'params' => array(
|
151 |
+
'back' => $backUrl,
|
152 |
+
'channel' => Ess_M2ePro_Helper_Component_Buy::NICK
|
153 |
+
)
|
154 |
+
)
|
155 |
+
),
|
156 |
+
array(
|
157 |
+
'caption' => Mage::helper('M2ePro')->__('Clear Log'),
|
158 |
+
'url' => array(
|
159 |
+
'base' => '*/adminhtml_listing_other/clearLog',
|
160 |
+
'params' => array(
|
161 |
+
'back' => $backUrl
|
162 |
+
)
|
163 |
+
),
|
164 |
+
'field' => 'id',
|
165 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
166 |
+
)
|
167 |
+
)
|
168 |
+
));
|
169 |
+
|
170 |
+
return parent::_prepareColumns();
|
171 |
+
}
|
172 |
+
|
173 |
+
protected function _prepareMassaction()
|
174 |
+
{
|
175 |
+
// Set mass-action identifiers
|
176 |
+
//--------------------------------
|
177 |
+
$this->setMassactionIdField('`main_table`.id');
|
178 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
179 |
+
//--------------------------------
|
180 |
+
|
181 |
+
$this->getMassactionBlock()->setGroups(array(
|
182 |
+
'mapping' => Mage::helper('M2ePro')->__('Mapping'),
|
183 |
+
'other' => Mage::helper('M2ePro')->__('Other')
|
184 |
+
));
|
185 |
+
|
186 |
+
// Set mass-action
|
187 |
+
//--------------------------------
|
188 |
+
$this->getMassactionBlock()->addItem('autoMapping', array(
|
189 |
+
'label' => Mage::helper('M2ePro')->__('Map Item(s) Automatically'),
|
190 |
+
'url' => '',
|
191 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
192 |
+
), 'mapping');
|
193 |
+
$this->getMassactionBlock()->addItem('moving', array(
|
194 |
+
'label' => Mage::helper('M2ePro')->__('Move Item(s) To Listing'),
|
195 |
+
'url' => '',
|
196 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
197 |
+
), 'other');
|
198 |
+
$this->getMassactionBlock()->addItem('removing', array(
|
199 |
+
'label' => Mage::helper('M2ePro')->__('Remove Item(s)'),
|
200 |
+
'url' => '',
|
201 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
202 |
+
), 'other');
|
203 |
+
$this->getMassactionBlock()->addItem('unmapping', array(
|
204 |
+
'label' => Mage::helper('M2ePro')->__('Unmap Item(s)'),
|
205 |
+
'url' => '',
|
206 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
207 |
+
), 'mapping');
|
208 |
+
//--------------------------------
|
209 |
+
|
210 |
+
return parent::_prepareMassaction();
|
211 |
+
}
|
212 |
+
|
213 |
+
// ####################################
|
214 |
+
|
215 |
+
public function callbackColumnProductId($value, $row, $column, $isExport)
|
216 |
+
{
|
217 |
+
if (empty($value)) {
|
218 |
+
$productTitle = $row->getData('title');
|
219 |
+
|
220 |
+
if (is_null($productTitle) || $productTitle === '') {
|
221 |
+
$productTitle = Mage::helper('M2ePro')->__('N/A');
|
222 |
+
} else {
|
223 |
+
$productTitle = Mage::helper('M2ePro')->escapeHtml($productTitle);
|
224 |
+
$productTitle = Mage::helper('M2ePro')->escapeJs($productTitle);
|
225 |
+
if (strlen($productTitle) > 60) {
|
226 |
+
$productTitle = substr($productTitle, 0, 60) . '...';
|
227 |
+
}
|
228 |
+
}
|
229 |
+
|
230 |
+
$htmlValue = ' <a href="javascript:void(0);"
|
231 |
+
onclick="BuyListingOtherMappingHandlerObj.openPopUp(\''
|
232 |
+
.$productTitle
|
233 |
+
.'\','
|
234 |
+
.(int)$row->getId()
|
235 |
+
.');">'
|
236 |
+
.Mage::helper('M2ePro')->__('Map').'</a>';
|
237 |
+
|
238 |
+
if (Mage::helper('M2ePro/Module')->isDevelopmentMode()) {
|
239 |
+
$htmlValue .= '<br/>' . $row->getId();
|
240 |
+
}
|
241 |
+
|
242 |
+
return $htmlValue;
|
243 |
+
}
|
244 |
+
|
245 |
+
$htmlValue = ' <a href="'
|
246 |
+
.$this->getUrl('adminhtml/catalog_product/edit',
|
247 |
+
array('id' => $row->getData('product_id')))
|
248 |
+
.'" target="_blank">'
|
249 |
+
.$row->getData('product_id')
|
250 |
+
.'</a>';
|
251 |
+
|
252 |
+
$htmlValue .= '   <a href="javascript:void(0);"'
|
253 |
+
.' onclick="BuyListingOtherGridHandlerObj.movingHandler.getGridHtml('
|
254 |
+
.json_encode(array((int)$row->getData('id')))
|
255 |
+
.')">'
|
256 |
+
.Mage::helper('M2ePro')->__('Move')
|
257 |
+
.'</a>';
|
258 |
+
|
259 |
+
if (Mage::helper('M2ePro/Module')->isDevelopmentMode()) {
|
260 |
+
$htmlValue .= '<br/>' . $row->getId();
|
261 |
+
}
|
262 |
+
|
263 |
+
return $htmlValue;
|
264 |
+
}
|
265 |
+
|
266 |
+
public function callbackColumnProductTitle($value, $row, $column, $isExport)
|
267 |
+
{
|
268 |
+
if (is_null($value) || $value === '') {
|
269 |
+
$value = '<i style="color:gray;">receiving...</i>';
|
270 |
+
} else {
|
271 |
+
$value = '<span>' . Mage::helper('M2ePro')->escapeHtml($value) . '</span>';
|
272 |
+
}
|
273 |
+
|
274 |
+
$tempSku = $row->getData('sku');
|
275 |
+
is_null($tempSku) && $tempSku = Mage::helper('M2ePro')->__('N/A');
|
276 |
+
|
277 |
+
$value .= '<br/><strong>'.Mage::helper('M2ePro')->__('Reference ID').':</strong> '
|
278 |
+
.Mage::helper('M2ePro')->escapeHtml($tempSku);
|
279 |
+
|
280 |
+
return $value;
|
281 |
+
}
|
282 |
+
|
283 |
+
public function callbackColumnGeneralId($value, $row, $column, $isExport)
|
284 |
+
{
|
285 |
+
$url = Mage::helper('M2ePro/Component_Buy')->getItemUrl($value);
|
286 |
+
return '<a href="'.$url.'" target="_blank">'.$value.'</a>';
|
287 |
+
}
|
288 |
+
|
289 |
+
public function callbackColumnSku($value, $row, $column, $isExport)
|
290 |
+
{
|
291 |
+
return $value;
|
292 |
+
}
|
293 |
+
|
294 |
+
public function callbackColumnAvailableQty($value, $row, $column, $isExport)
|
295 |
+
{
|
296 |
+
if (is_null($value) || $value === '') {
|
297 |
+
return Mage::helper('M2ePro')->__('N/A');
|
298 |
+
}
|
299 |
+
|
300 |
+
if ($value <= 0) {
|
301 |
+
return '<span style="color: red;">0</span>';
|
302 |
+
}
|
303 |
+
|
304 |
+
return $value;
|
305 |
+
}
|
306 |
+
|
307 |
+
public function callbackColumnPrice($value, $row, $column, $isExport)
|
308 |
+
{
|
309 |
+
if (is_null($value) || $value === '') {
|
310 |
+
return Mage::helper('M2ePro')->__('N/A');
|
311 |
+
}
|
312 |
+
|
313 |
+
if ((float)$value <= 0) {
|
314 |
+
return '<span style="color: #f00;">0</span>';
|
315 |
+
}
|
316 |
+
|
317 |
+
return Mage::app()->getLocale()->currency('USD')->toCurrency($value);
|
318 |
+
}
|
319 |
+
|
320 |
+
public function callbackColumnStatus($value, $row, $column, $isExport)
|
321 |
+
{
|
322 |
+
switch ($row->getData('status')) {
|
323 |
+
|
324 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED:
|
325 |
+
$value = '<span style="color: gray;">' . $value . '</span>';
|
326 |
+
break;
|
327 |
+
|
328 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_LISTED:
|
329 |
+
$value = '<span style="color: green;">' . $value . '</span>';
|
330 |
+
break;
|
331 |
+
|
332 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED:
|
333 |
+
$value = '<span style="color: red;">' . $value . '</span>';
|
334 |
+
break;
|
335 |
+
|
336 |
+
default:
|
337 |
+
break;
|
338 |
+
}
|
339 |
+
|
340 |
+
return $value.$this->getViewLogIconHtml($row->getId());
|
341 |
+
}
|
342 |
+
|
343 |
+
protected function callbackFilterTitle($collection, $column)
|
344 |
+
{
|
345 |
+
$value = $column->getFilter()->getValue();
|
346 |
+
|
347 |
+
if ($value == null) {
|
348 |
+
return;
|
349 |
+
}
|
350 |
+
|
351 |
+
$collection->getSelect()->where('second_table.title LIKE ? OR second_table.sku LIKE ?', '%'.$value.'%');
|
352 |
+
}
|
353 |
+
|
354 |
+
// ####################################
|
355 |
+
|
356 |
+
public function getViewLogIconHtml($listingOtherId)
|
357 |
+
{
|
358 |
+
$listingOtherId = (int)$listingOtherId;
|
359 |
+
|
360 |
+
// Get last messages
|
361 |
+
//--------------------------
|
362 |
+
$dbSelect = $this->connRead->select()
|
363 |
+
->from(
|
364 |
+
Mage::getResourceModel('M2ePro/Listing_Other_Log')->getMainTable(),
|
365 |
+
array('action_id','action','type','description','create_date','initiator')
|
366 |
+
)
|
367 |
+
->where('`listing_other_id` = ?', $listingOtherId)
|
368 |
+
->where('`action_id` IS NOT NULL')
|
369 |
+
->order(array('id DESC'))
|
370 |
+
->limit(30);
|
371 |
+
|
372 |
+
$logRows = $this->connRead->fetchAll($dbSelect);
|
373 |
+
//--------------------------
|
374 |
+
|
375 |
+
// Get grouped messages by action_id
|
376 |
+
//--------------------------
|
377 |
+
$actionsRows = array();
|
378 |
+
$tempActionRows = array();
|
379 |
+
$lastActionId = false;
|
380 |
+
|
381 |
+
foreach ($logRows as $row) {
|
382 |
+
|
383 |
+
$row['description'] = Mage::helper('M2ePro/View')->getModifiedLogMessage($row['description']);
|
384 |
+
|
385 |
+
if ($row['action_id'] !== $lastActionId) {
|
386 |
+
if (count($tempActionRows) > 0) {
|
387 |
+
$actionsRows[] = array(
|
388 |
+
'type' => $this->getMainTypeForActionId($tempActionRows),
|
389 |
+
'date' => $this->getMainDateForActionId($tempActionRows),
|
390 |
+
'action' => $this->getActionForAction($tempActionRows[0]),
|
391 |
+
'initiator' => $this->getInitiatorForAction($tempActionRows[0]),
|
392 |
+
'items' => $tempActionRows
|
393 |
+
);
|
394 |
+
$tempActionRows = array();
|
395 |
+
}
|
396 |
+
$lastActionId = $row['action_id'];
|
397 |
+
}
|
398 |
+
$tempActionRows[] = $row;
|
399 |
+
}
|
400 |
+
|
401 |
+
if (count($tempActionRows) > 0) {
|
402 |
+
$actionsRows[] = array(
|
403 |
+
'type' => $this->getMainTypeForActionId($tempActionRows),
|
404 |
+
'date' => $this->getMainDateForActionId($tempActionRows),
|
405 |
+
'action' => $this->getActionForAction($tempActionRows[0]),
|
406 |
+
'initiator' => $this->getInitiatorForAction($tempActionRows[0]),
|
407 |
+
'items' => $tempActionRows
|
408 |
+
);
|
409 |
+
}
|
410 |
+
|
411 |
+
if (count($actionsRows) <= 0) {
|
412 |
+
return '';
|
413 |
+
}
|
414 |
+
|
415 |
+
$tips = array(
|
416 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'Last Action was completed successfully.',
|
417 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'Last Action was completed with error(s).',
|
418 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'Last Action was completed with warning(s).'
|
419 |
+
);
|
420 |
+
|
421 |
+
$icons = array(
|
422 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'normal',
|
423 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'error',
|
424 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'warning'
|
425 |
+
);
|
426 |
+
|
427 |
+
$summary = $this->getLayout()->createBlock('M2ePro/adminhtml_log_grid_summary', '', array(
|
428 |
+
'entity_id' => $listingOtherId,
|
429 |
+
'rows' => $actionsRows,
|
430 |
+
'tips' => $tips,
|
431 |
+
'icons' => $icons,
|
432 |
+
'view_help_handler' => 'BuyListingOtherGridHandlerObj.viewItemHelp',
|
433 |
+
'hide_help_handler' => 'BuyListingOtherGridHandlerObj.hideItemHelp',
|
434 |
+
));
|
435 |
+
|
436 |
+
return $summary->toHtml();
|
437 |
+
}
|
438 |
+
|
439 |
+
public function getActionForAction($actionRows)
|
440 |
+
{
|
441 |
+
$string = '';
|
442 |
+
|
443 |
+
switch ((int)$actionRows['action']) {
|
444 |
+
case Ess_M2ePro_Model_Listing_Other_Log::ACTION_CHANGE_STATUS_ON_CHANNEL:
|
445 |
+
$string = Mage::helper('M2ePro')->__('Status Change');
|
446 |
+
break;
|
447 |
+
}
|
448 |
+
|
449 |
+
return $string;
|
450 |
+
}
|
451 |
+
|
452 |
+
public function getInitiatorForAction($actionRows)
|
453 |
+
{
|
454 |
+
$string = '';
|
455 |
+
|
456 |
+
switch ($actionRows['initiator']) {
|
457 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_UNKNOWN:
|
458 |
+
$string = '';
|
459 |
+
break;
|
460 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_USER:
|
461 |
+
$string = Mage::helper('M2ePro')->__('Manual');
|
462 |
+
break;
|
463 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION:
|
464 |
+
$string = Mage::helper('M2ePro')->__('Automatic');
|
465 |
+
break;
|
466 |
+
}
|
467 |
+
|
468 |
+
return $string;
|
469 |
+
}
|
470 |
+
|
471 |
+
public function getMainTypeForActionId($actionRows)
|
472 |
+
{
|
473 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS;
|
474 |
+
|
475 |
+
foreach ($actionRows as $row) {
|
476 |
+
if ($row['type'] == Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR) {
|
477 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR;
|
478 |
+
break;
|
479 |
+
}
|
480 |
+
if ($row['type'] == Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING) {
|
481 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING;
|
482 |
+
}
|
483 |
+
}
|
484 |
+
|
485 |
+
return $type;
|
486 |
+
}
|
487 |
+
|
488 |
+
public function getMainDateForActionId($actionRows)
|
489 |
+
{
|
490 |
+
$format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
|
491 |
+
return Mage::app()->getLocale()->date(strtotime($actionRows[0]['create_date']))->toString($format);
|
492 |
+
}
|
493 |
+
|
494 |
+
// ####################################
|
495 |
+
|
496 |
+
protected function _toHtml()
|
497 |
+
{
|
498 |
+
$javascriptsMain = <<<JAVASCRIPT
|
499 |
+
<script type="text/javascript">
|
500 |
+
|
501 |
+
if (typeof BuyListingOtherGridHandlerObj != 'undefined') {
|
502 |
+
BuyListingOtherGridHandlerObj.afterInitPage();
|
503 |
+
}
|
504 |
+
|
505 |
+
Event.observe(window, 'load', function() {
|
506 |
+
setTimeout(function() {
|
507 |
+
BuyListingOtherGridHandlerObj.afterInitPage();
|
508 |
+
}, 350);
|
509 |
+
});
|
510 |
+
|
511 |
+
</script>
|
512 |
+
JAVASCRIPT;
|
513 |
+
|
514 |
+
return parent::_toHtml().$javascriptsMain;
|
515 |
+
}
|
516 |
+
|
517 |
+
// ####################################
|
518 |
+
|
519 |
+
public function getGridUrl()
|
520 |
+
{
|
521 |
+
return $this->getUrl('*/adminhtml_common_buy_listing_other/grid', array('_current' => true));
|
522 |
+
}
|
523 |
+
|
524 |
+
public function getRowUrl($row)
|
525 |
+
{
|
526 |
+
return false;
|
527 |
+
}
|
528 |
+
|
529 |
+
// ####################################
|
530 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Product.php
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_Product extends Mage_Adminhtml_Block_Widget_Grid_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingProduct');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_buy_listing_product';
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
// Set header text
|
21 |
+
//------------------------------
|
22 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
23 |
+
|
24 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
25 |
+
$headerText = Mage::helper('M2ePro')->__(
|
26 |
+
'Add Products To %component_name% Listing "%listing_title%"',
|
27 |
+
Mage::helper('M2ePro/Component_Buy')->getTitle(),
|
28 |
+
$this->escapeHtml($listingData['title'])
|
29 |
+
);
|
30 |
+
} else {
|
31 |
+
$headerText = Mage::helper('M2ePro')->__('Add Products To Listing "%listing_title%"',
|
32 |
+
$this->escapeHtml($listingData['title'])
|
33 |
+
);
|
34 |
+
}
|
35 |
+
|
36 |
+
$this->_headerText = $headerText;
|
37 |
+
//------------------------------
|
38 |
+
|
39 |
+
// Set buttons actions
|
40 |
+
//------------------------------
|
41 |
+
$this->removeButton('back');
|
42 |
+
$this->removeButton('reset');
|
43 |
+
$this->removeButton('delete');
|
44 |
+
$this->removeButton('add');
|
45 |
+
$this->removeButton('save');
|
46 |
+
$this->removeButton('edit');
|
47 |
+
//------------------------------
|
48 |
+
|
49 |
+
//------------------------------
|
50 |
+
if (is_null($this->getRequest()->getParam('back'))) {
|
51 |
+
$url = $this->getUrl(
|
52 |
+
'*/adminhtml_common_buy_listing/categoryProduct',
|
53 |
+
array(
|
54 |
+
'id' => $listingData['id'],
|
55 |
+
'save_categories' => $this->getRequest()->getParam('save_categories', 1),
|
56 |
+
'selected_categories' => $this->getRequest()->getParam('selected_categories')
|
57 |
+
)
|
58 |
+
);
|
59 |
+
} else {
|
60 |
+
$url = Mage::helper('M2ePro')->getBackUrl(
|
61 |
+
'*/adminhtml_common_listing/index',
|
62 |
+
array(
|
63 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_BUY
|
64 |
+
)
|
65 |
+
);
|
66 |
+
}
|
67 |
+
$this->_addButton('back', array(
|
68 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
69 |
+
'onclick' => 'ProductGridHandlerObj.back_click(\''.$url.'\')',
|
70 |
+
'class' => 'back'
|
71 |
+
));
|
72 |
+
//------------------------------
|
73 |
+
|
74 |
+
//------------------------------
|
75 |
+
$this->_addButton('save', array(
|
76 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
77 |
+
'onclick' => 'ProductGridHandlerObj.save_click(\'view\')',
|
78 |
+
'class' => 'save'
|
79 |
+
));
|
80 |
+
//------------------------------
|
81 |
+
}
|
82 |
+
|
83 |
+
public function getGridHtml()
|
84 |
+
{
|
85 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_listing_product_help');
|
86 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
87 |
+
}
|
88 |
+
|
89 |
+
protected function _toHtml()
|
90 |
+
{
|
91 |
+
return '<div id="add_products_progress_bar"></div>'.
|
92 |
+
'<div id="add_products_container">'.
|
93 |
+
parent::_toHtml().
|
94 |
+
'</div>';
|
95 |
+
}
|
96 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Product/Help.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_Product_Help extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingProductHelp');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/buy/listing/product/help.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/ProductSearch/Grid.php
ADDED
@@ -0,0 +1,254 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_ProductSearch_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
private $productId;
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
$this->productId = Mage::helper('M2ePro/Data_Global')->getValue('product_id');
|
16 |
+
|
17 |
+
// Initialization block
|
18 |
+
//------------------------------
|
19 |
+
$this->setId('buyProductSearchGrid');
|
20 |
+
//------------------------------
|
21 |
+
|
22 |
+
// Set default values
|
23 |
+
//------------------------------
|
24 |
+
$this->setFilterVisibility(false);
|
25 |
+
$this->setPagerVisibility(false);
|
26 |
+
$this->setDefaultSort('id');
|
27 |
+
$this->setDefaultDir('ASC');
|
28 |
+
$this->setSaveParametersInSession(true);
|
29 |
+
$this->setUseAjax(true);
|
30 |
+
//------------------------------
|
31 |
+
}
|
32 |
+
|
33 |
+
protected function _prepareCollection()
|
34 |
+
{
|
35 |
+
$data = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
36 |
+
|
37 |
+
$results = new Varien_Data_Collection();
|
38 |
+
foreach ($data as $index => $item) {
|
39 |
+
$temp = array(
|
40 |
+
'id' => $index,
|
41 |
+
'general_id' => isset($item['general_id']) ? $item['general_id'] : null,
|
42 |
+
'title' => $item['title'],
|
43 |
+
'image_url' => $item['image_url'],
|
44 |
+
'price' => isset($item['price']) ? $item['price'] : null,
|
45 |
+
'variations' => isset($item['variations']) ? $item['variations'] : null
|
46 |
+
);
|
47 |
+
|
48 |
+
$results->addItem(new Varien_Object($temp));
|
49 |
+
}
|
50 |
+
|
51 |
+
$this->setCollection($results);
|
52 |
+
|
53 |
+
return parent::_prepareCollection();
|
54 |
+
}
|
55 |
+
|
56 |
+
protected function _prepareColumns()
|
57 |
+
{
|
58 |
+
$this->addColumn('image', array(
|
59 |
+
'header' => Mage::helper('M2ePro')->__('Image'),
|
60 |
+
'align' => 'center',
|
61 |
+
'type' => 'text',
|
62 |
+
'width' => '80px',
|
63 |
+
'index' => 'image_url',
|
64 |
+
'filter' => false,
|
65 |
+
'sortable' => false,
|
66 |
+
'frame_callback' => array($this, 'callbackColumnImage')
|
67 |
+
));
|
68 |
+
|
69 |
+
$this->addColumn('general_id', array(
|
70 |
+
'header' => Mage::helper('M2ePro')->__('Rakuten.com SKU'),
|
71 |
+
'align' => 'center',
|
72 |
+
'type' => 'text',
|
73 |
+
'width' => '75px',
|
74 |
+
'index' => 'general_id',
|
75 |
+
'filter' => false,
|
76 |
+
'sortable' => false,
|
77 |
+
'frame_callback' => array($this, 'callbackColumnGeneralId')
|
78 |
+
));
|
79 |
+
|
80 |
+
$this->addColumn('title', array(
|
81 |
+
'header' => Mage::helper('M2ePro')->__('Product Title'),
|
82 |
+
'align' => 'left',
|
83 |
+
'type' => 'text',
|
84 |
+
'width' => '375px',
|
85 |
+
'string_limit' => 10000,
|
86 |
+
'index' => 'title',
|
87 |
+
'filter' => false,
|
88 |
+
'sortable' => false,
|
89 |
+
'frame_callback' => array($this, 'callbackColumnTitle'),
|
90 |
+
));
|
91 |
+
|
92 |
+
$this->addColumn('price',array(
|
93 |
+
'header' => Mage::helper('catalog')->__('Price'),
|
94 |
+
'width' => '60px',
|
95 |
+
'align' => 'right',
|
96 |
+
'index' => 'price',
|
97 |
+
'filter' => false,
|
98 |
+
'sortable' => false,
|
99 |
+
'type' => 'text',
|
100 |
+
'frame_callback' => array($this, 'callbackColumnPrice')
|
101 |
+
));
|
102 |
+
|
103 |
+
$this->addColumn('actions', array(
|
104 |
+
'header' => Mage::helper('M2ePro')->__('Action'),
|
105 |
+
'align' => 'left',
|
106 |
+
'type' => 'text',
|
107 |
+
'width' => '78px',
|
108 |
+
'filter' => false,
|
109 |
+
'sortable' => false,
|
110 |
+
'frame_callback' => array($this, 'callbackColumnActions'),
|
111 |
+
));
|
112 |
+
|
113 |
+
}
|
114 |
+
|
115 |
+
// ####################################
|
116 |
+
|
117 |
+
public function callbackColumnImage($value, $product, $column, $isExport)
|
118 |
+
{
|
119 |
+
return '<img width="75px" src="'.$value.'" />';
|
120 |
+
}
|
121 |
+
|
122 |
+
public function callbackColumnGeneralId($value, $product, $column, $isExport)
|
123 |
+
{
|
124 |
+
if (empty($value)) {
|
125 |
+
$url = Mage::helper('M2ePro/Component_Buy')->getItemUrl('%general_id%');
|
126 |
+
$templateHtml = '<a href="'.$url.'" target="_blank">%general_id%</a>';
|
127 |
+
return '<span id="buy_link_'.$product->getId().'">' . Mage::helper('M2ePro')->__('N/A') . '</span>' .
|
128 |
+
'<div id="template_buy_link_'.$product->getId().'" style="display: none;">'.$templateHtml.'</div>';
|
129 |
+
}
|
130 |
+
|
131 |
+
$url = Mage::helper('M2ePro/Component_Buy')->getItemUrl($value);
|
132 |
+
|
133 |
+
return '<a href="'.$url.'" target="_blank">'.$value.'</a>';
|
134 |
+
}
|
135 |
+
|
136 |
+
public function callbackColumnTitle($value, $row, $column, $isExport)
|
137 |
+
{
|
138 |
+
$value = '<div style="margin-left: 3px; margin-bottom: 10px;">'.
|
139 |
+
Mage::helper('M2ePro')->escapeHtml($value)."</div>";
|
140 |
+
|
141 |
+
$variations = $row->getData('variations');
|
142 |
+
if (is_null($variations)) {
|
143 |
+
return $value;
|
144 |
+
}
|
145 |
+
|
146 |
+
$specificsHtml = '';
|
147 |
+
$id = $row->getId();
|
148 |
+
foreach ($variations['set'] as $specificName => $specific) {
|
149 |
+
$specificsHtml .= '<span style="margin-left: 10px;
|
150 |
+
font-size: 11px;
|
151 |
+
color: #808080;
|
152 |
+
display: inline-block;
|
153 |
+
width: 100px;">'.
|
154 |
+
ucfirst(strtolower($specificName)).
|
155 |
+
':</span>';
|
156 |
+
$specificsHtml .= '<select class="specifics_'.$id.'"
|
157 |
+
onchange="ListingGridHandlerObj.productSearchHandler.specificsChange(this)"
|
158 |
+
style="width: 150px; margin-left: 5px; margin-bottom: 5px; font-size: 10px;"
|
159 |
+
id="specific_'.$specificName.'_'.$id.'">';
|
160 |
+
$specificsHtml .= '<option value=""></option>';
|
161 |
+
foreach ($specific as $option) {
|
162 |
+
$specificsHtml .= '<option value="'.$option.'">'.$option.'</option>';
|
163 |
+
}
|
164 |
+
$specificsHtml .= '</select><br/>';
|
165 |
+
}
|
166 |
+
|
167 |
+
$specificsJsonContainer = '<div id="skus_'.$id.'" style="display: none;">'.
|
168 |
+
json_encode($variations['skus']).'</div>';
|
169 |
+
|
170 |
+
return $value . $specificsHtml . $specificsJsonContainer;
|
171 |
+
}
|
172 |
+
|
173 |
+
public function callbackColumnPrice($value, $row, $column, $isExport)
|
174 |
+
{
|
175 |
+
if (empty($value)) {
|
176 |
+
$value = Mage::helper('M2ePro')->__('N/A');
|
177 |
+
}
|
178 |
+
|
179 |
+
return '<div id="price_'.$row->getId().'" style="margin-right: 5px;">'.$value.'</div>';
|
180 |
+
}
|
181 |
+
|
182 |
+
public function callbackColumnActions($value, $row, $column, $isExport)
|
183 |
+
{
|
184 |
+
$assignText = Mage::helper('M2ePro')->__('Assign Rakuten.com SKU');
|
185 |
+
//->__('There is no such variation on Rakuten.com. Please, choose another variation.');
|
186 |
+
$naMessage = 'There is no such Variation on Rakuten.com. Please, choose another Variation.';
|
187 |
+
$naMessage = Mage::helper('M2ePro')->__($naMessage);
|
188 |
+
|
189 |
+
if (!is_null($row->getData('variations'))) {
|
190 |
+
$templateMapHtml =
|
191 |
+
'<a href="javascript:void(0);" onclick="ListingGridHandlerObj.productSearchHandler.mapToGeneralId('
|
192 |
+
.$this->productId
|
193 |
+
.', \'%general_id%\');">'.$assignText.'</a>';
|
194 |
+
|
195 |
+
$templateNaHtml = '<a href="javascript:void(0);" onclick="alert(\''.$naMessage.'\')">'.$assignText.'</a>';
|
196 |
+
|
197 |
+
return '<span id="map_link_'.$row->getId().'"><span style="color: #808080">'.$assignText.'</span></span>
|
198 |
+
<div id="template_map_link_'.$row->getId().'" style="display: none;">'.$templateMapHtml.'</div>
|
199 |
+
<div id="template_na_link_'.$row->getId().'" style="display: none;">'.$templateNaHtml.'</div>';
|
200 |
+
}
|
201 |
+
|
202 |
+
return '<a href="javascript:void(0);" onclick="ListingGridHandlerObj.productSearchHandler.mapToGeneralId('
|
203 |
+
.$this->productId
|
204 |
+
.', \''
|
205 |
+
.$row->getData('general_id')
|
206 |
+
.'\');">'.$assignText.'</a>';
|
207 |
+
}
|
208 |
+
|
209 |
+
// ####################################
|
210 |
+
|
211 |
+
protected function _toHtml()
|
212 |
+
{
|
213 |
+
$javascriptsMain = <<<JAVASCRIPT
|
214 |
+
<script type="text/javascript">
|
215 |
+
|
216 |
+
$$('#buyProductSearchGrid div.grid th').each(function(el){
|
217 |
+
el.style.padding = '2px 2px';
|
218 |
+
});
|
219 |
+
|
220 |
+
$$('#buyProductSearchGrid div.grid td').each(function(el){
|
221 |
+
el.style.padding = '2px 2px';
|
222 |
+
});
|
223 |
+
|
224 |
+
</script>
|
225 |
+
JAVASCRIPT;
|
226 |
+
|
227 |
+
//------------------------------
|
228 |
+
$data = array(
|
229 |
+
'id' => 'productSearch_cleanSuggest_button',
|
230 |
+
'label' => Mage::helper('M2ePro')->__('Clear Search Results'),
|
231 |
+
'class' => 'productSearch_cleanSuggest_button'
|
232 |
+
);
|
233 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
234 |
+
//------------------------------
|
235 |
+
|
236 |
+
$buttonBlockHtml = Mage::helper('M2ePro/Data_Global')->getValue('is_suggestion') ? $buttonBlock->toHtml() : '';
|
237 |
+
|
238 |
+
return $buttonBlockHtml . parent::_toHtml() . $javascriptsMain;
|
239 |
+
}
|
240 |
+
|
241 |
+
// ####################################
|
242 |
+
|
243 |
+
public function getGridUrl()
|
244 |
+
{
|
245 |
+
return $this->getUrl('*/adminhtml_common_buy_listing/getSuggestedBuyComSkuGrid', array('_current'=>true));
|
246 |
+
}
|
247 |
+
|
248 |
+
public function getRowUrl($row)
|
249 |
+
{
|
250 |
+
return false;
|
251 |
+
}
|
252 |
+
|
253 |
+
// ####################################
|
254 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/ProductSearch/Main.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_ProductSearch_Main extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
$this->setTemplate('M2ePro/common/buy/listing/product_search/main.phtml');
|
14 |
+
}
|
15 |
+
|
16 |
+
protected function _beforeToHtml()
|
17 |
+
{
|
18 |
+
//------------------------------
|
19 |
+
$data = array(
|
20 |
+
'id' => 'productSearch_submit_button',
|
21 |
+
'label' => Mage::helper('M2ePro')->__('Search'),
|
22 |
+
'class' => 'productSearch_submit_button submit'
|
23 |
+
);
|
24 |
+
$buttonSubmitBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
25 |
+
$this->setChild('productSearch_submit_button', $buttonSubmitBlock);
|
26 |
+
//------------------------------
|
27 |
+
|
28 |
+
//------------------------------
|
29 |
+
$data = array(
|
30 |
+
'id' => 'productSearch_back_button',
|
31 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
32 |
+
'class' => 'productSearch_back_button'
|
33 |
+
);
|
34 |
+
$buttonBackBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
35 |
+
$this->setChild('productSearch_back_button', $buttonBackBlock);
|
36 |
+
//------------------------------
|
37 |
+
|
38 |
+
//------------------------------
|
39 |
+
$data = array(
|
40 |
+
'id' => 'productSearch_cancel_button',
|
41 |
+
'label' => Mage::helper('M2ePro')->__('Close'),
|
42 |
+
'class' => 'productSearch_cancel_button'
|
43 |
+
);
|
44 |
+
$buttonCancelBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
45 |
+
$this->setChild('productSearch_cancel_button', $buttonCancelBlock);
|
46 |
+
//------------------------------
|
47 |
+
|
48 |
+
parent::_beforeToHtml();
|
49 |
+
}
|
50 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/ProductSearch/Menu.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_ProductSearch_Menu extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
$this->setTemplate('M2ePro/common/buy/listing/product_search/menu.phtml');
|
14 |
+
}
|
15 |
+
|
16 |
+
protected function _beforeToHtml()
|
17 |
+
{
|
18 |
+
//------------------------------
|
19 |
+
$data = array(
|
20 |
+
'id' => 'productSearchMenu_cancel_button',
|
21 |
+
'label' => Mage::helper('M2ePro')->__('Close'),
|
22 |
+
'class' => 'productSearchMenu_cancel_button'
|
23 |
+
);
|
24 |
+
$buttonCancelBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
25 |
+
$this->setChild('productSearchMenu_cancel_button', $buttonCancelBlock);
|
26 |
+
//------------------------------
|
27 |
+
|
28 |
+
parent::_beforeToHtml();
|
29 |
+
}
|
30 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Search.php
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_Search extends Mage_Adminhtml_Block_Widget_Grid_Container
|
8 |
+
{
|
9 |
+
// ########################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('listingBuySearch');
|
18 |
+
$this->_blockGroup = 'M2ePro';
|
19 |
+
$this->_controller = 'adminhtml_common_buy_listing_search';
|
20 |
+
//------------------------------
|
21 |
+
|
22 |
+
// Set header text
|
23 |
+
//------------------------------
|
24 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
25 |
+
$componentName = Mage::helper('M2ePro/Component_Buy')->getTitle();
|
26 |
+
$headerText = Mage::helper('M2ePro')->__("Search %component_name% Listings Items", $componentName);
|
27 |
+
} else {
|
28 |
+
$headerText = Mage::helper('M2ePro')->__("Search Listings Items");
|
29 |
+
}
|
30 |
+
|
31 |
+
$this->_headerText = $headerText;
|
32 |
+
//------------------------------
|
33 |
+
|
34 |
+
// Set buttons actions
|
35 |
+
//------------------------------
|
36 |
+
$this->removeButton('back');
|
37 |
+
$this->removeButton('reset');
|
38 |
+
$this->removeButton('delete');
|
39 |
+
$this->removeButton('add');
|
40 |
+
$this->removeButton('save');
|
41 |
+
$this->removeButton('edit');
|
42 |
+
//------------------------------
|
43 |
+
|
44 |
+
//------------------------------
|
45 |
+
if (!is_null($this->getRequest()->getParam('back'))) {
|
46 |
+
$url = Mage::helper('M2ePro')->getBackUrl('*/adminhtml_common_buy_listing/search');
|
47 |
+
$this->_addButton('back', array(
|
48 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
49 |
+
'onclick' => 'CommonHandlerObj.back_click(\'' . $url . '\')',
|
50 |
+
'class' => 'back'
|
51 |
+
));
|
52 |
+
}
|
53 |
+
//------------------------------
|
54 |
+
|
55 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_buy_listing/search');
|
56 |
+
|
57 |
+
//------------------------------
|
58 |
+
$url = $this->getUrl(
|
59 |
+
'*/adminhtml_common_listing/index',
|
60 |
+
array(
|
61 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_BUY,
|
62 |
+
'back'=> $backUrl
|
63 |
+
)
|
64 |
+
);
|
65 |
+
$this->_addButton('goto_listings', array(
|
66 |
+
'label' => Mage::helper('M2ePro')->__('Listings'),
|
67 |
+
'onclick' => 'setLocation(\'' . $url . '\')',
|
68 |
+
'class' => 'button_link'
|
69 |
+
));
|
70 |
+
//------------------------------
|
71 |
+
|
72 |
+
//------------------------------
|
73 |
+
$this->_addButton('goto_templates', array(
|
74 |
+
'label' => Mage::helper('M2ePro')->__('Policies'),
|
75 |
+
'onclick' => '',
|
76 |
+
'class' => 'button_link drop_down templates-drop-down'
|
77 |
+
));
|
78 |
+
//------------------------------
|
79 |
+
|
80 |
+
//------------------------------
|
81 |
+
$url = $this->getUrl(
|
82 |
+
'*/adminhtml_common_log/listing',
|
83 |
+
array(
|
84 |
+
'channel' => Ess_M2ePro_Block_Adminhtml_Common_Log_Tabs::TAB_ID_BUY
|
85 |
+
)
|
86 |
+
);
|
87 |
+
$this->_addButton('view_log', array(
|
88 |
+
'label' => Mage::helper('M2ePro')->__('View Log'),
|
89 |
+
'onclick' => 'window.open(\'' . $url . '\')',
|
90 |
+
'class' => 'button_link'
|
91 |
+
));
|
92 |
+
//------------------------------
|
93 |
+
}
|
94 |
+
|
95 |
+
// ########################################
|
96 |
+
|
97 |
+
protected function _toHtml()
|
98 |
+
{
|
99 |
+
return $this->getTemplatesButtonJavascript() . parent::_toHtml();
|
100 |
+
}
|
101 |
+
|
102 |
+
public function getGridHtml()
|
103 |
+
{
|
104 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_listing_search_help');
|
105 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
106 |
+
}
|
107 |
+
|
108 |
+
// ########################################
|
109 |
+
|
110 |
+
protected function getTemplatesButtonJavascript()
|
111 |
+
{
|
112 |
+
$data = array(
|
113 |
+
'target_css_class' => 'templates-drop-down',
|
114 |
+
'items' => $this->getTemplatesButtonDropDownItems()
|
115 |
+
);
|
116 |
+
$dropDownBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_button_dropDown');
|
117 |
+
$dropDownBlock->setData($data);
|
118 |
+
|
119 |
+
return $dropDownBlock->toHtml();
|
120 |
+
}
|
121 |
+
|
122 |
+
protected function getTemplatesButtonDropDownItems()
|
123 |
+
{
|
124 |
+
$items = array();
|
125 |
+
|
126 |
+
$filter = base64_encode('component_mode=' . Ess_M2ePro_Helper_Component_Buy::NICK);
|
127 |
+
|
128 |
+
//------------------------------
|
129 |
+
$url = $this->getUrl(
|
130 |
+
'*/adminhtml_common_template_sellingFormat/index',
|
131 |
+
array(
|
132 |
+
'filter' => $filter
|
133 |
+
)
|
134 |
+
);
|
135 |
+
$items[] = array(
|
136 |
+
'url' => $url,
|
137 |
+
'label' => Mage::helper('M2ePro')->__('Selling Format Policies'),
|
138 |
+
'target' => '_blank'
|
139 |
+
);
|
140 |
+
//------------------------------
|
141 |
+
|
142 |
+
//------------------------------
|
143 |
+
$url = $this->getUrl(
|
144 |
+
'*/adminhtml_common_template_synchronization/index',
|
145 |
+
array(
|
146 |
+
'filter' => $filter
|
147 |
+
)
|
148 |
+
);
|
149 |
+
$items[] = array(
|
150 |
+
'url' => $url,
|
151 |
+
'label' => Mage::helper('M2ePro')->__('Synchronization Policies'),
|
152 |
+
'target' => '_blank'
|
153 |
+
);
|
154 |
+
//------------------------------
|
155 |
+
|
156 |
+
return $items;
|
157 |
+
}
|
158 |
+
|
159 |
+
// ########################################
|
160 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Search/Grid.php
ADDED
@@ -0,0 +1,458 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_Search_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
// ####################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('buyListingSearchGrid');
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
// Set default values
|
21 |
+
//------------------------------
|
22 |
+
$this->setDefaultSort('id');
|
23 |
+
$this->setDefaultDir('DESC');
|
24 |
+
$this->setSaveParametersInSession(true);
|
25 |
+
$this->setUseAjax(true);
|
26 |
+
//------------------------------
|
27 |
+
}
|
28 |
+
|
29 |
+
// ####################################
|
30 |
+
|
31 |
+
protected function _prepareCollection()
|
32 |
+
{
|
33 |
+
// Get collection products in listing
|
34 |
+
//--------------------------------
|
35 |
+
$collection = Mage::helper('M2ePro/Component_Buy')->getCollection('Listing_Product');
|
36 |
+
$collection->getSelect()->distinct();
|
37 |
+
$collection->getSelect()
|
38 |
+
->join(array('l'=>Mage::getResourceModel('M2ePro/Listing')->getMainTable()),
|
39 |
+
'(`l`.`id` = `main_table`.`listing_id`)',
|
40 |
+
array('listing_title'=>'title','store_id'))
|
41 |
+
->join(array('bl'=>Mage::getResourceModel('M2ePro/Buy_Listing')->getMainTable()),
|
42 |
+
'(`bl`.`listing_id` = `l`.`id`)',
|
43 |
+
array('template_selling_format_id'));
|
44 |
+
//--------------------------------
|
45 |
+
|
46 |
+
// Communicate with magento product table
|
47 |
+
//--------------------------------
|
48 |
+
$dbSelect = Mage::getResourceModel('core/config')->getReadConnection()
|
49 |
+
->select()
|
50 |
+
->from(Mage::getSingleton('core/resource')
|
51 |
+
->getTableName('catalog_product_entity_varchar'),
|
52 |
+
new Zend_Db_Expr('MAX(`store_id`)'))
|
53 |
+
->where("`entity_id` = `main_table`.`product_id`")
|
54 |
+
->where("`attribute_id` = `ea`.`attribute_id`")
|
55 |
+
->where("`store_id` = 0 OR `store_id` = `l`.`store_id`");
|
56 |
+
|
57 |
+
$collection->getSelect()
|
58 |
+
//->join(array('csi'=>Mage::getSingleton('core/resource')->getTableName('cataloginventory_stock_item')),
|
59 |
+
// '(csi.product_id = `main_table`.product_id)',array('qty'))
|
60 |
+
->join(array('cpe'=>Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')),
|
61 |
+
'(cpe.entity_id = `main_table`.product_id)',
|
62 |
+
array('magento_sku'=>'sku'))
|
63 |
+
->join(array('cisi'=>Mage::getSingleton('core/resource')->getTableName('cataloginventory_stock_item')),
|
64 |
+
'(cisi.product_id = `main_table`.product_id AND cisi.stock_id = 1)',
|
65 |
+
array('is_in_stock'))
|
66 |
+
->join(array('cpev'=>Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')),
|
67 |
+
"(`cpev`.`entity_id` = `main_table`.product_id)",
|
68 |
+
array('value'))
|
69 |
+
->join(array('ea'=>Mage::getSingleton('core/resource')->getTableName('eav_attribute')),
|
70 |
+
'(`cpev`.`attribute_id` = `ea`.`attribute_id` AND `ea`.`attribute_code` = \'name\')',
|
71 |
+
array())
|
72 |
+
->where('`cpev`.`store_id` = ('.$dbSelect->__toString().')');
|
73 |
+
//--------------------------------
|
74 |
+
|
75 |
+
//exit($collection->getSelect()->__toString());
|
76 |
+
|
77 |
+
// Set collection to grid
|
78 |
+
$this->setCollection($collection);
|
79 |
+
|
80 |
+
return parent::_prepareCollection();
|
81 |
+
}
|
82 |
+
|
83 |
+
protected function _prepareColumns()
|
84 |
+
{
|
85 |
+
$this->addColumn('product_id', array(
|
86 |
+
'header' => Mage::helper('M2ePro')->__('Product ID'),
|
87 |
+
'align' => 'right',
|
88 |
+
'width' => '100px',
|
89 |
+
'type' => 'number',
|
90 |
+
'index' => 'product_id',
|
91 |
+
'filter_index' => 'main_table.product_id',
|
92 |
+
'frame_callback' => array($this, 'callbackColumnProductId')
|
93 |
+
));
|
94 |
+
|
95 |
+
$this->addColumn('name', array(
|
96 |
+
'header' => Mage::helper('M2ePro')->__('Product Title / Listing / Product SKU'),
|
97 |
+
'align' => 'left',
|
98 |
+
//'width' => '300px',
|
99 |
+
'type' => 'text',
|
100 |
+
'index' => 'value',
|
101 |
+
'filter_index' => 'cpev.value',
|
102 |
+
'frame_callback' => array($this, 'callbackColumnProductTitle'),
|
103 |
+
'filter_condition_callback' => array($this, 'callbackFilterTitle')
|
104 |
+
));
|
105 |
+
|
106 |
+
$this->addColumn('stock_availability',
|
107 |
+
array(
|
108 |
+
'header'=> Mage::helper('M2ePro')->__('Stock Availability'),
|
109 |
+
'width' => '100px',
|
110 |
+
'index' => 'is_in_stock',
|
111 |
+
'filter_index' => 'cisi.is_in_stock',
|
112 |
+
'type' => 'options',
|
113 |
+
'sortable' => false,
|
114 |
+
'options' => array(
|
115 |
+
1 => Mage::helper('M2ePro')->__('In Stock'),
|
116 |
+
0 => Mage::helper('M2ePro')->__('Out of Stock')
|
117 |
+
),
|
118 |
+
'frame_callback' => array($this, 'callbackColumnStockAvailability')
|
119 |
+
));
|
120 |
+
|
121 |
+
$this->addColumn('sku', array(
|
122 |
+
'header' => Mage::helper('M2ePro')->__('Reference ID'),
|
123 |
+
'align' => 'left',
|
124 |
+
'width' => '150px',
|
125 |
+
'type' => 'text',
|
126 |
+
'index' => 'sku',
|
127 |
+
'filter_index' => 'second_table.sku',
|
128 |
+
'frame_callback' => array($this, 'callbackColumnSku')
|
129 |
+
));
|
130 |
+
|
131 |
+
$this->addColumn('general_id', array(
|
132 |
+
'header' => Mage::helper('M2ePro')->__('Rakuten.com SKU'),
|
133 |
+
'align' => 'left',
|
134 |
+
'width' => '90px',
|
135 |
+
'type' => 'text',
|
136 |
+
'index' => 'general_id',
|
137 |
+
'filter_index' => 'second_table.general_id',
|
138 |
+
'frame_callback' => array($this, 'callbackColumnGeneralId')
|
139 |
+
));
|
140 |
+
|
141 |
+
$this->addColumn('online_qty', array(
|
142 |
+
'header' => Mage::helper('M2ePro')->__('QTY'),
|
143 |
+
'align' => 'right',
|
144 |
+
'width' => '70px',
|
145 |
+
'type' => 'number',
|
146 |
+
'index' => 'online_qty',
|
147 |
+
'filter_index' => 'second_table.online_qty',
|
148 |
+
'frame_callback' => array($this, 'callbackColumnAvailableQty')
|
149 |
+
));
|
150 |
+
|
151 |
+
$this->addColumn('online_price', array(
|
152 |
+
'header' => Mage::helper('M2ePro')->__('Price'),
|
153 |
+
'align' => 'right',
|
154 |
+
'width' => '70px',
|
155 |
+
'type' => 'number',
|
156 |
+
'index' => 'online_price',
|
157 |
+
'filter_index' => 'second_table.online_price',
|
158 |
+
'frame_callback' => array($this, 'callbackColumnPrice')
|
159 |
+
));
|
160 |
+
|
161 |
+
$this->addColumn('status', array(
|
162 |
+
'header' => Mage::helper('M2ePro')->__('Status'),
|
163 |
+
'width' => '125px',
|
164 |
+
'index' => 'status',
|
165 |
+
'filter_index' => 'main_table.status',
|
166 |
+
'type' => 'options',
|
167 |
+
'sortable' => false,
|
168 |
+
'options' => array(
|
169 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED => Mage::helper('M2ePro')->__('Not Listed'),
|
170 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_LISTED => Mage::helper('M2ePro')->__('Active'),
|
171 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED => Mage::helper('M2ePro')->__('Inactive')
|
172 |
+
),
|
173 |
+
'frame_callback' => array($this, 'callbackColumnStatus')
|
174 |
+
));
|
175 |
+
|
176 |
+
$this->addColumn('goto_listing_item', array(
|
177 |
+
'header' => Mage::helper('M2ePro')->__('Manage'),
|
178 |
+
'align' => 'center',
|
179 |
+
'width' => '50px',
|
180 |
+
'type' => 'text',
|
181 |
+
'filter' => false,
|
182 |
+
'sortable' => false,
|
183 |
+
'frame_callback' => array($this, 'callbackColumnActions')
|
184 |
+
));
|
185 |
+
|
186 |
+
return parent::_prepareColumns();
|
187 |
+
}
|
188 |
+
|
189 |
+
// ####################################
|
190 |
+
|
191 |
+
public function callbackColumnProductId($value, $row, $column, $isExport)
|
192 |
+
{
|
193 |
+
$productId = (int)$row->getData('product_id');
|
194 |
+
$storeId = (int)$row->getData('store_id');
|
195 |
+
|
196 |
+
$withoutImageHtml = '<a href="'
|
197 |
+
.$this->getUrl('adminhtml/catalog_product/edit',
|
198 |
+
array('id' => $productId))
|
199 |
+
.'" target="_blank">'
|
200 |
+
.$productId
|
201 |
+
.'</a>';
|
202 |
+
|
203 |
+
$showProductsThumbnails = (bool)(int)Mage::helper('M2ePro/Module')->getConfig()
|
204 |
+
->getGroupValue('/view/','show_products_thumbnails');
|
205 |
+
if (!$showProductsThumbnails) {
|
206 |
+
return $withoutImageHtml;
|
207 |
+
}
|
208 |
+
|
209 |
+
/** @var $magentoProduct Ess_M2ePro_Model_Magento_Product */
|
210 |
+
$magentoProduct = Mage::getModel('M2ePro/Magento_Product');
|
211 |
+
$magentoProduct->setProductId($productId);
|
212 |
+
$magentoProduct->setStoreId($storeId);
|
213 |
+
|
214 |
+
$imageUrlResized = $magentoProduct->getThumbnailImageLink();
|
215 |
+
if (is_null($imageUrlResized)) {
|
216 |
+
return $withoutImageHtml;
|
217 |
+
}
|
218 |
+
|
219 |
+
$imageHtml = $productId.'<hr/><img src="'.$imageUrlResized.'" />';
|
220 |
+
$withImageHtml = str_replace('>'.$productId.'<','>'.$imageHtml.'<',$withoutImageHtml);
|
221 |
+
|
222 |
+
return $withImageHtml;
|
223 |
+
}
|
224 |
+
|
225 |
+
public function callbackColumnProductTitle($value, $row, $column, $isExport)
|
226 |
+
{
|
227 |
+
$value = '<span>'.Mage::helper('M2ePro')->escapeHtml($value).'</span>';
|
228 |
+
|
229 |
+
$urlParams = array();
|
230 |
+
$urlParams['id'] = $row->getData('listing_id');
|
231 |
+
$urlParams['back'] = Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_buy_listing/search');
|
232 |
+
|
233 |
+
$listingUrl = $this->getUrl('*/adminhtml_common_buy_listing/view',$urlParams);
|
234 |
+
$listingTitle = Mage::helper('M2ePro')->escapeHtml($row->getData('listing_title'));
|
235 |
+
|
236 |
+
if (strlen($listingTitle) > 50) {
|
237 |
+
$listingTitle = substr($listingTitle, 0, 50) . '...';
|
238 |
+
}
|
239 |
+
|
240 |
+
$value .= '<br/><hr style="border:none; border-top:1px solid silver; margin: 2px 0px;"/>';
|
241 |
+
$value .= '<strong>'
|
242 |
+
.Mage::helper('M2ePro')->__('Listing')
|
243 |
+
.': </strong> <a href="'
|
244 |
+
.$listingUrl
|
245 |
+
.'">'
|
246 |
+
.$listingTitle
|
247 |
+
.'</a>';
|
248 |
+
|
249 |
+
$tempSku = $row->getData('magento_sku');
|
250 |
+
is_null($tempSku)
|
251 |
+
&& $tempSku = Mage::getModel('M2ePro/Magento_Product')->setProductId($row->getData('product_id'))->getSku();
|
252 |
+
|
253 |
+
$value .= '<br/><strong>'
|
254 |
+
.Mage::helper('M2ePro')->__('SKU')
|
255 |
+
.':</strong> '
|
256 |
+
.Mage::helper('M2ePro')->escapeHtml($tempSku);
|
257 |
+
|
258 |
+
if ($row->getChildObject()->getVariationManager()->isVariationProduct() &&
|
259 |
+
$row->getChildObject()->getVariationManager()->isVariationProductMatched()
|
260 |
+
) {
|
261 |
+
$productOptions = $row->getChildObject()->getVariationManager()->getProductOptions();
|
262 |
+
|
263 |
+
$value .= '<br/>';
|
264 |
+
$value .= '<div style="font-size: 11px; color: grey;"><br/>';
|
265 |
+
foreach ($productOptions as $attribute => $option) {
|
266 |
+
!$option && $option = '--';
|
267 |
+
$value .= '<strong>' . Mage::helper('M2ePro')->escapeHtml($attribute) .
|
268 |
+
'</strong>: ' . Mage::helper('M2ePro')->escapeHtml($option) . '<br/>';
|
269 |
+
}
|
270 |
+
$value .= '</div>';
|
271 |
+
$value .= '<br/>';
|
272 |
+
}
|
273 |
+
|
274 |
+
return $value;
|
275 |
+
}
|
276 |
+
|
277 |
+
public function callbackColumnStockAvailability($value, $row, $column, $isExport)
|
278 |
+
{
|
279 |
+
if ((int)$row->getData('is_in_stock') <= 0) {
|
280 |
+
return '<span style="color: red;">'.$value.'</span>';
|
281 |
+
}
|
282 |
+
|
283 |
+
return $value;
|
284 |
+
}
|
285 |
+
|
286 |
+
public function callbackColumnSku($value, $row, $column, $isExport)
|
287 |
+
{
|
288 |
+
if (is_null($value) || $value === '') {
|
289 |
+
return Mage::helper('M2ePro')->__('N/A');
|
290 |
+
}
|
291 |
+
return $value;
|
292 |
+
}
|
293 |
+
|
294 |
+
public function callbackColumnGeneralId($value, $row, $column, $isExport)
|
295 |
+
{
|
296 |
+
if ((int)$row->getData('status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
297 |
+
if (is_null($value) || $value === '') {
|
298 |
+
return Mage::helper('M2ePro')->__('N/A');
|
299 |
+
}
|
300 |
+
} else {
|
301 |
+
if (is_null($value) || $value === '') {
|
302 |
+
return '<i style="color:gray;">receiving...</i>';
|
303 |
+
}
|
304 |
+
}
|
305 |
+
|
306 |
+
$url = Mage::helper('M2ePro/Component_Buy')->getItemUrl($value);
|
307 |
+
return '<a href="'.$url.'" target="_blank">'.$value.'</a>';
|
308 |
+
}
|
309 |
+
|
310 |
+
public function callbackColumnAvailableQty($value, $row, $column, $isExport)
|
311 |
+
{
|
312 |
+
if ((int)$row->getData('status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
313 |
+
if (is_null($value) || $value === '') {
|
314 |
+
return Mage::helper('M2ePro')->__('N/A');
|
315 |
+
}
|
316 |
+
} else {
|
317 |
+
if (is_null($value) || $value === '') {
|
318 |
+
return '<i style="color:gray;">'.Mage::helper('M2ePro')->__('receiving...').'</i>';
|
319 |
+
}
|
320 |
+
}
|
321 |
+
|
322 |
+
if ($value <= 0) {
|
323 |
+
return '<span style="color: red;">0</span>';
|
324 |
+
}
|
325 |
+
|
326 |
+
return Mage::app()->getLocale()->currency('USD')->toCurrency($value);
|
327 |
+
}
|
328 |
+
|
329 |
+
public function callbackColumnPrice($value, $row, $column, $isExport)
|
330 |
+
{
|
331 |
+
if ((int)$row->getData('status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
332 |
+
if (is_null($value) || $value === '') {
|
333 |
+
return Mage::helper('M2ePro')->__('N/A');
|
334 |
+
}
|
335 |
+
} else {
|
336 |
+
if (is_null($value) || $value === '') {
|
337 |
+
return '<i style="color:gray;">'.Mage::helper('M2ePro')->__('receiving...').'</i>';
|
338 |
+
}
|
339 |
+
}
|
340 |
+
|
341 |
+
if ((float)$value <= 0) {
|
342 |
+
return '<span style="color: #f00;">0</span>';
|
343 |
+
}
|
344 |
+
|
345 |
+
return $value;
|
346 |
+
}
|
347 |
+
|
348 |
+
public function callbackColumnStatus($value, $row, $column, $isExport)
|
349 |
+
{
|
350 |
+
switch ($row->getData('status')) {
|
351 |
+
|
352 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED:
|
353 |
+
$value = '<span style="color: gray;">' . $value . '</span>';
|
354 |
+
break;
|
355 |
+
|
356 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_LISTED:
|
357 |
+
$value = '<span style="color: green;">' . $value . '</span>';
|
358 |
+
break;
|
359 |
+
|
360 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED:
|
361 |
+
$value = '<span style="color: red;">'.$value.'</span>';
|
362 |
+
break;
|
363 |
+
|
364 |
+
default:
|
365 |
+
break;
|
366 |
+
}
|
367 |
+
|
368 |
+
$tempLocks = $row->getObjectLocks();
|
369 |
+
|
370 |
+
foreach ($tempLocks as $lock) {
|
371 |
+
|
372 |
+
switch ($lock->getTag()) {
|
373 |
+
|
374 |
+
case 'new_sku_action':
|
375 |
+
$title = Mage::helper('M2ePro')->__('Add New SKU in Progress...');
|
376 |
+
$value .= '<br/><span style="color: #605fff">['.$title.']</span>';
|
377 |
+
break;
|
378 |
+
|
379 |
+
case 'list_action':
|
380 |
+
$title = Mage::helper('M2ePro')->__('List in Progress...');
|
381 |
+
$value .= '<br/><span style="color: #605fff">['.$title.']</span>';
|
382 |
+
break;
|
383 |
+
|
384 |
+
case 'relist_action':
|
385 |
+
$title = Mage::helper('M2ePro')->__('Relist in Progress...');
|
386 |
+
$value .= '<br/><span style="color: #605fff">['.$title.']</span>';
|
387 |
+
break;
|
388 |
+
|
389 |
+
case 'revise_action':
|
390 |
+
$title = Mage::helper('M2ePro')->__('Revise in Progress...');
|
391 |
+
$value .= '<br/><span style="color: #605fff">['.$title.']</span>';
|
392 |
+
break;
|
393 |
+
|
394 |
+
case 'stop_action':
|
395 |
+
$title = Mage::helper('M2ePro')->__('Stop in Progress...');
|
396 |
+
$value .= '<br/><span style="color: #605fff">['.$title.']</span>';
|
397 |
+
break;
|
398 |
+
|
399 |
+
case 'stop_and_remove_action':
|
400 |
+
$title = Mage::helper('M2ePro')->__('Stop And Remove in Progress...');
|
401 |
+
$value .= '<br/><span style="color: #605fff">['.$title.']</span>';
|
402 |
+
break;
|
403 |
+
|
404 |
+
default:
|
405 |
+
break;
|
406 |
+
|
407 |
+
}
|
408 |
+
}
|
409 |
+
|
410 |
+
return $value;
|
411 |
+
}
|
412 |
+
|
413 |
+
public function callbackColumnActions($value, $row, $column, $isExport)
|
414 |
+
{
|
415 |
+
$altTitle = Mage::helper('M2ePro')->escapeHtml(Mage::helper('M2ePro')->__('Go to Listing'));
|
416 |
+
$iconSrc = $this->getSkinUrl('M2ePro/images/goto_listing.png');
|
417 |
+
$url = $this->getUrl('*/adminhtml_common_buy_listing/view/', array(
|
418 |
+
'id'=>$row->getData('listing_id'),
|
419 |
+
'filter'=>base64_encode(
|
420 |
+
'product_id[from]='.(int)$row->getData('product_id')
|
421 |
+
.'&product_id[to]='.(int)$row->getData('product_id')
|
422 |
+
)
|
423 |
+
));
|
424 |
+
|
425 |
+
$html = <<<HTML
|
426 |
+
<div style="float:right; margin:5px 15px 0 0;">
|
427 |
+
<a title="{$altTitle}" target="_blank" href="{$url}"><img src="{$iconSrc}" /></a>
|
428 |
+
</div>
|
429 |
+
HTML;
|
430 |
+
|
431 |
+
return $html;
|
432 |
+
}
|
433 |
+
|
434 |
+
protected function callbackFilterTitle($collection, $column)
|
435 |
+
{
|
436 |
+
$value = $column->getFilter()->getValue();
|
437 |
+
|
438 |
+
if ($value == null) {
|
439 |
+
return;
|
440 |
+
}
|
441 |
+
|
442 |
+
$collection->getSelect()->where('cpev.value LIKE ? OR cpe.sku LIKE ? OR l.title LIKE ?', '%'.$value.'%');
|
443 |
+
}
|
444 |
+
|
445 |
+
// ####################################
|
446 |
+
|
447 |
+
public function getGridUrl()
|
448 |
+
{
|
449 |
+
return $this->getUrl('*/adminhtml_common_buy_listing/searchGrid', array('_current'=>true));
|
450 |
+
}
|
451 |
+
|
452 |
+
public function getRowUrl($row)
|
453 |
+
{
|
454 |
+
return false;
|
455 |
+
}
|
456 |
+
|
457 |
+
// ####################################
|
458 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/View.php
ADDED
@@ -0,0 +1,596 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_View extends Mage_Adminhtml_Block_Widget_Grid_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingView');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_buy_listing_view';
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
// Set header text
|
21 |
+
//------------------------------
|
22 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
23 |
+
|
24 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
25 |
+
$headerText = Mage::helper('M2ePro')->__(
|
26 |
+
'View %component_name% Listing',
|
27 |
+
Mage::helper('M2ePro/Component_Buy')->getTitle()
|
28 |
+
);
|
29 |
+
} else {
|
30 |
+
$headerText = Mage::helper('M2ePro')->__('View Listing ');
|
31 |
+
}
|
32 |
+
|
33 |
+
$this->_headerText = $headerText;
|
34 |
+
//------------------------------
|
35 |
+
|
36 |
+
// Set buttons actions
|
37 |
+
//------------------------------
|
38 |
+
$this->removeButton('back');
|
39 |
+
$this->removeButton('reset');
|
40 |
+
$this->removeButton('delete');
|
41 |
+
$this->removeButton('add');
|
42 |
+
$this->removeButton('save');
|
43 |
+
$this->removeButton('edit');
|
44 |
+
//------------------------------
|
45 |
+
|
46 |
+
//------------------------------
|
47 |
+
$url = $this->getUrl('*/adminhtml_common_log/listing', array(
|
48 |
+
'id' => $listingData['id'],
|
49 |
+
'channel' => Ess_M2ePro_Block_Adminhtml_Common_Log_Tabs::TAB_ID_BUY
|
50 |
+
));
|
51 |
+
$this->_addButton('view_log', array(
|
52 |
+
'label' => Mage::helper('M2ePro')->__('View Log'),
|
53 |
+
'onclick' => 'window.open(\'' . $url . '\')',
|
54 |
+
'class' => 'button_link'
|
55 |
+
));
|
56 |
+
//------------------------------
|
57 |
+
|
58 |
+
//------------------------------
|
59 |
+
$this->_addButton('edit_settings', array(
|
60 |
+
'label' => Mage::helper('M2ePro')->__('Edit Settings'),
|
61 |
+
'onclick' => '',
|
62 |
+
'class' => 'drop_down edit_settings_drop_down'
|
63 |
+
));
|
64 |
+
//------------------------------
|
65 |
+
|
66 |
+
//------------------------------
|
67 |
+
$this->_addButton('add_products', array(
|
68 |
+
'label' => Mage::helper('M2ePro')->__('Add Products'),
|
69 |
+
'onclick' => '',
|
70 |
+
'class' => 'add drop_down add_products_drop_down'
|
71 |
+
));
|
72 |
+
//------------------------------
|
73 |
+
}
|
74 |
+
|
75 |
+
protected function _toHtml()
|
76 |
+
{
|
77 |
+
return '<div id="listing_view_progress_bar"></div>' .
|
78 |
+
'<div id="listing_container_errors_summary" class="errors_summary" style="display: none;"></div>' .
|
79 |
+
'<div id="listing_view_content_container">'.
|
80 |
+
parent::_toHtml() .
|
81 |
+
'</div>';
|
82 |
+
}
|
83 |
+
|
84 |
+
public function getGridHtml()
|
85 |
+
{
|
86 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
87 |
+
|
88 |
+
/** @var $helper Ess_M2ePro_Helper_Data */
|
89 |
+
$helper = Mage::helper('M2ePro');
|
90 |
+
|
91 |
+
//------------------------------
|
92 |
+
$urls = $helper->getControllerActions(
|
93 |
+
'adminhtml_common_listing_autoAction', array(
|
94 |
+
'listing_id' => $this->getRequest()->getParam('id'),
|
95 |
+
'component' => Ess_M2ePro_Helper_Component_Buy::NICK
|
96 |
+
)
|
97 |
+
);
|
98 |
+
$showAutoAction = json_encode((bool)$this->getRequest()->getParam('auto_actions'));
|
99 |
+
|
100 |
+
$path = 'adminhtml_common_log/listingProduct';
|
101 |
+
$urls[$path] = $this->getUrl('*/' . $path, array(
|
102 |
+
'channel' => Ess_M2ePro_Helper_Component_Buy::NICK,
|
103 |
+
'back'=>$helper->makeBackUrlParam('*/adminhtml_common_buy_listing/view', array('id' =>$listingData['id']))
|
104 |
+
));
|
105 |
+
|
106 |
+
$path = 'adminhtml_common_listing/duplicateProducts';
|
107 |
+
$urls[$path] = $this->getUrl('*/' . $path);
|
108 |
+
|
109 |
+
$urls = json_encode($urls);
|
110 |
+
//------------------------------
|
111 |
+
|
112 |
+
$component = Ess_M2ePro_Helper_Component_Buy::NICK;
|
113 |
+
$layout = $this->getLayout();
|
114 |
+
|
115 |
+
$temp = Mage::helper('M2ePro/Data_Session')->getValue('products_ids_for_list', true);
|
116 |
+
$productsIdsForList = empty($temp) ? '' : $temp;
|
117 |
+
|
118 |
+
$gridId = 'buyListingViewGrid' . $listingData['id'];
|
119 |
+
$ignoreListings = json_encode(array($listingData['id']));
|
120 |
+
|
121 |
+
$logViewUrl = $this->getUrl('*/adminhtml_common_log/listing', array(
|
122 |
+
'id' => $listingData['id'],
|
123 |
+
'channel' => Ess_M2ePro_Block_Adminhtml_Common_Log_Tabs::TAB_ID_BUY,
|
124 |
+
'back'=>$helper->makeBackUrlParam('*/adminhtml_common_buy_listing/view', array('id' =>$listingData['id']))
|
125 |
+
));
|
126 |
+
$getErrorsSummary = $this->getUrl('*/adminhtml_listing/getErrorsSummary');
|
127 |
+
|
128 |
+
$runListProducts = $this->getUrl('*/adminhtml_common_buy_listing/runListProducts');
|
129 |
+
$runReviseProducts = $this->getUrl('*/adminhtml_common_buy_listing/runReviseProducts');
|
130 |
+
$runRelistProducts = $this->getUrl('*/adminhtml_common_buy_listing/runRelistProducts');
|
131 |
+
$runStopProducts = $this->getUrl('*/adminhtml_common_buy_listing/runStopProducts');
|
132 |
+
$runStopAndRemoveProducts = $this->getUrl('*/adminhtml_common_buy_listing/runStopAndRemoveProducts');
|
133 |
+
|
134 |
+
$prepareData = $this->getUrl('*/adminhtml_listing_moving/prepareMoveToListing');
|
135 |
+
$getMoveToListingGridHtml = $this->getUrl('*/adminhtml_listing_moving/moveToListingGrid');
|
136 |
+
$getFailedProductsGridHtml = $this->getUrl('*/adminhtml_listing_moving/getFailedProductsGrid');
|
137 |
+
$tryToMoveToListing = $this->getUrl('*/adminhtml_listing_moving/tryToMoveToListing');
|
138 |
+
$moveToListing = $this->getUrl('*/adminhtml_listing_moving/moveToListing');
|
139 |
+
|
140 |
+
$getVariationEditPopupUrl = $this->getUrl('*/adminhtml_common_listing/getVariationEditPopup');
|
141 |
+
$getVariationManagePopupUrl = $this->getUrl('*/adminhtml_common_listing/getVariationManagePopup');
|
142 |
+
|
143 |
+
$variationEditActionUrl = $this->getUrl('*/adminhtml_common_listing/variationEdit');
|
144 |
+
$variationManageActionUrl = $this->getUrl('*/adminhtml_common_listing/variationManage');
|
145 |
+
$variationManageGenerateActionUrl = $this->getUrl('*/adminhtml_common_listing/variationManageGenerate');
|
146 |
+
|
147 |
+
$popupTitle = $helper->escapeJs($helper->__('Moving Rakuten.com Items'));
|
148 |
+
$popupTitleSingle = $helper->escapeJs($helper->__('Moving Rakuten.com Item'));
|
149 |
+
$failedProductsPopupTitle = $helper->escapeJs($helper->__('Products failed to move'));
|
150 |
+
|
151 |
+
$taskCompletedMessage = $helper->escapeJs($helper->__('Task completed. Please wait ...'));
|
152 |
+
$taskCompletedSuccessMessage = $helper->escapeJs(
|
153 |
+
$helper->__('"%task_title%" Task has successfully submitted to be processed.')
|
154 |
+
);
|
155 |
+
$taskCompletedWarningMessage = $helper->escapeJs($helper->__(
|
156 |
+
'"%task_title%" Task has completed with warnings. <a target="_blank" href="%url%">View Log</a> for details.'
|
157 |
+
));
|
158 |
+
$taskCompletedErrorMessage = $helper->escapeJs($helper->__(
|
159 |
+
'"%task_title%" Task has completed with errors. <a target="_blank" href="%url%">View Log</a> for details.'
|
160 |
+
));
|
161 |
+
|
162 |
+
$lockedObjNoticeMessage = $helper->escapeJs(
|
163 |
+
$helper->__('Some Rakuten.com request(s) are being processed now.')
|
164 |
+
);
|
165 |
+
$sendingDataToBuyMessage = $helper->escapeJs($helper->__(
|
166 |
+
'Sending %product_title% Product(s) data on Rakuten.com.'
|
167 |
+
));
|
168 |
+
$viewAllProductLogMessage = $helper->escapeJs($helper->__('View All Product Log.'));
|
169 |
+
|
170 |
+
$listingLockedMessage = $helper->escapeJs(
|
171 |
+
$helper->__('The Listing was locked by another process. Please try again later.')
|
172 |
+
);
|
173 |
+
$listingEmptyMessage = $helper->escapeJs($helper->__('Listing is empty.'));
|
174 |
+
|
175 |
+
$listingAllItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
176 |
+
->__('Listing All Items On Rakuten.com'));
|
177 |
+
$listingSelectedItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
178 |
+
->__('Listing Selected Items On Rakuten.com'));
|
179 |
+
$revisingSelectedItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
180 |
+
->__('Revising Selected Items On Rakuten.com'));
|
181 |
+
$relistingSelectedItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
182 |
+
->__('Relisting Selected Items On Rakuten.com'));
|
183 |
+
$stoppingSelectedItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
184 |
+
->__('Stopping Selected Items On Rakuten.com'));
|
185 |
+
$stoppingAndRemovingSelectedItemsMessage = Mage::helper('M2ePro')
|
186 |
+
->escapeJs(Mage::helper('M2ePro')
|
187 |
+
->__('Stopping On Rakuten.com And Removing From Listing Selected Items'));
|
188 |
+
$addNewSkuSelectedItemsMessage = Mage::helper('M2ePro')
|
189 |
+
->escapeJs(Mage::helper('M2ePro')
|
190 |
+
->__('Adding New SKU On Rakuten.com'));
|
191 |
+
|
192 |
+
$successfullyMovedMessage = $helper->escapeJs($helper->__('Product(s) was successfully Moved.'));
|
193 |
+
$productsWereNotMovedMessage = $helper->escapeJs(
|
194 |
+
$helper->__('Product(s) was not Moved. <a target="_blank" href="%url%">View Log</a> for details.')
|
195 |
+
);
|
196 |
+
$someProductsWereNotMovedMessage = $helper->escapeJs(
|
197 |
+
$helper->__('Some Product(s) was not Moved. <a target="_blank" href="%url%">View Log</a> for details.')
|
198 |
+
);
|
199 |
+
|
200 |
+
$selectItemsMessage = $helper->escapeJs(
|
201 |
+
$helper->__('Please select the Products you want to perform the Action on.')
|
202 |
+
);
|
203 |
+
$selectActionMessage = $helper->escapeJs($helper->__('Please select Action.'));
|
204 |
+
|
205 |
+
$successWord = $helper->escapeJs($helper->__('Success'));
|
206 |
+
$noticeWord = $helper->escapeJs($helper->__('Notice'));
|
207 |
+
$warningWord = $helper->escapeJs($helper->__('Warning'));
|
208 |
+
$errorWord = $helper->escapeJs($helper->__('Error'));
|
209 |
+
$closeWord = $helper->escapeJs($helper->__('Close'));
|
210 |
+
|
211 |
+
$naString = Mage::helper('M2ePro')->__('N/A');
|
212 |
+
$assignString = Mage::helper('M2ePro')->__('Assign Rakuten.com SKU');
|
213 |
+
|
214 |
+
$textConfirm = $helper->escapeJs($helper->__('Are you sure?'));
|
215 |
+
|
216 |
+
$searchBuyComSkuManual = $this->getUrl('*/adminhtml_common_buy_listing/searchBuyComSkuManual');
|
217 |
+
$suggestedBuyComSkuGridHmtl = $this->getUrl('*/adminhtml_common_buy_listing/getSuggestedBuyComSkuGrid');
|
218 |
+
$searchBuyComSkuAuto = $this->getUrl('*/adminhtml_common_buy_listing/searchBuyComSkuAuto');
|
219 |
+
$mapToBuyComSku = $this->getUrl('*/adminhtml_common_buy_listing/mapToBuyComSku');
|
220 |
+
$unmapFromBuyComSku = $this->getUrl('*/adminhtml_common_buy_listing/unmapFromBuyComSku');
|
221 |
+
|
222 |
+
$newGeneralId = $this->getUrl('*/adminhtml_common_buy_template_newProduct');
|
223 |
+
|
224 |
+
$marketplaceId = Mage::helper('M2ePro/Data_Global')->getValue('marketplace_id');
|
225 |
+
$marketplaceInstance = Mage::helper('M2ePro/Component_Buy')->getCachedObject('Marketplace',$marketplaceId);
|
226 |
+
$marketplace = json_encode($marketplaceInstance->getData());
|
227 |
+
|
228 |
+
$isMarketplaceSynchronized = json_encode($marketplaceInstance->getChildObject()->isSynchronized());
|
229 |
+
$marketplaceSynchUrl = $this->getUrl(
|
230 |
+
'*/adminhtml_common_marketplace/index',
|
231 |
+
array('tab' => Ess_M2ePro_Block_Adminhtml_Common_Marketplace::TAB_ID_RAKUTEN)
|
232 |
+
);
|
233 |
+
$notSynchronizedMarketplace = $helper->escapeJs(
|
234 |
+
$helper->__(
|
235 |
+
'In order to use New SKU functionality, please re-synchronize Marketplace data.'
|
236 |
+
).' '.
|
237 |
+
$helper->__(
|
238 |
+
'Press "Save And Update" Button after redirect on Marketplace Page.'
|
239 |
+
)
|
240 |
+
);
|
241 |
+
|
242 |
+
$enterProductSearchQueryMessage = $helper->escapeJs(
|
243 |
+
$helper->__('Please enter Product Title or Rakuten.com SKU/ISBN/UPC.')
|
244 |
+
);
|
245 |
+
$autoMapBuyComSkuProgressTitle = $helper->escapeJs($helper->__('Assign Rakuten.com SKU to Item(s)'));
|
246 |
+
$autoMapBuyComSkuErrorMessage = $helper->escapeJs(
|
247 |
+
$helper->__('Server is currently unavailable. Please try again later.')
|
248 |
+
);
|
249 |
+
|
250 |
+
$noVariationsLeftText = $helper->__('All Variations are already added.');
|
251 |
+
|
252 |
+
$translations = json_encode(array(
|
253 |
+
'Auto Add/Remove Rules' => $helper->__('Auto Add/Remove Rules'),
|
254 |
+
'Based on Magento Categories' => $helper->__('Based on Magento Categories'),
|
255 |
+
'You must select at least 1 Category.' => $helper->__('You must select at least 1 Category.'),
|
256 |
+
'Rule with the same Title already exists.' => $helper->__('Rule with the same Title already exists.')
|
257 |
+
));
|
258 |
+
|
259 |
+
$javascriptsMain = <<<JAVASCRIPT
|
260 |
+
<script type="text/javascript">
|
261 |
+
|
262 |
+
if (typeof M2ePro == 'undefined') {
|
263 |
+
M2ePro = {};
|
264 |
+
M2ePro.url = {};
|
265 |
+
M2ePro.formData = {};
|
266 |
+
M2ePro.customData = {};
|
267 |
+
M2ePro.text = {};
|
268 |
+
}
|
269 |
+
|
270 |
+
M2ePro.url.add({$urls});
|
271 |
+
M2ePro.translator.add({$translations});
|
272 |
+
|
273 |
+
M2ePro.productsIdsForList = '{$productsIdsForList}';
|
274 |
+
|
275 |
+
M2ePro.url.logViewUrl = '{$logViewUrl}';
|
276 |
+
M2ePro.url.getErrorsSummary = '{$getErrorsSummary}';
|
277 |
+
|
278 |
+
M2ePro.url.runListProducts = '{$runListProducts}';
|
279 |
+
M2ePro.url.runReviseProducts = '{$runReviseProducts}';
|
280 |
+
M2ePro.url.runRelistProducts = '{$runRelistProducts}';
|
281 |
+
M2ePro.url.runStopProducts = '{$runStopProducts}';
|
282 |
+
M2ePro.url.runStopAndRemoveProducts = '{$runStopAndRemoveProducts}';
|
283 |
+
|
284 |
+
M2ePro.url.searchBuyComSkuManual = '{$searchBuyComSkuManual}';
|
285 |
+
M2ePro.url.searchBuyComSkuAuto = '{$searchBuyComSkuAuto}';
|
286 |
+
M2ePro.url.suggestedBuyComSkuGrid = '{$suggestedBuyComSkuGridHmtl}';
|
287 |
+
M2ePro.url.mapToBuyComSku = '{$mapToBuyComSku}';
|
288 |
+
M2ePro.url.unmapFromBuyComSku = '{$unmapFromBuyComSku}';
|
289 |
+
|
290 |
+
M2ePro.url.prepareData = '{$prepareData}';
|
291 |
+
M2ePro.url.getGridHtml = '{$getMoveToListingGridHtml}';
|
292 |
+
M2ePro.url.getFailedProductsGridHtml = '{$getFailedProductsGridHtml}';
|
293 |
+
M2ePro.url.tryToMoveToListing = '{$tryToMoveToListing}';
|
294 |
+
M2ePro.url.moveToListing = '{$moveToListing}';
|
295 |
+
|
296 |
+
M2ePro.url.get_variation_edit_popup = '{$getVariationEditPopupUrl}';
|
297 |
+
M2ePro.url.get_variation_manage_popup = '{$getVariationManagePopupUrl}';
|
298 |
+
|
299 |
+
M2ePro.url.variation_edit_action = '{$variationEditActionUrl}';
|
300 |
+
M2ePro.url.variation_manage_action = '{$variationManageActionUrl}';
|
301 |
+
M2ePro.url.variation_manage_generate_action = '{$variationManageGenerateActionUrl}';
|
302 |
+
|
303 |
+
M2ePro.url.newGeneralId = '{$newGeneralId}';
|
304 |
+
M2ePro.url.marketplace_synch = '{$marketplaceSynchUrl}';
|
305 |
+
|
306 |
+
M2ePro.text.popup_title = '{$popupTitle}';
|
307 |
+
M2ePro.text.popup_title_single = '{$popupTitleSingle}';
|
308 |
+
M2ePro.text.failed_products_popup_title = '{$failedProductsPopupTitle}';
|
309 |
+
|
310 |
+
M2ePro.text.task_completed_message = '{$taskCompletedMessage}';
|
311 |
+
M2ePro.text.task_completed_success_message = '{$taskCompletedSuccessMessage}';
|
312 |
+
M2ePro.text.task_completed_warning_message = '{$taskCompletedWarningMessage}';
|
313 |
+
M2ePro.text.task_completed_error_message = '{$taskCompletedErrorMessage}';
|
314 |
+
|
315 |
+
M2ePro.text.locked_obj_notice = '{$lockedObjNoticeMessage}';
|
316 |
+
M2ePro.text.sending_data_message = '{$sendingDataToBuyMessage}';
|
317 |
+
M2ePro.text.view_all_product_log_message = '{$viewAllProductLogMessage}';
|
318 |
+
|
319 |
+
M2ePro.text.listing_locked_message = '{$listingLockedMessage}';
|
320 |
+
M2ePro.text.listing_empty_message = '{$listingEmptyMessage}';
|
321 |
+
|
322 |
+
M2ePro.text.listing_all_items_message = '{$listingAllItemsMessage}';
|
323 |
+
M2ePro.text.listing_selected_items_message = '{$listingSelectedItemsMessage}';
|
324 |
+
M2ePro.text.revising_selected_items_message = '{$revisingSelectedItemsMessage}';
|
325 |
+
M2ePro.text.relisting_selected_items_message = '{$relistingSelectedItemsMessage}';
|
326 |
+
M2ePro.text.stopping_selected_items_message = '{$stoppingSelectedItemsMessage}';
|
327 |
+
M2ePro.text.stopping_and_removing_selected_items_message = '{$stoppingAndRemovingSelectedItemsMessage}';
|
328 |
+
M2ePro.text.add_new_sku_selected_items_message = '{$addNewSkuSelectedItemsMessage}';
|
329 |
+
|
330 |
+
M2ePro.text.successfully_moved = '{$successfullyMovedMessage}';
|
331 |
+
M2ePro.text.products_were_not_moved = '{$productsWereNotMovedMessage}';
|
332 |
+
M2ePro.text.some_products_were_not_moved = '{$someProductsWereNotMovedMessage}';
|
333 |
+
|
334 |
+
M2ePro.text.select_items_message = '{$selectItemsMessage}';
|
335 |
+
M2ePro.text.select_action_message = '{$selectActionMessage}';
|
336 |
+
|
337 |
+
M2ePro.text.success_word = '{$successWord}';
|
338 |
+
M2ePro.text.notice_word = '{$noticeWord}';
|
339 |
+
M2ePro.text.warning_word = '{$warningWord}';
|
340 |
+
M2ePro.text.error_word = '{$errorWord}';
|
341 |
+
M2ePro.text.close_word = '{$closeWord}';
|
342 |
+
|
343 |
+
M2ePro.text.na = '{$naString}';
|
344 |
+
M2ePro.text.assign = '{$assignString}';
|
345 |
+
|
346 |
+
M2ePro.text.confirm = '{$textConfirm}';
|
347 |
+
|
348 |
+
M2ePro.text.enter_productSearch_query = '{$enterProductSearchQueryMessage}';
|
349 |
+
M2ePro.text.automap_buy_com_sku_progress_title = '{$autoMapBuyComSkuProgressTitle}';
|
350 |
+
M2ePro.text.automap_error_message = '{$autoMapBuyComSkuErrorMessage}';
|
351 |
+
|
352 |
+
M2ePro.text.no_variations_left = '{$noVariationsLeftText}';
|
353 |
+
|
354 |
+
M2ePro.text.not_synchronized_marketplace = '{$notSynchronizedMarketplace}';
|
355 |
+
|
356 |
+
M2ePro.customData.componentMode = '{$component}';
|
357 |
+
M2ePro.customData.gridId = '{$gridId}';
|
358 |
+
M2ePro.customData.ignoreListings = '{$ignoreListings}';
|
359 |
+
|
360 |
+
M2ePro.customData.marketplace = {$marketplace};
|
361 |
+
M2ePro.customData.isMarketplaceSynchronized = {$isMarketplaceSynchronized};
|
362 |
+
|
363 |
+
Event.observe(window, 'load', function() {
|
364 |
+
|
365 |
+
ListingGridHandlerObj = new BuyListingGridHandler(
|
366 |
+
'buyListingViewGrid{$listingData['id']}',
|
367 |
+
{$listingData['id']}
|
368 |
+
);
|
369 |
+
|
370 |
+
ListingGridHandlerObj.actionHandler.setOptions(M2ePro);
|
371 |
+
ListingGridHandlerObj.movingHandler.setOptions(M2ePro);
|
372 |
+
ListingGridHandlerObj.productSearchHandler.setOptions(M2ePro);
|
373 |
+
|
374 |
+
ListingProgressBarObj = new ProgressBar('listing_view_progress_bar');
|
375 |
+
GridWrapperObj = new AreaWrapper('listing_view_content_container');
|
376 |
+
|
377 |
+
ListingProductVariationHandlerObj = new ListingProductVariationHandler(M2ePro,
|
378 |
+
ListingGridHandlerObj);
|
379 |
+
|
380 |
+
if (M2ePro.productsIdsForList) {
|
381 |
+
ListingGridHandlerObj.getGridMassActionObj().checkedString = M2ePro.productsIdsForList;
|
382 |
+
ListingGridHandlerObj.actionHandler.listAction();
|
383 |
+
}
|
384 |
+
|
385 |
+
ListingAutoActionHandlerObj = new ListingAutoActionHandler();
|
386 |
+
if ({$showAutoAction}) {
|
387 |
+
ListingAutoActionHandlerObj.loadAutoActionHtml();
|
388 |
+
}
|
389 |
+
|
390 |
+
});
|
391 |
+
|
392 |
+
</script>
|
393 |
+
JAVASCRIPT;
|
394 |
+
|
395 |
+
$helpBlock = $layout->createBlock('M2ePro/adminhtml_common_buy_listing_view_help');
|
396 |
+
$productSearchMenuBlock = $layout->createBlock('M2ePro/adminhtml_common_buy_listing_productSearch_menu');
|
397 |
+
$productSearchBlock = $layout->createBlock('M2ePro/adminhtml_common_buy_listing_productSearch_main');
|
398 |
+
|
399 |
+
//------------------------------
|
400 |
+
$data = array(
|
401 |
+
'target_css_class' => 'edit_settings_drop_down',
|
402 |
+
'items' => $this->getTemplatesButtonDropDownItems()
|
403 |
+
);
|
404 |
+
$templatesDropDownBlock = $layout->createBlock('M2ePro/adminhtml_widget_button_dropDown');
|
405 |
+
$templatesDropDownBlock->setData($data);
|
406 |
+
//------------------------------
|
407 |
+
|
408 |
+
//------------------------------
|
409 |
+
$data = array(
|
410 |
+
'target_css_class' => 'add_products_drop_down',
|
411 |
+
'items' => $this->getAddProductsDropDownItems()
|
412 |
+
);
|
413 |
+
$addProductsDropDownBlock = $layout->createBlock('M2ePro/adminhtml_widget_button_dropDown');
|
414 |
+
$addProductsDropDownBlock->setData($data);
|
415 |
+
//------------------------------
|
416 |
+
|
417 |
+
//------------------------------
|
418 |
+
$listingSwitcher = $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_listing_view_listingSwitcher');
|
419 |
+
//------------------------------
|
420 |
+
|
421 |
+
//------------------------------
|
422 |
+
$viewHeaderBlock = $this->getLayout()->createBlock(
|
423 |
+
'M2ePro/adminhtml_listing_view_header','',
|
424 |
+
array('listing' => Mage::helper('M2ePro/Component_Buy')->getCachedObject('Listing',$listingData['id']))
|
425 |
+
);
|
426 |
+
//------------------------------
|
427 |
+
|
428 |
+
return $javascriptsMain
|
429 |
+
. $templatesDropDownBlock->toHtml()
|
430 |
+
. $listingSwitcher->toHtml()
|
431 |
+
. $addProductsDropDownBlock->toHtml()
|
432 |
+
. $helpBlock->toHtml()
|
433 |
+
. $viewHeaderBlock->toHtml()
|
434 |
+
. $productSearchMenuBlock->toHtml()
|
435 |
+
. $productSearchBlock->toHtml()
|
436 |
+
. parent::getGridHtml();
|
437 |
+
}
|
438 |
+
|
439 |
+
public function getHeaderHtml()
|
440 |
+
{
|
441 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
442 |
+
|
443 |
+
//------------------------------
|
444 |
+
$collection = Mage::getModel('M2ePro/Listing')->getCollection();
|
445 |
+
$collection->addFieldToFilter('component_mode', Ess_M2ePro_Helper_Component_Buy::NICK);
|
446 |
+
$collection->addFieldToFilter('id', array('neq' => $listingData['id']));
|
447 |
+
$collection->setPageSize(200);
|
448 |
+
$collection->setOrder('title', 'ASC');
|
449 |
+
|
450 |
+
$items = array();
|
451 |
+
foreach ($collection->getItems() as $item) {
|
452 |
+
$items[] = array(
|
453 |
+
'label' => $item->getTitle(),
|
454 |
+
'url' => $this->getUrl('*/*/view', array('id' => $item->getId()))
|
455 |
+
);
|
456 |
+
}
|
457 |
+
//------------------------------
|
458 |
+
|
459 |
+
if (count($items) == 0) {
|
460 |
+
return parent::getHeaderHtml();
|
461 |
+
}
|
462 |
+
|
463 |
+
//------------------------------
|
464 |
+
$data = array(
|
465 |
+
'target_css_class' => 'listing-profile-title',
|
466 |
+
'style' => 'max-height: 120px; overflow: auto; width: 200px;',
|
467 |
+
'items' => $items
|
468 |
+
);
|
469 |
+
$dropDownBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_button_dropDown');
|
470 |
+
$dropDownBlock->setData($data);
|
471 |
+
//------------------------------
|
472 |
+
|
473 |
+
return parent::getHeaderHtml() . $dropDownBlock->toHtml();
|
474 |
+
}
|
475 |
+
|
476 |
+
public function getHeaderText()
|
477 |
+
{
|
478 |
+
//------------------------------
|
479 |
+
$changeProfile = Mage::helper('M2ePro')->__('Change Listing');
|
480 |
+
$headerText = parent::getHeaderText();
|
481 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
482 |
+
$listingTitle = Mage::helper('M2ePro')->escapeHtml($listingData['title']);
|
483 |
+
//------------------------------
|
484 |
+
|
485 |
+
return <<<HTML
|
486 |
+
{$headerText} <a href="javascript: void(0);"
|
487 |
+
id="listing-profile-title"
|
488 |
+
class="listing-profile-title"
|
489 |
+
style="font-weight: bold;"
|
490 |
+
title="{$changeProfile}"><span class="drop_down_header">"{$listingTitle}"</span></a>
|
491 |
+
HTML;
|
492 |
+
}
|
493 |
+
|
494 |
+
protected function getTemplatesButtonDropDownItems()
|
495 |
+
{
|
496 |
+
$items = array();
|
497 |
+
|
498 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
499 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
500 |
+
'*/adminhtml_common_buy_listing/view',
|
501 |
+
array(
|
502 |
+
'id' => $listingData['id']
|
503 |
+
)
|
504 |
+
);
|
505 |
+
|
506 |
+
//------------------------------
|
507 |
+
$url = $this->getUrl(
|
508 |
+
'*/adminhtml_common_buy_listing/edit',
|
509 |
+
array(
|
510 |
+
'id' => $listingData['id'],
|
511 |
+
'back' => $backUrl,
|
512 |
+
'tab' => 'selling'
|
513 |
+
)
|
514 |
+
);
|
515 |
+
$items[] = array(
|
516 |
+
'url' => $url,
|
517 |
+
'label' => Mage::helper('M2ePro')->__('Selling Settings'),
|
518 |
+
'target' => '_blank'
|
519 |
+
);
|
520 |
+
//------------------------------
|
521 |
+
|
522 |
+
//------------------------------
|
523 |
+
$url = $this->getUrl(
|
524 |
+
'*/adminhtml_common_buy_listing/edit',
|
525 |
+
array(
|
526 |
+
'id' => $listingData['id'],
|
527 |
+
'back' => $backUrl,
|
528 |
+
'tab' => 'search'
|
529 |
+
)
|
530 |
+
);
|
531 |
+
$items[] = array(
|
532 |
+
'url' => $url,
|
533 |
+
'label' => Mage::helper('M2ePro')->__('Search Settings'),
|
534 |
+
'target' => '_blank'
|
535 |
+
);
|
536 |
+
//------------------------------
|
537 |
+
|
538 |
+
//------------------------------
|
539 |
+
$items[] = array(
|
540 |
+
'url' => 'javascript: void(0);',
|
541 |
+
'onclick' => 'ListingAutoActionHandlerObj.loadAutoActionHtml();',
|
542 |
+
'label' => Mage::helper('M2ePro')->__('Auto Add/Remove Rules')
|
543 |
+
);
|
544 |
+
//------------------------------
|
545 |
+
|
546 |
+
return $items;
|
547 |
+
}
|
548 |
+
|
549 |
+
public function getAddProductsDropDownItems()
|
550 |
+
{
|
551 |
+
$items = array();
|
552 |
+
|
553 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
554 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_buy_listing/view', array(
|
555 |
+
'id' => $listingData['id']
|
556 |
+
));
|
557 |
+
|
558 |
+
//------------------------------
|
559 |
+
$url = $this->getUrl(
|
560 |
+
'*/adminhtml_common_listing_productAdd/index',
|
561 |
+
array(
|
562 |
+
'id' => $listingData['id'],
|
563 |
+
'back' => $backUrl,
|
564 |
+
'component' => Ess_M2ePro_Helper_Component_Buy::NICK,
|
565 |
+
'clear' => 1,
|
566 |
+
'step' => 2,
|
567 |
+
'source' => Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_SourceMode::SOURCE_LIST
|
568 |
+
)
|
569 |
+
);
|
570 |
+
$items[] = array(
|
571 |
+
'url' => $url,
|
572 |
+
'label' => Mage::helper('M2ePro')->__('From Products List')
|
573 |
+
);
|
574 |
+
//------------------------------
|
575 |
+
|
576 |
+
//------------------------------
|
577 |
+
$url = $this->getUrl(
|
578 |
+
'*/adminhtml_common_listing_productAdd/index',
|
579 |
+
array(
|
580 |
+
'id' => $listingData['id'],
|
581 |
+
'back' => $backUrl,
|
582 |
+
'component' => Ess_M2ePro_Helper_Component_Buy::NICK,
|
583 |
+
'clear' => 1,
|
584 |
+
'step' => 2,
|
585 |
+
'source' => Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_SourceMode::SOURCE_CATEGORIES
|
586 |
+
)
|
587 |
+
);
|
588 |
+
$items[] = array(
|
589 |
+
'url' => $url,
|
590 |
+
'label' => Mage::helper('M2ePro')->__('From Categories')
|
591 |
+
);
|
592 |
+
//------------------------------
|
593 |
+
|
594 |
+
return $items;
|
595 |
+
}
|
596 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/View/Grid.php
ADDED
@@ -0,0 +1,972 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_View_Grid
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Magento_Product_Grid_Abstract
|
9 |
+
{
|
10 |
+
public $hideMassactionColumn = false;
|
11 |
+
|
12 |
+
/** @var $sellingFormatTemplate Ess_M2ePro_Model_Buy_Template_SellingFormat */
|
13 |
+
private $sellingFormatTemplate = NULL;
|
14 |
+
|
15 |
+
private $lockedDataCache = array();
|
16 |
+
|
17 |
+
// ####################################
|
18 |
+
|
19 |
+
public function __construct()
|
20 |
+
{
|
21 |
+
parent::__construct();
|
22 |
+
|
23 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
24 |
+
|
25 |
+
// Initialization block
|
26 |
+
//------------------------------
|
27 |
+
$this->setId('buyListingViewGrid'.$listingData['id']);
|
28 |
+
//------------------------------
|
29 |
+
|
30 |
+
$this->showAdvancedFilterProductsOption = false;
|
31 |
+
|
32 |
+
$this->sellingFormatTemplate = Mage::helper('M2ePro/Component_Buy')->getCachedObject(
|
33 |
+
'Template_SellingFormat', $listingData['template_selling_format_id'], NULL,
|
34 |
+
array('template')
|
35 |
+
);
|
36 |
+
}
|
37 |
+
|
38 |
+
// ####################################
|
39 |
+
|
40 |
+
protected function _prepareCollection()
|
41 |
+
{
|
42 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
43 |
+
|
44 |
+
// Get collection
|
45 |
+
//----------------------------
|
46 |
+
/* @var $collection Mage_Core_Model_Mysql4_Collection_Abstract */
|
47 |
+
$collection = Mage::getConfig()->getModelInstance('Ess_M2ePro_Model_Mysql4_Magento_Product_Collection',
|
48 |
+
Mage::getModel('catalog/product')->getResource());
|
49 |
+
$collection
|
50 |
+
->setListingProductModeOn()
|
51 |
+
->addAttributeToSelect('name')
|
52 |
+
->addAttributeToSelect('sku')
|
53 |
+
->joinTable(
|
54 |
+
array('cisi' => 'cataloginventory/stock_item'),
|
55 |
+
'product_id=entity_id',
|
56 |
+
array('qty' => 'qty'),
|
57 |
+
'{{table}}.stock_id=1',
|
58 |
+
'left'
|
59 |
+
);
|
60 |
+
|
61 |
+
//----------------------------
|
62 |
+
|
63 |
+
$collection->joinTable(
|
64 |
+
array('lp' => 'M2ePro/Listing_Product'),
|
65 |
+
'product_id=entity_id',
|
66 |
+
array(
|
67 |
+
'id' => 'id',
|
68 |
+
'component_mode' => 'component_mode',
|
69 |
+
'buy_status' => 'status',
|
70 |
+
'additional_data' => 'additional_data'
|
71 |
+
),
|
72 |
+
array(
|
73 |
+
'listing_id' => (int)$listingData['id']
|
74 |
+
)
|
75 |
+
);
|
76 |
+
$collection->joinTable(
|
77 |
+
array('blp' => 'M2ePro/Buy_Listing_Product'),
|
78 |
+
'listing_product_id=id',
|
79 |
+
array(
|
80 |
+
'general_id' => 'general_id',
|
81 |
+
'buy_sku' => 'sku',
|
82 |
+
'online_price' => 'online_price',
|
83 |
+
'online_qty' => 'online_qty',
|
84 |
+
'search_settings_status' => 'search_settings_status',
|
85 |
+
'search_settings_data' => 'search_settings_data'
|
86 |
+
),
|
87 |
+
null
|
88 |
+
);
|
89 |
+
//----------------------------
|
90 |
+
|
91 |
+
//exit($collection->getSelect()->__toString());
|
92 |
+
|
93 |
+
// Set collection to grid
|
94 |
+
$this->setCollection($collection);
|
95 |
+
|
96 |
+
return parent::_prepareCollection();
|
97 |
+
}
|
98 |
+
|
99 |
+
protected function _prepareColumns()
|
100 |
+
{
|
101 |
+
$this->addColumn('product_id', array(
|
102 |
+
'header' => Mage::helper('M2ePro')->__('Product ID'),
|
103 |
+
'align' => 'right',
|
104 |
+
'width' => '100px',
|
105 |
+
'type' => 'number',
|
106 |
+
'index' => 'entity_id',
|
107 |
+
'filter_index' => 'entity_id',
|
108 |
+
'frame_callback' => array($this, 'callbackColumnProductId')
|
109 |
+
));
|
110 |
+
|
111 |
+
$this->addColumn('name', array(
|
112 |
+
'header' => Mage::helper('M2ePro')->__('Product Title / Product SKU'),
|
113 |
+
'align' => 'left',
|
114 |
+
//'width' => '300px',
|
115 |
+
'type' => 'text',
|
116 |
+
'index' => 'name',
|
117 |
+
'filter_index' => 'name',
|
118 |
+
'frame_callback' => array($this, 'callbackColumnProductTitle'),
|
119 |
+
'filter_condition_callback' => array($this, 'callbackFilterTitle')
|
120 |
+
));
|
121 |
+
|
122 |
+
$this->addColumn('sku', array(
|
123 |
+
'header' => Mage::helper('M2ePro')->__('Reference ID'),
|
124 |
+
'align' => 'left',
|
125 |
+
'width' => '150px',
|
126 |
+
'type' => 'text',
|
127 |
+
'index' => 'buy_sku',
|
128 |
+
'filter_index' => 'buy_sku',
|
129 |
+
'frame_callback' => array($this, 'callbackColumnSku')
|
130 |
+
));
|
131 |
+
|
132 |
+
$this->addColumn('general_id', array(
|
133 |
+
'header' => Mage::helper('M2ePro')->__('Rakuten.com SKU'),
|
134 |
+
'align' => 'left',
|
135 |
+
'width' => '80px',
|
136 |
+
'type' => 'text',
|
137 |
+
'index' => 'general_id',
|
138 |
+
'filter_index' => 'general_id',
|
139 |
+
'frame_callback' => array($this, 'callbackColumnGeneralId')
|
140 |
+
));
|
141 |
+
|
142 |
+
$this->addColumn('online_qty', array(
|
143 |
+
'header' => Mage::helper('M2ePro')->__('QTY'),
|
144 |
+
'align' => 'right',
|
145 |
+
'width' => '70px',
|
146 |
+
'type' => 'number',
|
147 |
+
'index' => 'online_qty',
|
148 |
+
'filter_index' => 'online_qty',
|
149 |
+
'frame_callback' => array($this, 'callbackColumnAvailableQty')
|
150 |
+
));
|
151 |
+
|
152 |
+
$this->addColumn('online_price', array(
|
153 |
+
'header' => Mage::helper('M2ePro')->__('Price'),
|
154 |
+
'align' => 'right',
|
155 |
+
'width' => '70px',
|
156 |
+
'type' => 'number',
|
157 |
+
'index' => 'online_price',
|
158 |
+
'filter_index' => 'online_price',
|
159 |
+
'frame_callback' => array($this, 'callbackColumnPrice')
|
160 |
+
));
|
161 |
+
|
162 |
+
$this->addColumn('status', array(
|
163 |
+
'header' => Mage::helper('M2ePro')->__('Status'),
|
164 |
+
'width' => '125px',
|
165 |
+
'index' => 'buy_status',
|
166 |
+
'filter_index' => 'buy_status',
|
167 |
+
'type' => 'options',
|
168 |
+
'sortable' => false,
|
169 |
+
'options' => array(
|
170 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED => Mage::helper('M2ePro')->__('Not Listed'),
|
171 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_LISTED => Mage::helper('M2ePro')->__('Active'),
|
172 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED => Mage::helper('M2ePro')->__('Inactive'),
|
173 |
+
),
|
174 |
+
'frame_callback' => array($this, 'callbackColumnStatus')
|
175 |
+
));
|
176 |
+
|
177 |
+
if (Mage::helper('M2ePro/Module')->isDevelopmentMode()) {
|
178 |
+
$this->addColumn('developer_action', array(
|
179 |
+
'header' => Mage::helper('M2ePro')->__('Actions'),
|
180 |
+
'align' => 'left',
|
181 |
+
'width' => '120px',
|
182 |
+
'type' => 'text',
|
183 |
+
'renderer' => 'M2ePro/adminhtml_listing_view_grid_column_renderer_developerAction',
|
184 |
+
'index' => 'value',
|
185 |
+
'filter' => false,
|
186 |
+
'sortable' => false,
|
187 |
+
'js_handler' => 'ListingGridHandlerObj'
|
188 |
+
));
|
189 |
+
}
|
190 |
+
|
191 |
+
return parent::_prepareColumns();
|
192 |
+
}
|
193 |
+
|
194 |
+
protected function _prepareMassaction()
|
195 |
+
{
|
196 |
+
// Set massaction identifiers
|
197 |
+
//--------------------------------
|
198 |
+
$this->setMassactionIdField('id');
|
199 |
+
$this->setMassactionIdFieldOnlyIndexValue(true);
|
200 |
+
//--------------------------------
|
201 |
+
|
202 |
+
// Set mass-action
|
203 |
+
//--------------------------------
|
204 |
+
$groups = array(
|
205 |
+
'actions' => Mage::helper('M2ePro')->__('Actions'),
|
206 |
+
'rekuten_sku' => Mage::helper('M2ePro')->__('Rakuten.com SKU'),
|
207 |
+
'other' => Mage::helper('M2ePro')->__('Other')
|
208 |
+
);
|
209 |
+
|
210 |
+
$this->getMassactionBlock()->setGroups($groups);
|
211 |
+
|
212 |
+
$this->getMassactionBlock()->addItem('list', array(
|
213 |
+
'label' => Mage::helper('M2ePro')->__('List Item(s)'),
|
214 |
+
'url' => '',
|
215 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
216 |
+
), 'actions');
|
217 |
+
|
218 |
+
$this->getMassactionBlock()->addItem('revise', array(
|
219 |
+
'label' => Mage::helper('M2ePro')->__('Revise Item(s)'),
|
220 |
+
'url' => '',
|
221 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
222 |
+
), 'actions');
|
223 |
+
|
224 |
+
$this->getMassactionBlock()->addItem('relist', array(
|
225 |
+
'label' => Mage::helper('M2ePro')->__('Relist Item(s)'),
|
226 |
+
'url' => '',
|
227 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
228 |
+
), 'actions');
|
229 |
+
|
230 |
+
$this->getMassactionBlock()->addItem('stop', array(
|
231 |
+
'label' => Mage::helper('M2ePro')->__('Stop Item(s)'),
|
232 |
+
'url' => '',
|
233 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
234 |
+
), 'actions');
|
235 |
+
|
236 |
+
$this->getMassactionBlock()->addItem('stopAndRemove', array(
|
237 |
+
'label' => Mage::helper('M2ePro')->__('Stop on Channel / Remove from Listing'),
|
238 |
+
'url' => '',
|
239 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
240 |
+
), 'actions');
|
241 |
+
|
242 |
+
$this->getMassactionBlock()->addItem('newGeneralId', array(
|
243 |
+
'label' => Mage::helper('M2ePro')->__('Add New'),
|
244 |
+
'url' => '',
|
245 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
246 |
+
), 'rekuten_sku');
|
247 |
+
|
248 |
+
$this->getMassactionBlock()->addItem('assignGeneralId', array(
|
249 |
+
'label' => Mage::helper('M2ePro')->__('Assign'),
|
250 |
+
'url' => '',
|
251 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
252 |
+
), 'rekuten_sku');
|
253 |
+
|
254 |
+
$this->getMassactionBlock()->addItem('unassignGeneralId', array(
|
255 |
+
'label' => Mage::helper('M2ePro')->__('Unassign'),
|
256 |
+
'url' => '',
|
257 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
258 |
+
), 'rekuten_sku');
|
259 |
+
|
260 |
+
$this->getMassactionBlock()->addItem('moving', array(
|
261 |
+
'label' => Mage::helper('M2ePro')->__('Move Item(s) to Another Listing'),
|
262 |
+
'url' => '',
|
263 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
264 |
+
), 'other');
|
265 |
+
|
266 |
+
$this->getMassactionBlock()->addItem('duplicate', array(
|
267 |
+
'label' => Mage::helper('M2ePro')->__('Duplicate'),
|
268 |
+
'url' => '',
|
269 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
270 |
+
), 'other');
|
271 |
+
//--------------------------------
|
272 |
+
|
273 |
+
return parent::_prepareMassaction();
|
274 |
+
}
|
275 |
+
|
276 |
+
public function getMassactionBlockName()
|
277 |
+
{
|
278 |
+
return 'M2ePro/adminhtml_grid_massaction';
|
279 |
+
}
|
280 |
+
|
281 |
+
// ####################################
|
282 |
+
|
283 |
+
public function callbackColumnProductTitle($productTitle, $row, $column, $isExport)
|
284 |
+
{
|
285 |
+
$productTitle = Mage::helper('M2ePro')->escapeHtml($productTitle);
|
286 |
+
|
287 |
+
$value = '<span>'.$productTitle.'</span>';
|
288 |
+
|
289 |
+
$tempSku = $row->getData('sku');
|
290 |
+
is_null($tempSku)
|
291 |
+
&& $tempSku = Mage::getModel('M2ePro/Magento_Product')->setProductId($row->getData('entity_id'))->getSku();
|
292 |
+
|
293 |
+
$value .= '<br/><strong>'.Mage::helper('M2ePro')->__('SKU') .
|
294 |
+
':</strong> '.Mage::helper('M2ePro')->escapeHtml($tempSku) . '<br/>';
|
295 |
+
|
296 |
+
$listingProductId = (int)$row->getData('id');
|
297 |
+
/** @var Ess_M2ePro_Model_Listing_Product $listingProduct */
|
298 |
+
$listingProduct = Mage::helper('M2ePro/Component_Buy')->getObject('Listing_Product', $listingProductId);
|
299 |
+
|
300 |
+
if (!$listingProduct->getChildObject()->getVariationManager()->isVariationProduct()) {
|
301 |
+
return $value;
|
302 |
+
}
|
303 |
+
|
304 |
+
$productOptions = $listingProduct->getChildObject()->getVariationManager()->getProductOptions();
|
305 |
+
|
306 |
+
if (!empty($productOptions)) {
|
307 |
+
$value .= '<div style="font-size: 11px; color: grey; margin-left: 7px"><br/>';
|
308 |
+
foreach ($productOptions as $attribute => $option) {
|
309 |
+
!$option && $option = '--';
|
310 |
+
$value .= '<strong>' . Mage::helper('M2ePro')->escapeHtml($attribute) .
|
311 |
+
'</strong>: ' . Mage::helper('M2ePro')->escapeHtml($option) . '<br/>';
|
312 |
+
}
|
313 |
+
$value .= '</div>';
|
314 |
+
}
|
315 |
+
|
316 |
+
if (!$listingProduct->getChildObject()->getVariationManager()->isVariationProductMatched()) {
|
317 |
+
|
318 |
+
$popupTitle = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')->escapeHtml(
|
319 |
+
Mage::helper('M2ePro')->__('Manage "%product_title%" Options', $productTitle))
|
320 |
+
);
|
321 |
+
$linkTitle = Mage::helper('M2ePro')->__('Manage Options');
|
322 |
+
$linkContent = '<img height="12" width="12" src="'.$this->getSkinUrl('M2ePro/images/add.png').'">';
|
323 |
+
|
324 |
+
$value.= <<<HTML
|
325 |
+
<div style="clear: both"></div>
|
326 |
+
<div style="float: left; margin: 0 0 0 5px">
|
327 |
+
<a href="javascript:"
|
328 |
+
onclick="ListingProductVariationHandlerObj
|
329 |
+
.setListingProductId({$listingProductId})
|
330 |
+
.showManagePopup('{$popupTitle}');"
|
331 |
+
title="{$linkTitle}">{$linkContent}</a>
|
332 |
+
</div>
|
333 |
+
HTML;
|
334 |
+
|
335 |
+
$linkContent = Mage::helper('M2ePro')->__('Manage Options');
|
336 |
+
|
337 |
+
$value .= <<<HTML
|
338 |
+
<div style="float: left; margin: 0 0 0 5px">
|
339 |
+
<a href="javascript:"
|
340 |
+
onclick="ListingProductVariationHandlerObj
|
341 |
+
.setListingProductId({$listingProductId})
|
342 |
+
.showManagePopup('{$popupTitle}');"
|
343 |
+
title="{$linkTitle}">{$linkContent}</a>
|
344 |
+
</div>
|
345 |
+
HTML;
|
346 |
+
|
347 |
+
return $value;
|
348 |
+
}
|
349 |
+
|
350 |
+
// ---------------------------------
|
351 |
+
$hasInActionLock = $this->getLockedData($row);
|
352 |
+
$hasInActionLock = $hasInActionLock['in_action'];
|
353 |
+
// ---------------------------------
|
354 |
+
|
355 |
+
if (!$hasInActionLock) {
|
356 |
+
|
357 |
+
$popupTitle = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')->escapeHtml(
|
358 |
+
Mage::helper('M2ePro')->__('Edit "%product_title%" Variation', $productTitle))
|
359 |
+
);
|
360 |
+
$linkTitle = Mage::helper('M2ePro')->__('Edit Variation');
|
361 |
+
$linkContent = '<img width="12" height="12" src="'.$this->getSkinUrl('M2ePro/images/pencil.png').'">';
|
362 |
+
|
363 |
+
$value .= <<<HTML
|
364 |
+
<div style="clear: both"></div>
|
365 |
+
<div style="margin: 0 0 0 7px; float: left;">
|
366 |
+
<a href="javascript:"
|
367 |
+
onclick="ListingProductVariationHandlerObj
|
368 |
+
.setListingProductId({$listingProductId})
|
369 |
+
.showEditPopup('{$popupTitle}');"
|
370 |
+
title="{$linkTitle}">{$linkContent}</a>
|
371 |
+
</div>
|
372 |
+
HTML;
|
373 |
+
}
|
374 |
+
|
375 |
+
$popupTitle = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')->escapeHtml(
|
376 |
+
Mage::helper('M2ePro')->__('Add Another "%product_title%" Variations', $productTitle))
|
377 |
+
);
|
378 |
+
$linkTitle = Mage::helper('M2ePro')->__('Add Another Variation(s)');
|
379 |
+
$linkContent = '<img width="12" height="12" src="'.$this->getSkinUrl('M2ePro/images/add.png').'">';
|
380 |
+
|
381 |
+
$value.= <<<HTML
|
382 |
+
<div style="margin: 0 0 0 5px; float: left;">
|
383 |
+
<a href="javascript:"
|
384 |
+
onclick="ListingProductVariationHandlerObj
|
385 |
+
.setListingProductId({$listingProductId})
|
386 |
+
.showManagePopup('{$popupTitle}');"
|
387 |
+
title="{$linkTitle}">{$linkContent}</a>
|
388 |
+
</div>
|
389 |
+
HTML;
|
390 |
+
|
391 |
+
return $value;
|
392 |
+
}
|
393 |
+
|
394 |
+
public function callbackColumnSku($value, $row, $column, $isExport)
|
395 |
+
{
|
396 |
+
if (is_null($value) || $value === '') {
|
397 |
+
return Mage::helper('M2ePro')->__('N/A');
|
398 |
+
}
|
399 |
+
return $value;
|
400 |
+
}
|
401 |
+
|
402 |
+
public function callbackColumnGeneralId($generalId, $row, $column, $isExport)
|
403 |
+
{
|
404 |
+
if (empty($generalId)) {
|
405 |
+
return $this->getGeneralIdColumnValueEmptyGeneralId($row);
|
406 |
+
}
|
407 |
+
|
408 |
+
return $this->getGeneralIdColumnValueNotEmptyGeneralId($row);
|
409 |
+
}
|
410 |
+
|
411 |
+
public function callbackColumnAvailableQty($value, $row, $column, $isExport)
|
412 |
+
{
|
413 |
+
if ((int)$row->getData('buy_status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
414 |
+
if (is_null($value) || $value === '') {
|
415 |
+
return Mage::helper('M2ePro')->__('N/A');
|
416 |
+
}
|
417 |
+
} else {
|
418 |
+
if (is_null($value) || $value === '') {
|
419 |
+
return '<i style="color:gray;">receiving...</i>';
|
420 |
+
}
|
421 |
+
}
|
422 |
+
|
423 |
+
if ($value <= 0) {
|
424 |
+
return '<span style="color: red;">0</span>';
|
425 |
+
}
|
426 |
+
|
427 |
+
return $value;
|
428 |
+
}
|
429 |
+
|
430 |
+
public function callbackColumnPrice($value, $row, $column, $isExport)
|
431 |
+
{
|
432 |
+
if ((int)$row->getData('buy_status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
433 |
+
if (is_null($value) || $value === '') {
|
434 |
+
return Mage::helper('M2ePro')->__('N/A');
|
435 |
+
}
|
436 |
+
} else {
|
437 |
+
if (is_null($value) || $value === '') {
|
438 |
+
return '<i style="color:gray;">receiving...</i>';
|
439 |
+
}
|
440 |
+
}
|
441 |
+
|
442 |
+
if ((float)$value <= 0) {
|
443 |
+
return '<span style="color: #f00;">0</span>';
|
444 |
+
}
|
445 |
+
|
446 |
+
return Mage::app()->getLocale()->currency('USD')->toCurrency($value);
|
447 |
+
}
|
448 |
+
|
449 |
+
public function callbackColumnStatus($value, $row, $column, $isExport)
|
450 |
+
{
|
451 |
+
$listingProductId = (int)$row->getData('id');
|
452 |
+
|
453 |
+
$html = $this->getViewLogIconHtml($listingProductId);
|
454 |
+
|
455 |
+
/** @var Ess_M2ePro_Model_Listing_Product $listingProduct */
|
456 |
+
$listingProduct = Mage::helper('M2ePro/Component_Buy')->getObject('Listing_Product',$listingProductId);
|
457 |
+
|
458 |
+
$synchNote = $listingProduct->getSetting('additional_data', 'synch_template_list_rules_note');
|
459 |
+
if (!empty($synchNote)) {
|
460 |
+
|
461 |
+
$synchNote = Mage::helper('M2ePro/View')->getModifiedLogMessage($synchNote);
|
462 |
+
|
463 |
+
if (empty($html)) {
|
464 |
+
$html = <<<HTML
|
465 |
+
<span style="float:right;">
|
466 |
+
<img id="map_link_error_icon_{$row->getId()}"
|
467 |
+
class="tool-tip-image"
|
468 |
+
style="vertical-align: middle;"
|
469 |
+
src="{$this->getSkinUrl('M2ePro/images/warning.png')}">
|
470 |
+
<span class="tool-tip-message tool-tip-warning tip-left" style="display:none;">
|
471 |
+
<img src="{$this->getSkinUrl('M2ePro/images/i_notice.gif')}">
|
472 |
+
<span>{$synchNote}</span>
|
473 |
+
</span>
|
474 |
+
</span>
|
475 |
+
HTML;
|
476 |
+
} else {
|
477 |
+
$html .= <<<HTML
|
478 |
+
<div id="synch_template_list_rules_note_{$listingProductId}" style="display: none">{$synchNote}</div>
|
479 |
+
HTML;
|
480 |
+
}
|
481 |
+
}
|
482 |
+
|
483 |
+
switch ($row->getData('buy_status')) {
|
484 |
+
|
485 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED:
|
486 |
+
$html .= '<span style="color: gray;">' . $value . '</span>';
|
487 |
+
break;
|
488 |
+
|
489 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_LISTED:
|
490 |
+
$html .= '<span style="color: green;">' . $value . '</span>';
|
491 |
+
break;
|
492 |
+
|
493 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED:
|
494 |
+
$html .= '<span style="color: red;">'.$value.'</span>';
|
495 |
+
break;
|
496 |
+
|
497 |
+
default:
|
498 |
+
break;
|
499 |
+
}
|
500 |
+
|
501 |
+
$tempLocks = $this->getLockedData($row);
|
502 |
+
$tempLocks = $tempLocks['object_locks'];
|
503 |
+
|
504 |
+
foreach ($tempLocks as $lock) {
|
505 |
+
|
506 |
+
switch ($lock->getTag()) {
|
507 |
+
|
508 |
+
case 'new_sku_action':
|
509 |
+
$html .= '<br/><span style="color: #605fff">[Add New SKU in Progress...]</span>';
|
510 |
+
break;
|
511 |
+
|
512 |
+
case 'list_action':
|
513 |
+
$html .= '<br/><span style="color: #605fff">[List in Progress...]</span>';
|
514 |
+
break;
|
515 |
+
|
516 |
+
case 'relist_action':
|
517 |
+
$html .= '<br/><span style="color: #605fff">[Relist in Progress...]</span>';
|
518 |
+
break;
|
519 |
+
|
520 |
+
case 'revise_action':
|
521 |
+
$html .= '<br/><span style="color: #605fff">[Revise in Progress...]</span>';
|
522 |
+
break;
|
523 |
+
|
524 |
+
case 'stop_action':
|
525 |
+
$html .= '<br/><span style="color: #605fff">[Stop in Progress...]</span>';
|
526 |
+
break;
|
527 |
+
|
528 |
+
case 'stop_and_remove_action':
|
529 |
+
$html .= '<br/><span style="color: #605fff">[Stop And Remove in Progress...]</span>';
|
530 |
+
break;
|
531 |
+
|
532 |
+
default:
|
533 |
+
break;
|
534 |
+
}
|
535 |
+
}
|
536 |
+
|
537 |
+
return $html;
|
538 |
+
}
|
539 |
+
|
540 |
+
protected function callbackFilterTitle($collection, $column)
|
541 |
+
{
|
542 |
+
$value = $column->getFilter()->getValue();
|
543 |
+
|
544 |
+
if ($value == null) {
|
545 |
+
return;
|
546 |
+
}
|
547 |
+
|
548 |
+
$collection->addFieldToFilter(
|
549 |
+
array(
|
550 |
+
array('attribute'=>'sku','like'=>'%'.$value.'%'),
|
551 |
+
array('attribute'=>'name', 'like'=>'%'.$value.'%')
|
552 |
+
)
|
553 |
+
);
|
554 |
+
}
|
555 |
+
|
556 |
+
// ############################################
|
557 |
+
|
558 |
+
private function getGeneralIdColumnValueEmptyGeneralId($row)
|
559 |
+
{
|
560 |
+
// ---------------------------------
|
561 |
+
if ((int)$row->getData('buy_status') != Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
562 |
+
return <<<HTML
|
563 |
+
<i style="color:gray;">receiving...</i>
|
564 |
+
HTML;
|
565 |
+
}
|
566 |
+
// ---------------------------------
|
567 |
+
|
568 |
+
// ---------------------------------
|
569 |
+
$iconPath = $this->getSkinUrl('M2ePro/images/search_statuses/');
|
570 |
+
// ---------------------------------
|
571 |
+
|
572 |
+
// ---------------------------------
|
573 |
+
$lpId = $row->getData('id');
|
574 |
+
|
575 |
+
$productTitle = Mage::helper('M2ePro')->escapeHtml($row->getData('value'));
|
576 |
+
if (strlen($productTitle) > 60) {
|
577 |
+
$productTitle = substr($productTitle, 0, 60) . '...';
|
578 |
+
}
|
579 |
+
$productTitle = Mage::helper('M2ePro')->escapeJs($productTitle);
|
580 |
+
// ---------------------------------
|
581 |
+
|
582 |
+
// ---------------------------------
|
583 |
+
$hasInActionLock = $this->getLockedData($row);
|
584 |
+
$hasInActionLock = $hasInActionLock['in_action'];
|
585 |
+
// ---------------------------------
|
586 |
+
|
587 |
+
$na = Mage::helper('M2ePro')->__('N/A');
|
588 |
+
|
589 |
+
$templateNewProductId = $row->getData('template_new_product_id');
|
590 |
+
if (!empty($templateNewProductId)) {
|
591 |
+
|
592 |
+
$newSkuTemplateUrl = $this->getUrl(
|
593 |
+
'*/adminhtml_common_buy_template_newProduct/edit/',
|
594 |
+
array(
|
595 |
+
'id' => $templateNewProductId,
|
596 |
+
'listing_product_id' => $lpId,
|
597 |
+
'save_and_assign' => 0,
|
598 |
+
'back' => Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_buy_listing/view',array(
|
599 |
+
'id' => $row->getData('listing_id'),
|
600 |
+
))
|
601 |
+
)
|
602 |
+
);
|
603 |
+
|
604 |
+
$newSkuTemplateTitle = Mage::getModel('M2ePro/Buy_Template_NewProduct')
|
605 |
+
->load($templateNewProductId)
|
606 |
+
->getData('title');
|
607 |
+
|
608 |
+
if ($hasInActionLock) {
|
609 |
+
return $newSkuTemplateTitle;
|
610 |
+
}
|
611 |
+
|
612 |
+
$tip = Mage::helper('M2ePro')->__('Unassign New SKU Policy');
|
613 |
+
$iconSrc = $iconPath.'unassign.png';
|
614 |
+
|
615 |
+
return <<<HTML
|
616 |
+
|
617 |
+
<a href="{$newSkuTemplateUrl}">{$newSkuTemplateTitle}</a>
|
618 |
+
<a href="javascript:;" title="{$tip}"
|
619 |
+
onclick="ListingGridHandlerObj.productSearchHandler.showUnmapFromGeneralIdPrompt('{$lpId}');">
|
620 |
+
<img src="{$iconSrc}" alt="" width="16" height="16">
|
621 |
+
</a>
|
622 |
+
HTML;
|
623 |
+
}
|
624 |
+
// ---------------------------------
|
625 |
+
|
626 |
+
// ---------------------------------
|
627 |
+
$searchSettingsData = $row->getData('search_settings_data');
|
628 |
+
|
629 |
+
if (!is_null($searchSettingsData)) {
|
630 |
+
$searchSettingsData = @json_decode($searchSettingsData,true);
|
631 |
+
}
|
632 |
+
// ---------------------------------
|
633 |
+
|
634 |
+
if (!empty($searchSettingsData['data'])) {
|
635 |
+
|
636 |
+
$tip = Mage::helper('M2ePro')->__('Choose Rakuten.com SKU from the list');
|
637 |
+
$iconSrc = $iconPath.'list.png';
|
638 |
+
|
639 |
+
return <<<HTML
|
640 |
+
{$na}
|
641 |
+
<a href="javascript:;" title="{$tip}"
|
642 |
+
onclick="ListingGridHandlerObj.productSearchHandler.openPopUp(1,'{$productTitle}',{$lpId})">
|
643 |
+
<img src="{$iconSrc}" alt="" width="16" height="16">
|
644 |
+
</a>
|
645 |
+
HTML;
|
646 |
+
}
|
647 |
+
|
648 |
+
$searchSettingsStatus = $row->getData('search_settings_status');
|
649 |
+
|
650 |
+
if ($searchSettingsStatus == Ess_M2ePro_Model_Buy_Listing_Product::SEARCH_SETTINGS_STATUS_NOT_FOUND) {
|
651 |
+
|
652 |
+
$tip = Mage::helper('M2ePro')->__(
|
653 |
+
'There were no Products found on Rakuten.com according to the Listing Search Settings.'
|
654 |
+
);
|
655 |
+
$tip = Mage::helper('M2ePro')->escapeJs($tip);
|
656 |
+
|
657 |
+
$iconSrc = $iconPath.'error.png';
|
658 |
+
|
659 |
+
return <<<HTML
|
660 |
+
{$na}
|
661 |
+
<a href="javascript: void(0);" title="{$tip}"
|
662 |
+
onclick="ListingGridHandlerObj.productSearchHandler.openPopUp(0,'{$productTitle}',{$lpId},'{$tip}');">
|
663 |
+
<img src="{$iconSrc}" alt="" width="16" height="16">
|
664 |
+
</a>
|
665 |
+
HTML;
|
666 |
+
}
|
667 |
+
|
668 |
+
$tip = Mage::helper('M2ePro')->__('Search for Rakuten.com SKU');
|
669 |
+
$iconSrc = $iconPath.'search.png';
|
670 |
+
|
671 |
+
return <<<HTML
|
672 |
+
{$na}
|
673 |
+
<a href="javascript:;" title="{$tip}"
|
674 |
+
onclick="ListingGridHandlerObj.productSearchHandler.openPopUp(0,'{$productTitle}',{$lpId});">
|
675 |
+
<img src="{$iconSrc}" alt="" width="16" height="16">
|
676 |
+
</a>
|
677 |
+
HTML;
|
678 |
+
}
|
679 |
+
|
680 |
+
private function getGeneralIdColumnValueNotEmptyGeneralId($row)
|
681 |
+
{
|
682 |
+
$generalId = $row->getData('general_id');
|
683 |
+
|
684 |
+
$url = Mage::helper('M2ePro/Component_Buy')->getItemUrl($generalId);
|
685 |
+
|
686 |
+
if ((int)$row->getData('buy_status') != Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
687 |
+
$conditionTitle = '';
|
688 |
+
switch ((int)$row->getData('condition')) {
|
689 |
+
case Ess_M2ePro_Model_Buy_Listing::CONDITION_NEW:
|
690 |
+
$conditionTitle = Mage::helper('M2ePro')->__('New');
|
691 |
+
break;
|
692 |
+
case Ess_M2ePro_Model_Buy_Listing::CONDITION_USED_LIKE_NEW:
|
693 |
+
$conditionTitle = Mage::helper('M2ePro')->__('Used - Like New');
|
694 |
+
break;
|
695 |
+
case Ess_M2ePro_Model_Buy_Listing::CONDITION_USED_VERY_GOOD:
|
696 |
+
$conditionTitle = Mage::helper('M2ePro')->__('Used - Very Good');
|
697 |
+
break;
|
698 |
+
case Ess_M2ePro_Model_Buy_Listing::CONDITION_USED_GOOD:
|
699 |
+
$conditionTitle = Mage::helper('M2ePro')->__('Used - Good');
|
700 |
+
break;
|
701 |
+
case Ess_M2ePro_Model_Buy_Listing::CONDITION_USED_ACCEPTABLE:
|
702 |
+
$conditionTitle = Mage::helper('M2ePro')->__('Used - Acceptable');
|
703 |
+
break;
|
704 |
+
case Ess_M2ePro_Model_Buy_Listing::CONDITION_REFURBISHED:
|
705 |
+
$conditionTitle = Mage::helper('M2ePro')->__('Refurbished');
|
706 |
+
break;
|
707 |
+
}
|
708 |
+
return <<<HTML
|
709 |
+
<a href="{$url}" target="_blank">{$generalId}</a><br/>
|
710 |
+
<span style="color:gray;">{$conditionTitle}</span>
|
711 |
+
HTML;
|
712 |
+
}
|
713 |
+
|
714 |
+
$iconPath = $this->getSkinUrl('M2ePro/images/search_statuses/');
|
715 |
+
|
716 |
+
$generalIdSearchInfo = @json_decode($row->getData('general_id_search_info'), true);
|
717 |
+
|
718 |
+
if (!empty($generalIdSearchInfo['is_set_automatic'])) {
|
719 |
+
|
720 |
+
$tip = Mage::helper('M2ePro')->__('Rakuten.com SKU was found automatically');
|
721 |
+
|
722 |
+
$text = <<<HTML
|
723 |
+
<a href="{$url}" target="_blank" title="{$tip}" style="color:#40AADB;">{$generalId}</a>
|
724 |
+
HTML;
|
725 |
+
|
726 |
+
} else {
|
727 |
+
|
728 |
+
$text = <<<HTML
|
729 |
+
<a href="{$url}" target="_blank">{$generalId}</a>
|
730 |
+
HTML;
|
731 |
+
|
732 |
+
}
|
733 |
+
|
734 |
+
// ---------------------------------
|
735 |
+
$hasInActionLock = $this->getLockedData($row);
|
736 |
+
$hasInActionLock = $hasInActionLock['in_action'];
|
737 |
+
// ---------------------------------
|
738 |
+
|
739 |
+
if ($hasInActionLock) {
|
740 |
+
return $text;
|
741 |
+
}
|
742 |
+
|
743 |
+
$tip = Mage::helper('M2ePro')->__('Unassign Rakuten.com SKU');
|
744 |
+
$iconSrc = $iconPath.'unassign.png';
|
745 |
+
|
746 |
+
$id = $row->getData('id');
|
747 |
+
|
748 |
+
$text .= <<<HTML
|
749 |
+
<a href="javascript:;" onclick="ListingGridHandlerObj.productSearchHandler.showUnmapFromGeneralIdPrompt({$id});"
|
750 |
+
title="{$tip}">
|
751 |
+
<img src="{$iconSrc}" width="16" height="16"/>
|
752 |
+
</a>
|
753 |
+
HTML;
|
754 |
+
|
755 |
+
return $text;
|
756 |
+
}
|
757 |
+
|
758 |
+
// ############################################
|
759 |
+
|
760 |
+
public function getViewLogIconHtml($listingProductId)
|
761 |
+
{
|
762 |
+
$listingProductId = (int)$listingProductId;
|
763 |
+
|
764 |
+
// Get last messages
|
765 |
+
//--------------------------
|
766 |
+
/** @var $connRead Varien_Db_Adapter_Pdo_Mysql */
|
767 |
+
$connRead = Mage::getSingleton('core/resource')->getConnection('core_read');
|
768 |
+
|
769 |
+
$dbSelect = $connRead->select()
|
770 |
+
->from(
|
771 |
+
Mage::getResourceModel('M2ePro/Listing_Log')->getMainTable(),
|
772 |
+
array('action_id','action','type','description','create_date','initiator')
|
773 |
+
)
|
774 |
+
->where('`listing_product_id` = ?',$listingProductId)
|
775 |
+
->where('`action_id` IS NOT NULL')
|
776 |
+
->order(array('id DESC'))
|
777 |
+
->limit(30);
|
778 |
+
|
779 |
+
$logRows = $connRead->fetchAll($dbSelect);
|
780 |
+
//--------------------------
|
781 |
+
|
782 |
+
// Get grouped messages by action_id
|
783 |
+
//--------------------------
|
784 |
+
$actionsRows = array();
|
785 |
+
$tempActionRows = array();
|
786 |
+
$lastActionId = false;
|
787 |
+
|
788 |
+
foreach ($logRows as $row) {
|
789 |
+
|
790 |
+
$row['description'] = Mage::helper('M2ePro/View')->getModifiedLogMessage($row['description']);
|
791 |
+
|
792 |
+
if ($row['action_id'] !== $lastActionId) {
|
793 |
+
if (count($tempActionRows) > 0) {
|
794 |
+
$actionsRows[] = array(
|
795 |
+
'type' => $this->getMainTypeForActionId($tempActionRows),
|
796 |
+
'date' => $this->getMainDateForActionId($tempActionRows),
|
797 |
+
'action' => $this->getActionForAction($tempActionRows[0]),
|
798 |
+
'initiator' => $this->getInitiatorForAction($tempActionRows[0]),
|
799 |
+
'items' => $tempActionRows
|
800 |
+
);
|
801 |
+
$tempActionRows = array();
|
802 |
+
}
|
803 |
+
$lastActionId = $row['action_id'];
|
804 |
+
}
|
805 |
+
$tempActionRows[] = $row;
|
806 |
+
}
|
807 |
+
|
808 |
+
if (count($tempActionRows) > 0) {
|
809 |
+
$actionsRows[] = array(
|
810 |
+
'type' => $this->getMainTypeForActionId($tempActionRows),
|
811 |
+
'date' => $this->getMainDateForActionId($tempActionRows),
|
812 |
+
'action' => $this->getActionForAction($tempActionRows[0]),
|
813 |
+
'initiator' => $this->getInitiatorForAction($tempActionRows[0]),
|
814 |
+
'items' => $tempActionRows
|
815 |
+
);
|
816 |
+
}
|
817 |
+
|
818 |
+
if (count($actionsRows) <= 0) {
|
819 |
+
return '';
|
820 |
+
}
|
821 |
+
|
822 |
+
$tips = array(
|
823 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'Last Action was completed successfully.',
|
824 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'Last Action was completed with error(s).',
|
825 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'Last Action was completed with warning(s).'
|
826 |
+
);
|
827 |
+
|
828 |
+
$icons = array(
|
829 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'normal',
|
830 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'error',
|
831 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'warning'
|
832 |
+
);
|
833 |
+
|
834 |
+
$summary = $this->getLayout()->createBlock('M2ePro/adminhtml_log_grid_summary', '', array(
|
835 |
+
'entity_id' => $listingProductId,
|
836 |
+
'rows' => $actionsRows,
|
837 |
+
'tips' => $tips,
|
838 |
+
'icons' => $icons,
|
839 |
+
'view_help_handler' => 'ListingGridHandlerObj.viewItemHelp',
|
840 |
+
'hide_help_handler' => 'ListingGridHandlerObj.hideItemHelp',
|
841 |
+
));
|
842 |
+
|
843 |
+
return $summary->toHtml();
|
844 |
+
}
|
845 |
+
|
846 |
+
public function getActionForAction($actionRows)
|
847 |
+
{
|
848 |
+
$string = '';
|
849 |
+
|
850 |
+
switch ($actionRows['action']) {
|
851 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_NEW_SKU_PRODUCT_ON_COMPONENT:
|
852 |
+
$string = Mage::helper('M2ePro')->__('New SKU');
|
853 |
+
break;
|
854 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_LIST_PRODUCT_ON_COMPONENT:
|
855 |
+
$string = Mage::helper('M2ePro')->__('List');
|
856 |
+
break;
|
857 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_RELIST_PRODUCT_ON_COMPONENT:
|
858 |
+
$string = Mage::helper('M2ePro')->__('Relist');
|
859 |
+
break;
|
860 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_REVISE_PRODUCT_ON_COMPONENT:
|
861 |
+
$string = Mage::helper('M2ePro')->__('Revise');
|
862 |
+
break;
|
863 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_STOP_PRODUCT_ON_COMPONENT:
|
864 |
+
$string = Mage::helper('M2ePro')->__('Stop');
|
865 |
+
break;
|
866 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_STOP_AND_REMOVE_PRODUCT:
|
867 |
+
$string = Mage::helper('M2ePro')->__('Stop on Channel / Remove from Listing');
|
868 |
+
break;
|
869 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_CHANGE_STATUS_ON_CHANNEL:
|
870 |
+
$string = Mage::helper('M2ePro')->__('Status Change');
|
871 |
+
break;
|
872 |
+
}
|
873 |
+
|
874 |
+
return $string;
|
875 |
+
}
|
876 |
+
|
877 |
+
public function getInitiatorForAction($actionRows)
|
878 |
+
{
|
879 |
+
$string = '';
|
880 |
+
|
881 |
+
switch ((int)$actionRows['initiator']) {
|
882 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_UNKNOWN:
|
883 |
+
$string = '';
|
884 |
+
break;
|
885 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_USER:
|
886 |
+
$string = Mage::helper('M2ePro')->__('Manual');
|
887 |
+
break;
|
888 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION:
|
889 |
+
$string = Mage::helper('M2ePro')->__('Automatic');
|
890 |
+
break;
|
891 |
+
}
|
892 |
+
|
893 |
+
return $string;
|
894 |
+
}
|
895 |
+
|
896 |
+
public function getMainTypeForActionId($actionRows)
|
897 |
+
{
|
898 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS;
|
899 |
+
|
900 |
+
foreach ($actionRows as $row) {
|
901 |
+
if ($row['type'] == Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR) {
|
902 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR;
|
903 |
+
break;
|
904 |
+
}
|
905 |
+
if ($row['type'] == Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING) {
|
906 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING;
|
907 |
+
}
|
908 |
+
}
|
909 |
+
|
910 |
+
return $type;
|
911 |
+
}
|
912 |
+
|
913 |
+
public function getMainDateForActionId($actionRows)
|
914 |
+
{
|
915 |
+
$format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
|
916 |
+
return Mage::app()->getLocale()->date(strtotime($actionRows[0]['create_date']))->toString($format);
|
917 |
+
}
|
918 |
+
|
919 |
+
// ####################################
|
920 |
+
|
921 |
+
public function getGridUrl()
|
922 |
+
{
|
923 |
+
return $this->getUrl('*/adminhtml_common_buy_listing/viewGrid', array('_current'=>true));
|
924 |
+
}
|
925 |
+
|
926 |
+
public function getRowUrl($row)
|
927 |
+
{
|
928 |
+
return false;
|
929 |
+
}
|
930 |
+
|
931 |
+
// ####################################
|
932 |
+
|
933 |
+
protected function _toHtml()
|
934 |
+
{
|
935 |
+
$javascriptsMain = <<<JAVASCRIPT
|
936 |
+
<script type="text/javascript">
|
937 |
+
|
938 |
+
if (typeof ListingGridHandlerObj != 'undefined') {
|
939 |
+
ListingGridHandlerObj.afterInitPage();
|
940 |
+
}
|
941 |
+
|
942 |
+
Event.observe(window, 'load', function() {
|
943 |
+
setTimeout(function() {
|
944 |
+
ListingGridHandlerObj.afterInitPage();
|
945 |
+
}, 350);
|
946 |
+
});
|
947 |
+
|
948 |
+
</script>
|
949 |
+
JAVASCRIPT;
|
950 |
+
|
951 |
+
return parent::_toHtml().$javascriptsMain;
|
952 |
+
}
|
953 |
+
|
954 |
+
// ####################################
|
955 |
+
|
956 |
+
private function getLockedData($row)
|
957 |
+
{
|
958 |
+
$listingProductId = $row->getData('id');
|
959 |
+
if (!isset($this->lockedDataCache[$listingProductId])) {
|
960 |
+
$objectLocks = Mage::getModel('M2ePro/Listing_Product')->load($listingProductId)->getObjectLocks();
|
961 |
+
$tempArray = array(
|
962 |
+
'object_locks' => $objectLocks,
|
963 |
+
'in_action' => !empty($objectLocks),
|
964 |
+
);
|
965 |
+
$this->lockedDataCache[$listingProductId] = $tempArray;
|
966 |
+
}
|
967 |
+
|
968 |
+
return $this->lockedDataCache[$listingProductId];
|
969 |
+
}
|
970 |
+
|
971 |
+
// ####################################
|
972 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/View/Help.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_View_Help extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingViewHelp');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/buy/listing/view/help.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/View/ListingSwitcher.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2011 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_View_ListingSwitcher
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Listing_View_ListingSwitcher_Abstract
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
|
16 |
+
$this->setAddListingUrl('*/adminhtml_common_buy_listing/add/step/1/');
|
17 |
+
}
|
18 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Order/Edit/ShippingAddress.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Order_Edit_ShippingAddress
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Form_Container
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
//------------------------------
|
16 |
+
$this->setId('buyOrderEditShippingAddress');
|
17 |
+
$this->_blockGroup = 'M2ePro';
|
18 |
+
$this->_controller = 'adminhtml_common_buy_order_edit';
|
19 |
+
$this->_mode = 'shippingAddress';
|
20 |
+
//------------------------------
|
21 |
+
|
22 |
+
// Set header text
|
23 |
+
//------------------------------
|
24 |
+
$this->_headerText = Mage::helper('M2ePro')->__('Edit Shipping Address');
|
25 |
+
//------------------------------
|
26 |
+
|
27 |
+
// Set buttons actions
|
28 |
+
//------------------------------
|
29 |
+
$this->removeButton('back');
|
30 |
+
$this->removeButton('reset');
|
31 |
+
$this->removeButton('delete');
|
32 |
+
$this->removeButton('add');
|
33 |
+
$this->removeButton('save');
|
34 |
+
$this->removeButton('edit');
|
35 |
+
//------------------------------
|
36 |
+
|
37 |
+
if (!is_null($this->getRequest()->getParam('back'))) {
|
38 |
+
//------------------------------
|
39 |
+
$url = Mage::helper('M2ePro')->getBackUrl('*/adminhtml_common_order/index');
|
40 |
+
$this->_addButton('back', array(
|
41 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
42 |
+
'onclick' => 'CommonHandlerObj.back_click(\''.$url.'\')',
|
43 |
+
'class' => 'back'
|
44 |
+
));
|
45 |
+
//------------------------------
|
46 |
+
} else {
|
47 |
+
//------------------------------
|
48 |
+
$url = $this->getUrl('*/*/view', array('id' => $this->getRequest()->getParam('id')));
|
49 |
+
$this->_addButton('back', array(
|
50 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
51 |
+
'onclick' => 'CommonHandlerObj.back_click(\''.$url.'\')',
|
52 |
+
'class' => 'back'
|
53 |
+
));
|
54 |
+
//------------------------------
|
55 |
+
}
|
56 |
+
|
57 |
+
//------------------------------
|
58 |
+
$this->_addButton('save', array(
|
59 |
+
'label' => Mage::helper('M2ePro')->__('Save Order Address'),
|
60 |
+
'onclick' => 'CommonHandlerObj.save_click()',
|
61 |
+
'class' => 'save'
|
62 |
+
));
|
63 |
+
//------------------------------
|
64 |
+
}
|
65 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Order/Edit/ShippingAddress/Form.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Order_Edit_ShippingAddress_Form extends Mage_Adminhtml_Block_Widget_Form
|
8 |
+
{
|
9 |
+
private $order;
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('buyOrderEditShippingAddressForm');
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$this->setTemplate('M2ePro/common/buy/order/edit/shipping_address.phtml');
|
21 |
+
$this->order = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
22 |
+
}
|
23 |
+
|
24 |
+
protected function _prepareForm()
|
25 |
+
{
|
26 |
+
$form = new Varien_Data_Form(array(
|
27 |
+
'id' => 'edit_form',
|
28 |
+
'action' => $this->getUrl('*/*/save'),
|
29 |
+
'method' => 'post',
|
30 |
+
'enctype' => 'multipart/form-data'
|
31 |
+
));
|
32 |
+
|
33 |
+
$form->setUseContainer(true);
|
34 |
+
$this->setForm($form);
|
35 |
+
|
36 |
+
return parent::_prepareForm();
|
37 |
+
}
|
38 |
+
|
39 |
+
protected function _beforeToHtml()
|
40 |
+
{
|
41 |
+
try {
|
42 |
+
$regionCode = $this->order->getShippingAddress()->getRegionCode();
|
43 |
+
} catch (Exception $e) {
|
44 |
+
$regionCode = null;
|
45 |
+
}
|
46 |
+
|
47 |
+
$this->setData('buyer_name', $this->order->getData('buyer_name'));
|
48 |
+
$this->setData('buyer_email', $this->order->getData('buyer_email'));
|
49 |
+
$this->setData('address', $this->order->getShippingAddress()->getData());
|
50 |
+
$this->setData('region_code', $regionCode);
|
51 |
+
$this->setData('company', $this->order->getChildObject()->getBillingAddress()->getData('company'));
|
52 |
+
$this->setData('phone', $this->order->getChildObject()->getBillingAddress()->getData('phone'));
|
53 |
+
|
54 |
+
return parent::_beforeToHtml();
|
55 |
+
}
|
56 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Order/Grid.php
ADDED
@@ -0,0 +1,434 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
/** @var $itemsCollection Ess_M2ePro_Model_Mysql4_Order_Item_Collection */
|
10 |
+
private $itemsCollection = NULL;
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->setId('buyOrderGrid');
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
// Set default values
|
22 |
+
//------------------------------
|
23 |
+
$this->setDefaultSort('purchase_create_date');
|
24 |
+
$this->setDefaultDir('DESC');
|
25 |
+
$this->setSaveParametersInSession(true);
|
26 |
+
$this->setUseAjax(true);
|
27 |
+
//------------------------------
|
28 |
+
}
|
29 |
+
|
30 |
+
public function getMassactionBlockName()
|
31 |
+
{
|
32 |
+
return 'M2ePro/adminhtml_grid_massaction';
|
33 |
+
}
|
34 |
+
|
35 |
+
protected function _prepareCollection()
|
36 |
+
{
|
37 |
+
$collection = Mage::helper('M2ePro/Component_Buy')->getCollection('Order');
|
38 |
+
|
39 |
+
$collection->getSelect()->joinLeft(
|
40 |
+
array('so' => Mage::getSingleton('core/resource')->getTableName('sales/order')),
|
41 |
+
'(so.entity_id = `main_table`.magento_order_id)',
|
42 |
+
array('magento_order_num' => 'increment_id')
|
43 |
+
);
|
44 |
+
|
45 |
+
// Add Filter By Account
|
46 |
+
//------------------------------
|
47 |
+
if ($accountId = $this->getRequest()->getParam('buyAccount')) {
|
48 |
+
$collection->addFieldToFilter('`main_table`.account_id', $accountId);
|
49 |
+
}
|
50 |
+
//------------------------------
|
51 |
+
|
52 |
+
// Add Not Created Magento Orders Filter
|
53 |
+
//------------------------------
|
54 |
+
if ($this->getRequest()->getParam('not_created_only')) {
|
55 |
+
$collection->addFieldToFilter('magento_order_id', array('null' => true));
|
56 |
+
}
|
57 |
+
//------------------------------
|
58 |
+
|
59 |
+
$this->setCollection($collection);
|
60 |
+
|
61 |
+
return parent::_prepareCollection();
|
62 |
+
}
|
63 |
+
|
64 |
+
protected function _afterLoadCollection()
|
65 |
+
{
|
66 |
+
$this->itemsCollection = Mage::helper('M2ePro/Component_Buy')
|
67 |
+
->getCollection('Order_Item')
|
68 |
+
->addFieldToFilter('order_id', array('in' => $this->getCollection()->getColumnValues('id')));
|
69 |
+
|
70 |
+
return parent::_afterLoadCollection();
|
71 |
+
}
|
72 |
+
|
73 |
+
protected function _prepareColumns()
|
74 |
+
{
|
75 |
+
$this->addColumn('purchase_create_date', array(
|
76 |
+
'header' => Mage::helper('M2ePro')->__('Sale Date'),
|
77 |
+
'align' => 'left',
|
78 |
+
'type' => 'datetime',
|
79 |
+
'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM),
|
80 |
+
'index' => 'purchase_create_date',
|
81 |
+
'width' => '170px'
|
82 |
+
));
|
83 |
+
|
84 |
+
$this->addColumn('magento_order_num', array(
|
85 |
+
'header' => Mage::helper('M2ePro')->__('Magento Order #'),
|
86 |
+
'align' => 'left',
|
87 |
+
'index' => 'so.increment_id',
|
88 |
+
'width' => '110px',
|
89 |
+
'frame_callback' => array($this, 'callbackColumnMagentoOrder')
|
90 |
+
));
|
91 |
+
|
92 |
+
$this->addColumn('buy_order_id', array(
|
93 |
+
'header' => Mage::helper('M2ePro')->__('Rakuten.com Order #'),
|
94 |
+
'align' => 'left',
|
95 |
+
'width' => '110px',
|
96 |
+
'index' => 'buy_order_id',
|
97 |
+
));
|
98 |
+
|
99 |
+
$this->addColumn('buy_order_items', array(
|
100 |
+
'header' => Mage::helper('M2ePro')->__('Items'),
|
101 |
+
'align' => 'left',
|
102 |
+
'index' => 'buy_order_items',
|
103 |
+
'sortable' => false,
|
104 |
+
'width' => '*',
|
105 |
+
'frame_callback' => array($this, 'callbackColumnItems'),
|
106 |
+
'filter_condition_callback' => array($this, 'callbackFilterItems')
|
107 |
+
));
|
108 |
+
|
109 |
+
$this->addColumn('buyer', array(
|
110 |
+
'header' => Mage::helper('M2ePro')->__('Buyer'),
|
111 |
+
'align' => 'left',
|
112 |
+
'index' => 'buyer_name',
|
113 |
+
'frame_callback' => array($this, 'callbackColumnBuyer'),
|
114 |
+
'filter_condition_callback' => array($this, 'callbackFilterBuyer'),
|
115 |
+
'width' => '170px'
|
116 |
+
));
|
117 |
+
|
118 |
+
$this->addColumn('paid_amount', array(
|
119 |
+
'header' => Mage::helper('M2ePro')->__('Total Paid'),
|
120 |
+
'align' => 'left',
|
121 |
+
'width' => '110px',
|
122 |
+
'index' => 'paid_amount',
|
123 |
+
'type' => 'number',
|
124 |
+
'frame_callback' => array($this, 'callbackColumnTotal')
|
125 |
+
));
|
126 |
+
|
127 |
+
$back = Mage::helper('M2ePro')->makeBackUrlParam(
|
128 |
+
'*/adminhtml_common_order/index',
|
129 |
+
array(
|
130 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_BUY
|
131 |
+
)
|
132 |
+
);
|
133 |
+
|
134 |
+
$this->addColumn('action', array(
|
135 |
+
'header' => Mage::helper('M2ePro')->__('Action'),
|
136 |
+
'width' => '80px',
|
137 |
+
'type' => 'action',
|
138 |
+
'getter' => 'getId',
|
139 |
+
'actions' => array(
|
140 |
+
array(
|
141 |
+
'caption' => Mage::helper('M2ePro')->__('View'),
|
142 |
+
'url' => array('base' => '*/adminhtml_common_buy_order/view'),
|
143 |
+
'field' => 'id'
|
144 |
+
),
|
145 |
+
array(
|
146 |
+
'caption' => Mage::helper('M2ePro')->__('Edit Shipping Address'),
|
147 |
+
'url' => array(
|
148 |
+
'base' => '*/adminhtml_common_buy_order/editShippingAddress/',
|
149 |
+
'params' => array('back' => $back)
|
150 |
+
),
|
151 |
+
'field' => 'id'
|
152 |
+
),
|
153 |
+
array(
|
154 |
+
'caption' => Mage::helper('M2ePro')->__('Create Order'),
|
155 |
+
'url' => array('base' => '*/adminhtml_common_buy_order/createMagentoOrder'),
|
156 |
+
'field' => 'id'
|
157 |
+
)
|
158 |
+
),
|
159 |
+
'filter' => false,
|
160 |
+
'sortable' => false,
|
161 |
+
'is_system' => true
|
162 |
+
));
|
163 |
+
|
164 |
+
return parent::_prepareColumns();
|
165 |
+
}
|
166 |
+
|
167 |
+
protected function _prepareMassaction()
|
168 |
+
{
|
169 |
+
// Set massaction identifiers
|
170 |
+
//--------------------------------
|
171 |
+
$this->setMassactionIdField('main_table.id');
|
172 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
173 |
+
//--------------------------------
|
174 |
+
|
175 |
+
// Set mass-action
|
176 |
+
//--------------------------------
|
177 |
+
$this->getMassactionBlock()->addItem('resend_shipping', array(
|
178 |
+
'label' => Mage::helper('M2ePro')->__('Resend Shipping Information'),
|
179 |
+
'url' => $this->getUrl('*/adminhtml_order/resubmitShippingInfo'),
|
180 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
181 |
+
));
|
182 |
+
//--------------------------------
|
183 |
+
|
184 |
+
return parent::_prepareMassaction();
|
185 |
+
}
|
186 |
+
|
187 |
+
//##############################################################
|
188 |
+
|
189 |
+
public function callbackColumnMagentoOrder($value, $row, $column, $isExport)
|
190 |
+
{
|
191 |
+
$magentoOrderId = $row['magento_order_id'];
|
192 |
+
$magentoOrderNumber = Mage::helper('M2ePro')->escapeHtml($row['magento_order_num']);
|
193 |
+
|
194 |
+
$returnString = Mage::helper('M2ePro')->__('N/A');
|
195 |
+
|
196 |
+
if ($row['magento_order_id']) {
|
197 |
+
if ($row['magento_order_num']) {
|
198 |
+
$orderUrl = $this->getUrl('adminhtml/sales_order/view', array('order_id' => $magentoOrderId));
|
199 |
+
$returnString = '<a href="' . $orderUrl . '" target="_blank">' . $magentoOrderNumber . '</a>';
|
200 |
+
} else {
|
201 |
+
$returnString = '<span style="color: red;">'.Mage::helper('M2ePro')->__('Deleted').'</span>';
|
202 |
+
}
|
203 |
+
}
|
204 |
+
|
205 |
+
return $returnString.$this->getViewLogIconHtml($row->getId());
|
206 |
+
}
|
207 |
+
|
208 |
+
private function getViewLogIconHtml($orderId)
|
209 |
+
{
|
210 |
+
$orderId = (int)$orderId;
|
211 |
+
|
212 |
+
// Prepare collection
|
213 |
+
// --------------------------------
|
214 |
+
$orderLogsCollection = Mage::getModel('M2ePro/Order_Log')->getCollection()
|
215 |
+
->addFieldToFilter('order_id', $orderId)
|
216 |
+
->setOrder('id', 'DESC');
|
217 |
+
$orderLogsCollection->getSelect()
|
218 |
+
->limit(3);
|
219 |
+
// --------------------------------
|
220 |
+
|
221 |
+
// Prepare logs data
|
222 |
+
// --------------------------------
|
223 |
+
if ($orderLogsCollection->getSize() <= 0) {
|
224 |
+
return '';
|
225 |
+
}
|
226 |
+
|
227 |
+
$format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
|
228 |
+
|
229 |
+
$logRows = array();
|
230 |
+
foreach ($orderLogsCollection as $log) {
|
231 |
+
$logRows[] = array(
|
232 |
+
'type' => $log->getData('type'),
|
233 |
+
'text' => Mage::helper('M2ePro/View')->getModifiedLogMessage($log->getData('message')),
|
234 |
+
'initiator' => $this->getInitiatorForAction($log->getData('initiator')),
|
235 |
+
'date' => Mage::app()->getLocale()->date(strtotime($log->getData('create_date')))->toString($format)
|
236 |
+
);
|
237 |
+
}
|
238 |
+
// --------------------------------
|
239 |
+
|
240 |
+
$tips = array(
|
241 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'Last Order Action was completed successfully.',
|
242 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'Last Order Action was completed with error(s).',
|
243 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'Last Order Action was completed with warning(s).'
|
244 |
+
);
|
245 |
+
|
246 |
+
$icons = array(
|
247 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'normal',
|
248 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'error',
|
249 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'warning'
|
250 |
+
);
|
251 |
+
|
252 |
+
$summary = $this->getLayout()->createBlock('M2ePro/adminhtml_log_grid_summary', '', array(
|
253 |
+
'entity_id' => $orderId,
|
254 |
+
'rows' => $logRows,
|
255 |
+
'tips' => $tips,
|
256 |
+
'icons' => $icons,
|
257 |
+
'view_help_handler' => 'OrderHandlerObj.viewOrderHelp',
|
258 |
+
'hide_help_handler' => 'OrderHandlerObj.hideOrderHelp',
|
259 |
+
));
|
260 |
+
|
261 |
+
return $summary->toHtml();
|
262 |
+
}
|
263 |
+
|
264 |
+
public function getInitiatorForAction($initiator)
|
265 |
+
{
|
266 |
+
$string = '';
|
267 |
+
|
268 |
+
switch ((int)$initiator) {
|
269 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_UNKNOWN:
|
270 |
+
$string = '';
|
271 |
+
break;
|
272 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_USER:
|
273 |
+
$string = Mage::helper('M2ePro')->__('Manual');
|
274 |
+
break;
|
275 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION:
|
276 |
+
$string = Mage::helper('M2ePro')->__('Automatic');
|
277 |
+
break;
|
278 |
+
}
|
279 |
+
|
280 |
+
return $string;
|
281 |
+
}
|
282 |
+
|
283 |
+
//--------------------------------------------------------------
|
284 |
+
|
285 |
+
public function callbackColumnItems($value, $row, $column, $isExport)
|
286 |
+
{
|
287 |
+
/** @var $items Ess_M2ePro_Model_Order_Item[] */
|
288 |
+
$items = $this->itemsCollection->getItemsByColumnValue('order_id', $row->getData('id'));
|
289 |
+
|
290 |
+
$html = '';
|
291 |
+
$gridId = $this->getId();
|
292 |
+
|
293 |
+
foreach ($items as $item) {
|
294 |
+
if ($html != '') {
|
295 |
+
$html .= '<br/>';
|
296 |
+
}
|
297 |
+
|
298 |
+
$isShowEditLink = false;
|
299 |
+
|
300 |
+
$product = $item->getProduct();
|
301 |
+
if (!is_null($product)) {
|
302 |
+
/** @var Ess_M2ePro_Model_Magento_Product $magentoProduct */
|
303 |
+
$magentoProduct = Mage::getModel('M2ePro/Magento_Product');
|
304 |
+
$magentoProduct->setProduct($product);
|
305 |
+
|
306 |
+
$associatedProducts = $item->getAssociatedProducts();
|
307 |
+
$associatedOptions = $item->getAssociatedOptions();
|
308 |
+
|
309 |
+
if ($magentoProduct->isProductWithVariations()
|
310 |
+
&& empty($associatedOptions)
|
311 |
+
&& empty($associatedProducts)
|
312 |
+
) {
|
313 |
+
$isShowEditLink = true;
|
314 |
+
}
|
315 |
+
}
|
316 |
+
|
317 |
+
$editItemHtml = '';
|
318 |
+
if ($isShowEditLink) {
|
319 |
+
$orderItemId = $item->getId();
|
320 |
+
$orderItemEditLabel = Mage::helper('M2ePro')->__('edit');
|
321 |
+
|
322 |
+
$js = "{OrderEditItemHandlerObj.edit('{$gridId}', {$orderItemId});}";
|
323 |
+
|
324 |
+
$editItemHtml = <<<HTML
|
325 |
+
<span> <a href="javascript:void(0);" onclick="{$js}">[{$orderItemEditLabel}]</a></span>
|
326 |
+
HTML;
|
327 |
+
}
|
328 |
+
|
329 |
+
$skuHtml = '';
|
330 |
+
if ($item->getSku()) {
|
331 |
+
$skuLabel = Mage::helper('M2ePro')->__('SKU');
|
332 |
+
$sku = Mage::helper('M2ePro')->escapeHtml($item->getSku());
|
333 |
+
|
334 |
+
$skuHtml = <<<HTML
|
335 |
+
<span style="padding-left: 10px;"><b>{$skuLabel}:</b> {$sku}</span><br/>
|
336 |
+
HTML;
|
337 |
+
}
|
338 |
+
|
339 |
+
$generalId = $item->getGeneralId();
|
340 |
+
|
341 |
+
$itemLabel = Mage::helper('M2ePro')->__('Item');
|
342 |
+
$itemTitle = Mage::helper('M2ePro')->escapeHtml($item->getTitle());
|
343 |
+
$itemUrl = Mage::helper('M2ePro/Component_Buy')->getItemUrl($generalId);
|
344 |
+
|
345 |
+
$qtyLabel = Mage::helper('M2ePro')->__('QTY');
|
346 |
+
$qty = (int)$item->getQtyPurchased();
|
347 |
+
$qtyHtml = <<<HTML
|
348 |
+
<span style="padding-left: 10px;"><b>{$qtyLabel}: </b>{$qty}</span>
|
349 |
+
HTML;
|
350 |
+
|
351 |
+
$html .= <<<HTML
|
352 |
+
<b>{$itemLabel}: #</b> <a href="{$itemUrl}" target="_blank">{$generalId}</a><br/>
|
353 |
+
{$itemTitle} {$editItemHtml}<br/>
|
354 |
+
<small>{$skuHtml}{$qtyHtml}</small>
|
355 |
+
HTML;
|
356 |
+
}
|
357 |
+
|
358 |
+
return $html;
|
359 |
+
}
|
360 |
+
|
361 |
+
public function callbackColumnBuyer($value, $row, $column, $isExport)
|
362 |
+
{
|
363 |
+
$html = Mage::helper('M2ePro')->escapeHtml($row->getData('buyer_name')) . '<br/>';
|
364 |
+
|
365 |
+
$buyerEmail = $row->getData('buyer_email');
|
366 |
+
if ($buyerEmail) {
|
367 |
+
$html .= '<' . $buyerEmail . '><br/>';
|
368 |
+
}
|
369 |
+
|
370 |
+
return $html;
|
371 |
+
}
|
372 |
+
|
373 |
+
public function callbackColumnTotal($value, $row, $column, $isExport)
|
374 |
+
{
|
375 |
+
return Mage::getSingleton('M2ePro/Currency')->formatPrice(
|
376 |
+
$row->getData('currency'), $row->getData('paid_amount')
|
377 |
+
);
|
378 |
+
}
|
379 |
+
|
380 |
+
//##############################################################
|
381 |
+
|
382 |
+
protected function callbackFilterItems(Varien_Data_Collection_Db $collection, $column)
|
383 |
+
{
|
384 |
+
$value = $column->getFilter()->getValue();
|
385 |
+
if ($value == null) {
|
386 |
+
return;
|
387 |
+
}
|
388 |
+
|
389 |
+
/** @var $orderItemsCollection Varien_Data_Collection_Db */
|
390 |
+
$orderItemsCollection = Mage::helper('M2ePro/Component_Buy')->getCollection('Order_Item');
|
391 |
+
|
392 |
+
$orderItemsCollection->getSelect()->reset(Zend_Db_Select::COLUMNS);
|
393 |
+
$orderItemsCollection->getSelect()->columns('order_id');
|
394 |
+
$orderItemsCollection->getSelect()->distinct(true);
|
395 |
+
|
396 |
+
$orderItemsCollection->getSelect()
|
397 |
+
->where('general_id LIKE ? OR sku LIKE ? OR title LIKE ?', '%'.$value.'%');
|
398 |
+
|
399 |
+
$ordersIds = $orderItemsCollection->getColumnValues('order_id');
|
400 |
+
$collection->addFieldToFilter('`main_table`.id', array('in' => $ordersIds));
|
401 |
+
}
|
402 |
+
|
403 |
+
protected function callbackFilterBuyer(Varien_Data_Collection_Db $collection, $column)
|
404 |
+
{
|
405 |
+
$value = $column->getFilter()->getValue();
|
406 |
+
if ($value == null) {
|
407 |
+
return;
|
408 |
+
}
|
409 |
+
|
410 |
+
$collection->getSelect()
|
411 |
+
->where('buyer_email LIKE ? OR buyer_name LIKE ?', '%'.$value.'%');
|
412 |
+
}
|
413 |
+
|
414 |
+
//##############################################################
|
415 |
+
|
416 |
+
public function getGridUrl()
|
417 |
+
{
|
418 |
+
return $this->getUrl('*/adminhtml_common_buy_order/grid', array('_current' => true));
|
419 |
+
}
|
420 |
+
|
421 |
+
public function getRowUrl($row)
|
422 |
+
{
|
423 |
+
$back = Mage::helper('M2ePro')->makeBackUrlParam(
|
424 |
+
'*/adminhtml_common_order/index',
|
425 |
+
array(
|
426 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_BUY
|
427 |
+
)
|
428 |
+
);
|
429 |
+
|
430 |
+
return $this->getUrl('*/adminhtml_common_buy_order/view', array('id' => $row->getId(), 'back' => $back));
|
431 |
+
}
|
432 |
+
|
433 |
+
//##############################################################
|
434 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Order/View.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Order_View extends Mage_Adminhtml_Block_Widget_Form_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyOrderView');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_buy_order';
|
18 |
+
$this->_mode = 'view';
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
// Set header text
|
22 |
+
//------------------------------
|
23 |
+
$this->_headerText = Mage::helper('M2ePro')->__('View Order Details');
|
24 |
+
//------------------------------
|
25 |
+
|
26 |
+
/** @var $order Ess_M2ePro_Model_Order */
|
27 |
+
$this->order = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
28 |
+
|
29 |
+
// Set buttons actions
|
30 |
+
//------------------------------
|
31 |
+
$this->removeButton('back');
|
32 |
+
$this->removeButton('reset');
|
33 |
+
$this->removeButton('delete');
|
34 |
+
$this->removeButton('add');
|
35 |
+
$this->removeButton('save');
|
36 |
+
$this->removeButton('edit');
|
37 |
+
//------------------------------
|
38 |
+
|
39 |
+
//------------------------------
|
40 |
+
$url = Mage::helper('M2ePro')->getBackUrl('*/adminhtml_common_order/index');
|
41 |
+
$this->_addButton('back', array(
|
42 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
43 |
+
'onclick' => 'CommonHandlerObj.back_click(\''.$url.'\')',
|
44 |
+
'class' => 'back'
|
45 |
+
));
|
46 |
+
//------------------------------
|
47 |
+
|
48 |
+
if (is_null($this->order->getMagentoOrderId())) {
|
49 |
+
//------------------------------
|
50 |
+
$url = $this->getUrl('*/*/createMagentoOrder', array('id' => $this->order->getId()));
|
51 |
+
$this->_addButton('order', array(
|
52 |
+
'label' => Mage::helper('M2ePro')->__('Create Order'),
|
53 |
+
'onclick' => "setLocation('".$url."');",
|
54 |
+
'class' => 'scalable'
|
55 |
+
));
|
56 |
+
//------------------------------
|
57 |
+
} else if (is_null($this->order->getMagentoOrder()) || $this->order->getMagentoOrder()->isCanceled()) {
|
58 |
+
//------------------------------
|
59 |
+
$url = $this->getUrl('*/*/createMagentoOrder', array('id' => $this->order->getId(), 'force' => 'yes'));
|
60 |
+
$confirm = Mage::helper('M2ePro')->escapeJs(
|
61 |
+
Mage::helper('M2ePro')->__('Are you sure that you want to create new Magento Order?')
|
62 |
+
);
|
63 |
+
|
64 |
+
$this->_addButton('order', array(
|
65 |
+
'label' => Mage::helper('M2ePro')->__('Create Order'),
|
66 |
+
'onclick' => "confirmSetLocation('".$confirm."','".$url."');",
|
67 |
+
'class' => 'scalable'
|
68 |
+
));
|
69 |
+
//------------------------------
|
70 |
+
}
|
71 |
+
}
|
72 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Order/View/Form.php
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Order_View_Form extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
public $shippingAddress = array();
|
10 |
+
|
11 |
+
public $realMagentoOrderId = NULL;
|
12 |
+
|
13 |
+
public function __construct()
|
14 |
+
{
|
15 |
+
parent::__construct();
|
16 |
+
|
17 |
+
// Initialization block
|
18 |
+
//------------------------------
|
19 |
+
$this->setId('buyOrderViewForm');
|
20 |
+
$this->setTemplate('M2ePro/common/buy/order.phtml');
|
21 |
+
//------------------------------
|
22 |
+
|
23 |
+
/** @var $order Ess_M2ePro_Model_Order */
|
24 |
+
$this->order = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
25 |
+
}
|
26 |
+
|
27 |
+
protected function _beforeToHtml()
|
28 |
+
{
|
29 |
+
// Magento order data
|
30 |
+
// ---------------
|
31 |
+
$this->realMagentoOrderId = NULL;
|
32 |
+
|
33 |
+
$magentoOrder = $this->order->getMagentoOrder();
|
34 |
+
if (!is_null($magentoOrder)) {
|
35 |
+
$this->realMagentoOrderId = $magentoOrder->getRealOrderId();
|
36 |
+
}
|
37 |
+
// ---------------
|
38 |
+
|
39 |
+
// ---------------
|
40 |
+
if (!is_null($magentoOrder) && $magentoOrder->hasShipments()) {
|
41 |
+
$url = $this->getUrl('*/adminhtml_order/resubmitShippingInfo', array('id' => $this->order->getId()));
|
42 |
+
$data = array(
|
43 |
+
'class' => '',
|
44 |
+
'label' => Mage::helper('M2ePro')->__('Resend Shipping Information'),
|
45 |
+
'onclick' => 'setLocation(\''.$url.'\');',
|
46 |
+
);
|
47 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
48 |
+
$this->setChild('resubmit_shipping_info', $buttonBlock);
|
49 |
+
}
|
50 |
+
// ---------------
|
51 |
+
|
52 |
+
// Shipping data
|
53 |
+
// ---------------
|
54 |
+
/** @var $shippingAddress Ess_M2ePro_Model_Buy_Order_ShippingAddress */
|
55 |
+
$shippingAddress = $this->order->getShippingAddress();
|
56 |
+
|
57 |
+
$this->shippingAddress = $shippingAddress->getData();
|
58 |
+
$this->shippingAddress['country_name'] = $shippingAddress->getCountryName();
|
59 |
+
$this->shippingAddress['phone'] = $this->order->getChildObject()->getBillingAddress()->getData('phone');
|
60 |
+
$this->shippingAddress['company'] = $this->order->getChildObject()->getBillingAddress()->getData('company');
|
61 |
+
// ---------------
|
62 |
+
|
63 |
+
$this->setChild('item', $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_order_view_item'));
|
64 |
+
$this->setChild('item_edit', $this->getLayout()->createBlock('M2ePro/adminhtml_order_item_edit'));
|
65 |
+
$this->setChild('log', $this->getLayout()->createBlock('M2ePro/adminhtml_order_view_log_grid'));
|
66 |
+
|
67 |
+
return parent::_beforeToHtml();
|
68 |
+
}
|
69 |
+
|
70 |
+
private function getStore()
|
71 |
+
{
|
72 |
+
if (is_null($this->order->getData('store_id'))) {
|
73 |
+
return null;
|
74 |
+
}
|
75 |
+
|
76 |
+
try {
|
77 |
+
$store = Mage::app()->getStore($this->order->getData('store_id'));
|
78 |
+
} catch (Exception $e) {
|
79 |
+
return null;
|
80 |
+
}
|
81 |
+
|
82 |
+
return $store;
|
83 |
+
}
|
84 |
+
|
85 |
+
public function isCurrencyAllowed()
|
86 |
+
{
|
87 |
+
$store = $this->getStore();
|
88 |
+
|
89 |
+
if (is_null($store)) {
|
90 |
+
return true;
|
91 |
+
}
|
92 |
+
|
93 |
+
/** @var $currencyHelper Ess_M2ePro_Model_Currency */
|
94 |
+
$currencyHelper = Mage::getSingleton('M2ePro/Currency');
|
95 |
+
|
96 |
+
return $currencyHelper->isAllowed($this->order->getChildObject()->getCurrency(), $store);
|
97 |
+
}
|
98 |
+
|
99 |
+
public function hasCurrencyConversionRate()
|
100 |
+
{
|
101 |
+
$store = $this->getStore();
|
102 |
+
|
103 |
+
if (is_null($store)) {
|
104 |
+
return true;
|
105 |
+
}
|
106 |
+
|
107 |
+
/** @var $currencyHelper Ess_M2ePro_Model_Currency */
|
108 |
+
$currencyHelper = Mage::getSingleton('M2ePro/Currency');
|
109 |
+
|
110 |
+
return $currencyHelper->getConvertRateFromBase($this->order->getChildObject()->getCurrency(), $store) != 0;
|
111 |
+
}
|
112 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Order/View/Item.php
ADDED
@@ -0,0 +1,238 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Order_View_Item extends Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyOrderViewItem');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
// Set default values
|
19 |
+
//------------------------------
|
20 |
+
$this->setDefaultSort('id');
|
21 |
+
$this->setDefaultDir('DESC');
|
22 |
+
$this->setPagerVisibility(false);
|
23 |
+
$this->setFilterVisibility(false);
|
24 |
+
$this->setUseAjax(true);
|
25 |
+
$this->_defaultLimit = 200;
|
26 |
+
//------------------------------
|
27 |
+
|
28 |
+
/** @var $order Ess_M2ePro_Model_Order */
|
29 |
+
$this->order = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
30 |
+
}
|
31 |
+
|
32 |
+
protected function _prepareCollection()
|
33 |
+
{
|
34 |
+
$collection = Mage::helper('M2ePro/Component_Buy')
|
35 |
+
->getCollection('Order_Item')
|
36 |
+
->addFieldToFilter('order_id', $this->order->getId());
|
37 |
+
|
38 |
+
$collection->getSelect()->joinLeft(
|
39 |
+
array('cisi' => Mage::getSingleton('core/resource')->getTableName('cataloginventory_stock_item')),
|
40 |
+
'(cisi.product_id = `main_table`.product_id AND cisi.stock_id = 1)',
|
41 |
+
array('is_in_stock')
|
42 |
+
);
|
43 |
+
|
44 |
+
$this->setCollection($collection);
|
45 |
+
|
46 |
+
return parent::_prepareCollection();
|
47 |
+
}
|
48 |
+
|
49 |
+
protected function _prepareColumns()
|
50 |
+
{
|
51 |
+
$this->addColumn('product_id', array(
|
52 |
+
'header' => Mage::helper('M2ePro')->__('Product'),
|
53 |
+
'align' => 'left',
|
54 |
+
'width' => '*',
|
55 |
+
'index' => 'product_id',
|
56 |
+
'frame_callback' => array($this, 'callbackColumnProduct')
|
57 |
+
));
|
58 |
+
|
59 |
+
$this->addColumn('stock_availability', array(
|
60 |
+
'header'=> Mage::helper('M2ePro')->__('Stock Availability'),
|
61 |
+
'width' => '100px',
|
62 |
+
'index' => 'is_in_stock',
|
63 |
+
'filter_index' => 'cisi.is_in_stock',
|
64 |
+
'type' => 'options',
|
65 |
+
'sortable' => false,
|
66 |
+
'options' => array(
|
67 |
+
1 => Mage::helper('M2ePro')->__('In Stock'),
|
68 |
+
0 => Mage::helper('M2ePro')->__('Out of Stock')
|
69 |
+
),
|
70 |
+
'frame_callback' => array($this, 'callbackColumnStockAvailability')
|
71 |
+
));
|
72 |
+
|
73 |
+
$this->addColumn('original_price', array(
|
74 |
+
'header' => Mage::helper('M2ePro')->__('Original Price'),
|
75 |
+
'align' => 'left',
|
76 |
+
'width' => '80px',
|
77 |
+
'filter' => false,
|
78 |
+
'sortable' => false,
|
79 |
+
'frame_callback' => array($this, 'callbackColumnOriginalPrice')
|
80 |
+
));
|
81 |
+
|
82 |
+
$this->addColumn('qty', array(
|
83 |
+
'header' => Mage::helper('M2ePro')->__('QTY'),
|
84 |
+
'align' => 'left',
|
85 |
+
'width' => '80px',
|
86 |
+
'index' => 'qty'
|
87 |
+
));
|
88 |
+
|
89 |
+
$this->addColumn('price', array(
|
90 |
+
'header' => Mage::helper('M2ePro')->__('Price'),
|
91 |
+
'align' => 'left',
|
92 |
+
'width' => '80px',
|
93 |
+
'index' => 'price',
|
94 |
+
'frame_callback' => array($this, 'callbackColumnPrice')
|
95 |
+
));
|
96 |
+
|
97 |
+
$this->addColumn('row_total', array(
|
98 |
+
'header' => Mage::helper('M2ePro')->__('Row Total'),
|
99 |
+
'align' => 'left',
|
100 |
+
'width' => '80px',
|
101 |
+
'frame_callback' => array($this, 'callbackColumnRowTotal')
|
102 |
+
));
|
103 |
+
|
104 |
+
return parent::_prepareColumns();
|
105 |
+
}
|
106 |
+
|
107 |
+
//##############################################################
|
108 |
+
|
109 |
+
/**
|
110 |
+
* @param $value
|
111 |
+
* @param $row Ess_M2ePro_Model_Order_Item
|
112 |
+
* @param $column
|
113 |
+
* @param $isExport
|
114 |
+
*
|
115 |
+
* @return string
|
116 |
+
*/
|
117 |
+
public function callbackColumnProduct($value, $row, $column, $isExport)
|
118 |
+
{
|
119 |
+
$skuHtml = '';
|
120 |
+
if ($row->getSku()) {
|
121 |
+
$skuLabel = Mage::helper('M2ePro')->__('SKU');
|
122 |
+
$sku = Mage::helper('M2ePro')->escapeHtml($row->getSku());
|
123 |
+
|
124 |
+
$skuHtml = <<<HTML
|
125 |
+
<b>{$skuLabel}:</b> {$sku}<br/>
|
126 |
+
HTML;
|
127 |
+
}
|
128 |
+
|
129 |
+
// $referenceIdLabel = Mage::helper('M2ePro')->__('Reference ID');
|
130 |
+
// $referenceId = Mage::helper('M2ePro')->escapeHtml($row->getGeneralId());
|
131 |
+
//
|
132 |
+
// $generalIdHtml = <<<HTML
|
133 |
+
//<b>{$referenceIdLabel}:</b> {$referenceId}<br/>
|
134 |
+
//HTML;
|
135 |
+
|
136 |
+
$itemUrl = Mage::helper('M2ePro/Component_Buy')->getItemUrl($row->getGeneralId());
|
137 |
+
$itemLinkText = Mage::helper('M2ePro')->__('View on Rakuten.com');
|
138 |
+
|
139 |
+
$buyLink = <<<HTML
|
140 |
+
<a href="{$itemUrl}" target="_blank">{$itemLinkText}</a>
|
141 |
+
HTML;
|
142 |
+
|
143 |
+
$productLink = '';
|
144 |
+
if ($productId = $row->getData('product_id')) {
|
145 |
+
$productUrl = $this->getUrl('adminhtml/catalog_product/edit', array('id' => $productId));
|
146 |
+
$productLink = ' | <a href="'.$productUrl.'" target="_blank">'.Mage::helper('M2ePro')->__('View').'</a>';
|
147 |
+
}
|
148 |
+
|
149 |
+
$orderItemId = (int)$row->getId();
|
150 |
+
$gridId = $this->getId();
|
151 |
+
|
152 |
+
$editLink = '';
|
153 |
+
if (!$row->getProductId() || $row->getMagentoProduct()->hasRequiredOptions()) {
|
154 |
+
|
155 |
+
if (!$row->getProductId()) {
|
156 |
+
$action = Mage::helper('M2ePro')->__('Map to Magento Product');
|
157 |
+
} else {
|
158 |
+
$action = Mage::helper('M2ePro')->__('Set Options');
|
159 |
+
}
|
160 |
+
|
161 |
+
$class = 'class="gray"';
|
162 |
+
|
163 |
+
$js = "{OrderEditItemHandlerObj.edit('{$gridId}', {$orderItemId});}";
|
164 |
+
$editLink = '<a href="javascript:void(0);" onclick="'.$js.'" '.$class.'>'.$action.'</a>';
|
165 |
+
}
|
166 |
+
|
167 |
+
$discardLink = '';
|
168 |
+
if ($row->getProductId()) {
|
169 |
+
$action = Mage::helper('M2ePro')->__('Unmap');
|
170 |
+
|
171 |
+
$js = "{OrderEditItemHandlerObj.unassignProduct('{$gridId}', {$orderItemId});}";
|
172 |
+
$discardLink = '<a href="javascript:void(0);" onclick="'.$js.'" class="gray">'.$action.'</a>';
|
173 |
+
|
174 |
+
if ($editLink) {
|
175 |
+
$discardLink = ' | ' . $discardLink;
|
176 |
+
}
|
177 |
+
}
|
178 |
+
|
179 |
+
$itemTitle = Mage::helper('M2ePro')->escapeHtml($row->getTitle());
|
180 |
+
|
181 |
+
return <<<HTML
|
182 |
+
<b>{$itemTitle}</b><br/>
|
183 |
+
<div style="padding-left: 10px;">
|
184 |
+
{$skuHtml}
|
185 |
+
</div>
|
186 |
+
<div style="float: left;">{$buyLink}{$productLink}</div>
|
187 |
+
<div style="float: right;">{$editLink}{$discardLink}</div>
|
188 |
+
HTML;
|
189 |
+
}
|
190 |
+
|
191 |
+
public function callbackColumnStockAvailability($value, $row, $column, $isExport)
|
192 |
+
{
|
193 |
+
if (is_null($row->getData('is_in_stock'))) {
|
194 |
+
return Mage::helper('M2ePro')->__('N/A');
|
195 |
+
}
|
196 |
+
|
197 |
+
if ((int)$row->getData('is_in_stock') <= 0) {
|
198 |
+
return '<span style="color: red;">'.$value.'</span>';
|
199 |
+
}
|
200 |
+
|
201 |
+
return $value;
|
202 |
+
}
|
203 |
+
|
204 |
+
public function callbackColumnOriginalPrice($value, $row, $column, $isExport)
|
205 |
+
{
|
206 |
+
$productId = $row->getData('product_id');
|
207 |
+
$formattedPrice = Mage::helper('M2ePro')->__('N/A');
|
208 |
+
|
209 |
+
if ($productId && $product = Mage::getModel('catalog/product')->load($productId)) {
|
210 |
+
$formattedPrice = $product->getFormatedPrice();
|
211 |
+
}
|
212 |
+
|
213 |
+
return $formattedPrice;
|
214 |
+
}
|
215 |
+
|
216 |
+
public function callbackColumnPrice($value, $row, $column, $isExport)
|
217 |
+
{
|
218 |
+
return Mage::getSingleton('M2ePro/Currency')->formatPrice($row->getData('currency'), $row->getData('price'));
|
219 |
+
}
|
220 |
+
|
221 |
+
public function callbackColumnRowTotal($value, $row, $column, $isExport)
|
222 |
+
{
|
223 |
+
$price = (float)$row->getData('price');
|
224 |
+
return Mage::getSingleton('M2ePro/Currency')->formatPrice(
|
225 |
+
$row->getData('currency'), $price * $row->getData('qty')
|
226 |
+
);
|
227 |
+
}
|
228 |
+
|
229 |
+
public function getRowUrl($row)
|
230 |
+
{
|
231 |
+
return '';
|
232 |
+
}
|
233 |
+
|
234 |
+
public function getGridUrl()
|
235 |
+
{
|
236 |
+
return $this->getUrl('*/*/orderItemGrid', array('_current' => true));
|
237 |
+
}
|
238 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Synchronization/Form.php
ADDED
@@ -0,0 +1,236 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Synchronization_Form extends Mage_Adminhtml_Block_Widget_Form
|
8 |
+
{
|
9 |
+
private $component = Ess_M2ePro_Helper_Component_Buy::NICK;
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('buySynchronizationForm');
|
18 |
+
$this->setContainerId('magento_block_buy_synchronization');
|
19 |
+
$this->setTemplate('M2ePro/common/buy/synchronization.phtml');
|
20 |
+
//------------------------------
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _beforeToHtml()
|
24 |
+
{
|
25 |
+
//----------------------------
|
26 |
+
$this->templatesMode = Mage::helper('M2ePro/Module')->getSynchronizationConfig()
|
27 |
+
->getGroupValue('/buy/templates/', 'mode');
|
28 |
+
$this->ordersMode = Mage::helper('M2ePro/Module')->getSynchronizationConfig()
|
29 |
+
->getGroupValue('/buy/orders/', 'mode');
|
30 |
+
$this->otherListingsMode = Mage::helper('M2ePro/Module')->getSynchronizationConfig()
|
31 |
+
->getGroupValue('/buy/other_listings/', 'mode');
|
32 |
+
//----------------------------
|
33 |
+
|
34 |
+
//----------------------------
|
35 |
+
$format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
|
36 |
+
|
37 |
+
$this->reviseAllInProcessingState = !is_null(
|
38 |
+
Mage::helper('M2ePro/Module')->getSynchronizationConfig()->getGroupValue(
|
39 |
+
'/buy/templates/revise/total/', 'last_listing_product_id'
|
40 |
+
)
|
41 |
+
);
|
42 |
+
|
43 |
+
$this->reviseAllStartDate = Mage::helper('M2ePro/Module')->getSynchronizationConfig()->getGroupValue(
|
44 |
+
'/buy/templates/revise/total/', 'start_date'
|
45 |
+
);
|
46 |
+
$this->reviseAllStartDate && $this->reviseAllStartDate = Mage::app()->getLocale()
|
47 |
+
->date(strtotime($this->reviseAllStartDate))
|
48 |
+
->toString($format);
|
49 |
+
|
50 |
+
$this->reviseAllEndDate = Mage::helper('M2ePro/Module')->getSynchronizationConfig()->getGroupValue(
|
51 |
+
'/buy/templates/revise/total/', 'end_date'
|
52 |
+
);
|
53 |
+
$this->reviseAllEndDate && $this->reviseAllEndDate = Mage::app()->getLocale()
|
54 |
+
->date(strtotime($this->reviseAllEndDate))
|
55 |
+
->toString($format);
|
56 |
+
//----------------------------
|
57 |
+
|
58 |
+
//----------------------------
|
59 |
+
$component = Ess_M2ePro_Helper_Component_Buy::NICK;
|
60 |
+
$data = array(
|
61 |
+
'class' => 'ok_button',
|
62 |
+
'label' => Mage::helper('M2ePro')->__('Confirm'),
|
63 |
+
'onclick' => "Windows.getFocusedWindow().close(); SynchronizationHandlerObj.runReviseAll('{$component}');",
|
64 |
+
);
|
65 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
66 |
+
$this->setChild('revise_all_confirm_popup_ok_button', $buttonBlock);
|
67 |
+
//------------------------------
|
68 |
+
|
69 |
+
//-------------------------------
|
70 |
+
$data = array(
|
71 |
+
'label' => Mage::helper('M2ePro')->__('Run Now'),
|
72 |
+
'onclick' =>
|
73 |
+
'SynchronizationHandlerObj.saveSettings(\'runNowTemplates\', \'' . $this->component . '\');',
|
74 |
+
'class' => 'templates_run_now'
|
75 |
+
);
|
76 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
77 |
+
$this->setChild('buy_templates_run_now', $buttonBlock);
|
78 |
+
//-------------------------------
|
79 |
+
|
80 |
+
//-------------------------------
|
81 |
+
$areYouSure = Mage::helper('adminhtml')->__('Are you sure?');
|
82 |
+
|
83 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
84 |
+
'*/adminhtml_common_synchronization/index',
|
85 |
+
array(
|
86 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_BUY
|
87 |
+
)
|
88 |
+
);
|
89 |
+
//-------------------------------
|
90 |
+
|
91 |
+
//-------------------------------
|
92 |
+
$url = $this->getUrl(
|
93 |
+
'*/adminhtml_common_synchronization/clearLog',
|
94 |
+
array(
|
95 |
+
'task' => Ess_M2ePro_Model_Synchronization_Log::TASK_TEMPLATES,
|
96 |
+
'component' => $this->component,
|
97 |
+
'back' => $backUrl
|
98 |
+
)
|
99 |
+
);
|
100 |
+
$data = array(
|
101 |
+
'label' => Mage::helper('M2ePro')->__('Clear Log'),
|
102 |
+
'onclick' => 'deleteConfirm(\'' . $areYouSure . '\', \'' . $url . '\')',
|
103 |
+
'class' => 'templates_clear_log'
|
104 |
+
);
|
105 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
106 |
+
$this->setChild('buy_templates_clear_log', $buttonBlock);
|
107 |
+
//-------------------------------
|
108 |
+
|
109 |
+
//-------------------------------
|
110 |
+
$url = $this->getUrl(
|
111 |
+
'*/adminhtml_common_log/synchronization',
|
112 |
+
array(
|
113 |
+
'task' => Ess_M2ePro_Model_Synchronization_Log::TASK_TEMPLATES,
|
114 |
+
'channel' => $this->component
|
115 |
+
)
|
116 |
+
);
|
117 |
+
$data = array(
|
118 |
+
'label' => Mage::helper('M2ePro')->__('View Log'),
|
119 |
+
'onclick' => 'window.open(\'' . $url . '\')',
|
120 |
+
'class' => 'button_link'
|
121 |
+
);
|
122 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
123 |
+
$this->setChild('buy_templates_view_log', $buttonBlock);
|
124 |
+
//-------------------------------
|
125 |
+
|
126 |
+
//-------------------------------
|
127 |
+
$data = array(
|
128 |
+
'label' => Mage::helper('M2ePro')->__('Run Now'),
|
129 |
+
'onclick' =>
|
130 |
+
'SynchronizationHandlerObj.saveSettings(\'runNowOrders\', \'' . $this->component . '\');',
|
131 |
+
'class' => 'orders_run_now'
|
132 |
+
);
|
133 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
134 |
+
$this->setChild('buy_orders_run_now', $buttonBlock);
|
135 |
+
//-------------------------------
|
136 |
+
|
137 |
+
//-------------------------------
|
138 |
+
$url = $this->getUrl(
|
139 |
+
'*/adminhtml_common_synchronization/clearLog',
|
140 |
+
array(
|
141 |
+
'task' => Ess_M2ePro_Model_Synchronization_Log::TASK_ORDERS,
|
142 |
+
'component' => $this->component,
|
143 |
+
'back' => $backUrl
|
144 |
+
)
|
145 |
+
);
|
146 |
+
$data = array(
|
147 |
+
'label' => Mage::helper('M2ePro')->__('Clear Log'),
|
148 |
+
'onclick' => 'deleteConfirm(\'' . $areYouSure . '\', \'' . $url . '\')',
|
149 |
+
'class' => 'orders_clear_log'
|
150 |
+
);
|
151 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
152 |
+
$this->setChild('buy_orders_clear_log', $buttonBlock);
|
153 |
+
//-------------------------------
|
154 |
+
|
155 |
+
//-------------------------------
|
156 |
+
$url = $this->getUrl(
|
157 |
+
'*/adminhtml_common_log/synchronization',
|
158 |
+
array(
|
159 |
+
'task' => Ess_M2ePro_Model_Synchronization_Log::TASK_ORDERS,
|
160 |
+
'channel' => $this->component,
|
161 |
+
)
|
162 |
+
);
|
163 |
+
$data = array(
|
164 |
+
'label' => Mage::helper('M2ePro')->__('View Log'),
|
165 |
+
'onclick' => 'window.open(\'' . $url . '\')',
|
166 |
+
'class' => 'button_link'
|
167 |
+
);
|
168 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
169 |
+
$this->setChild('buy_orders_view_log', $buttonBlock);
|
170 |
+
//-------------------------------
|
171 |
+
|
172 |
+
//-------------------------------
|
173 |
+
$data = array(
|
174 |
+
'label' => Mage::helper('M2ePro')->__('Run Now'),
|
175 |
+
'onclick' => 'SynchronizationHandlerObj.saveSettings(\'runNowOtherListings\',\''.$this->component.'\');',
|
176 |
+
'class' => 'other_listings_run_now'
|
177 |
+
);
|
178 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
179 |
+
$this->setChild('buy_other_listings_run_now', $buttonBlock);
|
180 |
+
//-------------------------------
|
181 |
+
|
182 |
+
//-------------------------------
|
183 |
+
$url = $this->getUrl(
|
184 |
+
'*/adminhtml_common_synchronization/clearLog',
|
185 |
+
array(
|
186 |
+
'task' => Ess_M2ePro_Model_Synchronization_Log::TASK_OTHER_LISTINGS,
|
187 |
+
'component' => $this->component,
|
188 |
+
'back' => $backUrl
|
189 |
+
)
|
190 |
+
);
|
191 |
+
$data = array(
|
192 |
+
'label' => Mage::helper('M2ePro')->__('Clear Log'),
|
193 |
+
'onclick' => 'deleteConfirm(\'' . $areYouSure . '\', \'' . $url . '\')',
|
194 |
+
'class' => 'orders_clear_log'
|
195 |
+
);
|
196 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
197 |
+
$this->setChild('buy_other_listings_clear_log', $buttonBlock);
|
198 |
+
//-------------------------------
|
199 |
+
|
200 |
+
//-------------------------------
|
201 |
+
$url = $this->getUrl(
|
202 |
+
'*/adminhtml_common_log/synchronization',
|
203 |
+
array(
|
204 |
+
'task' => Ess_M2ePro_Model_Synchronization_Log::TASK_OTHER_LISTINGS,
|
205 |
+
'channel' => $this->component,
|
206 |
+
)
|
207 |
+
);
|
208 |
+
$data = array(
|
209 |
+
'label' => Mage::helper('M2ePro')->__('View Log'),
|
210 |
+
'onclick' => 'window.open(\'' . $url . '\')',
|
211 |
+
'class' => 'button_link'
|
212 |
+
);
|
213 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
214 |
+
$this->setChild('buy_other_listings_view_log', $buttonBlock);
|
215 |
+
//-------------------------------
|
216 |
+
|
217 |
+
//-------------------------------
|
218 |
+
$this->inspectorMode = (int)Mage::helper('M2ePro/Module')->getSynchronizationConfig()->getGroupValue(
|
219 |
+
'/defaults/inspector/','mode'
|
220 |
+
);
|
221 |
+
//-------------------------------
|
222 |
+
|
223 |
+
return parent::_beforeToHtml();
|
224 |
+
}
|
225 |
+
|
226 |
+
// ####################################
|
227 |
+
|
228 |
+
public function isShowReviseAll()
|
229 |
+
{
|
230 |
+
return Mage::helper('M2ePro/Module')->getConfig()->getGroupValue(
|
231 |
+
'/view/synchronization/revise_total/','show'
|
232 |
+
);
|
233 |
+
}
|
234 |
+
|
235 |
+
// ####################################
|
236 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Template_NewProduct extends Mage_Adminhtml_Block_Widget_Grid_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyTemplateNewProduct');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_buy_template_newProduct';
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
// Set header text
|
21 |
+
//------------------------------
|
22 |
+
$this->_headerText = Mage::helper('M2ePro')->__('New SKU Policies For %rakuten%',
|
23 |
+
Mage::helper('M2ePro/Component_Buy')->getTitle());
|
24 |
+
//------------------------------
|
25 |
+
|
26 |
+
// Set buttons actions
|
27 |
+
//------------------------------
|
28 |
+
$this->removeButton('back');
|
29 |
+
$this->removeButton('reset');
|
30 |
+
$this->removeButton('delete');
|
31 |
+
$this->removeButton('add');
|
32 |
+
$this->removeButton('save');
|
33 |
+
$this->removeButton('edit');
|
34 |
+
|
35 |
+
$listingProductIds = Mage::helper('M2ePro/Data_Session')->getValue('buy_listing_product_ids');
|
36 |
+
|
37 |
+
$listingId = Mage::helper('M2ePro/Component_Buy')
|
38 |
+
->getObject('Listing_Product',reset($listingProductIds))
|
39 |
+
->getListingId();
|
40 |
+
|
41 |
+
//------------------------------
|
42 |
+
$url = $this->getUrl(
|
43 |
+
'*/adminhtml_common_buy_listing/view',
|
44 |
+
array(
|
45 |
+
'id' => $listingId
|
46 |
+
)
|
47 |
+
);
|
48 |
+
$this->_addButton('back', array(
|
49 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
50 |
+
'onclick' => 'CommonHandlerObj.back_click(\''.$url.'\')',
|
51 |
+
'class' => 'back'
|
52 |
+
));
|
53 |
+
//------------------------------
|
54 |
+
|
55 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_buy_template_newProduct');
|
56 |
+
|
57 |
+
//------------------------------
|
58 |
+
$url = $this->getUrl(
|
59 |
+
'*/adminhtml_common_buy_template_newProduct/add',
|
60 |
+
array(
|
61 |
+
'back' => $backUrl
|
62 |
+
)
|
63 |
+
);
|
64 |
+
$this->_addButton('new', array(
|
65 |
+
'label' => Mage::helper('M2ePro')->__('Add New SKU Policy'),
|
66 |
+
'onclick' => 'setLocation(\''.$url.'\')',
|
67 |
+
'class' => 'add'
|
68 |
+
));
|
69 |
+
//------------------------------
|
70 |
+
}
|
71 |
+
|
72 |
+
public function getGridHtml()
|
73 |
+
{
|
74 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_template_newProduct_help');
|
75 |
+
|
76 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
77 |
+
}
|
78 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Edit.php
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Template_NewProduct_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyTemplateNewProductEdit');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_buy_template_newProduct';
|
18 |
+
$this->_mode = 'edit';
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
// Set header text
|
22 |
+
//------------------------------
|
23 |
+
$templateId = $this->getRequest()->getParam('id');
|
24 |
+
|
25 |
+
$this->_headerText = $templateId
|
26 |
+
? Mage::helper('M2ePro')->__('Edit New SKU Policy For %rakuten%',
|
27 |
+
Mage::helper('M2ePro/Component_Buy')->getTitle())
|
28 |
+
: Mage::helper('M2ePro')->__('Add New SKU Policy For %rakuten%',
|
29 |
+
Mage::helper('M2ePro/Component_Buy')->getTitle());
|
30 |
+
//------------------------------
|
31 |
+
|
32 |
+
// Set buttons actions
|
33 |
+
//------------------------------
|
34 |
+
$this->removeButton('back');
|
35 |
+
$this->removeButton('reset');
|
36 |
+
$this->removeButton('delete');
|
37 |
+
$this->removeButton('add');
|
38 |
+
$this->removeButton('save');
|
39 |
+
$this->removeButton('edit');
|
40 |
+
|
41 |
+
$back = $this->getRequest()->getParam('back');
|
42 |
+
$buyListingProductIds = Mage::helper('M2ePro/Data_Session')->getValue('buy_listing_product_ids');
|
43 |
+
$listingProductId = $this->getRequest()->getParam('listing_product_id');
|
44 |
+
|
45 |
+
if ($back && ($buyListingProductIds || $listingProductId)) {
|
46 |
+
//------------------------------
|
47 |
+
$url = Mage::helper('M2ePro')->getBackUrl();
|
48 |
+
$this->_addButton('back', array(
|
49 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
50 |
+
'onclick' => 'CommonHandlerObj.back_click(\'' . $url .'\')',
|
51 |
+
'class' => 'back'
|
52 |
+
));
|
53 |
+
//------------------------------
|
54 |
+
}
|
55 |
+
|
56 |
+
//------------------------------
|
57 |
+
$params = array();
|
58 |
+
$listingProductId && $params['listing_product_id'] = $listingProductId;
|
59 |
+
$templateId && $params['id'] = $listingProductId;
|
60 |
+
|
61 |
+
$url = $this->getUrl('*/adminhtml_common_buy_template_newProduct/add', $params);
|
62 |
+
$this->_addButton('save', array(
|
63 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
64 |
+
'onclick' => 'CommonHandlerObj.save_click(\''.$url.'\')',
|
65 |
+
'class' => 'save'
|
66 |
+
));
|
67 |
+
//------------------------------
|
68 |
+
|
69 |
+
$saveAndAssign = (int)$this->getRequest()->getParam('save_and_assign', 1);
|
70 |
+
|
71 |
+
if ($saveAndAssign && $buyListingProductIds) {
|
72 |
+
//------------------------------
|
73 |
+
$url = $this->getUrl(
|
74 |
+
'*/adminhtml_common_buy_template_newProduct/add',
|
75 |
+
array(
|
76 |
+
'do_map' => true
|
77 |
+
)
|
78 |
+
);
|
79 |
+
$this->_addButton('save_and_map', array(
|
80 |
+
'label' => Mage::helper('M2ePro')->__('Save And Assign'),
|
81 |
+
'onclick' => 'CommonHandlerObj.save_click(\''.$url.'\')',
|
82 |
+
'class' => 'save'
|
83 |
+
));
|
84 |
+
//------------------------------
|
85 |
+
}
|
86 |
+
}
|
87 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Edit/Form.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Template_NewProduct_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyTemplateNewProductEditForm');
|
16 |
+
//------------------------------
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _prepareForm()
|
20 |
+
{
|
21 |
+
$form = new Varien_Data_Form(array(
|
22 |
+
'id' => 'edit_form',
|
23 |
+
'method' => 'post',
|
24 |
+
'enctype' => 'multipart/form-data'
|
25 |
+
));
|
26 |
+
|
27 |
+
$form->setUseContainer(true);
|
28 |
+
$this->setForm($form);
|
29 |
+
|
30 |
+
return parent::_prepareForm();
|
31 |
+
}
|
32 |
+
|
33 |
+
protected function _beforeToHtml()
|
34 |
+
{
|
35 |
+
/** @var $connRead Varien_Db_Adapter_Pdo_Mysql */
|
36 |
+
$connRead = Mage::getSingleton('core/resource')->getConnection('core_read');
|
37 |
+
|
38 |
+
$this->nodes = $connRead->select()
|
39 |
+
->from(Mage::getSingleton('core/resource')->getTableName('m2epro_buy_dictionary_category'))
|
40 |
+
->where('parent_category_id = ?', 0)
|
41 |
+
->query()
|
42 |
+
->fetchAll();
|
43 |
+
|
44 |
+
//------------------------------
|
45 |
+
$data = array(
|
46 |
+
'id' => 'category_confirm_button',
|
47 |
+
'label' => Mage::helper('M2ePro')->__('Confirm'),
|
48 |
+
'onclick' => 'BuyTemplateNewProductHandlerObj.confirmCategory();',
|
49 |
+
);
|
50 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
51 |
+
$this->setChild('category_confirm_button',$buttonBlock);
|
52 |
+
//------------------------------
|
53 |
+
|
54 |
+
//------------------------------
|
55 |
+
$data = array(
|
56 |
+
'id' => 'category_change_button',
|
57 |
+
'label' => Mage::helper('M2ePro')->__('Change Category'),
|
58 |
+
'onclick' => 'BuyTemplateNewProductHandlerObj.changeCategory();',
|
59 |
+
);
|
60 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
61 |
+
$this->setChild('category_change_button',$buttonBlock);
|
62 |
+
//------------------------------
|
63 |
+
|
64 |
+
return parent::_beforeToHtml();
|
65 |
+
}
|
66 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Edit/Tabs.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Template_NewProduct_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyTemplateNewProductEditTabs');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTitle(Mage::helper('M2ePro')->__('Configuration'));
|
19 |
+
$this->setDestElementId('edit_form');
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _beforeToHtml()
|
23 |
+
{
|
24 |
+
$this->addTab('general', array(
|
25 |
+
'label' => Mage::helper('M2ePro')->__('General'),
|
26 |
+
'title' => Mage::helper('M2ePro')->__('General'),
|
27 |
+
'content' => $this->getLayout()->createBlock(
|
28 |
+
'M2ePro/adminhtml_common_buy_template_newProduct_edit_tabs_general'
|
29 |
+
)->toHtml(),
|
30 |
+
));
|
31 |
+
|
32 |
+
$this->addTab('core', array(
|
33 |
+
'label' => Mage::helper('M2ePro')->__('Description'),
|
34 |
+
'title' => Mage::helper('M2ePro')->__('Description'),
|
35 |
+
'content' => $this->getLayout()->createBlock(
|
36 |
+
'M2ePro/adminhtml_common_buy_template_newProduct_edit_tabs_description'
|
37 |
+
)->toHtml(),
|
38 |
+
));
|
39 |
+
|
40 |
+
$this->addTab('attribute', array(
|
41 |
+
'label' => Mage::helper('M2ePro')->__('Specifics'),
|
42 |
+
'title' => Mage::helper('M2ePro')->__('Specifics'),
|
43 |
+
'content' => $this->getLayout()->createBlock(
|
44 |
+
'M2ePro/adminhtml_common_buy_template_newProduct_edit_tabs_attributes'
|
45 |
+
)->toHtml(),
|
46 |
+
));
|
47 |
+
|
48 |
+
$this->setActiveTab($this->getRequest()->getParam('tab', 'general'));
|
49 |
+
|
50 |
+
return parent::_beforeToHtml();
|
51 |
+
}
|
52 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Edit/Tabs/Attributes.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Template_NewProduct_Edit_Tabs_Attributes extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyTemplateNewProductEditTabsAttributes');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/buy/template/newProduct/tabs/attributes.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Edit/Tabs/Description.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Template_NewProduct_Edit_Tabs_Description
|
8 |
+
extends Mage_Adminhtml_Block_Widget
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
//------------------------------
|
16 |
+
$this->setId('buyTemplateNewProductEditTabsDescription');
|
17 |
+
//------------------------------
|
18 |
+
|
19 |
+
$this->setTemplate('M2ePro/common/buy/template/newProduct/tabs/description.phtml');
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _beforeToHtml()
|
23 |
+
{
|
24 |
+
$this->attributes = Mage::helper('M2ePro/Magento_Attribute')->getAll();
|
25 |
+
|
26 |
+
//------------------------------
|
27 |
+
$data = array(
|
28 |
+
'label' => Mage::helper('M2ePro')->__('Insert'),
|
29 |
+
'onclick' => "AttributeHandlerObj.appendToText('select_attributes_for_title', 'title_template');",
|
30 |
+
'class' => 'select_attributes_for_title_button'
|
31 |
+
);
|
32 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
33 |
+
$this->setChild('select_attributes_for_title_button',$buttonBlock);
|
34 |
+
//------------------------------
|
35 |
+
|
36 |
+
//------------------------------
|
37 |
+
$data = array(
|
38 |
+
'label' => Mage::helper('M2ePro')->__('Insert'),
|
39 |
+
'onclick' => "AttributeHandlerObj.appendToText(".
|
40 |
+
"'select_attributes_for_mfg_name'," . " 'manufacturer_template'".
|
41 |
+
");",
|
42 |
+
'class' => 'select_attributes_for_mfg_name_template_button'
|
43 |
+
);
|
44 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
45 |
+
$this->setChild('select_attributes_for_mfg_name_template_button',$buttonBlock);
|
46 |
+
//------------------------------
|
47 |
+
|
48 |
+
//------------------------------
|
49 |
+
$data = array(
|
50 |
+
'label' => Mage::helper('M2ePro')->__('Insert'),
|
51 |
+
'onclick' => "AttributeHandlerObj.appendToTextarea('#' + $('select_attributes').value + '#');",
|
52 |
+
'class' => 'add_product_attribute_button',
|
53 |
+
);
|
54 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
55 |
+
$this->setChild('add_product_attribute_button',$buttonBlock);
|
56 |
+
//------------------------------
|
57 |
+
|
58 |
+
//------------------------------
|
59 |
+
for ($i = 0; $i < Ess_M2ePro_Model_Buy_Template_NewProduct_Core::FEATURES_COUNT; $i++) {
|
60 |
+
$data = array(
|
61 |
+
'label' => Mage::helper('M2ePro')->__('Insert'),
|
62 |
+
'onclick' => "AttributeHandlerObj.appendToText('select_attributes_for_features_{$i}',"
|
63 |
+
. " 'features_{$i}');BuyTemplateNewProductHandlerObj.allowAddFeature(this);",
|
64 |
+
'class' => "select_attributes_for_features_{$i}_button"
|
65 |
+
);
|
66 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
67 |
+
$this->setChild("select_attributes_for_features_{$i}_button",$buttonBlock);
|
68 |
+
}
|
69 |
+
//------------------------------
|
70 |
+
|
71 |
+
return parent::_beforeToHtml();
|
72 |
+
}
|
73 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Edit/Tabs/General.php
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Template_NewProduct_Edit_Tabs_General extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
// ########################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('buyTemplateNewProductEditTabsGeneral');
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$this->setTemplate('M2ePro/common/buy/template/newProduct/tabs/general.phtml');
|
21 |
+
}
|
22 |
+
|
23 |
+
// ########################################
|
24 |
+
|
25 |
+
protected function _beforeToHtml()
|
26 |
+
{
|
27 |
+
/** @var $connRead Varien_Db_Adapter_Pdo_Mysql */
|
28 |
+
$connRead = Mage::getSingleton('core/resource')->getConnection('core_read');
|
29 |
+
|
30 |
+
$this->nodes = $connRead->select()
|
31 |
+
->from(Mage::getSingleton('core/resource')->getTableName('m2epro_buy_dictionary_category'))
|
32 |
+
->where('parent_category_id = ?', 0)
|
33 |
+
->query()
|
34 |
+
->fetchAll();
|
35 |
+
!is_array($this->nodes) && $this->nodes = array();
|
36 |
+
|
37 |
+
$this->attributes = Mage::helper('M2ePro/Magento_Attribute')->getGeneralFromAllAttributeSets();
|
38 |
+
|
39 |
+
//------------------------------
|
40 |
+
$data = array(
|
41 |
+
'id' => 'category_confirm_button',
|
42 |
+
'label' => Mage::helper('M2ePro')->__('Confirm'),
|
43 |
+
'onclick' => 'BuyTemplateNewProductHandlerObj.confirmCategory();',
|
44 |
+
);
|
45 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
46 |
+
$this->setChild('category_confirm_button',$buttonBlock);
|
47 |
+
//------------------------------
|
48 |
+
|
49 |
+
//------------------------------
|
50 |
+
$data = array(
|
51 |
+
'id' => 'category_change_button',
|
52 |
+
'label' => Mage::helper('M2ePro')->__('Change Category'),
|
53 |
+
'onclick' => 'BuyTemplateNewProductHandlerObj.changeCategory();',
|
54 |
+
);
|
55 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
56 |
+
$this->setChild('category_change_button',$buttonBlock);
|
57 |
+
//------------------------------
|
58 |
+
|
59 |
+
//------------------------------
|
60 |
+
$data = array(
|
61 |
+
'id' => 'browse_category_button',
|
62 |
+
'label' => Mage::helper('M2ePro')->__('Browse'),
|
63 |
+
'onclick' => 'BuyTemplateNewProductHandlerObj.browse_category.showCenter(true)'
|
64 |
+
);
|
65 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
66 |
+
$this->setChild('browse_category_button',$buttonBlock);
|
67 |
+
//------------------------------
|
68 |
+
|
69 |
+
//------------------------------
|
70 |
+
$data = array(
|
71 |
+
'id' => 'search_category_button',
|
72 |
+
'label' => Mage::helper('M2ePro')->__('Search By Keywords'),
|
73 |
+
'onclick' => 'BuyTemplateNewProductHandlerObj.search_category.showCenter(true)',
|
74 |
+
);
|
75 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
76 |
+
$this->setChild('search_category_button',$buttonBlock);
|
77 |
+
//------------------------------
|
78 |
+
|
79 |
+
//------------------------------
|
80 |
+
$data = array(
|
81 |
+
'id' => 'search_category_popup_button',
|
82 |
+
'label' => Mage::helper('M2ePro')->__('Search'),
|
83 |
+
'onclick' => 'BuyTemplateNewProductHandlerObj.searchClick()',
|
84 |
+
);
|
85 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
86 |
+
$this->setChild('search_category_popup_button',$buttonBlock);
|
87 |
+
//------------------------------
|
88 |
+
|
89 |
+
//------------------------------
|
90 |
+
$data = array(
|
91 |
+
'id' => 'close_browse_popup_button',
|
92 |
+
'label' => Mage::helper('M2ePro')->__('Close'),
|
93 |
+
'onclick' => 'BuyTemplateNewProductHandlerObj.closeBrowseCategoryPopup()',
|
94 |
+
);
|
95 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
96 |
+
$this->setChild('close_browse_popup_button',$buttonBlock);
|
97 |
+
//------------------------------
|
98 |
+
|
99 |
+
//------------------------------
|
100 |
+
$data = array(
|
101 |
+
'id' => 'close_search_popup_button',
|
102 |
+
'label' => Mage::helper('M2ePro')->__('Close'),
|
103 |
+
'onclick' => 'BuyTemplateNewProductHandlerObj.closeSearchCategoryPopup()',
|
104 |
+
);
|
105 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
106 |
+
$this->setChild('close_search_popup_button',$buttonBlock);
|
107 |
+
//------------------------------
|
108 |
+
|
109 |
+
return parent::_beforeToHtml();
|
110 |
+
}
|
111 |
+
|
112 |
+
// ########################################
|
113 |
+
|
114 |
+
public function isAllowedUpcExemption($formData)
|
115 |
+
{
|
116 |
+
$isAllowedUpcExemption = Ess_M2ePro_Model_Buy_Template_NewProduct::isAllowedUpcExemption();
|
117 |
+
$gtinMode = $formData['category']['gtin_mode'];
|
118 |
+
return $isAllowedUpcExemption || $gtinMode == Ess_M2ePro_Model_Buy_Template_NewProduct_Core::GTIN_MODE_NONE;
|
119 |
+
}
|
120 |
+
|
121 |
+
// ########################################
|
122 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Grid.php
ADDED
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Template_NewProduct_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('templateNewProductGrid');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
// Set default values
|
19 |
+
//------------------------------
|
20 |
+
$this->setDefaultSort('id');
|
21 |
+
$this->setDefaultDir('ASC');
|
22 |
+
$this->setSaveParametersInSession(true);
|
23 |
+
$this->setUseAjax(true);
|
24 |
+
//------------------------------
|
25 |
+
}
|
26 |
+
|
27 |
+
protected function _prepareCollection()
|
28 |
+
{
|
29 |
+
$collection = Mage::getModel('M2ePro/Buy_Template_NewProduct')->getCollection();
|
30 |
+
$this->setCollection($collection);
|
31 |
+
return parent::_prepareCollection();
|
32 |
+
}
|
33 |
+
|
34 |
+
protected function _prepareColumns()
|
35 |
+
{
|
36 |
+
$this->addColumn('id', array(
|
37 |
+
'header' => Mage::helper('M2ePro')->__('ID'),
|
38 |
+
'align' => 'right',
|
39 |
+
'type' => 'number',
|
40 |
+
'width' => '50px',
|
41 |
+
'index' => 'id',
|
42 |
+
'filter_index' => 'id',
|
43 |
+
'frame_callback' => array($this, 'callbackColumnId')
|
44 |
+
));
|
45 |
+
|
46 |
+
$this->addColumn('title', array(
|
47 |
+
'header' => Mage::helper('M2ePro')->__('Title'),
|
48 |
+
'align' => 'left',
|
49 |
+
'type' => 'text',
|
50 |
+
'width' => '100px',
|
51 |
+
'index' => 'title',
|
52 |
+
'filter_index' => 'title',
|
53 |
+
'frame_callback' => array($this, 'callbackColumnTitle')
|
54 |
+
));
|
55 |
+
|
56 |
+
$this->addColumn('node_title', array(
|
57 |
+
'header' => Mage::helper('M2ePro')->__('Department'),
|
58 |
+
'align' => 'left',
|
59 |
+
'type' => 'text',
|
60 |
+
'width' => '100px',
|
61 |
+
'index' => 'node_title',
|
62 |
+
'filter_index' => 'node_title',
|
63 |
+
'frame_callback' => array($this, 'callbackColumnNodeTitle')
|
64 |
+
));
|
65 |
+
|
66 |
+
$this->addColumn('category_path', array(
|
67 |
+
'header' => Mage::helper('M2ePro')->__('Category'),
|
68 |
+
'align' => 'left',
|
69 |
+
'type' => 'text',
|
70 |
+
'width' => '350px',
|
71 |
+
'index' => 'category_path',
|
72 |
+
'filter_index' => 'category_path',
|
73 |
+
'frame_callback' => array($this, 'callbackColumnCategoryPath')
|
74 |
+
));
|
75 |
+
|
76 |
+
$back = Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_buy_template_newProduct');
|
77 |
+
|
78 |
+
$this->addColumn('assignment', array(
|
79 |
+
'header' => Mage::helper('M2ePro')->__('Assignment'),
|
80 |
+
'align' => 'left',
|
81 |
+
'type' => 'text',
|
82 |
+
'width' => '130px',
|
83 |
+
'filter' => false,
|
84 |
+
'sortable' => false,
|
85 |
+
'frame_callback' => array($this, 'callbackColumnActions'),
|
86 |
+
));
|
87 |
+
|
88 |
+
$this->addColumn('actions', array(
|
89 |
+
'header' => Mage::helper('M2ePro')->__('Actions'),
|
90 |
+
'align' => 'left',
|
91 |
+
'width' => '100px',
|
92 |
+
'type' => 'action',
|
93 |
+
'index' => 'actions',
|
94 |
+
'filter' => false,
|
95 |
+
'sortable' => false,
|
96 |
+
'getter' => 'getId',
|
97 |
+
'actions' => array(
|
98 |
+
array(
|
99 |
+
'caption' => Mage::helper('M2ePro')->__('Edit'),
|
100 |
+
'url' => array('base'=> '*/adminhtml_common_buy_template_newProduct/edit/back/'.$back),
|
101 |
+
'field' => 'id'
|
102 |
+
),
|
103 |
+
array(
|
104 |
+
'caption' => Mage::helper('M2ePro')->__('Delete Policy'),
|
105 |
+
'url' => array('base'=> '*/adminhtml_common_buy_template_newProduct/delete/back/'
|
106 |
+
.$this->getRequest()->getParam('back')),
|
107 |
+
'field' => 'ids',
|
108 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
109 |
+
),
|
110 |
+
)
|
111 |
+
));
|
112 |
+
}
|
113 |
+
|
114 |
+
// ####################################
|
115 |
+
|
116 |
+
protected function _prepareMassaction()
|
117 |
+
{
|
118 |
+
// Set massaction identifiers
|
119 |
+
//--------------------------------
|
120 |
+
$this->setMassactionIdField('id');
|
121 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
122 |
+
//--------------------------------
|
123 |
+
|
124 |
+
// Set delete action
|
125 |
+
//--------------------------------
|
126 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
127 |
+
'label' => Mage::helper('M2ePro')->__('Delete'),
|
128 |
+
'url' => $this->getUrl('*/*/delete'),
|
129 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
130 |
+
));
|
131 |
+
//--------------------------------
|
132 |
+
|
133 |
+
return parent::_prepareMassaction();
|
134 |
+
}
|
135 |
+
|
136 |
+
// ####################################
|
137 |
+
|
138 |
+
public function callbackColumnId($value, $row, $column, $isExport)
|
139 |
+
{
|
140 |
+
return $value.' ';
|
141 |
+
}
|
142 |
+
|
143 |
+
public function callbackColumnTitle($value, $row, $column, $isExport)
|
144 |
+
{
|
145 |
+
return ' '.$value;
|
146 |
+
}
|
147 |
+
|
148 |
+
public function callbackColumnNodeTitle($value, $row, $column, $isExport)
|
149 |
+
{
|
150 |
+
return ' '.$value;
|
151 |
+
}
|
152 |
+
|
153 |
+
public function callbackColumnCategoryPath($value, $row, $column, $isExport)
|
154 |
+
{
|
155 |
+
return ' '.$value;
|
156 |
+
}
|
157 |
+
|
158 |
+
public function callbackColumnActions($value, $row, $column, $isExport)
|
159 |
+
{
|
160 |
+
$url = $this->getUrl(
|
161 |
+
'*/adminhtml_common_buy_template_newProduct/map/',
|
162 |
+
array(
|
163 |
+
'id' => $row->getId(),
|
164 |
+
)
|
165 |
+
);
|
166 |
+
|
167 |
+
$confirmMessage = Mage::helper('M2ePro')->__('Are you sure?');
|
168 |
+
$actions = ' <a href="javascript:;" onclick="confirm(\''.$confirmMessage.'\') && ';
|
169 |
+
$actions .= 'setLocation(\''.$url.'\');">';
|
170 |
+
$actions .= Mage::helper('M2ePro')->__('Assign To This Policy');
|
171 |
+
$actions .= '</a>';
|
172 |
+
|
173 |
+
return $actions;
|
174 |
+
}
|
175 |
+
|
176 |
+
// ####################################
|
177 |
+
|
178 |
+
public function getGridUrl()
|
179 |
+
{
|
180 |
+
return $this->getUrl('*/adminhtml_common_buy_template_newProduct/templateNewProductGrid',
|
181 |
+
array('_current'=>true));
|
182 |
+
}
|
183 |
+
|
184 |
+
public function getRowUrl($row)
|
185 |
+
{
|
186 |
+
$back = Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_buy_template_newProduct');
|
187 |
+
|
188 |
+
return $this->getUrl('*/adminhtml_common_buy_template_newProduct/edit', array(
|
189 |
+
'id' => $row->getId(),
|
190 |
+
'back' => $back
|
191 |
+
));
|
192 |
+
}
|
193 |
+
|
194 |
+
// ####################################
|
195 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Help.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Template_NewProduct_Help extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyTemplateNewProductHelp');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/buy/template/newProduct/help.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Search/Grid.php
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Template_NewProduct_Search_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyTemplateNewProductSearchGrid');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
// Set default values
|
19 |
+
//------------------------------
|
20 |
+
$this->setFilterVisibility(false);
|
21 |
+
$this->setPagerVisibility(false);
|
22 |
+
$this->setDefaultSort('id');
|
23 |
+
$this->setDefaultDir('ASC');
|
24 |
+
$this->setSaveParametersInSession(true);
|
25 |
+
$this->setUseAjax(true);
|
26 |
+
//------------------------------
|
27 |
+
}
|
28 |
+
|
29 |
+
protected function _prepareCollection()
|
30 |
+
{
|
31 |
+
$data = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
32 |
+
|
33 |
+
$results = new Varien_Data_Collection();
|
34 |
+
foreach ($data as $index => $item) {
|
35 |
+
$temp = array(
|
36 |
+
'id' => $item['category_id'],
|
37 |
+
'title' => $item['title'],
|
38 |
+
'path' => $item['path'],
|
39 |
+
'node_id' => $item['node_id'],
|
40 |
+
'native_id' => $item['native_id']
|
41 |
+
);
|
42 |
+
|
43 |
+
$results->addItem(new Varien_Object($temp));
|
44 |
+
}
|
45 |
+
|
46 |
+
$this->setCollection($results);
|
47 |
+
|
48 |
+
return parent::_prepareCollection();
|
49 |
+
}
|
50 |
+
|
51 |
+
protected function _prepareColumns()
|
52 |
+
{
|
53 |
+
$this->addColumn('title', array(
|
54 |
+
'header' => Mage::helper('M2ePro')->__('Category'),
|
55 |
+
'align' => 'left',
|
56 |
+
'type' => 'text',
|
57 |
+
'index' => 'title',
|
58 |
+
'filter' => false,
|
59 |
+
'sortable' => false,
|
60 |
+
'frame_callback' => array($this, 'callbackColumnTitle')
|
61 |
+
));
|
62 |
+
|
63 |
+
$this->addColumn('actions', array(
|
64 |
+
'header' => Mage::helper('M2ePro')->__('Action'),
|
65 |
+
'align' => 'center',
|
66 |
+
'type' => 'text',
|
67 |
+
'width' => '80px',
|
68 |
+
'filter' => false,
|
69 |
+
'sortable' => false,
|
70 |
+
'frame_callback' => array($this, 'callbackColumnActions'),
|
71 |
+
));
|
72 |
+
|
73 |
+
}
|
74 |
+
|
75 |
+
// ####################################
|
76 |
+
|
77 |
+
public function callbackColumnTitle($title, $row, $column, $isExport)
|
78 |
+
{
|
79 |
+
$categoryInfo = json_encode($row->getData());
|
80 |
+
$categoryInfo = Mage::helper('M2ePro')->escapeHtml($categoryInfo);
|
81 |
+
$categoryInfo = Mage::helper('M2ePro')->escapeJs($categoryInfo);
|
82 |
+
|
83 |
+
$path = $row->getData('path');
|
84 |
+
(strlen($path) != strlen($title)) && $path = substr($path,0,strlen($path) - strlen($title)-2);
|
85 |
+
$path = str_replace('->',' > ',$path);
|
86 |
+
|
87 |
+
$title = Mage::helper('M2ePro')->escapeHtml($title);
|
88 |
+
if (strlen($title) > 60) {
|
89 |
+
$title = substr($title, 0, 60) . '...';
|
90 |
+
}
|
91 |
+
$foundIn = Mage::helper('M2ePro')->__('Found In: ');
|
92 |
+
|
93 |
+
$fullPath = $path;
|
94 |
+
if (strlen($path) > 135) {
|
95 |
+
$path = substr($path, 0, 135) . '...';
|
96 |
+
}
|
97 |
+
|
98 |
+
$html = <<<HTML
|
99 |
+
<div style="margin-left: 3px">
|
100 |
+
<a href="javascript:;" onclick="BuyTemplateNewProductHandlerObj.confirmSearchClick($categoryInfo)">$title</a>
|
101 |
+
<br/>
|
102 |
+
<span style="font-weight: bold;">$foundIn</span>
|
103 |
+
|
104 |
+
<span title="$fullPath">$path</span><br/>
|
105 |
+
</div>
|
106 |
+
HTML;
|
107 |
+
|
108 |
+
return $html;
|
109 |
+
}
|
110 |
+
|
111 |
+
public function callbackColumnActions($value, $row, $column, $isExport)
|
112 |
+
{
|
113 |
+
$categoryInfo = json_encode($row->getData());
|
114 |
+
$categoryInfo = Mage::helper('M2ePro')->escapeHtml($categoryInfo);
|
115 |
+
$categoryInfo = Mage::helper('M2ePro')->escapeJs($categoryInfo);
|
116 |
+
|
117 |
+
$select = Mage::helper('M2ePro')->__('Select');
|
118 |
+
$html = <<<HTML
|
119 |
+
<a href="javascript:;" onclick="BuyTemplateNewProductHandlerObj.confirmSearchClick($categoryInfo)">$select</a>
|
120 |
+
HTML;
|
121 |
+
|
122 |
+
return $html;
|
123 |
+
}
|
124 |
+
|
125 |
+
// ####################################
|
126 |
+
|
127 |
+
protected function _toHtml()
|
128 |
+
{
|
129 |
+
$javascriptsMain = <<<JAVASCRIPT
|
130 |
+
<script type="text/javascript">
|
131 |
+
|
132 |
+
$$('#buyTemplateNewProductSearchGrid div.grid th').each(function(el){
|
133 |
+
el.style.padding = '2px 2px';
|
134 |
+
});
|
135 |
+
|
136 |
+
$$('#buyTemplateNewProductSearchGrid div.grid td').each(function(el){
|
137 |
+
el.style.padding = '2px 2px';
|
138 |
+
});
|
139 |
+
|
140 |
+
$$('#buyTemplateNewProductSearchGrid div.grid table').each(function(el){
|
141 |
+
el.style.width = '99.9%';
|
142 |
+
});
|
143 |
+
|
144 |
+
</script>
|
145 |
+
JAVASCRIPT;
|
146 |
+
|
147 |
+
return parent::_toHtml() . $javascriptsMain;
|
148 |
+
}
|
149 |
+
|
150 |
+
// ####################################
|
151 |
+
|
152 |
+
public function getRowUrl($row)
|
153 |
+
{
|
154 |
+
return false;
|
155 |
+
}
|
156 |
+
|
157 |
+
// ####################################
|
158 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/SellingFormat/Edit.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Template_SellingFormat_Edit
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Form_Container
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
//------------------------------
|
16 |
+
$this->setId('buyTemplateSellingFormatEdit');
|
17 |
+
$this->_blockGroup = 'M2ePro';
|
18 |
+
$this->_controller = 'adminhtml_common_buy_template_sellingFormat';
|
19 |
+
$this->_mode = 'edit';
|
20 |
+
//------------------------------
|
21 |
+
|
22 |
+
// Set header text
|
23 |
+
//------------------------------
|
24 |
+
$helper = Mage::helper('M2ePro');
|
25 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
26 |
+
$componentName = Mage::helper('M2ePro/Component_Buy')->getTitle();
|
27 |
+
$headerTextEdit = $helper->__("Edit %component_name% Selling Format Policy", $componentName);
|
28 |
+
$headerTextAdd = $helper->__("Add %component_name% Selling Format Policy", $componentName);
|
29 |
+
} else {
|
30 |
+
$headerTextEdit = $helper->__("Edit Selling Format Policy");
|
31 |
+
$headerTextAdd = $helper->__("Add Selling Format Policy");
|
32 |
+
}
|
33 |
+
|
34 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data')
|
35 |
+
&& Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()
|
36 |
+
) {
|
37 |
+
$this->_headerText = $headerTextEdit;
|
38 |
+
$this->_headerText .= ' "'.$this->escapeHtml(
|
39 |
+
Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getTitle()).'"';
|
40 |
+
} else {
|
41 |
+
$this->_headerText = $headerTextAdd;
|
42 |
+
}
|
43 |
+
//------------------------------
|
44 |
+
|
45 |
+
// Set buttons actions
|
46 |
+
//------------------------------
|
47 |
+
$this->removeButton('back');
|
48 |
+
$this->removeButton('reset');
|
49 |
+
$this->removeButton('delete');
|
50 |
+
$this->removeButton('add');
|
51 |
+
$this->removeButton('save');
|
52 |
+
$this->removeButton('edit');
|
53 |
+
//------------------------------
|
54 |
+
|
55 |
+
//------------------------------
|
56 |
+
$url = Mage::helper('M2ePro')->getBackUrl('list');
|
57 |
+
$this->_addButton('back', array(
|
58 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
59 |
+
'onclick' => 'BuyTemplateSellingFormatHandlerObj.back_click(\'' . $url . '\')',
|
60 |
+
'class' => 'back'
|
61 |
+
));
|
62 |
+
//------------------------------
|
63 |
+
|
64 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data')
|
65 |
+
&& Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()
|
66 |
+
) {
|
67 |
+
//------------------------------
|
68 |
+
$this->_addButton('duplicate', array(
|
69 |
+
'label' => Mage::helper('M2ePro')->__('Duplicate'),
|
70 |
+
'onclick' => 'BuyTemplateSellingFormatHandlerObj.duplicate_click'
|
71 |
+
.'(\'common-buy-template-sellingFormat\')',
|
72 |
+
'class' => 'add M2ePro_duplicate_button'
|
73 |
+
));
|
74 |
+
//------------------------------
|
75 |
+
|
76 |
+
//------------------------------
|
77 |
+
$this->_addButton('delete', array(
|
78 |
+
'label' => Mage::helper('M2ePro')->__('Delete'),
|
79 |
+
'onclick' => 'BuyTemplateSellingFormatHandlerObj.delete_click()',
|
80 |
+
'class' => 'delete M2ePro_delete_button'
|
81 |
+
));
|
82 |
+
//------------------------------
|
83 |
+
}
|
84 |
+
|
85 |
+
//------------------------------
|
86 |
+
$this->_addButton('save', array(
|
87 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
88 |
+
'onclick' => 'BuyTemplateSellingFormatHandlerObj.save_click()',
|
89 |
+
'class' => 'save'
|
90 |
+
));
|
91 |
+
//------------------------------
|
92 |
+
|
93 |
+
//------------------------------
|
94 |
+
$this->_addButton('save_and_continue', array(
|
95 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
96 |
+
'onclick' => 'BuyTemplateSellingFormatHandlerObj.save_and_edit_click()',
|
97 |
+
'class' => 'save'
|
98 |
+
));
|
99 |
+
//------------------------------
|
100 |
+
}
|
101 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/SellingFormat/Edit/Form.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Template_SellingFormat_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
8 |
+
{
|
9 |
+
const QTY_MODE_PRODUCT_FIXED_VIRTUAL_ATTRIBUTE_VALUE = 'qty_mode_product_fixed';
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('buyTemplateSellingFormatEditForm');
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$this->setTemplate('M2ePro/common/buy/template/selling_format/form.phtml');
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _prepareForm()
|
24 |
+
{
|
25 |
+
$form = new Varien_Data_Form(array(
|
26 |
+
'id' => 'edit_form',
|
27 |
+
'action' => $this->getUrl('*/*/save'),
|
28 |
+
'method' => 'post',
|
29 |
+
'enctype' => 'multipart/form-data'
|
30 |
+
));
|
31 |
+
|
32 |
+
$form->setUseContainer(true);
|
33 |
+
$this->setForm($form);
|
34 |
+
|
35 |
+
return parent::_prepareForm();
|
36 |
+
}
|
37 |
+
|
38 |
+
protected function _beforeToHtml()
|
39 |
+
{
|
40 |
+
//------------------------------
|
41 |
+
$this->attributes = Mage::helper('M2ePro/Magento_Attribute')->getGeneralFromAllAttributeSets();
|
42 |
+
//------------------------------
|
43 |
+
|
44 |
+
//------------------------------
|
45 |
+
$this->customerGroups = Mage::getModel('customer/group')->getCollection()->toOptionArray();
|
46 |
+
//------------------------------
|
47 |
+
|
48 |
+
return parent::_beforeToHtml();
|
49 |
+
}
|
50 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/Synchronization/Edit.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Template_Synchronization_Edit
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Form_Container
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
//------------------------------
|
16 |
+
$this->setId('buyTemplateSynchronizationEdit');
|
17 |
+
$this->_blockGroup = 'M2ePro';
|
18 |
+
$this->_controller = 'adminhtml_common_buy_template_synchronization';
|
19 |
+
$this->_mode = 'edit';
|
20 |
+
//------------------------------
|
21 |
+
|
22 |
+
// Set header text
|
23 |
+
//------------------------------
|
24 |
+
$helper = Mage::helper('M2ePro');
|
25 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
26 |
+
$componentName = Mage::helper('M2ePro/Component_Buy')->getTitle();
|
27 |
+
$headerTextEdit = $helper->__("Edit %component_name% Synchronization Policy", $componentName);
|
28 |
+
$headerTextAdd = $helper->__("Add %component_name% Synchronization Policy", $componentName);
|
29 |
+
} else {
|
30 |
+
$headerTextEdit = $helper->__("Edit Synchronization Policy");
|
31 |
+
$headerTextAdd = $helper->__("Add Synchronization Policy");
|
32 |
+
}
|
33 |
+
|
34 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data')
|
35 |
+
&& Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()
|
36 |
+
) {
|
37 |
+
$this->_headerText = $headerTextEdit;
|
38 |
+
$this->_headerText .= ' "'.$this->escapeHtml(
|
39 |
+
Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getTitle()).'"';
|
40 |
+
} else {
|
41 |
+
$this->_headerText = $headerTextAdd;
|
42 |
+
}
|
43 |
+
//------------------------------
|
44 |
+
|
45 |
+
// Set buttons actions
|
46 |
+
//------------------------------
|
47 |
+
$this->removeButton('back');
|
48 |
+
$this->removeButton('reset');
|
49 |
+
$this->removeButton('delete');
|
50 |
+
$this->removeButton('add');
|
51 |
+
$this->removeButton('save');
|
52 |
+
$this->removeButton('edit');
|
53 |
+
//------------------------------
|
54 |
+
|
55 |
+
//------------------------------
|
56 |
+
$url = Mage::helper('M2ePro')->getBackUrl('list');
|
57 |
+
$this->_addButton('back', array(
|
58 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
59 |
+
'onclick' => 'BuyTemplateSynchronizationHandlerObj.back_click(\'' . $url . '\')',
|
60 |
+
'class' => 'back'
|
61 |
+
));
|
62 |
+
//------------------------------
|
63 |
+
|
64 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data')
|
65 |
+
&& Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()
|
66 |
+
) {
|
67 |
+
//------------------------------
|
68 |
+
$this->_addButton('duplicate', array(
|
69 |
+
'label' => Mage::helper('M2ePro')->__('Duplicate'),
|
70 |
+
'onclick' => 'BuyTemplateSynchronizationHandlerObj.duplicate_click'
|
71 |
+
.'(\'common-buy-template-synchronization\')',
|
72 |
+
'class' => 'add M2ePro_duplicate_button'
|
73 |
+
));
|
74 |
+
//------------------------------
|
75 |
+
|
76 |
+
//------------------------------
|
77 |
+
$this->_addButton('delete', array(
|
78 |
+
'label' => Mage::helper('M2ePro')->__('Delete'),
|
79 |
+
'onclick' => 'BuyTemplateSynchronizationHandlerObj.delete_click()',
|
80 |
+
'class' => 'delete M2ePro_delete_button'
|
81 |
+
));
|
82 |
+
//------------------------------
|
83 |
+
}
|
84 |
+
|
85 |
+
//------------------------------
|
86 |
+
$this->_addButton('save', array(
|
87 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
88 |
+
'onclick' => 'BuyTemplateSynchronizationHandlerObj.save_click()',
|
89 |
+
'class' => 'save'
|
90 |
+
));
|
91 |
+
//------------------------------
|
92 |
+
|
93 |
+
//------------------------------
|
94 |
+
$this->_addButton('save_and_continue', array(
|
95 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
96 |
+
'onclick' => 'BuyTemplateSynchronizationHandlerObj.save_and_edit_click'
|
97 |
+
.'(\'\',\'buyTemplateSynchronizationEditTabs\')',
|
98 |
+
'class' => 'save'
|
99 |
+
));
|
100 |
+
//------------------------------
|
101 |
+
}
|
102 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/Synchronization/Edit/Form.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Template_Synchronization_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyTemplateSynchronizationEditForm');
|
16 |
+
//------------------------------
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _prepareForm()
|
20 |
+
{
|
21 |
+
$form = new Varien_Data_Form(array(
|
22 |
+
'id' => 'edit_form',
|
23 |
+
'action' => $this->getUrl('*/*/save'),
|
24 |
+
'method' => 'post',
|
25 |
+
'enctype' => 'multipart/form-data'
|
26 |
+
));
|
27 |
+
|
28 |
+
$form->setUseContainer(true);
|
29 |
+
$this->setForm($form);
|
30 |
+
|
31 |
+
return parent::_prepareForm();
|
32 |
+
}
|
33 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/Synchronization/Edit/Tabs.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Template_Synchronization_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyTemplateSynchronizationEditTabs');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTitle(Mage::helper('M2ePro')->__('Configuration'));
|
19 |
+
$this->setDestElementId('edit_form');
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _beforeToHtml()
|
23 |
+
{
|
24 |
+
$this->addTab('list', array(
|
25 |
+
'label' => Mage::helper('M2ePro')->__('List Rules'),
|
26 |
+
'title' => Mage::helper('M2ePro')->__('List Rules'),
|
27 |
+
'content' => $this->getLayout()
|
28 |
+
->createBlock('M2ePro/adminhtml_common_buy_template_synchronization_edit_tabs_list')
|
29 |
+
->toHtml(),
|
30 |
+
))
|
31 |
+
->addTab('revise', array(
|
32 |
+
'label' => Mage::helper('M2ePro')->__('Revise Rules'),
|
33 |
+
'title' => Mage::helper('M2ePro')->__('Revise Rules'),
|
34 |
+
'content' => $this->getLayout()
|
35 |
+
->createBlock('M2ePro/adminhtml_common_buy_template_synchronization_edit_tabs_revise')
|
36 |
+
->toHtml(),
|
37 |
+
))
|
38 |
+
->addTab('relist', array(
|
39 |
+
'label' => Mage::helper('M2ePro')->__('Relist Rules'),
|
40 |
+
'title' => Mage::helper('M2ePro')->__('Relist Rules'),
|
41 |
+
'content' => $this->getLayout()
|
42 |
+
->createBlock('M2ePro/adminhtml_common_buy_template_synchronization_edit_tabs_relist')
|
43 |
+
->toHtml(),
|
44 |
+
))
|
45 |
+
->addTab('stop', array(
|
46 |
+
'label' => Mage::helper('M2ePro')->__('Stop Rules'),
|
47 |
+
'title' => Mage::helper('M2ePro')->__('Stop Rules'),
|
48 |
+
'content' => $this->getLayout()
|
49 |
+
->createBlock('M2ePro/adminhtml_common_buy_template_synchronization_edit_tabs_stop')
|
50 |
+
->toHtml(),
|
51 |
+
))
|
52 |
+
->setActiveTab($this->getRequest()->getParam('tab', 'list'));
|
53 |
+
|
54 |
+
return parent::_beforeToHtml();
|
55 |
+
}
|
56 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/Synchronization/Edit/Tabs/List.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Template_Synchronization_Edit_Tabs_List extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyTemplateSynchronizationEditTabsList');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/buy/template/synchronization/list.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/Synchronization/Edit/Tabs/Relist.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Template_Synchronization_Edit_Tabs_Relist
|
8 |
+
extends Mage_Adminhtml_Block_Widget
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
//------------------------------
|
16 |
+
$this->setId('buyTemplateSynchronizationEditTabsRelist');
|
17 |
+
//------------------------------
|
18 |
+
|
19 |
+
$this->setTemplate('M2ePro/common/buy/template/synchronization/relist.phtml');
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/Synchronization/Edit/Tabs/Revise.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Template_Synchronization_Edit_Tabs_Revise
|
8 |
+
extends Mage_Adminhtml_Block_Widget
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
//------------------------------
|
16 |
+
$this->setId('buyTemplateSynchronizationEditTabsRevise');
|
17 |
+
//------------------------------
|
18 |
+
|
19 |
+
$this->setTemplate('M2ePro/common/buy/template/synchronization/revise.phtml');
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/Synchronization/Edit/Tabs/Stop.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Template_Synchronization_Edit_Tabs_Stop extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyTemplateSynchronizationEditTabsStop');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/buy/template/synchronization/stop.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Component/Abstract.php
ADDED
@@ -0,0 +1,322 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
abstract class Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
// ########################################
|
10 |
+
|
11 |
+
const TAB_ID_AMAZON = 'amazon';
|
12 |
+
const TAB_ID_BUY = 'buy';
|
13 |
+
const TAB_ID_PLAY = 'play';
|
14 |
+
|
15 |
+
// ########################################
|
16 |
+
|
17 |
+
protected $tabs = array();
|
18 |
+
|
19 |
+
protected $enabledTab = NULL;
|
20 |
+
|
21 |
+
protected $tabsContainerBlock = NULL;
|
22 |
+
|
23 |
+
protected $tabsContainerId = 'components_container';
|
24 |
+
|
25 |
+
protected $useAjax = false;
|
26 |
+
|
27 |
+
protected $tabsAjaxUrls = array();
|
28 |
+
|
29 |
+
// ########################################
|
30 |
+
|
31 |
+
static public function getTabIdByComponent($component)
|
32 |
+
{
|
33 |
+
$tabId = null;
|
34 |
+
|
35 |
+
switch ($component) {
|
36 |
+
case Ess_M2ePro_Helper_Component_Amazon::NICK:
|
37 |
+
$tabId = self::TAB_ID_AMAZON;
|
38 |
+
break;
|
39 |
+
case Ess_M2ePro_Helper_Component_Buy::NICK:
|
40 |
+
$tabId = self::TAB_ID_BUY;
|
41 |
+
break;
|
42 |
+
case Ess_M2ePro_Helper_Component_Play::NICK:
|
43 |
+
$tabId = self::TAB_ID_PLAY;
|
44 |
+
break;
|
45 |
+
}
|
46 |
+
|
47 |
+
return $tabId;
|
48 |
+
}
|
49 |
+
|
50 |
+
// ########################################
|
51 |
+
|
52 |
+
public function enableAmazonTab()
|
53 |
+
{
|
54 |
+
$this->setEnabledTab(self::TAB_ID_AMAZON);
|
55 |
+
}
|
56 |
+
|
57 |
+
public function enableBuyTab()
|
58 |
+
{
|
59 |
+
$this->setEnabledTab(self::TAB_ID_BUY);
|
60 |
+
}
|
61 |
+
|
62 |
+
public function enablePlayTab()
|
63 |
+
{
|
64 |
+
$this->setEnabledTab(self::TAB_ID_PLAY);
|
65 |
+
}
|
66 |
+
|
67 |
+
// ########################################
|
68 |
+
|
69 |
+
public function setEnabledTab($id)
|
70 |
+
{
|
71 |
+
$this->enabledTab = $id;
|
72 |
+
}
|
73 |
+
|
74 |
+
// ----------------------------------------
|
75 |
+
|
76 |
+
protected function isTabEnabled($id)
|
77 |
+
{
|
78 |
+
if (is_null($this->enabledTab)) {
|
79 |
+
return true;
|
80 |
+
}
|
81 |
+
|
82 |
+
return $id == $this->enabledTab;
|
83 |
+
}
|
84 |
+
|
85 |
+
// ----------------------------------------
|
86 |
+
|
87 |
+
protected function canUseAjax()
|
88 |
+
{
|
89 |
+
if (count($this->tabs) < 2) {
|
90 |
+
return false;
|
91 |
+
}
|
92 |
+
|
93 |
+
return $this->useAjax;
|
94 |
+
}
|
95 |
+
|
96 |
+
// ########################################
|
97 |
+
|
98 |
+
protected function initializeTabs()
|
99 |
+
{
|
100 |
+
$this->initializeAmazon();
|
101 |
+
$this->initializeBuy();
|
102 |
+
$this->initializePlay();
|
103 |
+
}
|
104 |
+
|
105 |
+
protected function initializeTab($id)
|
106 |
+
{
|
107 |
+
if ($this->isTabEnabled($id) && !in_array($id, $this->tabs)) {
|
108 |
+
$this->tabs[] = $id;
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
protected function initializeAmazon()
|
113 |
+
{
|
114 |
+
if (Mage::helper('M2ePro/Component_Amazon')->isActive()) {
|
115 |
+
$this->initializeTab(self::TAB_ID_AMAZON);
|
116 |
+
}
|
117 |
+
}
|
118 |
+
|
119 |
+
protected function initializeBuy()
|
120 |
+
{
|
121 |
+
if (Mage::helper('M2ePro/Component_Buy')->isActive()) {
|
122 |
+
$this->initializeTab(self::TAB_ID_BUY);
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
protected function initializePlay()
|
127 |
+
{
|
128 |
+
if (Mage::helper('M2ePro/Component_Play')->isActive()) {
|
129 |
+
$this->initializeTab(self::TAB_ID_PLAY);
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
// ########################################
|
134 |
+
|
135 |
+
protected function getTabBlockById($id)
|
136 |
+
{
|
137 |
+
$id = ucfirst($id);
|
138 |
+
$method = "get{$id}TabBlock";
|
139 |
+
|
140 |
+
if (method_exists($this, $method)) {
|
141 |
+
return $this->$method();
|
142 |
+
}
|
143 |
+
|
144 |
+
return NULL;
|
145 |
+
}
|
146 |
+
|
147 |
+
protected function getTabHtmlById($id)
|
148 |
+
{
|
149 |
+
$id = ucfirst($id);
|
150 |
+
$method = "get{$id}TabHtml";
|
151 |
+
|
152 |
+
if (method_exists($this, $method)) {
|
153 |
+
return $this->$method();
|
154 |
+
}
|
155 |
+
|
156 |
+
return '';
|
157 |
+
}
|
158 |
+
|
159 |
+
protected function getTabLabelById($id)
|
160 |
+
{
|
161 |
+
$id = ucfirst($id);
|
162 |
+
$label = @constant("Ess_M2ePro_Helper_Component_{$id}::TITLE");
|
163 |
+
|
164 |
+
return $label ? Mage::helper('M2ePro')->__($label) : Mage::helper('M2ePro')->__('N/A');
|
165 |
+
}
|
166 |
+
|
167 |
+
protected function getTabUrlById($id)
|
168 |
+
{
|
169 |
+
return isset($this->tabsAjaxUrls[$id]) ? $this->tabsAjaxUrls[$id] : '';
|
170 |
+
}
|
171 |
+
|
172 |
+
// ########################################
|
173 |
+
|
174 |
+
protected function _prepareLayout()
|
175 |
+
{
|
176 |
+
if (count(Mage::helper('M2ePro/View_Common_Component')->getActiveComponents()) == 0) {
|
177 |
+
throw new LogicException('At least 1 Channel should be enabled.');
|
178 |
+
}
|
179 |
+
|
180 |
+
$this->initializeTabs();
|
181 |
+
|
182 |
+
parent::_prepareLayout();
|
183 |
+
}
|
184 |
+
|
185 |
+
// ########################################
|
186 |
+
|
187 |
+
protected function _toHtml()
|
188 |
+
{
|
189 |
+
return parent::_toHtml() . $this->_componentsToHtml();
|
190 |
+
}
|
191 |
+
|
192 |
+
protected function _componentsToHtml()
|
193 |
+
{
|
194 |
+
$tabsCount = count($this->tabs);
|
195 |
+
|
196 |
+
if ($tabsCount <= 0) {
|
197 |
+
return '';
|
198 |
+
}
|
199 |
+
|
200 |
+
if ($tabsCount == 1) {
|
201 |
+
$tabId = reset($this->tabs);
|
202 |
+
|
203 |
+
return $this->getTabHtmlById($tabId);
|
204 |
+
}
|
205 |
+
|
206 |
+
$tabsContainer = $this->getTabsContainerBlock();
|
207 |
+
$tabsContainer->setDestElementId($this->tabsContainerId);
|
208 |
+
|
209 |
+
foreach ($this->tabs as $tabId) {
|
210 |
+
$tab = $this->prepareTabById($tabId);
|
211 |
+
$tabsContainer->addTab($tabId, $tab);
|
212 |
+
}
|
213 |
+
|
214 |
+
$tabsContainer->setActiveTab($this->getActiveTab());
|
215 |
+
|
216 |
+
return $tabsContainer->toHtml() . $this->getTabsContainerDestinationHtml();
|
217 |
+
}
|
218 |
+
|
219 |
+
// ########################################
|
220 |
+
|
221 |
+
protected function prepareTabById($id)
|
222 |
+
{
|
223 |
+
$label = $this->getTabLabelById($id);
|
224 |
+
|
225 |
+
$tab = array(
|
226 |
+
'label' => $label,
|
227 |
+
'title' => $label
|
228 |
+
);
|
229 |
+
|
230 |
+
if ($this->canUseAjax() && $this->getActiveTab() != $id) {
|
231 |
+
$tab['class'] = 'ajax';
|
232 |
+
$tab['url'] = $this->getTabUrlById($id);
|
233 |
+
} else {
|
234 |
+
$tab['content'] = $this->getTabHtmlById($id);
|
235 |
+
}
|
236 |
+
|
237 |
+
return $tab;
|
238 |
+
}
|
239 |
+
|
240 |
+
// ########################################
|
241 |
+
|
242 |
+
protected function getSingleBlock()
|
243 |
+
{
|
244 |
+
if (count($this->tabs) != 1) {
|
245 |
+
return NULL;
|
246 |
+
}
|
247 |
+
|
248 |
+
$tabId = reset($this->tabs);
|
249 |
+
|
250 |
+
return $this->getTabBlockById($tabId);
|
251 |
+
}
|
252 |
+
|
253 |
+
// ########################################
|
254 |
+
|
255 |
+
/**
|
256 |
+
* @abstract
|
257 |
+
* @return Mage_Core_Block_Abstract
|
258 |
+
*/
|
259 |
+
abstract protected function getAmazonTabBlock();
|
260 |
+
|
261 |
+
public function getAmazonTabHtml()
|
262 |
+
{
|
263 |
+
return $this->getAmazonTabBlock()->toHtml();
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* @abstract
|
268 |
+
* @return Mage_Core_Block_Abstract
|
269 |
+
*/
|
270 |
+
abstract protected function getBuyTabBlock();
|
271 |
+
|
272 |
+
public function getBuyTabHtml()
|
273 |
+
{
|
274 |
+
return $this->getBuyTabBlock()->toHtml();
|
275 |
+
}
|
276 |
+
|
277 |
+
/**
|
278 |
+
* @abstract
|
279 |
+
* @return Mage_Core_Block_Abstract
|
280 |
+
*/
|
281 |
+
abstract protected function getPlayTabBlock();
|
282 |
+
|
283 |
+
public function getPlayTabHtml()
|
284 |
+
{
|
285 |
+
return $this->getPlayTabBlock()->toHtml();
|
286 |
+
}
|
287 |
+
|
288 |
+
// ########################################
|
289 |
+
|
290 |
+
/**
|
291 |
+
* @return Ess_M2ePro_Block_Adminhtml_Common_Component_Tabs
|
292 |
+
*/
|
293 |
+
protected function getTabsContainerBlock()
|
294 |
+
{
|
295 |
+
if (is_null($this->tabsContainerBlock)) {
|
296 |
+
$this->tabsContainerBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_component_tabs');
|
297 |
+
}
|
298 |
+
|
299 |
+
return $this->tabsContainerBlock;
|
300 |
+
}
|
301 |
+
|
302 |
+
protected function getTabsContainerDestinationHtml()
|
303 |
+
{
|
304 |
+
return '<div id="'.$this->tabsContainerId.'"></div>';
|
305 |
+
}
|
306 |
+
|
307 |
+
// ########################################
|
308 |
+
|
309 |
+
protected function getActiveTab()
|
310 |
+
{
|
311 |
+
$activeTab = $this->getRequest()->getParam('tab');
|
312 |
+
if (is_null($activeTab)) {
|
313 |
+
Mage::helper('M2ePro/View_Common_Component')->isAmazonDefault() && $activeTab = self::TAB_ID_AMAZON;
|
314 |
+
Mage::helper('M2ePro/View_Common_Component')->isBuyDefault() && $activeTab = self::TAB_ID_BUY;
|
315 |
+
Mage::helper('M2ePro/View_Common_Component')->isPlayDefault() && $activeTab = self::TAB_ID_PLAY;
|
316 |
+
}
|
317 |
+
|
318 |
+
return $activeTab;
|
319 |
+
}
|
320 |
+
|
321 |
+
// ########################################
|
322 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Component/Grid/Container.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
abstract class Ess_M2ePro_Block_Adminhtml_Common_Component_Grid_Container
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Container
|
9 |
+
{
|
10 |
+
// ########################################
|
11 |
+
|
12 |
+
abstract protected function getAmazonNewUrl();
|
13 |
+
|
14 |
+
abstract protected function getBuyNewUrl();
|
15 |
+
|
16 |
+
abstract protected function getPlayNewUrl();
|
17 |
+
|
18 |
+
// ########################################
|
19 |
+
|
20 |
+
protected function getAddButtonOnClickAction()
|
21 |
+
{
|
22 |
+
$components = Mage::helper('M2ePro/View_Common_Component')->getActiveComponents();
|
23 |
+
$action = '';
|
24 |
+
|
25 |
+
if (count($components) == 1) {
|
26 |
+
$component = reset($components);
|
27 |
+
$action = 'setLocation(\''.$this->getNewUrl($component).'\');';
|
28 |
+
}
|
29 |
+
|
30 |
+
return $action;
|
31 |
+
}
|
32 |
+
|
33 |
+
// ########################################
|
34 |
+
|
35 |
+
protected function _toHtml()
|
36 |
+
{
|
37 |
+
return $this->getAddButtonJavascript() . parent::_toHtml();
|
38 |
+
}
|
39 |
+
|
40 |
+
// ----------------------------------------
|
41 |
+
|
42 |
+
protected function getAddButtonJavascript()
|
43 |
+
{
|
44 |
+
if (count(Mage::helper('M2ePro/View_Common_Component')->getActiveComponents()) < 2) {
|
45 |
+
return '';
|
46 |
+
}
|
47 |
+
|
48 |
+
$data = array(
|
49 |
+
'target_css_class' => 'add-button-drop-down',
|
50 |
+
'items' => $this->getAddButtonDropDownItems()
|
51 |
+
);
|
52 |
+
$dropDownBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_button_dropDown');
|
53 |
+
$dropDownBlock->setData($data);
|
54 |
+
|
55 |
+
return $dropDownBlock->toHtml();
|
56 |
+
}
|
57 |
+
|
58 |
+
protected function getAddButtonDropDownItems()
|
59 |
+
{
|
60 |
+
$items = array();
|
61 |
+
|
62 |
+
$activeComponents = Mage::helper('M2ePro/View_Common_Component')->getActiveComponentsTitles();
|
63 |
+
|
64 |
+
//------------------------------
|
65 |
+
foreach ($activeComponents as $component => $title) {
|
66 |
+
$items[] = array(
|
67 |
+
'url' => $this->getNewUrl($component),
|
68 |
+
'label' => $title
|
69 |
+
);
|
70 |
+
}
|
71 |
+
//------------------------------
|
72 |
+
|
73 |
+
return $items;
|
74 |
+
}
|
75 |
+
|
76 |
+
// ########################################
|
77 |
+
|
78 |
+
protected function getNewUrl($component)
|
79 |
+
{
|
80 |
+
$component = ucfirst(strtolower($component));
|
81 |
+
$method = "get{$component}NewUrl";
|
82 |
+
|
83 |
+
if (!method_exists($this, $method)) {
|
84 |
+
throw new Exception('Method of adding a new entity is not defined.');
|
85 |
+
}
|
86 |
+
|
87 |
+
return $this->$method();
|
88 |
+
}
|
89 |
+
|
90 |
+
// ########################################
|
91 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Component/Tabs.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Component_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
8 |
+
{
|
9 |
+
// ########################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
$this->setTemplate('widget/tabshoriz.phtml');
|
15 |
+
}
|
16 |
+
|
17 |
+
// ########################################
|
18 |
+
|
19 |
+
public function addTabAfterAmazon($tabId, $tab)
|
20 |
+
{
|
21 |
+
return $this->addTabAfter($tabId, $tab, Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON);
|
22 |
+
}
|
23 |
+
|
24 |
+
public function addTabAfterBuy($tabId, $tab)
|
25 |
+
{
|
26 |
+
return $this->addTabAfter($tabId, $tab, Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_BUY);
|
27 |
+
}
|
28 |
+
|
29 |
+
public function addTabAfterPlay($tabId, $tab)
|
30 |
+
{
|
31 |
+
return $this->addTabAfter($tabId, $tab, Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_PLAY);
|
32 |
+
}
|
33 |
+
|
34 |
+
// ########################################
|
35 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Component/Tabs/Container.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
abstract class Ess_M2ePro_Block_Adminhtml_Common_Component_Tabs_Container
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract
|
9 |
+
{
|
10 |
+
// ########################################
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
$this->setTemplate('M2ePro/common/component/container.phtml');
|
16 |
+
}
|
17 |
+
|
18 |
+
// ########################################
|
19 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing.php
ADDED
@@ -0,0 +1,264 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing extends Ess_M2ePro_Block_Adminhtml_Common_Component_Tabs_Container
|
8 |
+
{
|
9 |
+
// ########################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Set header text
|
16 |
+
//------------------------------
|
17 |
+
$this->_headerText = Mage::helper('M2ePro')->__('Listings');
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
//------------------------------
|
21 |
+
if (!is_null($this->getRequest()->getParam('back'))) {
|
22 |
+
$url = Mage::helper('M2ePro')->getBackUrl('*/adminhtml_common_listing/index');
|
23 |
+
$this->_addButton('back', array(
|
24 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
25 |
+
'onclick' => 'CommonHandlerObj.back_click(\''.$url.'\')',
|
26 |
+
'class' => 'back'
|
27 |
+
));
|
28 |
+
}
|
29 |
+
//------------------------------
|
30 |
+
|
31 |
+
//------------------------------
|
32 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_listing/index');
|
33 |
+
//------------------------------
|
34 |
+
|
35 |
+
//------------------------------
|
36 |
+
$url = $this->getUrl('*/adminhtml_common_listing/search', array('back' => $backUrl));
|
37 |
+
$this->_addButton('search_products', array(
|
38 |
+
'label' => Mage::helper('M2ePro')->__('Search'),
|
39 |
+
'onclick' => 'setLocation(\'' . $url . '\')',
|
40 |
+
'class' => 'button_link search'
|
41 |
+
));
|
42 |
+
//------------------------------
|
43 |
+
|
44 |
+
//------------------------------
|
45 |
+
$this->useAjax = true;
|
46 |
+
$this->tabsAjaxUrls = array(
|
47 |
+
self::TAB_ID_AMAZON => $this->getUrl('*/adminhtml_common_amazon_listing/index'),
|
48 |
+
self::TAB_ID_BUY => $this->getUrl('*/adminhtml_common_buy_listing/index'),
|
49 |
+
self::TAB_ID_PLAY => $this->getUrl('*/adminhtml_common_play_listing/index'),
|
50 |
+
);
|
51 |
+
//------------------------------
|
52 |
+
}
|
53 |
+
|
54 |
+
// ########################################
|
55 |
+
|
56 |
+
protected function getTabsContainerBlock()
|
57 |
+
{
|
58 |
+
return parent::getTabsContainerBlock()->setId('listing');
|
59 |
+
}
|
60 |
+
|
61 |
+
// ########################################
|
62 |
+
|
63 |
+
protected function _toHtml()
|
64 |
+
{
|
65 |
+
$urls = json_encode(array(
|
66 |
+
'adminhtml_common_listing/saveTitle' => Mage::helper('adminhtml')
|
67 |
+
->getUrl('M2ePro/adminhtml_common_listing/saveTitle')
|
68 |
+
));
|
69 |
+
|
70 |
+
$translations = json_encode(array(
|
71 |
+
'Cancel' => Mage::helper('M2ePro')->__('Cancel'),
|
72 |
+
'Save' => Mage::helper('M2ePro')->__('Save'),
|
73 |
+
'Edit Listing Title' => Mage::helper('M2ePro')->__('Edit Listing Title'),
|
74 |
+
));
|
75 |
+
|
76 |
+
$uniqueTitleTxt = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
77 |
+
->__('The specified Title is already used for other Listing. Listing Title must be unique.'));
|
78 |
+
|
79 |
+
$constants = Mage::helper('M2ePro')
|
80 |
+
->getClassConstantAsJson('Ess_M2ePro_Helper_Component_'.ucfirst($this->getActiveTab()));
|
81 |
+
|
82 |
+
$javascripts = <<<HTML
|
83 |
+
|
84 |
+
<script type="text/javascript">
|
85 |
+
|
86 |
+
Event.observe(window, 'load', function() {
|
87 |
+
M2ePro.url.add({$urls});
|
88 |
+
M2ePro.translator.add({$translations});
|
89 |
+
});
|
90 |
+
|
91 |
+
M2ePro.text.title_not_unique_error = '{$uniqueTitleTxt}';
|
92 |
+
|
93 |
+
M2ePro.php.setConstants(
|
94 |
+
{$constants},
|
95 |
+
'Ess_M2ePro_Helper_Component'
|
96 |
+
);
|
97 |
+
|
98 |
+
var editListingTitle = function(el)
|
99 |
+
{
|
100 |
+
EditListingTitleObj.gridId = listingJsTabs.activeTab.id.replace('listing_', '') + 'ListingGrid';
|
101 |
+
EditListingTitleObj.openPopup(el);
|
102 |
+
}
|
103 |
+
|
104 |
+
EditListingTitleObj = new EditListingTitle();
|
105 |
+
|
106 |
+
</script>
|
107 |
+
|
108 |
+
HTML;
|
109 |
+
|
110 |
+
return parent::_toHtml().$javascripts;
|
111 |
+
}
|
112 |
+
|
113 |
+
// ########################################
|
114 |
+
|
115 |
+
protected function getAmazonTabBlock()
|
116 |
+
{
|
117 |
+
if (!$this->getChild('amazon_tab')) {
|
118 |
+
$block = $this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_listing');
|
119 |
+
|
120 |
+
$this->setChild('amazon_tab', $block);
|
121 |
+
}
|
122 |
+
|
123 |
+
return $this->getChild('amazon_tab');
|
124 |
+
}
|
125 |
+
|
126 |
+
public function getAmazonTabHtml()
|
127 |
+
{
|
128 |
+
return $this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_listing_filter')->toHtml() .
|
129 |
+
parent::getAmazonTabHtml();
|
130 |
+
}
|
131 |
+
|
132 |
+
// ########################################
|
133 |
+
|
134 |
+
protected function getBuyTabBlock()
|
135 |
+
{
|
136 |
+
if (!$this->getChild('buy_tab')) {
|
137 |
+
$block = $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_listing');
|
138 |
+
|
139 |
+
$this->setChild('buy_tab', $block);
|
140 |
+
}
|
141 |
+
|
142 |
+
return $this->getChild('buy_tab');
|
143 |
+
}
|
144 |
+
|
145 |
+
public function getBuyTabHtml()
|
146 |
+
{
|
147 |
+
return $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_listing_filter')->toHtml() .
|
148 |
+
parent::getBuyTabHtml();
|
149 |
+
}
|
150 |
+
|
151 |
+
// ########################################
|
152 |
+
|
153 |
+
protected function getPlayTabBlock()
|
154 |
+
{
|
155 |
+
if (!$this->getChild('play_tab')) {
|
156 |
+
$block = $this->getLayout()->createBlock('M2ePro/adminhtml_common_play_listing');
|
157 |
+
|
158 |
+
$this->setChild('play_tab', $block);
|
159 |
+
}
|
160 |
+
|
161 |
+
return $this->getChild('play_tab');
|
162 |
+
}
|
163 |
+
|
164 |
+
public function getPlayTabHtml()
|
165 |
+
{
|
166 |
+
return $this->getLayout()->createBlock('M2ePro/adminhtml_common_play_listing_filter')->toHtml() .
|
167 |
+
parent::getPlayTabHtml();
|
168 |
+
}
|
169 |
+
|
170 |
+
// ########################################
|
171 |
+
|
172 |
+
protected function getTabHtmlById($id)
|
173 |
+
{
|
174 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
175 |
+
return parent::getTabHtmlById($id);
|
176 |
+
}
|
177 |
+
|
178 |
+
/** @var $singleBlock Mage_Core_Block_Abstract|Mage_Adminhtml_Block_Widget_Grid_Container */
|
179 |
+
$singleBlock = $this->getSingleBlock();
|
180 |
+
|
181 |
+
if (is_object($singleBlock) && $singleBlock instanceof Mage_Adminhtml_Block_Widget_Grid_Container) {
|
182 |
+
return $singleBlock->getGridHtml();
|
183 |
+
}
|
184 |
+
|
185 |
+
return parent::getTabHtmlById($id);
|
186 |
+
}
|
187 |
+
|
188 |
+
protected function _componentsToHtml()
|
189 |
+
{
|
190 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_listing_help');
|
191 |
+
$floatingToolbarFixer = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_floatingToolbarFixer');
|
192 |
+
|
193 |
+
return $helpBlock->toHtml() . $floatingToolbarFixer->toHtml() . parent::_componentsToHtml();
|
194 |
+
}
|
195 |
+
|
196 |
+
// ########################################
|
197 |
+
|
198 |
+
public function getButtonsHtml($area = null)
|
199 |
+
{
|
200 |
+
$javascript = $this->getButtonsJavascript();
|
201 |
+
|
202 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
203 |
+
return $javascript . parent::getButtonsHtml($area);
|
204 |
+
}
|
205 |
+
|
206 |
+
return $javascript . $this->getSingleBlock()->getButtonsHtml();
|
207 |
+
}
|
208 |
+
|
209 |
+
private function getButtonsJavascript()
|
210 |
+
{
|
211 |
+
if (count($this->tabs) <= 0) {
|
212 |
+
return '';
|
213 |
+
}
|
214 |
+
|
215 |
+
if (count($this->tabs) == 1) {
|
216 |
+
return $this->getSingleBlock()->getTemplatesButtonJavascript();
|
217 |
+
}
|
218 |
+
|
219 |
+
$javascript = '';
|
220 |
+
|
221 |
+
return $javascript;
|
222 |
+
}
|
223 |
+
|
224 |
+
private function getAmazonButtonsJavascript()
|
225 |
+
{
|
226 |
+
if (!Mage::helper('M2ePro/Component_Amazon')->isActive()) {
|
227 |
+
return '';
|
228 |
+
}
|
229 |
+
|
230 |
+
if ($this->getActiveTab() != self::TAB_ID_AMAZON) {
|
231 |
+
return '';
|
232 |
+
}
|
233 |
+
|
234 |
+
return $this->getAmazonTabBlock()->getTemplatesButtonJavascript();
|
235 |
+
}
|
236 |
+
|
237 |
+
private function getBuyButtonsJavascript()
|
238 |
+
{
|
239 |
+
if (!Mage::helper('M2ePro/Component_Buy')->isActive()) {
|
240 |
+
return '';
|
241 |
+
}
|
242 |
+
|
243 |
+
if ($this->getActiveTab() != self::TAB_ID_BUY) {
|
244 |
+
return '';
|
245 |
+
}
|
246 |
+
|
247 |
+
return $this->getBuyTabBlock()->getTemplatesButtonJavascript();
|
248 |
+
}
|
249 |
+
|
250 |
+
private function getPlayButtonsJavascript()
|
251 |
+
{
|
252 |
+
if (!Mage::helper('M2ePro/Component_Play')->isActive()) {
|
253 |
+
return '';
|
254 |
+
}
|
255 |
+
|
256 |
+
if ($this->getActiveTab() != self::TAB_ID_PLAY) {
|
257 |
+
return '';
|
258 |
+
}
|
259 |
+
|
260 |
+
return $this->getPlayTabBlock()->getTemplatesButtonJavascript();
|
261 |
+
}
|
262 |
+
|
263 |
+
// ########################################
|
264 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/Form.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_Form extends Mage_Adminhtml_Block_Widget_Form
|
8 |
+
{
|
9 |
+
protected $component;
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('listingEditForm');
|
18 |
+
//------------------------------
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _prepareForm()
|
22 |
+
{
|
23 |
+
// Prepare action
|
24 |
+
// -------------------
|
25 |
+
$step = $this->getRequest()->getParam('step');
|
26 |
+
|
27 |
+
if (is_null($step)) {
|
28 |
+
// Edit listing mode
|
29 |
+
$action = $this->getUrl('*/adminhtml_common_' . $this->component . '_listing/save');
|
30 |
+
} else {
|
31 |
+
// Add listing mode
|
32 |
+
$action = $this->getUrl('*/adminhtml_common_' . $this->component . '_listing/add', array(
|
33 |
+
'step' => (int)$step
|
34 |
+
));
|
35 |
+
}
|
36 |
+
// -------------------
|
37 |
+
|
38 |
+
$form = new Varien_Data_Form(array(
|
39 |
+
'id' => 'edit_form',
|
40 |
+
'action' => $action,
|
41 |
+
'method' => 'post',
|
42 |
+
'enctype' => 'multipart/form-data'
|
43 |
+
));
|
44 |
+
|
45 |
+
$form->setUseContainer(true);
|
46 |
+
$this->setForm($form);
|
47 |
+
|
48 |
+
return parent::_prepareForm();
|
49 |
+
}
|
50 |
+
|
51 |
+
protected function _beforeToHtml()
|
52 |
+
{
|
53 |
+
// Add listing mode
|
54 |
+
// -------------------
|
55 |
+
$child = NULL;
|
56 |
+
$step = $this->getRequest()->getParam('step');
|
57 |
+
|
58 |
+
if ($step == 1) {
|
59 |
+
$child = $this->getLayout()
|
60 |
+
->createBlock('M2ePro/adminhtml_common_' . $this->component . '_listing_add_tabs_general');
|
61 |
+
} else if ($step == 2) {
|
62 |
+
$child = $this->getLayout()
|
63 |
+
->createBlock('M2ePro/adminhtml_common_' . $this->component . '_listing_add_tabs_selling');
|
64 |
+
} elseif ($step == 3) {
|
65 |
+
$child = $this->getLayout()
|
66 |
+
->createBlock('M2ePro/adminhtml_common_' . $this->component . '_listing_add_tabs_search');
|
67 |
+
}
|
68 |
+
|
69 |
+
if (!is_null($child)) {
|
70 |
+
$this->setTemplate('M2ePro/common/listing/add.phtml');
|
71 |
+
$this->setChild('main', $this->getLayout()
|
72 |
+
->createBlock('M2ePro/adminhtml_common_listing_add_main'));
|
73 |
+
$this->setChild('content', $child);
|
74 |
+
}
|
75 |
+
// -------------------
|
76 |
+
|
77 |
+
return parent::_beforeToHtml();
|
78 |
+
}
|
79 |
+
|
80 |
+
// ########################################
|
81 |
+
|
82 |
+
protected function _toHtml()
|
83 |
+
{
|
84 |
+
$breadcrumb = $this->getLayout()->createBlock(
|
85 |
+
'M2ePro/adminhtml_common_listing_breadcrumb','',
|
86 |
+
array('step' => $this->getRequest()->getParam('step', 1))
|
87 |
+
);
|
88 |
+
|
89 |
+
return $breadcrumb->_toHtml() . parent::_toHtml();
|
90 |
+
}
|
91 |
+
|
92 |
+
// ########################################
|
93 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/Main.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_Main extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('listingEditTabsChannelGeneral');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/listing/add/main.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/Review.php
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2011 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_Review extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
// ####################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('listingProductReview');
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$this->_headerText = Mage::helper('M2ePro')->__('Congratulations');
|
21 |
+
|
22 |
+
$this->setTemplate('M2ePro/common/listing/add/review.phtml');
|
23 |
+
}
|
24 |
+
|
25 |
+
// ####################################
|
26 |
+
|
27 |
+
public function getHeaderCssClass()
|
28 |
+
{
|
29 |
+
return 'icon-head ' . parent::getHeaderCssClass();
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getHeaderWidth()
|
33 |
+
{
|
34 |
+
return 'width:50%;';
|
35 |
+
}
|
36 |
+
|
37 |
+
// ####################################
|
38 |
+
|
39 |
+
protected function _beforeToHtml()
|
40 |
+
{
|
41 |
+
parent::_beforeToHtml();
|
42 |
+
|
43 |
+
// --------------------------------------
|
44 |
+
|
45 |
+
$listing = Mage::helper('M2ePro/Component')->getCachedUnknownObject(
|
46 |
+
'Listing', $this->getRequest()->getParam('id')
|
47 |
+
);
|
48 |
+
|
49 |
+
$viewHeaderBlock = $this->getLayout()->createBlock(
|
50 |
+
'M2ePro/adminhtml_listing_view_header','',
|
51 |
+
array('listing' => $listing)
|
52 |
+
);
|
53 |
+
|
54 |
+
$this->setChild('view_header', $viewHeaderBlock);
|
55 |
+
|
56 |
+
// --------------------------------------
|
57 |
+
|
58 |
+
// --------------------------------------
|
59 |
+
$url = $this->getUrl('*/*/viewListing', array(
|
60 |
+
'_current' => true,
|
61 |
+
'id' => $this->getRequest()->getParam('id')
|
62 |
+
));
|
63 |
+
|
64 |
+
$buttonBlock = $this->getLayout()
|
65 |
+
->createBlock('adminhtml/widget_button')
|
66 |
+
->setData( array(
|
67 |
+
'label' => Mage::helper('M2ePro')->__('Review Your Products'),
|
68 |
+
'onclick' => 'setLocation(\''.$url.'\');',
|
69 |
+
'class' => 'save'
|
70 |
+
) );
|
71 |
+
$this->setChild('review', $buttonBlock);
|
72 |
+
// --------------------------------------
|
73 |
+
|
74 |
+
// --------------------------------------
|
75 |
+
$url = $this->getUrl('*/*/viewListingAndList', array(
|
76 |
+
'_current' => true,
|
77 |
+
'id' => $this->getRequest()->getParam('id')
|
78 |
+
));
|
79 |
+
|
80 |
+
$buttonBlock = $this->getLayout()
|
81 |
+
->createBlock('adminhtml/widget_button')
|
82 |
+
->setData( array(
|
83 |
+
'label' => Mage::helper('M2ePro')->__('List Added Products Now'),
|
84 |
+
'onclick' => 'setLocation(\''.$url.'\');',
|
85 |
+
'class' => 'save'
|
86 |
+
) );
|
87 |
+
$this->setChild('list', $buttonBlock);
|
88 |
+
// --------------------------------------
|
89 |
+
}
|
90 |
+
|
91 |
+
// ####################################
|
92 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/SourceCategory.php
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_SourceCategory
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Container
|
9 |
+
{
|
10 |
+
public function __construct($attributes)
|
11 |
+
{
|
12 |
+
parent::__construct($attributes);
|
13 |
+
|
14 |
+
$this->setData($attributes);
|
15 |
+
$component = $this->getData('component');
|
16 |
+
|
17 |
+
// Initialization block
|
18 |
+
//------------------------------
|
19 |
+
$this->setId($component.'ListingAddStepFourCategory');
|
20 |
+
$this->_blockGroup = 'M2ePro';
|
21 |
+
$this->_controller = 'adminhtml_common_listing_product_category';
|
22 |
+
//------------------------------
|
23 |
+
|
24 |
+
// Set header text
|
25 |
+
//------------------------------
|
26 |
+
$this->_headerText = Mage::helper('M2ePro')->__("Select Products");
|
27 |
+
//------------------------------
|
28 |
+
|
29 |
+
// Set buttons actions
|
30 |
+
//------------------------------
|
31 |
+
$this->removeButton('back');
|
32 |
+
$this->removeButton('reset');
|
33 |
+
$this->removeButton('delete');
|
34 |
+
$this->removeButton('add');
|
35 |
+
$this->removeButton('save');
|
36 |
+
$this->removeButton('edit');
|
37 |
+
//------------------------------
|
38 |
+
|
39 |
+
//------------------------------
|
40 |
+
if (is_null($this->getRequest()->getParam('back'))) {
|
41 |
+
$url = $this->getUrl('*/adminhtml_common_listing_productAdd/index', array(
|
42 |
+
'id' => $this->getRequest()->getParam('id'),
|
43 |
+
'component' => $component
|
44 |
+
));
|
45 |
+
} else {
|
46 |
+
$tab = constant('Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_'.strtoupper($component));
|
47 |
+
$url = Mage::helper('M2ePro')->getBackUrl(
|
48 |
+
'*/adminhtml_common_listing/index',
|
49 |
+
array(
|
50 |
+
'tab' => $tab
|
51 |
+
)
|
52 |
+
);
|
53 |
+
}
|
54 |
+
$this->_addButton('back', array(
|
55 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
56 |
+
'onclick' => 'ProductGridHandlerObj.back_click(\'' . $url . '\')',
|
57 |
+
'class' => 'back'
|
58 |
+
));
|
59 |
+
//------------------------------
|
60 |
+
|
61 |
+
//------------------------------
|
62 |
+
$this->_addButton('auto_action', array(
|
63 |
+
'label' => Mage::helper('M2ePro')->__('Auto Add/Remove Rules'),
|
64 |
+
'onclick' => 'ListingAutoActionHandlerObj.loadAutoActionHtml();'
|
65 |
+
));
|
66 |
+
//------------------------------
|
67 |
+
|
68 |
+
//------------------------------
|
69 |
+
$this->_addButton('save_and_go_to_listing_view', array(
|
70 |
+
'label' => Mage::helper('M2ePro')->__('Continue'),
|
71 |
+
'onclick' => 'add_category_products()',
|
72 |
+
'class' => 'scalable next'
|
73 |
+
));
|
74 |
+
//------------------------------
|
75 |
+
}
|
76 |
+
|
77 |
+
public function getGridHtml()
|
78 |
+
{
|
79 |
+
$listing = Mage::helper('M2ePro/Component')
|
80 |
+
->getCachedUnknownObject('Listing', $this->getRequest()->getParam('id'));
|
81 |
+
|
82 |
+
$viewHeaderBlock = $this->getLayout()->createBlock(
|
83 |
+
'M2ePro/adminhtml_listing_view_header','',
|
84 |
+
array('listing' => $listing)
|
85 |
+
);
|
86 |
+
|
87 |
+
$urls = Mage::helper('M2ePro')->getControllerActions(
|
88 |
+
'adminhtml_common_listing_autoAction',
|
89 |
+
array(
|
90 |
+
'listing_id' => $this->getRequest()->getParam('id'),
|
91 |
+
'component' => $this->getData('component')
|
92 |
+
)
|
93 |
+
);
|
94 |
+
$urls = json_encode($urls);
|
95 |
+
|
96 |
+
/** @var $helper Ess_M2ePro_Helper_Data */
|
97 |
+
$helper = Mage::helper('M2ePro');
|
98 |
+
|
99 |
+
$translations = json_encode(array(
|
100 |
+
'Auto Add/Remove Rules' => $helper->__('Auto Add/Remove Rules'),
|
101 |
+
'Based on Magento Categories' => $helper->__('Based on Magento Categories'),
|
102 |
+
'You must select at least 1 Category.' => $helper->__('You must select at least 1 Category.'),
|
103 |
+
'Rule with the same Title already exists.' => $helper->__('Rule with the same Title already exists.')
|
104 |
+
));
|
105 |
+
|
106 |
+
$js = <<<HTML
|
107 |
+
<script type="text/javascript">
|
108 |
+
|
109 |
+
M2ePro.url.add({$urls});
|
110 |
+
M2ePro.translator.add({$translations});
|
111 |
+
|
112 |
+
ListingAutoActionHandlerObj = new ListingAutoActionHandler();
|
113 |
+
|
114 |
+
</script>
|
115 |
+
HTML;
|
116 |
+
|
117 |
+
return $viewHeaderBlock->toHtml() . parent::getGridHtml() . $js;
|
118 |
+
}
|
119 |
+
|
120 |
+
protected function _toHtml()
|
121 |
+
{
|
122 |
+
return '<div id="add_products_progress_bar"></div>'.
|
123 |
+
'<div id="add_products_container">'.
|
124 |
+
parent::_toHtml() .
|
125 |
+
'</div>';
|
126 |
+
}
|
127 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/SourceMode.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_SourceMode
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Form_Container
|
9 |
+
{
|
10 |
+
const SOURCE_LIST = 'list';
|
11 |
+
const SOURCE_CATEGORIES = 'categories';
|
12 |
+
|
13 |
+
public function __construct()
|
14 |
+
{
|
15 |
+
parent::__construct();
|
16 |
+
|
17 |
+
// Initialization block
|
18 |
+
//------------------------------
|
19 |
+
$this->setId('amazonListingSourceMode');
|
20 |
+
$this->_blockGroup = 'M2ePro';
|
21 |
+
$this->_controller = 'adminhtml_common_listing_add';
|
22 |
+
$this->_mode = 'sourceMode';
|
23 |
+
//------------------------------
|
24 |
+
|
25 |
+
// Set header text
|
26 |
+
//------------------------------
|
27 |
+
$this->_headerText = Mage::helper('M2ePro')->__('Add Products');
|
28 |
+
//------------------------------
|
29 |
+
|
30 |
+
// Set buttons actions
|
31 |
+
//------------------------------
|
32 |
+
$this->removeButton('back');
|
33 |
+
$this->removeButton('reset');
|
34 |
+
$this->removeButton('delete');
|
35 |
+
$this->removeButton('add');
|
36 |
+
$this->removeButton('save');
|
37 |
+
$this->removeButton('edit');
|
38 |
+
//------------------------------
|
39 |
+
|
40 |
+
//------------------------------
|
41 |
+
$url = $this->getUrl('*/*/*',array('_current' => true));
|
42 |
+
$this->_addButton('next', array(
|
43 |
+
'label' => Mage::helper('M2ePro')->__('Continue'),
|
44 |
+
'onclick' => 'CommonHandlerObj.submitForm(\''.$url.'\');',
|
45 |
+
'class' => 'scalable next'
|
46 |
+
));
|
47 |
+
//------------------------------
|
48 |
+
}
|
49 |
+
|
50 |
+
protected function _toHtml()
|
51 |
+
{
|
52 |
+
$listing = Mage::helper('M2ePro/Component')
|
53 |
+
->getCachedUnknownObject('Listing', $this->getRequest()->getParam('id'));
|
54 |
+
|
55 |
+
$viewHeaderBlock = $this->getLayout()->createBlock(
|
56 |
+
'M2ePro/adminhtml_listing_view_header','',
|
57 |
+
array('listing' => $listing)
|
58 |
+
);
|
59 |
+
|
60 |
+
$this->setChild('view_header', $viewHeaderBlock);
|
61 |
+
|
62 |
+
return parent::_toHtml();
|
63 |
+
}
|
64 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/SourceMode/Form.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_SourceMode_Form extends Mage_Adminhtml_Block_Widget_Form
|
8 |
+
{
|
9 |
+
// ########################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('listingSourceMode');
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$this->setTemplate('M2ePro/common/listing/add/source_mode/source_mode.phtml');
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _prepareForm()
|
24 |
+
{
|
25 |
+
$form = new Varien_Data_Form(array(
|
26 |
+
'id' => 'edit_form',
|
27 |
+
'action' => $this->getUrl('*/*/*'),
|
28 |
+
'method' => 'post',
|
29 |
+
'enctype' => 'multipart/form-data'
|
30 |
+
));
|
31 |
+
|
32 |
+
$form->setUseContainer(true);
|
33 |
+
$this->setForm($form);
|
34 |
+
|
35 |
+
return parent::_prepareForm();
|
36 |
+
}
|
37 |
+
|
38 |
+
protected function _beforeToHtml()
|
39 |
+
{
|
40 |
+
//------------------------------
|
41 |
+
$this->setData('source',
|
42 |
+
$this->getRequest()->getParam('source', Ess_M2ePro_Model_Listing::SOURCE_PRODUCTS_CUSTOM));
|
43 |
+
//------------------------------
|
44 |
+
|
45 |
+
return parent::_beforeToHtml();
|
46 |
+
}
|
47 |
+
|
48 |
+
// ########################################
|
49 |
+
|
50 |
+
protected function _toHtml()
|
51 |
+
{
|
52 |
+
return parent::_toHtml();
|
53 |
+
}
|
54 |
+
|
55 |
+
// ########################################
|
56 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/SourceProduct.php
ADDED
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_SourceProduct
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Container
|
9 |
+
{
|
10 |
+
public function __construct($attributes)
|
11 |
+
{
|
12 |
+
parent::__construct($attributes);
|
13 |
+
|
14 |
+
$this->setData($attributes);
|
15 |
+
$component = $this->getData('component');
|
16 |
+
|
17 |
+
// Initialization block
|
18 |
+
//------------------------------
|
19 |
+
$this->setId($component.'ListingAddFromProductList');
|
20 |
+
$this->_blockGroup = 'M2ePro';
|
21 |
+
$this->_controller = 'adminhtml_common_listing_product';
|
22 |
+
//------------------------------
|
23 |
+
|
24 |
+
// Set header text
|
25 |
+
//------------------------------
|
26 |
+
$this->_headerText = Mage::helper('M2ePro')->__("Select Products");
|
27 |
+
//------------------------------
|
28 |
+
|
29 |
+
// Set buttons actions
|
30 |
+
//------------------------------
|
31 |
+
$this->removeButton('back');
|
32 |
+
$this->removeButton('reset');
|
33 |
+
$this->removeButton('delete');
|
34 |
+
$this->removeButton('add');
|
35 |
+
$this->removeButton('save');
|
36 |
+
$this->removeButton('edit');
|
37 |
+
//------------------------------
|
38 |
+
|
39 |
+
//------------------------------
|
40 |
+
if (is_null($this->getRequest()->getParam('back'))) {
|
41 |
+
$url = $this->getUrl('*/adminhtml_common_listing_productAdd/index', array(
|
42 |
+
'id' => $this->getRequest()->getParam('id'),
|
43 |
+
'component' => $component
|
44 |
+
));
|
45 |
+
} else {
|
46 |
+
$tab = constant('Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_'.strtoupper($component));
|
47 |
+
$url = Mage::helper('M2ePro')->getBackUrl(
|
48 |
+
'*/adminhtml_common_listing/index',
|
49 |
+
array(
|
50 |
+
'tab' => $tab
|
51 |
+
)
|
52 |
+
);
|
53 |
+
}
|
54 |
+
$this->_addButton('back', array(
|
55 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
56 |
+
'onclick' => 'ProductGridHandlerObj.back_click(\'' . $url . '\')',
|
57 |
+
'class' => 'back'
|
58 |
+
));
|
59 |
+
|
60 |
+
//------------------------------
|
61 |
+
$this->_addButton('auto_action', array(
|
62 |
+
'label' => Mage::helper('M2ePro')->__('Auto Add/Remove Rules'),
|
63 |
+
'onclick' => 'ListingAutoActionHandlerObj.loadAutoActionHtml();'
|
64 |
+
));
|
65 |
+
//------------------------------
|
66 |
+
|
67 |
+
//------------------------------
|
68 |
+
$this->_addButton('save_and_go_to_listing_view', array(
|
69 |
+
'label' => Mage::helper('M2ePro')->__('Continue'),
|
70 |
+
'onclick' => 'ProductGridHandlerObj.save_click(\'view\')',
|
71 |
+
'class' => 'scalable next'
|
72 |
+
));
|
73 |
+
//------------------------------
|
74 |
+
}
|
75 |
+
|
76 |
+
public function getGridHtml()
|
77 |
+
{
|
78 |
+
$listing = Mage::helper('M2ePro/Component')
|
79 |
+
->getCachedUnknownObject('Listing', $this->getRequest()->getParam('id'));
|
80 |
+
|
81 |
+
$viewHeaderBlock = $this->getLayout()->createBlock(
|
82 |
+
'M2ePro/adminhtml_listing_view_header','',
|
83 |
+
array('listing' => $listing)
|
84 |
+
);
|
85 |
+
|
86 |
+
$urls = Mage::helper('M2ePro')->getControllerActions(
|
87 |
+
'adminhtml_common_listing_autoAction',
|
88 |
+
array(
|
89 |
+
'listing_id' => $this->getRequest()->getParam('id'),
|
90 |
+
'component' => $this->getData('component')
|
91 |
+
)
|
92 |
+
);
|
93 |
+
$urls = json_encode($urls);
|
94 |
+
|
95 |
+
/** @var $helper Ess_M2ePro_Helper_Data */
|
96 |
+
$helper = Mage::helper('M2ePro');
|
97 |
+
|
98 |
+
$translations = json_encode(array(
|
99 |
+
'Auto Add/Remove Rules' => $helper->__('Auto Add/Remove Rules'),
|
100 |
+
'Based on Magento Categories' => $helper->__('Based on Magento Categories'),
|
101 |
+
'You must select at least 1 Category.' => $helper->__('You must select at least 1 Category.'),
|
102 |
+
'Rule with the same Title already exists.' => $helper->__('Rule with the same Title already exists.')
|
103 |
+
));
|
104 |
+
|
105 |
+
$js = <<<HTML
|
106 |
+
<script type="text/javascript">
|
107 |
+
|
108 |
+
M2ePro.url.add({$urls});
|
109 |
+
M2ePro.translator.add({$translations});
|
110 |
+
|
111 |
+
ListingAutoActionHandlerObj = new ListingAutoActionHandler();
|
112 |
+
|
113 |
+
</script>
|
114 |
+
HTML;
|
115 |
+
|
116 |
+
return $viewHeaderBlock->toHtml() . parent::getGridHtml() . $js;
|
117 |
+
}
|
118 |
+
|
119 |
+
protected function _toHtml()
|
120 |
+
{
|
121 |
+
return '<div id="add_products_progress_bar"></div>'.
|
122 |
+
'<div id="add_products_container">'.
|
123 |
+
parent::_toHtml().
|
124 |
+
'</div>';
|
125 |
+
}
|
126 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/StepOne.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_StepOne extends Mage_Adminhtml_Block_Widget_Form_Container
|
8 |
+
{
|
9 |
+
public function __construct($attributes)
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
$this->setData($attributes);
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId($this->getData('component').'ListingAddStepOne');
|
18 |
+
$this->_blockGroup = 'M2ePro';
|
19 |
+
$this->_controller = 'adminhtml_common_'.$this->getData('component').'_listing';
|
20 |
+
$this->_mode = 'add';
|
21 |
+
//------------------------------
|
22 |
+
|
23 |
+
// Set header text
|
24 |
+
//------------------------------
|
25 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
26 |
+
$titleConst = constant('Ess_M2ePro_Helper_Component_'.ucfirst($this->getData('component')).'::TITLE');
|
27 |
+
$componentName = Mage::helper('M2ePro')->__($titleConst);
|
28 |
+
$headerText = Mage::helper('M2ePro')
|
29 |
+
->__("Creating A New %component_name% M2E Pro Listing", $componentName);
|
30 |
+
} else {
|
31 |
+
$headerText = Mage::helper('M2ePro')->__("Creating A New M2E Pro Listing");
|
32 |
+
}
|
33 |
+
$this->_headerText = $headerText;
|
34 |
+
//------------------------------
|
35 |
+
|
36 |
+
// Set buttons actions
|
37 |
+
//------------------------------
|
38 |
+
$this->removeButton('back');
|
39 |
+
$this->removeButton('reset');
|
40 |
+
$this->removeButton('delete');
|
41 |
+
$this->removeButton('add');
|
42 |
+
$this->removeButton('save');
|
43 |
+
$this->removeButton('edit');
|
44 |
+
//------------------------------
|
45 |
+
|
46 |
+
//------------------------------
|
47 |
+
$url = $this->getUrl('*/adminhtml_common_listing_create/index', array(
|
48 |
+
'_current' => true
|
49 |
+
));
|
50 |
+
$this->_addButton('save_and_next', array(
|
51 |
+
'label' => Mage::helper('M2ePro')->__('Next Step'),
|
52 |
+
'onclick' => 'CommonListingSettingsHandlerObj.save_click(\'' . $url . '\')',
|
53 |
+
'class' => 'next'
|
54 |
+
));
|
55 |
+
//------------------------------
|
56 |
+
}
|
57 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/StepThree.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_StepThree extends Mage_Adminhtml_Block_Widget_Form_Container
|
8 |
+
{
|
9 |
+
public function __construct($attributes)
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
$this->setData($attributes);
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId($this->getData('component').'ListingAddStepThree');
|
18 |
+
$this->_blockGroup = 'M2ePro';
|
19 |
+
$this->_controller = 'adminhtml_common_'.$this->getData('component').'_listing';
|
20 |
+
$this->_mode = 'add';
|
21 |
+
//------------------------------
|
22 |
+
|
23 |
+
// Set header text
|
24 |
+
//------------------------------
|
25 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
26 |
+
$titleConst = constant('Ess_M2ePro_Helper_Component_'.ucfirst($this->getData('component')).'::TITLE');
|
27 |
+
$componentName = Mage::helper('M2ePro')->__($titleConst);
|
28 |
+
$headerText = Mage::helper('M2ePro')
|
29 |
+
->__("Creating A New %component_name% M2E Pro Listing", $componentName);
|
30 |
+
} else {
|
31 |
+
$headerText = Mage::helper('M2ePro')->__("Creating A New M2E Pro Listing");
|
32 |
+
}
|
33 |
+
$this->_headerText = $headerText;
|
34 |
+
//------------------------------
|
35 |
+
|
36 |
+
// Set buttons actions
|
37 |
+
//------------------------------
|
38 |
+
$this->removeButton('back');
|
39 |
+
$this->removeButton('reset');
|
40 |
+
$this->removeButton('delete');
|
41 |
+
$this->removeButton('add');
|
42 |
+
$this->removeButton('save');
|
43 |
+
$this->removeButton('edit');
|
44 |
+
//------------------------------
|
45 |
+
|
46 |
+
//------------------------------
|
47 |
+
$url = $this->getUrl('*/adminhtml_common_listing_create/index', array(
|
48 |
+
'_current' => true,
|
49 |
+
'step' => '2',
|
50 |
+
'component' => $this->getData('component')
|
51 |
+
));
|
52 |
+
$this->_addButton('back', array(
|
53 |
+
'label' => Mage::helper('M2ePro')->__('Previous Step'),
|
54 |
+
'onclick' => 'CommonHandlerObj.back_click(\'' . $url . '\')',
|
55 |
+
'class' => 'back'
|
56 |
+
));
|
57 |
+
//------------------------------
|
58 |
+
|
59 |
+
//------------------------------
|
60 |
+
$url = $this->getUrl('*/adminhtml_common_listing_create/index', array(
|
61 |
+
'_current' => true
|
62 |
+
));
|
63 |
+
$this->_addButton('save_and_next', array(
|
64 |
+
'label' => Mage::helper('M2ePro')->__('Next Step'),
|
65 |
+
'onclick' => 'CommonHandlerObj.save_click(\'' . $url . '\')',
|
66 |
+
'class' => 'next'
|
67 |
+
));
|
68 |
+
//------------------------------
|
69 |
+
}
|
70 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/StepTwo.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_StepTwo extends Mage_Adminhtml_Block_Widget_Form_Container
|
8 |
+
{
|
9 |
+
public function __construct($attributes)
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
$this->setData($attributes);
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId($this->getData('component').'ListingAddStepTwo');
|
18 |
+
$this->_blockGroup = 'M2ePro';
|
19 |
+
$this->_controller = 'adminhtml_common_'.$this->getData('component').'_listing';
|
20 |
+
$this->_mode = 'add';
|
21 |
+
//------------------------------
|
22 |
+
|
23 |
+
// Set header text
|
24 |
+
//------------------------------
|
25 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
26 |
+
$titleConst = constant('Ess_M2ePro_Helper_Component_'.ucfirst($this->getData('component')).'::TITLE');
|
27 |
+
$componentName = Mage::helper('M2ePro')->__($titleConst);
|
28 |
+
$headerText = Mage::helper('M2ePro')
|
29 |
+
->__("Creating A New %component_name% M2E Pro Listing", $componentName);
|
30 |
+
} else {
|
31 |
+
$headerText = Mage::helper('M2ePro')->__("Creating A New M2E Pro Listing");
|
32 |
+
}
|
33 |
+
$this->_headerText = $headerText;
|
34 |
+
//------------------------------
|
35 |
+
|
36 |
+
// Set buttons actions
|
37 |
+
//------------------------------
|
38 |
+
$this->removeButton('back');
|
39 |
+
$this->removeButton('reset');
|
40 |
+
$this->removeButton('delete');
|
41 |
+
$this->removeButton('add');
|
42 |
+
$this->removeButton('save');
|
43 |
+
$this->removeButton('edit');
|
44 |
+
//------------------------------
|
45 |
+
|
46 |
+
//------------------------------
|
47 |
+
$url = $this->getUrl('*/adminhtml_common_listing_create/index', array(
|
48 |
+
'_current' => true,
|
49 |
+
'step' => '1',
|
50 |
+
'component' => $this->getData('component')
|
51 |
+
));
|
52 |
+
$this->_addButton('back', array(
|
53 |
+
'label' => Mage::helper('M2ePro')->__('Previous Step'),
|
54 |
+
'onclick' => ucfirst($this->getData('component')) .
|
55 |
+
'ListingChannelSettingsHandlerObj.back_click(\'' . $url . '\')',
|
56 |
+
'class' => 'back'
|
57 |
+
));
|
58 |
+
//------------------------------
|
59 |
+
|
60 |
+
//------------------------------
|
61 |
+
$url = $this->getUrl('*/adminhtml_common_listing_create/index', array(
|
62 |
+
'_current' => true
|
63 |
+
));
|
64 |
+
$this->_addButton('save_and_next', array(
|
65 |
+
'label' => Mage::helper('M2ePro')->__('Next Step'),
|
66 |
+
'onclick' => ucfirst($this->getData('component')) .
|
67 |
+
'ListingChannelSettingsHandlerObj.save_click(\'' . $url . '\')',
|
68 |
+
'class' => 'next'
|
69 |
+
));
|
70 |
+
//------------------------------
|
71 |
+
}
|
72 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/Tabs/General.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_Tabs_General extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
protected $sessionKey = 'listing_create';
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('listingAddTabsGeneral');
|
18 |
+
//------------------------------
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _beforeToHtml()
|
22 |
+
{
|
23 |
+
//------------------------------
|
24 |
+
$sessionData = Mage::helper('M2ePro/Data_Session')->getValue($this->sessionKey);
|
25 |
+
|
26 |
+
isset($sessionData['title']) && $this->setData('title',$sessionData['title']);
|
27 |
+
isset($sessionData['account_id']) && $this->setData('account_id',$sessionData['account_id']);
|
28 |
+
isset($sessionData['store_id']) && $this->setData('store_id',$sessionData['store_id']);
|
29 |
+
//------------------------------
|
30 |
+
|
31 |
+
//------------------------------
|
32 |
+
$buttonBlock = $this->getLayout()
|
33 |
+
->createBlock('adminhtml/widget_button')
|
34 |
+
->setData( array(
|
35 |
+
'label' => 'Add',
|
36 |
+
'onclick' => '',
|
37 |
+
'id' => 'add_account_button',
|
38 |
+
) );
|
39 |
+
|
40 |
+
$this->setChild('add_account_button',$buttonBlock);
|
41 |
+
//------------------------------
|
42 |
+
|
43 |
+
//------------------------------
|
44 |
+
$this->setChild(
|
45 |
+
'store_switcher',
|
46 |
+
$this->getLayout()->createBlock(
|
47 |
+
'M2ePro/adminhtml_storeSwitcher', '', array('id'=>'store_id','selected' => $this->getData('store_id'))
|
48 |
+
)
|
49 |
+
);
|
50 |
+
//------------------------------
|
51 |
+
|
52 |
+
return parent::_beforeToHtml();
|
53 |
+
}
|
54 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/Tabs/Search.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_Tabs_Search extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
protected $sessionKey = 'listing_create';
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('listingAddTabsGeneral');
|
18 |
+
//------------------------------
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _beforeToHtml()
|
22 |
+
{
|
23 |
+
//-------------------------------
|
24 |
+
$data = $this->getListingData();
|
25 |
+
|
26 |
+
$this->setData(
|
27 |
+
'general_attributes',
|
28 |
+
Mage::helper('M2ePro/Magento_Attribute')->getGeneralFromAllAttributeSets()
|
29 |
+
);
|
30 |
+
|
31 |
+
foreach ($data as $key=>$value) {
|
32 |
+
$this->setData($key, $value);
|
33 |
+
}
|
34 |
+
//-------------------------------
|
35 |
+
|
36 |
+
return parent::_beforeToHtml();
|
37 |
+
}
|
38 |
+
|
39 |
+
// #############################################
|
40 |
+
|
41 |
+
protected function getListingData()
|
42 |
+
{
|
43 |
+
if (!is_null($this->getRequest()->getParam('id'))) {
|
44 |
+
$data = $this->getListing()->getData();
|
45 |
+
} else {
|
46 |
+
$data = Mage::helper('M2ePro/Data_Session')->getValue($this->sessionKey);
|
47 |
+
$data = array_merge($this->getDefaults(), $data);
|
48 |
+
}
|
49 |
+
|
50 |
+
return $data;
|
51 |
+
}
|
52 |
+
|
53 |
+
protected function getDefaults()
|
54 |
+
{
|
55 |
+
return array();
|
56 |
+
}
|
57 |
+
|
58 |
+
protected function getListing()
|
59 |
+
{
|
60 |
+
if (!$listingId = $this->getRequest()->getParam('id')) {
|
61 |
+
throw new Exception('Listing is not defined');
|
62 |
+
}
|
63 |
+
|
64 |
+
if (is_null($this->listing)) {
|
65 |
+
$this->listing = Mage::helper('M2ePro/Component')
|
66 |
+
->getCachedUnknownObject('Listing', $listingId);
|
67 |
+
}
|
68 |
+
|
69 |
+
return $this->listing;
|
70 |
+
}
|
71 |
+
|
72 |
+
// ####################################
|
73 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Add/Tabs/Selling.php
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing_Add_Tabs_Selling extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
protected $sessionKey = 'listing_create';
|
10 |
+
protected $component = null;
|
11 |
+
protected $listing = null;
|
12 |
+
|
13 |
+
public function __construct()
|
14 |
+
{
|
15 |
+
parent::__construct();
|
16 |
+
|
17 |
+
// Initialization block
|
18 |
+
//------------------------------
|
19 |
+
$this->setId('listingAddTabsSelling');
|
20 |
+
//------------------------------
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _beforeToHtml()
|
24 |
+
{
|
25 |
+
//-------------------------------
|
26 |
+
$data = $this->getListingData();
|
27 |
+
|
28 |
+
$this->setData(
|
29 |
+
'general_attributes',
|
30 |
+
Mage::helper('M2ePro/Magento_Attribute')->getGeneralFromAllAttributeSets()
|
31 |
+
);
|
32 |
+
|
33 |
+
$this->setData(
|
34 |
+
'all_attributes',
|
35 |
+
Mage::helper('M2ePro/Magento_Attribute')->getAll()
|
36 |
+
);
|
37 |
+
|
38 |
+
foreach ($data as $key=>$value) {
|
39 |
+
$this->setData($key, $value);
|
40 |
+
}
|
41 |
+
//-------------------------------
|
42 |
+
|
43 |
+
//-------------------------------
|
44 |
+
$maxRecordsQuantity = Mage::helper('M2ePro/View_Common')->getAutocompleteMaxItems();
|
45 |
+
//-------------------------------
|
46 |
+
|
47 |
+
//----------------------------
|
48 |
+
$templates = $this->getSellingFormatTemplates();
|
49 |
+
if (count($templates) < $maxRecordsQuantity) {
|
50 |
+
$this->sellingFormatTemplatesDropDown = true;
|
51 |
+
$this->sellingFormatTemplates = $templates;
|
52 |
+
} else {
|
53 |
+
$this->sellingFormatTemplatesDropDown = false;
|
54 |
+
$this->sellingFormatTemplates = array();
|
55 |
+
}
|
56 |
+
//----------------------------
|
57 |
+
|
58 |
+
//----------------------------
|
59 |
+
$synchronizationTemplatesCollection = Mage::helper('M2ePro/Component')
|
60 |
+
->getComponentCollection($this->component, 'Template_Synchronization')
|
61 |
+
->setOrder('title', 'ASC');
|
62 |
+
|
63 |
+
if ($synchronizationTemplatesCollection->getSize() < $maxRecordsQuantity) {
|
64 |
+
$this->synchronizationsTemplatesDropDown = true;
|
65 |
+
$templates = $synchronizationTemplatesCollection->toArray();
|
66 |
+
|
67 |
+
foreach ($templates['items'] as $key => $value) {
|
68 |
+
$templates['items'][$key]['title'] = Mage::helper('M2ePro')
|
69 |
+
->escapeHtml($templates['items'][$key]['title']);
|
70 |
+
}
|
71 |
+
|
72 |
+
$this->synchronizationsTemplates = $templates['items'];
|
73 |
+
} else {
|
74 |
+
$this->synchronizationsTemplatesDropDown = false;
|
75 |
+
$this->synchronizationsTemplates = array();
|
76 |
+
}
|
77 |
+
//----------------------------
|
78 |
+
|
79 |
+
return parent::_beforeToHtml();
|
80 |
+
}
|
81 |
+
|
82 |
+
protected function getSellingFormatTemplates()
|
83 |
+
{
|
84 |
+
$collection = Mage::getModel('M2ePro/Template_SellingFormat')->getCollection();
|
85 |
+
$collection->addFieldToFilter('component_mode', $this->component);
|
86 |
+
|
87 |
+
$collection->getSelect()->reset(Zend_Db_Select::COLUMNS)
|
88 |
+
->columns(array('id', 'title'));
|
89 |
+
|
90 |
+
$collection->setOrder('main_table.title', 'ASC');
|
91 |
+
|
92 |
+
$data = $collection->toArray();
|
93 |
+
|
94 |
+
foreach ($data['items'] as $key => $value) {
|
95 |
+
$data['items'][$key]['title'] = Mage::helper('M2ePro')->escapeHtml($data['items'][$key]['title']);
|
96 |
+
}
|
97 |
+
|
98 |
+
return $data['items'];
|
99 |
+
}
|
100 |
+
|
101 |
+
// #############################################
|
102 |
+
|
103 |
+
protected function getListingData()
|
104 |
+
{
|
105 |
+
if (!is_null($this->getRequest()->getParam('id'))) {
|
106 |
+
$data = $this->getListing()->getData();
|
107 |
+
} else {
|
108 |
+
$data = Mage::helper('M2ePro/Data_Session')->getValue($this->sessionKey);
|
109 |
+
$data = array_merge($this->getDefaults(), $data);
|
110 |
+
}
|
111 |
+
|
112 |
+
return $data;
|
113 |
+
}
|
114 |
+
|
115 |
+
// ####################################
|
116 |
+
|
117 |
+
protected function getDefaults()
|
118 |
+
{
|
119 |
+
return array();
|
120 |
+
}
|
121 |
+
|
122 |
+
// ####################################
|
123 |
+
|
124 |
+
protected function getListing()
|
125 |
+
{
|
126 |
+
if (!$listingId = $this->getRequest()->getParam('id')) {
|
127 |
+
throw new Exception('Listing is not defined');
|
128 |
+
}
|
129 |
+
|
130 |
+
if (is_null($this->listing)) {
|
131 |
+
$this->listing = Mage::helper('M2ePro/Component')
|
132 |
+
->getCachedUnknownObject('Listing', $listingId);
|
133 |
+
}
|
134 |
+
|
135 |
+
return $this->listing;
|
136 |
+
}
|
137 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Breadcrumb.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2011 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing_Breadcrumb extends Mage_Adminhtml_Block_Template
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('commonListingBreadcrumb');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/listing/breadcrumb.phtml');
|
19 |
+
}
|
20 |
+
|
21 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Category/Tree.php
ADDED
@@ -0,0 +1,379 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing_Category_Tree extends Mage_Adminhtml_Block_Catalog_Category_Abstract
|
8 |
+
{
|
9 |
+
// #############################################
|
10 |
+
|
11 |
+
protected $listing;
|
12 |
+
|
13 |
+
protected $selectedIds = array();
|
14 |
+
|
15 |
+
/* @var string */
|
16 |
+
protected $gridId = NULL;
|
17 |
+
|
18 |
+
/* @var Varien_Data_Tree_Node */
|
19 |
+
protected $currentNode = NULL;
|
20 |
+
|
21 |
+
// #############################################
|
22 |
+
|
23 |
+
public function setSelectedIds(array $ids)
|
24 |
+
{
|
25 |
+
$this->selectedIds = $ids;
|
26 |
+
return $this;
|
27 |
+
}
|
28 |
+
|
29 |
+
public function getSelectedIds()
|
30 |
+
{
|
31 |
+
return $this->selectedIds;
|
32 |
+
}
|
33 |
+
|
34 |
+
public function setCurrentNodeById($categoryId)
|
35 |
+
{
|
36 |
+
$category = Mage::getModel('catalog/category')->load($categoryId);
|
37 |
+
$node = $this->getRoot($category, 1)->getTree()->getNodeById($categoryId);
|
38 |
+
return $this->setCurrentNode($node);
|
39 |
+
}
|
40 |
+
|
41 |
+
public function setCurrentNode(Varien_Data_Tree_Node $currentNode)
|
42 |
+
{
|
43 |
+
$this->currentNode = $currentNode;
|
44 |
+
return $this;
|
45 |
+
}
|
46 |
+
|
47 |
+
public function getCurrentNode()
|
48 |
+
{
|
49 |
+
return $this->currentNode;
|
50 |
+
}
|
51 |
+
|
52 |
+
public function getCurrentNodeId()
|
53 |
+
{
|
54 |
+
return $this->currentNode ? $this->currentNode->getId() : NULL;
|
55 |
+
}
|
56 |
+
|
57 |
+
// #############################################
|
58 |
+
|
59 |
+
public function setGridId($gridId)
|
60 |
+
{
|
61 |
+
$this->gridId = $gridId;
|
62 |
+
return $this;
|
63 |
+
}
|
64 |
+
|
65 |
+
public function getGridId()
|
66 |
+
{
|
67 |
+
return $this->gridId;
|
68 |
+
}
|
69 |
+
|
70 |
+
// #############################################
|
71 |
+
|
72 |
+
public function getLoadTreeUrl()
|
73 |
+
{
|
74 |
+
return $this->getUrl('*/*/getCategoriesJson', array('_current'=>true));
|
75 |
+
}
|
76 |
+
|
77 |
+
// #############################################
|
78 |
+
|
79 |
+
public function getCategoryCollection()
|
80 |
+
{
|
81 |
+
$collection = $this->getData('category_collection');
|
82 |
+
|
83 |
+
if (!$collection) {
|
84 |
+
$collection = Mage::getModel('catalog/category')
|
85 |
+
->getCollection()
|
86 |
+
->addAttributeToSelect('name')
|
87 |
+
->addAttributeToSelect('is_active');
|
88 |
+
|
89 |
+
$this->loadProductsCount($collection);
|
90 |
+
|
91 |
+
$this->setData('category_collection', $collection);
|
92 |
+
}
|
93 |
+
|
94 |
+
return $collection;
|
95 |
+
}
|
96 |
+
|
97 |
+
// #############################################
|
98 |
+
|
99 |
+
public function __construct()
|
100 |
+
{
|
101 |
+
parent::__construct();
|
102 |
+
|
103 |
+
// Initialization block
|
104 |
+
//------------------------------
|
105 |
+
$this->setId('listingCategoryTree');
|
106 |
+
//------------------------------
|
107 |
+
|
108 |
+
$this->setTemplate('M2ePro/common/listing/category/tree.phtml');
|
109 |
+
|
110 |
+
$this->_isAjax = $this->getRequest()->isXmlHttpRequest();
|
111 |
+
}
|
112 |
+
|
113 |
+
// #############################################
|
114 |
+
|
115 |
+
public function getTreeJson($parentNodeCategory=null)
|
116 |
+
{
|
117 |
+
$rootArray = $this->_getNodeJson($this->getRoot($parentNodeCategory));
|
118 |
+
$json = Zend_Json::encode(isset($rootArray['children']) ? $rootArray['children'] : array());
|
119 |
+
return $json;
|
120 |
+
}
|
121 |
+
|
122 |
+
// #############################################
|
123 |
+
|
124 |
+
protected function _getNodeJson($node, $level = 0)
|
125 |
+
{
|
126 |
+
// create a node from data array
|
127 |
+
if (is_array($node)) {
|
128 |
+
$node = new Varien_Data_Tree_Node($node, 'entity_id', new Varien_Data_Tree);
|
129 |
+
}
|
130 |
+
|
131 |
+
$item = array();
|
132 |
+
$item['text'] = $this->buildNodeName($node);
|
133 |
+
$item['id'] = $node->getId();
|
134 |
+
$item['cls'] = 'folder ' . ($node->getIsActive() ? 'active-category' : 'no-active-category');
|
135 |
+
$item['path'] = $node->getData('path');
|
136 |
+
$item['allowDrop'] = false;
|
137 |
+
$item['allowDrag'] = false;
|
138 |
+
|
139 |
+
$isParent = $this->_isParentSelectedCategory($node);
|
140 |
+
|
141 |
+
if ((int)$node->getChildrenCount() > 0) {
|
142 |
+
$item['children'] = array();
|
143 |
+
}
|
144 |
+
|
145 |
+
if ($node->hasChildren()) {
|
146 |
+
|
147 |
+
$item['children'] = array();
|
148 |
+
|
149 |
+
if (!($node->getLevel() > 1 && !$isParent)) {
|
150 |
+
foreach ($node->getChildren() as $child) {
|
151 |
+
$item['children'][] = $this->_getNodeJson($child, $level+1);
|
152 |
+
}
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
if ($isParent || $node->getLevel() < 2) {
|
157 |
+
$item['expanded'] = true;
|
158 |
+
}
|
159 |
+
|
160 |
+
return $item;
|
161 |
+
}
|
162 |
+
|
163 |
+
protected function _isParentSelectedCategory($node)
|
164 |
+
{
|
165 |
+
if ($node && $this->getCurrentNode()) {
|
166 |
+
$pathIds = explode('/', $this->getCurrentNode()->getData('path'));
|
167 |
+
if (in_array($node->getId(), $pathIds)) {
|
168 |
+
return true;
|
169 |
+
}
|
170 |
+
}
|
171 |
+
|
172 |
+
return false;
|
173 |
+
}
|
174 |
+
|
175 |
+
// #############################################
|
176 |
+
|
177 |
+
public function buildNodeName($node)
|
178 |
+
{
|
179 |
+
$treeSettings = $this->getData('tree_settings');
|
180 |
+
$result = $this->escapeHtml($node->getName());
|
181 |
+
|
182 |
+
$ccpTable = Mage::getSingleton('core/resource')->getTableName('catalog_category_product');
|
183 |
+
$cpeTable = Mage::getSingleton('core/resource')->getTableName('catalog_product_entity');
|
184 |
+
|
185 |
+
$dbSelect = $this->getReadConnection()
|
186 |
+
->select()
|
187 |
+
->from(array('ccp'=>$ccpTable),new Zend_Db_Expr('DISTINCT `ccp`.`product_id`'))
|
188 |
+
->join(array('cpe'=>$cpeTable),'`cpe`.`entity_id` = `ccp`.`product_id`',array())
|
189 |
+
->where('`ccp`.`category_id` = ?',(int)$node->getId());
|
190 |
+
|
191 |
+
//----------------------------
|
192 |
+
if ($treeSettings['show_products_amount'] != false) {
|
193 |
+
if ($treeSettings['hide_products_this_listing']) {
|
194 |
+
$fields = new Zend_Db_Expr('DISTINCT `product_id`');
|
195 |
+
$dbSelect3 = $this->getReadConnection()
|
196 |
+
->select()
|
197 |
+
->from(Mage::getResourceModel('M2ePro/Listing_Product')->getMainTable(),$fields)
|
198 |
+
->where('`component_mode` = ?',$this->getData('component'))
|
199 |
+
->where('`listing_id` = ?', $this->getRequest()->getParam('id'));
|
200 |
+
|
201 |
+
$dbSelect->where('`ccp`.`product_id` NOT IN ('.$dbSelect3->__toString().')');
|
202 |
+
}
|
203 |
+
$sqlQuery = " SELECT count(`rez`.`product_id`) as `count_products`
|
204 |
+
FROM ( ".$dbSelect->__toString()." ) as `rez` ";
|
205 |
+
|
206 |
+
$countProducts = $this->getReadConnection()
|
207 |
+
->fetchOne($sqlQuery);
|
208 |
+
|
209 |
+
$helper = Mage::helper('M2ePro');
|
210 |
+
$result .= <<<HTML
|
211 |
+
<span category_id="{$node->getId()}">(0</span>{$helper->__('of')} {$countProducts})
|
212 |
+
HTML;
|
213 |
+
}
|
214 |
+
//----------------------------
|
215 |
+
|
216 |
+
return $result;
|
217 |
+
|
218 |
+
}
|
219 |
+
|
220 |
+
// #############################################
|
221 |
+
|
222 |
+
public function getCategoryChildrenJson($categoryId)
|
223 |
+
{
|
224 |
+
$this->setCurrentNodeById($categoryId);
|
225 |
+
return $this->getTreeJson(Mage::getModel('catalog/category')->load($categoryId));
|
226 |
+
}
|
227 |
+
|
228 |
+
// #############################################
|
229 |
+
|
230 |
+
public function getAffectedCategoriesCount()
|
231 |
+
{
|
232 |
+
if (!is_null($this->getData('affected_categories_count'))) {
|
233 |
+
return $this->getData('affected_categories_count');
|
234 |
+
}
|
235 |
+
|
236 |
+
$dbSelect = Mage::getResourceModel('core/config')->getReadConnection()
|
237 |
+
->select()
|
238 |
+
->from(Mage::getSingleton('core/resource')->getTableName('catalog/category_product'),
|
239 |
+
'category_id')
|
240 |
+
->where('`product_id` IN(?)',$this->getSelectedIds());
|
241 |
+
|
242 |
+
$affectedCategoriesCount = Mage::getModel('catalog/category')->getCollection()
|
243 |
+
->getSelectCountSql()
|
244 |
+
->where('entity_id IN ('.$dbSelect->__toString().')')
|
245 |
+
->query()
|
246 |
+
->fetchColumn();
|
247 |
+
|
248 |
+
$this->setData('affected_categories_count', (int)$affectedCategoriesCount);
|
249 |
+
|
250 |
+
return $this->getData('affected_categories_count');
|
251 |
+
}
|
252 |
+
|
253 |
+
// #############################################
|
254 |
+
|
255 |
+
public function getProductsForEachCategory()
|
256 |
+
{
|
257 |
+
if (!is_null($this->getData('products_for_each_category'))) {
|
258 |
+
return $this->getData('products_for_each_category');
|
259 |
+
}
|
260 |
+
|
261 |
+
$ids = array_map('intval',$this->selectedIds);
|
262 |
+
$ids = implode(',',$ids);
|
263 |
+
!$ids && $ids = 0;
|
264 |
+
|
265 |
+
/* @var $select Varien_Db_Select */
|
266 |
+
$select = Mage::getModel('catalog/category')->getCollection()->getSelect();
|
267 |
+
$select->joinLeft(
|
268 |
+
Mage::getSingleton('core/resource')->getTableName('catalog/category_product'),
|
269 |
+
"entity_id = category_id AND product_id IN ({$ids})",
|
270 |
+
array('product_id')
|
271 |
+
);
|
272 |
+
|
273 |
+
$productsForEachCategory = array();
|
274 |
+
foreach ($select->query() as $row) {
|
275 |
+
if (!isset($productsForEachCategory[$row['entity_id']])) {
|
276 |
+
$productsForEachCategory[$row['entity_id']] = array();
|
277 |
+
}
|
278 |
+
$row['product_id'] && $productsForEachCategory[$row['entity_id']][] = $row['product_id'];
|
279 |
+
}
|
280 |
+
|
281 |
+
$this->setData('products_for_each_category', $productsForEachCategory);
|
282 |
+
|
283 |
+
return $this->getData('products_for_each_category');
|
284 |
+
}
|
285 |
+
|
286 |
+
public function getProductsCountForEachCategory()
|
287 |
+
{
|
288 |
+
if (!is_null($this->getData('products_count_for_each_category'))) {
|
289 |
+
return $this->getData('products_count_for_each_category');
|
290 |
+
}
|
291 |
+
|
292 |
+
$productsCountForEachCategory = $this->getProductsForEachCategory();
|
293 |
+
$productsCountForEachCategory = array_map('count',$productsCountForEachCategory);
|
294 |
+
|
295 |
+
$this->setData('products_count_for_each_category', $productsCountForEachCategory);
|
296 |
+
|
297 |
+
return $this->getData('products_count_for_each_category');
|
298 |
+
}
|
299 |
+
|
300 |
+
// #############################################
|
301 |
+
|
302 |
+
public function getInfoJson()
|
303 |
+
{
|
304 |
+
return json_encode(array(
|
305 |
+
'category_products' => $this->getProductsCountForEachCategory(),
|
306 |
+
'total_products_count' => count($this->getSelectedIds()),
|
307 |
+
'total_categories_count' => $this->getAffectedCategoriesCount()
|
308 |
+
));
|
309 |
+
}
|
310 |
+
|
311 |
+
// #############################################
|
312 |
+
|
313 |
+
protected function loadProductsCount($collection)
|
314 |
+
{
|
315 |
+
$items = $collection->getItems();
|
316 |
+
|
317 |
+
if (!$items) {
|
318 |
+
return;
|
319 |
+
}
|
320 |
+
|
321 |
+
$readConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
322 |
+
|
323 |
+
//----------------------------
|
324 |
+
$excludeProductsSelect = $readConnection->select()->from(
|
325 |
+
Mage::getResourceModel('M2ePro/Listing_Product')->getMainTable(),
|
326 |
+
new Zend_Db_Expr('DISTINCT `product_id`')
|
327 |
+
);
|
328 |
+
|
329 |
+
$excludeProductsSelect->where('`listing_id` = ?',(int)$this->getRequest()->getParam('id'));
|
330 |
+
|
331 |
+
$select = $readConnection->select();
|
332 |
+
$select->from(
|
333 |
+
array('main_table' => $collection->getTable('catalog/category_product')),
|
334 |
+
array('category_id', new Zend_Db_Expr('COUNT(main_table.product_id)'))
|
335 |
+
)
|
336 |
+
->where($readConnection->quoteInto('main_table.category_id IN(?)', array_keys($items)))
|
337 |
+
->where('main_table.product_id NOT IN ('.$excludeProductsSelect.')')
|
338 |
+
->group('main_table.category_id');
|
339 |
+
|
340 |
+
$counts = $readConnection->fetchPairs($select);
|
341 |
+
|
342 |
+
foreach ($items as $item) {
|
343 |
+
if (isset($counts[$item->getId()])) {
|
344 |
+
$item->setProductCount($counts[$item->getId()]);
|
345 |
+
} else {
|
346 |
+
$item->setProductCount(0);
|
347 |
+
}
|
348 |
+
}
|
349 |
+
}
|
350 |
+
|
351 |
+
// #############################################
|
352 |
+
|
353 |
+
private function getListing()
|
354 |
+
{
|
355 |
+
if (!$listingId = $this->getRequest()->getParam('id')) {
|
356 |
+
throw new Exception('Listing is not defined');
|
357 |
+
}
|
358 |
+
|
359 |
+
if (is_null($this->listing)) {
|
360 |
+
$this->listing = Mage::helper('M2ePro/Component_' . ucfirst($this->getData('component')))
|
361 |
+
->getCachedObject('Listing',$listingId)->getChildObject();
|
362 |
+
}
|
363 |
+
|
364 |
+
return $this->listing;
|
365 |
+
}
|
366 |
+
|
367 |
+
// ####################################
|
368 |
+
|
369 |
+
private function getReadConnection()
|
370 |
+
{
|
371 |
+
if (is_null($this->readConnection)) {
|
372 |
+
$this->readConnection = Mage::getResourceModel('core/config')->getReadConnection();
|
373 |
+
}
|
374 |
+
|
375 |
+
return $this->readConnection;
|
376 |
+
}
|
377 |
+
|
378 |
+
// ####################################
|
379 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Help.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing_Help extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
$this->setTemplate('M2ePro/common/listing/help.phtml');
|
13 |
+
}
|
14 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Log.php
ADDED
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing_Log extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
// ########################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('listingLog');
|
18 |
+
$this->_blockGroup = 'M2ePro';
|
19 |
+
$this->_controller = 'adminhtml_common_listing_log';
|
20 |
+
//------------------------------
|
21 |
+
|
22 |
+
//------------------------------
|
23 |
+
$this->setTemplate('M2ePro/common/log/log.phtml');
|
24 |
+
//------------------------------
|
25 |
+
|
26 |
+
// Set buttons actions
|
27 |
+
//------------------------------
|
28 |
+
$this->removeButton('back');
|
29 |
+
$this->removeButton('reset');
|
30 |
+
$this->removeButton('delete');
|
31 |
+
$this->removeButton('add');
|
32 |
+
$this->removeButton('save');
|
33 |
+
$this->removeButton('edit');
|
34 |
+
|
35 |
+
if (!is_null($this->getRequest()->getParam('back'))) {
|
36 |
+
//------------------------------
|
37 |
+
$url = Mage::helper('M2ePro')->getBackUrl('*/adminhtml_common_listing/index');
|
38 |
+
$this->_addButton('back', array(
|
39 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
40 |
+
'onclick' => 'CommonHandlerObj.back_click(\''.$url.'\')',
|
41 |
+
'class' => 'back'
|
42 |
+
));
|
43 |
+
//------------------------------
|
44 |
+
}
|
45 |
+
|
46 |
+
//------------------------------
|
47 |
+
$this->_addButton('goto_listings', array(
|
48 |
+
'label' => Mage::helper('M2ePro')->__('Listings'),
|
49 |
+
'onclick' => 'setLocation(\'' .$this->getUrl('*/adminhtml_common_listing/index').'\')',
|
50 |
+
'class' => 'button_link'
|
51 |
+
));
|
52 |
+
//------------------------------
|
53 |
+
|
54 |
+
//------------------------------
|
55 |
+
if (isset($listingData['id'])) {
|
56 |
+
//------------------------------
|
57 |
+
$url = Mage::helper('M2ePro/View')->getUrl(
|
58 |
+
new Varien_Object($listingData), 'listing', 'edit', array('id' => $listingData['id'])
|
59 |
+
);
|
60 |
+
$this->_addButton('goto_listing_settings', array(
|
61 |
+
'label' => Mage::helper('M2ePro')->__('Listing Settings'),
|
62 |
+
'onclick' => 'setLocation(\'' .$url.'\')',
|
63 |
+
'class' => 'button_link'
|
64 |
+
));
|
65 |
+
//------------------------------
|
66 |
+
|
67 |
+
//------------------------------
|
68 |
+
$url = Mage::helper('M2ePro/View')->getUrl(
|
69 |
+
new Varien_Object($listingData), 'listing', 'view', array('id' => $listingData['id'])
|
70 |
+
);
|
71 |
+
$this->_addButton('goto_listing_items', array(
|
72 |
+
'label' => Mage::helper('M2ePro')->__('Listing Items'),
|
73 |
+
'onclick' => 'setLocation(\'' .$url.'\')',
|
74 |
+
'class' => 'button_link'
|
75 |
+
));
|
76 |
+
//------------------------------
|
77 |
+
}
|
78 |
+
|
79 |
+
if (isset($listingData['id'])) {
|
80 |
+
//------------------------------
|
81 |
+
$url = $this->getUrl('*/*/*');
|
82 |
+
$this->_addButton('show_general_log', array(
|
83 |
+
'label' => Mage::helper('M2ePro')->__('Show General Log'),
|
84 |
+
'onclick' => 'setLocation(\'' . $url .'\')',
|
85 |
+
'class' => 'show_general_log'
|
86 |
+
));
|
87 |
+
//------------------------------
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
// ########################################
|
92 |
+
|
93 |
+
public function getListingId()
|
94 |
+
{
|
95 |
+
return $this->getRequest()->getParam('id', false);
|
96 |
+
}
|
97 |
+
|
98 |
+
// ----------------------------------------
|
99 |
+
|
100 |
+
/** @var Ess_M2ePro_Model_Listing $listing */
|
101 |
+
protected $listing = NULL;
|
102 |
+
|
103 |
+
/**
|
104 |
+
* @return Ess_M2ePro_Model_Listing|null
|
105 |
+
*/
|
106 |
+
public function getListing()
|
107 |
+
{
|
108 |
+
if (is_null($this->listing)) {
|
109 |
+
$this->listing = Mage::helper('M2ePro/Component')
|
110 |
+
->getCachedUnknownObject('Listing', $this->getListingId());
|
111 |
+
}
|
112 |
+
|
113 |
+
return $this->listing;
|
114 |
+
}
|
115 |
+
|
116 |
+
// ########################################
|
117 |
+
|
118 |
+
public function getListingProductId()
|
119 |
+
{
|
120 |
+
return $this->getRequest()->getParam('listing_product_id', false);
|
121 |
+
}
|
122 |
+
|
123 |
+
// ----------------------------------------
|
124 |
+
|
125 |
+
/** @var Ess_M2ePro_Model_Listing_Product $listingProduct */
|
126 |
+
protected $listingProduct = NULL;
|
127 |
+
|
128 |
+
/**
|
129 |
+
* @return Ess_M2ePro_Model_Listing_Product|null
|
130 |
+
*/
|
131 |
+
public function getListingProduct()
|
132 |
+
{
|
133 |
+
if (is_null($this->listingProduct)) {
|
134 |
+
$this->listingProduct = Mage::helper('M2ePro/Component')
|
135 |
+
->getUnknownObject('Listing_Product', $this->getListingProductId());
|
136 |
+
}
|
137 |
+
|
138 |
+
return $this->listingProduct;
|
139 |
+
}
|
140 |
+
|
141 |
+
// ########################################
|
142 |
+
|
143 |
+
protected function _beforeToHtml()
|
144 |
+
{
|
145 |
+
// Set header text
|
146 |
+
//------------------------------
|
147 |
+
$this->_headerText = '';
|
148 |
+
|
149 |
+
if ($this->getListingId()) {
|
150 |
+
|
151 |
+
$listing = $this->getListing();
|
152 |
+
|
153 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
154 |
+
$component = Mage::helper('M2ePro/Component')->getComponentTitle($listing->getComponentMode());
|
155 |
+
$this->_headerText = Mage::helper('M2ePro')->__(
|
156 |
+
'Log For %component_name% Listing "%listing_title%"',
|
157 |
+
$component, $this->escapeHtml($listing->getTitle())
|
158 |
+
);
|
159 |
+
} else {
|
160 |
+
$this->_headerText = Mage::helper('M2ePro')->__(
|
161 |
+
'Log For Listing "%listing_title%"',
|
162 |
+
$this->escapeHtml($listing->getTitle())
|
163 |
+
);
|
164 |
+
}
|
165 |
+
|
166 |
+
} else if ($this->getListingProductId()) {
|
167 |
+
|
168 |
+
$listingProduct = $this->getListingProduct();
|
169 |
+
$listing = $listingProduct->getListing();
|
170 |
+
|
171 |
+
$onlineTitle = $listingProduct->getOnlineTitle();
|
172 |
+
if (empty($onlineTitle)) {
|
173 |
+
$onlineTitle = $listingProduct->getMagentoProduct()->getName();
|
174 |
+
}
|
175 |
+
|
176 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
177 |
+
$component = Mage::helper('M2ePro/Component')->getComponentTitle($listing->getComponentMode());
|
178 |
+
$this->_headerText = Mage::helper('M2ePro')->__(
|
179 |
+
'Log For Product "%product_name%" (ID:%product_id%) Of %component_name% Listing "%listing_title%"',
|
180 |
+
$this->escapeHtml($onlineTitle),
|
181 |
+
$listingProduct->getProductId(),
|
182 |
+
$component,
|
183 |
+
$this->escapeHtml($listing->getTitle())
|
184 |
+
);
|
185 |
+
} else {
|
186 |
+
$this->_headerText = Mage::helper('M2ePro')->__(
|
187 |
+
'Log For Product "%product_name%" (ID:%product_id%) Of Listing "%listing_title%"',
|
188 |
+
$this->escapeHtml($onlineTitle),
|
189 |
+
$listingProduct->getProductId(),
|
190 |
+
$this->escapeHtml($listing->getTitle())
|
191 |
+
);
|
192 |
+
}
|
193 |
+
|
194 |
+
} else {
|
195 |
+
$this->_headerText = Mage::helper('M2ePro')->__('Listings Log');
|
196 |
+
}
|
197 |
+
//------------------------------
|
198 |
+
}
|
199 |
+
|
200 |
+
// ########################################
|
201 |
+
|
202 |
+
protected function _toHtml()
|
203 |
+
{
|
204 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_listing_log_help')->toHtml();
|
205 |
+
|
206 |
+
$logBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_log_tabs', '',
|
207 |
+
array(
|
208 |
+
'channel' => $this->getRequest()->getParam('channel'),
|
209 |
+
'log_type' => Ess_M2ePro_Block_Adminhtml_Common_Log_Tabs::LOG_TYPE_ID_LISTING
|
210 |
+
)
|
211 |
+
)->toHtml();
|
212 |
+
|
213 |
+
$translations = json_encode(array(
|
214 |
+
'Description' => Mage::helper('M2ePro')->__('Description')
|
215 |
+
));
|
216 |
+
|
217 |
+
$hideTabs = '';
|
218 |
+
if ($this->getListingId() || $this->getListingProductId()) {
|
219 |
+
$hideTabs = '$("commonLogTabs").hide();';
|
220 |
+
}
|
221 |
+
|
222 |
+
$javascript = <<<JAVASCIRPT
|
223 |
+
|
224 |
+
<script type="text/javascript">
|
225 |
+
|
226 |
+
M2ePro.translator.add({$translations});
|
227 |
+
|
228 |
+
Event.observe(window, 'load', function() {
|
229 |
+
LogHandlerObj = new LogHandler();
|
230 |
+
{$hideTabs}
|
231 |
+
});
|
232 |
+
|
233 |
+
</script>
|
234 |
+
|
235 |
+
JAVASCIRPT;
|
236 |
+
|
237 |
+
return $javascript . parent::_toHtml() . $helpBlock . $logBlock;
|
238 |
+
}
|
239 |
+
|
240 |
+
// ########################################
|
241 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Log/Grid.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing_Log_Grid extends Ess_M2ePro_Block_Adminhtml_Listing_Log_Grid
|
8 |
+
{
|
9 |
+
// ########################################
|
10 |
+
|
11 |
+
protected function getActionTitles()
|
12 |
+
{
|
13 |
+
$allActions = Mage::getModel('M2ePro/Listing_Log')->getActionsTitles();
|
14 |
+
|
15 |
+
$excludeActions = array(
|
16 |
+
Ess_M2ePro_Model_Listing_Log::ACTION_TRANSLATE_PRODUCT => ''
|
17 |
+
);
|
18 |
+
|
19 |
+
if ($this->getChannel() != Ess_M2ePro_Helper_Component_Buy::NICK) {
|
20 |
+
$excludeActions[Ess_M2ePro_Model_Listing_Log::ACTION_NEW_SKU_PRODUCT_ON_COMPONENT] = '';
|
21 |
+
}
|
22 |
+
|
23 |
+
return array_diff_key($allActions, $excludeActions);
|
24 |
+
}
|
25 |
+
|
26 |
+
// ########################################
|
27 |
+
|
28 |
+
public function callbackColumnListingTitleID($value, $row, $column, $isExport)
|
29 |
+
{
|
30 |
+
if (strlen($value) > 50) {
|
31 |
+
$value = substr($value, 0, 50) . '...';
|
32 |
+
}
|
33 |
+
|
34 |
+
$value = Mage::helper('M2ePro')->escapeHtml($value);
|
35 |
+
|
36 |
+
if ($row->getData('listing_id')) {
|
37 |
+
$url = $this->getUrl(
|
38 |
+
'*/adminhtml_common_'.$row->getData('component_mode').'_listing/view',
|
39 |
+
array('id' => $row->getData('listing_id'))
|
40 |
+
);
|
41 |
+
|
42 |
+
$value = '<a target="_blank" href="'.$url.'">' .
|
43 |
+
Mage::helper('M2ePro')->escapeHtml($value) .
|
44 |
+
'</a><br/>ID: '.$row->getData('listing_id');
|
45 |
+
}
|
46 |
+
|
47 |
+
return $value;
|
48 |
+
}
|
49 |
+
|
50 |
+
// ########################################
|
51 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Log/Help.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing_Log_Help extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('commonListingLogHelp');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/
|