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, 7 Amazon and 2 Rakuten (USA, UK) marketplaces. It supports multiple eBay/Amazon/Rakuten accounts and multiple Magento stores.
Download this release
Release Info
Developer | Magento Core Team |
Extension | m2epro_ebay_magento |
Version | 6.2.4.1 |
Comparing to | |
See all releases |
Code changes from version 1.0.3 to 6.2.4.1
- app/code/community/Ess/M2ePro/Block/Adminhtml/Account/Grid.php +144 -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 +63 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Account/Grid.php +49 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Account/Edit.php +139 -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 +54 -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 +157 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/StepFive.php +90 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/StepFourCategory.php +127 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/StepFourProduct.php +90 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/StepOne.php +74 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/StepThree.php +70 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/StepTwo.php +70 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Category.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Category/Help.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Edit.php +100 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Edit/Form.php +75 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Edit/Tabs.php +52 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Edit/Tabs/ChannelSettings.php +38 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Edit/Tabs/General.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Edit/Tabs/ProductsFilter.php +53 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Edit/Tabs/Settings.php +146 -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 +334 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Other/Grid.php +566 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Other/Help.php +25 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Product.php +105 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Product/Category.php +150 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Product/Category/Edit.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Product/Category/Help.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Product/Grid.php +605 -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 +280 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/ProductSearch/Main.php +60 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/ProductSearch/Menu.php +30 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Search.php +158 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Search/Grid.php +507 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Tutorial.php +41 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View.php +572 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View/Grid.php +1051 -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/Marketplace/Form.php +85 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Order/Edit/ShippingAddress.php +73 -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/Help.php +20 -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/Synchronization/Help.php +14 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/NewProduct.php +95 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/NewProduct/Edit.php +106 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/NewProduct/Edit/Form.php +32 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/NewProduct/Edit/Tabs.php +52 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/NewProduct/Edit/Tabs/Description.php +104 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/NewProduct/Edit/Tabs/General.php +183 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/NewProduct/Edit/Tabs/Specifics.php +21 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/NewProduct/Grid.php +287 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/NewProduct/Help.php +25 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/NewProduct/Search/Grid.php +155 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/SellingFormat/Edit.php +109 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/SellingFormat/Edit/Form.php +87 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/Synchronization/Edit.php +114 -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 +146 -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 +164 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Add/StepFive.php +90 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Add/StepFourCategory.php +128 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Add/StepFourProduct.php +90 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Add/StepOne.php +74 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Add/StepThree.php +73 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Add/StepTwo.php +69 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Category.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Category/Help.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Edit.php +98 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Edit/Form.php +72 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Edit/Tabs.php +52 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Edit/Tabs/ChannelSettings.php +38 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Edit/Tabs/General.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Edit/Tabs/ProductsFilter.php +53 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Edit/Tabs/Settings.php +146 -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 +334 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Other/Grid.php +529 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Other/Help.php +25 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Product.php +104 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Product/Category.php +143 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Product/Category/Edit.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Product/Category/Help.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Product/Grid.php +603 -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 +60 -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 +168 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Search/Grid.php +446 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Tutorial.php +41 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/View.php +560 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/View/Grid.php +980 -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/Order/Edit/ShippingAddress.php +73 -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/Help.php +20 -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/Synchronization/Help.php +14 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct.php +85 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Edit.php +93 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Edit/Form.php +103 -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 +71 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Edit/Tabs/General.php +177 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Grid.php +254 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Help.php +25 -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 +109 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/SellingFormat/Edit/Form.php +83 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/Synchronization/Edit.php +110 -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 +295 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Category/Tree.php +155 -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 +147 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Log/Grid.php +38 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Log/Help.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Other.php +710 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Other/Log.php +126 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Other/Log/Grid.php +40 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Other/Log/Help.php +14 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Product/Variation.php +152 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Product/Variation/Edit.php +78 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Product/Variation/Manage.php +95 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Search.php +138 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Search/Grid.php +334 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Search/Help.php +14 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Marketplace.php +214 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Marketplace/General/Form.php +38 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Marketplace/Help.php +18 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Order.php +217 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Order/Log.php +93 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Order/Log/Help.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Account/Edit.php +141 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Account/Edit/Form.php +33 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Account/Edit/Tabs.php +52 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Account/Edit/Tabs/General.php +65 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Account/Edit/Tabs/ListingOther.php +27 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Account/Edit/Tabs/Order.php +85 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing.php +164 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Add/StepFive.php +91 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Add/StepFourCategory.php +127 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Add/StepFourProduct.php +90 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Add/StepOne.php +74 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Add/StepThree.php +69 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Add/StepTwo.php +69 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Category.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Category/Help.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Edit.php +98 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Edit/Form.php +72 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Edit/Tabs.php +52 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Edit/Tabs/ChannelSettings.php +38 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Edit/Tabs/General.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Edit/Tabs/ProductsFilter.php +53 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Edit/Tabs/Settings.php +146 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Filter.php +116 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Grid.php +335 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Other/Grid.php +543 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Other/Help.php +25 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Product.php +105 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Product/Category.php +144 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Product/Category/Edit.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Product/Category/Help.php +20 -0
- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Product/Grid.php +369 -0
app/code/community/Ess/M2ePro/Block/Adminhtml/Account/Grid.php
ADDED
@@ -0,0 +1,144 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 = Mage::getModel('M2ePro/Account')->getCollection();
|
43 |
+
|
44 |
+
$components = $this->viewComponentHelper->getActiveComponents();
|
45 |
+
$collection->addFieldToFilter('main_table.component_mode', array('in'=>$components));
|
46 |
+
|
47 |
+
// Set collection to grid
|
48 |
+
$this->setCollection($collection);
|
49 |
+
|
50 |
+
return parent::_prepareCollection();
|
51 |
+
}
|
52 |
+
|
53 |
+
protected function _prepareColumns()
|
54 |
+
{
|
55 |
+
$this->addColumn('create_date', array(
|
56 |
+
'header' => Mage::helper('M2ePro')->__('Creation Date'),
|
57 |
+
'align' => 'left',
|
58 |
+
'width' => '150px',
|
59 |
+
'type' => 'datetime',
|
60 |
+
'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM),
|
61 |
+
'index' => 'create_date',
|
62 |
+
'filter_index' => 'main_table.create_date'
|
63 |
+
));
|
64 |
+
|
65 |
+
$this->addColumn('update_date', array(
|
66 |
+
'header' => Mage::helper('M2ePro')->__('Update Date'),
|
67 |
+
'align' => 'left',
|
68 |
+
'width' => '150px',
|
69 |
+
'type' => 'datetime',
|
70 |
+
'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM),
|
71 |
+
'index' => 'update_date',
|
72 |
+
'filter_index' => 'main_table.update_date'
|
73 |
+
));
|
74 |
+
|
75 |
+
$confirm = 'Attention! By deleting account you delete all information on it from M2E Pro server. ';
|
76 |
+
$confirm .= 'This will cause inappropriate work of all accounts\' copies.';
|
77 |
+
$confirm = Mage::helper('M2ePro')->__($confirm);
|
78 |
+
|
79 |
+
$this->addColumn('actions', array(
|
80 |
+
'header' => Mage::helper('M2ePro')->__('Actions'),
|
81 |
+
'align' => 'left',
|
82 |
+
'width' => '150px',
|
83 |
+
'type' => 'action',
|
84 |
+
'index' => 'actions',
|
85 |
+
'filter' => false,
|
86 |
+
'sortable' => false,
|
87 |
+
'getter' => 'getId',
|
88 |
+
'actions' => array(
|
89 |
+
array(
|
90 |
+
'caption' => Mage::helper('M2ePro')->__('Edit'),
|
91 |
+
'url' => array('base'=> '*/*/edit'),
|
92 |
+
'field' => 'id'
|
93 |
+
),
|
94 |
+
array(
|
95 |
+
'caption' => Mage::helper('M2ePro')->__('Delete'),
|
96 |
+
'url' => array('base'=> '*/*/delete'),
|
97 |
+
'field' => 'id',
|
98 |
+
'confirm' => $confirm
|
99 |
+
)
|
100 |
+
)
|
101 |
+
));
|
102 |
+
|
103 |
+
return parent::_prepareColumns();
|
104 |
+
}
|
105 |
+
|
106 |
+
protected function _prepareMassaction()
|
107 |
+
{
|
108 |
+
// Set massaction identifiers
|
109 |
+
//--------------------------------
|
110 |
+
$this->setMassactionIdField('main_table.id');
|
111 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
112 |
+
//--------------------------------
|
113 |
+
|
114 |
+
// Set delete action
|
115 |
+
//--------------------------------
|
116 |
+
$confirm = 'Attention! By deleting account you delete all information on it from M2E Pro server. ';
|
117 |
+
$confirm .= 'This will cause inappropriate work of all accounts\' copies.';
|
118 |
+
$confirm = Mage::helper('M2ePro')->__($confirm);
|
119 |
+
|
120 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
121 |
+
'label' => Mage::helper('M2ePro')->__('Delete'),
|
122 |
+
'url' => $this->getUrl('*/*/delete'),
|
123 |
+
'confirm' => $confirm
|
124 |
+
));
|
125 |
+
//--------------------------------
|
126 |
+
|
127 |
+
return parent::_prepareMassaction();
|
128 |
+
}
|
129 |
+
|
130 |
+
// ####################################
|
131 |
+
|
132 |
+
public function getGridUrl()
|
133 |
+
{
|
134 |
+
return $this->getUrl('*/*/accountGrid', array('_current'=>true));
|
135 |
+
}
|
136 |
+
|
137 |
+
public function getRowUrl($row)
|
138 |
+
{
|
139 |
+
return Mage::helper('M2ePro/View')
|
140 |
+
->getUrl($row, 'account', 'edit', array('id' => $row->getData('id')));
|
141 |
+
}
|
142 |
+
|
143 |
+
// ####################################
|
144 |
+
}
|
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,63 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Account/Grid.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_Account_Grid extends Ess_M2ePro_Block_Adminhtml_Account_Grid
|
8 |
+
{
|
9 |
+
// ####################################
|
10 |
+
|
11 |
+
protected function _prepareColumns()
|
12 |
+
{
|
13 |
+
$this->addColumn('id', array(
|
14 |
+
'header' => Mage::helper('M2ePro')->__('ID'),
|
15 |
+
'align' => 'right',
|
16 |
+
'width' => '100px',
|
17 |
+
'type' => 'number',
|
18 |
+
'index' => 'id',
|
19 |
+
'filter_index' => 'main_table.id'
|
20 |
+
));
|
21 |
+
|
22 |
+
$this->addColumn('title', array(
|
23 |
+
'header' => Mage::helper('M2ePro')->__('Title'),
|
24 |
+
'align' => 'left',
|
25 |
+
//'width' => '200px',
|
26 |
+
'type' => 'text',
|
27 |
+
'index' => 'title',
|
28 |
+
'escape' => true,
|
29 |
+
'filter_index' => 'main_table.title'
|
30 |
+
));
|
31 |
+
|
32 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
33 |
+
$this->addColumn('component_mode', array(
|
34 |
+
'header' => Mage::helper('M2ePro')->__('Channel'),
|
35 |
+
'align' => 'left',
|
36 |
+
'width' => '120px',
|
37 |
+
'type' => 'options',
|
38 |
+
'index' => 'component_mode',
|
39 |
+
'filter_index' => 'main_table.component_mode',
|
40 |
+
'sortable' => false,
|
41 |
+
'options' => Mage::helper('M2ePro/View_Common_Component')->getActiveComponentsTitles()
|
42 |
+
));
|
43 |
+
}
|
44 |
+
|
45 |
+
return parent::_prepareColumns();
|
46 |
+
}
|
47 |
+
|
48 |
+
// ####################################
|
49 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Account/Edit.php
ADDED
@@ -0,0 +1,139 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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')->__(Ess_M2ePro_Helper_Component_Amazon::TITLE);
|
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('reset', array(
|
61 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
62 |
+
'onclick' => 'AmazonAccountHandlerObj.reset_click()',
|
63 |
+
'class' => 'reset'
|
64 |
+
));
|
65 |
+
//------------------------------
|
66 |
+
|
67 |
+
//------------------------------
|
68 |
+
$this->_addButton('save_and_continue', array(
|
69 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
70 |
+
'onclick' => 'AmazonAccountHandlerObj.save_and_edit_click(\'\',\'amazonAccountEditTabs\')',
|
71 |
+
'class' => 'save'
|
72 |
+
));
|
73 |
+
//------------------------------
|
74 |
+
|
75 |
+
if ($this->getRequest()->getParam('id')) {
|
76 |
+
//------------------------------
|
77 |
+
$url = $this->getUrl('*/adminhtml_common_amazon_account/new', array('wizard' => true));
|
78 |
+
$this->_addButton('add_new_account', array(
|
79 |
+
'label' => Mage::helper('M2ePro')->__('Add New Account'),
|
80 |
+
'onclick' => 'setLocation(\''. $url .'\')',
|
81 |
+
'class' => 'add_new_account'
|
82 |
+
));
|
83 |
+
//------------------------------
|
84 |
+
|
85 |
+
//------------------------------
|
86 |
+
$this->_addButton('close', array(
|
87 |
+
'label' => Mage::helper('M2ePro')->__('Complete This Step'),
|
88 |
+
'onclick' => 'AmazonAccountHandlerObj.completeStep();',
|
89 |
+
'class' => 'close'
|
90 |
+
));
|
91 |
+
//------------------------------
|
92 |
+
}
|
93 |
+
} else {
|
94 |
+
//------------------------------
|
95 |
+
$url = Mage::helper('M2ePro')->getBackUrl('list');
|
96 |
+
$this->_addButton('back', array(
|
97 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
98 |
+
'onclick' => 'AmazonAccountHandlerObj.back_click(\''. $url .'\')',
|
99 |
+
'class' => 'back'
|
100 |
+
));
|
101 |
+
//------------------------------
|
102 |
+
|
103 |
+
//------------------------------
|
104 |
+
$this->_addButton('reset', array(
|
105 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
106 |
+
'onclick' => 'AmazonAccountHandlerObj.reset_click()',
|
107 |
+
'class' => 'reset'
|
108 |
+
));
|
109 |
+
|
110 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data') &&
|
111 |
+
Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()
|
112 |
+
) {
|
113 |
+
//------------------------------
|
114 |
+
$this->_addButton('delete', array(
|
115 |
+
'label' => Mage::helper('M2ePro')->__('Delete'),
|
116 |
+
'onclick' => 'AmazonAccountHandlerObj.delete_click()',
|
117 |
+
'class' => 'delete M2ePro_delete_button'
|
118 |
+
));
|
119 |
+
//------------------------------
|
120 |
+
}
|
121 |
+
|
122 |
+
//------------------------------
|
123 |
+
$this->_addButton('save', array(
|
124 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
125 |
+
'onclick' => 'AmazonAccountHandlerObj.save_click()',
|
126 |
+
'class' => 'save'
|
127 |
+
));
|
128 |
+
//------------------------------
|
129 |
+
|
130 |
+
//------------------------------
|
131 |
+
$this->_addButton('save_and_continue', array(
|
132 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
133 |
+
'onclick' => 'AmazonAccountHandlerObj.save_and_edit_click(\'\',\'amazonAccountEditTabs\')',
|
134 |
+
'class' => 'save'
|
135 |
+
));
|
136 |
+
//------------------------------
|
137 |
+
}
|
138 |
+
}
|
139 |
+
}
|
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,54 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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')->getCollection('Marketplace')
|
45 |
+
->addFieldToFilter('status',Ess_M2ePro_Model_Marketplace::STATUS_ENABLE)
|
46 |
+
->addFieldToFilter('developer_key',array('notnull' => true))
|
47 |
+
->toArray();
|
48 |
+
|
49 |
+
$this->marketplaces = $marketplaces['items'];
|
50 |
+
//var_dump($this->marketplaces); exit();
|
51 |
+
|
52 |
+
return parent::_beforeToHtml();
|
53 |
+
}
|
54 |
+
}
|
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,157 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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_listing_other/index',
|
49 |
+
array(
|
50 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON,
|
51 |
+
'back' => $backUrl
|
52 |
+
)
|
53 |
+
);
|
54 |
+
$this->_addButton('goto_listing_other', array(
|
55 |
+
'label' => Mage::helper('M2ePro')->__('3rd Party Listings'),
|
56 |
+
'onclick' => 'setLocation(\'' . $url . '\')',
|
57 |
+
'class' => 'button_link'
|
58 |
+
));
|
59 |
+
//------------------------------
|
60 |
+
|
61 |
+
//------------------------------
|
62 |
+
$this->_addButton('goto_template', array(
|
63 |
+
'label' => Mage::helper('M2ePro')->__('Templates'),
|
64 |
+
'onclick' => '',
|
65 |
+
'class' => 'button_link amazon-templates-drop-down'
|
66 |
+
));
|
67 |
+
//------------------------------
|
68 |
+
|
69 |
+
//------------------------------
|
70 |
+
$url = $this->getUrl(
|
71 |
+
'*/adminhtml_common_log/listing',
|
72 |
+
array(
|
73 |
+
'filter' => base64_encode('component_mode=' . Ess_M2ePro_Helper_Component_Amazon::NICK)
|
74 |
+
)
|
75 |
+
);
|
76 |
+
$this->_addButton('view_log', array(
|
77 |
+
'label' => Mage::helper('M2ePro')->__('View Log'),
|
78 |
+
'onclick' => 'window.open(\'' . $url . '\')',
|
79 |
+
'class' => 'button_link'
|
80 |
+
));
|
81 |
+
//------------------------------
|
82 |
+
|
83 |
+
//------------------------------
|
84 |
+
$url = $this->getUrl(
|
85 |
+
'*/adminhtml_common_amazon_listing/search',
|
86 |
+
array(
|
87 |
+
'back' => $backUrl
|
88 |
+
)
|
89 |
+
);
|
90 |
+
$this->_addButton('search_amazon_products', array(
|
91 |
+
'label' => Mage::helper('M2ePro')->__('Search Items'),
|
92 |
+
'onclick' => 'setLocation(\'' . $url . '\')',
|
93 |
+
'class' => 'button_link search'
|
94 |
+
));
|
95 |
+
//------------------------------
|
96 |
+
|
97 |
+
//------------------------------
|
98 |
+
if (Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
99 |
+
$this->_addButton('reset', array(
|
100 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
101 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
102 |
+
'class' => 'reset'
|
103 |
+
));
|
104 |
+
}
|
105 |
+
//------------------------------
|
106 |
+
|
107 |
+
//------------------------------
|
108 |
+
$url = $this->getUrl('*/adminhtml_common_amazon_listing/add', array('step' => '1', 'clear' => 'yes'));
|
109 |
+
$this->_addButton('add', array(
|
110 |
+
'label' => Mage::helper('M2ePro')->__('Add Listing'),
|
111 |
+
'onclick' => 'setLocation(\'' . $url . '\')',
|
112 |
+
'class' => 'add'
|
113 |
+
));
|
114 |
+
//------------------------------
|
115 |
+
}
|
116 |
+
|
117 |
+
// ####################################
|
118 |
+
|
119 |
+
public function getTemplatesButtonJavascript()
|
120 |
+
{
|
121 |
+
$dropDownBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_button_dropDown', '', array(
|
122 |
+
'target_css_class' => 'amazon-templates-drop-down',
|
123 |
+
'items' => $this->getTemplatesButtonDropDownItems()
|
124 |
+
));
|
125 |
+
|
126 |
+
return $dropDownBlock->toHtml();
|
127 |
+
}
|
128 |
+
|
129 |
+
protected function getTemplatesButtonDropDownItems()
|
130 |
+
{
|
131 |
+
$items = array();
|
132 |
+
|
133 |
+
$filter = base64_encode('component_mode=' . Ess_M2ePro_Helper_Component_Amazon::NICK);
|
134 |
+
|
135 |
+
//------------------------------
|
136 |
+
$url = $this->getUrl('*/adminhtml_common_template_sellingFormat/index', array('filter' => $filter));
|
137 |
+
$items[] = array(
|
138 |
+
'url' => $url,
|
139 |
+
'label' => Mage::helper('M2ePro')->__('Selling Format Templates'),
|
140 |
+
'target' => '_blank'
|
141 |
+
);
|
142 |
+
//------------------------------
|
143 |
+
|
144 |
+
//------------------------------
|
145 |
+
$url = $this->getUrl('*/adminhtml_common_template_synchronization/index', array('filter' => $filter));
|
146 |
+
$items[] = array(
|
147 |
+
'url' => $url,
|
148 |
+
'label' => Mage::helper('M2ePro')->__('Synchronization Templates'),
|
149 |
+
'target' => '_blank'
|
150 |
+
);
|
151 |
+
//------------------------------
|
152 |
+
|
153 |
+
return $items;
|
154 |
+
}
|
155 |
+
|
156 |
+
// ####################################
|
157 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/StepFive.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_Listing_Add_StepFive extends Mage_Adminhtml_Block_Widget_Grid_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonListingAddStepFive');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_amazon_listing_product';
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
// Set header text
|
21 |
+
//------------------------------
|
22 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
23 |
+
$componentName = Mage::helper('M2ePro')->__(Ess_M2ePro_Helper_Component_Amazon::TITLE);
|
24 |
+
$headerText = Mage::helper('M2ePro')->__("Add %component_name% Listing [Select Categories Products]",
|
25 |
+
$componentName);
|
26 |
+
} else {
|
27 |
+
$headerText = Mage::helper('M2ePro')->__("Add Listing [Select Categories Products]");
|
28 |
+
}
|
29 |
+
|
30 |
+
$this->_headerText = $headerText;
|
31 |
+
//------------------------------
|
32 |
+
|
33 |
+
// Set buttons actions
|
34 |
+
//------------------------------
|
35 |
+
$this->removeButton('back');
|
36 |
+
$this->removeButton('reset');
|
37 |
+
$this->removeButton('delete');
|
38 |
+
$this->removeButton('add');
|
39 |
+
$this->removeButton('save');
|
40 |
+
$this->removeButton('edit');
|
41 |
+
//------------------------------
|
42 |
+
|
43 |
+
//------------------------------
|
44 |
+
$url = $this->getUrl('*/adminhtml_common_amazon_listing/add', array('step' => '4'));
|
45 |
+
$this->_addButton('back', array(
|
46 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
47 |
+
'onclick' => 'ProductGridHandlerObj.back_click(\'' . $url . '\')',
|
48 |
+
'class' => 'back'
|
49 |
+
));
|
50 |
+
//------------------------------
|
51 |
+
|
52 |
+
//------------------------------
|
53 |
+
$this->_addButton('reset', array(
|
54 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
55 |
+
'onclick' => 'ProductGridHandlerObj.reset_click()',
|
56 |
+
'class' => 'reset'
|
57 |
+
));
|
58 |
+
//------------------------------
|
59 |
+
|
60 |
+
//------------------------------
|
61 |
+
$this->_addButton('save_and_go_to_listings_list', array(
|
62 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
63 |
+
'onclick' => 'ProductGridHandlerObj.save_click(\'list\')',
|
64 |
+
'class' => 'save'
|
65 |
+
));
|
66 |
+
//------------------------------
|
67 |
+
|
68 |
+
//------------------------------
|
69 |
+
$this->_addButton('save_and_go_to_listing_view', array(
|
70 |
+
'label' => Mage::helper('M2ePro')->__('Save And View Listing'),
|
71 |
+
'onclick' => 'ProductGridHandlerObj.save_click(\'view\')',
|
72 |
+
'class' => 'save'
|
73 |
+
));
|
74 |
+
//------------------------------
|
75 |
+
}
|
76 |
+
|
77 |
+
public function getGridHtml()
|
78 |
+
{
|
79 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_listing_product_help');
|
80 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
81 |
+
}
|
82 |
+
|
83 |
+
protected function _toHtml()
|
84 |
+
{
|
85 |
+
return '<div id="add_products_progress_bar"></div>'.
|
86 |
+
'<div id="add_products_container">'.
|
87 |
+
parent::_toHtml().
|
88 |
+
'</div>';
|
89 |
+
}
|
90 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/StepFourCategory.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_Amazon_Listing_Add_StepFourCategory
|
8 |
+
extends Mage_Adminhtml_Block_Widget_Container
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
//------------------------------
|
16 |
+
$this->setId('amazonListingAddStepFourCategory');
|
17 |
+
$this->_blockGroup = 'M2ePro';
|
18 |
+
$this->_controller = 'adminhtml_common_amazon_listing';
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
$this->setTemplate('widget/view/container.phtml');
|
22 |
+
|
23 |
+
// Set header text
|
24 |
+
//------------------------------
|
25 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
26 |
+
$componentName = Mage::helper('M2ePro')->__(Ess_M2ePro_Helper_Component_Amazon::TITLE);
|
27 |
+
$headerText = Mage::helper('M2ePro')->__("Add %component_name% Listing [Select Categories]",
|
28 |
+
$componentName);
|
29 |
+
} else {
|
30 |
+
$headerText = Mage::helper('M2ePro')->__("Add Listing [Select Categories]");
|
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_amazon_listing/add', array('step' => '3'));
|
48 |
+
$this->_addButton('back', array(
|
49 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
50 |
+
'onclick' => 'AmazonListingCategoryHandlerObj.back_click(\'' . $url . '\')',
|
51 |
+
'class' => 'back'
|
52 |
+
));
|
53 |
+
//------------------------------
|
54 |
+
|
55 |
+
//------------------------------
|
56 |
+
$this->_addButton('reset', array(
|
57 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
58 |
+
'onclick' => 'AmazonListingCategoryHandlerObj.reset_click()',
|
59 |
+
'class' => 'reset'
|
60 |
+
));
|
61 |
+
//------------------------------
|
62 |
+
|
63 |
+
//------------------------------
|
64 |
+
$url = $this->getUrl(
|
65 |
+
'*/adminhtml_common_amazon_listing/add',
|
66 |
+
array(
|
67 |
+
'step' => '4',
|
68 |
+
'remember_categories' => 'yes'
|
69 |
+
)
|
70 |
+
);
|
71 |
+
$this->_addButton('save_and_next', array(
|
72 |
+
'label' => Mage::helper('M2ePro')->__('Next'),
|
73 |
+
'onclick' => 'AmazonListingCategoryHandlerObj.save_click(\'' . $url . '\')',
|
74 |
+
'class' => 'next save_and_next_button'
|
75 |
+
));
|
76 |
+
//------------------------------
|
77 |
+
|
78 |
+
//------------------------------
|
79 |
+
$url = $this->getUrl(
|
80 |
+
'*/adminhtml_common_amazon_listing/add',
|
81 |
+
array(
|
82 |
+
'step' => '4',
|
83 |
+
'back' => 'list'
|
84 |
+
)
|
85 |
+
);
|
86 |
+
$this->_addButton('save_and_go_to_listings_list', array(
|
87 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
88 |
+
'onclick' => 'AmazonListingCategoryHandlerObj.save_click(\'' . $url . '\')',
|
89 |
+
'class' => 'save save_and_go_to_listings_list_button'
|
90 |
+
));
|
91 |
+
//------------------------------
|
92 |
+
|
93 |
+
//------------------------------
|
94 |
+
$url = $this->getUrl('*/adminhtml_common_amazon_listing/add',
|
95 |
+
array(
|
96 |
+
'step' => '4',
|
97 |
+
'back' => 'view'
|
98 |
+
)
|
99 |
+
);
|
100 |
+
$this->_addButton('save_and_go_to_listing_view', array(
|
101 |
+
'label' => Mage::helper('M2ePro')->__('Save And View Listing'),
|
102 |
+
'onclick' => 'AmazonListingCategoryHandlerObj.save_click(\'' . $url . '\')',
|
103 |
+
'class' => 'save save_and_go_to_listing_view_button'
|
104 |
+
));
|
105 |
+
//------------------------------
|
106 |
+
}
|
107 |
+
|
108 |
+
protected function _toHtml()
|
109 |
+
{
|
110 |
+
$treeSettings = array(
|
111 |
+
'show_products_amount' => true,
|
112 |
+
'hide_products_this_listing' => false
|
113 |
+
);
|
114 |
+
// todo next
|
115 |
+
$categoryTreeBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_listing_category_tree',
|
116 |
+
'',
|
117 |
+
array('component'=>Ess_M2ePro_Helper_Component_Amazon::NICK,
|
118 |
+
'tree_settings' => $treeSettings));
|
119 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_listing_category_help');
|
120 |
+
$categoryBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_listing_category');
|
121 |
+
|
122 |
+
return '<div id="add_products_progress_bar"></div>'.
|
123 |
+
'<div id="add_products_container">'.
|
124 |
+
parent::_toHtml() . $helpBlock->toHtml() . $categoryTreeBlock->toHtml() . $categoryBlock->toHtml().
|
125 |
+
'</div>';
|
126 |
+
}
|
127 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/StepFourProduct.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_Listing_Add_StepFourProduct
|
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('amazonListingAddStepFourProduct');
|
17 |
+
$this->_blockGroup = 'M2ePro';
|
18 |
+
$this->_controller = 'adminhtml_common_amazon_listing_product';
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
// Set header text
|
22 |
+
//------------------------------
|
23 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
24 |
+
$componentName = Mage::helper('M2ePro')->__(Ess_M2ePro_Helper_Component_Amazon::TITLE);
|
25 |
+
$headerText = Mage::helper('M2ePro')->__("Add %component_name% Listing [Select Products]", $componentName);
|
26 |
+
} else {
|
27 |
+
$headerText = Mage::helper('M2ePro')->__("Add Listing [Select Products]");
|
28 |
+
}
|
29 |
+
|
30 |
+
$this->_headerText = $headerText;
|
31 |
+
//------------------------------
|
32 |
+
|
33 |
+
// Set buttons actions
|
34 |
+
//------------------------------
|
35 |
+
$this->removeButton('back');
|
36 |
+
$this->removeButton('reset');
|
37 |
+
$this->removeButton('delete');
|
38 |
+
$this->removeButton('add');
|
39 |
+
$this->removeButton('save');
|
40 |
+
$this->removeButton('edit');
|
41 |
+
//------------------------------
|
42 |
+
|
43 |
+
//------------------------------
|
44 |
+
$url = $this->getUrl('*/adminhtml_common_amazon_listing/add', array('step' => '3'));
|
45 |
+
$this->_addButton('back', array(
|
46 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
47 |
+
'onclick' => 'ProductGridHandlerObj.back_click(\'' . $url . '\')',
|
48 |
+
'class' => 'back'
|
49 |
+
));
|
50 |
+
//------------------------------
|
51 |
+
|
52 |
+
//------------------------------
|
53 |
+
$this->_addButton('reset', array(
|
54 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
55 |
+
'onclick' => 'ProductGridHandlerObj.reset_click()',
|
56 |
+
'class' => 'reset'
|
57 |
+
));
|
58 |
+
//------------------------------
|
59 |
+
|
60 |
+
//------------------------------
|
61 |
+
$this->_addButton('save_and_go_to_listings_list', array(
|
62 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
63 |
+
'onclick' => 'ProductGridHandlerObj.save_click(\'list\')',
|
64 |
+
'class' => 'save'
|
65 |
+
));
|
66 |
+
//------------------------------
|
67 |
+
|
68 |
+
//------------------------------
|
69 |
+
$this->_addButton('save_and_go_to_listing_view', array(
|
70 |
+
'label' => Mage::helper('M2ePro')->__('Save And View Listing'),
|
71 |
+
'onclick' => 'ProductGridHandlerObj.save_click(\'view\')',
|
72 |
+
'class' => 'save'
|
73 |
+
));
|
74 |
+
//------------------------------
|
75 |
+
}
|
76 |
+
|
77 |
+
public function getGridHtml()
|
78 |
+
{
|
79 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_listing_product_help');
|
80 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
81 |
+
}
|
82 |
+
|
83 |
+
protected function _toHtml()
|
84 |
+
{
|
85 |
+
return '<div id="add_products_progress_bar"></div>'.
|
86 |
+
'<div id="add_products_container">'.
|
87 |
+
parent::_toHtml().
|
88 |
+
'</div>';
|
89 |
+
}
|
90 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/StepOne.php
ADDED
@@ -0,0 +1,74 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Add_StepOne extends Mage_Adminhtml_Block_Widget_Form_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonListingAddStepOne');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_amazon_listing';
|
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')->__(Ess_M2ePro_Helper_Component_Amazon::TITLE);
|
25 |
+
$headerText = Mage::helper('M2ePro')->__("Add %component_name% Listing [Settings]", $componentName);
|
26 |
+
} else {
|
27 |
+
$headerText = Mage::helper('M2ePro')->__("Add Listing [Settings]");
|
28 |
+
}
|
29 |
+
|
30 |
+
$this->_headerText = $headerText;
|
31 |
+
//------------------------------
|
32 |
+
|
33 |
+
// Set buttons actions
|
34 |
+
//------------------------------
|
35 |
+
$this->removeButton('back');
|
36 |
+
$this->removeButton('reset');
|
37 |
+
$this->removeButton('delete');
|
38 |
+
$this->removeButton('add');
|
39 |
+
$this->removeButton('save');
|
40 |
+
$this->removeButton('edit');
|
41 |
+
//------------------------------
|
42 |
+
|
43 |
+
//------------------------------
|
44 |
+
$url = $this->getUrl(
|
45 |
+
'*/adminhtml_common_listing/index',
|
46 |
+
array(
|
47 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON
|
48 |
+
)
|
49 |
+
);
|
50 |
+
$this->_addButton('back', array(
|
51 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
52 |
+
'onclick' => 'AmazonListingSettingsHandlerObj.back_click(\'' . $url . '\')',
|
53 |
+
'class' => 'back'
|
54 |
+
));
|
55 |
+
//------------------------------
|
56 |
+
|
57 |
+
//------------------------------
|
58 |
+
$this->_addButton('reset', array(
|
59 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
60 |
+
'onclick' => 'AmazonListingSettingsHandlerObj.reset_click()',
|
61 |
+
'class' => 'reset'
|
62 |
+
));
|
63 |
+
//------------------------------
|
64 |
+
|
65 |
+
//------------------------------
|
66 |
+
$url = $this->getUrl('*/adminhtml_common_amazon_listing/add', array('step' => '1'));
|
67 |
+
$this->_addButton('save_and_next', array(
|
68 |
+
'label' => Mage::helper('M2ePro')->__('Next'),
|
69 |
+
'onclick' => 'AmazonListingSettingsHandlerObj.save_click(\'' . $url . '\')',
|
70 |
+
'class' => 'next'
|
71 |
+
));
|
72 |
+
//------------------------------
|
73 |
+
}
|
74 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/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_Amazon_Listing_Add_StepThree extends Mage_Adminhtml_Block_Widget_Form_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonListingAddStepThree');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_amazon_listing';
|
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')->__(Ess_M2ePro_Helper_Component_Amazon::TITLE);
|
25 |
+
$headerText = Mage::helper('M2ePro')->__("Add %component_name% Listing [Products Filter]",
|
26 |
+
$componentName);
|
27 |
+
} else {
|
28 |
+
$headerText = Mage::helper('M2ePro')->__("Add Listing [Products Filter]" );
|
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 |
+
$url = $this->getUrl('*/adminhtml_common_amazon_listing/add', array('step' => '2'));
|
46 |
+
$this->_addButton('back', array(
|
47 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
48 |
+
'onclick' => 'CommonHandlerObj.back_click(\'' . $url . '\')',
|
49 |
+
'class' => 'back'
|
50 |
+
));
|
51 |
+
//------------------------------
|
52 |
+
|
53 |
+
//------------------------------
|
54 |
+
$this->_addButton('reset', array(
|
55 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
56 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
57 |
+
'class' => 'reset'
|
58 |
+
));
|
59 |
+
//------------------------------
|
60 |
+
|
61 |
+
//------------------------------
|
62 |
+
$url = $this->getUrl('*/adminhtml_common_amazon_listing/add', array('step' => '3'));
|
63 |
+
$this->_addButton('save_and_next', array(
|
64 |
+
'label' => Mage::helper('M2ePro')->__('Next'),
|
65 |
+
'onclick' => 'CommonHandlerObj.save_click(\'' . $url . '\')',
|
66 |
+
'class' => 'next'
|
67 |
+
));
|
68 |
+
//------------------------------
|
69 |
+
}
|
70 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Add/StepTwo.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_Listing_Add_StepTwo extends Mage_Adminhtml_Block_Widget_Form_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonListingAddStepTwo');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_amazon_listing';
|
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')->__(Ess_M2ePro_Helper_Component_Amazon::TITLE);
|
25 |
+
$headerText = Mage::helper('M2ePro')->__("Add %component_name% Listing [Channel Settings]",
|
26 |
+
$componentName);
|
27 |
+
} else {
|
28 |
+
$headerText = Mage::helper('M2ePro')->__("Add Listing [Channel Settings]");
|
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 |
+
$url = $this->getUrl('*/adminhtml_common_amazon_listing/add', array('step' => '1'));
|
46 |
+
$this->_addButton('back', array(
|
47 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
48 |
+
'onclick' => 'AmazonListingChannelSettingsHandlerObj.back_click(\'' . $url . '\')',
|
49 |
+
'class' => 'back'
|
50 |
+
));
|
51 |
+
//------------------------------
|
52 |
+
|
53 |
+
//------------------------------
|
54 |
+
$this->_addButton('reset', array(
|
55 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
56 |
+
'onclick' => 'AmazonListingChannelSettingsHandlerObj.reset_click()',
|
57 |
+
'class' => 'reset'
|
58 |
+
));
|
59 |
+
//------------------------------
|
60 |
+
|
61 |
+
//------------------------------
|
62 |
+
$url = $this->getUrl('*/adminhtml_common_amazon_listing/add', array('step' => '2'));
|
63 |
+
$this->_addButton('save_and_next', array(
|
64 |
+
'label' => Mage::helper('M2ePro')->__('Next'),
|
65 |
+
'onclick' => 'AmazonListingChannelSettingsHandlerObj.save_click(\'' . $url . '\')',
|
66 |
+
'class' => 'next'
|
67 |
+
));
|
68 |
+
//------------------------------
|
69 |
+
}
|
70 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Category.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_Category extends Mage_Adminhtml_Block_Template
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonListingCategory');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/amazon/listing/category.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Category/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_Category_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/category/help.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Edit.php
ADDED
@@ -0,0 +1,100 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_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('amazonListingEdit');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_amazon_listing';
|
18 |
+
$this->_mode = 'edit';
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
// Set header text
|
22 |
+
//------------------------------
|
23 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
24 |
+
|
25 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
26 |
+
$headerText = Mage::helper('M2ePro')->__(
|
27 |
+
'Edit "%listing_title%" %component_name% Listing [Settings]',
|
28 |
+
$this->escapeHtml($listingData['title']),
|
29 |
+
Mage::helper('M2ePro')->__(Ess_M2ePro_Helper_Component_Amazon::TITLE)
|
30 |
+
);
|
31 |
+
} else {
|
32 |
+
$headerText = Mage::helper('M2ePro')->__(
|
33 |
+
'Edit "%listing_title%" Listing [Settings]',
|
34 |
+
$this->escapeHtml($listingData['title'])
|
35 |
+
);
|
36 |
+
}
|
37 |
+
|
38 |
+
$this->_headerText = $headerText;
|
39 |
+
//------------------------------
|
40 |
+
|
41 |
+
// Set buttons actions
|
42 |
+
//------------------------------
|
43 |
+
$this->removeButton('back');
|
44 |
+
$this->removeButton('reset');
|
45 |
+
$this->removeButton('delete');
|
46 |
+
$this->removeButton('add');
|
47 |
+
$this->removeButton('save');
|
48 |
+
$this->removeButton('edit');
|
49 |
+
//------------------------------
|
50 |
+
|
51 |
+
if (!is_null($this->getRequest()->getParam('back'))) {
|
52 |
+
//------------------------------
|
53 |
+
$url = Mage::helper('M2ePro')->getBackUrl(
|
54 |
+
'*/adminhtml_common_listing/index',
|
55 |
+
array(
|
56 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON
|
57 |
+
)
|
58 |
+
);
|
59 |
+
$this->_addButton('back', array(
|
60 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
61 |
+
'onclick' => 'AmazonListingSettingsHandlerObj.back_click(\''.$url.'\')',
|
62 |
+
'class' => 'back'
|
63 |
+
));
|
64 |
+
//------------------------------
|
65 |
+
}
|
66 |
+
|
67 |
+
//------------------------------
|
68 |
+
$this->_addButton('reset', array(
|
69 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
70 |
+
'onclick' => 'AmazonListingSettingsHandlerObj.reset_click()',
|
71 |
+
'class' => 'reset'
|
72 |
+
));
|
73 |
+
//------------------------------
|
74 |
+
|
75 |
+
$backUrl = Mage::helper('M2ePro')->getBackUrlParam('list');
|
76 |
+
|
77 |
+
//------------------------------
|
78 |
+
$url = $this->getUrl(
|
79 |
+
'*/adminhtml_common_amazon_listing/save',
|
80 |
+
array(
|
81 |
+
'id' => $listingData['id'],
|
82 |
+
'back' => $backUrl
|
83 |
+
)
|
84 |
+
);
|
85 |
+
$this->_addButton('save', array(
|
86 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
87 |
+
'onclick' => 'AmazonListingSettingsHandlerObj.save_click(\'' . $url . '\')',
|
88 |
+
'class' => 'save'
|
89 |
+
));
|
90 |
+
//------------------------------
|
91 |
+
|
92 |
+
//------------------------------
|
93 |
+
$this->_addButton('save_and_continue', array(
|
94 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
95 |
+
'onclick' => 'AmazonListingSettingsHandlerObj.save_and_edit_click(\'\',\'amazonListingEditTabs\')',
|
96 |
+
'class' => 'save'
|
97 |
+
));
|
98 |
+
//------------------------------
|
99 |
+
}
|
100 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Edit/Form.php
ADDED
@@ -0,0 +1,75 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
// Prepare action
|
22 |
+
// -------------------
|
23 |
+
$step = $this->getRequest()->getParam('step');
|
24 |
+
|
25 |
+
if (is_null($step)) {
|
26 |
+
// Edit listing mode
|
27 |
+
$action = $this->getUrl('*/adminhtml_common_amazon_listing/save');
|
28 |
+
} else {
|
29 |
+
// Add listing mode
|
30 |
+
$action = $this->getUrl('*/adminhtml_common_amazon_listing/add', array('step' => (int)$step));
|
31 |
+
}
|
32 |
+
// -------------------
|
33 |
+
|
34 |
+
$form = new Varien_Data_Form(array(
|
35 |
+
'id' => 'edit_form',
|
36 |
+
'action' => $action,
|
37 |
+
'method' => 'post',
|
38 |
+
'enctype' => 'multipart/form-data'
|
39 |
+
));
|
40 |
+
|
41 |
+
$form->setUseContainer(true);
|
42 |
+
$this->setForm($form);
|
43 |
+
|
44 |
+
return parent::_prepareForm();
|
45 |
+
}
|
46 |
+
|
47 |
+
protected function _beforeToHtml()
|
48 |
+
{
|
49 |
+
// Add listing mode
|
50 |
+
// -------------------
|
51 |
+
$child = NULL;
|
52 |
+
$step = $this->getRequest()->getParam('step');
|
53 |
+
|
54 |
+
if ($step == 1) {
|
55 |
+
$child = $this->getLayout()
|
56 |
+
->createBlock('M2ePro/adminhtml_common_amazon_listing_edit_tabs_settings');
|
57 |
+
} else if ($step == 2) {
|
58 |
+
$child = $this->getLayout()
|
59 |
+
->createBlock('M2ePro/adminhtml_common_amazon_listing_edit_tabs_channelSettings');
|
60 |
+
} elseif ($step == 3) {
|
61 |
+
$child = $this->getLayout()
|
62 |
+
->createBlock('M2ePro/adminhtml_common_amazon_listing_edit_tabs_productsFilter');
|
63 |
+
}
|
64 |
+
|
65 |
+
if (!is_null($child)) {
|
66 |
+
$this->setTemplate('M2ePro/common/amazon/listing/add.phtml');
|
67 |
+
$this->setChild('general', $this->getLayout()
|
68 |
+
->createBlock('M2ePro/adminhtml_common_amazon_listing_edit_tabs_general'));
|
69 |
+
$this->setChild('content', $child);
|
70 |
+
}
|
71 |
+
// -------------------
|
72 |
+
|
73 |
+
return parent::_beforeToHtml();
|
74 |
+
}
|
75 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/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_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->setTitle(Mage::helper('M2ePro')->__('Configuration'));
|
19 |
+
$this->setDestElementId('edit_form');
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _beforeToHtml()
|
23 |
+
{
|
24 |
+
$this->addTab('settings', array(
|
25 |
+
'label' => Mage::helper('M2ePro')->__('Settings'),
|
26 |
+
'title' => Mage::helper('M2ePro')->__('Settings'),
|
27 |
+
'content' => $this->getLayout()
|
28 |
+
->createBlock('M2ePro/adminhtml_common_amazon_listing_edit_tabs_settings')
|
29 |
+
->toHtml(),
|
30 |
+
));
|
31 |
+
|
32 |
+
$this->addTab('channel', array(
|
33 |
+
'label' => Mage::helper('M2ePro')->__('Channel Settings'),
|
34 |
+
'title' => Mage::helper('M2ePro')->__('Channel Settings'),
|
35 |
+
'content' => $this->getLayout()
|
36 |
+
->createBlock('M2ePro/adminhtml_common_amazon_listing_edit_tabs_channelSettings')
|
37 |
+
->toHtml(),
|
38 |
+
));
|
39 |
+
|
40 |
+
$this->addTab('products_filter', array(
|
41 |
+
'label' => Mage::helper('M2ePro')->__('Products Filter'),
|
42 |
+
'title' => Mage::helper('M2ePro')->__('Products Filter'),
|
43 |
+
'content' => $this->getLayout()
|
44 |
+
->createBlock('M2ePro/adminhtml_common_amazon_listing_edit_tabs_ProductsFilter')
|
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/Amazon/Listing/Edit/Tabs/ChannelSettings.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_Edit_Tabs_ChannelSettings extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonListingEditTabsChannelSettings');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/amazon/listing/tabs/channel_settings.phtml');
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _beforeToHtml()
|
22 |
+
{
|
23 |
+
//-------------------------------
|
24 |
+
$accounts = Mage::helper('M2ePro/Component_Amazon')->getCollection('Account')
|
25 |
+
->setOrder('title', 'ASC')
|
26 |
+
->toArray();
|
27 |
+
$this->setData('accounts', $accounts['items']);
|
28 |
+
//-------------------------------
|
29 |
+
|
30 |
+
//-------------------------------
|
31 |
+
$formData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
32 |
+
$this->setData('attributes',
|
33 |
+
Mage::helper('M2ePro/Magento_Attribute')->getByAttributeSets($formData['attribute_sets']));
|
34 |
+
//-------------------------------
|
35 |
+
|
36 |
+
return parent::_beforeToHtml();
|
37 |
+
}
|
38 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Edit/Tabs/General.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_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('amazonListingEditTabsChannelGeneral');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/amazon/listing/tabs/general.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Edit/Tabs/ProductsFilter.php
ADDED
@@ -0,0 +1,53 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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_ProductsFilter extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonListingEditTabsProductsFilter');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/amazon/listing/tabs/products_filter.phtml');
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _beforeToHtml()
|
22 |
+
{
|
23 |
+
//-------------------------------
|
24 |
+
$accounts = Mage::helper('M2ePro/Component_Amazon')->getCollection('Account')
|
25 |
+
->setOrder('title', 'ASC')
|
26 |
+
->toArray();
|
27 |
+
$this->setData('accounts', $accounts['items']);
|
28 |
+
//-------------------------------
|
29 |
+
|
30 |
+
//-------------------------------
|
31 |
+
$formData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
32 |
+
$this->setData('attributes',
|
33 |
+
Mage::helper('M2ePro/Magento_Attribute')->getByAttributeSets($formData['attribute_sets']));
|
34 |
+
//-------------------------------
|
35 |
+
|
36 |
+
//------------------------------
|
37 |
+
$treeSettings = array(
|
38 |
+
'show_products_amount' => false,
|
39 |
+
'hide_products_this_listing' => false
|
40 |
+
);
|
41 |
+
|
42 |
+
// todo next
|
43 |
+
$treeBlock = $this->getLayout()
|
44 |
+
->createBlock('M2ePro/adminhtml_common_listing_category_tree','',array(
|
45 |
+
'component'=>Ess_M2ePro_Helper_Component_Amazon::NICK,
|
46 |
+
'tree_settings' => $treeSettings
|
47 |
+
));
|
48 |
+
$this->setChild('categoriesTree', $treeBlock);
|
49 |
+
//------------------------------
|
50 |
+
|
51 |
+
return parent::_beforeToHtml();
|
52 |
+
}
|
53 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Edit/Tabs/Settings.php
ADDED
@@ -0,0 +1,146 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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_Settings extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonListingEditTabsSettings');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/amazon/listing/tabs/settings.phtml');
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _beforeToHtml()
|
22 |
+
{
|
23 |
+
//-------------------------------
|
24 |
+
$maxRecordsQuantity = Mage::helper('M2ePro/View_Common')->getAutocompleteMaxItems();
|
25 |
+
//-------------------------------
|
26 |
+
|
27 |
+
// Get attribute sets
|
28 |
+
//------------------------------
|
29 |
+
$this->attributesSets = Mage::helper('M2ePro/Magento_AttributeSet')->getAll();
|
30 |
+
|
31 |
+
//------------------------------
|
32 |
+
$data = array(
|
33 |
+
'id' => 'attribute_sets_select_all_button',
|
34 |
+
'label' => Mage::helper('M2ePro')->__('Select All'),
|
35 |
+
'onclick' => 'AttributeSetHandlerObj.selectAllAttributeSets();',
|
36 |
+
'class' => 'attribute_sets_select_all_button'
|
37 |
+
);
|
38 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
39 |
+
$this->setChild('attribute_sets_select_all_button',$buttonBlock);
|
40 |
+
//------------------------------
|
41 |
+
|
42 |
+
//------------------------------
|
43 |
+
$data = array(
|
44 |
+
'id' => 'attribute_sets_confirm_button',
|
45 |
+
'label' => Mage::helper('M2ePro')->__('Confirm'),
|
46 |
+
'onclick' => 'AmazonListingSettingsHandlerObj.attribute_sets_confirm();',
|
47 |
+
'class' => 'attribute_sets_confirm_button',
|
48 |
+
'style' => 'display: none'
|
49 |
+
);
|
50 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
51 |
+
$this->setChild('attribute_sets_confirm_button',$buttonBlock);
|
52 |
+
//------------------------------
|
53 |
+
|
54 |
+
//----------------------------
|
55 |
+
$this->sellingFormatTemplatesDropDown = Mage::helper('M2ePro/Component_Amazon')
|
56 |
+
->getCollection('Template_SellingFormat')
|
57 |
+
->getSize() < $maxRecordsQuantity;
|
58 |
+
//----------------------------
|
59 |
+
|
60 |
+
//----------------------------
|
61 |
+
$synchronizationTemplatesCollection = Mage::helper('M2ePro/Component_Amazon')
|
62 |
+
->getCollection('Template_Synchronization')
|
63 |
+
->setOrder('title', 'ASC');
|
64 |
+
|
65 |
+
if ($synchronizationTemplatesCollection->getSize() < $maxRecordsQuantity) {
|
66 |
+
$this->synchronizationsTemplatesDropDown = true;
|
67 |
+
$templates = $synchronizationTemplatesCollection->toArray();
|
68 |
+
|
69 |
+
foreach ($templates['items'] as $key => $value) {
|
70 |
+
$templates['items'][$key]['title'] = Mage::helper('M2ePro')
|
71 |
+
->escapeHtml($templates['items'][$key]['title']);
|
72 |
+
}
|
73 |
+
|
74 |
+
$this->synchronizationsTemplates = $templates['items'];
|
75 |
+
} else {
|
76 |
+
$this->synchronizationsTemplatesDropDown = false;
|
77 |
+
$this->synchronizationsTemplates = array();
|
78 |
+
}
|
79 |
+
//----------------------------
|
80 |
+
|
81 |
+
// Get selected categories
|
82 |
+
//----------------------------
|
83 |
+
if ($listingId = $this->getRequest()->getParam('id')) {
|
84 |
+
$listingCategories = Mage::helper('M2ePro/Component_Amazon')
|
85 |
+
->getCachedObject('Listing',$listingId)
|
86 |
+
->getCategories();
|
87 |
+
|
88 |
+
$categoriesIds = array();
|
89 |
+
foreach ($listingCategories as $listingCategory) {
|
90 |
+
$categoriesIds[] = $listingCategory['category_id'];
|
91 |
+
}
|
92 |
+
//----------------------------
|
93 |
+
|
94 |
+
Mage::helper('M2ePro/Data_Global')->setValue('temp_listing_categories', $categoriesIds);
|
95 |
+
}
|
96 |
+
//----------------------------
|
97 |
+
|
98 |
+
//------------------------------
|
99 |
+
$url = $this->getUrl('*/adminhtml_common_amazon_template_sellingFormat/new');
|
100 |
+
$data = array(
|
101 |
+
'label' => Mage::helper('M2ePro')->__('Add New'),
|
102 |
+
'onclick' => 'AmazonListingSettingsHandlerObj.openWindow(\'' . $url . '\');',
|
103 |
+
'class' => 'add add_new_selling_format_template_button',
|
104 |
+
'style' => 'vertical-align: bottom'
|
105 |
+
);
|
106 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
107 |
+
$this->setChild('add_new_selling_format_template_button',$buttonBlock);
|
108 |
+
//------------------------------
|
109 |
+
|
110 |
+
//------------------------------
|
111 |
+
$data = array(
|
112 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
113 |
+
'onclick' => 'AmazonListingSettingsHandlerObj.reloadSellingFormatTemplates();',
|
114 |
+
'class' => 'reload_selling_format_templates_button',
|
115 |
+
'style' => 'vertical-align: bottom'
|
116 |
+
);
|
117 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
118 |
+
$this->setChild('reload_selling_format_templates_button',$buttonBlock);
|
119 |
+
//------------------------------
|
120 |
+
|
121 |
+
//------------------------------
|
122 |
+
$url = $this->getUrl('*/adminhtml_common_amazon_template_synchronization/new');
|
123 |
+
$data = array(
|
124 |
+
'label' => Mage::helper('M2ePro')->__('Add New'),
|
125 |
+
'onclick' => 'AmazonListingSettingsHandlerObj.openWindow(\'' . $url . '\');',
|
126 |
+
'class' => 'add add_new_synchronization_template_button',
|
127 |
+
'style' => 'vertical-align: bottom'
|
128 |
+
);
|
129 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
130 |
+
$this->setChild('add_new_synchronization_template_button',$buttonBlock);
|
131 |
+
//------------------------------
|
132 |
+
|
133 |
+
//------------------------------
|
134 |
+
$data = array(
|
135 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
136 |
+
'onclick' => 'AmazonListingSettingsHandlerObj.reloadSynchronizationTemplates();',
|
137 |
+
'class' => 'reload_synchronization_templates_button',
|
138 |
+
'style' => 'vertical-align: bottom'
|
139 |
+
);
|
140 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
141 |
+
$this->setChild('reload_synchronization_templates_button',$buttonBlock);
|
142 |
+
//------------------------------
|
143 |
+
|
144 |
+
return parent::_beforeToHtml();
|
145 |
+
}
|
146 |
+
}
|
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,334 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â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
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonListingGrid');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
// Set default values
|
19 |
+
//------------------------------
|
20 |
+
$this->setDefaultSort('id');
|
21 |
+
$this->setDefaultDir('DESC');
|
22 |
+
$this->setSaveParametersInSession(true);
|
23 |
+
$this->setUseAjax(true);
|
24 |
+
//------------------------------
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getMassactionBlockName()
|
28 |
+
{
|
29 |
+
return 'M2ePro/adminhtml_grid_massaction';
|
30 |
+
}
|
31 |
+
|
32 |
+
protected function _prepareCollection()
|
33 |
+
{
|
34 |
+
// Update statistic table values
|
35 |
+
Mage::getResourceModel('M2ePro/Listing')->updateStatisticColumns();
|
36 |
+
Mage::getResourceModel('M2ePro/Amazon_Listing')->updateStatisticColumns();
|
37 |
+
|
38 |
+
// Get collection of listings
|
39 |
+
$collection = Mage::helper('M2ePro/Component_Amazon')->getCollection('Listing');
|
40 |
+
|
41 |
+
// Set global filters
|
42 |
+
//--------------------------
|
43 |
+
$filterSellingFormatTemplate = $this->getRequest()->getParam('filter_amazon_selling_format_template');
|
44 |
+
$filterSynchronizationTemplate = $this->getRequest()->getParam('filter_amazon_synchronization_template');
|
45 |
+
|
46 |
+
if ($filterSellingFormatTemplate != 0) {
|
47 |
+
$collection->addFieldToFilter(
|
48 |
+
'second_table.template_selling_format_id', (int)$filterSellingFormatTemplate
|
49 |
+
);
|
50 |
+
}
|
51 |
+
|
52 |
+
if ($filterSynchronizationTemplate != 0) {
|
53 |
+
$collection->addFieldToFilter(
|
54 |
+
'second_table.template_synchronization_id', (int)$filterSynchronizationTemplate
|
55 |
+
);
|
56 |
+
}
|
57 |
+
//--------------------------
|
58 |
+
|
59 |
+
//exit($collection->getSelect()->__toString());
|
60 |
+
|
61 |
+
// Set collection to grid
|
62 |
+
$this->setCollection($collection);
|
63 |
+
|
64 |
+
return parent::_prepareCollection();
|
65 |
+
}
|
66 |
+
|
67 |
+
protected function _prepareColumns()
|
68 |
+
{
|
69 |
+
$this->addColumn('id', array(
|
70 |
+
'header' => Mage::helper('M2ePro')->__('ID'),
|
71 |
+
'align' => 'right',
|
72 |
+
'width' => '100px',
|
73 |
+
'type' => 'number',
|
74 |
+
'index' => 'id',
|
75 |
+
'filter_index' => 'main_table.id'
|
76 |
+
));
|
77 |
+
|
78 |
+
$this->addColumn('title', array(
|
79 |
+
'header' => Mage::helper('M2ePro')->__('Title'),
|
80 |
+
'align' => 'left',
|
81 |
+
//'width' => '200px',
|
82 |
+
'type' => 'text',
|
83 |
+
'index' => 'title',
|
84 |
+
'escape' => true,
|
85 |
+
'filter_index' => 'main_table.title'
|
86 |
+
));
|
87 |
+
|
88 |
+
$this->addColumn('products_total_count', array(
|
89 |
+
'header' => Mage::helper('M2ePro')->__('Total Items'),
|
90 |
+
'align' => 'right',
|
91 |
+
'width' => '100px',
|
92 |
+
'type' => 'number',
|
93 |
+
'index' => 'products_total_count',
|
94 |
+
'filter_index' => 'main_table.products_total_count',
|
95 |
+
'frame_callback' => array($this, 'callbackColumnTotalProducts')
|
96 |
+
));
|
97 |
+
|
98 |
+
$this->addColumn('products_active_count', array(
|
99 |
+
'header' => Mage::helper('M2ePro')->__('Active Items'),
|
100 |
+
'align' => 'right',
|
101 |
+
'width' => '100px',
|
102 |
+
'type' => 'number',
|
103 |
+
'index' => 'products_active_count',
|
104 |
+
'filter_index' => 'main_table.products_active_count',
|
105 |
+
'frame_callback' => array($this, 'callbackColumnListedProducts')
|
106 |
+
));
|
107 |
+
|
108 |
+
$this->addColumn('products_inactive_count', array(
|
109 |
+
'header' => Mage::helper('M2ePro')->__('Inactive Items'),
|
110 |
+
'align' => 'right',
|
111 |
+
'width' => '100px',
|
112 |
+
'type' => 'number',
|
113 |
+
'index' => 'products_inactive_count',
|
114 |
+
'filter_index' => 'main_table.products_inactive_count',
|
115 |
+
'frame_callback' => array($this, 'callbackColumnInactiveProducts')
|
116 |
+
));
|
117 |
+
|
118 |
+
$this->addColumn('create_date', array(
|
119 |
+
'header' => Mage::helper('M2ePro')->__('Creation Date'),
|
120 |
+
'align' => 'left',
|
121 |
+
'width' => '150px',
|
122 |
+
'type' => 'datetime',
|
123 |
+
'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM),
|
124 |
+
'index' => 'create_date',
|
125 |
+
'filter_index' => 'main_table.create_date'
|
126 |
+
));
|
127 |
+
|
128 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
129 |
+
'*/adminhtml_common_listing/index',
|
130 |
+
array(
|
131 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON
|
132 |
+
)
|
133 |
+
);
|
134 |
+
|
135 |
+
$this->addColumn('actions', array(
|
136 |
+
'header' => Mage::helper('M2ePro')->__('Actions'),
|
137 |
+
'align' => 'left',
|
138 |
+
'width' => '150px',
|
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 Products'),
|
147 |
+
'field' => 'id',
|
148 |
+
'url' => array(
|
149 |
+
'base' => '*/adminhtml_common_amazon_listing/view',
|
150 |
+
'params' => array('back' => $backUrl)
|
151 |
+
)
|
152 |
+
),
|
153 |
+
array(
|
154 |
+
'caption' => Mage::helper('M2ePro')->__('Add Products from Products List'),
|
155 |
+
'field' => 'id',
|
156 |
+
'url' => array(
|
157 |
+
'base' => '*/adminhtml_common_amazon_listing/product',
|
158 |
+
'params' => array('back' => $backUrl)
|
159 |
+
)
|
160 |
+
),
|
161 |
+
array(
|
162 |
+
'caption' => Mage::helper('M2ePro')->__('Add Products from Categories'),
|
163 |
+
'field' => 'id',
|
164 |
+
'url' => array(
|
165 |
+
'base' => '*/adminhtml_common_amazon_listing/categoryProduct',
|
166 |
+
'params' => array('back' => $backUrl)
|
167 |
+
)
|
168 |
+
),
|
169 |
+
array(
|
170 |
+
'caption' => Mage::helper('M2ePro')->__('Edit Settings'),
|
171 |
+
'field' => 'id',
|
172 |
+
'url' => array(
|
173 |
+
'base' => '*/adminhtml_common_amazon_listing/edit',
|
174 |
+
'params' => array('back' => $backUrl)
|
175 |
+
)
|
176 |
+
),
|
177 |
+
array(
|
178 |
+
'caption' => Mage::helper('M2ePro')->__('Delete Listing'),
|
179 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?'),
|
180 |
+
'field' => 'id',
|
181 |
+
'url' => array(
|
182 |
+
'base' => '*/adminhtml_common_amazon_listing/delete',
|
183 |
+
)
|
184 |
+
),
|
185 |
+
array(
|
186 |
+
'caption' => Mage::helper('M2ePro')->__('View Log'),
|
187 |
+
'field' => 'id',
|
188 |
+
'url' => array(
|
189 |
+
'base' => '*/adminhtml_common_log/listing',
|
190 |
+
'params' => array('back' => $backUrl)
|
191 |
+
)
|
192 |
+
),
|
193 |
+
array(
|
194 |
+
'caption' => Mage::helper('M2ePro')->__('Clear Log'),
|
195 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?'),
|
196 |
+
'field' => 'id',
|
197 |
+
'url' => array(
|
198 |
+
'base' => '*/adminhtml_listing/clearLog',
|
199 |
+
'params' => array('back' => $backUrl)
|
200 |
+
)
|
201 |
+
),
|
202 |
+
array(
|
203 |
+
'caption' => Mage::helper('M2ePro')->__('Edit Selling Format Template'),
|
204 |
+
'field' => 'id',
|
205 |
+
'url' => array(
|
206 |
+
'base' => '*/adminhtml_common_listing/goToSellingFormatTemplate',
|
207 |
+
'params' => array('back' => $backUrl)
|
208 |
+
)
|
209 |
+
),
|
210 |
+
array(
|
211 |
+
'caption' => Mage::helper('M2ePro')->__('Edit Synchronization Template'),
|
212 |
+
'field' => 'id',
|
213 |
+
'url' => array(
|
214 |
+
'base' => '*/adminhtml_common_listing/goToSynchronizationTemplate',
|
215 |
+
'params' => array('back' => $backUrl)
|
216 |
+
)
|
217 |
+
)
|
218 |
+
)
|
219 |
+
));
|
220 |
+
|
221 |
+
return parent::_prepareColumns();
|
222 |
+
}
|
223 |
+
|
224 |
+
// ####################################
|
225 |
+
|
226 |
+
protected function _prepareMassaction()
|
227 |
+
{
|
228 |
+
// Set massaction identifiers
|
229 |
+
//--------------------------------
|
230 |
+
$this->setMassactionIdField('id');
|
231 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
232 |
+
//--------------------------------
|
233 |
+
|
234 |
+
// Set clear log action
|
235 |
+
//--------------------------------
|
236 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
237 |
+
'*/adminhtml_common_listing/index',
|
238 |
+
array(
|
239 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON
|
240 |
+
)
|
241 |
+
);
|
242 |
+
|
243 |
+
$this->getMassactionBlock()->addItem('clear_logs', array(
|
244 |
+
'label' => Mage::helper('M2ePro')->__('Clear Log(s)'),
|
245 |
+
'url' => $this->getUrl('*/adminhtml_listing/clearLog', array('back' => $backUrl)),
|
246 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
247 |
+
));
|
248 |
+
//--------------------------------
|
249 |
+
|
250 |
+
// Set remove listings action
|
251 |
+
//--------------------------------
|
252 |
+
$this->getMassactionBlock()->addItem('delete_listings', array(
|
253 |
+
'label' => Mage::helper('M2ePro')->__('Delete Listing(s)'),
|
254 |
+
'url' => $this->getUrl('*/adminhtml_common_amazon_listing/delete'),
|
255 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
256 |
+
));
|
257 |
+
//--------------------------------
|
258 |
+
|
259 |
+
return parent::_prepareMassaction();
|
260 |
+
}
|
261 |
+
|
262 |
+
// ####################################
|
263 |
+
|
264 |
+
public function callbackColumnTotalProducts($value, $row, $column, $isExport)
|
265 |
+
{
|
266 |
+
if (is_null($value) || $value === '') {
|
267 |
+
$value = Mage::helper('M2ePro')->__('N/A');
|
268 |
+
} else if ($value <= 0) {
|
269 |
+
$value = '<span style="color: red;">0</span>';
|
270 |
+
}
|
271 |
+
|
272 |
+
return $value;
|
273 |
+
}
|
274 |
+
|
275 |
+
public function callbackColumnListedProducts($value, $row, $column, $isExport)
|
276 |
+
{
|
277 |
+
if (is_null($value) || $value === '') {
|
278 |
+
$value = Mage::helper('M2ePro')->__('N/A');
|
279 |
+
} else if ($value <= 0) {
|
280 |
+
$value = '<span style="color: red;">0</span>';
|
281 |
+
}
|
282 |
+
|
283 |
+
return $value;
|
284 |
+
}
|
285 |
+
|
286 |
+
public function callbackColumnSoldProducts($value, $row, $column, $isExport)
|
287 |
+
{
|
288 |
+
if (is_null($value) || $value === '') {
|
289 |
+
$value = Mage::helper('M2ePro')->__('N/A');
|
290 |
+
} else if ($value <= 0) {
|
291 |
+
$value = '<span style="color: red;">0</span>';
|
292 |
+
}
|
293 |
+
|
294 |
+
return $value;
|
295 |
+
}
|
296 |
+
|
297 |
+
public function callbackColumnInactiveProducts($value, $row, $column, $isExport)
|
298 |
+
{
|
299 |
+
if (is_null($value) || $value === '') {
|
300 |
+
$value = Mage::helper('M2ePro')->__('N/A');
|
301 |
+
} else if ($value <= 0) {
|
302 |
+
$value = '<span style="color: red;">0</span>';
|
303 |
+
}
|
304 |
+
|
305 |
+
return $value;
|
306 |
+
}
|
307 |
+
|
308 |
+
// ####################################
|
309 |
+
|
310 |
+
public function getGridUrl()
|
311 |
+
{
|
312 |
+
return $this->getUrl('*/adminhtml_common_amazon_listing/listingGrid', array('_current'=>true));
|
313 |
+
}
|
314 |
+
|
315 |
+
public function getRowUrl($row)
|
316 |
+
{
|
317 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
318 |
+
'*/adminhtml_common_listing/index',
|
319 |
+
array(
|
320 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON
|
321 |
+
)
|
322 |
+
);
|
323 |
+
|
324 |
+
return $this->getUrl(
|
325 |
+
'*/adminhtml_common_amazon_listing/view',
|
326 |
+
array(
|
327 |
+
'id' => $row->getId(),
|
328 |
+
'back' => $backUrl
|
329 |
+
)
|
330 |
+
);
|
331 |
+
}
|
332 |
+
|
333 |
+
// ####################################
|
334 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Other/Grid.php
ADDED
@@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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 |
+
|
53 |
+
// Add Filter By Account
|
54 |
+
if ($this->getRequest()->getParam('amazonAccount')) {
|
55 |
+
$collection->addFieldToFilter('main_table.account_id',
|
56 |
+
$this->getRequest()->getParam('amazonAccount'));
|
57 |
+
}
|
58 |
+
|
59 |
+
// Add Filter By Marketplace
|
60 |
+
if ($this->getRequest()->getParam('amazonMarketplace')) {
|
61 |
+
$collection->addFieldToFilter('main_table.marketplace_id',
|
62 |
+
$this->getRequest()->getParam('amazonMarketplace'));
|
63 |
+
}
|
64 |
+
|
65 |
+
//var_dump($collection->getSelect()->__toString()); exit();
|
66 |
+
|
67 |
+
$this->setCollection($collection);
|
68 |
+
|
69 |
+
return parent::_prepareCollection();
|
70 |
+
}
|
71 |
+
|
72 |
+
protected function _prepareColumns()
|
73 |
+
{
|
74 |
+
$this->addColumn('product_id', array(
|
75 |
+
'header' => Mage::helper('M2ePro')->__('Product ID'),
|
76 |
+
'align' => 'left',
|
77 |
+
'width' => '80px',
|
78 |
+
'type' => 'number',
|
79 |
+
'index' => 'product_id',
|
80 |
+
'filter_index' => 'product_id',
|
81 |
+
'frame_callback' => array($this, 'callbackColumnProductId')
|
82 |
+
));
|
83 |
+
|
84 |
+
$this->addColumn('title', array(
|
85 |
+
'header' => Mage::helper('M2ePro')->__('Product Title / SKU'),
|
86 |
+
'align' => 'left',
|
87 |
+
'type' => 'text',
|
88 |
+
'index' => 'title',
|
89 |
+
'filter_index' => 'second_table.title',
|
90 |
+
'frame_callback' => array($this, 'callbackColumnProductTitle'),
|
91 |
+
'filter_condition_callback' => array($this, 'callbackFilterTitle')
|
92 |
+
));
|
93 |
+
|
94 |
+
$this->addColumn('general_id', array(
|
95 |
+
'header' => Mage::helper('M2ePro')->__('ASIN / ISBN'),
|
96 |
+
'align' => 'left',
|
97 |
+
'width' => '100px',
|
98 |
+
'type' => 'text',
|
99 |
+
'index' => 'general_id',
|
100 |
+
'filter_index' => 'general_id',
|
101 |
+
'frame_callback' => array($this, 'callbackColumnGeneralId')
|
102 |
+
));
|
103 |
+
|
104 |
+
$this->addColumn('online_qty', array(
|
105 |
+
'header' => Mage::helper('M2ePro')->__('Amazon QTY'),
|
106 |
+
'align' => 'right',
|
107 |
+
'width' => '100px',
|
108 |
+
'type' => 'number',
|
109 |
+
'index' => 'online_qty',
|
110 |
+
'filter_index' => 'online_qty',
|
111 |
+
'frame_callback' => array($this, 'callbackColumnAvailableQty')
|
112 |
+
));
|
113 |
+
|
114 |
+
$this->addColumn('online_price', array(
|
115 |
+
'header' => Mage::helper('M2ePro')->__('Amazon Price'),
|
116 |
+
'align' => 'right',
|
117 |
+
'width' => '100px',
|
118 |
+
'type' => 'number',
|
119 |
+
'index' => 'online_price',
|
120 |
+
'filter_index' => 'online_price',
|
121 |
+
'frame_callback' => array($this, 'callbackColumnPrice')
|
122 |
+
));
|
123 |
+
|
124 |
+
$this->addColumn('is_afn_channel', array(
|
125 |
+
'header' => Mage::helper('M2ePro')->__('Fulfillment'),
|
126 |
+
'width' => '100px',
|
127 |
+
'index' => 'is_afn_channel',
|
128 |
+
'filter_index' => 'second_table.is_afn_channel',
|
129 |
+
'type' => 'options',
|
130 |
+
'sortable' => false,
|
131 |
+
'options' => array(
|
132 |
+
0 => Mage::helper('M2ePro')->__('Merchant'),
|
133 |
+
1 => Mage::helper('M2ePro')->__('Amazon')
|
134 |
+
),
|
135 |
+
'frame_callback' => array($this, 'callbackColumnAfnChannel')
|
136 |
+
));
|
137 |
+
|
138 |
+
$this->addColumn('status', array(
|
139 |
+
'header' => Mage::helper('M2ePro')->__('Status'),
|
140 |
+
'width' => '60px',
|
141 |
+
'index' => 'status',
|
142 |
+
'filter_index' => 'main_table.status',
|
143 |
+
'type' => 'options',
|
144 |
+
'sortable' => false,
|
145 |
+
'options' => array(
|
146 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_UNKNOWN => Mage::helper('M2ePro')->__('Unknown'),
|
147 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_LISTED => Mage::helper('M2ePro')->__('Active'),
|
148 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED => Mage::helper('M2ePro')->__('Inactive'),
|
149 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_BLOCKED => Mage::helper('M2ePro')->__('Inactive (Blocked)')
|
150 |
+
),
|
151 |
+
'frame_callback' => array($this, 'callbackColumnStatus')
|
152 |
+
));
|
153 |
+
|
154 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
155 |
+
'*/adminhtml_common_listing_other/index',
|
156 |
+
array(
|
157 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON
|
158 |
+
)
|
159 |
+
);
|
160 |
+
|
161 |
+
$this->addColumn('actions', array(
|
162 |
+
'header' => Mage::helper('M2ePro')->__('Actions'),
|
163 |
+
'align' => 'left',
|
164 |
+
'width' => '70px',
|
165 |
+
'type' => 'action',
|
166 |
+
'index' => 'actions',
|
167 |
+
'filter' => false,
|
168 |
+
'sortable' => false,
|
169 |
+
'getter' => 'getId',
|
170 |
+
'actions' => array(
|
171 |
+
array(
|
172 |
+
'caption' => Mage::helper('M2ePro')->__('View Log'),
|
173 |
+
'field' => 'id',
|
174 |
+
'url' => array(
|
175 |
+
'base' => '*/adminhtml_common_log/listingOther',
|
176 |
+
'params' => array(
|
177 |
+
'back' => $backUrl
|
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 |
+
// Set mass-action
|
207 |
+
//--------------------------------
|
208 |
+
$this->getMassactionBlock()->addItem('autoMapping', array(
|
209 |
+
'label' => Mage::helper('M2ePro')->__('Map Item(s) Automatically'),
|
210 |
+
'url' => '',
|
211 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
212 |
+
));
|
213 |
+
$this->getMassactionBlock()->addItem('moving', array(
|
214 |
+
'label' => Mage::helper('M2ePro')->__('Move Item(s) to Listing'),
|
215 |
+
'url' => '',
|
216 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
217 |
+
));
|
218 |
+
$this->getMassactionBlock()->addItem('removing', array(
|
219 |
+
'label' => Mage::helper('M2ePro')->__('Remove Item(s)'),
|
220 |
+
'url' => '',
|
221 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
222 |
+
));
|
223 |
+
$this->getMassactionBlock()->addItem('unmapping', array(
|
224 |
+
'label' => Mage::helper('M2ePro')->__('Unmap Item(s)'),
|
225 |
+
'url' => '',
|
226 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
227 |
+
));
|
228 |
+
//--------------------------------
|
229 |
+
|
230 |
+
return parent::_prepareMassaction();
|
231 |
+
}
|
232 |
+
|
233 |
+
// ####################################
|
234 |
+
|
235 |
+
public function callbackColumnProductId($value, $row, $column, $isExport)
|
236 |
+
{
|
237 |
+
if (empty($value)) {
|
238 |
+
$productTitle = Mage::helper('M2ePro')->escapeHtml($row->getData('title'));
|
239 |
+
$productTitle = Mage::helper('M2ePro')->escapeJs($productTitle);
|
240 |
+
if (strlen($productTitle) > 60) {
|
241 |
+
$productTitle = substr($productTitle, 0, 60) . '...';
|
242 |
+
}
|
243 |
+
$htmlValue = ' <a href="javascript:void(0);"
|
244 |
+
onclick="AmazonListingOtherMappingHandlerObj.openPopUp(\''.
|
245 |
+
$productTitle.
|
246 |
+
'\','.
|
247 |
+
(int)$row->getId().
|
248 |
+
');">' . Mage::helper('M2ePro')->__('Map') . '</a>';
|
249 |
+
|
250 |
+
if (Mage::helper('M2ePro/Module')->isDevelopmentMode()) {
|
251 |
+
$htmlValue .= '<br>' . $row->getId();
|
252 |
+
}
|
253 |
+
return $htmlValue;
|
254 |
+
}
|
255 |
+
|
256 |
+
$htmlValue = ' <a href="'
|
257 |
+
.$this->getUrl('adminhtml/catalog_product/edit',
|
258 |
+
array('id' => $row->getData('product_id')))
|
259 |
+
.'" target="_blank">'
|
260 |
+
.$row->getData('product_id')
|
261 |
+
.'</a>';
|
262 |
+
|
263 |
+
$htmlValue .= '   <a href="javascript:void(0);"'
|
264 |
+
.' onclick="AmazonListingOtherGridHandlerObj.movingHandler.getGridHtml('
|
265 |
+
.json_encode(array((int)$row->getData('id')))
|
266 |
+
.')">'
|
267 |
+
.Mage::helper('M2ePro')->__('Move')
|
268 |
+
.'</a>';
|
269 |
+
|
270 |
+
if (Mage::helper('M2ePro/Module')->isDevelopmentMode()) {
|
271 |
+
$htmlValue .= '<br>' . $row->getId();
|
272 |
+
}
|
273 |
+
|
274 |
+
return $htmlValue;
|
275 |
+
}
|
276 |
+
|
277 |
+
public function callbackColumnProductTitle($value, $row, $column, $isExport)
|
278 |
+
{
|
279 |
+
if (strlen($value) > 60) {
|
280 |
+
$value = substr($value, 0, 60) . '...';
|
281 |
+
}
|
282 |
+
|
283 |
+
$value = '<span>' . Mage::helper('M2ePro')->escapeHtml($value) . '</span>';
|
284 |
+
|
285 |
+
$tempSku = $row->getData('sku');
|
286 |
+
empty($tempSku) && $tempSku = 'N/A';
|
287 |
+
|
288 |
+
$value .= '<br/><strong>'
|
289 |
+
.Mage::helper('M2ePro')->__('SKU')
|
290 |
+
.':</strong> '
|
291 |
+
.Mage::helper('M2ePro')->escapeHtml($tempSku);
|
292 |
+
|
293 |
+
return $value;
|
294 |
+
}
|
295 |
+
|
296 |
+
public function callbackColumnGeneralId($value, $row, $column, $isExport)
|
297 |
+
{
|
298 |
+
$url = Mage::helper('M2ePro/Component_Amazon')->getItemUrl($value, $row->getData('marketplace_id'));
|
299 |
+
return '<a href="'.$url.'" target="_blank">'.$value.'</a>';
|
300 |
+
}
|
301 |
+
|
302 |
+
public function callbackColumnAvailableQty($value, $row, $column, $isExport)
|
303 |
+
{
|
304 |
+
if (is_null($value) || $value === '') {
|
305 |
+
return Mage::helper('M2ePro')->__('N/A');
|
306 |
+
}
|
307 |
+
|
308 |
+
if ((bool)$row->getData('is_afn_channel')) {
|
309 |
+
return '--';
|
310 |
+
}
|
311 |
+
|
312 |
+
if ($value <= 0) {
|
313 |
+
return '<span style="color: red;">0</span>';
|
314 |
+
}
|
315 |
+
|
316 |
+
return $value;
|
317 |
+
}
|
318 |
+
|
319 |
+
public function callbackColumnPrice($value, $row, $column, $isExport)
|
320 |
+
{
|
321 |
+
if (is_null($value) || $value === '') {
|
322 |
+
return Mage::helper('M2ePro')->__('N/A');
|
323 |
+
}
|
324 |
+
|
325 |
+
if ((float)$value <= 0) {
|
326 |
+
return '<span style="color: #f00;">0</span>';
|
327 |
+
}
|
328 |
+
|
329 |
+
$currency = Mage::helper('M2ePro/Component_Amazon')
|
330 |
+
->getCachedObject('Marketplace',$row->getData('marketplace_id'))
|
331 |
+
->getChildObject()
|
332 |
+
->getDefaultCurrency();
|
333 |
+
|
334 |
+
return Mage::app()->getLocale()->currency($currency)->toCurrency($value);
|
335 |
+
}
|
336 |
+
|
337 |
+
public function callbackColumnAfnChannel($value, $row, $column, $isExport)
|
338 |
+
{
|
339 |
+
switch ($row->getData('is_afn_channel')) {
|
340 |
+
case Ess_M2ePro_Model_Amazon_Listing_Product::IS_ISBN_GENERAL_ID_YES:
|
341 |
+
$value = '<span style="font-weight: bold;">' . $value . '</span>';
|
342 |
+
break;
|
343 |
+
|
344 |
+
default:
|
345 |
+
break;
|
346 |
+
}
|
347 |
+
|
348 |
+
return $value;
|
349 |
+
}
|
350 |
+
|
351 |
+
public function callbackColumnStatus($value, $row, $column, $isExport)
|
352 |
+
{
|
353 |
+
switch ($row->getData('status')) {
|
354 |
+
|
355 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_UNKNOWN:
|
356 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED:
|
357 |
+
$value = '<span style="color: gray;">' . $value . '</span>';
|
358 |
+
break;
|
359 |
+
|
360 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_LISTED:
|
361 |
+
$value = '<span style="color: green;">' . $value . '</span>';
|
362 |
+
break;
|
363 |
+
|
364 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED:
|
365 |
+
$value = '<span style="color: red;">' . $value . '</span>';
|
366 |
+
break;
|
367 |
+
|
368 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_BLOCKED:
|
369 |
+
$value = '<span style="color: orange; font-weight: bold;">' . $value . '</span>';
|
370 |
+
break;
|
371 |
+
|
372 |
+
default:
|
373 |
+
break;
|
374 |
+
}
|
375 |
+
|
376 |
+
return $value.$this->getViewLogIconHtml($row->getId());
|
377 |
+
}
|
378 |
+
|
379 |
+
protected function callbackFilterTitle($collection, $column)
|
380 |
+
{
|
381 |
+
$value = $column->getFilter()->getValue();
|
382 |
+
|
383 |
+
if ($value == null) {
|
384 |
+
return;
|
385 |
+
}
|
386 |
+
|
387 |
+
$collection->getSelect()->where('second_table.title LIKE ? OR second_table.sku LIKE ?', '%'.$value.'%');
|
388 |
+
}
|
389 |
+
|
390 |
+
// ####################################
|
391 |
+
|
392 |
+
public function getViewLogIconHtml($listingOtherId)
|
393 |
+
{
|
394 |
+
$listingOtherId = (int)$listingOtherId;
|
395 |
+
|
396 |
+
// Get last messages
|
397 |
+
//--------------------------
|
398 |
+
$dbSelect = $this->connRead->select()
|
399 |
+
->from(
|
400 |
+
Mage::getResourceModel('M2ePro/Listing_Other_Log')->getMainTable(),
|
401 |
+
array('action_id','action','type','description','create_date','initiator')
|
402 |
+
)
|
403 |
+
->where('`listing_other_id` = ?', $listingOtherId)
|
404 |
+
->where('`action_id` IS NOT NULL')
|
405 |
+
->order(array('id DESC'))
|
406 |
+
->limit(30);
|
407 |
+
|
408 |
+
$logRows = $this->connRead->fetchAll($dbSelect);
|
409 |
+
//--------------------------
|
410 |
+
|
411 |
+
// Get grouped messages by action_id
|
412 |
+
//--------------------------
|
413 |
+
$actionsRows = array();
|
414 |
+
$tempActionRows = array();
|
415 |
+
$lastActionId = false;
|
416 |
+
|
417 |
+
foreach ($logRows as $row) {
|
418 |
+
|
419 |
+
$row['description'] = Mage::helper('M2ePro/View')->getModifiedLogMessage($row['description']);
|
420 |
+
|
421 |
+
if ($row['action_id'] !== $lastActionId) {
|
422 |
+
if (count($tempActionRows) > 0) {
|
423 |
+
$actionsRows[] = array(
|
424 |
+
'type' => $this->getMainTypeForActionId($tempActionRows),
|
425 |
+
'date' => $this->getMainDateForActionId($tempActionRows),
|
426 |
+
'action' => $this->getActionForAction($tempActionRows[0]),
|
427 |
+
'initiator' => $this->getInitiatorForAction($tempActionRows[0]),
|
428 |
+
'items' => $tempActionRows
|
429 |
+
);
|
430 |
+
$tempActionRows = array();
|
431 |
+
}
|
432 |
+
$lastActionId = $row['action_id'];
|
433 |
+
}
|
434 |
+
$tempActionRows[] = $row;
|
435 |
+
}
|
436 |
+
|
437 |
+
if (count($tempActionRows) > 0) {
|
438 |
+
$actionsRows[] = array(
|
439 |
+
'type' => $this->getMainTypeForActionId($tempActionRows),
|
440 |
+
'date' => $this->getMainDateForActionId($tempActionRows),
|
441 |
+
'action' => $this->getActionForAction($tempActionRows[0]),
|
442 |
+
'initiator' => $this->getInitiatorForAction($tempActionRows[0]),
|
443 |
+
'items' => $tempActionRows
|
444 |
+
);
|
445 |
+
}
|
446 |
+
|
447 |
+
if (count($actionsRows) <= 0) {
|
448 |
+
return '';
|
449 |
+
}
|
450 |
+
|
451 |
+
$tips = array(
|
452 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'Last action was completed successfully.',
|
453 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'Last action was completed with error(s).',
|
454 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'Last action was completed with warning(s).'
|
455 |
+
);
|
456 |
+
|
457 |
+
$icons = array(
|
458 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'normal',
|
459 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'error',
|
460 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'warning'
|
461 |
+
);
|
462 |
+
|
463 |
+
$summary = $this->getLayout()->createBlock('M2ePro/adminhtml_log_grid_summary', '', array(
|
464 |
+
'entity_id' => $listingOtherId,
|
465 |
+
'rows' => $actionsRows,
|
466 |
+
'tips' => $tips,
|
467 |
+
'icons' => $icons,
|
468 |
+
'view_help_handler' => 'AmazonListingOtherGridHandlerObj.viewItemHelp',
|
469 |
+
'hide_help_handler' => 'AmazonListingOtherGridHandlerObj.hideItemHelp',
|
470 |
+
));
|
471 |
+
|
472 |
+
return $summary->toHtml();
|
473 |
+
}
|
474 |
+
|
475 |
+
public function getActionForAction($actionRows)
|
476 |
+
{
|
477 |
+
$string = '';
|
478 |
+
|
479 |
+
switch ((int)$actionRows['action']) {
|
480 |
+
case Ess_M2ePro_Model_Listing_Other_Log::ACTION_CHANGE_STATUS_ON_CHANNEL:
|
481 |
+
$string = Mage::helper('M2ePro')->__('Status Change');
|
482 |
+
break;
|
483 |
+
}
|
484 |
+
|
485 |
+
return $string;
|
486 |
+
}
|
487 |
+
|
488 |
+
public function getInitiatorForAction($actionRows)
|
489 |
+
{
|
490 |
+
$string = '';
|
491 |
+
|
492 |
+
switch ($actionRows['initiator']) {
|
493 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_UNKNOWN:
|
494 |
+
$string = '';
|
495 |
+
break;
|
496 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_USER:
|
497 |
+
$string = Mage::helper('M2ePro')->__('Manual');
|
498 |
+
break;
|
499 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION:
|
500 |
+
$string = Mage::helper('M2ePro')->__('Automatic');
|
501 |
+
break;
|
502 |
+
}
|
503 |
+
|
504 |
+
return $string;
|
505 |
+
}
|
506 |
+
|
507 |
+
public function getMainTypeForActionId($actionRows)
|
508 |
+
{
|
509 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS;
|
510 |
+
|
511 |
+
foreach ($actionRows as $row) {
|
512 |
+
if ($row['type'] == Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR) {
|
513 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR;
|
514 |
+
break;
|
515 |
+
}
|
516 |
+
if ($row['type'] == Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING) {
|
517 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING;
|
518 |
+
}
|
519 |
+
}
|
520 |
+
|
521 |
+
return $type;
|
522 |
+
}
|
523 |
+
|
524 |
+
public function getMainDateForActionId($actionRows)
|
525 |
+
{
|
526 |
+
$format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
|
527 |
+
return Mage::app()->getLocale()->date(strtotime($actionRows[0]['create_date']))->toString($format);
|
528 |
+
}
|
529 |
+
|
530 |
+
// ####################################
|
531 |
+
|
532 |
+
protected function _toHtml()
|
533 |
+
{
|
534 |
+
$javascriptsMain = <<<JAVASCRIPT
|
535 |
+
<script type="text/javascript">
|
536 |
+
|
537 |
+
if (typeof AmazonListingOtherGridHandlerObj != 'undefined') {
|
538 |
+
AmazonListingOtherGridHandlerObj.afterInitPage();
|
539 |
+
}
|
540 |
+
|
541 |
+
Event.observe(window, 'load', function() {
|
542 |
+
setTimeout(function() {
|
543 |
+
AmazonListingOtherGridHandlerObj.afterInitPage();
|
544 |
+
}, 350);
|
545 |
+
});
|
546 |
+
|
547 |
+
</script>
|
548 |
+
JAVASCRIPT;
|
549 |
+
|
550 |
+
return parent::_toHtml().$javascriptsMain;
|
551 |
+
}
|
552 |
+
|
553 |
+
// ####################################
|
554 |
+
|
555 |
+
public function getGridUrl()
|
556 |
+
{
|
557 |
+
return $this->getUrl('*/adminhtml_common_amazon_listing_other/grid', array('_current' => true));
|
558 |
+
}
|
559 |
+
|
560 |
+
public function getRowUrl($row)
|
561 |
+
{
|
562 |
+
return false;
|
563 |
+
}
|
564 |
+
|
565 |
+
// ####################################
|
566 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Other/Help.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_Other_Help extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonListingOtherHelp');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/amazon/listing/other/help.phtml');
|
19 |
+
}
|
20 |
+
|
21 |
+
public function getContainerId()
|
22 |
+
{
|
23 |
+
return 'block_notice_amazon_listings';
|
24 |
+
}
|
25 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Product.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_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')->__(Ess_M2ePro_Helper_Component_Amazon::TITLE),
|
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('reset', array(
|
77 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
78 |
+
'onclick' => 'ProductGridHandlerObj.reset_click()',
|
79 |
+
'class' => 'reset'
|
80 |
+
));
|
81 |
+
//------------------------------
|
82 |
+
|
83 |
+
//------------------------------
|
84 |
+
$this->_addButton('save', array(
|
85 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
86 |
+
'onclick' => 'ProductGridHandlerObj.save_click(\'view\')',
|
87 |
+
'class' => 'save'
|
88 |
+
));
|
89 |
+
//------------------------------
|
90 |
+
}
|
91 |
+
|
92 |
+
public function getGridHtml()
|
93 |
+
{
|
94 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_listing_product_help');
|
95 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
96 |
+
}
|
97 |
+
|
98 |
+
protected function _toHtml()
|
99 |
+
{
|
100 |
+
return '<div id="add_products_progress_bar"></div>'.
|
101 |
+
'<div id="add_products_container">'.
|
102 |
+
parent::_toHtml().
|
103 |
+
'</div>';
|
104 |
+
}
|
105 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Product/Category.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_Amazon_Listing_Product_Category extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonListingProductCategory');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_amazon_listing';
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$this->setTemplate('widget/view/container.phtml');
|
21 |
+
|
22 |
+
// Set header text
|
23 |
+
//------------------------------
|
24 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
25 |
+
|
26 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
27 |
+
$headerText = Mage::helper('M2ePro')->__(
|
28 |
+
'Add Products To %component_name% Listing "%listing_title%" From Categories',
|
29 |
+
Mage::helper('M2ePro')->__(Ess_M2ePro_Helper_Component_Amazon::TITLE),
|
30 |
+
$this->escapeHtml($listingData['title'])
|
31 |
+
);
|
32 |
+
} else {
|
33 |
+
$headerText = Mage::helper('M2ePro')->__(
|
34 |
+
'Add Products To Listing "%listing_title%" From Categories',
|
35 |
+
$this->escapeHtml($listingData['title'])
|
36 |
+
);
|
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 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
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' => 'AmazonListingCategoryHandlerObj.back_click(\'' . $url . '\')',
|
65 |
+
'class' => 'back'
|
66 |
+
));
|
67 |
+
//------------------------------
|
68 |
+
} else {
|
69 |
+
//------------------------------
|
70 |
+
$url = $this->getUrl('*/adminhtml_common_amazon_listing/view', array('id' => $listingData['id']));
|
71 |
+
$this->_addButton('view_listing', array(
|
72 |
+
'label' => Mage::helper('M2ePro')->__('View Listing'),
|
73 |
+
'onclick' => 'setLocation(\''.$url.'\')',
|
74 |
+
'class' => 'button_link'
|
75 |
+
));
|
76 |
+
//------------------------------
|
77 |
+
}
|
78 |
+
|
79 |
+
//------------------------------
|
80 |
+
$this->_addButton('reset', array(
|
81 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
82 |
+
'onclick' => 'AmazonListingCategoryHandlerObj.reset_click()',
|
83 |
+
'class' => 'reset'
|
84 |
+
));
|
85 |
+
//------------------------------
|
86 |
+
|
87 |
+
//------------------------------
|
88 |
+
$url = $this->getUrl(
|
89 |
+
'*/adminhtml_common_amazon_listing/categoryProduct',
|
90 |
+
array(
|
91 |
+
'id' => $listingData['id'],
|
92 |
+
'add_products' => 'yes',
|
93 |
+
'next' => 'yes'
|
94 |
+
)
|
95 |
+
);
|
96 |
+
$this->_addButton('save_and_next', array(
|
97 |
+
'label' => Mage::helper('M2ePro')->__('Next'),
|
98 |
+
'onclick' => 'AmazonListingCategoryHandlerObj.save_click(\''.$url.'\')',
|
99 |
+
'class' => 'next save_and_next_button'
|
100 |
+
));
|
101 |
+
//------------------------------
|
102 |
+
|
103 |
+
//$url = $this->getUrl('*/adminhtml_common_amazon_listing/product',array(
|
104 |
+
// 'id' => $listingData['id'],
|
105 |
+
// 'back' => Mage::helper('M2ePro')->getBackUrlParam('*/adminhtml_listing/index')
|
106 |
+
//));
|
107 |
+
//$this->_addButton('save_and_list', array(
|
108 |
+
// 'label' => Mage::helper('M2ePro')->__('Save And List'),
|
109 |
+
// 'onclick' => 'AmazonListingCategoryHandlerObj.save_and_list_click(\''.$url.'\')',
|
110 |
+
// 'class' => 'save save_and_list_button'
|
111 |
+
//));
|
112 |
+
|
113 |
+
//------------------------------
|
114 |
+
$url = $this->getUrl('*/adminhtml_common_amazon_listing/add', array('add_products' => 'yes'));
|
115 |
+
$this->_addButton('save_and_go_to_listing_view', array(
|
116 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
117 |
+
'onclick' => 'AmazonListingCategoryHandlerObj.save_click(\'' . $url .'\')',
|
118 |
+
'class' => 'save save_and_go_to_listings_view_button'
|
119 |
+
));
|
120 |
+
//------------------------------
|
121 |
+
}
|
122 |
+
|
123 |
+
protected function _toHtml()
|
124 |
+
{
|
125 |
+
$treeSettings = array(
|
126 |
+
'show_products_amount' => true,
|
127 |
+
'hide_products_this_listing' => true
|
128 |
+
);
|
129 |
+
// todo next
|
130 |
+
$categoryTreeBlock = $this->getLayout()->createBlock(
|
131 |
+
'M2ePro/adminhtml_common_listing_category_tree',
|
132 |
+
'',
|
133 |
+
array(
|
134 |
+
'component' => Ess_M2ePro_Helper_Component_Amazon::NICK,
|
135 |
+
'tree_settings' => $treeSettings
|
136 |
+
)
|
137 |
+
);
|
138 |
+
|
139 |
+
$helpBlock = $this->getLayout()
|
140 |
+
->createBlock('M2ePro/adminhtml_common_amazon_listing_product_category_help');
|
141 |
+
|
142 |
+
$categoryBlock = $this->getLayout()
|
143 |
+
->createBlock('M2ePro/adminhtml_common_amazon_listing_product_category_edit');
|
144 |
+
|
145 |
+
return '<div id="add_products_progress_bar"></div>'.
|
146 |
+
'<div id="add_products_container">'.
|
147 |
+
parent::_toHtml() . $helpBlock->toHtml() . $categoryTreeBlock->toHtml() . $categoryBlock->toHtml().
|
148 |
+
'</div>';
|
149 |
+
}
|
150 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Product/Category/Edit.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_Category_Edit extends Mage_Adminhtml_Block_Template
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonListingProductCategory');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/amazon/listing/product/category/edit.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Product/Category/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_Category_Help extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonListingProductCategoryHelp');
|
16 |
+
//------------------------------
|
17 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Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_Product_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('amazonListingProductGrid'.(isset($listingData['id'])?$listingData['id']:''));
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
// Set default values
|
21 |
+
//------------------------------
|
22 |
+
$this->setDefaultSort('product_id');
|
23 |
+
$this->setDefaultDir('DESC');
|
24 |
+
$this->setSaveParametersInSession(true);
|
25 |
+
$this->setUseAjax(true);
|
26 |
+
//------------------------------
|
27 |
+
|
28 |
+
$this->isAjax = json_encode($this->getRequest()->isXmlHttpRequest());
|
29 |
+
}
|
30 |
+
|
31 |
+
// ####################################
|
32 |
+
|
33 |
+
protected function _prepareCollection()
|
34 |
+
{
|
35 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
36 |
+
|
37 |
+
// Get collection
|
38 |
+
//----------------------------
|
39 |
+
/* @var $collection Mage_Catalog_Model_Resource_Product_Collection */
|
40 |
+
$collection = Mage::getModel('catalog/product')->getCollection()
|
41 |
+
->addAttributeToSelect('sku')
|
42 |
+
->addAttributeToSelect('name')
|
43 |
+
->addAttributeToSelect('attribute_set_id')
|
44 |
+
->addAttributeToSelect('type_id')
|
45 |
+
->joinField('qty',
|
46 |
+
'cataloginventory/stock_item',
|
47 |
+
'qty',
|
48 |
+
'product_id=entity_id',
|
49 |
+
'{{table}}.stock_id=1',
|
50 |
+
'left')
|
51 |
+
->joinField('is_in_stock',
|
52 |
+
'cataloginventory/stock_item',
|
53 |
+
'is_in_stock',
|
54 |
+
'product_id=entity_id',
|
55 |
+
'{{table}}.stock_id=1',
|
56 |
+
'left');
|
57 |
+
|
58 |
+
/*$collection->getSelect()->joinLeft(
|
59 |
+
array('cisi' => Mage::getSingleton('core/resource')->getTableName('cataloginventory/stock_item')),
|
60 |
+
'(cisi.product_id = e.entity_id) AND (cisi.stock_id = 1)',
|
61 |
+
array('qty','is_in_stock')
|
62 |
+
);*/
|
63 |
+
//----------------------------
|
64 |
+
|
65 |
+
//----------------------------
|
66 |
+
$collection->getSelect()->distinct();
|
67 |
+
//----------------------------
|
68 |
+
|
69 |
+
// Add attribute set filter
|
70 |
+
//----------------------------
|
71 |
+
$collection->addFieldToFilter('attribute_set_id', array('in' => $listingData['attribute_sets']));
|
72 |
+
//----------------------------
|
73 |
+
|
74 |
+
// Set filter store
|
75 |
+
//----------------------------
|
76 |
+
$store = $this->_getStore();
|
77 |
+
|
78 |
+
if ($store->getId()) {
|
79 |
+
$collection->addStoreFilter($store);
|
80 |
+
$collection->joinAttribute('custom_name',
|
81 |
+
'catalog_product/name',
|
82 |
+
'entity_id',
|
83 |
+
null,
|
84 |
+
'inner',
|
85 |
+
$store->getId());
|
86 |
+
$collection->joinAttribute('status',
|
87 |
+
'catalog_product/status',
|
88 |
+
'entity_id',
|
89 |
+
null,
|
90 |
+
'inner',
|
91 |
+
$store->getId());
|
92 |
+
$collection->joinAttribute('visibility',
|
93 |
+
'catalog_product/visibility',
|
94 |
+
'entity_id',
|
95 |
+
null,
|
96 |
+
'inner',
|
97 |
+
$store->getId());
|
98 |
+
$collection->joinAttribute('price',
|
99 |
+
'catalog_product/price',
|
100 |
+
'entity_id',
|
101 |
+
null,
|
102 |
+
'left',
|
103 |
+
$store->getId());
|
104 |
+
$collection->joinAttribute('thumbnail',
|
105 |
+
'catalog_product/thumbnail',
|
106 |
+
'entity_id',
|
107 |
+
null,
|
108 |
+
'left',
|
109 |
+
$store->getId());
|
110 |
+
} else {
|
111 |
+
$collection->addAttributeToSelect('price');
|
112 |
+
$collection->addAttributeToSelect('status');
|
113 |
+
$collection->addAttributeToSelect('visibility');
|
114 |
+
$collection->addAttributeToSelect('thumbnail');
|
115 |
+
}
|
116 |
+
//----------------------------
|
117 |
+
|
118 |
+
// Hide products others listings
|
119 |
+
//----------------------------
|
120 |
+
$prefix = Mage::helper('M2ePro/Data_Global')->getValue('hide_products_others_listings_prefix');
|
121 |
+
is_null($hideParam = Mage::helper('M2ePro/Data_Session')->getValue($prefix)) && $hideParam = true;
|
122 |
+
|
123 |
+
if ($hideParam || isset($listingData['id'])) {
|
124 |
+
|
125 |
+
$dbExcludeSelect = Mage::getResourceModel('core/config')->getReadConnection()
|
126 |
+
->select()
|
127 |
+
->from(Mage::getResourceModel('M2ePro/Listing_Product')->getMainTable(),
|
128 |
+
new Zend_Db_Expr('DISTINCT `product_id`'));
|
129 |
+
|
130 |
+
if ($hideParam) {
|
131 |
+
|
132 |
+
$dbExcludeSelect->join(
|
133 |
+
array('l' => Mage::getResourceModel('M2ePro/Listing')->getMainTable()),
|
134 |
+
'`l`.`id` = `listing_id`', NULL
|
135 |
+
);
|
136 |
+
|
137 |
+
$dbExcludeSelect->where('`l`.`account_id` = ?', $listingData['account_id']);
|
138 |
+
$dbExcludeSelect->where('`l`.`marketplace_id` = ?', $listingData['marketplace_id']);
|
139 |
+
$dbExcludeSelect->where('`l`.`component_mode` = ?',Ess_M2ePro_Helper_Component_Amazon::NICK);
|
140 |
+
|
141 |
+
} else {
|
142 |
+
$dbExcludeSelect->where('`listing_id` = ?',(int)$listingData['id']);
|
143 |
+
}
|
144 |
+
|
145 |
+
// default sql select
|
146 |
+
$collection->getSelect()
|
147 |
+
->joinLeft(array('sq' => $dbExcludeSelect), 'sq.product_id = e.entity_id', array())
|
148 |
+
->where('sq.product_id IS NULL');
|
149 |
+
|
150 |
+
// alternatively sql select (for mysql v.5.1)
|
151 |
+
// $collection->getSelect()->where('`e`.`entity_id` NOT IN ('.$dbExcludeSelect->__toString().')');
|
152 |
+
}
|
153 |
+
//----------------------------
|
154 |
+
|
155 |
+
// Add categories filter
|
156 |
+
//----------------------------
|
157 |
+
$categoriesData = Mage::helper('M2ePro/Data_Global')->getValue('temp_listing_categories');
|
158 |
+
|
159 |
+
if (count($categoriesData) > 0) {
|
160 |
+
$dbSelect = Mage::getResourceModel('core/config')->getReadConnection()
|
161 |
+
->select()
|
162 |
+
->from(Mage::getSingleton('core/resource')->getTableName('catalog_category_product'),
|
163 |
+
new Zend_Db_Expr('DISTINCT `product_id`'))
|
164 |
+
->where('`category_id` IN ('.implode(',',$categoriesData).')');
|
165 |
+
|
166 |
+
$collection->getSelect()->where('`e`.`entity_id` IN ('.$dbSelect->__toString().')');
|
167 |
+
}
|
168 |
+
//----------------------------
|
169 |
+
|
170 |
+
$collection->addFieldToFilter(
|
171 |
+
array(
|
172 |
+
array('attribute'=>'type_id','neq'=>'virtual'),
|
173 |
+
)
|
174 |
+
);
|
175 |
+
|
176 |
+
/** @var $ruleModel Ess_M2ePro_Model_Magento_Product_Rule */
|
177 |
+
$ruleModel = Mage::helper('M2ePro/Data_Global')->getValue('rule_model');
|
178 |
+
$ruleModel->setAttributesFilterToCollection($collection);
|
179 |
+
|
180 |
+
//exit($collection->getSelect()->__toString());
|
181 |
+
|
182 |
+
// Set collection to grid
|
183 |
+
$this->setCollection($collection);
|
184 |
+
|
185 |
+
parent::_prepareCollection();
|
186 |
+
$this->getCollection()->addWebsiteNamesToResult();
|
187 |
+
|
188 |
+
return $this;
|
189 |
+
}
|
190 |
+
|
191 |
+
protected function _prepareColumns()
|
192 |
+
{
|
193 |
+
$this->addColumn('product_id', array(
|
194 |
+
'header' => Mage::helper('M2ePro')->__('Product ID'),
|
195 |
+
'align' => 'right',
|
196 |
+
'width' => '100px',
|
197 |
+
'type' => 'number',
|
198 |
+
'index' => 'entity_id',
|
199 |
+
'filter_index' => 'entity_id',
|
200 |
+
'frame_callback' => array($this, 'callbackColumnProductId')
|
201 |
+
));
|
202 |
+
|
203 |
+
$this->addColumn('name', array(
|
204 |
+
'header' => Mage::helper('M2ePro')->__('Product Title'),
|
205 |
+
'align' => 'left',
|
206 |
+
//'width' => '100px',
|
207 |
+
'type' => 'text',
|
208 |
+
'index' => 'name',
|
209 |
+
'filter_index' => 'name',
|
210 |
+
'frame_callback' => array($this, 'callbackColumnProductTitle')
|
211 |
+
));
|
212 |
+
|
213 |
+
$tempTypes = Mage::getSingleton('catalog/product_type')->getOptionArray();
|
214 |
+
if (isset($tempTypes['virtual'])) {
|
215 |
+
unset($tempTypes['virtual']);
|
216 |
+
}
|
217 |
+
|
218 |
+
$this->addColumn('type', array(
|
219 |
+
'header' => Mage::helper('M2ePro')->__('Type'),
|
220 |
+
'align' => 'left',
|
221 |
+
'width' => '90px',
|
222 |
+
'type' => 'options',
|
223 |
+
'sortable' => false,
|
224 |
+
'index' => 'type_id',
|
225 |
+
'filter_index' => 'type_id',
|
226 |
+
'options' => $tempTypes
|
227 |
+
));
|
228 |
+
|
229 |
+
$this->addColumn('is_in_stock', array(
|
230 |
+
'header' => Mage::helper('M2ePro')->__('Stock Availability'),
|
231 |
+
'align' => 'left',
|
232 |
+
'width' => '90px',
|
233 |
+
'type' => 'options',
|
234 |
+
'sortable' => false,
|
235 |
+
'index' => 'is_in_stock',
|
236 |
+
'filter_index' => 'is_in_stock',
|
237 |
+
'options' => array(
|
238 |
+
'1' => Mage::helper('M2ePro')->__('In Stock'),
|
239 |
+
'0' => Mage::helper('M2ePro')->__('Out of Stock')
|
240 |
+
),
|
241 |
+
'frame_callback' => array($this, 'callbackColumnIsInStock')
|
242 |
+
));
|
243 |
+
|
244 |
+
$this->addColumn('sku', array(
|
245 |
+
'header' => Mage::helper('M2ePro')->__('SKU'),
|
246 |
+
'align' => 'left',
|
247 |
+
'width' => '90px',
|
248 |
+
'type' => 'text',
|
249 |
+
'index' => 'sku',
|
250 |
+
'filter_index' => 'sku'
|
251 |
+
));
|
252 |
+
|
253 |
+
$store = $this->_getStore();
|
254 |
+
|
255 |
+
$this->addColumn('price', array(
|
256 |
+
'header' => Mage::helper('M2ePro')->__('Price'),
|
257 |
+
'align' => 'right',
|
258 |
+
'width' => '100px',
|
259 |
+
'type' => 'price',
|
260 |
+
'currency_code' => $store->getBaseCurrency()->getCode(),
|
261 |
+
'index' => 'price',
|
262 |
+
'filter_index' => 'price',
|
263 |
+
'frame_callback' => array($this, 'callbackColumnPrice')
|
264 |
+
));
|
265 |
+
|
266 |
+
$this->addColumn('qty', array(
|
267 |
+
'header' => Mage::helper('M2ePro')->__('Qty'),
|
268 |
+
'align' => 'right',
|
269 |
+
'width' => '100px',
|
270 |
+
'type' => 'number',
|
271 |
+
'index' => 'qty',
|
272 |
+
'filter_index' => 'qty',
|
273 |
+
'frame_callback' => array($this, 'callbackColumnQty')
|
274 |
+
));
|
275 |
+
|
276 |
+
$this->addColumn('visibility', array(
|
277 |
+
'header' => Mage::helper('M2ePro')->__('Visibility'),
|
278 |
+
'align' => 'left',
|
279 |
+
'width' => '90px',
|
280 |
+
'type' => 'options',
|
281 |
+
'sortable' => false,
|
282 |
+
'index' => 'visibility',
|
283 |
+
'filter_index' => 'visibility',
|
284 |
+
'options' => Mage::getModel('catalog/product_visibility')->getOptionArray()
|
285 |
+
));
|
286 |
+
|
287 |
+
$this->addColumn('status', array(
|
288 |
+
'header' => Mage::helper('M2ePro')->__('Status'),
|
289 |
+
'align' => 'left',
|
290 |
+
'width' => '90px',
|
291 |
+
'type' => 'options',
|
292 |
+
'sortable' => false,
|
293 |
+
'index' => 'status',
|
294 |
+
'filter_index' => 'status',
|
295 |
+
'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
|
296 |
+
'frame_callback' => array($this, 'callbackColumnStatus')
|
297 |
+
));
|
298 |
+
|
299 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
300 |
+
|
301 |
+
$this->addColumn('websites', array(
|
302 |
+
'header' => Mage::helper('M2ePro')->__('Websites'),
|
303 |
+
'align' => 'left',
|
304 |
+
'width' => '90px',
|
305 |
+
'type' => 'options',
|
306 |
+
'sortable' => false,
|
307 |
+
'index' => 'websites',
|
308 |
+
'filter_index' => 'websites',
|
309 |
+
'options' => Mage::getModel('core/website')->getCollection()->toOptionHash()
|
310 |
+
));
|
311 |
+
}
|
312 |
+
|
313 |
+
return parent::_prepareColumns();
|
314 |
+
}
|
315 |
+
|
316 |
+
protected function _prepareMassaction()
|
317 |
+
{
|
318 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
319 |
+
|
320 |
+
// Set massaction identifiers
|
321 |
+
//--------------------------------
|
322 |
+
$this->setMassactionIdField('entity_id');
|
323 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
324 |
+
//--------------------------------
|
325 |
+
|
326 |
+
// Set fake action
|
327 |
+
//--------------------------------
|
328 |
+
$this->getMassactionBlock()->addItem('attributes', array(
|
329 |
+
'label' => ' ',
|
330 |
+
'url' => $this->getUrl('*/adminhtml_common_amazon_listing/massStatus', array('_current'=>true)),
|
331 |
+
));
|
332 |
+
//--------------------------------
|
333 |
+
|
334 |
+
return parent::_prepareMassaction();
|
335 |
+
}
|
336 |
+
|
337 |
+
public function getMassactionBlockHtml()
|
338 |
+
{
|
339 |
+
$advancedFilterBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_listing_product_rule');
|
340 |
+
$advancedFilterBlock->setShowHideProductsOption();
|
341 |
+
$advancedFilterBlock->setGridJsObjectName($this->getJsObjectName());
|
342 |
+
|
343 |
+
return $advancedFilterBlock->toHtml() . parent::getMassactionBlockHtml();
|
344 |
+
}
|
345 |
+
|
346 |
+
// ####################################
|
347 |
+
|
348 |
+
public function callbackColumnProductId($value, $row, $column, $isExport)
|
349 |
+
{
|
350 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
351 |
+
|
352 |
+
$productId = (int)$value;
|
353 |
+
$storeId = (int)$listingData['store_id'];
|
354 |
+
|
355 |
+
$withoutImageHtml = '<a href="'
|
356 |
+
.$this->getUrl('adminhtml/catalog_product/edit',
|
357 |
+
array('id' => $productId))
|
358 |
+
.'" target="_blank">'
|
359 |
+
.$productId
|
360 |
+
.'</a>';
|
361 |
+
|
362 |
+
$showProductsThumbnails = (bool)(int)Mage::helper('M2ePro/Module')
|
363 |
+
->getConfig()
|
364 |
+
->getGroupValue('/view/','show_products_thumbnails');
|
365 |
+
if (!$showProductsThumbnails) {
|
366 |
+
return $withoutImageHtml;
|
367 |
+
}
|
368 |
+
|
369 |
+
/** @var $magentoProduct Ess_M2ePro_Model_Magento_Product */
|
370 |
+
$magentoProduct = Mage::getModel('M2ePro/Magento_Product');
|
371 |
+
$magentoProduct->setProductId($productId);
|
372 |
+
$magentoProduct->setStoreId($storeId);
|
373 |
+
|
374 |
+
$imageUrlResized = $magentoProduct->getThumbnailImageLink();
|
375 |
+
if (is_null($imageUrlResized)) {
|
376 |
+
return $withoutImageHtml;
|
377 |
+
}
|
378 |
+
|
379 |
+
$imageHtml = $productId.'<hr/><img src="'.$imageUrlResized.'" />';
|
380 |
+
$withImageHtml = str_replace('>'.$productId.'<','>'.$imageHtml.'<',$withoutImageHtml);
|
381 |
+
|
382 |
+
return $withImageHtml;
|
383 |
+
}
|
384 |
+
|
385 |
+
public function callbackColumnProductTitle($value, $row, $column, $isExport)
|
386 |
+
{
|
387 |
+
if (strlen($value) > 60) {
|
388 |
+
return substr($value, 0, 60) . '...';
|
389 |
+
}
|
390 |
+
return Mage::helper('M2ePro')->escapeHtml($value);
|
391 |
+
}
|
392 |
+
|
393 |
+
public function callbackColumnIsInStock($value, $row, $column, $isExport)
|
394 |
+
{
|
395 |
+
if ((int)$row->getData('is_in_stock') <= 0) {
|
396 |
+
return '<span style="color: red;">'.$value.'</span>';
|
397 |
+
}
|
398 |
+
|
399 |
+
return $value;
|
400 |
+
}
|
401 |
+
|
402 |
+
public function callbackColumnPrice($value, $row, $column, $isExport)
|
403 |
+
{
|
404 |
+
$rowVal = $row->getData();
|
405 |
+
|
406 |
+
if (!isset($rowVal['price']) || (float)$rowVal['price'] <= 0) {
|
407 |
+
$value = 0;
|
408 |
+
$value = '<span style="color: red;">'.$value.'</span>';
|
409 |
+
}
|
410 |
+
return $value;
|
411 |
+
}
|
412 |
+
|
413 |
+
public function callbackColumnQty($value, $row, $column, $isExport)
|
414 |
+
{
|
415 |
+
if ($value <= 0) {
|
416 |
+
$value = 0;
|
417 |
+
$value = '<span style="color: red;">'.$value.'</span>';
|
418 |
+
}
|
419 |
+
|
420 |
+
return $value;
|
421 |
+
}
|
422 |
+
|
423 |
+
public function callbackColumnStatus($value, $row, $column, $isExport)
|
424 |
+
{
|
425 |
+
if ($row->getData('status') == Mage_Catalog_Model_Product_Status::STATUS_DISABLED) {
|
426 |
+
$value = '<span style="color: red;">'.$value.'</span>';
|
427 |
+
}
|
428 |
+
|
429 |
+
return $value;
|
430 |
+
}
|
431 |
+
|
432 |
+
// ####################################
|
433 |
+
|
434 |
+
protected function _addColumnFilterToCollection($column)
|
435 |
+
{
|
436 |
+
if ($this->getCollection()) {
|
437 |
+
if ($column->getId() == 'websites') {
|
438 |
+
$this->getCollection()->joinField('websites',
|
439 |
+
'catalog/product_website',
|
440 |
+
'website_id',
|
441 |
+
'product_id=entity_id',
|
442 |
+
null,
|
443 |
+
'left');
|
444 |
+
}
|
445 |
+
}
|
446 |
+
return parent::_addColumnFilterToCollection($column);
|
447 |
+
}
|
448 |
+
|
449 |
+
protected function _getStore()
|
450 |
+
{
|
451 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
452 |
+
|
453 |
+
// Get store filter
|
454 |
+
//----------------------------
|
455 |
+
$storeId = 0;
|
456 |
+
if (isset($listingData['store_id'])) {
|
457 |
+
$storeId = (int)$listingData['store_id'];
|
458 |
+
}
|
459 |
+
//----------------------------
|
460 |
+
|
461 |
+
return Mage::app()->getStore((int)$storeId);
|
462 |
+
}
|
463 |
+
|
464 |
+
public function getGridUrl()
|
465 |
+
{
|
466 |
+
return $this->getUrl('*/adminhtml_common_amazon_listing/productGrid', array('_current'=>true));
|
467 |
+
}
|
468 |
+
|
469 |
+
public function getRowUrl($row)
|
470 |
+
{
|
471 |
+
return false;
|
472 |
+
}
|
473 |
+
|
474 |
+
// ####################################
|
475 |
+
|
476 |
+
protected function _toHtml()
|
477 |
+
{
|
478 |
+
$cssBefore = <<<STYLE
|
479 |
+
<style type="text/css">
|
480 |
+
table.massaction div.right {
|
481 |
+
display: none;
|
482 |
+
}
|
483 |
+
</style>
|
484 |
+
STYLE;
|
485 |
+
|
486 |
+
$helper = Mage::helper('M2ePro');
|
487 |
+
|
488 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
489 |
+
$suffixGridId = isset($listingData['id']) ? $listingData['id'] : '';
|
490 |
+
|
491 |
+
$isShowRuleBlock = json_encode($this->isShowRuleBlock());
|
492 |
+
|
493 |
+
$selectItemsMessage = $helper->escapeJs(
|
494 |
+
$helper->__('Please select the products you want to perform the action on.')
|
495 |
+
);
|
496 |
+
$createEmptyListingMessage = $helper->escapeJs($helper->__('Are you sure you want to create empty listing?'));
|
497 |
+
|
498 |
+
$showAdvancedFilterButtonText = $helper->escapeJs($helper->__('Show Advanced Filter'));
|
499 |
+
$hideAdvancedFilterButtonText = $helper->escapeJs($helper->__('Hide Advanced Filter'));
|
500 |
+
|
501 |
+
$createListingUrl = $this->getUrl(
|
502 |
+
'*/adminhtml_common_amazon_listing/createListing'
|
503 |
+
);
|
504 |
+
$getProductsUrl = $this->getUrl(
|
505 |
+
'*/adminhtml_common_amazon_listing/getProductsFromCategories'
|
506 |
+
);
|
507 |
+
$addProductsUrl = $this->getUrl(
|
508 |
+
'*/adminhtml_common_amazon_listing/addProducts'
|
509 |
+
);
|
510 |
+
$backUrl = $this->getUrl('*/*/index');
|
511 |
+
|
512 |
+
$javascript = <<<JAVASCRIPT
|
513 |
+
<script type="text/javascript">
|
514 |
+
if (typeof M2ePro == 'undefined') {
|
515 |
+
M2ePro = {};
|
516 |
+
M2ePro.url = {};
|
517 |
+
M2ePro.formData = {};
|
518 |
+
M2ePro.customData = {};
|
519 |
+
M2ePro.text = {};
|
520 |
+
}
|
521 |
+
|
522 |
+
M2ePro.text.select_items_message = '{$selectItemsMessage}';
|
523 |
+
M2ePro.text.create_empty_listing_message = '{$createEmptyListingMessage}';
|
524 |
+
M2ePro.text.show_advanced_filter = '{$showAdvancedFilterButtonText}';
|
525 |
+
M2ePro.text.hide_advanced_filter = '{$hideAdvancedFilterButtonText}';
|
526 |
+
M2ePro.url.create_listing = '{$createListingUrl}';
|
527 |
+
M2ePro.url.get_products_from_categories = '{$getProductsUrl}';
|
528 |
+
M2ePro.url.add_products = '{$addProductsUrl}';
|
529 |
+
M2ePro.url.back = '{$backUrl}';
|
530 |
+
|
531 |
+
WrapperObj = new AreaWrapper('add_products_container');
|
532 |
+
ProgressBarObj = new ProgressBar('add_products_progress_bar');
|
533 |
+
AddListingObj = new AddListingHandler(M2ePro, ProgressBarObj, WrapperObj);
|
534 |
+
ProductGridHandlerObj = new ProductGridHandler(AddListingObj);
|
535 |
+
ProductGridHandlerObj.setGridId('amazonListingProductGrid{$suffixGridId}');
|
536 |
+
|
537 |
+
var init = function () {
|
538 |
+
amazonListingProductGrid{$suffixGridId}JsObject.doFilter = ProductGridHandlerObj.setFilter;
|
539 |
+
amazonListingProductGrid{$suffixGridId}JsObject.resetFilter = ProductGridHandlerObj.resetFilter;
|
540 |
+
if ({$isShowRuleBlock}) {
|
541 |
+
$('listing_product_rules').show();
|
542 |
+
if ($('advanced_filter_button')) {
|
543 |
+
$('advanced_filter_button').simulate('click');
|
544 |
+
}
|
545 |
+
}
|
546 |
+
}
|
547 |
+
|
548 |
+
{$this->isAjax} ? init()
|
549 |
+
: Event.observe(window, 'load', init);
|
550 |
+
</script>
|
551 |
+
JAVASCRIPT;
|
552 |
+
|
553 |
+
return $cssBefore.parent::_toHtml().$javascript;
|
554 |
+
}
|
555 |
+
|
556 |
+
// ####################################
|
557 |
+
|
558 |
+
public function getAdvancedFilterButtonHtml()
|
559 |
+
{
|
560 |
+
if (!$this->getChild('advanced_filter_button')) {
|
561 |
+
//------------------------------
|
562 |
+
$data = array(
|
563 |
+
'label' => Mage::helper('adminhtml')->__('Show Advanced Filter'),
|
564 |
+
'onclick' => 'ProductGridHandlerObj.advancedFilterToggle()',
|
565 |
+
'class' => 'task',
|
566 |
+
'id' => 'advanced_filter_button'
|
567 |
+
);
|
568 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
569 |
+
$this->setChild('advanced_filter_button', $buttonBlock);
|
570 |
+
//------------------------------
|
571 |
+
}
|
572 |
+
|
573 |
+
return $this->getChildHtml('advanced_filter_button');
|
574 |
+
}
|
575 |
+
|
576 |
+
public function getMainButtonsHtml()
|
577 |
+
{
|
578 |
+
$html = '';
|
579 |
+
if($this->getFilterVisibility()){
|
580 |
+
$html.= $this->getResetFilterButtonHtml();
|
581 |
+
if (!$this->isShowRuleBlock()) {
|
582 |
+
$html.= $this->getAdvancedFilterButtonHtml();
|
583 |
+
}
|
584 |
+
$html.= $this->getSearchButtonHtml();
|
585 |
+
}
|
586 |
+
return $html;
|
587 |
+
}
|
588 |
+
|
589 |
+
// ####################################
|
590 |
+
|
591 |
+
private function isShowRuleBlock()
|
592 |
+
{
|
593 |
+
$ruleData = Mage::helper('M2ePro/Data_Session')->getValue(
|
594 |
+
Mage::helper('M2ePro/Data_Global')->getValue('rule_prefix')
|
595 |
+
);
|
596 |
+
|
597 |
+
$showHideProductsOption = Mage::helper('M2ePro/Data_Session')->getValue(
|
598 |
+
Mage::helper('M2ePro/Data_Global')->getValue('hide_products_others_listings_prefix')
|
599 |
+
);
|
600 |
+
|
601 |
+
return !empty($ruleData) || is_null($showHideProductsOption) || $showHideProductsOption;
|
602 |
+
}
|
603 |
+
|
604 |
+
// ####################################
|
605 |
+
}
|
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,280 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
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
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
|
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('amazonProductSearchGrid');
|
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' => $item['general_id'],
|
42 |
+
'brand' => $item['brand'],
|
43 |
+
'title' => $item['title'],
|
44 |
+
'image_url' => $item['image_url'],
|
45 |
+
'price' => isset($item['list_price']['amount']) ? $item['list_price']['amount'] : null,
|
46 |
+
'is_variation_product' => $item['is_variation_product'],
|
47 |
+
);
|
48 |
+
|
49 |
+
if ($temp['is_variation_product']) {
|
50 |
+
$temp += array(
|
51 |
+
'parentage' => $item['parentage'],
|
52 |
+
'variations' => $item['variations']
|
53 |
+
);
|
54 |
+
|
55 |
+
if (!empty($item['requested_child_id'])) {
|
56 |
+
$temp['requested_child_id'] = $item['requested_child_id'];
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
$results->addItem(new Varien_Object($temp));
|
61 |
+
}
|
62 |
+
|
63 |
+
$this->setCollection($results);
|
64 |
+
|
65 |
+
return parent::_prepareCollection();
|
66 |
+
}
|
67 |
+
|
68 |
+
protected function _prepareColumns()
|
69 |
+
{
|
70 |
+
$this->addColumn('image', array(
|
71 |
+
'header' => Mage::helper('M2ePro')->__('Image'),
|
72 |
+
'align' => 'center',
|
73 |
+
'type' => 'text',
|
74 |
+
'width' => '80px',
|
75 |
+
'index' => 'image_url',
|
76 |
+
'filter' => false,
|
77 |
+
'sortable' => false,
|
78 |
+
'frame_callback' => array($this, 'callbackColumnImage')
|
79 |
+
));
|
80 |
+
|
81 |
+
$this->addColumn('general_id', array(
|
82 |
+
'header' => Mage::helper('M2ePro')->__('ASIN / ISBN'),
|
83 |
+
'align' => 'center',
|
84 |
+
'type' => 'text',
|
85 |
+
'width' => '75px',
|
86 |
+
'index' => 'general_id',
|
87 |
+
'filter' => false,
|
88 |
+
'sortable' => false,
|
89 |
+
'frame_callback' => array($this, 'callbackColumnGeneralId')
|
90 |
+
));
|
91 |
+
|
92 |
+
$this->addColumn('title', array(
|
93 |
+
'header' => Mage::helper('M2ePro')->__('Product Title'),
|
94 |
+
'align' => 'left',
|
95 |
+
'type' => 'text',
|
96 |
+
'string_limit' => 10000,
|
97 |
+
'width' => '375px',
|
98 |
+
'index' => 'title',
|
99 |
+
'filter' => false,
|
100 |
+
'sortable' => false,
|
101 |
+
'frame_callback' => array($this, 'callbackColumnTitle'),
|
102 |
+
));
|
103 |
+
|
104 |
+
$this->addColumn('price',array(
|
105 |
+
'header' => Mage::helper('catalog')->__('Price'),
|
106 |
+
'width' => '60px',
|
107 |
+
'align' => 'right',
|
108 |
+
'index' => 'price',
|
109 |
+
'filter' => false,
|
110 |
+
'sortable' => false,
|
111 |
+
'type' => 'number',
|
112 |
+
'frame_callback' => array($this, 'callbackColumnPrice')
|
113 |
+
));
|
114 |
+
|
115 |
+
$this->addColumn('actions', array(
|
116 |
+
'header' => Mage::helper('M2ePro')->__('Action'),
|
117 |
+
'align' => 'left',
|
118 |
+
'type' => 'text',
|
119 |
+
'width' => '78px',
|
120 |
+
'filter' => false,
|
121 |
+
'sortable' => false,
|
122 |
+
'frame_callback' => array($this, 'callbackColumnActions'),
|
123 |
+
));
|
124 |
+
|
125 |
+
}
|
126 |
+
|
127 |
+
// ####################################
|
128 |
+
|
129 |
+
public function callbackColumnImage($value, $product, $column, $isExport)
|
130 |
+
{
|
131 |
+
return '<img src="'.$value.'" />';
|
132 |
+
}
|
133 |
+
|
134 |
+
public function callbackColumnGeneralId($value, $product, $column, $isExport)
|
135 |
+
{
|
136 |
+
$url = Mage::helper('M2ePro/Component_Amazon')->getItemUrl(
|
137 |
+
$value, Mage::helper('M2ePro/Data_Global')->getValue('marketplace_id')
|
138 |
+
);
|
139 |
+
|
140 |
+
return '<a id="asin_link_'.$product->getData('id').'" href="'.$url.'" target="_blank">'.$value.'</a>';
|
141 |
+
}
|
142 |
+
|
143 |
+
public function callbackColumnTitle($value, $row, $column, $isExport)
|
144 |
+
{
|
145 |
+
$value = '<div style="margin-left: 3px; margin-bottom: 10px;">'.
|
146 |
+
Mage::helper('M2ePro')->escapeHtml($value)."</div>";
|
147 |
+
|
148 |
+
$variations = $row->getData('variations');
|
149 |
+
if (is_null($variations)) {
|
150 |
+
return $value;
|
151 |
+
}
|
152 |
+
|
153 |
+
$specificsJs = '<script type="text/javascript">';
|
154 |
+
$specificsHtml = '';
|
155 |
+
$id = $row->getId();
|
156 |
+
$requestedChildAsin = $row->getData('requested_child_id');
|
157 |
+
|
158 |
+
$selectedOptions = array();
|
159 |
+
if ($requestedChildAsin) {
|
160 |
+
$selectedOptions = $variations['asins'][$requestedChildAsin]['specifics'];
|
161 |
+
}
|
162 |
+
|
163 |
+
foreach ($variations['set'] as $specificName => $specific) {
|
164 |
+
$specificsHtml .= '<span style="margin-left: 10px;
|
165 |
+
font-size: 11px;
|
166 |
+
color: #808080;
|
167 |
+
display: inline-block;
|
168 |
+
width: 100px;">'.
|
169 |
+
ucfirst(strtolower($specificName)).
|
170 |
+
':</span>';
|
171 |
+
$specificsHtml .= '<select class="specifics_'.$id.'"
|
172 |
+
onchange="ListingGridHandlerObj.productSearchHandler.specificsChange(this)"
|
173 |
+
style="width: 150px; margin-left: 5px; margin-bottom: 5px; font-size: 10px;"
|
174 |
+
id="specific_'.$specificName.'_'.$id.'">';
|
175 |
+
$specificsHtml .= '<option value=""></option>';
|
176 |
+
foreach ($specific as $option) {
|
177 |
+
|
178 |
+
$selected = '';
|
179 |
+
if ($requestedChildAsin && $selectedOptions[$specificName] == $option) {
|
180 |
+
$selected = 'selected';
|
181 |
+
$specificsJs .= <<<JS
|
182 |
+
ListingGridHandlerObj.productSearchHandler.specificsChange({id:"specific_{$specificName}_{$id}"});
|
183 |
+
JS;
|
184 |
+
|
185 |
+
}
|
186 |
+
|
187 |
+
$option = Mage::helper('M2ePro')->escapeHtml($option);
|
188 |
+
$specificsHtml .= '<option value="'.$option.'" '.$selected.'>'.$option.'</option>';
|
189 |
+
}
|
190 |
+
$specificsHtml .= '</select><br />';
|
191 |
+
}
|
192 |
+
|
193 |
+
$specificsJs .= '</script>';
|
194 |
+
|
195 |
+
$specificsJsonContainer = '<div id="parent_asin_'.$row->getId().'" style="display: none">'.
|
196 |
+
$row->getData('general_id').
|
197 |
+
'</div>'.
|
198 |
+
'<div id="asins_'.$id.'" style="display: none;">'.
|
199 |
+
json_encode($variations['asins']).
|
200 |
+
'</div>';
|
201 |
+
|
202 |
+
return $value . $specificsHtml . $specificsJsonContainer . $specificsJs;
|
203 |
+
}
|
204 |
+
|
205 |
+
public function callbackColumnPrice($value, $row, $column, $isExport)
|
206 |
+
{
|
207 |
+
if (empty($value) || $row->getData('is_variation_product')) {
|
208 |
+
$value = Mage::helper('M2ePro')->__('N/A');
|
209 |
+
}
|
210 |
+
|
211 |
+
return '<div style="margin-right: 5px;">'.$value.'</div>';
|
212 |
+
}
|
213 |
+
|
214 |
+
public function callbackColumnActions($value, $row, $column, $isExport)
|
215 |
+
{
|
216 |
+
$assignText = Mage::helper('M2ePro')->__('Assign ASIN/ISBN');
|
217 |
+
|
218 |
+
if (!is_null($row->getData('variations'))) {
|
219 |
+
$templateMapHtml =
|
220 |
+
'<a href="javascript:void(0);" onclick="ListingGridHandlerObj.productSearchHandler.mapToGeneralId('
|
221 |
+
.$this->productId
|
222 |
+
.', \'%general_id%\');">'.$assignText.'</a>';
|
223 |
+
|
224 |
+
return '<span id="map_link_'.$row->getId().'"><span style="color: #808080">'.$assignText.'</span></span>
|
225 |
+
<div id="template_map_link_'.$row->getId().'" style="display: none;">'.$templateMapHtml.'</div>';
|
226 |
+
}
|
227 |
+
|
228 |
+
return '<a href="javascript:void(0);" onclick="ListingGridHandlerObj.productSearchHandler.mapToGeneralId('
|
229 |
+
.$this->productId
|
230 |
+
.', \''
|
231 |
+
.$row->getData('general_id')
|
232 |
+
.'\');">'.$assignText.'</a>';
|
233 |
+
}
|
234 |
+
|
235 |
+
// ####################################
|
236 |
+
|
237 |
+
protected function _toHtml()
|
238 |
+
{
|
239 |
+
$javascriptsMain = <<<JAVASCRIPT
|
240 |
+
<script type="text/javascript">
|
241 |
+
|
242 |
+
$$('#amazonProductSearchGrid div.grid th').each(function(el){
|
243 |
+
el.style.padding = '2px 2px';
|
244 |
+
});
|
245 |
+
|
246 |
+
$$('#amazonProductSearchGrid div.grid td').each(function(el){
|
247 |
+
el.style.padding = '2px 2px';
|
248 |
+
});
|
249 |
+
|
250 |
+
</script>
|
251 |
+
JAVASCRIPT;
|
252 |
+
|
253 |
+
//------------------------------
|
254 |
+
$data = array(
|
255 |
+
'id' => 'productSearch_cleanSuggest_button',
|
256 |
+
'label' => Mage::helper('M2ePro')->__('Clear Search Result'),
|
257 |
+
'class' => 'productSearch_cleanSuggest_button'
|
258 |
+
);
|
259 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
260 |
+
//------------------------------
|
261 |
+
|
262 |
+
$buttonBlockHtml = Mage::helper('M2ePro/Data_Global')->getValue('is_suggestion') ? $buttonBlock->toHtml() : '';
|
263 |
+
|
264 |
+
return $buttonBlockHtml . parent::_toHtml() . $javascriptsMain;
|
265 |
+
}
|
266 |
+
|
267 |
+
// ####################################
|
268 |
+
|
269 |
+
public function getGridUrl()
|
270 |
+
{
|
271 |
+
return $this->getUrl('*/adminhtml_common_amazon_listing/getSuggestedAsinGrid', array('_current'=>true));
|
272 |
+
}
|
273 |
+
|
274 |
+
public function getRowUrl($row)
|
275 |
+
{
|
276 |
+
return false;
|
277 |
+
}
|
278 |
+
|
279 |
+
// ####################################
|
280 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/ProductSearch/Main.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_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_reset_button',
|
31 |
+
'label' => Mage::helper('M2ePro')->__('Reset'),
|
32 |
+
'class' => 'productSearch_reset_button submit'
|
33 |
+
);
|
34 |
+
$buttonSubmitBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
35 |
+
$this->setChild('productSearch_reset_button', $buttonSubmitBlock);
|
36 |
+
//------------------------------
|
37 |
+
|
38 |
+
//------------------------------
|
39 |
+
$data = array(
|
40 |
+
'id' => 'productSearch_back_button',
|
41 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
42 |
+
'class' => 'productSearch_back_button'
|
43 |
+
);
|
44 |
+
$buttonBackBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
45 |
+
$this->setChild('productSearch_back_button', $buttonBackBlock);
|
46 |
+
//------------------------------
|
47 |
+
|
48 |
+
//------------------------------
|
49 |
+
$data = array(
|
50 |
+
'id' => 'productSearch_cancel_button',
|
51 |
+
'label' => Mage::helper('M2ePro')->__('Close'),
|
52 |
+
'class' => 'productSearch_cancel_button'
|
53 |
+
);
|
54 |
+
$buttonCancelBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
55 |
+
$this->setChild('productSearch_cancel_button', $buttonCancelBlock);
|
56 |
+
//------------------------------
|
57 |
+
|
58 |
+
parent::_beforeToHtml();
|
59 |
+
}
|
60 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/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_Amazon_Listing_ProductSearch_Menu 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/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/Amazon/Listing/Search.php
ADDED
@@ -0,0 +1,158 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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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')->__(Ess_M2ePro_Helper_Component_Amazon::TITLE);
|
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')->__('Templates'),
|
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 |
+
'filter' => base64_encode('component_mode=' . Ess_M2ePro_Helper_Component_Amazon::NICK)
|
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 |
+
$this->_addButton('reset', array(
|
96 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
97 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
98 |
+
'class' => 'reset'
|
99 |
+
));
|
100 |
+
//------------------------------
|
101 |
+
}
|
102 |
+
|
103 |
+
// ########################################
|
104 |
+
|
105 |
+
protected function _toHtml()
|
106 |
+
{
|
107 |
+
return $this->getTemplatesButtonJavascript() . parent::_toHtml();
|
108 |
+
}
|
109 |
+
|
110 |
+
public function getGridHtml()
|
111 |
+
{
|
112 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_listing_search_help');
|
113 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
114 |
+
}
|
115 |
+
|
116 |
+
// ########################################
|
117 |
+
|
118 |
+
protected function getTemplatesButtonJavascript()
|
119 |
+
{
|
120 |
+
$data = array(
|
121 |
+
'target_css_class' => 'templates-drop-down',
|
122 |
+
'items' => $this->getTemplatesButtonDropDownItems()
|
123 |
+
);
|
124 |
+
$dropDownBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_button_dropDown');
|
125 |
+
$dropDownBlock->setData($data);
|
126 |
+
|
127 |
+
return $dropDownBlock->toHtml();
|
128 |
+
}
|
129 |
+
|
130 |
+
protected function getTemplatesButtonDropDownItems()
|
131 |
+
{
|
132 |
+
$items = array();
|
133 |
+
|
134 |
+
$filter = base64_encode('component_mode=' . Ess_M2ePro_Helper_Component_Amazon::NICK);
|
135 |
+
|
136 |
+
//------------------------------
|
137 |
+
$url = $this->getUrl('*/adminhtml_common_template_sellingFormat/index', array('filter' => $filter));
|
138 |
+
$items[] = array(
|
139 |
+
'url' => $url,
|
140 |
+
'label' => Mage::helper('M2ePro')->__('Selling Format Templates'),
|
141 |
+
'target' => '_blank'
|
142 |
+
);
|
143 |
+
//------------------------------
|
144 |
+
|
145 |
+
//------------------------------
|
146 |
+
$url = $this->getUrl('*/adminhtml_common_template_synchronization/index', array('filter' => $filter));
|
147 |
+
$items[] = array(
|
148 |
+
'url' => $url,
|
149 |
+
'label' => Mage::helper('M2ePro')->__('Synchronization Templates'),
|
150 |
+
'target' => '_blank'
|
151 |
+
);
|
152 |
+
//------------------------------
|
153 |
+
|
154 |
+
return $items;
|
155 |
+
}
|
156 |
+
|
157 |
+
// ########################################
|
158 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Search/Grid.php
ADDED
@@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|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
// 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')
|
64 |
+
->getTableName('cataloginventory_stock_item')),
|
65 |
+
'(cisi.product_id = `main_table`.product_id AND cisi.stock_id = 1)',
|
66 |
+
array('is_in_stock'))
|
67 |
+
->join(array('cpev'=>Mage::getSingleton('core/resource')
|
68 |
+
->getTableName('catalog_product_entity_varchar')),
|
69 |
+
"(`cpev`.`entity_id` = `main_table`.product_id)",
|
70 |
+
array('value'))
|
71 |
+
->join(array('ea'=>Mage::getSingleton('core/resource')->getTableName('eav_attribute')),
|
72 |
+
'(`cpev`.`attribute_id` = `ea`.`attribute_id` AND `ea`.`attribute_code` = \'name\')',
|
73 |
+
array())
|
74 |
+
->where('`cpev`.`store_id` = ('.$dbSelect->__toString().')');
|
75 |
+
//--------------------------------
|
76 |
+
|
77 |
+
//exit($collection->getSelect()->__toString());
|
78 |
+
|
79 |
+
// Set collection to grid
|
80 |
+
$this->setCollection($collection);
|
81 |
+
|
82 |
+
return parent::_prepareCollection();
|
83 |
+
}
|
84 |
+
|
85 |
+
protected function _prepareColumns()
|
86 |
+
{
|
87 |
+
$this->addColumn('product_id', array(
|
88 |
+
'header' => Mage::helper('M2ePro')->__('Product ID'),
|
89 |
+
'align' => 'right',
|
90 |
+
'width' => '100px',
|
91 |
+
'type' => 'number',
|
92 |
+
'index' => 'product_id',
|
93 |
+
'filter_index' => 'main_table.product_id',
|
94 |
+
'frame_callback' => array($this, 'callbackColumnProductId')
|
95 |
+
));
|
96 |
+
|
97 |
+
$this->addColumn('name', array(
|
98 |
+
'header' => Mage::helper('M2ePro')->__('Product Title / Listing / SKU'),
|
99 |
+
'align' => 'left',
|
100 |
+
//'width' => '300px',
|
101 |
+
'type' => 'text',
|
102 |
+
'index' => 'value',
|
103 |
+
'filter_index' => 'cpev.value',
|
104 |
+
'frame_callback' => array($this, 'callbackColumnProductTitle'),
|
105 |
+
'filter_condition_callback' => array($this, 'callbackFilterTitle')
|
106 |
+
));
|
107 |
+
|
108 |
+
$this->addColumn('stock_availability',
|
109 |
+
array(
|
110 |
+
'header'=> Mage::helper('M2ePro')->__('Stock Availability'),
|
111 |
+
'width' => '100px',
|
112 |
+
'index' => 'is_in_stock',
|
113 |
+
'filter_index' => 'cisi.is_in_stock',
|
114 |
+
'type' => 'options',
|
115 |
+
'sortable' => false,
|
116 |
+
'options' => array(
|
117 |
+
1 => Mage::helper('M2ePro')->__('In Stock'),
|
118 |
+
0 => Mage::helper('M2ePro')->__('Out of Stock')
|
119 |
+
),
|
120 |
+
'frame_callback' => array($this, 'callbackColumnStockAvailability')
|
121 |
+
));
|
122 |
+
|
123 |
+
$this->addColumn('sku', array(
|
124 |
+
'header' => Mage::helper('M2ePro')->__('Amazon SKU'),
|
125 |
+
'align' => 'left',
|
126 |
+
'width' => '150px',
|
127 |
+
'type' => 'text',
|
128 |
+
'index' => 'sku',
|
129 |
+
'filter_index' => 'second_table.sku',
|
130 |
+
'frame_callback' => array($this, 'callbackColumnAmazonSku')
|
131 |
+
));
|
132 |
+
|
133 |
+
$this->addColumn('general_id', array(
|
134 |
+
'header' => Mage::helper('M2ePro')->__('ASIN / ISBN'),
|
135 |
+
'align' => 'left',
|
136 |
+
'width' => '90px',
|
137 |
+
'type' => 'text',
|
138 |
+
'index' => 'general_id',
|
139 |
+
'filter_index' => 'second_table.general_id',
|
140 |
+
'frame_callback' => array($this, 'callbackColumnGeneralId')
|
141 |
+
));
|
142 |
+
|
143 |
+
$this->addColumn('online_qty', array(
|
144 |
+
'header' => Mage::helper('M2ePro')->__('Amazon QTY'),
|
145 |
+
'align' => 'right',
|
146 |
+
'width' => '70px',
|
147 |
+
'type' => 'number',
|
148 |
+
'index' => 'online_qty',
|
149 |
+
'filter_index' => 'second_table.online_qty',
|
150 |
+
'frame_callback' => array($this, 'callbackColumnAvailableQty')
|
151 |
+
));
|
152 |
+
|
153 |
+
$this->addColumn('online_price', array(
|
154 |
+
'header' => Mage::helper('M2ePro')->__('Amazon Price'),
|
155 |
+
'align' => 'right',
|
156 |
+
'width' => '70px',
|
157 |
+
'type' => 'number',
|
158 |
+
'index' => 'online_price',
|
159 |
+
'filter_index' => 'second_table.online_price',
|
160 |
+
'frame_callback' => array($this, 'callbackColumnPrice')
|
161 |
+
));
|
162 |
+
|
163 |
+
$this->addColumn('is_afn_channel', array(
|
164 |
+
'header' => Mage::helper('M2ePro')->__('Fulfillment'),
|
165 |
+
'width' => '90px',
|
166 |
+
'index' => 'is_afn_channel',
|
167 |
+
'filter_index' => 'second_table.is_afn_channel',
|
168 |
+
'type' => 'options',
|
169 |
+
'sortable' => false,
|
170 |
+
'options' => array(
|
171 |
+
0 => Mage::helper('M2ePro')->__('Merchant'),
|
172 |
+
1 => Mage::helper('M2ePro')->__('Amazon')
|
173 |
+
),
|
174 |
+
'frame_callback' => array($this, 'callbackColumnAfnChannel')
|
175 |
+
));
|
176 |
+
|
177 |
+
$this->addColumn('status', array(
|
178 |
+
'header' => Mage::helper('M2ePro')->__('Status'),
|
179 |
+
'width' => '125px',
|
180 |
+
'index' => 'status',
|
181 |
+
'filter_index' => 'main_table.status',
|
182 |
+
'type' => 'options',
|
183 |
+
'sortable' => false,
|
184 |
+
'options' => array(
|
185 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_UNKNOWN => Mage::helper('M2ePro')->__('Unknown'),
|
186 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED => Mage::helper('M2ePro')->__('Not Listed'),
|
187 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_LISTED => Mage::helper('M2ePro')->__('Active'),
|
188 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED => Mage::helper('M2ePro')->__('Inactive'),
|
189 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_BLOCKED => Mage::helper('M2ePro')->__('Inactive (Blocked)')
|
190 |
+
),
|
191 |
+
'frame_callback' => array($this, 'callbackColumnStatus')
|
192 |
+
));
|
193 |
+
|
194 |
+
$this->addColumn('goto_listing_item', array(
|
195 |
+
'header' => Mage::helper('M2ePro')->__('Manage'),
|
196 |
+
'align' => 'center',
|
197 |
+
'width' => '50px',
|
198 |
+
'type' => 'text',
|
199 |
+
'filter' => false,
|
200 |
+
'sortable' => false,
|
201 |
+
'frame_callback' => array($this, 'callbackColumnActions')
|
202 |
+
));
|
203 |
+
|
204 |
+
return parent::_prepareColumns();
|
205 |
+
}
|
206 |
+
|
207 |
+
// ####################################
|
208 |
+
|
209 |
+
public function callbackColumnProductId($value, $row, $column, $isExport)
|
210 |
+
{
|
211 |
+
$productId = (int)$row->getData('product_id');
|
212 |
+
$storeId = (int)$row->getData('store_id');
|
213 |
+
|
214 |
+
$withoutImageHtml = '<a href="'
|
215 |
+
.$this->getUrl('adminhtml/catalog_product/edit',
|
216 |
+
array('id' => $productId))
|
217 |
+
.'" target="_blank">'
|
218 |
+
.$productId
|
219 |
+
.'</a>';
|
220 |
+
|
221 |
+
$showProductsThumbnails = (bool)(int)Mage::helper('M2ePro/Module')->getConfig()
|
222 |
+
->getGroupValue('/view/',
|
223 |
+
'show_products_thumbnails');
|
224 |
+
if (!$showProductsThumbnails) {
|
225 |
+
return $withoutImageHtml;
|
226 |
+
}
|
227 |
+
|
228 |
+
/** @var $magentoProduct Ess_M2ePro_Model_Magento_Product */
|
229 |
+
$magentoProduct = Mage::getModel('M2ePro/Magento_Product');
|
230 |
+
$magentoProduct->setProductId($productId);
|
231 |
+
$magentoProduct->setStoreId($storeId);
|
232 |
+
|
233 |
+
$imageUrlResized = $magentoProduct->getThumbnailImageLink();
|
234 |
+
if (is_null($imageUrlResized)) {
|
235 |
+
return $withoutImageHtml;
|
236 |
+
}
|
237 |
+
|
238 |
+
$imageHtml = $productId.'<hr/><img src="'.$imageUrlResized.'" />';
|
239 |
+
$withImageHtml = str_replace('>'.$productId.'<','>'.$imageHtml.'<',$withoutImageHtml);
|
240 |
+
|
241 |
+
return $withImageHtml;
|
242 |
+
}
|
243 |
+
|
244 |
+
public function callbackColumnProductTitle($value, $row, $column, $isExport)
|
245 |
+
{
|
246 |
+
if (strlen($value) > 60) {
|
247 |
+
$value = substr($value, 0, 60) . '...';
|
248 |
+
}
|
249 |
+
|
250 |
+
$value = '<span>'.Mage::helper('M2ePro')->escapeHtml($value).'</span>';
|
251 |
+
|
252 |
+
$urlParams = array();
|
253 |
+
$urlParams['id'] = $row->getData('listing_id');
|
254 |
+
$urlParams['back'] = Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_amazon_listing/search');
|
255 |
+
|
256 |
+
$listingUrl = $this->getUrl('*/adminhtml_common_amazon_listing/view',$urlParams);
|
257 |
+
$listingTitle = Mage::helper('M2ePro')->escapeHtml($row->getData('listing_title'));
|
258 |
+
|
259 |
+
if (strlen($listingTitle) > 50) {
|
260 |
+
$listingTitle = substr($listingTitle, 0, 50) . '...';
|
261 |
+
}
|
262 |
+
|
263 |
+
$value .= '<br/><hr style="border:none; border-top:1px solid silver; margin: 2px 0px;"/>';
|
264 |
+
$value .= '<strong>'
|
265 |
+
.Mage::helper('M2ePro')->__('Listing')
|
266 |
+
.': </strong> <a href="'
|
267 |
+
.$listingUrl
|
268 |
+
.'">'
|
269 |
+
.$listingTitle
|
270 |
+
.'</a>';
|
271 |
+
|
272 |
+
$tempSku = $row->getData('magento_sku');
|
273 |
+
is_null($tempSku)
|
274 |
+
&& $tempSku = Mage::getModel('M2ePro/Magento_Product')->setProductId($row->getData('product_id'))->getSku();
|
275 |
+
|
276 |
+
$value .= '<br/><strong>'
|
277 |
+
.Mage::helper('M2ePro')->__('SKU')
|
278 |
+
.':</strong> '
|
279 |
+
.Mage::helper('M2ePro')->escapeHtml($tempSku);
|
280 |
+
|
281 |
+
return $value;
|
282 |
+
}
|
283 |
+
|
284 |
+
public function callbackColumnStockAvailability($value, $row, $column, $isExport)
|
285 |
+
{
|
286 |
+
if ((int)$row->getData('is_in_stock') <= 0) {
|
287 |
+
return '<span style="color: red;">'.$value.'</span>';
|
288 |
+
}
|
289 |
+
|
290 |
+
return $value;
|
291 |
+
}
|
292 |
+
|
293 |
+
public function callbackColumnAmazonSku($value, $row, $column, $isExport)
|
294 |
+
{
|
295 |
+
if (is_null($value) || $value === '') {
|
296 |
+
return Mage::helper('M2ePro')->__('N/A');
|
297 |
+
}
|
298 |
+
return $value;
|
299 |
+
}
|
300 |
+
|
301 |
+
public function callbackColumnGeneralId($value, $row, $column, $isExport)
|
302 |
+
{
|
303 |
+
if ((int)$row->getData('status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
304 |
+
if (is_null($value) || $value === '') {
|
305 |
+
return Mage::helper('M2ePro')->__('N/A');
|
306 |
+
}
|
307 |
+
} else {
|
308 |
+
if (is_null($value) || $value === '') {
|
309 |
+
return '<i style="color:gray;">receiving...</i>';
|
310 |
+
}
|
311 |
+
}
|
312 |
+
|
313 |
+
$url = Mage::helper('M2ePro/Component_Amazon')->getItemUrl($value, $row->getData('marketplace_id'));
|
314 |
+
|
315 |
+
return '<a href="'.$url.'" target="_blank">'.$value.'</a>';
|
316 |
+
}
|
317 |
+
|
318 |
+
public function callbackColumnAvailableQty($value, $row, $column, $isExport)
|
319 |
+
{
|
320 |
+
if ((int)$row->getData('status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
321 |
+
if (is_null($value) || $value === '') {
|
322 |
+
return Mage::helper('M2ePro')->__('N/A');
|
323 |
+
}
|
324 |
+
} else {
|
325 |
+
if (is_null($value) || $value === '') {
|
326 |
+
return '<i style="color:gray;">receiving...</i>';
|
327 |
+
}
|
328 |
+
}
|
329 |
+
|
330 |
+
if ((bool)$row->getData('is_afn_channel')) {
|
331 |
+
return '--';
|
332 |
+
}
|
333 |
+
|
334 |
+
if ($value <= 0) {
|
335 |
+
return '<span style="color: red;">0</span>';
|
336 |
+
}
|
337 |
+
|
338 |
+
return $value;
|
339 |
+
}
|
340 |
+
|
341 |
+
public function callbackColumnPrice($value, $row, $column, $isExport)
|
342 |
+
{
|
343 |
+
if ((int)$row->getData('status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
344 |
+
if (is_null($value) || $value === '') {
|
345 |
+
return Mage::helper('M2ePro')->__('N/A');
|
346 |
+
}
|
347 |
+
} else {
|
348 |
+
if (is_null($value) || $value === '') {
|
349 |
+
return '<i style="color:gray;">receiving...</i>';
|
350 |
+
}
|
351 |
+
}
|
352 |
+
|
353 |
+
if ((float)$value <= 0) {
|
354 |
+
return '<span style="color: #f00;">0</span>';
|
355 |
+
}
|
356 |
+
|
357 |
+
$marketplaceId = Mage::helper('M2ePro/Component_Amazon')
|
358 |
+
->getCachedObject('Listing',
|
359 |
+
$row->getData('listing_id'), NULL,
|
360 |
+
array('listing'))
|
361 |
+
->getMarketplaceId();
|
362 |
+
|
363 |
+
$currency = Mage::helper('M2ePro/Component_Amazon')
|
364 |
+
->getCachedObject('Marketplace',$marketplaceId)
|
365 |
+
->getChildObject()
|
366 |
+
->getDefaultCurrency();
|
367 |
+
|
368 |
+
$value = Mage::app()->getLocale()->currency($currency)->toCurrency($value);
|
369 |
+
|
370 |
+
$salePriceValue = $row->getData('online_sale_price');
|
371 |
+
if (!is_null($salePriceValue) &&
|
372 |
+
(float)$salePriceValue > 0) {
|
373 |
+
$salePriceValue = Mage::app()->getLocale()->currency($currency)->toCurrency($salePriceValue);
|
374 |
+
$value .= '<br/><span style="color:gray;">'.$salePriceValue.'</span>';
|
375 |
+
}
|
376 |
+
|
377 |
+
return $value;
|
378 |
+
}
|
379 |
+
|
380 |
+
public function callbackColumnAfnChannel($value, $row, $column, $isExport)
|
381 |
+
{
|
382 |
+
if (is_null($value) || $value === '') {
|
383 |
+
return Mage::helper('M2ePro')->__('N/A');
|
384 |
+
}
|
385 |
+
|
386 |
+
switch ($row->getData('is_afn_channel')) {
|
387 |
+
case Ess_M2ePro_Model_Amazon_Listing_Product::IS_ISBN_GENERAL_ID_YES:
|
388 |
+
$value = '<span style="font-weight: bold;">' . $value . '</span>';
|
389 |
+
break;
|
390 |
+
|
391 |
+
default:
|
392 |
+
break;
|
393 |
+
}
|
394 |
+
|
395 |
+
return $value;
|
396 |
+
}
|
397 |
+
|
398 |
+
public function callbackColumnStatus($value, $row, $column, $isExport)
|
399 |
+
{
|
400 |
+
switch ($row->getData('status')) {
|
401 |
+
|
402 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_UNKNOWN:
|
403 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED:
|
404 |
+
$value = '<span style="color: gray;">' . $value . '</span>';
|
405 |
+
break;
|
406 |
+
|
407 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_LISTED:
|
408 |
+
$value = '<span style="color: green;">' . $value . '</span>';
|
409 |
+
break;
|
410 |
+
|
411 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED:
|
412 |
+
$value = '<span style="color: red;">'.$value.'</span>';
|
413 |
+
break;
|
414 |
+
|
415 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_BLOCKED:
|
416 |
+
$value = '<span style="color: orange; font-weight: bold;">'.$value.'</span>';
|
417 |
+
break;
|
418 |
+
|
419 |
+
default:
|
420 |
+
break;
|
421 |
+
}
|
422 |
+
|
423 |
+
$tempLocks = $row->getObjectLocks();
|
424 |
+
|
425 |
+
foreach ($tempLocks as $lock) {
|
426 |
+
|
427 |
+
switch ($lock->getTag()) {
|
428 |
+
|
429 |
+
case 'list_action':
|
430 |
+
$value .= '<br><span style="color: #605fff">[List In Progress...]</span>';
|
431 |
+
break;
|
432 |
+
|
433 |
+
case 'relist_action':
|
434 |
+
$value .= '<br><span style="color: #605fff">[Relist In Progress...]</span>';
|
435 |
+
break;
|
436 |
+
|
437 |
+
case 'revise_action':
|
438 |
+
$value .= '<br><span style="color: #605fff">[Revise In Progress...]</span>';
|
439 |
+
break;
|
440 |
+
|
441 |
+
case 'stop_action':
|
442 |
+
$value .= '<br><span style="color: #605fff">[Stop In Progress...]</span>';
|
443 |
+
break;
|
444 |
+
|
445 |
+
case 'stop_and_remove_action':
|
446 |
+
$value .= '<br><span style="color: #605fff">[Stop And Remove In Progress...]</span>';
|
447 |
+
break;
|
448 |
+
|
449 |
+
case 'delete_and_remove_action':
|
450 |
+
$value .= '<br><span style="color: #605fff">[Remove In Progress...]</span>';
|
451 |
+
break;
|
452 |
+
|
453 |
+
default:
|
454 |
+
break;
|
455 |
+
|
456 |
+
}
|
457 |
+
}
|
458 |
+
|
459 |
+
return $value;
|
460 |
+
}
|
461 |
+
|
462 |
+
public function callbackColumnActions($value, $row, $column, $isExport)
|
463 |
+
{
|
464 |
+
$altTitle = Mage::helper('M2ePro')->escapeHtml(Mage::helper('M2ePro')->__('Go to listing'));
|
465 |
+
$iconSrc = $this->getSkinUrl('M2ePro').'/images/goto_listing.png';
|
466 |
+
$url = $this->getUrl('*/adminhtml_common_amazon_listing/view/',array(
|
467 |
+
'id' => $row->getData('listing_id'),
|
468 |
+
'filter' => base64_encode(
|
469 |
+
'product_id[from]='.(int)$row->getData('product_id')
|
470 |
+
.'&product_id[to]='.(int)$row->getData('product_id')
|
471 |
+
)
|
472 |
+
));
|
473 |
+
|
474 |
+
$html = <<<HTML
|
475 |
+
<div style="float:right; margin:5px 15px 0 0;">
|
476 |
+
<a title="{$altTitle}" target="_blank" href="{$url}"><img src="{$iconSrc}" alt="{$altTitle}" /></a>
|
477 |
+
</div>
|
478 |
+
HTML;
|
479 |
+
|
480 |
+
return $html;
|
481 |
+
}
|
482 |
+
|
483 |
+
protected function callbackFilterTitle($collection, $column)
|
484 |
+
{
|
485 |
+
$value = $column->getFilter()->getValue();
|
486 |
+
|
487 |
+
if ($value == null) {
|
488 |
+
return;
|
489 |
+
}
|
490 |
+
|
491 |
+
$collection->getSelect()->where('cpev.value LIKE ? OR cpe.sku LIKE ? OR l.title LIKE ?', '%'.$value.'%');
|
492 |
+
}
|
493 |
+
|
494 |
+
// ####################################
|
495 |
+
|
496 |
+
public function getGridUrl()
|
497 |
+
{
|
498 |
+
return $this->getUrl('*/adminhtml_common_amazon_listing/searchGrid', array('_current'=>true));
|
499 |
+
}
|
500 |
+
|
501 |
+
public function getRowUrl($row)
|
502 |
+
{
|
503 |
+
return false;
|
504 |
+
}
|
505 |
+
|
506 |
+
// ####################################
|
507 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Tutorial.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_Tutorial extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonListingTutorial');
|
16 |
+
$this->setContainerId('amazon_listing_tutorial');
|
17 |
+
$this->setTemplate('M2ePro/common/amazon/listing/tutorial.phtml');
|
18 |
+
//------------------------------
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _beforeToHtml()
|
22 |
+
{
|
23 |
+
//-------------------------------
|
24 |
+
$url = $this->getUrl(
|
25 |
+
'*/adminhtml_common_listing/confirmTutorial',
|
26 |
+
array(
|
27 |
+
'component' => Ess_M2ePro_Helper_Component_Amazon::NICK
|
28 |
+
)
|
29 |
+
);
|
30 |
+
$data = array(
|
31 |
+
'label' => Mage::helper('M2ePro')->__('Continue'),
|
32 |
+
'onclick' => 'setLocation(\''.$url.'\');',
|
33 |
+
'class' => 'confirm_tutorial'
|
34 |
+
);
|
35 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
36 |
+
$this->setChild('confirm_tutorial',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
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('amazonListingView');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_amazon_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 "%listing_title%"',
|
27 |
+
Mage::helper('M2ePro')->__(Ess_M2ePro_Helper_Component_Amazon::TITLE),
|
28 |
+
$this->escapeHtml($listingData['title'])
|
29 |
+
);
|
30 |
+
} else {
|
31 |
+
$headerText = Mage::helper('M2ePro')->__(
|
32 |
+
'View Listing "%listing_title%"', $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 |
+
if (!is_null($this->getRequest()->getParam('back'))) {
|
50 |
+
//------------------------------
|
51 |
+
$url = Mage::helper('M2ePro')->getBackUrl('*/adminhtml_common_listing/index');
|
52 |
+
$this->_addButton('back', array(
|
53 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
54 |
+
'onclick' => 'CommonHandlerObj.back_click(\'' . $url . '\')',
|
55 |
+
'class' => 'back'
|
56 |
+
));
|
57 |
+
//------------------------------
|
58 |
+
}
|
59 |
+
|
60 |
+
//------------------------------
|
61 |
+
$url = $this->getUrl(
|
62 |
+
'*/adminhtml_common_listing/index',
|
63 |
+
array(
|
64 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON
|
65 |
+
)
|
66 |
+
);
|
67 |
+
$this->_addButton('goto_listings', array(
|
68 |
+
'label' => Mage::helper('M2ePro')->__('Listings'),
|
69 |
+
'onclick' => 'setLocation(\'' . $url . '\')',
|
70 |
+
'class' => 'button_link'
|
71 |
+
));
|
72 |
+
//------------------------------
|
73 |
+
|
74 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
75 |
+
'*/adminhtml_common_amazon_listing/view',
|
76 |
+
array(
|
77 |
+
'id' => $listingData['id']
|
78 |
+
)
|
79 |
+
);
|
80 |
+
|
81 |
+
//------------------------------
|
82 |
+
$url = $this->getUrl('*/adminhtml_common_log/listing', array('id' => $listingData['id']));
|
83 |
+
$this->_addButton('view_log', array(
|
84 |
+
'label' => Mage::helper('M2ePro')->__('View Log'),
|
85 |
+
'onclick' => 'window.open(\'' . $url . '\')',
|
86 |
+
'class' => 'button_link'
|
87 |
+
));
|
88 |
+
//------------------------------
|
89 |
+
|
90 |
+
//------------------------------
|
91 |
+
$this->_addButton('reset', array(
|
92 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
93 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
94 |
+
'class' => 'reset'
|
95 |
+
));
|
96 |
+
//------------------------------
|
97 |
+
|
98 |
+
$newListing = $this->getRequest()->getParam('new');
|
99 |
+
$tempStr = Mage::helper('M2ePro')->__('Are you sure?');
|
100 |
+
|
101 |
+
//------------------------------
|
102 |
+
if (is_null($newListing)) {
|
103 |
+
$url = $this->getUrl(
|
104 |
+
'*/adminhtml_listing/clearLog',
|
105 |
+
array(
|
106 |
+
'id' => $listingData['id'],
|
107 |
+
'back' => $backUrl
|
108 |
+
)
|
109 |
+
);
|
110 |
+
$this->_addButton('clear_log', array(
|
111 |
+
'label' => Mage::helper('M2ePro')->__('Clear Log'),
|
112 |
+
'onclick' => 'deleteConfirm(\'' . $tempStr . '\', \'' . $url . '\')',
|
113 |
+
'class' => 'clear_log'
|
114 |
+
));
|
115 |
+
}
|
116 |
+
//------------------------------
|
117 |
+
|
118 |
+
//------------------------------
|
119 |
+
$url = $this->getUrl('*/adminhtml_common_amazon_listing/delete', array('id' => $listingData['id']));
|
120 |
+
$this->_addButton('delete', array(
|
121 |
+
'label' => Mage::helper('M2ePro')->__('Delete'),
|
122 |
+
'onclick' => 'deleteConfirm(\'' . $tempStr . '\', \'' . $url . '\')',
|
123 |
+
'class' => 'delete'
|
124 |
+
));
|
125 |
+
//------------------------------
|
126 |
+
|
127 |
+
//------------------------------
|
128 |
+
$this->_addButton('edit_templates', array(
|
129 |
+
'label' => Mage::helper('M2ePro')->__('Edit Templates'),
|
130 |
+
'onclick' => '',
|
131 |
+
'class' => 'drop_down edit_template_drop_down'
|
132 |
+
));
|
133 |
+
//------------------------------
|
134 |
+
|
135 |
+
//------------------------------
|
136 |
+
$url = $this->getUrl(
|
137 |
+
'*/adminhtml_common_amazon_listing/edit',
|
138 |
+
array(
|
139 |
+
'id'=>$listingData['id'],
|
140 |
+
'back'=>$backUrl
|
141 |
+
)
|
142 |
+
);
|
143 |
+
$this->_addButton('edit_settings', array(
|
144 |
+
'label' => Mage::helper('M2ePro')->__('Edit Settings'),
|
145 |
+
'onclick' => 'window.open(\'' . $url . '\',\'_blank\')',
|
146 |
+
'class' => ''
|
147 |
+
));
|
148 |
+
//------------------------------
|
149 |
+
|
150 |
+
//------------------------------
|
151 |
+
$this->_addButton('add_products', array(
|
152 |
+
'label' => Mage::helper('M2ePro')->__('Add Products'),
|
153 |
+
'onclick' => '',
|
154 |
+
'class' => 'add drop_down add_products_drop_down'
|
155 |
+
));
|
156 |
+
//------------------------------
|
157 |
+
}
|
158 |
+
|
159 |
+
protected function _toHtml()
|
160 |
+
{
|
161 |
+
return '<div id="listing_view_progress_bar"></div>' .
|
162 |
+
'<div id="listing_container_errors_summary" class="errors_summary" style="display: none;"></div>' .
|
163 |
+
'<div id="listing_view_content_container">'.
|
164 |
+
parent::_toHtml() .
|
165 |
+
'</div>';
|
166 |
+
}
|
167 |
+
|
168 |
+
public function getGridHtml()
|
169 |
+
{
|
170 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
171 |
+
|
172 |
+
/** @var $helper Ess_M2ePro_Helper_Data */
|
173 |
+
$helper = Mage::helper('M2ePro');
|
174 |
+
|
175 |
+
//------------------------------
|
176 |
+
$urls = array();
|
177 |
+
|
178 |
+
$path = 'adminhtml_common_log/listing';
|
179 |
+
$urls[$path] = $this->getUrl('*/' . $path, array(
|
180 |
+
'id' => $listingData['id'],
|
181 |
+
'back'=>$helper->makeBackUrlParam('*/adminhtml_common_amazon_listing/view',array('id' =>$listingData['id']))
|
182 |
+
));
|
183 |
+
|
184 |
+
$path = 'adminhtml_common_listing/duplicateProducts';
|
185 |
+
$urls[$path] = $this->getUrl('*/' . $path);
|
186 |
+
|
187 |
+
$urls = json_encode($urls);
|
188 |
+
//------------------------------
|
189 |
+
|
190 |
+
// todo next (change)
|
191 |
+
|
192 |
+
$component = Ess_M2ePro_Helper_Component_Amazon::NICK;
|
193 |
+
|
194 |
+
$temp = Mage::helper('M2ePro/Data_Session')->getValue('products_ids_for_list', true);
|
195 |
+
$productsIdsForList = empty($temp) ? '' : $temp;
|
196 |
+
|
197 |
+
$gridId = 'amazonListingViewGrid' . $listingData['id'];
|
198 |
+
$ignoreListings = json_encode(array($listingData['id']));
|
199 |
+
|
200 |
+
$marketplaceId = Mage::helper('M2ePro/Data_Global')->getValue('marketplace_id');
|
201 |
+
$marketplaceInstance = Mage::helper('M2ePro/Component_Amazon')->getCachedObject('Marketplace',$marketplaceId);
|
202 |
+
$marketplace = json_encode($marketplaceInstance->getData());
|
203 |
+
$isNewAsinAvailable = json_encode($marketplaceInstance->getChildObject()->isNewAsinAvailable());
|
204 |
+
$isMarketplaceSynchronized = json_encode($marketplaceInstance->getChildObject()->isSynchronized());
|
205 |
+
|
206 |
+
$logViewUrl = $this->getUrl('*/adminhtml_common_log/listing',array(
|
207 |
+
'id' => $listingData['id'],
|
208 |
+
'back' => $helper->makeBackUrlParam('*/adminhtml_common_amazon_listing/view',
|
209 |
+
array('id' =>$listingData['id']))
|
210 |
+
));
|
211 |
+
$getErrorsSummary = $this->getUrl('*/adminhtml_listing/getErrorsSummary');
|
212 |
+
|
213 |
+
$runListProducts = $this->getUrl('*/adminhtml_common_amazon_listing/runListProducts');
|
214 |
+
$runReviseProducts = $this->getUrl('*/adminhtml_common_amazon_listing/runReviseProducts');
|
215 |
+
$runRelistProducts = $this->getUrl('*/adminhtml_common_amazon_listing/runRelistProducts');
|
216 |
+
$runStopProducts = $this->getUrl('*/adminhtml_common_amazon_listing/runStopProducts');
|
217 |
+
$runStopAndRemoveProducts = $this->getUrl('*/adminhtml_common_amazon_listing/runStopAndRemoveProducts');
|
218 |
+
$runDeleteAndRemoveProducts = $this->getUrl('*/adminhtml_common_amazon_listing/runDeleteAndRemoveProducts');
|
219 |
+
|
220 |
+
$prepareData = $this->getUrl('*/adminhtml_listing_moving/prepareMoveToListing');
|
221 |
+
$getMoveToListingGridHtml = $this->getUrl('*/adminhtml_listing_moving/moveToListingGrid');
|
222 |
+
$getFailedProductsGridHtml = $this->getUrl('*/adminhtml_listing_moving/getFailedProductsGrid');
|
223 |
+
$tryToMoveToListing = $this->getUrl('*/adminhtml_listing_moving/tryToMoveToListing');
|
224 |
+
$moveToListing = $this->getUrl('*/adminhtml_listing_moving/moveToListing');
|
225 |
+
|
226 |
+
$marketplaceSynchUrl = $this->getUrl(
|
227 |
+
'*/adminhtml_common_marketplace/index',
|
228 |
+
array('tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_AMAZON)
|
229 |
+
);
|
230 |
+
|
231 |
+
$getVariationEditPopupUrl = $this->getUrl('*/adminhtml_common_listing/getVariationEditPopup');
|
232 |
+
$getVariationManagePopupUrl = $this->getUrl('*/adminhtml_common_listing/getVariationManagePopup');
|
233 |
+
|
234 |
+
$variationEditActionUrl = $this->getUrl('*/adminhtml_common_listing/variationEdit');
|
235 |
+
$variationManageActionUrl = $this->getUrl('*/adminhtml_common_listing/variationManage');
|
236 |
+
$variationManageGenerateActionUrl = $this->getUrl('*/adminhtml_common_listing/variationManageGenerate');
|
237 |
+
|
238 |
+
$popupTitle = $helper->escapeJs($helper->__('Moving Amazon Items.'));
|
239 |
+
$failedProductsPopupTitle = $helper->escapeJs($helper->__('Products failed to move'));
|
240 |
+
|
241 |
+
$taskCompletedMessage = $helper->escapeJs($helper->__('Task completed. Please wait ...'));
|
242 |
+
$taskCompletedSuccessMessage = $helper->escapeJs(
|
243 |
+
$helper->__('"%task_title%" task has successfully submitted to be processed.')
|
244 |
+
);
|
245 |
+
$taskCompletedWarningMessage = $helper->escapeJs($helper->__(
|
246 |
+
'"%task_title%" task has completed with warnings. <a target="_blank" href="%url%">View log</a> for details.'
|
247 |
+
));
|
248 |
+
$taskCompletedErrorMessage = $helper->escapeJs($helper->__(
|
249 |
+
'"%task_title%" task has completed with errors. <a target="_blank" href="%url%">View log</a> for details.'
|
250 |
+
));
|
251 |
+
|
252 |
+
$lockedObjNoticeMessage = $helper->escapeJs($helper->__('Some Amazon request(s) are being processed now.'));
|
253 |
+
$sendingDataToAmazonMessage = $helper->escapeJs($helper->__(
|
254 |
+
'Sending %product_title% product(s) data on Amazon.')
|
255 |
+
);
|
256 |
+
$viewAllProductLogMessage = $helper->escapeJs($helper->__('View All Product Log.'));
|
257 |
+
|
258 |
+
$listingLockedMessage = $helper->escapeJs(
|
259 |
+
$helper->__('The listing was locked by another process. Please try again later.')
|
260 |
+
);
|
261 |
+
$listingEmptyMessage = $helper->escapeJs($helper->__('Listing is empty.'));
|
262 |
+
|
263 |
+
$listingAllItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
264 |
+
->__('Listing All Items On Amazon'));
|
265 |
+
$listingSelectedItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
266 |
+
->__('Listing Selected Items On Amazon'));
|
267 |
+
$revisingSelectedItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
268 |
+
->__('Revising Selected Items On Amazon'));
|
269 |
+
$relistingSelectedItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
270 |
+
->__('Relisting Selected Items On Amazon'));
|
271 |
+
$stoppingSelectedItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
272 |
+
->__('Stopping Selected Items On Amazon'));
|
273 |
+
$stoppingAndRemovingSelectedItemsMessage = Mage::helper('M2ePro')
|
274 |
+
->escapeJs(Mage::helper('M2ePro')
|
275 |
+
->__('Stopping On Amazon And Removing From Listing Selected Items'));
|
276 |
+
$deletingAndRemovingSelectedItemsMessage = Mage::helper('M2ePro')
|
277 |
+
->escapeJs(Mage::helper('M2ePro')
|
278 |
+
->__('Removing From Amazon And Listing Selected Items'));
|
279 |
+
|
280 |
+
$successfullyMovedMessage = $helper->escapeJs($helper->__('Product(s) was successfully moved.'));
|
281 |
+
$productsWereNotMovedMessage = $helper->escapeJs(
|
282 |
+
$helper->__('Product(s) was not moved. <a target="_blank" href="%url%">View log</a> for details.')
|
283 |
+
);
|
284 |
+
$someProductsWereNotMovedMessage = $helper->escapeJs(
|
285 |
+
$helper->__('Some product(s) was not moved. <a target="_blank" href="%url%">View log</a> for details.')
|
286 |
+
);
|
287 |
+
|
288 |
+
$selectItemsMessage = $helper->escapeJs(
|
289 |
+
$helper->__('Please select the products you want to perform the action on.')
|
290 |
+
);
|
291 |
+
$selectActionMessage = $helper->escapeJs($helper->__('Please select action.'));
|
292 |
+
|
293 |
+
$successWord = $helper->escapeJs($helper->__('Success'));
|
294 |
+
$noticeWord = $helper->escapeJs($helper->__('Notice'));
|
295 |
+
$warningWord = $helper->escapeJs($helper->__('Warning'));
|
296 |
+
$errorWord = $helper->escapeJs($helper->__('Error'));
|
297 |
+
$closeWord = $helper->escapeJs($helper->__('Close'));
|
298 |
+
|
299 |
+
$assignString = Mage::helper('M2ePro')->__('Assign ASIN/ISBN');
|
300 |
+
$textConfirm = $helper->escapeJs($helper->__('Are you sure?'));
|
301 |
+
|
302 |
+
$searchAsinManual = $this->getUrl('*/adminhtml_common_amazon_listing/searchAsinManual');
|
303 |
+
$suggestedAsinGridHmtl = $this->getUrl('*/adminhtml_common_amazon_listing/getSuggestedAsinGrid');
|
304 |
+
$searchAsinAuto = $this->getUrl('*/adminhtml_common_amazon_listing/searchAsinAuto');
|
305 |
+
$mapToAsin = $this->getUrl('*/adminhtml_common_amazon_listing/mapToAsin');
|
306 |
+
$unmapFromAsin = $this->getUrl('*/adminhtml_common_amazon_listing/unmapFromAsin');
|
307 |
+
|
308 |
+
$newAsinUrl = $this->getUrl('*/adminhtml_common_amazon_template_newProduct',array(
|
309 |
+
'marketplace_id' => Mage::helper('M2ePro/Data_Global')->getValue('marketplace_id'),
|
310 |
+
));
|
311 |
+
|
312 |
+
$enterProductSearchQueryMessage = $helper->escapeJs(
|
313 |
+
$helper->__('Please enter product name or ASIN/ISBN/UPC/EAN.')
|
314 |
+
);
|
315 |
+
$autoMapAsinProgressTitle = $helper->escapeJs($helper->__('Assign ASIN/ISBN to Item(s)'));
|
316 |
+
$autoMapAsinErrorMessage = $helper->escapeJs(
|
317 |
+
$helper->__('Server is currently unavailable. Please try again later.')
|
318 |
+
);
|
319 |
+
$newAsinNotAvailable = $helper->escapeJs(
|
320 |
+
$helper->__('The new ASIN creation functionality is not available in %code% marketplace yet.')
|
321 |
+
);
|
322 |
+
$notSynchronizedMarketplace = $helper->escapeJs(
|
323 |
+
$helper->__(
|
324 |
+
'In order to use New ASIN functionality, please re-synchronize marketplace data.'
|
325 |
+
).' '.
|
326 |
+
$helper->__(
|
327 |
+
'Press "Save And Update" button after redirect on marketplace page.'
|
328 |
+
)
|
329 |
+
);
|
330 |
+
|
331 |
+
$noVariationsLeftText = $helper->__('All variations are already added.');
|
332 |
+
|
333 |
+
$javascriptsMain = <<<JAVASCRIPT
|
334 |
+
<script type="text/javascript">
|
335 |
+
|
336 |
+
if (typeof M2ePro == 'undefined') {
|
337 |
+
M2ePro = {};
|
338 |
+
M2ePro.url = {};
|
339 |
+
M2ePro.formData = {};
|
340 |
+
M2ePro.customData = {};
|
341 |
+
M2ePro.text = {};
|
342 |
+
}
|
343 |
+
|
344 |
+
M2ePro.url.add({$urls});
|
345 |
+
|
346 |
+
M2ePro.productsIdsForList = '{$productsIdsForList}';
|
347 |
+
|
348 |
+
M2ePro.url.logViewUrl = '{$logViewUrl}';
|
349 |
+
M2ePro.url.getErrorsSummary = '{$getErrorsSummary}';
|
350 |
+
|
351 |
+
M2ePro.url.runListProducts = '{$runListProducts}';
|
352 |
+
M2ePro.url.runReviseProducts = '{$runReviseProducts}';
|
353 |
+
M2ePro.url.runRelistProducts = '{$runRelistProducts}';
|
354 |
+
M2ePro.url.runStopProducts = '{$runStopProducts}';
|
355 |
+
M2ePro.url.runStopAndRemoveProducts = '{$runStopAndRemoveProducts}';
|
356 |
+
M2ePro.url.runDeleteAndRemoveProducts = '{$runDeleteAndRemoveProducts}';
|
357 |
+
|
358 |
+
M2ePro.url.searchAsinManual = '{$searchAsinManual}';
|
359 |
+
M2ePro.url.searchAsinAuto = '{$searchAsinAuto}';
|
360 |
+
M2ePro.url.suggestedAsinGrid = '{$suggestedAsinGridHmtl}';
|
361 |
+
M2ePro.url.mapToAsin = '{$mapToAsin}';
|
362 |
+
M2ePro.url.unmapFromAsin = '{$unmapFromAsin}';
|
363 |
+
|
364 |
+
M2ePro.url.newAsin = '{$newAsinUrl}';
|
365 |
+
|
366 |
+
M2ePro.url.prepareData = '{$prepareData}';
|
367 |
+
M2ePro.url.getGridHtml = '{$getMoveToListingGridHtml}';
|
368 |
+
M2ePro.url.getFailedProductsGridHtml = '{$getFailedProductsGridHtml}';
|
369 |
+
M2ePro.url.tryToMoveToListing = '{$tryToMoveToListing}';
|
370 |
+
M2ePro.url.moveToListing = '{$moveToListing}';
|
371 |
+
|
372 |
+
M2ePro.url.marketplace_synch = '{$marketplaceSynchUrl}';
|
373 |
+
|
374 |
+
M2ePro.url.get_variation_edit_popup = '{$getVariationEditPopupUrl}';
|
375 |
+
M2ePro.url.get_variation_manage_popup = '{$getVariationManagePopupUrl}';
|
376 |
+
|
377 |
+
M2ePro.url.variation_edit_action = '{$variationEditActionUrl}';
|
378 |
+
M2ePro.url.variation_manage_action = '{$variationManageActionUrl}';
|
379 |
+
M2ePro.url.variation_manage_generate_action = '{$variationManageGenerateActionUrl}';
|
380 |
+
|
381 |
+
M2ePro.text.popup_title = '{$popupTitle}';
|
382 |
+
M2ePro.text.failed_products_popup_title = '{$failedProductsPopupTitle}';
|
383 |
+
|
384 |
+
M2ePro.text.task_completed_message = '{$taskCompletedMessage}';
|
385 |
+
M2ePro.text.task_completed_success_message = '{$taskCompletedSuccessMessage}';
|
386 |
+
M2ePro.text.task_completed_warning_message = '{$taskCompletedWarningMessage}';
|
387 |
+
M2ePro.text.task_completed_error_message = '{$taskCompletedErrorMessage}';
|
388 |
+
|
389 |
+
M2ePro.text.locked_obj_notice = '{$lockedObjNoticeMessage}';
|
390 |
+
M2ePro.text.sending_data_message = '{$sendingDataToAmazonMessage}';
|
391 |
+
M2ePro.text.view_all_product_log_message = '{$viewAllProductLogMessage}';
|
392 |
+
|
393 |
+
M2ePro.text.listing_locked_message = '{$listingLockedMessage}';
|
394 |
+
M2ePro.text.listing_empty_message = '{$listingEmptyMessage}';
|
395 |
+
|
396 |
+
M2ePro.text.listing_all_items_message = '{$listingAllItemsMessage}';
|
397 |
+
M2ePro.text.listing_selected_items_message = '{$listingSelectedItemsMessage}';
|
398 |
+
M2ePro.text.revising_selected_items_message = '{$revisingSelectedItemsMessage}';
|
399 |
+
M2ePro.text.relisting_selected_items_message = '{$relistingSelectedItemsMessage}';
|
400 |
+
M2ePro.text.stopping_selected_items_message = '{$stoppingSelectedItemsMessage}';
|
401 |
+
M2ePro.text.stopping_and_removing_selected_items_message = '{$stoppingAndRemovingSelectedItemsMessage}';
|
402 |
+
M2ePro.text.deleting_and_removing_selected_items_message = '{$deletingAndRemovingSelectedItemsMessage}';
|
403 |
+
|
404 |
+
M2ePro.text.successfully_moved = '{$successfullyMovedMessage}';
|
405 |
+
M2ePro.text.products_were_not_moved = '{$productsWereNotMovedMessage}';
|
406 |
+
M2ePro.text.some_products_were_not_moved = '{$someProductsWereNotMovedMessage}';
|
407 |
+
|
408 |
+
M2ePro.text.select_items_message = '{$selectItemsMessage}';
|
409 |
+
M2ePro.text.select_action_message = '{$selectActionMessage}';
|
410 |
+
|
411 |
+
M2ePro.text.success_word = '{$successWord}';
|
412 |
+
M2ePro.text.notice_word = '{$noticeWord}';
|
413 |
+
M2ePro.text.warning_word = '{$warningWord}';
|
414 |
+
M2ePro.text.error_word = '{$errorWord}';
|
415 |
+
M2ePro.text.close_word = '{$closeWord}';
|
416 |
+
|
417 |
+
M2ePro.text.assign = '{$assignString}';
|
418 |
+
M2ePro.text.confirm = '{$textConfirm}';
|
419 |
+
|
420 |
+
M2ePro.text.enter_productSearch_query = '{$enterProductSearchQueryMessage}';
|
421 |
+
M2ePro.text.automap_asin_progress_title = '{$autoMapAsinProgressTitle}';
|
422 |
+
M2ePro.text.automap_error_message = '{$autoMapAsinErrorMessage}';
|
423 |
+
|
424 |
+
M2ePro.text.new_asin_not_available = '{$newAsinNotAvailable}';
|
425 |
+
M2ePro.text.not_synchronized_marketplace = '{$notSynchronizedMarketplace}';
|
426 |
+
|
427 |
+
M2ePro.text.no_variations_left = '{$noVariationsLeftText}';
|
428 |
+
|
429 |
+
M2ePro.customData.componentMode = '{$component}';
|
430 |
+
M2ePro.customData.gridId = '{$gridId}';
|
431 |
+
M2ePro.customData.ignoreListings = '{$ignoreListings}';
|
432 |
+
|
433 |
+
M2ePro.customData.marketplace = {$marketplace};
|
434 |
+
M2ePro.customData.isNewAsinAvailable = {$isNewAsinAvailable};
|
435 |
+
M2ePro.customData.isMarketplaceSynchronized = {$isMarketplaceSynchronized};
|
436 |
+
|
437 |
+
Event.observe(window, 'load', function() {
|
438 |
+
|
439 |
+
ListingGridHandlerObj = new AmazonListingGridHandler(
|
440 |
+
'amazonListingViewGrid{$listingData['id']}',
|
441 |
+
{$listingData['id']}
|
442 |
+
);
|
443 |
+
|
444 |
+
// todo next
|
445 |
+
ListingGridHandlerObj.actionHandler.setOptions(M2ePro);
|
446 |
+
ListingGridHandlerObj.movingHandler.setOptions(M2ePro);
|
447 |
+
ListingGridHandlerObj.productSearchHandler.setOptions(M2ePro);
|
448 |
+
|
449 |
+
ListingProgressBarObj = new ProgressBar('listing_view_progress_bar');
|
450 |
+
GridWrapperObj = new AreaWrapper('listing_view_content_container');
|
451 |
+
|
452 |
+
ListingProductVariationHandlerObj = new ListingProductVariationHandler(M2ePro,
|
453 |
+
ListingGridHandlerObj);
|
454 |
+
|
455 |
+
if (M2ePro.productsIdsForList) {
|
456 |
+
ListingGridHandlerObj.getGridMassActionObj().checkedString = M2ePro.productsIdsForList;
|
457 |
+
ListingGridHandlerObj.actionHandler.listAction();
|
458 |
+
}
|
459 |
+
|
460 |
+
});
|
461 |
+
|
462 |
+
</script>
|
463 |
+
JAVASCRIPT;
|
464 |
+
|
465 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_listing_view_help');
|
466 |
+
$productSearchMenuBlock = $this->getLayout()
|
467 |
+
->createBlock('M2ePro/adminhtml_common_amazon_listing_productSearch_menu');
|
468 |
+
$productSearchBlock = $this->getLayout()
|
469 |
+
->createBlock('M2ePro/adminhtml_common_amazon_listing_productSearch_main');
|
470 |
+
|
471 |
+
//------------------------------
|
472 |
+
$data = array(
|
473 |
+
'target_css_class' => 'edit_template_drop_down',
|
474 |
+
'items' => $this->getTemplatesButtonDropDownItems()
|
475 |
+
);
|
476 |
+
$templatesDropDownBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_button_dropDown');
|
477 |
+
$templatesDropDownBlock->setData($data);
|
478 |
+
//------------------------------
|
479 |
+
|
480 |
+
//------------------------------
|
481 |
+
$data = array(
|
482 |
+
'target_css_class' => 'add_products_drop_down',
|
483 |
+
'items' => $this->getAddProductsDropDownItems()
|
484 |
+
);
|
485 |
+
$addProductsDropDownBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_button_dropDown');
|
486 |
+
$addProductsDropDownBlock->setData($data);
|
487 |
+
//------------------------------
|
488 |
+
|
489 |
+
return $javascriptsMain
|
490 |
+
. $templatesDropDownBlock->toHtml()
|
491 |
+
. $addProductsDropDownBlock->toHtml()
|
492 |
+
. $helpBlock->toHtml()
|
493 |
+
. $productSearchMenuBlock->toHtml()
|
494 |
+
. $productSearchBlock->toHtml()
|
495 |
+
. parent::getGridHtml();
|
496 |
+
}
|
497 |
+
|
498 |
+
protected function getTemplatesButtonDropDownItems()
|
499 |
+
{
|
500 |
+
$items = array();
|
501 |
+
|
502 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
503 |
+
|
504 |
+
//------------------------------
|
505 |
+
$url = $this->getUrl(
|
506 |
+
'*/adminhtml_common_amazon_template_sellingFormat/edit',
|
507 |
+
array(
|
508 |
+
'id' => $listingData['template_selling_format_id']
|
509 |
+
)
|
510 |
+
);
|
511 |
+
$items[] = array(
|
512 |
+
'url' => $url,
|
513 |
+
'label' => Mage::helper('M2ePro')->__('Selling Format Template'),
|
514 |
+
'target' => '_blank'
|
515 |
+
);
|
516 |
+
//------------------------------
|
517 |
+
|
518 |
+
//------------------------------
|
519 |
+
$url = $this->getUrl(
|
520 |
+
'*/adminhtml_common_amazon_template_synchronization/edit',
|
521 |
+
array(
|
522 |
+
'id' => $listingData['template_synchronization_id']
|
523 |
+
)
|
524 |
+
);
|
525 |
+
$items[] = array(
|
526 |
+
'url' => $url,
|
527 |
+
'label' => Mage::helper('M2ePro')->__('Synchronization Template'),
|
528 |
+
'target' => '_blank'
|
529 |
+
);
|
530 |
+
//------------------------------
|
531 |
+
|
532 |
+
return $items;
|
533 |
+
}
|
534 |
+
|
535 |
+
public function getAddProductsDropDownItems()
|
536 |
+
{
|
537 |
+
$items = array();
|
538 |
+
|
539 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
540 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam('view', array('id' => $listingData['id']));
|
541 |
+
|
542 |
+
//------------------------------
|
543 |
+
$url = $this->getUrl(
|
544 |
+
'*/adminhtml_common_amazon_listing/product',
|
545 |
+
array(
|
546 |
+
'id' => $listingData['id'],
|
547 |
+
'back' => $backUrl
|
548 |
+
)
|
549 |
+
);
|
550 |
+
$items[] = array(
|
551 |
+
'url' => $url,
|
552 |
+
'label' => Mage::helper('M2ePro')->__('From Products List')
|
553 |
+
);
|
554 |
+
//------------------------------
|
555 |
+
|
556 |
+
//------------------------------
|
557 |
+
$url = $this->getUrl(
|
558 |
+
'*/adminhtml_common_amazon_listing/categoryProduct',
|
559 |
+
array(
|
560 |
+
'id' => $listingData['id'],
|
561 |
+
'back' => $backUrl
|
562 |
+
)
|
563 |
+
);
|
564 |
+
$items[] = array(
|
565 |
+
'url' => $url,
|
566 |
+
'label' => Mage::helper('M2ePro')->__('From Categories')
|
567 |
+
);
|
568 |
+
//------------------------------
|
569 |
+
|
570 |
+
return $items;
|
571 |
+
}
|
572 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminh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Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Listing_View_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
/** @var $sellingFormatTemplate Ess_M2ePro_Model_Amazon_Template_SellingFormat */
|
10 |
+
private $sellingFormatTemplate = NULL;
|
11 |
+
|
12 |
+
private $lockedDataCache = array();
|
13 |
+
|
14 |
+
// ####################################
|
15 |
+
|
16 |
+
public function __construct()
|
17 |
+
{
|
18 |
+
parent::__construct();
|
19 |
+
|
20 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
21 |
+
|
22 |
+
// Initialization block
|
23 |
+
//------------------------------
|
24 |
+
$this->setId('amazonListingViewGrid'.$listingData['id']);
|
25 |
+
//------------------------------
|
26 |
+
|
27 |
+
// Set default values
|
28 |
+
//------------------------------
|
29 |
+
$this->setDefaultSort('product_id');
|
30 |
+
$this->setDefaultDir('DESC');
|
31 |
+
$this->setSaveParametersInSession(true);
|
32 |
+
$this->setUseAjax(true);
|
33 |
+
//------------------------------
|
34 |
+
|
35 |
+
$this->sellingFormatTemplate = Mage::helper('M2ePro/Component_Amazon')->getCachedObject(
|
36 |
+
'Template_SellingFormat', $listingData['template_selling_format_id'], NULL,
|
37 |
+
array('template')
|
38 |
+
);
|
39 |
+
}
|
40 |
+
|
41 |
+
// ####################################
|
42 |
+
|
43 |
+
protected function _prepareCollection()
|
44 |
+
{
|
45 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
46 |
+
|
47 |
+
// Get collection products in listing
|
48 |
+
//--------------------------------
|
49 |
+
$collection = Mage::helper('M2ePro/Component_Amazon')->getCollection('Listing_Product');
|
50 |
+
$collection->getSelect()->distinct();
|
51 |
+
$collection->getSelect()->where("`main_table`.`listing_id` = ?",(int)$listingData['id']);
|
52 |
+
//--------------------------------
|
53 |
+
|
54 |
+
// Communicate with magento product table
|
55 |
+
//--------------------------------
|
56 |
+
$dbSelect = Mage::getResourceModel('core/config')->getReadConnection()
|
57 |
+
->select()
|
58 |
+
->from(Mage::getSingleton('core/resource')
|
59 |
+
->getTableName('catalog_product_entity_varchar'),
|
60 |
+
new Zend_Db_Expr('MAX(`store_id`)'))
|
61 |
+
->where("`entity_id` = `main_table`.`product_id`")
|
62 |
+
->where("`attribute_id` = `ea`.`attribute_id`")
|
63 |
+
->where("`store_id` = 0 OR `store_id` = ?",(int)$listingData['store_id']);
|
64 |
+
|
65 |
+
$collection->getSelect()
|
66 |
+
//->join(array('csi'=>Mage::getSingleton('core/resource')
|
67 |
+
// ->getTableName('cataloginventory_stock_item')),
|
68 |
+
// '(csi.product_id = `main_table`.product_id)',array('qty'))
|
69 |
+
->join(array('cpe'=>Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')),
|
70 |
+
'(cpe.entity_id = `main_table`.product_id)',array('magento_sku'=>'sku'))
|
71 |
+
->join(array('cisi'=>Mage::getSingleton('core/resource')
|
72 |
+
->getTableName('cataloginventory_stock_item')),
|
73 |
+
'(cisi.product_id = `main_table`.product_id AND cisi.stock_id = 1)',
|
74 |
+
array('is_in_stock'))
|
75 |
+
->join(array('cpev'=>Mage::getSingleton('core/resource')
|
76 |
+
->getTableName('catalog_product_entity_varchar')),
|
77 |
+
"( `cpev`.`entity_id` = `main_table`.product_id )",
|
78 |
+
array('value'))
|
79 |
+
->join(array('ea'=>Mage::getSingleton('core/resource')->getTableName('eav_attribute')),
|
80 |
+
'(`cpev`.`attribute_id` = `ea`.`attribute_id` AND `ea`.`attribute_code` = \'name\')',
|
81 |
+
array());
|
82 |
+
|
83 |
+
//--------------------------------
|
84 |
+
|
85 |
+
$collection->getSelect()->where('cpev.store_id = ('.$dbSelect->__toString().')');
|
86 |
+
//exit($collection->getSelect()->__toString());
|
87 |
+
|
88 |
+
// Set collection to grid
|
89 |
+
$this->setCollection($collection);
|
90 |
+
|
91 |
+
return parent::_prepareCollection();
|
92 |
+
}
|
93 |
+
|
94 |
+
protected function _prepareColumns()
|
95 |
+
{
|
96 |
+
$this->addColumn('product_id', array(
|
97 |
+
'header' => Mage::helper('M2ePro')->__('Product ID'),
|
98 |
+
'align' => 'right',
|
99 |
+
'width' => '100px',
|
100 |
+
'type' => 'number',
|
101 |
+
'index' => 'product_id',
|
102 |
+
'filter_index' => 'main_table.product_id',
|
103 |
+
'frame_callback' => array($this, 'callbackColumnProductId')
|
104 |
+
));
|
105 |
+
|
106 |
+
$this->addColumn('name', array(
|
107 |
+
'header' => Mage::helper('M2ePro')->__('Product Title / SKU'),
|
108 |
+
'align' => 'left',
|
109 |
+
//'width' => '300px',
|
110 |
+
'type' => 'text',
|
111 |
+
'index' => 'value',
|
112 |
+
'filter_index' => 'cpev.value',
|
113 |
+
'frame_callback' => array($this, 'callbackColumnProductTitle'),
|
114 |
+
'filter_condition_callback' => array($this, 'callbackFilterTitle')
|
115 |
+
));
|
116 |
+
|
117 |
+
$this->addColumn('stock_availability',
|
118 |
+
array(
|
119 |
+
'header'=> Mage::helper('M2ePro')->__('Stock Availability'),
|
120 |
+
'width' => '100px',
|
121 |
+
'index' => 'is_in_stock',
|
122 |
+
'filter_index' => 'cisi.is_in_stock',
|
123 |
+
'type' => 'options',
|
124 |
+
'sortable' => false,
|
125 |
+
'options' => array(
|
126 |
+
1 => Mage::helper('M2ePro')->__('In Stock'),
|
127 |
+
0 => Mage::helper('M2ePro')->__('Out of Stock')
|
128 |
+
),
|
129 |
+
'frame_callback' => array($this, 'callbackColumnStockAvailability')
|
130 |
+
));
|
131 |
+
|
132 |
+
$this->addColumn('sku', array(
|
133 |
+
'header' => Mage::helper('M2ePro')->__('Amazon SKU'),
|
134 |
+
'align' => 'left',
|
135 |
+
'width' => '150px',
|
136 |
+
'type' => 'text',
|
137 |
+
'index' => 'sku',
|
138 |
+
'filter_index' => 'second_table.sku',
|
139 |
+
'frame_callback' => array($this, 'callbackColumnAmazonSku')
|
140 |
+
));
|
141 |
+
|
142 |
+
$this->addColumn('general_id', array(
|
143 |
+
'header' => Mage::helper('M2ePro')->__('ASIN / ISBN'),
|
144 |
+
'align' => 'left',
|
145 |
+
'width' => '100px',
|
146 |
+
'type' => 'text',
|
147 |
+
'index' => 'general_id',
|
148 |
+
'filter_index' => 'second_table.general_id',
|
149 |
+
'frame_callback' => array($this, 'callbackColumnGeneralId')
|
150 |
+
));
|
151 |
+
|
152 |
+
$this->addColumn('online_qty', array(
|
153 |
+
'header' => Mage::helper('M2ePro')->__('Amazon QTY'),
|
154 |
+
'align' => 'right',
|
155 |
+
'width' => '70px',
|
156 |
+
'type' => 'number',
|
157 |
+
'index' => 'online_qty',
|
158 |
+
'filter_index' => 'second_table.online_qty',
|
159 |
+
'frame_callback' => array($this, 'callbackColumnAvailableQty')
|
160 |
+
));
|
161 |
+
|
162 |
+
$this->addColumn('online_price', array(
|
163 |
+
'header' => Mage::helper('M2ePro')->__('Amazon Price'),
|
164 |
+
'align' => 'right',
|
165 |
+
'width' => '70px',
|
166 |
+
'type' => 'number',
|
167 |
+
'index' => 'online_price',
|
168 |
+
'filter_index' => 'second_table.online_price',
|
169 |
+
'frame_callback' => array($this, 'callbackColumnPrice')
|
170 |
+
));
|
171 |
+
|
172 |
+
$this->addColumn('is_afn_channel', array(
|
173 |
+
'header' => Mage::helper('M2ePro')->__('Fulfillment'),
|
174 |
+
'align' => 'right',
|
175 |
+
'width' => '90px',
|
176 |
+
'index' => 'is_afn_channel',
|
177 |
+
'filter_index' => 'second_table.is_afn_channel',
|
178 |
+
'type' => 'options',
|
179 |
+
'sortable' => false,
|
180 |
+
'options' => array(
|
181 |
+
0 => Mage::helper('M2ePro')->__('Merchant'),
|
182 |
+
1 => Mage::helper('M2ePro')->__('Amazon')
|
183 |
+
),
|
184 |
+
'frame_callback' => array($this, 'callbackColumnAfnChannel')
|
185 |
+
));
|
186 |
+
|
187 |
+
$this->addColumn('status', array(
|
188 |
+
'header' => Mage::helper('M2ePro')->__('Status'),
|
189 |
+
'width' => '125px',
|
190 |
+
'index' => 'status',
|
191 |
+
'filter_index' => 'main_table.status',
|
192 |
+
'type' => 'options',
|
193 |
+
'sortable' => false,
|
194 |
+
'options' => array(
|
195 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_UNKNOWN => Mage::helper('M2ePro')->__('Unknown'),
|
196 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED => Mage::helper('M2ePro')->__('Not Listed'),
|
197 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_LISTED => Mage::helper('M2ePro')->__('Active'),
|
198 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED => Mage::helper('M2ePro')->__('Inactive'),
|
199 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_BLOCKED => Mage::helper('M2ePro')->__('Inactive (Blocked)')
|
200 |
+
),
|
201 |
+
'frame_callback' => array($this, 'callbackColumnStatus')
|
202 |
+
));
|
203 |
+
|
204 |
+
if (Mage::helper('M2ePro/Module')->isDevelopmentMode()) {
|
205 |
+
$this->addColumn('developer_action', array(
|
206 |
+
'header' => Mage::helper('M2ePro')->__('Actions'),
|
207 |
+
'align' => 'left',
|
208 |
+
'width' => '120px',
|
209 |
+
'type' => 'text',
|
210 |
+
'renderer' => 'M2ePro/adminhtml_listing_view_grid_column_renderer_developerAction',
|
211 |
+
'index' => 'value',
|
212 |
+
'filter' => false,
|
213 |
+
'sortable' => false,
|
214 |
+
'js_handler' => 'ListingGridHandlerObj'
|
215 |
+
));
|
216 |
+
}
|
217 |
+
|
218 |
+
return parent::_prepareColumns();
|
219 |
+
}
|
220 |
+
|
221 |
+
protected function _prepareMassaction()
|
222 |
+
{
|
223 |
+
// Set massaction identifiers
|
224 |
+
//--------------------------------
|
225 |
+
$this->setMassactionIdField('main_table.id');
|
226 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
227 |
+
//--------------------------------
|
228 |
+
|
229 |
+
// Set mass-action
|
230 |
+
//--------------------------------
|
231 |
+
$this->getMassactionBlock()->addItem('list', array(
|
232 |
+
'label' => Mage::helper('M2ePro')->__('List Item(s)'),
|
233 |
+
'url' => '',
|
234 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
235 |
+
));
|
236 |
+
|
237 |
+
$this->getMassactionBlock()->addItem('revise', array(
|
238 |
+
'label' => Mage::helper('M2ePro')->__('Revise Item(s)'),
|
239 |
+
'url' => '',
|
240 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
241 |
+
));
|
242 |
+
|
243 |
+
$this->getMassactionBlock()->addItem('relist', array(
|
244 |
+
'label' => Mage::helper('M2ePro')->__('Relist Item(s)'),
|
245 |
+
'url' => '',
|
246 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
247 |
+
));
|
248 |
+
|
249 |
+
$this->getMassactionBlock()->addItem('stop', array(
|
250 |
+
'label' => Mage::helper('M2ePro')->__('Stop Item(s)'),
|
251 |
+
'url' => '',
|
252 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
253 |
+
));
|
254 |
+
|
255 |
+
$this->getMassactionBlock()->addItem('stopAndRemove', array(
|
256 |
+
'label' => Mage::helper('M2ePro')->__('Stop on Channel / Remove from Listing'),
|
257 |
+
'url' => '',
|
258 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
259 |
+
));
|
260 |
+
|
261 |
+
$this->getMassactionBlock()->addItem('deleteAndRemove', array(
|
262 |
+
'label' => Mage::helper('M2ePro')->__('Remove from Channel & Listing'),
|
263 |
+
'url' => '',
|
264 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
265 |
+
));
|
266 |
+
|
267 |
+
$this->getMassactionBlock()->addItem('moving', array(
|
268 |
+
'label' => Mage::helper('M2ePro')->__('Move Item(s) to Another Listing'),
|
269 |
+
'url' => '',
|
270 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
271 |
+
));
|
272 |
+
|
273 |
+
$this->getMassactionBlock()->addItem('assignGeneralId', array(
|
274 |
+
'label' => Mage::helper('M2ePro')->__('Assign ASIN/ISBN to Item(s)'),
|
275 |
+
'url' => '',
|
276 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
277 |
+
));
|
278 |
+
|
279 |
+
$this->getMassactionBlock()->addItem('newGeneralId', array(
|
280 |
+
'label' => Mage::helper('M2ePro')->__('Add New ASIN(s)'),
|
281 |
+
'url' => '',
|
282 |
+
));
|
283 |
+
|
284 |
+
$this->getMassactionBlock()->addItem('unassignGeneralId', array(
|
285 |
+
'label' => Mage::helper('M2ePro')->__('Unassign ASIN/ISBN'),
|
286 |
+
'url' => '',
|
287 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
288 |
+
));
|
289 |
+
|
290 |
+
$this->getMassactionBlock()->addItem('duplicate', array(
|
291 |
+
'label' => Mage::helper('M2ePro')->__('Duplicate'),
|
292 |
+
'url' => '',
|
293 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
294 |
+
));
|
295 |
+
//--------------------------------
|
296 |
+
|
297 |
+
return parent::_prepareMassaction();
|
298 |
+
}
|
299 |
+
|
300 |
+
// ####################################
|
301 |
+
|
302 |
+
public function callbackColumnProductId($value, $row, $column, $isExport)
|
303 |
+
{
|
304 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
305 |
+
|
306 |
+
$productId = (int)$row->getData('product_id');
|
307 |
+
$storeId = (int)$listingData['store_id'];
|
308 |
+
|
309 |
+
$withoutImageHtml = '<a href="'
|
310 |
+
.$this->getUrl('adminhtml/catalog_product/edit',
|
311 |
+
array('id' => $productId))
|
312 |
+
.'" target="_blank">'.$productId.'</a>';
|
313 |
+
|
314 |
+
$showProductsThumbnails = (bool)(int)Mage::helper('M2ePro/Module')->getConfig()
|
315 |
+
->getGroupValue('/view/',
|
316 |
+
'show_products_thumbnails');
|
317 |
+
if (!$showProductsThumbnails) {
|
318 |
+
return $withoutImageHtml;
|
319 |
+
}
|
320 |
+
|
321 |
+
/** @var $magentoProduct Ess_M2ePro_Model_Magento_Product */
|
322 |
+
$magentoProduct = Mage::getModel('M2ePro/Magento_Product');
|
323 |
+
$magentoProduct->setProductId($productId);
|
324 |
+
$magentoProduct->setStoreId($storeId);
|
325 |
+
|
326 |
+
$imageUrlResized = $magentoProduct->getThumbnailImageLink();
|
327 |
+
if (is_null($imageUrlResized)) {
|
328 |
+
return $withoutImageHtml;
|
329 |
+
}
|
330 |
+
|
331 |
+
$imageHtml = $productId.'<hr style="border: 1px solid silver; border-bottom: none;"><img src="'.
|
332 |
+
$imageUrlResized.'" />';
|
333 |
+
$withImageHtml = str_replace('>'.$productId.'<','>'.$imageHtml.'<',$withoutImageHtml);
|
334 |
+
|
335 |
+
return $withImageHtml;
|
336 |
+
}
|
337 |
+
|
338 |
+
public function callbackColumnProductTitle($productTitle, $row, $column, $isExport)
|
339 |
+
{
|
340 |
+
if (strlen($productTitle) > 60) {
|
341 |
+
$productTitle = substr($productTitle, 0, 60) . '...';
|
342 |
+
}
|
343 |
+
|
344 |
+
$productTitle = Mage::helper('M2ePro')->escapeHtml($productTitle);
|
345 |
+
|
346 |
+
$value = '<span>'.$productTitle.'</span>';
|
347 |
+
|
348 |
+
$tempSku = $row->getData('magento_sku');
|
349 |
+
is_null($tempSku)
|
350 |
+
&& $tempSku = Mage::getModel('M2ePro/Magento_Product')->setProductId($row->getData('product_id'))->getSku();
|
351 |
+
|
352 |
+
$value .= '<br/><strong>'.Mage::helper('M2ePro')->__('SKU') .
|
353 |
+
':</strong> '.Mage::helper('M2ePro')->escapeHtml($tempSku) . '<br>';
|
354 |
+
|
355 |
+
$listingProductId = (int)$row->getData('listing_product_id');
|
356 |
+
|
357 |
+
if (!$row->getChildObject()->isVariationProduct()) {
|
358 |
+
return $value;
|
359 |
+
}
|
360 |
+
|
361 |
+
$additionalData = $row->getData('additional_data');
|
362 |
+
$additionalData = (array)json_decode($additionalData, true);
|
363 |
+
$additionalData = array_filter($additionalData);
|
364 |
+
$variations = isset($additionalData['variation_options']) ? $additionalData['variation_options'] : array();
|
365 |
+
|
366 |
+
$value .= '<div style="font-size: 11px; color: grey; margin-left: 7px"><br>';
|
367 |
+
foreach ($variations as $attribute => $option) {
|
368 |
+
!$option && $option = '--';
|
369 |
+
$value .= '<strong>' . Mage::helper('M2ePro')->escapeHtml($attribute) .
|
370 |
+
'</strong>: ' . Mage::helper('M2ePro')->escapeHtml($option) . '<br>';
|
371 |
+
}
|
372 |
+
$value .= '</div>';
|
373 |
+
|
374 |
+
if (!$row->getChildObject()->isVariationMatched()) {
|
375 |
+
|
376 |
+
$popupTitle = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')->escapeHtml(
|
377 |
+
Mage::helper('M2ePro')->__('Manage "%product_title%" Options', $productTitle))
|
378 |
+
);
|
379 |
+
$linkTitle = Mage::helper('M2ePro')->__('Manage Options');
|
380 |
+
$linkContent = '<img height="12" width="12" src="'.$this->getSkinUrl('M2ePro').'/images/add.png'.'">';
|
381 |
+
|
382 |
+
$value.= <<<HTML
|
383 |
+
<div style="clear: both"></div>
|
384 |
+
<div style="float: left; margin: 0 0 0 5px">
|
385 |
+
<a href="javascript:"
|
386 |
+
onclick="ListingProductVariationHandlerObj
|
387 |
+
.setListingProductId({$listingProductId})
|
388 |
+
.showManagePopup('{$popupTitle}');"
|
389 |
+
title="{$linkTitle}">{$linkContent}</a>
|
390 |
+
</div>
|
391 |
+
HTML;
|
392 |
+
|
393 |
+
$linkContent = Mage::helper('M2ePro')->__('Manage Options');
|
394 |
+
|
395 |
+
$value .= <<<HTML
|
396 |
+
<div style="float: left; margin: 0 0 0 5px">
|
397 |
+
<a href="javascript:"
|
398 |
+
onclick="ListingProductVariationHandlerObj
|
399 |
+
.setListingProductId({$listingProductId})
|
400 |
+
.showManagePopup('{$popupTitle}');"
|
401 |
+
title="{$linkTitle}">{$linkContent}</a>
|
402 |
+
</div>
|
403 |
+
HTML;
|
404 |
+
|
405 |
+
return $value;
|
406 |
+
}
|
407 |
+
|
408 |
+
// ---------------------------------
|
409 |
+
$hasInActionLock = $this->getLockedData($row);
|
410 |
+
$hasInActionLock = $hasInActionLock['in_action'];
|
411 |
+
// ---------------------------------
|
412 |
+
|
413 |
+
if (!$hasInActionLock) {
|
414 |
+
|
415 |
+
$popupTitle = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')->escapeHtml(
|
416 |
+
Mage::helper('M2ePro')->__('Edit "%product_title%" Variation', $productTitle))
|
417 |
+
);
|
418 |
+
$linkTitle = Mage::helper('M2ePro')->__('Edit');
|
419 |
+
$linkContent = '<img width="12" height="12" src="'.$this->getSkinUrl('M2ePro').'/images/pencil.png'.'">';
|
420 |
+
|
421 |
+
$value .= <<<HTML
|
422 |
+
<div style="clear: both"></div>
|
423 |
+
<div style="margin: 0 0 0 7px; float: left;">
|
424 |
+
<a href="javascript:"
|
425 |
+
onclick="ListingProductVariationHandlerObj
|
426 |
+
.setListingProductId({$listingProductId})
|
427 |
+
.showEditPopup('{$popupTitle}');"
|
428 |
+
title="{$linkTitle}">{$linkContent}</a>
|
429 |
+
</div>
|
430 |
+
HTML;
|
431 |
+
}
|
432 |
+
|
433 |
+
$popupTitle = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')->escapeHtml(
|
434 |
+
Mage::helper('M2ePro')->__('Add Another "%product_title%" Variations', $productTitle))
|
435 |
+
);
|
436 |
+
$linkTitle = Mage::helper('M2ePro')->__('Add Another Variation');
|
437 |
+
$linkContent = '<img width="12" height="12" src="'.$this->getSkinUrl('M2ePro').'/images/add.png'.'">';
|
438 |
+
|
439 |
+
$value.= <<<HTML
|
440 |
+
<div style="margin: 0 0 0 5px; float: left;">
|
441 |
+
<a href="javascript:"
|
442 |
+
onclick="ListingProductVariationHandlerObj
|
443 |
+
.setListingProductId({$listingProductId})
|
444 |
+
.showManagePopup('{$popupTitle}');"
|
445 |
+
title="{$linkTitle}">{$linkContent}</a>
|
446 |
+
</div>
|
447 |
+
HTML;
|
448 |
+
|
449 |
+
return $value;
|
450 |
+
}
|
451 |
+
|
452 |
+
public function callbackColumnStockAvailability($value, $row, $column, $isExport)
|
453 |
+
{
|
454 |
+
if ((int)$row->getData('is_in_stock') <= 0) {
|
455 |
+
return '<span style="color: red;">'.$value.'</span>';
|
456 |
+
}
|
457 |
+
|
458 |
+
return $value;
|
459 |
+
}
|
460 |
+
|
461 |
+
public function callbackColumnAmazonSku($value, $row, $column, $isExport)
|
462 |
+
{
|
463 |
+
if (is_null($value) || $value === '') {
|
464 |
+
return Mage::helper('M2ePro')->__('N/A');
|
465 |
+
}
|
466 |
+
return $value;
|
467 |
+
}
|
468 |
+
|
469 |
+
public function callbackColumnGeneralId($generalId, $row, $column, $isExport)
|
470 |
+
{
|
471 |
+
if (empty($generalId)) {
|
472 |
+
return $this->getGeneralIdColumnValueEmptyGeneralId($row);
|
473 |
+
}
|
474 |
+
|
475 |
+
return $this->getGeneralIdColumnValueNotEmptyGeneralId($row);
|
476 |
+
}
|
477 |
+
|
478 |
+
public function callbackColumnAvailableQty($value, $row, $column, $isExport)
|
479 |
+
{
|
480 |
+
if ((int)$row->getData('status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
481 |
+
if (is_null($value) || $value === '') {
|
482 |
+
return Mage::helper('M2ePro')->__('N/A');
|
483 |
+
}
|
484 |
+
} else {
|
485 |
+
if (is_null($value) || $value === '') {
|
486 |
+
return '<i style="color:gray;">receiving...</i>';
|
487 |
+
}
|
488 |
+
}
|
489 |
+
|
490 |
+
if ((bool)$row->getData('is_afn_channel')) {
|
491 |
+
return '--';
|
492 |
+
}
|
493 |
+
|
494 |
+
if ($value <= 0) {
|
495 |
+
return '<span style="color: red;">0</span>';
|
496 |
+
}
|
497 |
+
|
498 |
+
return $value;
|
499 |
+
}
|
500 |
+
|
501 |
+
public function callbackColumnPrice($value, $row, $column, $isExport)
|
502 |
+
{
|
503 |
+
if ((int)$row->getData('status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
504 |
+
if (is_null($value) || $value === '') {
|
505 |
+
return Mage::helper('M2ePro')->__('N/A');
|
506 |
+
}
|
507 |
+
} else {
|
508 |
+
if (is_null($value) || $value === '') {
|
509 |
+
return '<i style="color:gray;">receiving...</i>';
|
510 |
+
}
|
511 |
+
}
|
512 |
+
|
513 |
+
$marketplaceId = Mage::helper('M2ePro/Data_Global')->getValue('marketplace_id');
|
514 |
+
$currency = Mage::helper('M2ePro/Component_Amazon')
|
515 |
+
->getCachedObject('Marketplace',$marketplaceId)
|
516 |
+
->getChildObject()
|
517 |
+
->getDefaultCurrency();
|
518 |
+
|
519 |
+
$salePriceValue = $row->getData('online_sale_price');
|
520 |
+
if (is_null($salePriceValue) ||
|
521 |
+
(float)$salePriceValue <= 0) {
|
522 |
+
$salePriceValue = null;
|
523 |
+
} else {
|
524 |
+
$salePriceValue = Mage::app()->getLocale()->currency($currency)->toCurrency($salePriceValue);
|
525 |
+
}
|
526 |
+
|
527 |
+
if ((float)$value <= 0) {
|
528 |
+
$result = '<span style="color: #f00;">0</span>';
|
529 |
+
} else {
|
530 |
+
$result = Mage::app()->getLocale()->currency($currency)->toCurrency($value);
|
531 |
+
}
|
532 |
+
|
533 |
+
return $result.($salePriceValue ? ' <br/><span style="color:gray;">'.$salePriceValue.'</span>' : '');
|
534 |
+
}
|
535 |
+
|
536 |
+
public function callbackColumnAfnChannel($value, $row, $column, $isExport)
|
537 |
+
{
|
538 |
+
if (is_null($value) || $value === '') {
|
539 |
+
return Mage::helper('M2ePro')->__('N/A');
|
540 |
+
}
|
541 |
+
|
542 |
+
switch ($row->getData('is_afn_channel')) {
|
543 |
+
case Ess_M2ePro_Model_Amazon_Listing_Product::IS_ISBN_GENERAL_ID_YES:
|
544 |
+
$value = '<span style="font-weight: bold;">' . $value . '</span>';
|
545 |
+
break;
|
546 |
+
|
547 |
+
default:
|
548 |
+
break;
|
549 |
+
}
|
550 |
+
|
551 |
+
return $value;
|
552 |
+
}
|
553 |
+
|
554 |
+
public function callbackColumnStatus($value, $row, $column, $isExport)
|
555 |
+
{
|
556 |
+
switch ($row->getData('status')) {
|
557 |
+
|
558 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_UNKNOWN:
|
559 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED:
|
560 |
+
$value = '<span style="color: gray;">' . $value . '</span>';
|
561 |
+
break;
|
562 |
+
|
563 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_LISTED:
|
564 |
+
$value = '<span style="color: green;">' . $value . '</span>';
|
565 |
+
break;
|
566 |
+
|
567 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED:
|
568 |
+
$value = '<span style="color: red;">'.$value.'</span>';
|
569 |
+
break;
|
570 |
+
|
571 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_BLOCKED:
|
572 |
+
$value = '<span style="color: orange; font-weight: bold;">'.$value.'</span>';
|
573 |
+
break;
|
574 |
+
|
575 |
+
default:
|
576 |
+
break;
|
577 |
+
}
|
578 |
+
|
579 |
+
$value .= $this->getViewLogIconHtml($row->getId());
|
580 |
+
|
581 |
+
$tempLocks = $this->getLockedData($row);
|
582 |
+
$tempLocks = $tempLocks['object_locks'];
|
583 |
+
|
584 |
+
foreach ($tempLocks as $lock) {
|
585 |
+
|
586 |
+
switch ($lock->getTag()) {
|
587 |
+
|
588 |
+
case 'list_action':
|
589 |
+
$value .= '<br><span style="color: #605fff">[List In Progress...]</span>';
|
590 |
+
break;
|
591 |
+
|
592 |
+
case 'relist_action':
|
593 |
+
$value .= '<br><span style="color: #605fff">[Relist In Progress...]</span>';
|
594 |
+
break;
|
595 |
+
|
596 |
+
case 'revise_action':
|
597 |
+
$value .= '<br><span style="color: #605fff">[Revise In Progress...]</span>';
|
598 |
+
break;
|
599 |
+
|
600 |
+
case 'stop_action':
|
601 |
+
$value .= '<br><span style="color: #605fff">[Stop In Progress...]</span>';
|
602 |
+
break;
|
603 |
+
|
604 |
+
case 'stop_and_remove_action':
|
605 |
+
$value .= '<br><span style="color: #605fff">[Stop And Remove In Progress...]</span>';
|
606 |
+
break;
|
607 |
+
|
608 |
+
case 'delete_and_remove_action':
|
609 |
+
$value .= '<br><span style="color: #605fff">[Remove In Progress...]</span>';
|
610 |
+
break;
|
611 |
+
|
612 |
+
default:
|
613 |
+
break;
|
614 |
+
|
615 |
+
}
|
616 |
+
}
|
617 |
+
|
618 |
+
return $value;
|
619 |
+
}
|
620 |
+
|
621 |
+
protected function callbackFilterTitle($collection, $column)
|
622 |
+
{
|
623 |
+
$value = $column->getFilter()->getValue();
|
624 |
+
|
625 |
+
if ($value == null) {
|
626 |
+
return;
|
627 |
+
}
|
628 |
+
|
629 |
+
$collection->getSelect()->where('cpev.value LIKE ? OR cpe.sku LIKE ?', '%'.$value.'%');
|
630 |
+
}
|
631 |
+
|
632 |
+
//----------------------------------------
|
633 |
+
|
634 |
+
public function getViewLogIconHtml($listingProductId)
|
635 |
+
{
|
636 |
+
$listingProductId = (int)$listingProductId;
|
637 |
+
|
638 |
+
// Get last messages
|
639 |
+
//--------------------------
|
640 |
+
/** @var $connRead Varien_Db_Adapter_Pdo_Mysql */
|
641 |
+
$connRead = Mage::getSingleton('core/resource')->getConnection('core_read');
|
642 |
+
|
643 |
+
$dbSelect = $connRead->select()
|
644 |
+
->from(
|
645 |
+
Mage::getResourceModel('M2ePro/Listing_Log')->getMainTable(),
|
646 |
+
array('action_id','action','type','description','create_date','initiator')
|
647 |
+
)
|
648 |
+
->where('`listing_product_id` = ?',$listingProductId)
|
649 |
+
->where('`action_id` IS NOT NULL')
|
650 |
+
->order(array('id DESC'))
|
651 |
+
->limit(30);
|
652 |
+
|
653 |
+
$logRows = $connRead->fetchAll($dbSelect);
|
654 |
+
//--------------------------
|
655 |
+
|
656 |
+
// Get grouped messages by action_id
|
657 |
+
//--------------------------
|
658 |
+
$actionsRows = array();
|
659 |
+
$tempActionRows = array();
|
660 |
+
$lastActionId = false;
|
661 |
+
|
662 |
+
foreach ($logRows as $row) {
|
663 |
+
|
664 |
+
$row['description'] = Mage::helper('M2ePro/View')->getModifiedLogMessage($row['description']);
|
665 |
+
|
666 |
+
if ($row['action_id'] !== $lastActionId) {
|
667 |
+
if (count($tempActionRows) > 0) {
|
668 |
+
$actionsRows[] = array(
|
669 |
+
'type' => $this->getMainTypeForActionId($tempActionRows),
|
670 |
+
'date' => $this->getMainDateForActionId($tempActionRows),
|
671 |
+
'action' => $this->getActionForAction($tempActionRows[0]),
|
672 |
+
'initiator' => $this->getInitiatorForAction($tempActionRows[0]),
|
673 |
+
'items' => $tempActionRows
|
674 |
+
);
|
675 |
+
$tempActionRows = array();
|
676 |
+
}
|
677 |
+
$lastActionId = $row['action_id'];
|
678 |
+
}
|
679 |
+
$tempActionRows[] = $row;
|
680 |
+
}
|
681 |
+
|
682 |
+
if (count($tempActionRows) > 0) {
|
683 |
+
$actionsRows[] = array(
|
684 |
+
'type' => $this->getMainTypeForActionId($tempActionRows),
|
685 |
+
'date' => $this->getMainDateForActionId($tempActionRows),
|
686 |
+
'action' => $this->getActionForAction($tempActionRows[0]),
|
687 |
+
'initiator' => $this->getInitiatorForAction($tempActionRows[0]),
|
688 |
+
'items' => $tempActionRows
|
689 |
+
);
|
690 |
+
}
|
691 |
+
|
692 |
+
if (count($actionsRows) <= 0) {
|
693 |
+
return '';
|
694 |
+
}
|
695 |
+
|
696 |
+
$tips = array(
|
697 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'Last action was completed successfully.',
|
698 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'Last action was completed with error(s).',
|
699 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'Last action was completed with warning(s).'
|
700 |
+
);
|
701 |
+
|
702 |
+
$icons = array(
|
703 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'normal',
|
704 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'error',
|
705 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'warning'
|
706 |
+
);
|
707 |
+
|
708 |
+
$summary = $this->getLayout()->createBlock('M2ePro/adminhtml_log_grid_summary', '', array(
|
709 |
+
'entity_id' => $listingProductId,
|
710 |
+
'rows' => $actionsRows,
|
711 |
+
'tips' => $tips,
|
712 |
+
'icons' => $icons,
|
713 |
+
'view_help_handler' => 'ListingGridHandlerObj.viewItemHelp',
|
714 |
+
'hide_help_handler' => 'ListingGridHandlerObj.hideItemHelp',
|
715 |
+
));
|
716 |
+
|
717 |
+
return $summary->toHtml();
|
718 |
+
}
|
719 |
+
|
720 |
+
public function getActionForAction($actionRows)
|
721 |
+
{
|
722 |
+
$string = '';
|
723 |
+
|
724 |
+
switch ($actionRows['action']) {
|
725 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_LIST_PRODUCT_ON_COMPONENT:
|
726 |
+
$string = Mage::helper('M2ePro')->__('List');
|
727 |
+
break;
|
728 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_RELIST_PRODUCT_ON_COMPONENT:
|
729 |
+
$string = Mage::helper('M2ePro')->__('Relist');
|
730 |
+
break;
|
731 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_REVISE_PRODUCT_ON_COMPONENT:
|
732 |
+
$string = Mage::helper('M2ePro')->__('Revise');
|
733 |
+
break;
|
734 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_STOP_PRODUCT_ON_COMPONENT:
|
735 |
+
$string = Mage::helper('M2ePro')->__('Stop');
|
736 |
+
break;
|
737 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_DELETE_PRODUCT_FROM_COMPONENT:
|
738 |
+
$string = Mage::helper('M2ePro')->__('Remove from Channel');
|
739 |
+
break;
|
740 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_STOP_AND_REMOVE_PRODUCT:
|
741 |
+
$string = Mage::helper('M2ePro')->__('Stop on Channel / Remove from Listing');
|
742 |
+
break;
|
743 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_DELETE_AND_REMOVE_PRODUCT:
|
744 |
+
$string = Mage::helper('M2ePro')->__('Remove from Channel & Listing');
|
745 |
+
break;
|
746 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_CHANGE_STATUS_ON_CHANNEL:
|
747 |
+
$string = Mage::helper('M2ePro')->__('Status Change');
|
748 |
+
break;
|
749 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_INVENTORY_SYNCHRONIZATION:
|
750 |
+
$string = Mage::helper('M2ePro')->__('Inventory Synchronization');
|
751 |
+
break;
|
752 |
+
}
|
753 |
+
|
754 |
+
return $string;
|
755 |
+
}
|
756 |
+
|
757 |
+
public function getInitiatorForAction($actionRows)
|
758 |
+
{
|
759 |
+
$string = '';
|
760 |
+
|
761 |
+
switch ((int)$actionRows['initiator']) {
|
762 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_UNKNOWN:
|
763 |
+
$string = '';
|
764 |
+
break;
|
765 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_USER:
|
766 |
+
$string = Mage::helper('M2ePro')->__('Manual');
|
767 |
+
break;
|
768 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION:
|
769 |
+
$string = Mage::helper('M2ePro')->__('Automatic');
|
770 |
+
break;
|
771 |
+
}
|
772 |
+
|
773 |
+
return $string;
|
774 |
+
}
|
775 |
+
|
776 |
+
public function getMainTypeForActionId($actionRows)
|
777 |
+
{
|
778 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS;
|
779 |
+
|
780 |
+
foreach ($actionRows as $row) {
|
781 |
+
if ($row['type'] == Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR) {
|
782 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR;
|
783 |
+
break;
|
784 |
+
}
|
785 |
+
if ($row['type'] == Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING) {
|
786 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING;
|
787 |
+
}
|
788 |
+
}
|
789 |
+
|
790 |
+
return $type;
|
791 |
+
}
|
792 |
+
|
793 |
+
public function getMainDateForActionId($actionRows)
|
794 |
+
{
|
795 |
+
$format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
|
796 |
+
return Mage::app()->getLocale()->date(strtotime($actionRows[0]['create_date']))->toString($format);
|
797 |
+
}
|
798 |
+
|
799 |
+
// ####################################
|
800 |
+
|
801 |
+
public function getGridUrl()
|
802 |
+
{
|
803 |
+
return $this->getUrl('*/adminhtml_common_amazon_listing/viewGrid', array('_current'=>true));
|
804 |
+
}
|
805 |
+
|
806 |
+
public function getRowUrl($row)
|
807 |
+
{
|
808 |
+
return false;
|
809 |
+
}
|
810 |
+
|
811 |
+
// ####################################
|
812 |
+
|
813 |
+
protected function _toHtml()
|
814 |
+
{
|
815 |
+
$javascriptsMain = <<<JAVASCRIPT
|
816 |
+
<script type="text/javascript">
|
817 |
+
|
818 |
+
if (typeof ListingGridHandlerObj != 'undefined') {
|
819 |
+
ListingGridHandlerObj.afterInitPage();
|
820 |
+
}
|
821 |
+
|
822 |
+
Event.observe(window, 'load', function() {
|
823 |
+
setTimeout(function() {
|
824 |
+
ListingGridHandlerObj.afterInitPage();
|
825 |
+
}, 350);
|
826 |
+
});
|
827 |
+
|
828 |
+
</script>
|
829 |
+
JAVASCRIPT;
|
830 |
+
|
831 |
+
return parent::_toHtml().$javascriptsMain;
|
832 |
+
}
|
833 |
+
|
834 |
+
// ####################################
|
835 |
+
|
836 |
+
private function getLockedData($row)
|
837 |
+
{
|
838 |
+
$listingProductId = $row->getData('listing_product_id');
|
839 |
+
if (!isset($this->lockedDataCache[$listingProductId])) {
|
840 |
+
$objectLocks = $row->getObjectLocks();
|
841 |
+
$tempArray = array(
|
842 |
+
'object_locks' => $objectLocks,
|
843 |
+
'in_action' => !empty($objectLocks),
|
844 |
+
);
|
845 |
+
$this->lockedDataCache[$listingProductId] = $tempArray;
|
846 |
+
}
|
847 |
+
|
848 |
+
return $this->lockedDataCache[$listingProductId];
|
849 |
+
}
|
850 |
+
|
851 |
+
// ####################################
|
852 |
+
|
853 |
+
private function getGeneralIdColumnValueEmptyGeneralId($row)
|
854 |
+
{
|
855 |
+
// ---------------------------------
|
856 |
+
if ((int)$row->getData('status') != Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
857 |
+
return '<i style="color:gray;">'.Mage::helper('M2ePro')->__('receiving...').'</i>';
|
858 |
+
}
|
859 |
+
// ---------------------------------
|
860 |
+
|
861 |
+
// ---------------------------------
|
862 |
+
$iconPath = $this->getSkinUrl('M2ePro').'/images/search_statuses/';
|
863 |
+
$marketplaceId = Mage::helper('M2ePro/Data_Global')->getValue('marketplace_id');
|
864 |
+
// ---------------------------------
|
865 |
+
|
866 |
+
// ---------------------------------
|
867 |
+
$lpId = $row->getData('listing_product_id');
|
868 |
+
|
869 |
+
$productTitle = Mage::helper('M2ePro')->escapeHtml($row->getData('value'));
|
870 |
+
if (strlen($productTitle) > 60) {
|
871 |
+
$productTitle = substr($productTitle, 0, 60) . '...';
|
872 |
+
}
|
873 |
+
$productTitle = Mage::helper('M2ePro')->escapeJs($productTitle);
|
874 |
+
// ---------------------------------
|
875 |
+
|
876 |
+
// ---------------------------------
|
877 |
+
$hasInActionLock = $this->getLockedData($row);
|
878 |
+
$hasInActionLock = $hasInActionLock['in_action'];
|
879 |
+
// ---------------------------------
|
880 |
+
|
881 |
+
$templateNewProductId = $row->getData('template_new_product_id');
|
882 |
+
if (!empty($templateNewProductId)) {
|
883 |
+
|
884 |
+
$newAsinTemplateUrl = $this->getUrl(
|
885 |
+
'*/adminhtml_common_amazon_template_newProduct/edit/',
|
886 |
+
array(
|
887 |
+
'id' => $templateNewProductId,
|
888 |
+
'marketplace_id' => $marketplaceId,
|
889 |
+
'listing_product_id' => $lpId,
|
890 |
+
'save_and_assign' => 0,
|
891 |
+
'back' => Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_amazon_listing/view',array(
|
892 |
+
'id' => $row->getData('listing_id'),
|
893 |
+
))
|
894 |
+
)
|
895 |
+
);
|
896 |
+
|
897 |
+
$newAsinTemplateTitle = Mage::getModel('M2ePro/Amazon_Template_NewProduct')
|
898 |
+
->load($templateNewProductId)
|
899 |
+
->getData('title');
|
900 |
+
|
901 |
+
if ($hasInActionLock) {
|
902 |
+
return $newAsinTemplateTitle;
|
903 |
+
}
|
904 |
+
|
905 |
+
$tip = Mage::helper('M2ePro')->__('Unassign New ASIN Template');
|
906 |
+
$iconSrc = $iconPath.'unassign.png';
|
907 |
+
|
908 |
+
return <<<HTML
|
909 |
+
|
910 |
+
<a href="{$newAsinTemplateUrl}">{$newAsinTemplateTitle}</a>
|
911 |
+
<a href="javascript: void(0);" title="{$tip}"
|
912 |
+
onclick="ListingGridHandlerObj.productSearchHandler.showUnmapFromGeneralIdPrompt('{$lpId}');">
|
913 |
+
<img src="{$iconSrc}" alt="" width="16" height="16">
|
914 |
+
</a>
|
915 |
+
HTML;
|
916 |
+
}
|
917 |
+
// ---------------------------------
|
918 |
+
|
919 |
+
$generalIdSearchStatus = $row->getData('general_id_search_status');
|
920 |
+
|
921 |
+
// ---------------------------------
|
922 |
+
if ($generalIdSearchStatus == Ess_M2ePro_Model_Amazon_Listing_Product::GENERAL_ID_SEARCH_STATUS_PROCESSING) {
|
923 |
+
|
924 |
+
$tip = Mage::helper('M2ePro')->__('Automatic ASIN/ISBN search in progress.');
|
925 |
+
$iconSrc = $iconPath.'processing.gif';
|
926 |
+
|
927 |
+
return <<<HTML
|
928 |
+
|
929 |
+
<a href="javascript: void(0);" title="{$tip}">
|
930 |
+
<img src="{$iconSrc}" alt="">
|
931 |
+
</a>
|
932 |
+
HTML;
|
933 |
+
}
|
934 |
+
// ---------------------------------
|
935 |
+
|
936 |
+
// ---------------------------------
|
937 |
+
$generalIdSearchSuggestData = $row->getData('general_id_search_suggest_data');
|
938 |
+
|
939 |
+
if (!is_null($generalIdSearchSuggestData)) {
|
940 |
+
$generalIdSearchSuggestData = @json_decode($generalIdSearchSuggestData,true);
|
941 |
+
}
|
942 |
+
// ---------------------------------
|
943 |
+
|
944 |
+
$na = Mage::helper('M2ePro')->__('N/A');
|
945 |
+
|
946 |
+
if (isset($generalIdSearchSuggestData['message'])) {
|
947 |
+
|
948 |
+
$tip = Mage::helper('M2ePro')->escapeHtml($generalIdSearchSuggestData['message']);
|
949 |
+
$tip = Mage::helper('M2ePro')->escapeJs($tip);
|
950 |
+
|
951 |
+
$iconSrc = $iconPath.'error.png';
|
952 |
+
|
953 |
+
return <<<HTML
|
954 |
+
{$na}
|
955 |
+
<a href="javascript: void(0);" title="{$tip}"
|
956 |
+
onclick="ListingGridHandlerObj.productSearchHandler.openPopUp(0,'{$productTitle}',{$lpId},'{$tip}');">
|
957 |
+
<img src="{$iconSrc}" alt="" width="16" height="16">
|
958 |
+
</a>
|
959 |
+
HTML;
|
960 |
+
}
|
961 |
+
|
962 |
+
if (!empty($generalIdSearchSuggestData)) {
|
963 |
+
|
964 |
+
$tip = Mage::helper('M2ePro')->__('Choose ASIN/ISBN from the list');
|
965 |
+
$iconSrc = $iconPath.'list.png';
|
966 |
+
|
967 |
+
return <<<HTML
|
968 |
+
{$na}
|
969 |
+
<a href="javascript:;" title="{$tip}"
|
970 |
+
onclick="ListingGridHandlerObj.productSearchHandler.openPopUp(1,'{$productTitle}',{$lpId})">
|
971 |
+
<img src="{$iconSrc}" alt="" width="16" height="16">
|
972 |
+
</a>
|
973 |
+
HTML;
|
974 |
+
}
|
975 |
+
|
976 |
+
$tip = Mage::helper('M2ePro')->__('Search for ASIN/ISBN');
|
977 |
+
$iconSrc = $iconPath.'search.png';
|
978 |
+
|
979 |
+
return <<<HTML
|
980 |
+
{$na}
|
981 |
+
<a href="javascript:;" title="{$tip}"
|
982 |
+
onclick="ListingGridHandlerObj.productSearchHandler.openPopUp(0,'{$productTitle}',{$lpId});">
|
983 |
+
<img src="{$iconSrc}" alt="" width="16" height="16">
|
984 |
+
</a>
|
985 |
+
HTML;
|
986 |
+
}
|
987 |
+
|
988 |
+
private function getGeneralIdColumnValueNotEmptyGeneralId($row)
|
989 |
+
{
|
990 |
+
$generalId = $row->getData('general_id');
|
991 |
+
$marketplaceId = Mage::helper('M2ePro/Data_Global')->getValue('marketplace_id');
|
992 |
+
|
993 |
+
$url = Mage::helper('M2ePro/Component_Amazon')->getItemUrl(
|
994 |
+
$generalId,
|
995 |
+
$marketplaceId
|
996 |
+
);
|
997 |
+
|
998 |
+
if ((int)$row->getData('status') != Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
999 |
+
return <<<HTML
|
1000 |
+
<a href="{$url}" target="_blank">{$generalId}</a>
|
1001 |
+
HTML;
|
1002 |
+
}
|
1003 |
+
|
1004 |
+
$iconPath = $this->getSkinUrl('M2ePro').'/images/search_statuses/';
|
1005 |
+
|
1006 |
+
$generalIdSearchStatus = $row->getData('general_id_search_status');
|
1007 |
+
|
1008 |
+
if (Ess_M2ePro_Model_Amazon_Listing_Product::GENERAL_ID_SEARCH_STATUS_SET_AUTOMATIC ==
|
1009 |
+
$generalIdSearchStatus) {
|
1010 |
+
|
1011 |
+
$tip = Mage::helper('M2ePro')->__('ASIN/ISBN was found automatically');
|
1012 |
+
|
1013 |
+
$text = <<<HTML
|
1014 |
+
<a href="{$url}" target="_blank" title="{$tip}" style="color:#40AADB;">{$generalId}</a>
|
1015 |
+
HTML;
|
1016 |
+
|
1017 |
+
} else {
|
1018 |
+
|
1019 |
+
$text = <<<HTML
|
1020 |
+
<a href="{$url}" target="_blank">{$generalId}</a>
|
1021 |
+
HTML;
|
1022 |
+
|
1023 |
+
}
|
1024 |
+
|
1025 |
+
// ---------------------------------
|
1026 |
+
$hasInActionLock = $this->getLockedData($row);
|
1027 |
+
$hasInActionLock = $hasInActionLock['in_action'];
|
1028 |
+
// ---------------------------------
|
1029 |
+
|
1030 |
+
if ($hasInActionLock) {
|
1031 |
+
return $text;
|
1032 |
+
}
|
1033 |
+
|
1034 |
+
$tip = Mage::helper('M2ePro')->__('Unassign ASIN/ISBN');
|
1035 |
+
$iconSrc = $iconPath.'unassign.png';
|
1036 |
+
|
1037 |
+
$lpId = $row->getData('listing_product_id');
|
1038 |
+
|
1039 |
+
$text .= <<<HTML
|
1040 |
+
<a href="javascript:;"
|
1041 |
+
onclick="ListingGridHandlerObj.productSearchHandler.showUnmapFromGeneralIdPrompt({$lpId});"
|
1042 |
+
title="{$tip}">
|
1043 |
+
<img src="{$iconSrc}" width="16" height="16"/>
|
1044 |
+
</a>
|
1045 |
+
HTML;
|
1046 |
+
|
1047 |
+
return $text;
|
1048 |
+
}
|
1049 |
+
|
1050 |
+
// ####################################
|
1051 |
+
}
|
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/Marketplace/Form.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_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 |
+
$marketplaces = Mage::helper('M2ePro/Component_Amazon')->getCollection('Marketplace')
|
34 |
+
->setOrder('group_title', 'ASC')
|
35 |
+
->setOrder('sorder','ASC')
|
36 |
+
->setOrder('title','ASC')
|
37 |
+
->getItems();
|
38 |
+
$groups = array();
|
39 |
+
$storedStatuses = array();
|
40 |
+
$previewGroup = '';
|
41 |
+
$idGroup = 1;
|
42 |
+
foreach($marketplaces as $marketplace) {
|
43 |
+
|
44 |
+
if ($marketplace->getGroupTitle() != $previewGroup) {
|
45 |
+
$previewGroup = $marketplace->getGroupTitle();
|
46 |
+
$groups[] = array(
|
47 |
+
'id' => $idGroup,
|
48 |
+
'title' => $previewGroup,
|
49 |
+
'marketplaces' => array()
|
50 |
+
);
|
51 |
+
$idGroup++;
|
52 |
+
}
|
53 |
+
|
54 |
+
$storedStatuses[] = array(
|
55 |
+
'marketplace_id' => $marketplace->getId(),
|
56 |
+
'status' => $marketplace->getStatus()
|
57 |
+
);
|
58 |
+
|
59 |
+
$marketplace = array(
|
60 |
+
'instance' => $marketplace,
|
61 |
+
'params' => array('locked'=>$marketplace->isLocked())
|
62 |
+
);
|
63 |
+
|
64 |
+
$groups[count($groups)-1]['marketplaces'][] = $marketplace;
|
65 |
+
}
|
66 |
+
|
67 |
+
$this->groups = $groups;
|
68 |
+
$this->storedStatuses = $storedStatuses;
|
69 |
+
//----------------------------
|
70 |
+
|
71 |
+
//------------------------------
|
72 |
+
$data = array(
|
73 |
+
'label' => Mage::helper('M2ePro')->__('Update Now'),
|
74 |
+
'onclick' => 'MarketplaceHandlerObj.runSingleSynchronization(this)',
|
75 |
+
'class' => 'run_single_button'
|
76 |
+
);
|
77 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
78 |
+
$this->setChild('run_single_button', $buttonBlock);
|
79 |
+
//------------------------------
|
80 |
+
|
81 |
+
return parent::_beforeToHtml();
|
82 |
+
}
|
83 |
+
|
84 |
+
// ########################################
|
85 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Order/Edit/ShippingAddress.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_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('reset', array(
|
59 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
60 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
61 |
+
'class' => 'reset'
|
62 |
+
));
|
63 |
+
//------------------------------
|
64 |
+
|
65 |
+
//------------------------------
|
66 |
+
$this->_addButton('save', array(
|
67 |
+
'label' => Mage::helper('M2ePro')->__('Save Order Address'),
|
68 |
+
'onclick' => 'CommonHandlerObj.save_click()',
|
69 |
+
'class' => 'save'
|
70 |
+
));
|
71 |
+
//------------------------------
|
72 |
+
}
|
73 |
+
}
|
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 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â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â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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/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_Order_Help extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
$this->setTemplate('M2ePro/common/amazon/order/help.phtml');
|
14 |
+
}
|
15 |
+
|
16 |
+
public function getContainerId()
|
17 |
+
{
|
18 |
+
return 'block_notice_amazon_orders_list';
|
19 |
+
}
|
20 |
+
}
|
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 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
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|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
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|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
'component' => $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 |
+
'component' => $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 |
+
'component' => $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/Synchronization/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_Amazon_Synchronization_Help extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
$this->setTemplate('M2ePro/common/amazon/synchronization/help.phtml');
|
13 |
+
}
|
14 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/NewProduct.php
ADDED
@@ -0,0 +1,95 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_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('amazonTemplateNewProduct');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_amazon_template_newProduct';
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$marketplace_id = $this->getRequest()->getParam('marketplace_id');
|
21 |
+
|
22 |
+
// Set header text
|
23 |
+
//------------------------------
|
24 |
+
$marketplaceInstance = Mage::helper('M2ePro/Component_Amazon')->getCachedObject('Marketplace',$marketplace_id);
|
25 |
+
$this->_headerText = Mage::helper('M2ePro')->__(
|
26 |
+
'New ASIN Templates For "%marketplace_code%" Marketplace (Beta)',
|
27 |
+
$marketplaceInstance->getCode()
|
28 |
+
);
|
29 |
+
//------------------------------
|
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 |
+
$listingProductIds = Mage::helper('M2ePro/Data_Session')->getValue('listing_product_ids');
|
42 |
+
|
43 |
+
$listingId = Mage::helper('M2ePro/Component_Amazon')
|
44 |
+
->getObject('Listing_Product',reset($listingProductIds))
|
45 |
+
->getListingId();
|
46 |
+
|
47 |
+
//------------------------------
|
48 |
+
$url = $this->getUrl('*/adminhtml_common_amazon_listing/view',array(
|
49 |
+
'id' => $listingId
|
50 |
+
));
|
51 |
+
$this->_addButton('back', array(
|
52 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
53 |
+
'onclick' => 'CommonHandlerObj.back_click(\''.$url.'\')',
|
54 |
+
'class' => 'back'
|
55 |
+
));
|
56 |
+
//------------------------------
|
57 |
+
|
58 |
+
//------------------------------
|
59 |
+
$this->_addButton('reset', array(
|
60 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
61 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
62 |
+
'class' => 'reset'
|
63 |
+
));
|
64 |
+
//------------------------------
|
65 |
+
|
66 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
67 |
+
'*/adminhtml_common_amazon_template_newProduct',
|
68 |
+
array(
|
69 |
+
'marketplace_id' => $marketplace_id
|
70 |
+
)
|
71 |
+
);
|
72 |
+
|
73 |
+
//------------------------------
|
74 |
+
$url = $this->getUrl(
|
75 |
+
'*/adminhtml_common_amazon_template_newProduct/add',
|
76 |
+
array(
|
77 |
+
'marketplace_id' => $marketplace_id,
|
78 |
+
'back' => $backUrl
|
79 |
+
)
|
80 |
+
);
|
81 |
+
$this->_addButton('new', array(
|
82 |
+
'label' => Mage::helper('M2ePro')->__('Add New ASIN Template'),
|
83 |
+
'onclick' => 'setLocation(\''.$url.'\')',
|
84 |
+
'class' => 'add'
|
85 |
+
));
|
86 |
+
//------------------------------
|
87 |
+
}
|
88 |
+
|
89 |
+
public function getGridHtml()
|
90 |
+
{
|
91 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_template_newProduct_help');
|
92 |
+
|
93 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
94 |
+
}
|
95 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/NewProduct/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_NewProduct_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('amazonTemplateNewProductEdit');
|
17 |
+
$this->_blockGroup = 'M2ePro';
|
18 |
+
$this->_controller = 'adminhtml_common_amazon_template_newProduct';
|
19 |
+
$this->_mode = 'edit';
|
20 |
+
//------------------------------
|
21 |
+
|
22 |
+
$marketplace_id = $this->getRequest()->getParam('marketplace_id');
|
23 |
+
|
24 |
+
// Set header text
|
25 |
+
//------------------------------
|
26 |
+
$marketplaceInstance = Mage::helper('M2ePro/Component_Amazon')->getCachedObject('Marketplace',$marketplace_id);
|
27 |
+
|
28 |
+
if ($this->getRequest()->getParam('id')) {
|
29 |
+
$this->_headerText = Mage::helper('M2ePro')->__(
|
30 |
+
'Edit "New ASIN" Template For "%marketplace_code%" Marketplace (Beta)',
|
31 |
+
$marketplaceInstance->getCode()
|
32 |
+
);
|
33 |
+
} else {
|
34 |
+
$this->_headerText = Mage::helper('M2ePro')->__(
|
35 |
+
'Add "New ASIN" Template For "%marketplace_code%" Marketplace (Beta)',
|
36 |
+
$marketplaceInstance->getCode()
|
37 |
+
);
|
38 |
+
}
|
39 |
+
//------------------------------
|
40 |
+
|
41 |
+
// Set buttons actions
|
42 |
+
//------------------------------
|
43 |
+
$this->removeButton('back');
|
44 |
+
$this->removeButton('reset');
|
45 |
+
$this->removeButton('delete');
|
46 |
+
$this->removeButton('add');
|
47 |
+
$this->removeButton('save');
|
48 |
+
$this->removeButton('edit');
|
49 |
+
//------------------------------
|
50 |
+
|
51 |
+
$hasBack = $this->getRequest()->getParam('back');
|
52 |
+
$listingProductIds = Mage::helper('M2ePro/Data_Session')->getValue('listing_product_ids');
|
53 |
+
$listingProductId = $this->getRequest()->getParam('listing_product_id');
|
54 |
+
|
55 |
+
if ($hasBack && ($listingProductIds || $listingProductId)) {
|
56 |
+
//------------------------------
|
57 |
+
$url = Mage::helper('M2ePro')->getBackUrl();
|
58 |
+
$this->_addButton('back', array(
|
59 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
60 |
+
'onclick' => 'CommonHandlerObj.back_click(\'' . $url .'\')',
|
61 |
+
'class' => 'back'
|
62 |
+
));
|
63 |
+
//------------------------------
|
64 |
+
}
|
65 |
+
|
66 |
+
//------------------------------
|
67 |
+
$this->_addButton('reset', array(
|
68 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
69 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
70 |
+
'class' => 'reset'
|
71 |
+
));
|
72 |
+
//------------------------------
|
73 |
+
|
74 |
+
//------------------------------
|
75 |
+
$params = array('marketplace_id' => $marketplace_id);
|
76 |
+
if ($listingProductId) {
|
77 |
+
$params['listing_product_id'] = $listingProductId;
|
78 |
+
}
|
79 |
+
$url = $this->getUrl('*/adminhtml_common_amazon_template_newProduct/add', $params);
|
80 |
+
$this->_addButton('save', array(
|
81 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
82 |
+
'onclick' => 'CommonHandlerObj.save_click(\''.$url.'\')',
|
83 |
+
'class' => 'save'
|
84 |
+
));
|
85 |
+
//------------------------------
|
86 |
+
|
87 |
+
$saveAndAssign = (int)$this->getRequest()->getParam('save_and_assign', 1);
|
88 |
+
|
89 |
+
if ($saveAndAssign && $listingProductIds) {
|
90 |
+
//------------------------------
|
91 |
+
$url = $this->getUrl(
|
92 |
+
'*/adminhtml_common_amazon_template_newProduct/add',
|
93 |
+
array(
|
94 |
+
'marketplace_id' => $marketplace_id,
|
95 |
+
'do_map' => true
|
96 |
+
)
|
97 |
+
);
|
98 |
+
$this->_addButton('save_and_map', array(
|
99 |
+
'label' => Mage::helper('M2ePro')->__('Save And Assign'),
|
100 |
+
'onclick' => 'CommonHandlerObj.save_click(\''.$url.'\')',
|
101 |
+
'class' => 'save'
|
102 |
+
));
|
103 |
+
//------------------------------
|
104 |
+
}
|
105 |
+
}
|
106 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/NewProduct/Edit/Form.php
ADDED
@@ -0,0 +1,32 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_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('amazonTemplateNewProductEditForm');
|
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 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/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_Amazon_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('amazonTemplateNewProductEditTabs');
|
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_amazon_template_newProduct_edit_tabs_general'
|
29 |
+
)->toHtml(),
|
30 |
+
));
|
31 |
+
|
32 |
+
$this->addTab('description', array(
|
33 |
+
'label' => Mage::helper('M2ePro')->__('Description'),
|
34 |
+
'title' => Mage::helper('M2ePro')->__('Description'),
|
35 |
+
'content' => $this->getLayout()->createBlock(
|
36 |
+
'M2ePro/adminhtml_common_amazon_template_newProduct_edit_tabs_description'
|
37 |
+
)->toHtml(),
|
38 |
+
));
|
39 |
+
|
40 |
+
$this->addTab('specifics', array(
|
41 |
+
'label' => Mage::helper('M2ePro')->__('Specifics'),
|
42 |
+
'title' => Mage::helper('M2ePro')->__('Specifics'),
|
43 |
+
'content' => $this->getLayout()->createBlock(
|
44 |
+
'M2ePro/adminhtml_common_amazon_template_newProduct_edit_tabs_specifics'
|
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/Amazon/Template/NewProduct/Edit/Tabs/Description.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_Common_Amazon_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('amazonTemplateNewProductEditTabsDescription');
|
17 |
+
//------------------------------
|
18 |
+
|
19 |
+
$this->setTemplate('M2ePro/common/amazon/template/newProduct/tabs/description.phtml');
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _beforeToHtml()
|
23 |
+
{
|
24 |
+
//------------------------------
|
25 |
+
$data = array(
|
26 |
+
'label' => Mage::helper('M2ePro')->__('Insert'),
|
27 |
+
'onclick' => "AttributeSetHandlerObj.appendToText('select_attributes_for_title', 'title_template');",
|
28 |
+
'class' => 'select_attributes_for_title_button'
|
29 |
+
);
|
30 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
31 |
+
$this->setChild('select_attributes_for_title_button',$buttonBlock);
|
32 |
+
//------------------------------
|
33 |
+
|
34 |
+
//------------------------------
|
35 |
+
$data = array(
|
36 |
+
'label' => Mage::helper('M2ePro')->__('Insert'),
|
37 |
+
'onclick' => "AttributeSetHandlerObj.appendToText('select_attributes_for_brand', 'brand_template');",
|
38 |
+
'class' => 'select_attributes_for_brand_button'
|
39 |
+
);
|
40 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
41 |
+
$this->setChild('select_attributes_for_brand_button',$buttonBlock);
|
42 |
+
//------------------------------
|
43 |
+
|
44 |
+
//------------------------------
|
45 |
+
$data = array(
|
46 |
+
'label' => Mage::helper('M2ePro')->__('Insert'),
|
47 |
+
'onclick' => "AttributeSetHandlerObj.appendToText(".
|
48 |
+
"'select_attributes_for_manufacturer'," . " 'manufacturer_template'".
|
49 |
+
");",
|
50 |
+
'class' => 'select_attributes_for_manufacturer_button'
|
51 |
+
);
|
52 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
53 |
+
$this->setChild('select_attributes_for_manufacturer_button',$buttonBlock);
|
54 |
+
//------------------------------
|
55 |
+
|
56 |
+
//------------------------------
|
57 |
+
$data = array(
|
58 |
+
'label' => Mage::helper('M2ePro')->__('Insert'),
|
59 |
+
'onclick' => "AttributeSetHandlerObj.appendToTextarea('#' + $('select_attributes').value + '#');",
|
60 |
+
'class' => 'add_product_attribute_button',
|
61 |
+
);
|
62 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
63 |
+
$this->setChild('add_product_attribute_button',$buttonBlock);
|
64 |
+
//------------------------------
|
65 |
+
|
66 |
+
//------------------------------
|
67 |
+
for ($i = 0; $i < 5; $i++) {
|
68 |
+
|
69 |
+
$onClick = <<<JS
|
70 |
+
AttributeSetHandlerObj.appendToText('select_attributes_for_bullet_points_{$i}', 'bullet_points_{$i}');
|
71 |
+
AmazonTemplateNewProductDescriptionHandlerObj.multi_element_keyup('bullet_points',{value:' '});
|
72 |
+
JS;
|
73 |
+
|
74 |
+
$data = array(
|
75 |
+
'label' => Mage::helper('M2ePro')->__('Insert'),
|
76 |
+
'onclick' => $onClick,
|
77 |
+
'class' => "select_attributes_for_bullet_points_{$i}_button"
|
78 |
+
);
|
79 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
80 |
+
$this->setChild("select_attributes_for_bullet_points_{$i}_button",$buttonBlock);
|
81 |
+
}
|
82 |
+
//------------------------------
|
83 |
+
|
84 |
+
//------------------------------
|
85 |
+
for ($i = 0; $i < 5; $i++) {
|
86 |
+
|
87 |
+
$onClick = <<<JS
|
88 |
+
AttributeSetHandlerObj.appendToText('select_attributes_for_search_terms_{$i}', 'search_terms_{$i}');
|
89 |
+
AmazonTemplateNewProductDescriptionHandlerObj.multi_element_keyup('search_terms',{value:' '});
|
90 |
+
JS;
|
91 |
+
|
92 |
+
$data = array(
|
93 |
+
'label' => Mage::helper('M2ePro')->__('Insert'),
|
94 |
+
'onclick' => $onClick,
|
95 |
+
'class' => "select_attributes_for_search_terms_{$i}_button"
|
96 |
+
);
|
97 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
98 |
+
$this->setChild("select_attributes_for_search_terms_{$i}_button",$buttonBlock);
|
99 |
+
}
|
100 |
+
//------------------------------
|
101 |
+
|
102 |
+
return parent::_beforeToHtml();
|
103 |
+
}
|
104 |
+
}
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|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Template_NewProduct_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('amazonTemplateNewProductEditTabsGeneral');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/amazon/template/newProduct/tabs/general.phtml');
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _beforeToHtml()
|
22 |
+
{
|
23 |
+
/** @var $connRead Varien_Db_Adapter_Pdo_Mysql */
|
24 |
+
$connRead = Mage::getSingleton('core/resource')->getConnection('core_read');
|
25 |
+
|
26 |
+
$this->marketplaceId = $this->getRequest()->getParam('marketplace_id');
|
27 |
+
|
28 |
+
$this->listingAttributeSetsIds = array();
|
29 |
+
if (!$this->getRequest()->getParam('id') &&
|
30 |
+
$listingProductIds = Mage::helper('M2ePro/Data_Session')->getValue('listing_product_ids')) {
|
31 |
+
|
32 |
+
$this->listingAttributeSetsIds = (array)Mage::helper('M2ePro/Component_Amazon')
|
33 |
+
->getObject('Listing_Product',reset($listingProductIds))
|
34 |
+
->getListing()
|
35 |
+
->getAttributeSetsIds();
|
36 |
+
}
|
37 |
+
|
38 |
+
$this->nodes = json_decode($connRead->select()
|
39 |
+
->from(Mage::getSingleton('core/resource')
|
40 |
+
->getTableName('m2epro_amazon_dictionary_marketplace'),'nodes')
|
41 |
+
->where('marketplace_id = ?', $this->marketplaceId)
|
42 |
+
->query()
|
43 |
+
->fetchColumn(),true);
|
44 |
+
!is_array($this->nodes) && $this->nodes = array();
|
45 |
+
|
46 |
+
$onlyVariationXsds = array(
|
47 |
+
$connRead->quote('Shoes'),
|
48 |
+
$connRead->quote('LabSupplies')
|
49 |
+
);
|
50 |
+
|
51 |
+
$stmt = $connRead->select()
|
52 |
+
->from(Mage::getSingleton('core/resource')
|
53 |
+
->getTableName('m2epro_amazon_dictionary_specific'),'*')
|
54 |
+
->where('xml_tag IN ('.implode(',',$onlyVariationXsds).')')
|
55 |
+
->query();
|
56 |
+
|
57 |
+
$onlyVariationXsdHashes = array();
|
58 |
+
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
59 |
+
$onlyVariationXsdHashes[] = $row['xsd_hash'];
|
60 |
+
}
|
61 |
+
|
62 |
+
$this->onlyVariationXsdHashes = json_encode(array_flip($onlyVariationXsdHashes));
|
63 |
+
|
64 |
+
//------------------------------
|
65 |
+
$data = array(
|
66 |
+
'id' => 'category_confirm_button',
|
67 |
+
'label' => Mage::helper('M2ePro')->__('Confirm'),
|
68 |
+
'onclick' => 'AmazonTemplateNewProductHandlerObj.confirmCategory();',
|
69 |
+
);
|
70 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
71 |
+
$this->setChild('category_confirm_button',$buttonBlock);
|
72 |
+
//------------------------------
|
73 |
+
|
74 |
+
//------------------------------
|
75 |
+
$data = array(
|
76 |
+
'id' => 'category_change_button',
|
77 |
+
'label' => Mage::helper('M2ePro')->__('Change Category'),
|
78 |
+
'onclick' => 'AmazonTemplateNewProductHandlerObj.changeCategory();',
|
79 |
+
);
|
80 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
81 |
+
$this->setChild('category_change_button',$buttonBlock);
|
82 |
+
//------------------------------
|
83 |
+
|
84 |
+
$attributesSets = Mage::helper('M2ePro/Magento_AttributeSet')->getAll();
|
85 |
+
$this->setData('attributes_sets', $attributesSets);
|
86 |
+
|
87 |
+
$temp = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
88 |
+
|
89 |
+
$this->attribute_set_locked = false;
|
90 |
+
|
91 |
+
if (!is_null($temp)) {
|
92 |
+
$this->attribute_set_locked = (bool)Mage::getModel('M2ePro/Amazon_Listing_Product')->getCollection()
|
93 |
+
->addFieldToFilter('template_new_product_id',$temp['category']['id'])
|
94 |
+
->getSize();
|
95 |
+
}
|
96 |
+
|
97 |
+
//------------------------------
|
98 |
+
$data = array(
|
99 |
+
'id' => 'attribute_sets_select_all_button',
|
100 |
+
'label' => Mage::helper('M2ePro')->__('Select All'),
|
101 |
+
'onclick' => 'AttributeSetHandlerObj.selectAllAttributeSets();',
|
102 |
+
'class' => 'attribute_sets_select_all_button'
|
103 |
+
);
|
104 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
105 |
+
$this->setChild('attribute_sets_select_all_button',$buttonBlock);
|
106 |
+
//------------------------------
|
107 |
+
|
108 |
+
//------------------------------
|
109 |
+
$data = array(
|
110 |
+
'id' => 'attribute_sets_confirm_button',
|
111 |
+
'label' => Mage::helper('M2ePro')->__('Confirm'),
|
112 |
+
'onclick' => '',
|
113 |
+
'class' => 'attribute_sets_confirm_button',
|
114 |
+
'style' => 'display: none'
|
115 |
+
);
|
116 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
117 |
+
$this->setChild('attribute_sets_confirm_button',$buttonBlock);
|
118 |
+
//------------------------------
|
119 |
+
|
120 |
+
//------------------------------
|
121 |
+
$data = array(
|
122 |
+
'id' => 'browse_category_button',
|
123 |
+
'label' => Mage::helper('M2ePro')->__('Browse'),
|
124 |
+
'onclick' => 'AmazonTemplateNewProductHandlerObj.browse_category.showCenter(true)'
|
125 |
+
);
|
126 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
127 |
+
$this->setChild('browse_category_button',$buttonBlock);
|
128 |
+
//------------------------------
|
129 |
+
|
130 |
+
//------------------------------
|
131 |
+
$data = array(
|
132 |
+
'id' => 'search_category_button',
|
133 |
+
'label' => Mage::helper('M2ePro')->__('Search By Keywords'),
|
134 |
+
'onclick' => 'AmazonTemplateNewProductHandlerObj.search_category.showCenter(true)',
|
135 |
+
);
|
136 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
137 |
+
$this->setChild('search_category_button',$buttonBlock);
|
138 |
+
//------------------------------
|
139 |
+
|
140 |
+
//------------------------------
|
141 |
+
$data = array(
|
142 |
+
'id' => 'search_category_popup_button',
|
143 |
+
'label' => Mage::helper('M2ePro')->__('Search'),
|
144 |
+
'onclick' => 'AmazonTemplateNewProductHandlerObj.searchClick()',
|
145 |
+
);
|
146 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
147 |
+
$this->setChild('search_category_popup_button',$buttonBlock);
|
148 |
+
//------------------------------
|
149 |
+
|
150 |
+
//------------------------------
|
151 |
+
$data = array(
|
152 |
+
'id' => 'reset_category_popup_button',
|
153 |
+
'label' => Mage::helper('M2ePro')->__('Reset'),
|
154 |
+
'onclick' => 'AmazonTemplateNewProductHandlerObj.resetSearchClick()',
|
155 |
+
'style' => 'display: none'
|
156 |
+
);
|
157 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
158 |
+
$this->setChild('reset_category_popup_button',$buttonBlock);
|
159 |
+
//------------------------------
|
160 |
+
|
161 |
+
//------------------------------
|
162 |
+
$data = array(
|
163 |
+
'id' => 'close_browse_popup_button',
|
164 |
+
'label' => Mage::helper('M2ePro')->__('Close'),
|
165 |
+
'onclick' => 'AmazonTemplateNewProductHandlerObj.closeBrowseCategoryPopup()',
|
166 |
+
);
|
167 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
168 |
+
$this->setChild('close_browse_popup_button',$buttonBlock);
|
169 |
+
//------------------------------
|
170 |
+
|
171 |
+
//------------------------------
|
172 |
+
$data = array(
|
173 |
+
'id' => 'close_search_popup_button',
|
174 |
+
'label' => Mage::helper('M2ePro')->__('Close'),
|
175 |
+
'onclick' => 'AmazonTemplateNewProductHandlerObj.closeSearchCategoryPopup()',
|
176 |
+
);
|
177 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
178 |
+
$this->setChild('close_search_popup_button',$buttonBlock);
|
179 |
+
//------------------------------
|
180 |
+
|
181 |
+
return parent::_beforeToHtml();
|
182 |
+
}
|
183 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/NewProduct/Edit/Tabs/Specifics.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_NewProduct_Edit_Tabs_Specifics
|
8 |
+
extends Mage_Adminhtml_Block_Widget
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
// Initialization block
|
15 |
+
//------------------------------
|
16 |
+
$this->setId('amazonTemplateNewProductEditTabsSpecifics');
|
17 |
+
//------------------------------
|
18 |
+
|
19 |
+
$this->setTemplate('M2ePro/common/amazon/template/newProduct/tabs/specifics.phtml');
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/NewProduct/Grid.php
ADDED
@@ -0,0 +1,287 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|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
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_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 |
+
$this->attributeSets = Mage::getResourceModel('eav/entity_attribute_set_collection')
|
27 |
+
->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
|
28 |
+
->load()->toOptionHash();
|
29 |
+
|
30 |
+
//------------------------------
|
31 |
+
$listingProductIds = Mage::helper('M2ePro/Data_Session')->getValue('listing_product_ids');
|
32 |
+
|
33 |
+
/** @var $connWrite Varien_Db_Adapter_Pdo_Mysql */
|
34 |
+
$connWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
|
35 |
+
$tableListingProduct = Mage::getSingleton('core/resource')->getTableName('m2epro_listing_product');
|
36 |
+
|
37 |
+
$productsIds = Mage::getResourceModel('core/config')
|
38 |
+
->getReadConnection()
|
39 |
+
->fetchCol($connWrite->select()
|
40 |
+
->from($tableListingProduct, 'product_id')
|
41 |
+
->where('id in (?)', $listingProductIds));
|
42 |
+
|
43 |
+
$this->attributesSetsIds = Mage::helper('M2ePro/Magento_AttributeSet')
|
44 |
+
->getFromProducts($productsIds, Ess_M2ePro_Helper_Magento_Abstract::RETURN_TYPE_IDS);
|
45 |
+
}
|
46 |
+
|
47 |
+
protected function _prepareCollection()
|
48 |
+
{
|
49 |
+
$marketplaceId = $this->getRequest()->getParam('marketplace_id');
|
50 |
+
|
51 |
+
$collection = Mage::getModel('M2ePro/Amazon_Template_NewProduct')->getCollection();
|
52 |
+
$collection->addFieldToFilter('`marketplace_id`', $marketplaceId);
|
53 |
+
|
54 |
+
$this->setCollection($collection);
|
55 |
+
|
56 |
+
return parent::_prepareCollection();
|
57 |
+
}
|
58 |
+
|
59 |
+
protected function _prepareColumns()
|
60 |
+
{
|
61 |
+
$this->addColumn('id', array(
|
62 |
+
'header' => Mage::helper('M2ePro')->__('ID'),
|
63 |
+
'align' => 'right',
|
64 |
+
'type' => 'number',
|
65 |
+
'width' => '50px',
|
66 |
+
'index' => 'id',
|
67 |
+
'filter_index' => 'id',
|
68 |
+
'frame_callback' => array($this, 'callbackColumnId')
|
69 |
+
));
|
70 |
+
|
71 |
+
$this->addColumn('title', array(
|
72 |
+
'header' => Mage::helper('M2ePro')->__('Title'),
|
73 |
+
'align' => 'left',
|
74 |
+
'type' => 'text',
|
75 |
+
'width' => '100px',
|
76 |
+
'index' => 'title',
|
77 |
+
'filter_index' => 'title',
|
78 |
+
'frame_callback' => array($this, 'callbackColumnTitle')
|
79 |
+
));
|
80 |
+
|
81 |
+
$this->addColumn('node_title', array(
|
82 |
+
'header' => Mage::helper('M2ePro')->__('Department'),
|
83 |
+
'align' => 'left',
|
84 |
+
'type' => 'text',
|
85 |
+
'width' => '100px',
|
86 |
+
'index' => 'node_title',
|
87 |
+
'filter_index' => 'node_title',
|
88 |
+
'frame_callback' => array($this, 'callbackColumnNodeTitle')
|
89 |
+
));
|
90 |
+
|
91 |
+
$this->addColumn('category_path', array(
|
92 |
+
'header' => Mage::helper('M2ePro')->__('Category'),
|
93 |
+
'align' => 'left',
|
94 |
+
'type' => 'text',
|
95 |
+
'width' => '350px',
|
96 |
+
'index' => 'category_path',
|
97 |
+
'filter_index' => 'category_path',
|
98 |
+
'frame_callback' => array($this, 'callbackColumnCategoryPath')
|
99 |
+
));
|
100 |
+
|
101 |
+
$this->addColumn('attribute_sets', array(
|
102 |
+
'header' => Mage::helper('M2ePro')->__('Attribute Sets'),
|
103 |
+
'align' => 'left',
|
104 |
+
'width' => '200px',
|
105 |
+
'filter' => false,
|
106 |
+
'sortable' => false,
|
107 |
+
'frame_callback' => array($this, 'callbackColumnAttributeSets')
|
108 |
+
));
|
109 |
+
|
110 |
+
$marketplace_id = $this->getRequest()->getParam('marketplace_id');
|
111 |
+
|
112 |
+
$back = Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_amazon_template_newProduct',array(
|
113 |
+
'marketplace_id' => $marketplace_id,
|
114 |
+
));
|
115 |
+
|
116 |
+
$this->addColumn('assignment', array(
|
117 |
+
'header' => Mage::helper('M2ePro')->__('Assignment'),
|
118 |
+
'align' => 'left',
|
119 |
+
'type' => 'text',
|
120 |
+
'width' => '130px',
|
121 |
+
'filter' => false,
|
122 |
+
'sortable' => false,
|
123 |
+
'frame_callback' => array($this, 'callbackColumnActions'),
|
124 |
+
));
|
125 |
+
|
126 |
+
$this->addColumn('actions', array(
|
127 |
+
'header' => Mage::helper('M2ePro')->__('Actions'),
|
128 |
+
'align' => 'left',
|
129 |
+
'width' => '100px',
|
130 |
+
'type' => 'action',
|
131 |
+
'index' => 'actions',
|
132 |
+
'filter' => false,
|
133 |
+
'sortable' => false,
|
134 |
+
'getter' => 'getId',
|
135 |
+
'actions' => array(
|
136 |
+
array(
|
137 |
+
'caption' => Mage::helper('M2ePro')->__('Edit Template'),
|
138 |
+
'field' => 'id',
|
139 |
+
'url' => array(
|
140 |
+
'base' => '*/adminhtml_common_amazon_template_newProduct/edit',
|
141 |
+
'params' => array(
|
142 |
+
'marketplace_id' => $marketplace_id,
|
143 |
+
'back' => $back
|
144 |
+
)
|
145 |
+
)
|
146 |
+
),
|
147 |
+
array(
|
148 |
+
'caption' => Mage::helper('M2ePro')->__('Delete Template'),
|
149 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?'),
|
150 |
+
'field' => 'ids',
|
151 |
+
'url' => array(
|
152 |
+
'base' => '*/adminhtml_common_amazon_template_newProduct/delete',
|
153 |
+
'params' => array(
|
154 |
+
'marketplace_id' => $marketplace_id,
|
155 |
+
'back' => $back
|
156 |
+
)
|
157 |
+
)
|
158 |
+
),
|
159 |
+
)
|
160 |
+
));
|
161 |
+
}
|
162 |
+
|
163 |
+
// ####################################
|
164 |
+
|
165 |
+
protected function _prepareMassaction()
|
166 |
+
{
|
167 |
+
// Set massaction identifiers
|
168 |
+
//--------------------------------
|
169 |
+
$this->setMassactionIdField('id');
|
170 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
171 |
+
//--------------------------------
|
172 |
+
|
173 |
+
// Set delete action
|
174 |
+
//--------------------------------
|
175 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
176 |
+
'label' => Mage::helper('M2ePro')->__('Delete'),
|
177 |
+
'url' => $this->getUrl('*/*/delete'),
|
178 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
179 |
+
));
|
180 |
+
//--------------------------------
|
181 |
+
|
182 |
+
return parent::_prepareMassaction();
|
183 |
+
}
|
184 |
+
|
185 |
+
// ####################################
|
186 |
+
|
187 |
+
public function callbackColumnId($value, $row, $column, $isExport)
|
188 |
+
{
|
189 |
+
return $value.' ';
|
190 |
+
}
|
191 |
+
|
192 |
+
public function callbackColumnTitle($value, $row, $column, $isExport)
|
193 |
+
{
|
194 |
+
return ' '.$value;
|
195 |
+
}
|
196 |
+
|
197 |
+
public function callbackColumnNodeTitle($value, $row, $column, $isExport)
|
198 |
+
{
|
199 |
+
return ' '.$value;
|
200 |
+
}
|
201 |
+
|
202 |
+
public function callbackColumnCategoryPath($value, $row, $column, $isExport)
|
203 |
+
{
|
204 |
+
return ' '.$value;
|
205 |
+
}
|
206 |
+
|
207 |
+
public function callbackColumnAttributeSets($value, $row, $column, $isExport)
|
208 |
+
{
|
209 |
+
$attributeSets = Mage::getModel('M2ePro/AttributeSet')->getCollection()
|
210 |
+
->addFieldToFilter('object_type',Ess_M2ePro_Model_AttributeSet::OBJECT_TYPE_AMAZON_TEMPLATE_NEW_PRODUCT)
|
211 |
+
->addFieldToFilter('object_id',(int)$row->getId())
|
212 |
+
->toArray();
|
213 |
+
|
214 |
+
$value = '';
|
215 |
+
foreach ($attributeSets['items'] as $attributeSet) {
|
216 |
+
if (strlen($value) > 100) {
|
217 |
+
$value .= ', <strong>...</strong>';
|
218 |
+
break;
|
219 |
+
}
|
220 |
+
if (isset($this->attributeSets[$attributeSet['attribute_set_id']])) {
|
221 |
+
$value != '' && $value .= ', ';
|
222 |
+
$value .= $this->attributeSets[$attributeSet['attribute_set_id']];
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
return $value;
|
227 |
+
}
|
228 |
+
|
229 |
+
public function callbackColumnActions($value, $row, $column, $isExport)
|
230 |
+
{
|
231 |
+
$url = $this->getUrl(
|
232 |
+
'*/adminhtml_common_amazon_template_newProduct/map/',
|
233 |
+
array(
|
234 |
+
'id' => $row->getId(),
|
235 |
+
'marketplace_id' => $this->getRequest()->getParam('marketplace_id')
|
236 |
+
)
|
237 |
+
);
|
238 |
+
$newAsinTemplateAttributes = $row->getAttributeSetsIds();
|
239 |
+
|
240 |
+
$listingAttributesAreIncludedInNewAsinTemplate = true;
|
241 |
+
foreach ($this->attributesSetsIds as $attributeSetId) {
|
242 |
+
if (array_search($attributeSetId, $newAsinTemplateAttributes) === false) {
|
243 |
+
$listingAttributesAreIncludedInNewAsinTemplate = false;
|
244 |
+
continue;
|
245 |
+
}
|
246 |
+
}
|
247 |
+
|
248 |
+
if ($listingAttributesAreIncludedInNewAsinTemplate) {
|
249 |
+
$confirmMessage = Mage::helper('M2ePro')->__('Are you sure?');
|
250 |
+
$actions = ' <a href="javascript:;" onclick="confirm(\''.$confirmMessage.'\') && ';
|
251 |
+
$actions .= 'setLocation(\''.$url.'\');">';
|
252 |
+
$actions .= Mage::helper('M2ePro')->__('Assign To This Template');
|
253 |
+
$actions .= '</a>';
|
254 |
+
} else {
|
255 |
+
$actions = '<span style="color: #808080;">';
|
256 |
+
$actions .= ' '.Mage::helper('M2ePro')->__('Attribute Sets Mismatch');
|
257 |
+
$actions .= '</span>';
|
258 |
+
}
|
259 |
+
|
260 |
+
return $actions;
|
261 |
+
}
|
262 |
+
|
263 |
+
// ####################################
|
264 |
+
|
265 |
+
public function getGridUrl()
|
266 |
+
{
|
267 |
+
return $this->getUrl('*/adminhtml_common_amazon_template_newProduct/templateNewProductGrid',
|
268 |
+
array('_current'=>true));
|
269 |
+
}
|
270 |
+
|
271 |
+
public function getRowUrl($row)
|
272 |
+
{
|
273 |
+
$marketplace_id = $this->getRequest()->getParam('marketplace_id');
|
274 |
+
|
275 |
+
$back = Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_amazon_template_newProduct',array(
|
276 |
+
'marketplace_id' => $marketplace_id
|
277 |
+
));
|
278 |
+
|
279 |
+
return $this->getUrl('*/adminhtml_common_amazon_template_newProduct/edit', array(
|
280 |
+
'id' => $row->getId(),
|
281 |
+
'marketplace_id' => $marketplace_id,
|
282 |
+
'back' => $back
|
283 |
+
));
|
284 |
+
}
|
285 |
+
|
286 |
+
// ####################################
|
287 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/NewProduct/Help.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_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('amazonTemplateNewProductHelp');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/amazon/template/newProduct/help.phtml');
|
19 |
+
}
|
20 |
+
|
21 |
+
public function getContainerId()
|
22 |
+
{
|
23 |
+
return 'block_notice_amazon_template_newProduct';
|
24 |
+
}
|
25 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/NewProduct/Search/Grid.php
ADDED
@@ -0,0 +1,155 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Amazon_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('amazonTemplateNewProductSearchGrid');
|
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 |
+
'xsd_hash' => $item['xsd_hash'],
|
40 |
+
'node_hash' => $item['node_hash'],
|
41 |
+
'item_types' => json_decode($item['item_types'],true),
|
42 |
+
'browsenode_id' => $item['browsenode_id'],
|
43 |
+
);
|
44 |
+
|
45 |
+
$results->addItem(new Varien_Object($temp));
|
46 |
+
}
|
47 |
+
|
48 |
+
$this->setCollection($results);
|
49 |
+
|
50 |
+
return parent::_prepareCollection();
|
51 |
+
}
|
52 |
+
|
53 |
+
protected function _prepareColumns()
|
54 |
+
{
|
55 |
+
$this->addColumn('title', array(
|
56 |
+
'header' => Mage::helper('M2ePro')->__('Category'),
|
57 |
+
'align' => 'left',
|
58 |
+
'type' => 'text',
|
59 |
+
'index' => 'title',
|
60 |
+
'filter' => false,
|
61 |
+
'sortable' => false,
|
62 |
+
'frame_callback' => array($this, 'callbackColumnTitle')
|
63 |
+
));
|
64 |
+
|
65 |
+
$this->addColumn('actions', array(
|
66 |
+
'header' => Mage::helper('M2ePro')->__('Action'),
|
67 |
+
'align' => 'center',
|
68 |
+
'type' => 'text',
|
69 |
+
'width' => '80px',
|
70 |
+
'filter' => false,
|
71 |
+
'sortable' => false,
|
72 |
+
'frame_callback' => array($this, 'callbackColumnActions'),
|
73 |
+
));
|
74 |
+
|
75 |
+
}
|
76 |
+
|
77 |
+
// ####################################
|
78 |
+
|
79 |
+
public function callbackColumnTitle($title, $row, $column, $isExport)
|
80 |
+
{
|
81 |
+
$categoryInfo = json_encode($row->getData());
|
82 |
+
$categoryInfo = Mage::helper('M2ePro')->escapeHtml($categoryInfo);
|
83 |
+
$categoryInfo = Mage::helper('M2ePro')->escapeJs($categoryInfo);
|
84 |
+
|
85 |
+
if (strlen($title) > 60) {
|
86 |
+
$title = substr($title, 0, 60) . '...';
|
87 |
+
}
|
88 |
+
|
89 |
+
$title = Mage::helper('M2ePro')->escapeHtml($title);
|
90 |
+
$path = str_replace('->',' > ',$row->getData('path'));
|
91 |
+
$path = Mage::helper('M2ePro')->escapeHtml($path);
|
92 |
+
$foundIn = Mage::helper('M2ePro')->__('Found In: ');
|
93 |
+
|
94 |
+
$fullPath = $path;
|
95 |
+
if (strlen($path) > 135) {
|
96 |
+
$path = substr($path, 0, 135) . '...';
|
97 |
+
}
|
98 |
+
|
99 |
+
$html = <<<HTML
|
100 |
+
<div style="margin-left: 3px">
|
101 |
+
<a href="javascript:;" onclick="AmazonTemplateNewProductHandlerObj.confirmSearchClick($categoryInfo)">$title</a>
|
102 |
+
<br>
|
103 |
+
<span style="font-weight: bold;">$foundIn</span>
|
104 |
+
|
105 |
+
<span title="$fullPath">$path</span><br>
|
106 |
+
</div>
|
107 |
+
HTML;
|
108 |
+
|
109 |
+
return $html;
|
110 |
+
}
|
111 |
+
|
112 |
+
public function callbackColumnActions($value, $row, $column, $isExport)
|
113 |
+
{
|
114 |
+
$categoryInfo = json_encode($row->getData());
|
115 |
+
$categoryInfo = Mage::helper('M2ePro')->escapeHtml($categoryInfo);
|
116 |
+
$categoryInfo = Mage::helper('M2ePro')->escapeJs($categoryInfo);
|
117 |
+
|
118 |
+
$select = Mage::helper('M2ePro')->__('Select');
|
119 |
+
$html = <<<HTML
|
120 |
+
<a href="javascript:;" onclick="AmazonTemplateNewProductHandlerObj.confirmSearchClick($categoryInfo)">$select</a>
|
121 |
+
HTML;
|
122 |
+
|
123 |
+
return $html;
|
124 |
+
}
|
125 |
+
|
126 |
+
// ####################################
|
127 |
+
|
128 |
+
protected function _toHtml()
|
129 |
+
{
|
130 |
+
$javascriptsMain = <<<JAVASCRIPT
|
131 |
+
<script type="text/javascript">
|
132 |
+
|
133 |
+
$$('#amazonTemplateNewProductSearchGrid div.grid th').each(function(el){
|
134 |
+
el.style.padding = '2px 2px';
|
135 |
+
});
|
136 |
+
|
137 |
+
$$('#amazonTemplateNewProductSearchGrid div.grid td').each(function(el){
|
138 |
+
el.style.padding = '2px 2px';
|
139 |
+
});
|
140 |
+
|
141 |
+
</script>
|
142 |
+
JAVASCRIPT;
|
143 |
+
|
144 |
+
return parent::_toHtml() . $javascriptsMain;
|
145 |
+
}
|
146 |
+
|
147 |
+
// ####################################
|
148 |
+
|
149 |
+
public function getRowUrl($row)
|
150 |
+
{
|
151 |
+
return false;
|
152 |
+
}
|
153 |
+
|
154 |
+
// ####################################
|
155 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/SellingFormat/Edit.php
ADDED
@@ -0,0 +1,109 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 = $helper->__(Ess_M2ePro_Helper_Component_Amazon::TITLE);
|
27 |
+
$headerTextEdit = $helper->__("Edit %component_name% Selling Format Template", $componentName);
|
28 |
+
$headerTextAdd = $helper->__("Add %component_name% Selling Format Template", $componentName);
|
29 |
+
} else {
|
30 |
+
$headerTextEdit = $helper->__("Edit Selling Format Template");
|
31 |
+
$headerTextAdd = $helper->__("Add Selling Format Template" );
|
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 |
+
//------------------------------
|
65 |
+
$this->_addButton('reset', array(
|
66 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
67 |
+
'onclick' => 'AmazonTemplateSellingFormatHandlerObj.reset_click()',
|
68 |
+
'class' => 'reset'
|
69 |
+
));
|
70 |
+
//------------------------------
|
71 |
+
|
72 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data')
|
73 |
+
&& Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()
|
74 |
+
) {
|
75 |
+
//------------------------------
|
76 |
+
$this->_addButton('duplicate', array(
|
77 |
+
'label' => Mage::helper('M2ePro')->__('Duplicate'),
|
78 |
+
'onclick' => 'AmazonTemplateSellingFormatHandlerObj.duplicate_click'
|
79 |
+
.'(\'common-amazon-template-sellingFormat\')',
|
80 |
+
'class' => 'add M2ePro_duplicate_button'
|
81 |
+
));
|
82 |
+
//------------------------------
|
83 |
+
|
84 |
+
//------------------------------
|
85 |
+
$this->_addButton('delete', array(
|
86 |
+
'label' => Mage::helper('M2ePro')->__('Delete'),
|
87 |
+
'onclick' => 'AmazonTemplateSellingFormatHandlerObj.delete_click()',
|
88 |
+
'class' => 'delete M2ePro_delete_button'
|
89 |
+
));
|
90 |
+
//------------------------------
|
91 |
+
}
|
92 |
+
|
93 |
+
//------------------------------
|
94 |
+
$this->_addButton('save', array(
|
95 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
96 |
+
'onclick' => 'AmazonTemplateSellingFormatHandlerObj.save_click()',
|
97 |
+
'class' => 'save'
|
98 |
+
));
|
99 |
+
//------------------------------
|
100 |
+
|
101 |
+
//------------------------------
|
102 |
+
$this->_addButton('save_and_continue', array(
|
103 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
104 |
+
'onclick' => 'AmazonTemplateSellingFormatHandlerObj.save_and_edit_click()',
|
105 |
+
'class' => 'save'
|
106 |
+
));
|
107 |
+
//------------------------------
|
108 |
+
}
|
109 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/SellingFormat/Edit/Form.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_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 |
+
$attributesSets = Mage::helper('M2ePro/Magento_AttributeSet')->getAll();
|
42 |
+
$this->setData('attributes_sets', $attributesSets);
|
43 |
+
//------------------------------
|
44 |
+
|
45 |
+
//------------------------------
|
46 |
+
$this->attribute_set_locked = false;
|
47 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data')
|
48 |
+
&& Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()
|
49 |
+
) {
|
50 |
+
$this->attribute_set_locked = Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->isLocked();
|
51 |
+
}
|
52 |
+
//------------------------------
|
53 |
+
|
54 |
+
//------------------------------
|
55 |
+
$this->setData('currencies', Mage::helper('M2ePro/Component_Amazon')->getCurrencies());
|
56 |
+
//------------------------------
|
57 |
+
|
58 |
+
//------------------------------
|
59 |
+
$data = array(
|
60 |
+
'id' => 'attribute_sets_select_all_button',
|
61 |
+
'label' => Mage::helper('M2ePro')->__('Select All'),
|
62 |
+
'onclick' => 'AttributeSetHandlerObj.selectAllAttributeSets();',
|
63 |
+
'class' => 'attribute_sets_select_all_button'
|
64 |
+
);
|
65 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
66 |
+
$this->setChild('attribute_sets_select_all_button',$buttonBlock);
|
67 |
+
//------------------------------
|
68 |
+
|
69 |
+
//------------------------------
|
70 |
+
$data = array(
|
71 |
+
'id' => 'attribute_sets_confirm_button',
|
72 |
+
'label' => Mage::helper('M2ePro')->__('Confirm'),
|
73 |
+
'onclick' => 'AmazonTemplateSellingFormatHandlerObj.attribute_sets_confirm();',
|
74 |
+
'class' => 'attribute_sets_confirm_button',
|
75 |
+
'style' => 'display: none'
|
76 |
+
);
|
77 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
78 |
+
$this->setChild('attribute_sets_confirm_button',$buttonBlock);
|
79 |
+
//------------------------------
|
80 |
+
|
81 |
+
//------------------------------
|
82 |
+
$this->customerGroups = Mage::getModel('customer/group')->getCollection()->toOptionArray();
|
83 |
+
//------------------------------
|
84 |
+
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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')->__(Ess_M2ePro_Helper_Component_Amazon::TITLE);
|
26 |
+
$headerTextEdit = Mage::helper('M2ePro')->__(
|
27 |
+
"Edit %component_name% Synchronization Template",
|
28 |
+
$componentName
|
29 |
+
);
|
30 |
+
$headerTextAdd = Mage::helper('M2ePro')->__(
|
31 |
+
"Add %component_name% Synchronization Template",
|
32 |
+
$componentName);
|
33 |
+
} else {
|
34 |
+
$headerTextEdit = Mage::helper('M2ePro')->__("Edit Synchronization Template");
|
35 |
+
$headerTextAdd = Mage::helper('M2ePro')->__("Add Synchronization Template");
|
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 |
+
//------------------------------
|
69 |
+
$this->_addButton('reset', array(
|
70 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
71 |
+
'onclick' => 'AmazonTemplateSynchronizationHandlerObj.reset_click()',
|
72 |
+
'class' => 'reset'
|
73 |
+
));
|
74 |
+
//------------------------------
|
75 |
+
|
76 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data')
|
77 |
+
&& Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()
|
78 |
+
) {
|
79 |
+
//------------------------------
|
80 |
+
$this->_addButton('duplicate', array(
|
81 |
+
'label' => Mage::helper('M2ePro')->__('Duplicate'),
|
82 |
+
'onclick' => 'AmazonTemplateSynchronizationHandlerObj.duplicate_click'
|
83 |
+
.'(\'common-amazon-template-synchronization\')',
|
84 |
+
'class' => 'add M2ePro_duplicate_button'
|
85 |
+
));
|
86 |
+
//------------------------------
|
87 |
+
|
88 |
+
//------------------------------
|
89 |
+
$this->_addButton('delete', array(
|
90 |
+
'label' => Mage::helper('M2ePro')->__('Delete'),
|
91 |
+
'onclick' => 'AmazonTemplateSynchronizationHandlerObj.delete_click()',
|
92 |
+
'class' => 'delete M2ePro_delete_button'
|
93 |
+
));
|
94 |
+
//------------------------------
|
95 |
+
}
|
96 |
+
|
97 |
+
//------------------------------
|
98 |
+
$this->_addButton('save', array(
|
99 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
100 |
+
'onclick' => 'AmazonTemplateSynchronizationHandlerObj.save_click()',
|
101 |
+
'class' => 'save'
|
102 |
+
));
|
103 |
+
//------------------------------
|
104 |
+
|
105 |
+
//------------------------------
|
106 |
+
$this->_addButton('save_and_continue', array(
|
107 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
108 |
+
'onclick' => 'AmazonTemplateSynchronizationHandlerObj.save_and_edit_click'
|
109 |
+
.'(\'\',\'amazonTemplateSynchronizationEditTabs\')',
|
110 |
+
'class' => 'save'
|
111 |
+
));
|
112 |
+
//------------------------------
|
113 |
+
}
|
114 |
+
}
|
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,146 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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')->__(Ess_M2ePro_Helper_Component_Buy::TITLE);
|
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 |
+
$this->_addButton('reset', array(
|
67 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
68 |
+
'onclick' => 'BuyAccountHandlerObj.reset_click()',
|
69 |
+
'class' => 'reset'
|
70 |
+
));
|
71 |
+
//------------------------------
|
72 |
+
|
73 |
+
//------------------------------
|
74 |
+
$this->_addButton('save_and_continue', array(
|
75 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
76 |
+
'onclick' => 'BuyAccountHandlerObj.save_and_edit_click(\'\',\'buyAccountEditTabs\')',
|
77 |
+
'class' => 'save'
|
78 |
+
));
|
79 |
+
//------------------------------
|
80 |
+
|
81 |
+
if ($this->getRequest()->getParam('id')) {
|
82 |
+
//------------------------------
|
83 |
+
$url = $this->getUrl('*/adminhtml_common_buy_account/new', array('wizard' => true));
|
84 |
+
$this->_addButton('add_new_account', array(
|
85 |
+
'label' => Mage::helper('M2ePro')->__('Add New Account'),
|
86 |
+
'onclick' => 'setLocation(\''. $url .'\')',
|
87 |
+
'class' => 'add_new_account'
|
88 |
+
));
|
89 |
+
//------------------------------
|
90 |
+
|
91 |
+
//------------------------------
|
92 |
+
$this->_addButton('close', array(
|
93 |
+
'label' => Mage::helper('M2ePro')->__('Complete This Step'),
|
94 |
+
'onclick' => 'BuyAccountHandlerObj.completeStep();',
|
95 |
+
'class' => 'close'
|
96 |
+
));
|
97 |
+
//------------------------------
|
98 |
+
}
|
99 |
+
} else {
|
100 |
+
//------------------------------
|
101 |
+
$url = Mage::helper('M2ePro')->getBackUrl('list');
|
102 |
+
$this->_addButton('back', array(
|
103 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
104 |
+
'onclick' => 'BuyAccountHandlerObj.back_click(\'' . $url .'\')',
|
105 |
+
'class' => 'back'
|
106 |
+
));
|
107 |
+
//------------------------------
|
108 |
+
|
109 |
+
//------------------------------
|
110 |
+
$this->_addButton('reset', array(
|
111 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
112 |
+
'onclick' => 'BuyAccountHandlerObj.reset_click()',
|
113 |
+
'class' => 'reset'
|
114 |
+
));
|
115 |
+
//------------------------------
|
116 |
+
|
117 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data') &&
|
118 |
+
Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()
|
119 |
+
) {
|
120 |
+
//------------------------------
|
121 |
+
$this->_addButton('delete', array(
|
122 |
+
'label' => Mage::helper('M2ePro')->__('Delete'),
|
123 |
+
'onclick' => 'BuyAccountHandlerObj.delete_click()',
|
124 |
+
'class' => 'delete M2ePro_delete_button'
|
125 |
+
));
|
126 |
+
//------------------------------
|
127 |
+
}
|
128 |
+
|
129 |
+
//------------------------------
|
130 |
+
$this->_addButton('save', array(
|
131 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
132 |
+
'onclick' => 'BuyAccountHandlerObj.save_click()',
|
133 |
+
'class' => 'save'
|
134 |
+
));
|
135 |
+
//------------------------------
|
136 |
+
|
137 |
+
//------------------------------
|
138 |
+
$this->_addButton('save_and_continue', array(
|
139 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
140 |
+
'onclick' => 'BuyAccountHandlerObj.save_and_edit_click(\'\',\'buyAccountEditTabs\')',
|
141 |
+
'class' => 'save'
|
142 |
+
));
|
143 |
+
//------------------------------
|
144 |
+
}
|
145 |
+
}
|
146 |
+
}
|
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,164 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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_listing_other/index',
|
49 |
+
array(
|
50 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_BUY,
|
51 |
+
'back' => $backUrl
|
52 |
+
)
|
53 |
+
);
|
54 |
+
$this->_addButton('goto_listing_other', array(
|
55 |
+
'label' => Mage::helper('M2ePro')->__('3rd Party Listings'),
|
56 |
+
'onclick' => 'setLocation(\''.$url.'\')',
|
57 |
+
'class' => 'button_link'
|
58 |
+
));
|
59 |
+
//------------------------------
|
60 |
+
|
61 |
+
//------------------------------
|
62 |
+
$this->_addButton('goto_template', array(
|
63 |
+
'label' => Mage::helper('M2ePro')->__('Templates'),
|
64 |
+
'onclick' => '',
|
65 |
+
'class' => 'button_link buy-templates-drop-down'
|
66 |
+
));
|
67 |
+
//------------------------------
|
68 |
+
|
69 |
+
//------------------------------
|
70 |
+
$url = $this->getUrl(
|
71 |
+
'*/adminhtml_common_log/listing',
|
72 |
+
array(
|
73 |
+
'filter' => base64_encode('component_mode=' . Ess_M2ePro_Helper_Component_Buy::NICK)
|
74 |
+
)
|
75 |
+
);
|
76 |
+
$this->_addButton('view_log', array(
|
77 |
+
'label' => Mage::helper('M2ePro')->__('View Log'),
|
78 |
+
'onclick' => 'window.open(\''.$url.'\')',
|
79 |
+
'class' => 'button_link'
|
80 |
+
));
|
81 |
+
//------------------------------
|
82 |
+
|
83 |
+
//------------------------------
|
84 |
+
$url = $this->getUrl('*/adminhtml_common_buy_listing/search', array('back' => $backUrl));
|
85 |
+
$this->_addButton('search_buy_products', array(
|
86 |
+
'label' => Mage::helper('M2ePro')->__('Search Items'),
|
87 |
+
'onclick' => 'setLocation(\''.$url.'\')',
|
88 |
+
'class' => 'button_link search'
|
89 |
+
));
|
90 |
+
//------------------------------
|
91 |
+
|
92 |
+
//------------------------------
|
93 |
+
if (Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
94 |
+
$this->_addButton('reset', array(
|
95 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
96 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
97 |
+
'class' => 'reset'
|
98 |
+
));
|
99 |
+
}
|
100 |
+
//------------------------------
|
101 |
+
|
102 |
+
//------------------------------
|
103 |
+
$url = $this->getUrl('*/adminhtml_common_buy_listing/add', array('step' => '1','clear'=>'yes'));
|
104 |
+
$this->_addButton('add', array(
|
105 |
+
'label' => Mage::helper('M2ePro')->__('Add Listing'),
|
106 |
+
'onclick' => 'setLocation(\'' .$url.'\')',
|
107 |
+
'class' => 'add'
|
108 |
+
));
|
109 |
+
//------------------------------
|
110 |
+
}
|
111 |
+
|
112 |
+
// ####################################
|
113 |
+
|
114 |
+
public function getTemplatesButtonJavascript()
|
115 |
+
{
|
116 |
+
$data = array(
|
117 |
+
'target_css_class' => 'buy-templates-drop-down',
|
118 |
+
'items' => $this->getTemplatesButtonDropDownItems()
|
119 |
+
);
|
120 |
+
$dropDownBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_button_dropDown');
|
121 |
+
$dropDownBlock->setData($data);
|
122 |
+
|
123 |
+
return $dropDownBlock->toHtml();
|
124 |
+
}
|
125 |
+
|
126 |
+
protected function getTemplatesButtonDropDownItems()
|
127 |
+
{
|
128 |
+
$items = array();
|
129 |
+
|
130 |
+
$filter = base64_encode('component_mode=' . Ess_M2ePro_Helper_Component_Buy::NICK);
|
131 |
+
|
132 |
+
//------------------------------
|
133 |
+
$url = $this->getUrl(
|
134 |
+
'*/adminhtml_common_template_sellingFormat/index',
|
135 |
+
array(
|
136 |
+
'filter' => $filter
|
137 |
+
)
|
138 |
+
);
|
139 |
+
$items[] = array(
|
140 |
+
'url' => $url,
|
141 |
+
'label' => Mage::helper('M2ePro')->__('Selling Format Templates'),
|
142 |
+
'target' => '_blank'
|
143 |
+
);
|
144 |
+
//------------------------------
|
145 |
+
|
146 |
+
//------------------------------
|
147 |
+
$url = $this->getUrl(
|
148 |
+
'*/adminhtml_common_template_synchronization/index',
|
149 |
+
array(
|
150 |
+
'filter' => $filter
|
151 |
+
)
|
152 |
+
);
|
153 |
+
$items[] = array(
|
154 |
+
'url' => $url,
|
155 |
+
'label' => Mage::helper('M2ePro')->__('Synchronization Templates'),
|
156 |
+
'target' => '_blank'
|
157 |
+
);
|
158 |
+
//------------------------------
|
159 |
+
|
160 |
+
return $items;
|
161 |
+
}
|
162 |
+
|
163 |
+
// ####################################
|
164 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Add/StepFive.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_Buy_Listing_Add_StepFive extends Mage_Adminhtml_Block_Widget_Grid_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingAddStepFive');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_buy_listing_product';
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
// Set header text
|
21 |
+
//------------------------------
|
22 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
23 |
+
$componentName = Mage::helper('M2ePro')->__(Ess_M2ePro_Helper_Component_Buy::TITLE);
|
24 |
+
$headerText = Mage::helper('M2ePro')->__("Add %component_name% Listing [Select Categories Products]",
|
25 |
+
$componentName);
|
26 |
+
} else {
|
27 |
+
$headerText = Mage::helper('M2ePro')->__("Add Listing [Select Categories Products]");
|
28 |
+
}
|
29 |
+
|
30 |
+
$this->_headerText = $headerText;
|
31 |
+
//------------------------------
|
32 |
+
|
33 |
+
// Set buttons actions
|
34 |
+
//------------------------------
|
35 |
+
$this->removeButton('back');
|
36 |
+
$this->removeButton('reset');
|
37 |
+
$this->removeButton('delete');
|
38 |
+
$this->removeButton('add');
|
39 |
+
$this->removeButton('save');
|
40 |
+
$this->removeButton('edit');
|
41 |
+
//------------------------------
|
42 |
+
|
43 |
+
//------------------------------
|
44 |
+
$url = $this->getUrl('*/adminhtml_common_buy_listing/add', array('step' => '4'));
|
45 |
+
$this->_addButton('back', array(
|
46 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
47 |
+
'onclick' => 'ProductGridHandlerObj.back_click(\'' . $url . '\')',
|
48 |
+
'class' => 'back'
|
49 |
+
));
|
50 |
+
//------------------------------
|
51 |
+
|
52 |
+
//------------------------------
|
53 |
+
$this->_addButton('reset', array(
|
54 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
55 |
+
'onclick' => 'ProductGridHandlerObj.reset_click()',
|
56 |
+
'class' => 'reset'
|
57 |
+
));
|
58 |
+
//------------------------------
|
59 |
+
|
60 |
+
//------------------------------
|
61 |
+
$this->_addButton('save_and_go_to_listings_list', array(
|
62 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
63 |
+
'onclick' => 'ProductGridHandlerObj.save_click(\'list\')',
|
64 |
+
'class' => 'save'
|
65 |
+
));
|
66 |
+
//------------------------------
|
67 |
+
|
68 |
+
//------------------------------
|
69 |
+
$this->_addButton('save_and_go_to_listing_view', array(
|
70 |
+
'label' => Mage::helper('M2ePro')->__('Save And View Listing'),
|
71 |
+
'onclick' => 'ProductGridHandlerObj.save_click(\'view\')',
|
72 |
+
'class' => 'save'
|
73 |
+
));
|
74 |
+
//------------------------------
|
75 |
+
}
|
76 |
+
|
77 |
+
public function getGridHtml()
|
78 |
+
{
|
79 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_listing_product_help');
|
80 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
81 |
+
}
|
82 |
+
|
83 |
+
protected function _toHtml()
|
84 |
+
{
|
85 |
+
return '<div id="add_products_progress_bar"></div>'.
|
86 |
+
'<div id="add_products_container">'.
|
87 |
+
parent::_toHtml().
|
88 |
+
'</div>';
|
89 |
+
}
|
90 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Add/StepFourCategory.php
ADDED
@@ -0,0 +1,128 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingAddStepFourCategory');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_buy_listing';
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$this->setTemplate('widget/view/container.phtml');
|
21 |
+
|
22 |
+
// Set header text
|
23 |
+
//------------------------------
|
24 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
25 |
+
$componentName = Mage::helper('M2ePro')->__(Ess_M2ePro_Helper_Component_Buy::TITLE);
|
26 |
+
$headerText = Mage::helper('M2ePro')->__("Add %component_name% Listing [Select Categories]",
|
27 |
+
$componentName);
|
28 |
+
} else {
|
29 |
+
$headerText = Mage::helper('M2ePro')->__("Add Listing [Select Categories]");
|
30 |
+
}
|
31 |
+
|
32 |
+
$this->_headerText = $headerText;
|
33 |
+
//------------------------------
|
34 |
+
|
35 |
+
// Set buttons actions
|
36 |
+
//------------------------------
|
37 |
+
$this->removeButton('back');
|
38 |
+
$this->removeButton('reset');
|
39 |
+
$this->removeButton('delete');
|
40 |
+
$this->removeButton('add');
|
41 |
+
$this->removeButton('save');
|
42 |
+
$this->removeButton('edit');
|
43 |
+
//------------------------------
|
44 |
+
|
45 |
+
//------------------------------
|
46 |
+
$url = $this->getUrl('*/adminhtml_common_buy_listing/add', array('step' => '3'));
|
47 |
+
$this->_addButton('back', array(
|
48 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
49 |
+
'onclick' => 'BuyListingCategoryHandlerObj.back_click(\'' . $url . '\')',
|
50 |
+
'class' => 'back'
|
51 |
+
));
|
52 |
+
//------------------------------
|
53 |
+
|
54 |
+
//------------------------------
|
55 |
+
$this->_addButton('reset', array(
|
56 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
57 |
+
'onclick' => 'BuyListingCategoryHandlerObj.reset_click()',
|
58 |
+
'class' => 'reset'
|
59 |
+
));
|
60 |
+
//------------------------------
|
61 |
+
|
62 |
+
//------------------------------
|
63 |
+
$url = $this->getUrl(
|
64 |
+
'*/adminhtml_common_buy_listing/add',
|
65 |
+
array(
|
66 |
+
'step' => '4',
|
67 |
+
'remember_categories' => 'yes'
|
68 |
+
)
|
69 |
+
);
|
70 |
+
$this->_addButton('save_and_next', array(
|
71 |
+
'label' => Mage::helper('M2ePro')->__('Next'),
|
72 |
+
'onclick' => 'BuyListingCategoryHandlerObj.save_click(\'' . $url . '\')',
|
73 |
+
'class' => 'next save_and_next_button'
|
74 |
+
));
|
75 |
+
//------------------------------
|
76 |
+
|
77 |
+
//------------------------------
|
78 |
+
$url = $this->getUrl(
|
79 |
+
'*/adminhtml_common_buy_listing/add',
|
80 |
+
array(
|
81 |
+
'step' => '4',
|
82 |
+
'back' => 'list'
|
83 |
+
)
|
84 |
+
);
|
85 |
+
$this->_addButton('save_and_go_to_listings_list', array(
|
86 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
87 |
+
'onclick' => 'BuyListingCategoryHandlerObj.save_click(\'' . $url . '\')',
|
88 |
+
'class' => 'save save_and_go_to_listings_list_button'
|
89 |
+
));
|
90 |
+
//------------------------------
|
91 |
+
|
92 |
+
//------------------------------
|
93 |
+
$url = $this->getUrl(
|
94 |
+
'*/adminhtml_common_buy_listing/add',
|
95 |
+
array(
|
96 |
+
'step' => '4',
|
97 |
+
'back' => 'view'
|
98 |
+
)
|
99 |
+
);
|
100 |
+
$this->_addButton('save_and_go_to_listing_view', array(
|
101 |
+
'label' => Mage::helper('M2ePro')->__('Save And View Listing'),
|
102 |
+
'onclick' => 'BuyListingCategoryHandlerObj.save_click(\'' . $url . '\')',
|
103 |
+
'class' => 'save save_and_go_to_listing_view_button'
|
104 |
+
));
|
105 |
+
//------------------------------
|
106 |
+
}
|
107 |
+
|
108 |
+
protected function _toHtml()
|
109 |
+
{
|
110 |
+
$treeSettings = array(
|
111 |
+
'show_products_amount' => true,
|
112 |
+
'hide_products_this_listing' => false
|
113 |
+
);
|
114 |
+
|
115 |
+
// todo next
|
116 |
+
$categoryTreeBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_listing_category_tree',
|
117 |
+
'',
|
118 |
+
array('component'=>Ess_M2ePro_Helper_Component_Buy::NICK,
|
119 |
+
'tree_settings' => $treeSettings));
|
120 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_listing_category_help');
|
121 |
+
$categoryBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_listing_category');
|
122 |
+
|
123 |
+
return '<div id="add_products_progress_bar"></div>'.
|
124 |
+
'<div id="add_products_container">'.
|
125 |
+
parent::_toHtml() . $helpBlock->toHtml() . $categoryTreeBlock->toHtml() . $categoryBlock->toHtml().
|
126 |
+
'</div>';
|
127 |
+
}
|
128 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Add/StepFourProduct.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_Buy_Listing_Add_StepFourProduct
|
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('buyListingAddStepFourProduct');
|
17 |
+
$this->_blockGroup = 'M2ePro';
|
18 |
+
$this->_controller = 'adminhtml_common_buy_listing_product';
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
// Set header text
|
22 |
+
//------------------------------
|
23 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
24 |
+
$componentName = Mage::helper('M2ePro')->__(Ess_M2ePro_Helper_Component_Buy::TITLE);
|
25 |
+
$headerText = Mage::helper('M2ePro')->__("Add %component_name% Listing [Select Products]", $componentName);
|
26 |
+
} else {
|
27 |
+
$headerText = Mage::helper('M2ePro')->__("Add Listing [Select Products]");
|
28 |
+
}
|
29 |
+
|
30 |
+
$this->_headerText = $headerText;
|
31 |
+
//------------------------------
|
32 |
+
|
33 |
+
// Set buttons actions
|
34 |
+
//------------------------------
|
35 |
+
$this->removeButton('back');
|
36 |
+
$this->removeButton('reset');
|
37 |
+
$this->removeButton('delete');
|
38 |
+
$this->removeButton('add');
|
39 |
+
$this->removeButton('save');
|
40 |
+
$this->removeButton('edit');
|
41 |
+
//------------------------------
|
42 |
+
|
43 |
+
//------------------------------
|
44 |
+
$url = $this->getUrl('*/adminhtml_common_buy_listing/add', array('step' => '3'));
|
45 |
+
$this->_addButton('back', array(
|
46 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
47 |
+
'onclick' => 'ProductGridHandlerObj.back_click(\'' . $url . '\')',
|
48 |
+
'class' => 'back'
|
49 |
+
));
|
50 |
+
//------------------------------
|
51 |
+
|
52 |
+
//------------------------------
|
53 |
+
$this->_addButton('reset', array(
|
54 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
55 |
+
'onclick' => 'ProductGridHandlerObj.reset_click()',
|
56 |
+
'class' => 'reset'
|
57 |
+
));
|
58 |
+
//------------------------------
|
59 |
+
|
60 |
+
//------------------------------
|
61 |
+
$this->_addButton('save_and_go_to_listings_list', array(
|
62 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
63 |
+
'onclick' => 'ProductGridHandlerObj.save_click(\'list\')',
|
64 |
+
'class' => 'save'
|
65 |
+
));
|
66 |
+
//------------------------------
|
67 |
+
|
68 |
+
//------------------------------
|
69 |
+
$this->_addButton('save_and_go_to_listing_view', array(
|
70 |
+
'label' => Mage::helper('M2ePro')->__('Save And View Listing'),
|
71 |
+
'onclick' => 'ProductGridHandlerObj.save_click(\'view\')',
|
72 |
+
'class' => 'save'
|
73 |
+
));
|
74 |
+
//------------------------------
|
75 |
+
}
|
76 |
+
|
77 |
+
public function getGridHtml()
|
78 |
+
{
|
79 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_listing_product_help');
|
80 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
81 |
+
}
|
82 |
+
|
83 |
+
protected function _toHtml()
|
84 |
+
{
|
85 |
+
return '<div id="add_products_progress_bar"></div>'.
|
86 |
+
'<div id="add_products_container">'.
|
87 |
+
parent::_toHtml().
|
88 |
+
'</div>';
|
89 |
+
}
|
90 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Add/StepOne.php
ADDED
@@ -0,0 +1,74 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_Add_StepOne extends Mage_Adminhtml_Block_Widget_Form_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingAddStepOne');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_buy_listing';
|
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')->__(Ess_M2ePro_Helper_Component_Buy::TITLE);
|
25 |
+
$headerText = Mage::helper('M2ePro')->__("Add %component_name% Listing [Settings]", $componentName);
|
26 |
+
} else {
|
27 |
+
$headerText = Mage::helper('M2ePro')->__("Add Listing [Settings]");
|
28 |
+
}
|
29 |
+
|
30 |
+
$this->_headerText = $headerText;
|
31 |
+
//------------------------------
|
32 |
+
|
33 |
+
// Set buttons actions
|
34 |
+
//------------------------------
|
35 |
+
$this->removeButton('back');
|
36 |
+
$this->removeButton('reset');
|
37 |
+
$this->removeButton('delete');
|
38 |
+
$this->removeButton('add');
|
39 |
+
$this->removeButton('save');
|
40 |
+
$this->removeButton('edit');
|
41 |
+
//------------------------------
|
42 |
+
|
43 |
+
//------------------------------
|
44 |
+
$url = $this->getUrl(
|
45 |
+
'*/adminhtml_common_listing/index',
|
46 |
+
array(
|
47 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_BUY
|
48 |
+
)
|
49 |
+
);
|
50 |
+
$this->_addButton('back', array(
|
51 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
52 |
+
'onclick' => 'BuyListingSettingsHandlerObj.back_click(\'' . $url . '\')',
|
53 |
+
'class' => 'back'
|
54 |
+
));
|
55 |
+
//------------------------------
|
56 |
+
|
57 |
+
//------------------------------
|
58 |
+
$this->_addButton('reset', array(
|
59 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
60 |
+
'onclick' => 'BuyListingSettingsHandlerObj.reset_click()',
|
61 |
+
'class' => 'reset'
|
62 |
+
));
|
63 |
+
//------------------------------
|
64 |
+
|
65 |
+
//------------------------------
|
66 |
+
$url = $this->getUrl('*/adminhtml_common_buy_listing/add', array('step' => '1'));
|
67 |
+
$this->_addButton('save_and_next', array(
|
68 |
+
'label' => Mage::helper('M2ePro')->__('Next'),
|
69 |
+
'onclick' => 'BuyListingSettingsHandlerObj.save_click(\'' . $url . '\')',
|
70 |
+
'class' => 'next'
|
71 |
+
));
|
72 |
+
//------------------------------
|
73 |
+
}
|
74 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Add/StepThree.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_Listing_Add_StepThree extends Mage_Adminhtml_Block_Widget_Form_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingAddStepThree');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_buy_listing';
|
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')->__(Ess_M2ePro_Helper_Component_Buy::TITLE);
|
25 |
+
$headerText = Mage::helper('M2ePro')->__("Add %component_name% Listing [Products Filter]", $componentName);
|
26 |
+
} else {
|
27 |
+
$headerText = Mage::helper('M2ePro')->__("Add Listing [Products Filter]");
|
28 |
+
}
|
29 |
+
|
30 |
+
$this->_headerText = $headerText;
|
31 |
+
//------------------------------
|
32 |
+
|
33 |
+
// Set buttons actions
|
34 |
+
//------------------------------
|
35 |
+
$this->removeButton('back');
|
36 |
+
$this->removeButton('reset');
|
37 |
+
$this->removeButton('delete');
|
38 |
+
$this->removeButton('add');
|
39 |
+
$this->removeButton('save');
|
40 |
+
$this->removeButton('edit');
|
41 |
+
//------------------------------
|
42 |
+
|
43 |
+
//------------------------------
|
44 |
+
$url = $this->getUrl('*/adminhtml_common_buy_listing/add', array('step' => '2'));
|
45 |
+
$this->_addButton('back', array(
|
46 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
47 |
+
'onclick' => 'CommonHandlerObj.back_click(\''
|
48 |
+
. $url
|
49 |
+
.'\')',
|
50 |
+
'class' => 'back'
|
51 |
+
));
|
52 |
+
//------------------------------
|
53 |
+
|
54 |
+
//------------------------------
|
55 |
+
$this->_addButton('reset', array(
|
56 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
57 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
58 |
+
'class' => 'reset'
|
59 |
+
));
|
60 |
+
//------------------------------
|
61 |
+
|
62 |
+
//------------------------------
|
63 |
+
$url = $this->getUrl('*/adminhtml_common_buy_listing/add', array('step' => '3'));
|
64 |
+
$this->_addButton('save_and_next', array(
|
65 |
+
'label' => Mage::helper('M2ePro')->__('Next'),
|
66 |
+
'onclick' => 'CommonHandlerObj.save_click(\''
|
67 |
+
. $url
|
68 |
+
.'\')',
|
69 |
+
'class' => 'next'
|
70 |
+
));
|
71 |
+
//------------------------------
|
72 |
+
}
|
73 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Add/StepTwo.php
ADDED
@@ -0,0 +1,69 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_Add_StepTwo extends Mage_Adminhtml_Block_Widget_Form_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingAddStepTwo');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_buy_listing';
|
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')->__(Ess_M2ePro_Helper_Component_Buy::TITLE);
|
25 |
+
$headerText = Mage::helper('M2ePro')->__("Add %component_name% Listing [Channel Settings]", $componentName);
|
26 |
+
} else {
|
27 |
+
$headerText = Mage::helper('M2ePro')->__("Add Listing [Channel Settings]");
|
28 |
+
}
|
29 |
+
|
30 |
+
$this->_headerText = $headerText;
|
31 |
+
//------------------------------
|
32 |
+
|
33 |
+
// Set buttons actions
|
34 |
+
//------------------------------
|
35 |
+
$this->removeButton('back');
|
36 |
+
$this->removeButton('reset');
|
37 |
+
$this->removeButton('delete');
|
38 |
+
$this->removeButton('add');
|
39 |
+
$this->removeButton('save');
|
40 |
+
$this->removeButton('edit');
|
41 |
+
//------------------------------
|
42 |
+
|
43 |
+
//------------------------------
|
44 |
+
$url = $this->getUrl('*/adminhtml_common_buy_listing/add', array('step' => '1'));
|
45 |
+
$this->_addButton('back', array(
|
46 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
47 |
+
'onclick' => 'BuyListingChannelSettingsHandlerObj.back_click(\'' . $url . '\')',
|
48 |
+
'class' => 'back'
|
49 |
+
));
|
50 |
+
//------------------------------
|
51 |
+
|
52 |
+
//------------------------------
|
53 |
+
$this->_addButton('reset', array(
|
54 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
55 |
+
'onclick' => 'BuyListingChannelSettingsHandlerObj.reset_click()',
|
56 |
+
'class' => 'reset'
|
57 |
+
));
|
58 |
+
//------------------------------
|
59 |
+
|
60 |
+
//------------------------------
|
61 |
+
$url = $this->getUrl('*/adminhtml_common_buy_listing/add', array('step' => '2'));
|
62 |
+
$this->_addButton('save_and_next', array(
|
63 |
+
'label' => Mage::helper('M2ePro')->__('Next'),
|
64 |
+
'onclick' => 'BuyListingChannelSettingsHandlerObj.save_click(\'' . $url . '\')',
|
65 |
+
'class' => 'next'
|
66 |
+
));
|
67 |
+
//------------------------------
|
68 |
+
}
|
69 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Category.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_Category extends Mage_Adminhtml_Block_Template
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingCategory');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/buy/listing/category.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Category/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_Category_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/category/help.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Edit.php
ADDED
@@ -0,0 +1,98 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingEdit');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_buy_listing';
|
18 |
+
$this->_mode = 'edit';
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
// Set header text
|
22 |
+
//------------------------------
|
23 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
24 |
+
|
25 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
26 |
+
$headerText = Mage::helper('M2ePro')->__(
|
27 |
+
'Edit "%listing_title%" %component_name% Listing [Settings]',
|
28 |
+
$this->escapeHtml($listingData['title']),
|
29 |
+
Mage::helper('M2ePro')->__(Ess_M2ePro_Helper_Component_Buy::TITLE)
|
30 |
+
);
|
31 |
+
} else {
|
32 |
+
$headerText =Mage::helper('M2ePro')->__(
|
33 |
+
'Edit "%listing_title%" Listing [Settings]',
|
34 |
+
$this->escapeHtml($listingData['title'])
|
35 |
+
);
|
36 |
+
}
|
37 |
+
|
38 |
+
$this->_headerText = $headerText;
|
39 |
+
//------------------------------
|
40 |
+
|
41 |
+
// Set buttons actions
|
42 |
+
//------------------------------
|
43 |
+
$this->removeButton('back');
|
44 |
+
$this->removeButton('reset');
|
45 |
+
$this->removeButton('delete');
|
46 |
+
$this->removeButton('add');
|
47 |
+
$this->removeButton('save');
|
48 |
+
$this->removeButton('edit');
|
49 |
+
//------------------------------
|
50 |
+
|
51 |
+
if (!is_null($this->getRequest()->getParam('back'))) {
|
52 |
+
//------------------------------
|
53 |
+
$url = Mage::helper('M2ePro')->getBackUrl(
|
54 |
+
'*/adminhtml_common_listing/index',
|
55 |
+
array(
|
56 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_BUY
|
57 |
+
)
|
58 |
+
);
|
59 |
+
$this->_addButton('back', array(
|
60 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
61 |
+
'onclick' => 'BuyListingSettingsHandlerObj.back_click(\''.$url.'\')',
|
62 |
+
'class' => 'back'
|
63 |
+
));
|
64 |
+
//------------------------------
|
65 |
+
}
|
66 |
+
|
67 |
+
//------------------------------
|
68 |
+
$this->_addButton('reset', array(
|
69 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
70 |
+
'onclick' => 'BuyListingSettingsHandlerObj.reset_click()',
|
71 |
+
'class' => 'reset'
|
72 |
+
));
|
73 |
+
//------------------------------
|
74 |
+
|
75 |
+
//------------------------------
|
76 |
+
$url = $this->getUrl(
|
77 |
+
'*/adminhtml_common_buy_listing/save',
|
78 |
+
array(
|
79 |
+
'id' => $listingData['id'],
|
80 |
+
'back' => Mage::helper('M2ePro')->getBackUrlParam('list')
|
81 |
+
)
|
82 |
+
);
|
83 |
+
$this->_addButton('save', array(
|
84 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
85 |
+
'onclick' => 'BuyListingSettingsHandlerObj.save_click(\'' . $url . '\')',
|
86 |
+
'class' => 'save'
|
87 |
+
));
|
88 |
+
//------------------------------
|
89 |
+
|
90 |
+
//------------------------------
|
91 |
+
$this->_addButton('save_and_continue', array(
|
92 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
93 |
+
'onclick' => 'BuyListingSettingsHandlerObj.save_and_edit_click(\'\',\'buyListingEditTabs\')',
|
94 |
+
'class' => 'save'
|
95 |
+
));
|
96 |
+
//------------------------------
|
97 |
+
}
|
98 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Edit/Form.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_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 |
+
// Prepare action
|
22 |
+
// -------------------
|
23 |
+
$step = $this->getRequest()->getParam('step');
|
24 |
+
|
25 |
+
if (is_null($step)) {
|
26 |
+
// Edit listing mode
|
27 |
+
$action = $this->getUrl('*/adminhtml_common_buy_listing/save');
|
28 |
+
} else {
|
29 |
+
// Add listing mode
|
30 |
+
$action = $this->getUrl('*/adminhtml_common_buy_listing/add', array('step' => (int)$step));
|
31 |
+
}
|
32 |
+
// -------------------
|
33 |
+
|
34 |
+
$form = new Varien_Data_Form(array(
|
35 |
+
'id' => 'edit_form',
|
36 |
+
'action' => $action,
|
37 |
+
'method' => 'post',
|
38 |
+
'enctype' => 'multipart/form-data'
|
39 |
+
));
|
40 |
+
|
41 |
+
$form->setUseContainer(true);
|
42 |
+
$this->setForm($form);
|
43 |
+
|
44 |
+
return parent::_prepareForm();
|
45 |
+
}
|
46 |
+
|
47 |
+
protected function _beforeToHtml()
|
48 |
+
{
|
49 |
+
// Add listing mode
|
50 |
+
// -------------------
|
51 |
+
$child = NULL;
|
52 |
+
$step = $this->getRequest()->getParam('step');
|
53 |
+
|
54 |
+
if ($step == 1) {
|
55 |
+
$child = $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_listing_edit_tabs_settings');
|
56 |
+
} else if ($step == 2) {
|
57 |
+
$child = $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_listing_edit_tabs_channelSettings');
|
58 |
+
} elseif ($step == 3) {
|
59 |
+
$child = $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_listing_edit_tabs_productsFilter');
|
60 |
+
}
|
61 |
+
|
62 |
+
if (!is_null($child)) {
|
63 |
+
$this->setTemplate('M2ePro/common/buy/listing/add.phtml');
|
64 |
+
$this->setChild('general',
|
65 |
+
$this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_listing_edit_tabs_general'));
|
66 |
+
$this->setChild('content', $child);
|
67 |
+
}
|
68 |
+
// -------------------
|
69 |
+
|
70 |
+
return parent::_beforeToHtml();
|
71 |
+
}
|
72 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/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_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->setTitle(Mage::helper('M2ePro')->__('Configuration'));
|
19 |
+
$this->setDestElementId('edit_form');
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _beforeToHtml()
|
23 |
+
{
|
24 |
+
$this->addTab('settings', array(
|
25 |
+
'label' => Mage::helper('M2ePro')->__('Settings'),
|
26 |
+
'title' => Mage::helper('M2ePro')->__('Settings'),
|
27 |
+
'content' => $this->getLayout()
|
28 |
+
->createBlock('M2ePro/adminhtml_common_buy_listing_edit_tabs_settings')
|
29 |
+
->toHtml(),
|
30 |
+
));
|
31 |
+
|
32 |
+
$this->addTab('channel', array(
|
33 |
+
'label' => Mage::helper('M2ePro')->__('Channel Settings'),
|
34 |
+
'title' => Mage::helper('M2ePro')->__('Channel Settings'),
|
35 |
+
'content' => $this->getLayout()
|
36 |
+
->createBlock('M2ePro/adminhtml_common_buy_listing_edit_tabs_channelSettings')
|
37 |
+
->toHtml(),
|
38 |
+
));
|
39 |
+
|
40 |
+
$this->addTab('products_filter', array(
|
41 |
+
'label' => Mage::helper('M2ePro')->__('Products Filter'),
|
42 |
+
'title' => Mage::helper('M2ePro')->__('Products Filter'),
|
43 |
+
'content' => $this->getLayout()
|
44 |
+
->createBlock('M2ePro/adminhtml_common_buy_listing_edit_tabs_ProductsFilter')
|
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/Listing/Edit/Tabs/ChannelSettings.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_Buy_Listing_Edit_Tabs_ChannelSettings extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingEditTabsChannelSettings');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/buy/listing/tabs/channel_settings.phtml');
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _beforeToHtml()
|
22 |
+
{
|
23 |
+
//-------------------------------
|
24 |
+
$accounts = Mage::helper('M2ePro/Component_Buy')->getCollection('Account')
|
25 |
+
->setOrder('title', 'ASC')
|
26 |
+
->toArray();
|
27 |
+
$this->setData('accounts', $accounts['items']);
|
28 |
+
//-------------------------------
|
29 |
+
|
30 |
+
//-------------------------------
|
31 |
+
$formData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
32 |
+
$this->setData('attributes',
|
33 |
+
Mage::helper('M2ePro/Magento_Attribute')->getByAttributeSets($formData['attribute_sets']));
|
34 |
+
//-------------------------------
|
35 |
+
|
36 |
+
return parent::_beforeToHtml();
|
37 |
+
}
|
38 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Edit/Tabs/General.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_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('buyListingEditTabsChannelGeneral');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/buy/listing/tabs/general.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Edit/Tabs/ProductsFilter.php
ADDED
@@ -0,0 +1,53 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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_ProductsFilter extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingEditTabsProductsFilter');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/buy/listing/tabs/products_filter.phtml');
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _beforeToHtml()
|
22 |
+
{
|
23 |
+
//-------------------------------
|
24 |
+
$accounts = Mage::helper('M2ePro/Component_Buy')->getCollection('Account')
|
25 |
+
->setOrder('title', 'ASC')
|
26 |
+
->toArray();
|
27 |
+
$this->setData('accounts', $accounts['items']);
|
28 |
+
//-------------------------------
|
29 |
+
|
30 |
+
//-------------------------------
|
31 |
+
$formData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
32 |
+
$this->setData('attributes',
|
33 |
+
Mage::helper('M2ePro/Magento_Attribute')->getByAttributeSets($formData['attribute_sets']));
|
34 |
+
//-------------------------------
|
35 |
+
|
36 |
+
//------------------------------
|
37 |
+
$treeSettings = array(
|
38 |
+
'show_products_amount' => false,
|
39 |
+
'hide_products_this_listing' => false
|
40 |
+
);
|
41 |
+
|
42 |
+
// todo next
|
43 |
+
$treeBlock = $this->getLayout()
|
44 |
+
->createBlock('M2ePro/adminhtml_common_listing_category_tree','',array(
|
45 |
+
'component'=>Ess_M2ePro_Helper_Component_Buy::NICK,
|
46 |
+
'tree_settings' => $treeSettings
|
47 |
+
));
|
48 |
+
$this->setChild('categoriesTree', $treeBlock);
|
49 |
+
//------------------------------
|
50 |
+
|
51 |
+
return parent::_beforeToHtml();
|
52 |
+
}
|
53 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Edit/Tabs/Settings.php
ADDED
@@ -0,0 +1,146 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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_Settings extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingEditTabsSettings');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/buy/listing/tabs/settings.phtml');
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _beforeToHtml()
|
22 |
+
{
|
23 |
+
//-------------------------------
|
24 |
+
$maxRecordsQuantity = Mage::helper('M2ePro/View_Common')->getAutocompleteMaxItems();
|
25 |
+
//-------------------------------
|
26 |
+
|
27 |
+
// Get attribute sets
|
28 |
+
//------------------------------
|
29 |
+
$this->attributesSets = Mage::helper('M2ePro/Magento_AttributeSet')->getAll();
|
30 |
+
|
31 |
+
//------------------------------
|
32 |
+
$data = array(
|
33 |
+
'id' => 'attribute_sets_select_all_button',
|
34 |
+
'label' => Mage::helper('M2ePro')->__('Select All'),
|
35 |
+
'onclick' => 'AttributeSetHandlerObj.selectAllAttributeSets();',
|
36 |
+
'class' => 'attribute_sets_select_all_button'
|
37 |
+
);
|
38 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
39 |
+
$this->setChild('attribute_sets_select_all_button',$buttonBlock);
|
40 |
+
//------------------------------
|
41 |
+
|
42 |
+
//------------------------------
|
43 |
+
$data = array(
|
44 |
+
'id' => 'attribute_sets_confirm_button',
|
45 |
+
'label' => Mage::helper('M2ePro')->__('Confirm'),
|
46 |
+
'onclick' => 'BuyListingSettingsHandlerObj.attribute_sets_confirm();',
|
47 |
+
'class' => 'attribute_sets_confirm_button',
|
48 |
+
'style' => 'display: none'
|
49 |
+
);
|
50 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
51 |
+
$this->setChild('attribute_sets_confirm_button',$buttonBlock);
|
52 |
+
//------------------------------
|
53 |
+
|
54 |
+
//----------------------------
|
55 |
+
$this->sellingFormatTemplatesDropDown = Mage::helper('M2ePro/Component_Buy')
|
56 |
+
->getCollection('Template_SellingFormat')
|
57 |
+
->getSize() < $maxRecordsQuantity;
|
58 |
+
//----------------------------
|
59 |
+
|
60 |
+
//----------------------------
|
61 |
+
$synchronizationTemplatesCollection = Mage::helper('M2ePro/Component_Buy')
|
62 |
+
->getCollection('Template_Synchronization')
|
63 |
+
->setOrder('title', 'ASC');
|
64 |
+
|
65 |
+
if ($synchronizationTemplatesCollection->getSize() < $maxRecordsQuantity) {
|
66 |
+
$this->synchronizationsTemplatesDropDown = true;
|
67 |
+
$templates = $synchronizationTemplatesCollection->toArray();
|
68 |
+
|
69 |
+
foreach ($templates['items'] as $key => $value) {
|
70 |
+
$templates['items'][$key]['title'] = Mage::helper('M2ePro')
|
71 |
+
->escapeHtml($templates['items'][$key]['title']);
|
72 |
+
}
|
73 |
+
|
74 |
+
$this->synchronizationsTemplates = $templates['items'];
|
75 |
+
} else {
|
76 |
+
$this->synchronizationsTemplatesDropDown = false;
|
77 |
+
$this->synchronizationsTemplates = array();
|
78 |
+
}
|
79 |
+
//----------------------------
|
80 |
+
|
81 |
+
// Get selected categories
|
82 |
+
//----------------------------
|
83 |
+
if ($listingId = $this->getRequest()->getParam('id')) {
|
84 |
+
$listingCategories = Mage::helper('M2ePro/Component_Buy')
|
85 |
+
->getCachedObject('Listing',$listingId)
|
86 |
+
->getCategories();
|
87 |
+
|
88 |
+
$categoriesIds = array();
|
89 |
+
foreach ($listingCategories as $listingCategory) {
|
90 |
+
$categoriesIds[] = $listingCategory['category_id'];
|
91 |
+
}
|
92 |
+
//----------------------------
|
93 |
+
|
94 |
+
Mage::helper('M2ePro/Data_Global')->setValue('temp_listing_categories', $categoriesIds);
|
95 |
+
}
|
96 |
+
//----------------------------
|
97 |
+
|
98 |
+
//------------------------------
|
99 |
+
$url = $this->getUrl('*/adminhtml_common_buy_template_sellingFormat/new');
|
100 |
+
$data = array(
|
101 |
+
'label' => Mage::helper('M2ePro')->__('Add New'),
|
102 |
+
'onclick' => 'BuyListingSettingsHandlerObj.openWindow(\'' . $url . '\');',
|
103 |
+
'class' => 'add add_new_selling_format_template_button',
|
104 |
+
'style' => 'vertical-align: bottom'
|
105 |
+
);
|
106 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
107 |
+
$this->setChild('add_new_selling_format_template_button',$buttonBlock);
|
108 |
+
//------------------------------
|
109 |
+
|
110 |
+
//------------------------------
|
111 |
+
$data = array(
|
112 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
113 |
+
'onclick' => 'BuyListingSettingsHandlerObj.reloadSellingFormatTemplates();',
|
114 |
+
'class' => 'reload_selling_format_templates_button',
|
115 |
+
'style' => 'vertical-align: bottom'
|
116 |
+
);
|
117 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
118 |
+
$this->setChild('reload_selling_format_templates_button',$buttonBlock);
|
119 |
+
//------------------------------
|
120 |
+
|
121 |
+
//------------------------------
|
122 |
+
$url = $this->getUrl('*/adminhtml_common_buy_template_synchronization/new');
|
123 |
+
$data = array(
|
124 |
+
'label' => Mage::helper('M2ePro')->__('Add New'),
|
125 |
+
'onclick' => 'BuyListingSettingsHandlerObj.openWindow(\'' . $url . '\');',
|
126 |
+
'class' => 'add add_new_synchronization_template_button',
|
127 |
+
'style' => 'vertical-align: bottom'
|
128 |
+
);
|
129 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
130 |
+
$this->setChild('add_new_synchronization_template_button',$buttonBlock);
|
131 |
+
//------------------------------
|
132 |
+
|
133 |
+
//------------------------------
|
134 |
+
$data = array(
|
135 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
136 |
+
'onclick' => 'BuyListingSettingsHandlerObj.reloadSynchronizationTemplates();',
|
137 |
+
'class' => 'reload_synchronization_templates_button',
|
138 |
+
'style' => 'vertical-align: bottom'
|
139 |
+
);
|
140 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
141 |
+
$this->setChild('reload_synchronization_templates_button',$buttonBlock);
|
142 |
+
//------------------------------
|
143 |
+
|
144 |
+
return parent::_beforeToHtml();
|
145 |
+
}
|
146 |
+
}
|
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,334 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
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Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingGrid');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
// Set default values
|
19 |
+
//------------------------------
|
20 |
+
$this->setDefaultSort('id');
|
21 |
+
$this->setDefaultDir('DESC');
|
22 |
+
$this->setSaveParametersInSession(true);
|
23 |
+
$this->setUseAjax(true);
|
24 |
+
//------------------------------
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getMassactionBlockName()
|
28 |
+
{
|
29 |
+
return 'M2ePro/adminhtml_grid_massaction';
|
30 |
+
}
|
31 |
+
|
32 |
+
protected function _prepareCollection()
|
33 |
+
{
|
34 |
+
// Update statistic table values
|
35 |
+
Mage::getResourceModel('M2ePro/Listing')->updateStatisticColumns();
|
36 |
+
Mage::getResourceModel('M2ePro/Buy_Listing')->updateStatisticColumns();
|
37 |
+
|
38 |
+
// Get collection of listings
|
39 |
+
$collection = Mage::helper('M2ePro/Component_Buy')->getCollection('Listing');
|
40 |
+
|
41 |
+
// Set global filters
|
42 |
+
//--------------------------
|
43 |
+
$filterSellingFormatTemplate = $this->getRequest()->getParam('filter_buy_selling_format_template');
|
44 |
+
$filterSynchronizationTemplate = $this->getRequest()->getParam('filter_buy_synchronization_template');
|
45 |
+
|
46 |
+
if ($filterSellingFormatTemplate != 0) {
|
47 |
+
$collection->addFieldToFilter(
|
48 |
+
'second_table.template_selling_format_id', (int)$filterSellingFormatTemplate
|
49 |
+
);
|
50 |
+
}
|
51 |
+
|
52 |
+
if ($filterSynchronizationTemplate != 0) {
|
53 |
+
$collection->addFieldToFilter(
|
54 |
+
'second_table.template_synchronization_id', (int)$filterSynchronizationTemplate
|
55 |
+
);
|
56 |
+
}
|
57 |
+
//--------------------------
|
58 |
+
|
59 |
+
//exit($collection->getSelect()->__toString());
|
60 |
+
|
61 |
+
// Set collection to grid
|
62 |
+
$this->setCollection($collection);
|
63 |
+
|
64 |
+
return parent::_prepareCollection();
|
65 |
+
}
|
66 |
+
|
67 |
+
protected function _prepareColumns()
|
68 |
+
{
|
69 |
+
$this->addColumn('id', array(
|
70 |
+
'header' => Mage::helper('M2ePro')->__('ID'),
|
71 |
+
'align' => 'right',
|
72 |
+
'width' => '100px',
|
73 |
+
'type' => 'number',
|
74 |
+
'index' => 'id',
|
75 |
+
'filter_index' => 'main_table.id'
|
76 |
+
));
|
77 |
+
|
78 |
+
$this->addColumn('title', array(
|
79 |
+
'header' => Mage::helper('M2ePro')->__('Title'),
|
80 |
+
'align' => 'left',
|
81 |
+
//'width' => '200px',
|
82 |
+
'type' => 'text',
|
83 |
+
'index' => 'title',
|
84 |
+
'escape' => true,
|
85 |
+
'filter_index' => 'main_table.title'
|
86 |
+
));
|
87 |
+
|
88 |
+
$this->addColumn('products_total_count', array(
|
89 |
+
'header' => Mage::helper('M2ePro')->__('Total Items'),
|
90 |
+
'align' => 'right',
|
91 |
+
'width' => '100px',
|
92 |
+
'type' => 'number',
|
93 |
+
'index' => 'products_total_count',
|
94 |
+
'filter_index' => 'main_table.products_total_count',
|
95 |
+
'frame_callback' => array($this, 'callbackColumnTotalProducts')
|
96 |
+
));
|
97 |
+
|
98 |
+
$this->addColumn('products_active_count', array(
|
99 |
+
'header' => Mage::helper('M2ePro')->__('Active Items'),
|
100 |
+
'align' => 'right',
|
101 |
+
'width' => '100px',
|
102 |
+
'type' => 'number',
|
103 |
+
'index' => 'products_active_count',
|
104 |
+
'filter_index' => 'main_table.products_active_count',
|
105 |
+
'frame_callback' => array($this, 'callbackColumnListedProducts')
|
106 |
+
));
|
107 |
+
|
108 |
+
$this->addColumn('products_inactive_count', array(
|
109 |
+
'header' => Mage::helper('M2ePro')->__('Inactive Items'),
|
110 |
+
'align' => 'right',
|
111 |
+
'width' => '100px',
|
112 |
+
'type' => 'number',
|
113 |
+
'index' => 'products_inactive_count',
|
114 |
+
'filter_index' => 'main_table.products_inactive_count',
|
115 |
+
'frame_callback' => array($this, 'callbackColumnInactiveProducts')
|
116 |
+
));
|
117 |
+
|
118 |
+
$this->addColumn('create_date', array(
|
119 |
+
'header' => Mage::helper('M2ePro')->__('Creation Date'),
|
120 |
+
'align' => 'left',
|
121 |
+
'width' => '150px',
|
122 |
+
'type' => 'datetime',
|
123 |
+
'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM),
|
124 |
+
'index' => 'create_date',
|
125 |
+
'filter_index' => 'main_table.create_date'
|
126 |
+
));
|
127 |
+
|
128 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
129 |
+
'*/adminhtml_common_listing/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' => '150px',
|
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 Products'),
|
147 |
+
'field' => 'id',
|
148 |
+
'url' => array(
|
149 |
+
'base' => '*/adminhtml_common_buy_listing/view',
|
150 |
+
'params' => array('back' => $backUrl)
|
151 |
+
)
|
152 |
+
),
|
153 |
+
array(
|
154 |
+
'caption' => Mage::helper('M2ePro')->__('Add Products from Products List'),
|
155 |
+
'field' => 'id',
|
156 |
+
'url' => array(
|
157 |
+
'base' => '*/adminhtml_common_buy_listing/product',
|
158 |
+
'params' => array('back' => $backUrl)
|
159 |
+
)
|
160 |
+
),
|
161 |
+
array(
|
162 |
+
'caption' => Mage::helper('M2ePro')->__('Add Products from Categories'),
|
163 |
+
'field' => 'id',
|
164 |
+
'url' => array(
|
165 |
+
'base' => '*/adminhtml_common_buy_listing/categoryProduct',
|
166 |
+
'params' => array('back' => $backUrl)
|
167 |
+
)
|
168 |
+
),
|
169 |
+
array(
|
170 |
+
'caption' => Mage::helper('M2ePro')->__('Edit Settings'),
|
171 |
+
'field' => 'id',
|
172 |
+
'url' => array(
|
173 |
+
'base' => '*/adminhtml_common_buy_listing/edit',
|
174 |
+
'params' => array('back' => $backUrl)
|
175 |
+
)
|
176 |
+
),
|
177 |
+
array(
|
178 |
+
'caption' => Mage::helper('M2ePro')->__('Delete Listing'),
|
179 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?'),
|
180 |
+
'field' => 'id',
|
181 |
+
'url' => array(
|
182 |
+
'base' => '*/adminhtml_common_buy_listing/delete',
|
183 |
+
)
|
184 |
+
),
|
185 |
+
array(
|
186 |
+
'caption' => Mage::helper('M2ePro')->__('View Log'),
|
187 |
+
'field' => 'id',
|
188 |
+
'url' => array(
|
189 |
+
'base' => '*/adminhtml_common_log/listing',
|
190 |
+
'params' => array('back' => $backUrl)
|
191 |
+
)
|
192 |
+
),
|
193 |
+
array(
|
194 |
+
'caption' => Mage::helper('M2ePro')->__('Clear Log'),
|
195 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?'),
|
196 |
+
'field' => 'id',
|
197 |
+
'url' => array(
|
198 |
+
'base' => '*/adminhtml_listing/clearLog',
|
199 |
+
'params' => array('back' => $backUrl)
|
200 |
+
)
|
201 |
+
),
|
202 |
+
array(
|
203 |
+
'caption' => Mage::helper('M2ePro')->__('Edit Selling Format Template'),
|
204 |
+
'field' => 'id',
|
205 |
+
'url' => array(
|
206 |
+
'base' => '*/adminhtml_common_listing/goToSellingFormatTemplate',
|
207 |
+
'params' => array('back' => $backUrl)
|
208 |
+
)
|
209 |
+
),
|
210 |
+
array(
|
211 |
+
'caption' => Mage::helper('M2ePro')->__('Edit Synchronization Template'),
|
212 |
+
'field' => 'id',
|
213 |
+
'url' => array(
|
214 |
+
'base' => '*/adminhtml_common_listing/goToSynchronizationTemplate',
|
215 |
+
'params' => array('back' => $backUrl)
|
216 |
+
)
|
217 |
+
)
|
218 |
+
)
|
219 |
+
));
|
220 |
+
|
221 |
+
return parent::_prepareColumns();
|
222 |
+
}
|
223 |
+
|
224 |
+
// ####################################
|
225 |
+
|
226 |
+
protected function _prepareMassaction()
|
227 |
+
{
|
228 |
+
// Set massaction identifiers
|
229 |
+
//--------------------------------
|
230 |
+
$this->setMassactionIdField('id');
|
231 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
232 |
+
//--------------------------------
|
233 |
+
|
234 |
+
// Set clear log action
|
235 |
+
//--------------------------------
|
236 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
237 |
+
'*/adminhtml_common_listing/index',
|
238 |
+
array(
|
239 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_BUY
|
240 |
+
)
|
241 |
+
);
|
242 |
+
|
243 |
+
$this->getMassactionBlock()->addItem('clear_logs', array(
|
244 |
+
'label' => Mage::helper('M2ePro')->__('Clear Log(s)'),
|
245 |
+
'url' => $this->getUrl('*/adminhtml_listing/clearLog', array('back' => $backUrl)),
|
246 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
247 |
+
));
|
248 |
+
//--------------------------------
|
249 |
+
|
250 |
+
// Set remove listings action
|
251 |
+
//--------------------------------
|
252 |
+
$this->getMassactionBlock()->addItem('delete_listings', array(
|
253 |
+
'label' => Mage::helper('M2ePro')->__('Delete Listing(s)'),
|
254 |
+
'url' => $this->getUrl('*/adminhtml_common_buy_listing/delete'),
|
255 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
256 |
+
));
|
257 |
+
//--------------------------------
|
258 |
+
|
259 |
+
return parent::_prepareMassaction();
|
260 |
+
}
|
261 |
+
|
262 |
+
// ####################################
|
263 |
+
|
264 |
+
public function callbackColumnTotalProducts($value, $row, $column, $isExport)
|
265 |
+
{
|
266 |
+
if (is_null($value) || $value === '') {
|
267 |
+
$value = Mage::helper('M2ePro')->__('N/A');
|
268 |
+
} else if ($value <= 0) {
|
269 |
+
$value = '<span style="color: red;">0</span>';
|
270 |
+
}
|
271 |
+
|
272 |
+
return $value;
|
273 |
+
}
|
274 |
+
|
275 |
+
public function callbackColumnListedProducts($value, $row, $column, $isExport)
|
276 |
+
{
|
277 |
+
if (is_null($value) || $value === '') {
|
278 |
+
$value = Mage::helper('M2ePro')->__('N/A');
|
279 |
+
} else if ($value <= 0) {
|
280 |
+
$value = '<span style="color: red;">0</span>';
|
281 |
+
}
|
282 |
+
|
283 |
+
return $value;
|
284 |
+
}
|
285 |
+
|
286 |
+
public function callbackColumnSoldProducts($value, $row, $column, $isExport)
|
287 |
+
{
|
288 |
+
if (is_null($value) || $value === '') {
|
289 |
+
$value = Mage::helper('M2ePro')->__('N/A');
|
290 |
+
} else if ($value <= 0) {
|
291 |
+
$value = '<span style="color: red;">0</span>';
|
292 |
+
}
|
293 |
+
|
294 |
+
return $value;
|
295 |
+
}
|
296 |
+
|
297 |
+
public function callbackColumnInactiveProducts($value, $row, $column, $isExport)
|
298 |
+
{
|
299 |
+
if (is_null($value) || $value === '') {
|
300 |
+
$value = Mage::helper('M2ePro')->__('N/A');
|
301 |
+
} else if ($value <= 0) {
|
302 |
+
$value = '<span style="color: red;">0</span>';
|
303 |
+
}
|
304 |
+
|
305 |
+
return $value;
|
306 |
+
}
|
307 |
+
|
308 |
+
// ####################################
|
309 |
+
|
310 |
+
public function getGridUrl()
|
311 |
+
{
|
312 |
+
return $this->getUrl('*/adminhtml_common_buy_listing/listingGrid', array('_current'=>true));
|
313 |
+
}
|
314 |
+
|
315 |
+
public function getRowUrl($row)
|
316 |
+
{
|
317 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
318 |
+
'*/adminhtml_common_listing/index',
|
319 |
+
array(
|
320 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_BUY
|
321 |
+
)
|
322 |
+
);
|
323 |
+
|
324 |
+
return $this->getUrl(
|
325 |
+
'*/adminhtml_common_buy_listing/view',
|
326 |
+
array(
|
327 |
+
'id' => $row->getId(),
|
328 |
+
'back' => $backUrl
|
329 |
+
)
|
330 |
+
);
|
331 |
+
}
|
332 |
+
|
333 |
+
// ####################################
|
334 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Other/Grid.php
ADDED
@@ -0,0 +1,529 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|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|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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')->__('Product 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')->__('Rakuten.com 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')->__('Rakuten.com 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 |
+
)
|
153 |
+
)
|
154 |
+
),
|
155 |
+
array(
|
156 |
+
'caption' => Mage::helper('M2ePro')->__('Clear Log'),
|
157 |
+
'url' => array(
|
158 |
+
'base' => '*/adminhtml_listing_other/clearLog',
|
159 |
+
'params' => array(
|
160 |
+
'back' => $backUrl
|
161 |
+
)
|
162 |
+
),
|
163 |
+
'field' => 'id',
|
164 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
165 |
+
)
|
166 |
+
)
|
167 |
+
));
|
168 |
+
|
169 |
+
return parent::_prepareColumns();
|
170 |
+
}
|
171 |
+
|
172 |
+
protected function _prepareMassaction()
|
173 |
+
{
|
174 |
+
// Set mass-action identifiers
|
175 |
+
//--------------------------------
|
176 |
+
$this->setMassactionIdField('`main_table`.id');
|
177 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
178 |
+
//--------------------------------
|
179 |
+
|
180 |
+
// Set mass-action
|
181 |
+
//--------------------------------
|
182 |
+
$this->getMassactionBlock()->addItem('autoMapping', array(
|
183 |
+
'label' => Mage::helper('M2ePro')->__('Map Item(s) Automatically'),
|
184 |
+
'url' => '',
|
185 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
186 |
+
));
|
187 |
+
$this->getMassactionBlock()->addItem('moving', array(
|
188 |
+
'label' => Mage::helper('M2ePro')->__('Move Item(s) To Listing'),
|
189 |
+
'url' => '',
|
190 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
191 |
+
));
|
192 |
+
$this->getMassactionBlock()->addItem('removing', array(
|
193 |
+
'label' => Mage::helper('M2ePro')->__('Remove Item(s)'),
|
194 |
+
'url' => '',
|
195 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
196 |
+
));
|
197 |
+
$this->getMassactionBlock()->addItem('unmapping', array(
|
198 |
+
'label' => Mage::helper('M2ePro')->__('Unmap Item(s)'),
|
199 |
+
'url' => '',
|
200 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
201 |
+
));
|
202 |
+
//--------------------------------
|
203 |
+
|
204 |
+
return parent::_prepareMassaction();
|
205 |
+
}
|
206 |
+
|
207 |
+
// ####################################
|
208 |
+
|
209 |
+
public function callbackColumnProductId($value, $row, $column, $isExport)
|
210 |
+
{
|
211 |
+
if (empty($value)) {
|
212 |
+
$productTitle = $row->getData('title');
|
213 |
+
|
214 |
+
if (is_null($productTitle) || $productTitle === '') {
|
215 |
+
$productTitle = Mage::helper('M2ePro')->__('N/A');
|
216 |
+
} else {
|
217 |
+
$productTitle = Mage::helper('M2ePro')->escapeHtml($productTitle);
|
218 |
+
$productTitle = Mage::helper('M2ePro')->escapeJs($productTitle);
|
219 |
+
if (strlen($productTitle) > 60) {
|
220 |
+
$productTitle = substr($productTitle, 0, 60) . '...';
|
221 |
+
}
|
222 |
+
}
|
223 |
+
|
224 |
+
$htmlValue = ' <a href="javascript:void(0);"
|
225 |
+
onclick="BuyListingOtherMappingHandlerObj.openPopUp(\''
|
226 |
+
.$productTitle
|
227 |
+
.'\','
|
228 |
+
.(int)$row->getId()
|
229 |
+
.');">'
|
230 |
+
.Mage::helper('M2ePro')->__('Map').'</a>';
|
231 |
+
|
232 |
+
if (Mage::helper('M2ePro/Module')->isDevelopmentMode()) {
|
233 |
+
$htmlValue .= '<br>' . $row->getId();
|
234 |
+
}
|
235 |
+
|
236 |
+
return $htmlValue;
|
237 |
+
}
|
238 |
+
|
239 |
+
$htmlValue = ' <a href="'
|
240 |
+
.$this->getUrl('adminhtml/catalog_product/edit',
|
241 |
+
array('id' => $row->getData('product_id')))
|
242 |
+
.'" target="_blank">'
|
243 |
+
.$row->getData('product_id')
|
244 |
+
.'</a>';
|
245 |
+
|
246 |
+
$htmlValue .= '   <a href="javascript:void(0);"'
|
247 |
+
.' onclick="BuyListingOtherGridHandlerObj.movingHandler.getGridHtml('
|
248 |
+
.json_encode(array((int)$row->getData('id')))
|
249 |
+
.')">'
|
250 |
+
.Mage::helper('M2ePro')->__('Move')
|
251 |
+
.'</a>';
|
252 |
+
|
253 |
+
if (Mage::helper('M2ePro/Module')->isDevelopmentMode()) {
|
254 |
+
$htmlValue .= '<br>' . $row->getId();
|
255 |
+
}
|
256 |
+
|
257 |
+
return $htmlValue;
|
258 |
+
}
|
259 |
+
|
260 |
+
public function callbackColumnProductTitle($value, $row, $column, $isExport)
|
261 |
+
{
|
262 |
+
if (is_null($value) || $value === '') {
|
263 |
+
$value = '<i style="color:gray;">receiving...</i>';
|
264 |
+
} else {
|
265 |
+
$value = Mage::helper('M2ePro')->escapeHtml($value);
|
266 |
+
if (strlen($value) > 60) {
|
267 |
+
$value = substr($value, 0, 60) . '...';
|
268 |
+
}
|
269 |
+
|
270 |
+
$value = '<span>' . $value . '</span>';
|
271 |
+
}
|
272 |
+
|
273 |
+
$tempSku = $row->getData('sku');
|
274 |
+
is_null($tempSku) && $tempSku = Mage::helper('M2ePro')->__('N/A');
|
275 |
+
|
276 |
+
$value .= '<br/><strong>'.Mage::helper('M2ePro')->__('Reference ID').':</strong> '
|
277 |
+
.Mage::helper('M2ePro')->escapeHtml($tempSku);
|
278 |
+
|
279 |
+
return $value;
|
280 |
+
}
|
281 |
+
|
282 |
+
public function callbackColumnGeneralId($value, $row, $column, $isExport)
|
283 |
+
{
|
284 |
+
$url = Mage::helper('M2ePro/Component_Buy')->getItemUrl($value);
|
285 |
+
return '<a href="'.$url.'" target="_blank">'.$value.'</a>';
|
286 |
+
}
|
287 |
+
|
288 |
+
public function callbackColumnSku($value, $row, $column, $isExport)
|
289 |
+
{
|
290 |
+
return $value;
|
291 |
+
}
|
292 |
+
|
293 |
+
public function callbackColumnAvailableQty($value, $row, $column, $isExport)
|
294 |
+
{
|
295 |
+
if (is_null($value) || $value === '') {
|
296 |
+
return Mage::helper('M2ePro')->__('N/A');
|
297 |
+
}
|
298 |
+
|
299 |
+
if ($value <= 0) {
|
300 |
+
return '<span style="color: red;">0</span>';
|
301 |
+
}
|
302 |
+
|
303 |
+
return $value;
|
304 |
+
}
|
305 |
+
|
306 |
+
public function callbackColumnPrice($value, $row, $column, $isExport)
|
307 |
+
{
|
308 |
+
if (is_null($value) || $value === '') {
|
309 |
+
return Mage::helper('M2ePro')->__('N/A');
|
310 |
+
}
|
311 |
+
|
312 |
+
if ((float)$value <= 0) {
|
313 |
+
return '<span style="color: #f00;">0</span>';
|
314 |
+
}
|
315 |
+
|
316 |
+
return Mage::app()->getLocale()->currency('USD')->toCurrency($value);
|
317 |
+
}
|
318 |
+
|
319 |
+
public function callbackColumnStatus($value, $row, $column, $isExport)
|
320 |
+
{
|
321 |
+
switch ($row->getData('status')) {
|
322 |
+
|
323 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED:
|
324 |
+
$value = '<span style="color: gray;">' . $value . '</span>';
|
325 |
+
break;
|
326 |
+
|
327 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_LISTED:
|
328 |
+
$value = '<span style="color: green;">' . $value . '</span>';
|
329 |
+
break;
|
330 |
+
|
331 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED:
|
332 |
+
$value = '<span style="color: red;">' . $value . '</span>';
|
333 |
+
break;
|
334 |
+
|
335 |
+
default:
|
336 |
+
break;
|
337 |
+
}
|
338 |
+
|
339 |
+
return $value.$this->getViewLogIconHtml($row->getId());
|
340 |
+
}
|
341 |
+
|
342 |
+
protected function callbackFilterTitle($collection, $column)
|
343 |
+
{
|
344 |
+
$value = $column->getFilter()->getValue();
|
345 |
+
|
346 |
+
if ($value == null) {
|
347 |
+
return;
|
348 |
+
}
|
349 |
+
|
350 |
+
$collection->getSelect()->where('second_table.title LIKE ? OR second_table.sku LIKE ?', '%'.$value.'%');
|
351 |
+
}
|
352 |
+
|
353 |
+
// ####################################
|
354 |
+
|
355 |
+
public function getViewLogIconHtml($listingOtherId)
|
356 |
+
{
|
357 |
+
$listingOtherId = (int)$listingOtherId;
|
358 |
+
|
359 |
+
// Get last messages
|
360 |
+
//--------------------------
|
361 |
+
$dbSelect = $this->connRead->select()
|
362 |
+
->from(
|
363 |
+
Mage::getResourceModel('M2ePro/Listing_Other_Log')->getMainTable(),
|
364 |
+
array('action_id','action','type','description','create_date','initiator')
|
365 |
+
)
|
366 |
+
->where('`listing_other_id` = ?', $listingOtherId)
|
367 |
+
->where('`action_id` IS NOT NULL')
|
368 |
+
->order(array('id DESC'))
|
369 |
+
->limit(30);
|
370 |
+
|
371 |
+
$logRows = $this->connRead->fetchAll($dbSelect);
|
372 |
+
//--------------------------
|
373 |
+
|
374 |
+
// Get grouped messages by action_id
|
375 |
+
//--------------------------
|
376 |
+
$actionsRows = array();
|
377 |
+
$tempActionRows = array();
|
378 |
+
$lastActionId = false;
|
379 |
+
|
380 |
+
foreach ($logRows as $row) {
|
381 |
+
|
382 |
+
$row['description'] = Mage::helper('M2ePro/View')->getModifiedLogMessage($row['description']);
|
383 |
+
|
384 |
+
if ($row['action_id'] !== $lastActionId) {
|
385 |
+
if (count($tempActionRows) > 0) {
|
386 |
+
$actionsRows[] = array(
|
387 |
+
'type' => $this->getMainTypeForActionId($tempActionRows),
|
388 |
+
'date' => $this->getMainDateForActionId($tempActionRows),
|
389 |
+
'action' => $this->getActionForAction($tempActionRows[0]),
|
390 |
+
'initiator' => $this->getInitiatorForAction($tempActionRows[0]),
|
391 |
+
'items' => $tempActionRows
|
392 |
+
);
|
393 |
+
$tempActionRows = array();
|
394 |
+
}
|
395 |
+
$lastActionId = $row['action_id'];
|
396 |
+
}
|
397 |
+
$tempActionRows[] = $row;
|
398 |
+
}
|
399 |
+
|
400 |
+
if (count($tempActionRows) > 0) {
|
401 |
+
$actionsRows[] = array(
|
402 |
+
'type' => $this->getMainTypeForActionId($tempActionRows),
|
403 |
+
'date' => $this->getMainDateForActionId($tempActionRows),
|
404 |
+
'action' => $this->getActionForAction($tempActionRows[0]),
|
405 |
+
'initiator' => $this->getInitiatorForAction($tempActionRows[0]),
|
406 |
+
'items' => $tempActionRows
|
407 |
+
);
|
408 |
+
}
|
409 |
+
|
410 |
+
if (count($actionsRows) <= 0) {
|
411 |
+
return '';
|
412 |
+
}
|
413 |
+
|
414 |
+
$tips = array(
|
415 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'Last action was completed successfully.',
|
416 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'Last action was completed with error(s).',
|
417 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'Last action was completed with warning(s).'
|
418 |
+
);
|
419 |
+
|
420 |
+
$icons = array(
|
421 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'normal',
|
422 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'error',
|
423 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'warning'
|
424 |
+
);
|
425 |
+
|
426 |
+
$summary = $this->getLayout()->createBlock('M2ePro/adminhtml_log_grid_summary', '', array(
|
427 |
+
'entity_id' => $listingOtherId,
|
428 |
+
'rows' => $actionsRows,
|
429 |
+
'tips' => $tips,
|
430 |
+
'icons' => $icons,
|
431 |
+
'view_help_handler' => 'BuyListingOtherGridHandlerObj.viewItemHelp',
|
432 |
+
'hide_help_handler' => 'BuyListingOtherGridHandlerObj.hideItemHelp',
|
433 |
+
));
|
434 |
+
|
435 |
+
return $summary->toHtml();
|
436 |
+
}
|
437 |
+
|
438 |
+
public function getActionForAction($actionRows)
|
439 |
+
{
|
440 |
+
$string = '';
|
441 |
+
|
442 |
+
switch ((int)$actionRows['action']) {
|
443 |
+
case Ess_M2ePro_Model_Listing_Other_Log::ACTION_CHANGE_STATUS_ON_CHANNEL:
|
444 |
+
$string = Mage::helper('M2ePro')->__('Status Change');
|
445 |
+
break;
|
446 |
+
}
|
447 |
+
|
448 |
+
return $string;
|
449 |
+
}
|
450 |
+
|
451 |
+
public function getInitiatorForAction($actionRows)
|
452 |
+
{
|
453 |
+
$string = '';
|
454 |
+
|
455 |
+
switch ($actionRows['initiator']) {
|
456 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_UNKNOWN:
|
457 |
+
$string = '';
|
458 |
+
break;
|
459 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_USER:
|
460 |
+
$string = Mage::helper('M2ePro')->__('Manual');
|
461 |
+
break;
|
462 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION:
|
463 |
+
$string = Mage::helper('M2ePro')->__('Automatic');
|
464 |
+
break;
|
465 |
+
}
|
466 |
+
|
467 |
+
return $string;
|
468 |
+
}
|
469 |
+
|
470 |
+
public function getMainTypeForActionId($actionRows)
|
471 |
+
{
|
472 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS;
|
473 |
+
|
474 |
+
foreach ($actionRows as $row) {
|
475 |
+
if ($row['type'] == Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR) {
|
476 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR;
|
477 |
+
break;
|
478 |
+
}
|
479 |
+
if ($row['type'] == Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING) {
|
480 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING;
|
481 |
+
}
|
482 |
+
}
|
483 |
+
|
484 |
+
return $type;
|
485 |
+
}
|
486 |
+
|
487 |
+
public function getMainDateForActionId($actionRows)
|
488 |
+
{
|
489 |
+
$format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
|
490 |
+
return Mage::app()->getLocale()->date(strtotime($actionRows[0]['create_date']))->toString($format);
|
491 |
+
}
|
492 |
+
|
493 |
+
// ####################################
|
494 |
+
|
495 |
+
protected function _toHtml()
|
496 |
+
{
|
497 |
+
$javascriptsMain = <<<JAVASCRIPT
|
498 |
+
<script type="text/javascript">
|
499 |
+
|
500 |
+
if (typeof BuyListingOtherGridHandlerObj != 'undefined') {
|
501 |
+
BuyListingOtherGridHandlerObj.afterInitPage();
|
502 |
+
}
|
503 |
+
|
504 |
+
Event.observe(window, 'load', function() {
|
505 |
+
setTimeout(function() {
|
506 |
+
BuyListingOtherGridHandlerObj.afterInitPage();
|
507 |
+
}, 350);
|
508 |
+
});
|
509 |
+
|
510 |
+
</script>
|
511 |
+
JAVASCRIPT;
|
512 |
+
|
513 |
+
return parent::_toHtml().$javascriptsMain;
|
514 |
+
}
|
515 |
+
|
516 |
+
// ####################################
|
517 |
+
|
518 |
+
public function getGridUrl()
|
519 |
+
{
|
520 |
+
return $this->getUrl('*/adminhtml_common_buy_listing_other/grid', 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/Buy/Listing/Other/Help.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_Other_Help extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingOtherHelp');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/buy/listing/other/help.phtml');
|
19 |
+
}
|
20 |
+
|
21 |
+
public function getContainerId()
|
22 |
+
{
|
23 |
+
return 'block_notice_buy_listings';
|
24 |
+
}
|
25 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Product.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_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')->__(Ess_M2ePro_Helper_Component_Buy::TITLE),
|
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('reset', array(
|
76 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
77 |
+
'onclick' => 'ProductGridHandlerObj.reset_click()',
|
78 |
+
'class' => 'reset'
|
79 |
+
));
|
80 |
+
//------------------------------
|
81 |
+
|
82 |
+
//------------------------------
|
83 |
+
$this->_addButton('save', array(
|
84 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
85 |
+
'onclick' => 'ProductGridHandlerObj.save_click(\'view\')',
|
86 |
+
'class' => 'save'
|
87 |
+
));
|
88 |
+
//------------------------------
|
89 |
+
}
|
90 |
+
|
91 |
+
public function getGridHtml()
|
92 |
+
{
|
93 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_listing_product_help');
|
94 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
95 |
+
}
|
96 |
+
|
97 |
+
protected function _toHtml()
|
98 |
+
{
|
99 |
+
return '<div id="add_products_progress_bar"></div>'.
|
100 |
+
'<div id="add_products_container">'.
|
101 |
+
parent::_toHtml().
|
102 |
+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â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_Product_Category extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingProductCategory');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_buy_listing';
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$this->setTemplate('widget/view/container.phtml');
|
21 |
+
|
22 |
+
// Set header text
|
23 |
+
//------------------------------
|
24 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
25 |
+
|
26 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
27 |
+
$headerText = Mage::helper('M2ePro')->__(
|
28 |
+
'Add Products To %component_name% Listing "%listing_title%" From Categories',
|
29 |
+
Mage::helper('M2ePro')->__(Ess_M2ePro_Helper_Component_Buy::TITLE),
|
30 |
+
$this->escapeHtml($listingData['title'])
|
31 |
+
);
|
32 |
+
} else {
|
33 |
+
$headerText = Mage::helper('M2ePro')->__(
|
34 |
+
'Add Products To Listing "%listing_title%" From Categories',
|
35 |
+
$this->escapeHtml($listingData['title'])
|
36 |
+
);
|
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 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
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' => 'BuyListingCategoryHandlerObj.back_click(\'' . $url . '\')',
|
65 |
+
'class' => 'back'
|
66 |
+
));
|
67 |
+
//------------------------------
|
68 |
+
} else {
|
69 |
+
//------------------------------
|
70 |
+
$url = $this->getUrl('*/adminhtml_common_buy_listing/view', array('id' => $listingData['id']));
|
71 |
+
$this->_addButton('view_listing', array(
|
72 |
+
'label' => Mage::helper('M2ePro')->__('View Listing'),
|
73 |
+
'onclick' => 'setLocation(\''.$url.'\')',
|
74 |
+
'class' => 'button_link'
|
75 |
+
));
|
76 |
+
//------------------------------
|
77 |
+
}
|
78 |
+
|
79 |
+
//------------------------------
|
80 |
+
$this->_addButton('reset', array(
|
81 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
82 |
+
'onclick' => 'BuyListingCategoryHandlerObj.reset_click()',
|
83 |
+
'class' => 'reset'
|
84 |
+
));
|
85 |
+
//------------------------------
|
86 |
+
|
87 |
+
//------------------------------
|
88 |
+
$url = $this->getUrl(
|
89 |
+
'*/adminhtml_common_buy_listing/categoryProduct',
|
90 |
+
array(
|
91 |
+
'id' => $listingData['id'],
|
92 |
+
'add_products'=>'yes',
|
93 |
+
'next' => 'yes'
|
94 |
+
)
|
95 |
+
);
|
96 |
+
$this->_addButton('save_and_next', array(
|
97 |
+
'label' => Mage::helper('M2ePro')->__('Next'),
|
98 |
+
'onclick' => 'BuyListingCategoryHandlerObj.save_click(\''.$url.'\')',
|
99 |
+
'class' => 'next save_and_next_button'
|
100 |
+
));
|
101 |
+
//------------------------------
|
102 |
+
|
103 |
+
//$url = $this->getUrl('*/adminhtml_common_buy_listing/product',array(
|
104 |
+
// 'id' => $listingData['id'],
|
105 |
+
// 'back' => Mage::helper('M2ePro')->getBackUrlParam('*/adminhtml_common_listing/index')
|
106 |
+
//));
|
107 |
+
//$this->_addButton('save_and_list', array(
|
108 |
+
// 'label' => Mage::helper('M2ePro')->__('Save And List'),
|
109 |
+
// 'onclick' => 'BuyListingCategoryHandlerObj.save_and_list_click(\''.$url.'\')',
|
110 |
+
// 'class' => 'save save_and_list_button'
|
111 |
+
//));
|
112 |
+
|
113 |
+
//------------------------------
|
114 |
+
$url = $this->getUrl('*/adminhtml_common_buy_listing/add',array('add_products'=>'yes'));
|
115 |
+
$this->_addButton('save_and_go_to_listing_view', array(
|
116 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
117 |
+
'onclick' => 'BuyListingCategoryHandlerObj.save_click(\'' . $url .'\')',
|
118 |
+
'class' => 'save save_and_go_to_listings_view_button'
|
119 |
+
));
|
120 |
+
//------------------------------
|
121 |
+
}
|
122 |
+
|
123 |
+
protected function _toHtml()
|
124 |
+
{
|
125 |
+
$treeSettings = array(
|
126 |
+
'show_products_amount' => true,
|
127 |
+
'hide_products_this_listing' => true
|
128 |
+
);
|
129 |
+
// todo next
|
130 |
+
$categoryTreeBlock = $this->getLayout()
|
131 |
+
->createBlock('M2ePro/adminhtml_common_listing_category_tree','',array(
|
132 |
+
'component'=>Ess_M2ePro_Helper_Component_Buy::NICK,
|
133 |
+
'tree_settings' => $treeSettings
|
134 |
+
));
|
135 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_listing_product_category_help');
|
136 |
+
$categoryBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_listing_product_category_edit');
|
137 |
+
|
138 |
+
return '<div id="add_products_progress_bar"></div>'.
|
139 |
+
'<div id="add_products_container">'.
|
140 |
+
parent::_toHtml() . $helpBlock->toHtml() . $categoryTreeBlock->toHtml() . $categoryBlock->toHtml().
|
141 |
+
'</div>';
|
142 |
+
}
|
143 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Product/Category/Edit.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_Category_Edit extends Mage_Adminhtml_Block_Template
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingProductCategory');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/buy/listing/product/category/edit.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Product/Category/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_Category_Help extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingProductCategoryHelp');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/buy/listing/product/category/help.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Product/Grid.php
ADDED
@@ -0,0 +1,603 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|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|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Buy_Listing_Product_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('buyListingProductGrid'.(isset($listingData['id'])?$listingData['id']:''));
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
// Set default values
|
21 |
+
//------------------------------
|
22 |
+
$this->setDefaultSort('product_id');
|
23 |
+
$this->setDefaultDir('DESC');
|
24 |
+
$this->setSaveParametersInSession(true);
|
25 |
+
$this->setUseAjax(true);
|
26 |
+
//------------------------------
|
27 |
+
|
28 |
+
$this->isAjax = json_encode($this->getRequest()->isXmlHttpRequest());
|
29 |
+
}
|
30 |
+
|
31 |
+
// ####################################
|
32 |
+
|
33 |
+
protected function _prepareCollection()
|
34 |
+
{
|
35 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
36 |
+
|
37 |
+
// Get collection
|
38 |
+
//----------------------------
|
39 |
+
/* @var $collection Mage_Catalog_Model_Resource_Product_Collection */
|
40 |
+
$collection = Mage::getModel('catalog/product')->getCollection()
|
41 |
+
->addAttributeToSelect('sku')
|
42 |
+
->addAttributeToSelect('name')
|
43 |
+
->addAttributeToSelect('attribute_set_id')
|
44 |
+
->addAttributeToSelect('type_id')
|
45 |
+
->joinField('qty',
|
46 |
+
'cataloginventory/stock_item',
|
47 |
+
'qty',
|
48 |
+
'product_id=entity_id',
|
49 |
+
'{{table}}.stock_id=1',
|
50 |
+
'left')
|
51 |
+
->joinField('is_in_stock',
|
52 |
+
'cataloginventory/stock_item',
|
53 |
+
'is_in_stock',
|
54 |
+
'product_id=entity_id',
|
55 |
+
'{{table}}.stock_id=1',
|
56 |
+
'left');
|
57 |
+
|
58 |
+
/*$collection->getSelect()->joinLeft(
|
59 |
+
array('cisi' => Mage::getSingleton('core/resource')->getTableName('cataloginventory/stock_item')),
|
60 |
+
'(cisi.product_id = e.entity_id) AND (cisi.stock_id = 1)',
|
61 |
+
array('qty','is_in_stock')
|
62 |
+
);*/
|
63 |
+
//----------------------------
|
64 |
+
|
65 |
+
//----------------------------
|
66 |
+
$collection->getSelect()->distinct();
|
67 |
+
//----------------------------
|
68 |
+
|
69 |
+
// Add attribute set filter
|
70 |
+
//----------------------------
|
71 |
+
$collection->addFieldToFilter('attribute_set_id', array('in' => $listingData['attribute_sets']));
|
72 |
+
//----------------------------
|
73 |
+
|
74 |
+
// Set filter store
|
75 |
+
//----------------------------
|
76 |
+
$store = $this->_getStore();
|
77 |
+
|
78 |
+
if ($store->getId()) {
|
79 |
+
$collection->addStoreFilter($store);
|
80 |
+
$collection->joinAttribute('custom_name',
|
81 |
+
'catalog_product/name',
|
82 |
+
'entity_id',
|
83 |
+
null,
|
84 |
+
'inner',
|
85 |
+
$store->getId());
|
86 |
+
$collection->joinAttribute('status',
|
87 |
+
'catalog_product/status',
|
88 |
+
'entity_id',
|
89 |
+
null,
|
90 |
+
'inner',
|
91 |
+
$store->getId());
|
92 |
+
$collection->joinAttribute('visibility',
|
93 |
+
'catalog_product/visibility',
|
94 |
+
'entity_id',
|
95 |
+
null,
|
96 |
+
'inner',
|
97 |
+
$store->getId());
|
98 |
+
$collection->joinAttribute('price',
|
99 |
+
'catalog_product/price',
|
100 |
+
'entity_id',
|
101 |
+
null,
|
102 |
+
'left',
|
103 |
+
$store->getId());
|
104 |
+
$collection->joinAttribute('thumbnail',
|
105 |
+
'catalog_product/thumbnail',
|
106 |
+
'entity_id',
|
107 |
+
null,
|
108 |
+
'left',
|
109 |
+
$store->getId());
|
110 |
+
} else {
|
111 |
+
$collection->addAttributeToSelect('price');
|
112 |
+
$collection->addAttributeToSelect('status');
|
113 |
+
$collection->addAttributeToSelect('visibility');
|
114 |
+
$collection->addAttributeToSelect('thumbnail');
|
115 |
+
}
|
116 |
+
//----------------------------
|
117 |
+
|
118 |
+
// Hide products others listings
|
119 |
+
//----------------------------
|
120 |
+
$prefix = Mage::helper('M2ePro/Data_Global')->getValue('hide_products_others_listings_prefix');
|
121 |
+
is_null($hideParam = Mage::helper('M2ePro/Data_Session')->getValue($prefix)) && $hideParam = true;
|
122 |
+
|
123 |
+
if ($hideParam || isset($listingData['id'])) {
|
124 |
+
|
125 |
+
$dbExcludeSelect = Mage::getResourceModel('core/config')->getReadConnection()
|
126 |
+
->select()
|
127 |
+
->from(Mage::getResourceModel('M2ePro/Listing_Product')->getMainTable(),
|
128 |
+
new Zend_Db_Expr('DISTINCT `product_id`'));
|
129 |
+
|
130 |
+
if ($hideParam) {
|
131 |
+
|
132 |
+
$dbExcludeSelect->join(
|
133 |
+
array('l' => Mage::getResourceModel('M2ePro/Listing')->getMainTable()),
|
134 |
+
'`l`.`id` = `listing_id`', NULL
|
135 |
+
);
|
136 |
+
|
137 |
+
$dbExcludeSelect->where('`l`.`account_id` = ?', $listingData['account_id']);
|
138 |
+
$dbExcludeSelect->where('`l`.`marketplace_id` = ?', $listingData['marketplace_id']);
|
139 |
+
$dbExcludeSelect->where('`l`.`component_mode` = ?',Ess_M2ePro_Helper_Component_Buy::NICK);
|
140 |
+
|
141 |
+
} else {
|
142 |
+
$dbExcludeSelect->where('`listing_id` = ?',(int)$listingData['id']);
|
143 |
+
}
|
144 |
+
|
145 |
+
// default sql select
|
146 |
+
$collection->getSelect()
|
147 |
+
->joinLeft(array('sq' => $dbExcludeSelect), 'sq.product_id = e.entity_id', array())
|
148 |
+
->where('sq.product_id IS NULL');
|
149 |
+
|
150 |
+
// alternatively sql select (for mysql v.5.1)
|
151 |
+
// $collection->getSelect()->where('`e`.`entity_id` NOT IN ('.$dbExcludeSelect->__toString().')');
|
152 |
+
}
|
153 |
+
//----------------------------
|
154 |
+
|
155 |
+
// Add categories filter
|
156 |
+
//----------------------------
|
157 |
+
$categoriesData = Mage::helper('M2ePro/Data_Global')->getValue('temp_listing_categories');
|
158 |
+
|
159 |
+
if (count($categoriesData) > 0) {
|
160 |
+
$dbSelect = Mage::getResourceModel('core/config')->getReadConnection()
|
161 |
+
->select()
|
162 |
+
->from(Mage::getSingleton('core/resource')->getTableName('catalog_category_product'),
|
163 |
+
new Zend_Db_Expr('DISTINCT `product_id`'))
|
164 |
+
->where('`category_id` IN ('.implode(',',$categoriesData).')');
|
165 |
+
|
166 |
+
$collection->getSelect()->where('`e`.`entity_id` IN ('.$dbSelect->__toString().')');
|
167 |
+
}
|
168 |
+
//----------------------------
|
169 |
+
|
170 |
+
$collection->addFieldToFilter(
|
171 |
+
array(
|
172 |
+
array('attribute'=>'type_id','neq'=>'virtual'),
|
173 |
+
)
|
174 |
+
);
|
175 |
+
|
176 |
+
/** @var $ruleModel Ess_M2ePro_Model_Magento_Product_Rule */
|
177 |
+
$ruleModel = Mage::helper('M2ePro/Data_Global')->getValue('rule_model');
|
178 |
+
$ruleModel->setAttributesFilterToCollection($collection);
|
179 |
+
|
180 |
+
//exit($collection->getSelect()->__toString());
|
181 |
+
|
182 |
+
// Set collection to grid
|
183 |
+
$this->setCollection($collection);
|
184 |
+
|
185 |
+
parent::_prepareCollection();
|
186 |
+
$this->getCollection()->addWebsiteNamesToResult();
|
187 |
+
|
188 |
+
return $this;
|
189 |
+
}
|
190 |
+
|
191 |
+
protected function _prepareColumns()
|
192 |
+
{
|
193 |
+
$this->addColumn('product_id', array(
|
194 |
+
'header' => Mage::helper('M2ePro')->__('Product ID'),
|
195 |
+
'align' => 'right',
|
196 |
+
'width' => '100px',
|
197 |
+
'type' => 'number',
|
198 |
+
'index' => 'entity_id',
|
199 |
+
'filter_index' => 'entity_id',
|
200 |
+
'frame_callback' => array($this, 'callbackColumnProductId')
|
201 |
+
));
|
202 |
+
|
203 |
+
$this->addColumn('name', array(
|
204 |
+
'header' => Mage::helper('M2ePro')->__('Product Title'),
|
205 |
+
'align' => 'left',
|
206 |
+
//'width' => '100px',
|
207 |
+
'type' => 'text',
|
208 |
+
'index' => 'name',
|
209 |
+
'filter_index' => 'name',
|
210 |
+
'frame_callback' => array($this, 'callbackColumnProductTitle')
|
211 |
+
));
|
212 |
+
|
213 |
+
$tempTypes = Mage::getSingleton('catalog/product_type')->getOptionArray();
|
214 |
+
if (isset($tempTypes['virtual'])) {
|
215 |
+
unset($tempTypes['virtual']);
|
216 |
+
}
|
217 |
+
|
218 |
+
$this->addColumn('type', array(
|
219 |
+
'header' => Mage::helper('M2ePro')->__('Type'),
|
220 |
+
'align' => 'left',
|
221 |
+
'width' => '90px',
|
222 |
+
'type' => 'options',
|
223 |
+
'sortable' => false,
|
224 |
+
'index' => 'type_id',
|
225 |
+
'filter_index' => 'type_id',
|
226 |
+
'options' => $tempTypes
|
227 |
+
));
|
228 |
+
|
229 |
+
$this->addColumn('is_in_stock', array(
|
230 |
+
'header' => Mage::helper('M2ePro')->__('Stock Availability'),
|
231 |
+
'align' => 'left',
|
232 |
+
'width' => '90px',
|
233 |
+
'type' => 'options',
|
234 |
+
'sortable' => false,
|
235 |
+
'index' => 'is_in_stock',
|
236 |
+
'filter_index' => 'is_in_stock',
|
237 |
+
'options' => array(
|
238 |
+
'1' => Mage::helper('M2ePro')->__('In Stock'),
|
239 |
+
'0' => Mage::helper('M2ePro')->__('Out of Stock')
|
240 |
+
),
|
241 |
+
'frame_callback' => array($this, 'callbackColumnIsInStock')
|
242 |
+
));
|
243 |
+
|
244 |
+
$this->addColumn('sku', array(
|
245 |
+
'header' => Mage::helper('M2ePro')->__('SKU'),
|
246 |
+
'align' => 'left',
|
247 |
+
'width' => '90px',
|
248 |
+
'type' => 'text',
|
249 |
+
'index' => 'sku',
|
250 |
+
'filter_index' => 'sku'
|
251 |
+
));
|
252 |
+
|
253 |
+
$store = $this->_getStore();
|
254 |
+
|
255 |
+
$this->addColumn('price', array(
|
256 |
+
'header' => Mage::helper('M2ePro')->__('Price'),
|
257 |
+
'align' => 'right',
|
258 |
+
'width' => '100px',
|
259 |
+
'type' => 'price',
|
260 |
+
'currency_code' => $store->getBaseCurrency()->getCode(),
|
261 |
+
'index' => 'price',
|
262 |
+
'filter_index' => 'price',
|
263 |
+
'frame_callback' => array($this, 'callbackColumnPrice')
|
264 |
+
));
|
265 |
+
|
266 |
+
$this->addColumn('qty', array(
|
267 |
+
'header' => Mage::helper('M2ePro')->__('Qty'),
|
268 |
+
'align' => 'right',
|
269 |
+
'width' => '100px',
|
270 |
+
'type' => 'number',
|
271 |
+
'index' => 'qty',
|
272 |
+
'filter_index' => 'qty',
|
273 |
+
'frame_callback' => array($this, 'callbackColumnQty')
|
274 |
+
));
|
275 |
+
|
276 |
+
$this->addColumn('visibility', array(
|
277 |
+
'header' => Mage::helper('M2ePro')->__('Visibility'),
|
278 |
+
'align' => 'left',
|
279 |
+
'width' => '90px',
|
280 |
+
'type' => 'options',
|
281 |
+
'sortable' => false,
|
282 |
+
'index' => 'visibility',
|
283 |
+
'filter_index' => 'visibility',
|
284 |
+
'options' => Mage::getModel('catalog/product_visibility')->getOptionArray()
|
285 |
+
));
|
286 |
+
|
287 |
+
$this->addColumn('status', array(
|
288 |
+
'header' => Mage::helper('M2ePro')->__('Status'),
|
289 |
+
'align' => 'left',
|
290 |
+
'width' => '90px',
|
291 |
+
'type' => 'options',
|
292 |
+
'sortable' => false,
|
293 |
+
'index' => 'status',
|
294 |
+
'filter_index' => 'status',
|
295 |
+
'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
|
296 |
+
'frame_callback' => array($this, 'callbackColumnStatus')
|
297 |
+
));
|
298 |
+
|
299 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
300 |
+
|
301 |
+
$this->addColumn('websites', array(
|
302 |
+
'header' => Mage::helper('M2ePro')->__('Websites'),
|
303 |
+
'align' => 'left',
|
304 |
+
'width' => '90px',
|
305 |
+
'type' => 'options',
|
306 |
+
'sortable' => false,
|
307 |
+
'index' => 'websites',
|
308 |
+
'filter_index' => 'websites',
|
309 |
+
'options' => Mage::getModel('core/website')->getCollection()->toOptionHash()
|
310 |
+
));
|
311 |
+
}
|
312 |
+
|
313 |
+
return parent::_prepareColumns();
|
314 |
+
}
|
315 |
+
|
316 |
+
protected function _prepareMassaction()
|
317 |
+
{
|
318 |
+
// Set massaction identifiers
|
319 |
+
//--------------------------------
|
320 |
+
$this->setMassactionIdField('entity_id');
|
321 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
322 |
+
//--------------------------------
|
323 |
+
|
324 |
+
// Set fake action
|
325 |
+
//--------------------------------
|
326 |
+
$this->getMassactionBlock()->addItem('attributes', array(
|
327 |
+
'label' => ' ',
|
328 |
+
'url' => $this->getUrl('*/adminhtml_common_buy_listing/massStatus', array('_current'=>true)),
|
329 |
+
));
|
330 |
+
//--------------------------------
|
331 |
+
|
332 |
+
return parent::_prepareMassaction();
|
333 |
+
}
|
334 |
+
|
335 |
+
public function getMassactionBlockHtml()
|
336 |
+
{
|
337 |
+
$advancedFilterBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_listing_product_rule');
|
338 |
+
$advancedFilterBlock->setShowHideProductsOption();
|
339 |
+
$advancedFilterBlock->setGridJsObjectName($this->getJsObjectName());
|
340 |
+
|
341 |
+
return $advancedFilterBlock->toHtml() . parent::getMassactionBlockHtml();
|
342 |
+
}
|
343 |
+
|
344 |
+
// ####################################
|
345 |
+
|
346 |
+
public function callbackColumnProductId($value, $row, $column, $isExport)
|
347 |
+
{
|
348 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
349 |
+
|
350 |
+
$productId = (int)$value;
|
351 |
+
$storeId = (int)$listingData['store_id'];
|
352 |
+
|
353 |
+
$withoutImageHtml = '<a href="'
|
354 |
+
.$this->getUrl('adminhtml/catalog_product/edit',
|
355 |
+
array('id' => $productId))
|
356 |
+
.'" target="_blank">'
|
357 |
+
.$productId
|
358 |
+
.'</a>';
|
359 |
+
|
360 |
+
$showProductsThumbnails = (bool)(int)Mage::helper('M2ePro/Module')
|
361 |
+
->getConfig()
|
362 |
+
->getGroupValue('/view/','show_products_thumbnails');
|
363 |
+
if (!$showProductsThumbnails) {
|
364 |
+
return $withoutImageHtml;
|
365 |
+
}
|
366 |
+
|
367 |
+
/** @var $magentoProduct Ess_M2ePro_Model_Magento_Product */
|
368 |
+
$magentoProduct = Mage::getModel('M2ePro/Magento_Product');
|
369 |
+
$magentoProduct->setProductId($productId);
|
370 |
+
$magentoProduct->setStoreId($storeId);
|
371 |
+
|
372 |
+
$imageUrlResized = $magentoProduct->getThumbnailImageLink();
|
373 |
+
if (is_null($imageUrlResized)) {
|
374 |
+
return $withoutImageHtml;
|
375 |
+
}
|
376 |
+
|
377 |
+
$imageHtml = $productId.'<hr/><img src="'.$imageUrlResized.'" />';
|
378 |
+
$withImageHtml = str_replace('>'.$productId.'<','>'.$imageHtml.'<',$withoutImageHtml);
|
379 |
+
|
380 |
+
return $withImageHtml;
|
381 |
+
}
|
382 |
+
|
383 |
+
public function callbackColumnProductTitle($value, $row, $column, $isExport)
|
384 |
+
{
|
385 |
+
if (strlen($value) > 60) {
|
386 |
+
return substr($value, 0, 60) . '...';
|
387 |
+
}
|
388 |
+
return Mage::helper('M2ePro')->escapeHtml($value);
|
389 |
+
}
|
390 |
+
|
391 |
+
public function callbackColumnIsInStock($value, $row, $column, $isExport)
|
392 |
+
{
|
393 |
+
if ((int)$row->getData('is_in_stock') <= 0) {
|
394 |
+
return '<span style="color: red;">'.$value.'</span>';
|
395 |
+
}
|
396 |
+
|
397 |
+
return $value;
|
398 |
+
}
|
399 |
+
|
400 |
+
public function callbackColumnPrice($value, $row, $column, $isExport)
|
401 |
+
{
|
402 |
+
$rowVal = $row->getData();
|
403 |
+
|
404 |
+
if (!isset($rowVal['price']) || (float)$rowVal['price'] <= 0) {
|
405 |
+
$value = 0;
|
406 |
+
$value = '<span style="color: red;">'.$value.'</span>';
|
407 |
+
}
|
408 |
+
return $value;
|
409 |
+
}
|
410 |
+
|
411 |
+
public function callbackColumnQty($value, $row, $column, $isExport)
|
412 |
+
{
|
413 |
+
if ($value <= 0) {
|
414 |
+
$value = 0;
|
415 |
+
$value = '<span style="color: red;">'.$value.'</span>';
|
416 |
+
}
|
417 |
+
|
418 |
+
return $value;
|
419 |
+
}
|
420 |
+
|
421 |
+
public function callbackColumnStatus($value, $row, $column, $isExport)
|
422 |
+
{
|
423 |
+
if ($row->getData('status') == Mage_Catalog_Model_Product_Status::STATUS_DISABLED) {
|
424 |
+
$value = '<span style="color: red;">'.$value.'</span>';
|
425 |
+
}
|
426 |
+
|
427 |
+
return $value;
|
428 |
+
}
|
429 |
+
|
430 |
+
// ####################################
|
431 |
+
|
432 |
+
protected function _addColumnFilterToCollection($column)
|
433 |
+
{
|
434 |
+
if ($this->getCollection()) {
|
435 |
+
if ($column->getId() == 'websites') {
|
436 |
+
$this->getCollection()->joinField('websites',
|
437 |
+
'catalog/product_website',
|
438 |
+
'website_id',
|
439 |
+
'product_id=entity_id',
|
440 |
+
null,
|
441 |
+
'left');
|
442 |
+
}
|
443 |
+
}
|
444 |
+
return parent::_addColumnFilterToCollection($column);
|
445 |
+
}
|
446 |
+
|
447 |
+
protected function _getStore()
|
448 |
+
{
|
449 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
450 |
+
|
451 |
+
// Get store filter
|
452 |
+
//----------------------------
|
453 |
+
$storeId = 0;
|
454 |
+
if (isset($listingData['store_id'])) {
|
455 |
+
$storeId = (int)$listingData['store_id'];
|
456 |
+
}
|
457 |
+
//----------------------------
|
458 |
+
|
459 |
+
return Mage::app()->getStore((int)$storeId);
|
460 |
+
}
|
461 |
+
|
462 |
+
public function getGridUrl()
|
463 |
+
{
|
464 |
+
return $this->getUrl('*/adminhtml_common_buy_listing/productGrid', array('_current'=>true));
|
465 |
+
}
|
466 |
+
|
467 |
+
public function getRowUrl($row)
|
468 |
+
{
|
469 |
+
return false;
|
470 |
+
}
|
471 |
+
|
472 |
+
// ####################################
|
473 |
+
|
474 |
+
protected function _toHtml()
|
475 |
+
{
|
476 |
+
$cssBefore = <<<STYLE
|
477 |
+
<style type="text/css">
|
478 |
+
table.massaction div.right {
|
479 |
+
display: none;
|
480 |
+
}
|
481 |
+
</style>
|
482 |
+
STYLE;
|
483 |
+
|
484 |
+
$helper = Mage::helper('M2ePro');
|
485 |
+
|
486 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
487 |
+
$suffixGridId = isset($listingData['id']) ? $listingData['id'] : '';
|
488 |
+
|
489 |
+
$isShowRuleBlock = json_encode($this->isShowRuleBlock());
|
490 |
+
|
491 |
+
$selectItemsMessage = $helper->escapeJs(
|
492 |
+
$helper->__('Please select the products you want to perform the action on.')
|
493 |
+
);
|
494 |
+
$createEmptyListingMessage = $helper->escapeJs($helper->__('Are you sure you want to create empty listing?'));
|
495 |
+
|
496 |
+
$showAdvancedFilterButtonText = $helper->escapeJs($helper->__('Show Advanced Filter'));
|
497 |
+
$hideAdvancedFilterButtonText = $helper->escapeJs($helper->__('Hide Advanced Filter'));
|
498 |
+
|
499 |
+
$createListingUrl = $this->getUrl(
|
500 |
+
'*/adminhtml_common_buy_listing/createListing'
|
501 |
+
);
|
502 |
+
$getProductsUrl = $this->getUrl(
|
503 |
+
'*/adminhtml_common_buy_listing/getProductsFromCategories'
|
504 |
+
);
|
505 |
+
$addProductsUrl = $this->getUrl(
|
506 |
+
'*/adminhtml_common_buy_listing/addProducts'
|
507 |
+
);
|
508 |
+
$backUrl = $this->getUrl('*/*/index');
|
509 |
+
|
510 |
+
$javascript = <<<JAVASCRIPT
|
511 |
+
<script type="text/javascript">
|
512 |
+
if (typeof M2ePro == 'undefined') {
|
513 |
+
M2ePro = {};
|
514 |
+
M2ePro.url = {};
|
515 |
+
M2ePro.formData = {};
|
516 |
+
M2ePro.customData = {};
|
517 |
+
M2ePro.text = {};
|
518 |
+
}
|
519 |
+
|
520 |
+
M2ePro.text.select_items_message = '{$selectItemsMessage}';
|
521 |
+
M2ePro.text.create_empty_listing_message = '{$createEmptyListingMessage}';
|
522 |
+
M2ePro.text.show_advanced_filter = '{$showAdvancedFilterButtonText}';
|
523 |
+
M2ePro.text.hide_advanced_filter = '{$hideAdvancedFilterButtonText}';
|
524 |
+
M2ePro.url.create_listing = '{$createListingUrl}';
|
525 |
+
M2ePro.url.get_products_from_categories = '{$getProductsUrl}';
|
526 |
+
M2ePro.url.add_products = '{$addProductsUrl}';
|
527 |
+
M2ePro.url.back = '{$backUrl}';
|
528 |
+
|
529 |
+
WrapperObj = new AreaWrapper('add_products_container');
|
530 |
+
ProgressBarObj = new ProgressBar('add_products_progress_bar');
|
531 |
+
AddListingObj = new AddListingHandler(M2ePro, ProgressBarObj, WrapperObj);
|
532 |
+
ProductGridHandlerObj = new ProductGridHandler(AddListingObj);
|
533 |
+
ProductGridHandlerObj.setGridId('buyListingProductGrid{$suffixGridId}');
|
534 |
+
|
535 |
+
var init = function () {
|
536 |
+
buyListingProductGrid{$suffixGridId}JsObject.doFilter = ProductGridHandlerObj.setFilter;
|
537 |
+
buyListingProductGrid{$suffixGridId}JsObject.resetFilter = ProductGridHandlerObj.resetFilter;
|
538 |
+
if ({$isShowRuleBlock}) {
|
539 |
+
$('listing_product_rules').show();
|
540 |
+
if ($('advanced_filter_button')) {
|
541 |
+
$('advanced_filter_button').simulate('click');
|
542 |
+
}
|
543 |
+
}
|
544 |
+
}
|
545 |
+
|
546 |
+
{$this->isAjax} ? init()
|
547 |
+
: Event.observe(window, 'load', init);
|
548 |
+
</script>
|
549 |
+
JAVASCRIPT;
|
550 |
+
|
551 |
+
return $cssBefore.parent::_toHtml().$javascript;
|
552 |
+
}
|
553 |
+
|
554 |
+
// ####################################
|
555 |
+
|
556 |
+
public function getAdvancedFilterButtonHtml()
|
557 |
+
{
|
558 |
+
if (!$this->getChild('advanced_filter_button')) {
|
559 |
+
//------------------------------
|
560 |
+
$data = array(
|
561 |
+
'label' => Mage::helper('adminhtml')->__('Show Advanced Filter'),
|
562 |
+
'onclick' => 'ProductGridHandlerObj.advancedFilterToggle()',
|
563 |
+
'class' => 'task',
|
564 |
+
'id' => 'advanced_filter_button'
|
565 |
+
);
|
566 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
567 |
+
$this->setChild('advanced_filter_button', $buttonBlock);
|
568 |
+
//------------------------------
|
569 |
+
}
|
570 |
+
|
571 |
+
return $this->getChildHtml('advanced_filter_button');
|
572 |
+
}
|
573 |
+
|
574 |
+
public function getMainButtonsHtml()
|
575 |
+
{
|
576 |
+
$html = '';
|
577 |
+
if($this->getFilterVisibility()){
|
578 |
+
$html.= $this->getResetFilterButtonHtml();
|
579 |
+
if (!$this->isShowRuleBlock()) {
|
580 |
+
$html.= $this->getAdvancedFilterButtonHtml();
|
581 |
+
}
|
582 |
+
$html.= $this->getSearchButtonHtml();
|
583 |
+
}
|
584 |
+
return $html;
|
585 |
+
}
|
586 |
+
|
587 |
+
// ####################################
|
588 |
+
|
589 |
+
private function isShowRuleBlock()
|
590 |
+
{
|
591 |
+
$ruleData = Mage::helper('M2ePro/Data_Session')->getValue(
|
592 |
+
Mage::helper('M2ePro/Data_Global')->getValue('rule_prefix')
|
593 |
+
);
|
594 |
+
|
595 |
+
$showHideProductsOption = Mage::helper('M2ePro/Data_Session')->getValue(
|
596 |
+
Mage::helper('M2ePro/Data_Global')->getValue('hide_products_others_listings_prefix')
|
597 |
+
);
|
598 |
+
|
599 |
+
return !empty($ruleData) || is_null($showHideProductsOption) || $showHideProductsOption;
|
600 |
+
}
|
601 |
+
|
602 |
+
// ####################################
|
603 |
+
}
|
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 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
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
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 Result'),
|
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,60 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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_reset_button',
|
31 |
+
'label' => Mage::helper('M2ePro')->__('Reset'),
|
32 |
+
'class' => 'productSearch_reset_button submit'
|
33 |
+
);
|
34 |
+
$buttonSubmitBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
35 |
+
$this->setChild('productSearch_reset_button', $buttonSubmitBlock);
|
36 |
+
//------------------------------
|
37 |
+
|
38 |
+
//------------------------------
|
39 |
+
$data = array(
|
40 |
+
'id' => 'productSearch_back_button',
|
41 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
42 |
+
'class' => 'productSearch_back_button'
|
43 |
+
);
|
44 |
+
$buttonBackBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
45 |
+
$this->setChild('productSearch_back_button', $buttonBackBlock);
|
46 |
+
//------------------------------
|
47 |
+
|
48 |
+
//------------------------------
|
49 |
+
$data = array(
|
50 |
+
'id' => 'productSearch_cancel_button',
|
51 |
+
'label' => Mage::helper('M2ePro')->__('Close'),
|
52 |
+
'class' => 'productSearch_cancel_button'
|
53 |
+
);
|
54 |
+
$buttonCancelBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
55 |
+
$this->setChild('productSearch_cancel_button', $buttonCancelBlock);
|
56 |
+
//------------------------------
|
57 |
+
|
58 |
+
parent::_beforeToHtml();
|
59 |
+
}
|
60 |
+
}
|
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,168 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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')->__(Ess_M2ePro_Helper_Component_Buy::TITLE);
|
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')->__('Templates'),
|
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 |
+
'filter' => base64_encode('component_mode=' . Ess_M2ePro_Helper_Component_Buy::NICK)
|
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 |
+
$this->_addButton('reset', array(
|
96 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
97 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
98 |
+
'class' => 'reset'
|
99 |
+
));
|
100 |
+
//------------------------------
|
101 |
+
}
|
102 |
+
|
103 |
+
// ########################################
|
104 |
+
|
105 |
+
protected function _toHtml()
|
106 |
+
{
|
107 |
+
return $this->getTemplatesButtonJavascript() . parent::_toHtml();
|
108 |
+
}
|
109 |
+
|
110 |
+
public function getGridHtml()
|
111 |
+
{
|
112 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_listing_search_help');
|
113 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
114 |
+
}
|
115 |
+
|
116 |
+
// ########################################
|
117 |
+
|
118 |
+
protected function getTemplatesButtonJavascript()
|
119 |
+
{
|
120 |
+
$data = array(
|
121 |
+
'target_css_class' => 'templates-drop-down',
|
122 |
+
'items' => $this->getTemplatesButtonDropDownItems()
|
123 |
+
);
|
124 |
+
$dropDownBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_button_dropDown');
|
125 |
+
$dropDownBlock->setData($data);
|
126 |
+
|
127 |
+
return $dropDownBlock->toHtml();
|
128 |
+
}
|
129 |
+
|
130 |
+
protected function getTemplatesButtonDropDownItems()
|
131 |
+
{
|
132 |
+
$items = array();
|
133 |
+
|
134 |
+
$filter = base64_encode('component_mode=' . Ess_M2ePro_Helper_Component_Buy::NICK);
|
135 |
+
|
136 |
+
//------------------------------
|
137 |
+
$url = $this->getUrl(
|
138 |
+
'*/adminhtml_common_template_sellingFormat/index',
|
139 |
+
array(
|
140 |
+
'filter' => $filter
|
141 |
+
)
|
142 |
+
);
|
143 |
+
$items[] = array(
|
144 |
+
'url' => $url,
|
145 |
+
'label' => Mage::helper('M2ePro')->__('Selling Format Templates'),
|
146 |
+
'target' => '_blank'
|
147 |
+
);
|
148 |
+
//------------------------------
|
149 |
+
|
150 |
+
//------------------------------
|
151 |
+
$url = $this->getUrl(
|
152 |
+
'*/adminhtml_common_template_synchronization/index',
|
153 |
+
array(
|
154 |
+
'filter' => $filter
|
155 |
+
)
|
156 |
+
);
|
157 |
+
$items[] = array(
|
158 |
+
'url' => $url,
|
159 |
+
'label' => Mage::helper('M2ePro')->__('Synchronization Templates'),
|
160 |
+
'target' => '_blank'
|
161 |
+
);
|
162 |
+
//------------------------------
|
163 |
+
|
164 |
+
return $items;
|
165 |
+
}
|
166 |
+
|
167 |
+
// ########################################
|
168 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Search/Grid.php
ADDED
@@ -0,0 +1,446 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
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
{
|
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 / 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')->__('Rakuten.com 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')->__('Rakuten.com 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 |
+
if (strlen($value) > 60) {
|
228 |
+
$value = substr($value, 0, 60) . '...';
|
229 |
+
}
|
230 |
+
|
231 |
+
$value = '<span>'.Mage::helper('M2ePro')->escapeHtml($value).'</span>';
|
232 |
+
|
233 |
+
$urlParams = array();
|
234 |
+
$urlParams['id'] = $row->getData('listing_id');
|
235 |
+
$urlParams['back'] = Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_buy_listing/search');
|
236 |
+
|
237 |
+
$listingUrl = $this->getUrl('*/adminhtml_common_buy_listing/view',$urlParams);
|
238 |
+
$listingTitle = Mage::helper('M2ePro')->escapeHtml($row->getData('listing_title'));
|
239 |
+
|
240 |
+
if (strlen($listingTitle) > 50) {
|
241 |
+
$listingTitle = substr($listingTitle, 0, 50) . '...';
|
242 |
+
}
|
243 |
+
|
244 |
+
$value .= '<br/><hr style="border:none; border-top:1px solid silver; margin: 2px 0px;"/>';
|
245 |
+
$value .= '<strong>'
|
246 |
+
.Mage::helper('M2ePro')->__('Listing')
|
247 |
+
.': </strong> <a href="'
|
248 |
+
.$listingUrl
|
249 |
+
.'">'
|
250 |
+
.$listingTitle
|
251 |
+
.'</a>';
|
252 |
+
|
253 |
+
$tempSku = $row->getData('magento_sku');
|
254 |
+
is_null($tempSku)
|
255 |
+
&& $tempSku = Mage::getModel('M2ePro/Magento_Product')->setProductId($row->getData('product_id'))->getSku();
|
256 |
+
|
257 |
+
$value .= '<br/><strong>'
|
258 |
+
.Mage::helper('M2ePro')->__('SKU')
|
259 |
+
.':</strong> '
|
260 |
+
.Mage::helper('M2ePro')->escapeHtml($tempSku);
|
261 |
+
|
262 |
+
return $value;
|
263 |
+
}
|
264 |
+
|
265 |
+
public function callbackColumnStockAvailability($value, $row, $column, $isExport)
|
266 |
+
{
|
267 |
+
if ((int)$row->getData('is_in_stock') <= 0) {
|
268 |
+
return '<span style="color: red;">'.$value.'</span>';
|
269 |
+
}
|
270 |
+
|
271 |
+
return $value;
|
272 |
+
}
|
273 |
+
|
274 |
+
public function callbackColumnSku($value, $row, $column, $isExport)
|
275 |
+
{
|
276 |
+
if (is_null($value) || $value === '') {
|
277 |
+
return Mage::helper('M2ePro')->__('N/A');
|
278 |
+
}
|
279 |
+
return $value;
|
280 |
+
}
|
281 |
+
|
282 |
+
public function callbackColumnGeneralId($value, $row, $column, $isExport)
|
283 |
+
{
|
284 |
+
if ((int)$row->getData('status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
285 |
+
if (is_null($value) || $value === '') {
|
286 |
+
return Mage::helper('M2ePro')->__('N/A');
|
287 |
+
}
|
288 |
+
} else {
|
289 |
+
if (is_null($value) || $value === '') {
|
290 |
+
return '<i style="color:gray;">receiving...</i>';
|
291 |
+
}
|
292 |
+
}
|
293 |
+
|
294 |
+
$url = Mage::helper('M2ePro/Component_Buy')->getItemUrl($value);
|
295 |
+
return '<a href="'.$url.'" target="_blank">'.$value.'</a>';
|
296 |
+
}
|
297 |
+
|
298 |
+
public function callbackColumnAvailableQty($value, $row, $column, $isExport)
|
299 |
+
{
|
300 |
+
if ((int)$row->getData('status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
301 |
+
if (is_null($value) || $value === '') {
|
302 |
+
return Mage::helper('M2ePro')->__('N/A');
|
303 |
+
}
|
304 |
+
} else {
|
305 |
+
if (is_null($value) || $value === '') {
|
306 |
+
return '<i style="color:gray;">'.Mage::helper('M2ePro')->__('receiving...').'</i>';
|
307 |
+
}
|
308 |
+
}
|
309 |
+
|
310 |
+
if ($value <= 0) {
|
311 |
+
return '<span style="color: red;">0</span>';
|
312 |
+
}
|
313 |
+
|
314 |
+
return Mage::app()->getLocale()->currency('USD')->toCurrency($value);
|
315 |
+
}
|
316 |
+
|
317 |
+
public function callbackColumnPrice($value, $row, $column, $isExport)
|
318 |
+
{
|
319 |
+
if ((int)$row->getData('status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
320 |
+
if (is_null($value) || $value === '') {
|
321 |
+
return Mage::helper('M2ePro')->__('N/A');
|
322 |
+
}
|
323 |
+
} else {
|
324 |
+
if (is_null($value) || $value === '') {
|
325 |
+
return '<i style="color:gray;">'.Mage::helper('M2ePro')->__('receiving...').'</i>';
|
326 |
+
}
|
327 |
+
}
|
328 |
+
|
329 |
+
if ((float)$value <= 0) {
|
330 |
+
return '<span style="color: #f00;">0</span>';
|
331 |
+
}
|
332 |
+
|
333 |
+
return $value;
|
334 |
+
}
|
335 |
+
|
336 |
+
public function callbackColumnStatus($value, $row, $column, $isExport)
|
337 |
+
{
|
338 |
+
switch ($row->getData('status')) {
|
339 |
+
|
340 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED:
|
341 |
+
$value = '<span style="color: gray;">' . $value . '</span>';
|
342 |
+
break;
|
343 |
+
|
344 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_LISTED:
|
345 |
+
$value = '<span style="color: green;">' . $value . '</span>';
|
346 |
+
break;
|
347 |
+
|
348 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED:
|
349 |
+
$value = '<span style="color: red;">'.$value.'</span>';
|
350 |
+
break;
|
351 |
+
|
352 |
+
default:
|
353 |
+
break;
|
354 |
+
}
|
355 |
+
|
356 |
+
$tempLocks = $row->getObjectLocks();
|
357 |
+
|
358 |
+
foreach ($tempLocks as $lock) {
|
359 |
+
|
360 |
+
switch ($lock->getTag()) {
|
361 |
+
|
362 |
+
case 'new_sku_action':
|
363 |
+
$title = Mage::helper('M2ePro')->__('Add New SKU In Progress...');
|
364 |
+
$value .= '<br><span style="color: #605fff">['.$title.']</span>';
|
365 |
+
break;
|
366 |
+
|
367 |
+
case 'list_action':
|
368 |
+
$title = Mage::helper('M2ePro')->__('List In Progress...');
|
369 |
+
$value .= '<br><span style="color: #605fff">['.$title.']</span>';
|
370 |
+
break;
|
371 |
+
|
372 |
+
case 'relist_action':
|
373 |
+
$title = Mage::helper('M2ePro')->__('Relist In Progress...');
|
374 |
+
$value .= '<br><span style="color: #605fff">['.$title.']</span>';
|
375 |
+
break;
|
376 |
+
|
377 |
+
case 'revise_action':
|
378 |
+
$title = Mage::helper('M2ePro')->__('Revise In Progress...');
|
379 |
+
$value .= '<br><span style="color: #605fff">['.$title.']</span>';
|
380 |
+
break;
|
381 |
+
|
382 |
+
case 'stop_action':
|
383 |
+
$title = Mage::helper('M2ePro')->__('Stop In Progress...');
|
384 |
+
$value .= '<br><span style="color: #605fff">['.$title.']</span>';
|
385 |
+
break;
|
386 |
+
|
387 |
+
case 'stop_and_remove_action':
|
388 |
+
$title = Mage::helper('M2ePro')->__('Stop And Remove In Progress...');
|
389 |
+
$value .= '<br><span style="color: #605fff">['.$title.']</span>';
|
390 |
+
break;
|
391 |
+
|
392 |
+
default:
|
393 |
+
break;
|
394 |
+
|
395 |
+
}
|
396 |
+
}
|
397 |
+
|
398 |
+
return $value;
|
399 |
+
}
|
400 |
+
|
401 |
+
public function callbackColumnActions($value, $row, $column, $isExport)
|
402 |
+
{
|
403 |
+
$altTitle = Mage::helper('M2ePro')->escapeHtml(Mage::helper('M2ePro')->__('Go to listing'));
|
404 |
+
$iconSrc = $this->getSkinUrl('M2ePro').'/images/goto_listing.png';
|
405 |
+
$url = $this->getUrl('*/adminhtml_common_buy_listing/view/', array(
|
406 |
+
'id'=>$row->getData('listing_id'),
|
407 |
+
'filter'=>base64_encode(
|
408 |
+
'product_id[from]='.(int)$row->getData('product_id')
|
409 |
+
.'&product_id[to]='.(int)$row->getData('product_id')
|
410 |
+
)
|
411 |
+
));
|
412 |
+
|
413 |
+
$html = <<<HTML
|
414 |
+
<div style="float:right; margin:5px 15px 0 0;">
|
415 |
+
<a title="{$altTitle}" target="_blank" href="{$url}"><img src="{$iconSrc}" /></a>
|
416 |
+
</div>
|
417 |
+
HTML;
|
418 |
+
|
419 |
+
return $html;
|
420 |
+
}
|
421 |
+
|
422 |
+
protected function callbackFilterTitle($collection, $column)
|
423 |
+
{
|
424 |
+
$value = $column->getFilter()->getValue();
|
425 |
+
|
426 |
+
if ($value == null) {
|
427 |
+
return;
|
428 |
+
}
|
429 |
+
|
430 |
+
$collection->getSelect()->where('cpev.value LIKE ? OR cpe.sku LIKE ? OR l.title LIKE ?', '%'.$value.'%');
|
431 |
+
}
|
432 |
+
|
433 |
+
// ####################################
|
434 |
+
|
435 |
+
public function getGridUrl()
|
436 |
+
{
|
437 |
+
return $this->getUrl('*/adminhtml_common_buy_listing/searchGrid', array('_current'=>true));
|
438 |
+
}
|
439 |
+
|
440 |
+
public function getRowUrl($row)
|
441 |
+
{
|
442 |
+
return false;
|
443 |
+
}
|
444 |
+
|
445 |
+
// ####################################
|
446 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/Tutorial.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_Buy_Listing_Tutorial extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('buyListingTutorial');
|
16 |
+
$this->setContainerId('buy_listing_tutorial');
|
17 |
+
$this->setTemplate('M2ePro/common/buy/listing/tutorial.phtml');
|
18 |
+
//------------------------------
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _beforeToHtml()
|
22 |
+
{
|
23 |
+
//-------------------------------
|
24 |
+
$url = $this->getUrl(
|
25 |
+
'*/adminhtml_common_listing/confirmTutorial',
|
26 |
+
array(
|
27 |
+
'component' => Ess_M2ePro_Helper_Component_Buy::NICK
|
28 |
+
)
|
29 |
+
);
|
30 |
+
$data = array(
|
31 |
+
'label' => Mage::helper('M2ePro')->__('Continue'),
|
32 |
+
'onclick' => 'setLocation(\'' . $url . '\');',
|
33 |
+
'class' => 'confirm_tutorial'
|
34 |
+
);
|
35 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
36 |
+
$this->setChild('confirm_tutorial',$buttonBlock);
|
37 |
+
//-------------------------------
|
38 |
+
|
39 |
+
return parent::_beforeToHtml();
|
40 |
+
}
|
41 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/View.php
ADDED
@@ -0,0 +1,560 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|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|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 "%listing_title%"',
|
27 |
+
Mage::helper('M2ePro')->__(Ess_M2ePro_Helper_Component_Buy::TITLE),
|
28 |
+
$this->escapeHtml($listingData['title'])
|
29 |
+
);
|
30 |
+
} else {
|
31 |
+
$headerText = Mage::helper('M2ePro')->__(
|
32 |
+
'View Listing "%listing_title%"', $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 |
+
if (!is_null($this->getRequest()->getParam('back'))) {
|
50 |
+
//------------------------------
|
51 |
+
$url = Mage::helper('M2ePro')->getBackUrl('*/adminhtml_common_listing/index');
|
52 |
+
$this->_addButton('back', array(
|
53 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
54 |
+
'onclick' => 'CommonHandlerObj.back_click(\'' . $url . '\')',
|
55 |
+
'class' => 'back'
|
56 |
+
));
|
57 |
+
//------------------------------
|
58 |
+
}
|
59 |
+
|
60 |
+
//------------------------------
|
61 |
+
$url = $this->getUrl(
|
62 |
+
'*/adminhtml_common_listing/index',
|
63 |
+
array(
|
64 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_BUY
|
65 |
+
)
|
66 |
+
);
|
67 |
+
$this->_addButton('goto_listings', array(
|
68 |
+
'label' => Mage::helper('M2ePro')->__('Listings'),
|
69 |
+
'onclick' => 'setLocation(\'' . $url . '\')',
|
70 |
+
'class' => 'button_link'
|
71 |
+
));
|
72 |
+
//------------------------------
|
73 |
+
|
74 |
+
//------------------------------
|
75 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
76 |
+
'*/adminhtml_common_buy_listing/view',
|
77 |
+
array(
|
78 |
+
'id' => $listingData['id']
|
79 |
+
)
|
80 |
+
);
|
81 |
+
//------------------------------
|
82 |
+
|
83 |
+
//------------------------------
|
84 |
+
$url = $this->getUrl('*/adminhtml_common_log/listing', array('id' => $listingData['id']));
|
85 |
+
$this->_addButton('view_log', array(
|
86 |
+
'label' => Mage::helper('M2ePro')->__('View Log'),
|
87 |
+
'onclick' => 'window.open(\'' . $url . '\')',
|
88 |
+
'class' => 'button_link'
|
89 |
+
));
|
90 |
+
//------------------------------
|
91 |
+
|
92 |
+
//------------------------------
|
93 |
+
$this->_addButton('reset', array(
|
94 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
95 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
96 |
+
'class' => 'reset'
|
97 |
+
));
|
98 |
+
//------------------------------
|
99 |
+
|
100 |
+
//------------------------------
|
101 |
+
$newListing = $this->getRequest()->getParam('new');
|
102 |
+
$areYouSure = Mage::helper('M2ePro')->__('Are you sure?');
|
103 |
+
//------------------------------
|
104 |
+
|
105 |
+
//------------------------------
|
106 |
+
if (is_null($newListing)) {
|
107 |
+
$url = $this->getUrl('*/adminhtml_listing/clearLog', array('id' => $listingData['id'], 'back' => $backUrl));
|
108 |
+
$this->_addButton('clear_log', array(
|
109 |
+
'label' => Mage::helper('M2ePro')->__('Clear Log'),
|
110 |
+
'onclick' => 'deleteConfirm(\'' . $areYouSure . '\', \'' . $url . '\')',
|
111 |
+
'class' => 'clear_log'
|
112 |
+
));
|
113 |
+
}
|
114 |
+
//------------------------------
|
115 |
+
|
116 |
+
//------------------------------
|
117 |
+
$url = $this->getUrl('*/adminhtml_common_buy_listing/delete', array('id' => $listingData['id']));
|
118 |
+
$this->_addButton('delete', array(
|
119 |
+
'label' => Mage::helper('M2ePro')->__('Delete'),
|
120 |
+
'onclick' => 'deleteConfirm(\'' . $areYouSure . '\', \'' . $url . '\')',
|
121 |
+
'class' => 'delete'
|
122 |
+
));
|
123 |
+
//------------------------------
|
124 |
+
|
125 |
+
//------------------------------
|
126 |
+
$this->_addButton('edit_templates', array(
|
127 |
+
'label' => Mage::helper('M2ePro')->__('Edit Templates'),
|
128 |
+
'onclick' => '',
|
129 |
+
'class' => 'drop_down edit_template_drop_down'
|
130 |
+
));
|
131 |
+
//------------------------------
|
132 |
+
|
133 |
+
//------------------------------
|
134 |
+
$url = $this->getUrl(
|
135 |
+
'*/adminhtml_common_buy_listing/edit',
|
136 |
+
array(
|
137 |
+
'id' => $listingData['id'],
|
138 |
+
'back' => $backUrl
|
139 |
+
)
|
140 |
+
);
|
141 |
+
$this->_addButton('edit_settings', array(
|
142 |
+
'label' => Mage::helper('M2ePro')->__('Edit Settings'),
|
143 |
+
'onclick' => 'window.open(\'' . $url . '\',\'_blank\')',
|
144 |
+
'class' => ''
|
145 |
+
));
|
146 |
+
//------------------------------
|
147 |
+
|
148 |
+
//------------------------------
|
149 |
+
$this->_addButton('add_products', array(
|
150 |
+
'label' => Mage::helper('M2ePro')->__('Add Products'),
|
151 |
+
'onclick' => '',
|
152 |
+
'class' => 'add drop_down add_products_drop_down'
|
153 |
+
));
|
154 |
+
//------------------------------
|
155 |
+
}
|
156 |
+
|
157 |
+
protected function _toHtml()
|
158 |
+
{
|
159 |
+
return '<div id="listing_view_progress_bar"></div>' .
|
160 |
+
'<div id="listing_container_errors_summary" class="errors_summary" style="display: none;"></div>' .
|
161 |
+
'<div id="listing_view_content_container">'.
|
162 |
+
parent::_toHtml() .
|
163 |
+
'</div>';
|
164 |
+
}
|
165 |
+
|
166 |
+
public function getGridHtml()
|
167 |
+
{
|
168 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
169 |
+
|
170 |
+
/** @var $helper Ess_M2ePro_Helper_Data */
|
171 |
+
$helper = Mage::helper('M2ePro');
|
172 |
+
|
173 |
+
//------------------------------
|
174 |
+
$urls = array();
|
175 |
+
|
176 |
+
$path = 'adminhtml_common_log/listing';
|
177 |
+
$urls[$path] = $this->getUrl('*/' . $path, array(
|
178 |
+
'id' => $listingData['id'],
|
179 |
+
'back'=>$helper->makeBackUrlParam('*/adminhtml_common_buy_listing/view', array('id' =>$listingData['id']))
|
180 |
+
));
|
181 |
+
|
182 |
+
$path = 'adminhtml_common_listing/duplicateProducts';
|
183 |
+
$urls[$path] = $this->getUrl('*/' . $path);
|
184 |
+
|
185 |
+
$urls = json_encode($urls);
|
186 |
+
//------------------------------
|
187 |
+
|
188 |
+
$component = Ess_M2ePro_Helper_Component_Buy::NICK;
|
189 |
+
$layout = $this->getLayout();
|
190 |
+
|
191 |
+
$temp = Mage::helper('M2ePro/Data_Session')->getValue('products_ids_for_list', true);
|
192 |
+
$productsIdsForList = empty($temp) ? '' : $temp;
|
193 |
+
|
194 |
+
$gridId = 'buyListingViewGrid' . $listingData['id'];
|
195 |
+
$ignoreListings = json_encode(array($listingData['id']));
|
196 |
+
|
197 |
+
$logViewUrl = $this->getUrl('*/adminhtml_common_log/listing', array(
|
198 |
+
'id' =>$listingData['id'],
|
199 |
+
'back'=>$helper->makeBackUrlParam('*/adminhtml_common_buy_listing/view', array('id' =>$listingData['id']))
|
200 |
+
));
|
201 |
+
$getErrorsSummary = $this->getUrl('*/adminhtml_listing/getErrorsSummary');
|
202 |
+
|
203 |
+
$runListProducts = $this->getUrl('*/adminhtml_common_buy_listing/runListProducts');
|
204 |
+
$runReviseProducts = $this->getUrl('*/adminhtml_common_buy_listing/runReviseProducts');
|
205 |
+
$runRelistProducts = $this->getUrl('*/adminhtml_common_buy_listing/runRelistProducts');
|
206 |
+
$runStopProducts = $this->getUrl('*/adminhtml_common_buy_listing/runStopProducts');
|
207 |
+
$runStopAndRemoveProducts = $this->getUrl('*/adminhtml_common_buy_listing/runStopAndRemoveProducts');
|
208 |
+
|
209 |
+
$prepareData = $this->getUrl('*/adminhtml_listing_moving/prepareMoveToListing');
|
210 |
+
$getMoveToListingGridHtml = $this->getUrl('*/adminhtml_listing_moving/moveToListingGrid');
|
211 |
+
$getFailedProductsGridHtml = $this->getUrl('*/adminhtml_listing_moving/getFailedProductsGrid');
|
212 |
+
$tryToMoveToListing = $this->getUrl('*/adminhtml_listing_moving/tryToMoveToListing');
|
213 |
+
$moveToListing = $this->getUrl('*/adminhtml_listing_moving/moveToListing');
|
214 |
+
|
215 |
+
$getVariationEditPopupUrl = $this->getUrl('*/adminhtml_common_listing/getVariationEditPopup');
|
216 |
+
$getVariationManagePopupUrl = $this->getUrl('*/adminhtml_common_listing/getVariationManagePopup');
|
217 |
+
|
218 |
+
$variationEditActionUrl = $this->getUrl('*/adminhtml_common_listing/variationEdit');
|
219 |
+
$variationManageActionUrl = $this->getUrl('*/adminhtml_common_listing/variationManage');
|
220 |
+
$variationManageGenerateActionUrl = $this->getUrl('*/adminhtml_common_listing/variationManageGenerate');
|
221 |
+
|
222 |
+
$popupTitle = $helper->escapeJs($helper->__('Moving Rakuten.com Items.'));
|
223 |
+
$failedProductsPopupTitle = $helper->escapeJs($helper->__('Products failed to move'));
|
224 |
+
|
225 |
+
$taskCompletedMessage = $helper->escapeJs($helper->__('Task completed. Please wait ...'));
|
226 |
+
$taskCompletedSuccessMessage = $helper->escapeJs(
|
227 |
+
$helper->__('"%task_title%" task has successfully submitted to be processed.')
|
228 |
+
);
|
229 |
+
$taskCompletedWarningMessage = $helper->escapeJs($helper->__(
|
230 |
+
'"%task_title%" task has completed with warnings. <a target="_blank" href="%url%">View log</a> for details.'
|
231 |
+
));
|
232 |
+
$taskCompletedErrorMessage = $helper->escapeJs($helper->__(
|
233 |
+
'"%task_title%" task has completed with errors. <a target="_blank" href="%url%">View log</a> for details.'
|
234 |
+
));
|
235 |
+
|
236 |
+
$lockedObjNoticeMessage = $helper->escapeJs(
|
237 |
+
$helper->__('Some Rakuten.com request(s) are being processed now.')
|
238 |
+
);
|
239 |
+
$sendingDataToBuyMessage = $helper->escapeJs($helper->__(
|
240 |
+
'Sending %product_title% product(s) data on Rakuten.com.'
|
241 |
+
));
|
242 |
+
$viewAllProductLogMessage = $helper->escapeJs($helper->__('View All Product Log.'));
|
243 |
+
|
244 |
+
$listingLockedMessage = $helper->escapeJs(
|
245 |
+
$helper->__('The listing was locked by another process. Please try again later.')
|
246 |
+
);
|
247 |
+
$listingEmptyMessage = $helper->escapeJs($helper->__('Listing is empty.'));
|
248 |
+
|
249 |
+
$listingAllItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
250 |
+
->__('Listing All Items On Rakuten.com'));
|
251 |
+
$listingSelectedItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
252 |
+
->__('Listing Selected Items On Rakuten.com'));
|
253 |
+
$revisingSelectedItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
254 |
+
->__('Revising Selected Items On Rakuten.com'));
|
255 |
+
$relistingSelectedItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
256 |
+
->__('Relisting Selected Items On Rakuten.com'));
|
257 |
+
$stoppingSelectedItemsMessage = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')
|
258 |
+
->__('Stopping Selected Items On Rakuten.com'));
|
259 |
+
$stoppingAndRemovingSelectedItemsMessage = Mage::helper('M2ePro')
|
260 |
+
->escapeJs(Mage::helper('M2ePro')
|
261 |
+
->__('Stopping On Rakuten.com And Removing From Listing Selected Items'));
|
262 |
+
$addNewSkuSelectedItemsMessage = Mage::helper('M2ePro')
|
263 |
+
->escapeJs(Mage::helper('M2ePro')
|
264 |
+
->__('Adding New SKU On Rakuten.com'));
|
265 |
+
|
266 |
+
$successfullyMovedMessage = $helper->escapeJs($helper->__('Product(s) was successfully moved.'));
|
267 |
+
$productsWereNotMovedMessage = $helper->escapeJs(
|
268 |
+
$helper->__('Product(s) was not moved. <a target="_blank" href="%url%">View log</a> for details.')
|
269 |
+
);
|
270 |
+
$someProductsWereNotMovedMessage = $helper->escapeJs(
|
271 |
+
$helper->__('Some product(s) was not moved. <a target="_blank" href="%url%">View log</a> for details.')
|
272 |
+
);
|
273 |
+
|
274 |
+
$selectItemsMessage = $helper->escapeJs(
|
275 |
+
$helper->__('Please select the products you want to perform the action on.')
|
276 |
+
);
|
277 |
+
$selectActionMessage = $helper->escapeJs($helper->__('Please select action.'));
|
278 |
+
|
279 |
+
$successWord = $helper->escapeJs($helper->__('Success'));
|
280 |
+
$noticeWord = $helper->escapeJs($helper->__('Notice'));
|
281 |
+
$warningWord = $helper->escapeJs($helper->__('Warning'));
|
282 |
+
$errorWord = $helper->escapeJs($helper->__('Error'));
|
283 |
+
$closeWord = $helper->escapeJs($helper->__('Close'));
|
284 |
+
|
285 |
+
$naString = Mage::helper('M2ePro')->__('N/A');
|
286 |
+
$assignString = Mage::helper('M2ePro')->__('Assign Rakuten.com SKU');
|
287 |
+
|
288 |
+
$textConfirm = $helper->escapeJs($helper->__('Are you sure?'));
|
289 |
+
|
290 |
+
$searchBuyComSkuManual = $this->getUrl('*/adminhtml_common_buy_listing/searchBuyComSkuManual');
|
291 |
+
$suggestedBuyComSkuGridHmtl = $this->getUrl('*/adminhtml_common_buy_listing/getSuggestedBuyComSkuGrid');
|
292 |
+
$searchBuyComSkuAuto = $this->getUrl('*/adminhtml_common_buy_listing/searchBuyComSkuAuto');
|
293 |
+
$mapToBuyComSku = $this->getUrl('*/adminhtml_common_buy_listing/mapToBuyComSku');
|
294 |
+
$unmapFromBuyComSku = $this->getUrl('*/adminhtml_common_buy_listing/unmapFromBuyComSku');
|
295 |
+
|
296 |
+
$newGeneralId = $this->getUrl('*/adminhtml_common_buy_template_newProduct');
|
297 |
+
|
298 |
+
$marketplaceId = Mage::helper('M2ePro/Data_Global')->getValue('marketplace_id');
|
299 |
+
$marketplaceInstance = Mage::helper('M2ePro/Component_Buy')->getCachedObject('Marketplace',$marketplaceId);
|
300 |
+
$marketplace = json_encode($marketplaceInstance->getData());
|
301 |
+
|
302 |
+
$isMarketplaceSynchronized = json_encode($marketplaceInstance->getChildObject()->isSynchronized());
|
303 |
+
$marketplaceSynchUrl = $this->getUrl(
|
304 |
+
'*/adminhtml_common_marketplace/index',
|
305 |
+
array('tab' => Ess_M2ePro_Block_Adminhtml_Common_Marketplace::TAB_ID_RAKUTEN)
|
306 |
+
);
|
307 |
+
$notSynchronizedMarketplace = $helper->escapeJs(
|
308 |
+
$helper->__(
|
309 |
+
'In order to use New SKU functionality, please re-synchronize marketplace data.'
|
310 |
+
).' '.
|
311 |
+
$helper->__(
|
312 |
+
'Press "Save And Update" button after redirect on marketplace page.'
|
313 |
+
)
|
314 |
+
);
|
315 |
+
|
316 |
+
$enterProductSearchQueryMessage = $helper->escapeJs(
|
317 |
+
$helper->__('Please enter product name or Rakuten.com SKU/ISBN/UPC.')
|
318 |
+
);
|
319 |
+
$autoMapBuyComSkuProgressTitle = $helper->escapeJs($helper->__('Assign Rakuten.com SKU to Item(s)'));
|
320 |
+
$autoMapBuyComSkuErrorMessage = $helper->escapeJs(
|
321 |
+
$helper->__('Server is currently unavailable. Please try again later.')
|
322 |
+
);
|
323 |
+
|
324 |
+
$noVariationsLeftText = $helper->__('All variations are already added.');
|
325 |
+
|
326 |
+
$javascriptsMain = <<<JAVASCRIPT
|
327 |
+
<script type="text/javascript">
|
328 |
+
|
329 |
+
if (typeof M2ePro == 'undefined') {
|
330 |
+
M2ePro = {};
|
331 |
+
M2ePro.url = {};
|
332 |
+
M2ePro.formData = {};
|
333 |
+
M2ePro.customData = {};
|
334 |
+
M2ePro.text = {};
|
335 |
+
}
|
336 |
+
|
337 |
+
M2ePro.url.add({$urls});
|
338 |
+
|
339 |
+
M2ePro.productsIdsForList = '{$productsIdsForList}';
|
340 |
+
|
341 |
+
M2ePro.url.logViewUrl = '{$logViewUrl}';
|
342 |
+
M2ePro.url.getErrorsSummary = '{$getErrorsSummary}';
|
343 |
+
|
344 |
+
M2ePro.url.runListProducts = '{$runListProducts}';
|
345 |
+
M2ePro.url.runReviseProducts = '{$runReviseProducts}';
|
346 |
+
M2ePro.url.runRelistProducts = '{$runRelistProducts}';
|
347 |
+
M2ePro.url.runStopProducts = '{$runStopProducts}';
|
348 |
+
M2ePro.url.runStopAndRemoveProducts = '{$runStopAndRemoveProducts}';
|
349 |
+
|
350 |
+
M2ePro.url.searchBuyComSkuManual = '{$searchBuyComSkuManual}';
|
351 |
+
M2ePro.url.searchBuyComSkuAuto = '{$searchBuyComSkuAuto}';
|
352 |
+
M2ePro.url.suggestedBuyComSkuGrid = '{$suggestedBuyComSkuGridHmtl}';
|
353 |
+
M2ePro.url.mapToBuyComSku = '{$mapToBuyComSku}';
|
354 |
+
M2ePro.url.unmapFromBuyComSku = '{$unmapFromBuyComSku}';
|
355 |
+
|
356 |
+
M2ePro.url.prepareData = '{$prepareData}';
|
357 |
+
M2ePro.url.getGridHtml = '{$getMoveToListingGridHtml}';
|
358 |
+
M2ePro.url.getFailedProductsGridHtml = '{$getFailedProductsGridHtml}';
|
359 |
+
M2ePro.url.tryToMoveToListing = '{$tryToMoveToListing}';
|
360 |
+
M2ePro.url.moveToListing = '{$moveToListing}';
|
361 |
+
|
362 |
+
M2ePro.url.get_variation_edit_popup = '{$getVariationEditPopupUrl}';
|
363 |
+
M2ePro.url.get_variation_manage_popup = '{$getVariationManagePopupUrl}';
|
364 |
+
|
365 |
+
M2ePro.url.variation_edit_action = '{$variationEditActionUrl}';
|
366 |
+
M2ePro.url.variation_manage_action = '{$variationManageActionUrl}';
|
367 |
+
M2ePro.url.variation_manage_generate_action = '{$variationManageGenerateActionUrl}';
|
368 |
+
|
369 |
+
M2ePro.url.newGeneralId = '{$newGeneralId}';
|
370 |
+
M2ePro.url.marketplace_synch = '{$marketplaceSynchUrl}';
|
371 |
+
|
372 |
+
M2ePro.text.popup_title = '{$popupTitle}';
|
373 |
+
M2ePro.text.failed_products_popup_title = '{$failedProductsPopupTitle}';
|
374 |
+
|
375 |
+
M2ePro.text.task_completed_message = '{$taskCompletedMessage}';
|
376 |
+
M2ePro.text.task_completed_success_message = '{$taskCompletedSuccessMessage}';
|
377 |
+
M2ePro.text.task_completed_warning_message = '{$taskCompletedWarningMessage}';
|
378 |
+
M2ePro.text.task_completed_error_message = '{$taskCompletedErrorMessage}';
|
379 |
+
|
380 |
+
M2ePro.text.locked_obj_notice = '{$lockedObjNoticeMessage}';
|
381 |
+
M2ePro.text.sending_data_message = '{$sendingDataToBuyMessage}';
|
382 |
+
M2ePro.text.view_all_product_log_message = '{$viewAllProductLogMessage}';
|
383 |
+
|
384 |
+
M2ePro.text.listing_locked_message = '{$listingLockedMessage}';
|
385 |
+
M2ePro.text.listing_empty_message = '{$listingEmptyMessage}';
|
386 |
+
|
387 |
+
M2ePro.text.listing_all_items_message = '{$listingAllItemsMessage}';
|
388 |
+
M2ePro.text.listing_selected_items_message = '{$listingSelectedItemsMessage}';
|
389 |
+
M2ePro.text.revising_selected_items_message = '{$revisingSelectedItemsMessage}';
|
390 |
+
M2ePro.text.relisting_selected_items_message = '{$relistingSelectedItemsMessage}';
|
391 |
+
M2ePro.text.stopping_selected_items_message = '{$stoppingSelectedItemsMessage}';
|
392 |
+
M2ePro.text.stopping_and_removing_selected_items_message = '{$stoppingAndRemovingSelectedItemsMessage}';
|
393 |
+
M2ePro.text.add_new_sku_selected_items_message = '{$addNewSkuSelectedItemsMessage}';
|
394 |
+
|
395 |
+
M2ePro.text.successfully_moved = '{$successfullyMovedMessage}';
|
396 |
+
M2ePro.text.products_were_not_moved = '{$productsWereNotMovedMessage}';
|
397 |
+
M2ePro.text.some_products_were_not_moved = '{$someProductsWereNotMovedMessage}';
|
398 |
+
|
399 |
+
M2ePro.text.select_items_message = '{$selectItemsMessage}';
|
400 |
+
M2ePro.text.select_action_message = '{$selectActionMessage}';
|
401 |
+
|
402 |
+
M2ePro.text.success_word = '{$successWord}';
|
403 |
+
M2ePro.text.notice_word = '{$noticeWord}';
|
404 |
+
M2ePro.text.warning_word = '{$warningWord}';
|
405 |
+
M2ePro.text.error_word = '{$errorWord}';
|
406 |
+
M2ePro.text.close_word = '{$closeWord}';
|
407 |
+
|
408 |
+
M2ePro.text.na = '{$naString}';
|
409 |
+
M2ePro.text.assign = '{$assignString}';
|
410 |
+
|
411 |
+
M2ePro.text.confirm = '{$textConfirm}';
|
412 |
+
|
413 |
+
M2ePro.text.enter_productSearch_query = '{$enterProductSearchQueryMessage}';
|
414 |
+
M2ePro.text.automap_buy_com_sku_progress_title = '{$autoMapBuyComSkuProgressTitle}';
|
415 |
+
M2ePro.text.automap_error_message = '{$autoMapBuyComSkuErrorMessage}';
|
416 |
+
|
417 |
+
M2ePro.text.no_variations_left = '{$noVariationsLeftText}';
|
418 |
+
|
419 |
+
M2ePro.text.not_synchronized_marketplace = '{$notSynchronizedMarketplace}';
|
420 |
+
|
421 |
+
M2ePro.customData.componentMode = '{$component}';
|
422 |
+
M2ePro.customData.gridId = '{$gridId}';
|
423 |
+
M2ePro.customData.ignoreListings = '{$ignoreListings}';
|
424 |
+
|
425 |
+
M2ePro.customData.marketplace = {$marketplace};
|
426 |
+
M2ePro.customData.isMarketplaceSynchronized = {$isMarketplaceSynchronized};
|
427 |
+
|
428 |
+
Event.observe(window, 'load', function() {
|
429 |
+
|
430 |
+
ListingGridHandlerObj = new BuyListingGridHandler(
|
431 |
+
'buyListingViewGrid{$listingData['id']}',
|
432 |
+
{$listingData['id']}
|
433 |
+
);
|
434 |
+
|
435 |
+
ListingGridHandlerObj.actionHandler.setOptions(M2ePro);
|
436 |
+
ListingGridHandlerObj.movingHandler.setOptions(M2ePro);
|
437 |
+
ListingGridHandlerObj.productSearchHandler.setOptions(M2ePro);
|
438 |
+
|
439 |
+
ListingProgressBarObj = new ProgressBar('listing_view_progress_bar');
|
440 |
+
GridWrapperObj = new AreaWrapper('listing_view_content_container');
|
441 |
+
|
442 |
+
ListingProductVariationHandlerObj = new ListingProductVariationHandler(M2ePro,
|
443 |
+
ListingGridHandlerObj);
|
444 |
+
|
445 |
+
if (M2ePro.productsIdsForList) {
|
446 |
+
ListingGridHandlerObj.getGridMassActionObj().checkedString = M2ePro.productsIdsForList;
|
447 |
+
ListingGridHandlerObj.actionHandler.listAction();
|
448 |
+
}
|
449 |
+
|
450 |
+
});
|
451 |
+
|
452 |
+
</script>
|
453 |
+
JAVASCRIPT;
|
454 |
+
|
455 |
+
$helpBlock = $layout->createBlock('M2ePro/adminhtml_common_buy_listing_view_help');
|
456 |
+
$productSearchMenuBlock = $layout->createBlock('M2ePro/adminhtml_common_buy_listing_productSearch_menu');
|
457 |
+
$productSearchBlock = $layout->createBlock('M2ePro/adminhtml_common_buy_listing_productSearch_main');
|
458 |
+
|
459 |
+
//------------------------------
|
460 |
+
$data = array(
|
461 |
+
'target_css_class' => 'edit_template_drop_down',
|
462 |
+
'items' => $this->getTemplatesButtonDropDownItems()
|
463 |
+
);
|
464 |
+
$templatesDropDownBlock = $layout->createBlock('M2ePro/adminhtml_widget_button_dropDown');
|
465 |
+
$templatesDropDownBlock->setData($data);
|
466 |
+
//------------------------------
|
467 |
+
|
468 |
+
//------------------------------
|
469 |
+
$data = array(
|
470 |
+
'target_css_class' => 'add_products_drop_down',
|
471 |
+
'items' => $this->getAddProductsDropDownItems()
|
472 |
+
);
|
473 |
+
$addProductsDropDownBlock = $layout->createBlock('M2ePro/adminhtml_widget_button_dropDown');
|
474 |
+
$addProductsDropDownBlock->setData($data);
|
475 |
+
//------------------------------
|
476 |
+
|
477 |
+
return $javascriptsMain
|
478 |
+
. $templatesDropDownBlock->toHtml()
|
479 |
+
. $addProductsDropDownBlock->toHtml()
|
480 |
+
. $helpBlock->toHtml()
|
481 |
+
. $productSearchMenuBlock->toHtml()
|
482 |
+
. $productSearchBlock->toHtml()
|
483 |
+
. parent::getGridHtml();
|
484 |
+
}
|
485 |
+
|
486 |
+
protected function getTemplatesButtonDropDownItems()
|
487 |
+
{
|
488 |
+
$items = array();
|
489 |
+
|
490 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
491 |
+
|
492 |
+
//------------------------------
|
493 |
+
$url = $this->getUrl(
|
494 |
+
'*/adminhtml_common_buy_template_sellingFormat/edit',
|
495 |
+
array(
|
496 |
+
'id' => $listingData['template_selling_format_id']
|
497 |
+
)
|
498 |
+
);
|
499 |
+
$items[] = array(
|
500 |
+
'url' => $url,
|
501 |
+
'label' => Mage::helper('M2ePro')->__('Selling Format Template'),
|
502 |
+
'target' => '_blank'
|
503 |
+
);
|
504 |
+
//------------------------------
|
505 |
+
|
506 |
+
//------------------------------
|
507 |
+
$url = $this->getUrl(
|
508 |
+
'*/adminhtml_common_buy_template_synchronization/edit',
|
509 |
+
array(
|
510 |
+
'id' => $listingData['template_synchronization_id']
|
511 |
+
)
|
512 |
+
);
|
513 |
+
$items[] = array(
|
514 |
+
'url' => $url,
|
515 |
+
'label' => Mage::helper('M2ePro')->__('Synchronization Template'),
|
516 |
+
'target' => '_blank'
|
517 |
+
);
|
518 |
+
//------------------------------
|
519 |
+
|
520 |
+
return $items;
|
521 |
+
}
|
522 |
+
|
523 |
+
public function getAddProductsDropDownItems()
|
524 |
+
{
|
525 |
+
$items = array();
|
526 |
+
|
527 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
528 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam('view', array('id' => $listingData['id']));
|
529 |
+
|
530 |
+
//------------------------------
|
531 |
+
$url = $this->getUrl(
|
532 |
+
'*/adminhtml_common_buy_listing/product',
|
533 |
+
array(
|
534 |
+
'id' => $listingData['id'],
|
535 |
+
'back' => $backUrl
|
536 |
+
)
|
537 |
+
);
|
538 |
+
$items[] = array(
|
539 |
+
'url' => $url,
|
540 |
+
'label' => Mage::helper('M2ePro')->__('From Products List')
|
541 |
+
);
|
542 |
+
//------------------------------
|
543 |
+
|
544 |
+
//------------------------------
|
545 |
+
$url = $this->getUrl(
|
546 |
+
'*/adminhtml_common_buy_listing/categoryProduct',
|
547 |
+
array(
|
548 |
+
'id' => $listingData['id'],
|
549 |
+
'back' => $backUrl
|
550 |
+
)
|
551 |
+
);
|
552 |
+
$items[] = array(
|
553 |
+
'url' => $url,
|
554 |
+
'label' => Mage::helper('M2ePro')->__('From Categories')
|
555 |
+
);
|
556 |
+
//------------------------------
|
557 |
+
|
558 |
+
return $items;
|
559 |
+
}
|
560 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Listing/View/Grid.php
ADDED
@@ -0,0 +1,980 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
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â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 extends Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
/** @var $sellingFormatTemplate Ess_M2ePro_Model_Buy_Template_SellingFormat */
|
10 |
+
private $sellingFormatTemplate = NULL;
|
11 |
+
|
12 |
+
private $lockedDataCache = array();
|
13 |
+
|
14 |
+
// ####################################
|
15 |
+
|
16 |
+
public function __construct()
|
17 |
+
{
|
18 |
+
parent::__construct();
|
19 |
+
|
20 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
21 |
+
|
22 |
+
// Initialization block
|
23 |
+
//------------------------------
|
24 |
+
$this->setId('buyListingViewGrid'.$listingData['id']);
|
25 |
+
//------------------------------
|
26 |
+
|
27 |
+
// Set default values
|
28 |
+
//------------------------------
|
29 |
+
$this->setDefaultSort('product_id');
|
30 |
+
$this->setDefaultDir('DESC');
|
31 |
+
$this->setSaveParametersInSession(true);
|
32 |
+
$this->setUseAjax(true);
|
33 |
+
//------------------------------
|
34 |
+
|
35 |
+
$this->sellingFormatTemplate = Mage::helper('M2ePro/Component_Buy')->getCachedObject(
|
36 |
+
'Template_SellingFormat', $listingData['template_selling_format_id'], NULL,
|
37 |
+
array('template')
|
38 |
+
);
|
39 |
+
}
|
40 |
+
|
41 |
+
// ####################################
|
42 |
+
|
43 |
+
protected function _prepareCollection()
|
44 |
+
{
|
45 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
46 |
+
|
47 |
+
// Get collection products in listing
|
48 |
+
//--------------------------------
|
49 |
+
$collection = Mage::helper('M2ePro/Component_Buy')->getCollection('Listing_Product');
|
50 |
+
$collection->getSelect()->distinct();
|
51 |
+
$collection->getSelect()->where("`main_table`.`listing_id` = ?",(int)$listingData['id']);
|
52 |
+
//--------------------------------
|
53 |
+
|
54 |
+
// Communicate with magento product table
|
55 |
+
//--------------------------------
|
56 |
+
$dbSelect = Mage::getResourceModel('core/config')->getReadConnection()
|
57 |
+
->select()
|
58 |
+
->from(Mage::getSingleton('core/resource')
|
59 |
+
->getTableName('catalog_product_entity_varchar'),
|
60 |
+
new Zend_Db_Expr('MAX(`store_id`)'))
|
61 |
+
->where("`entity_id` = `main_table`.`product_id`")
|
62 |
+
->where("`attribute_id` = `ea`.`attribute_id`")
|
63 |
+
->where("`store_id` = 0 OR `store_id` = ?",(int)$listingData['store_id']);
|
64 |
+
|
65 |
+
$collection->getSelect()
|
66 |
+
//->join(array('csi'=>Mage::getSingleton('core/resource')
|
67 |
+
// ->getTableName('cataloginventory_stock_item')),
|
68 |
+
// '(csi.product_id = `main_table`.product_id)',array('qty'))
|
69 |
+
->join(array('cpe'=>Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')),
|
70 |
+
'(cpe.entity_id = `main_table`.product_id)',array('magento_sku'=>'sku'))
|
71 |
+
->join(array('cisi'=>Mage::getSingleton('core/resource')
|
72 |
+
->getTableName('cataloginventory_stock_item')),
|
73 |
+
'(cisi.product_id = `main_table`.product_id AND cisi.stock_id = 1)',
|
74 |
+
array('is_in_stock'))
|
75 |
+
->join(array('cpev'=>Mage::getSingleton('core/resource')
|
76 |
+
->getTableName('catalog_product_entity_varchar')),
|
77 |
+
"( `cpev`.`entity_id` = `main_table`.product_id )",
|
78 |
+
array('value'))
|
79 |
+
->join(array('ea'=>Mage::getSingleton('core/resource')->getTableName('eav_attribute')),
|
80 |
+
'(`cpev`.`attribute_id` = `ea`.`attribute_id` AND `ea`.`attribute_code` = \'name\')',
|
81 |
+
array());
|
82 |
+
|
83 |
+
$collection->getSelect()->where('cpev.store_id = ('.$dbSelect->__toString().')');
|
84 |
+
//--------------------------------
|
85 |
+
|
86 |
+
//exit($collection->getSelect()->__toString());
|
87 |
+
|
88 |
+
// Set collection to grid
|
89 |
+
$this->setCollection($collection);
|
90 |
+
|
91 |
+
return parent::_prepareCollection();
|
92 |
+
}
|
93 |
+
|
94 |
+
protected function _prepareColumns()
|
95 |
+
{
|
96 |
+
$this->addColumn('product_id', array(
|
97 |
+
'header' => Mage::helper('M2ePro')->__('Product ID'),
|
98 |
+
'align' => 'right',
|
99 |
+
'width' => '100px',
|
100 |
+
'type' => 'number',
|
101 |
+
'index' => 'product_id',
|
102 |
+
'filter_index' => 'main_table.product_id',
|
103 |
+
'frame_callback' => array($this, 'callbackColumnProductId')
|
104 |
+
));
|
105 |
+
|
106 |
+
$this->addColumn('name', array(
|
107 |
+
'header' => Mage::helper('M2ePro')->__('Product Title / SKU'),
|
108 |
+
'align' => 'left',
|
109 |
+
//'width' => '300px',
|
110 |
+
'type' => 'text',
|
111 |
+
'index' => 'value',
|
112 |
+
'filter_index' => 'cpev.value',
|
113 |
+
'frame_callback' => array($this, 'callbackColumnProductTitle'),
|
114 |
+
'filter_condition_callback' => array($this, 'callbackFilterTitle')
|
115 |
+
));
|
116 |
+
|
117 |
+
$this->addColumn('stock_availability',
|
118 |
+
array(
|
119 |
+
'header'=> Mage::helper('M2ePro')->__('Stock Availability'),
|
120 |
+
'width' => '100px',
|
121 |
+
'index' => 'is_in_stock',
|
122 |
+
'filter_index' => 'cisi.is_in_stock',
|
123 |
+
'type' => 'options',
|
124 |
+
'sortable' => false,
|
125 |
+
'options' => array(
|
126 |
+
1 => Mage::helper('M2ePro')->__('In Stock'),
|
127 |
+
0 => Mage::helper('M2ePro')->__('Out of Stock')
|
128 |
+
),
|
129 |
+
'frame_callback' => array($this, 'callbackColumnStockAvailability')
|
130 |
+
));
|
131 |
+
|
132 |
+
$this->addColumn('sku', array(
|
133 |
+
'header' => Mage::helper('M2ePro')->__('Reference ID'),
|
134 |
+
'align' => 'left',
|
135 |
+
'width' => '150px',
|
136 |
+
'type' => 'text',
|
137 |
+
'index' => 'sku',
|
138 |
+
'filter_index' => 'second_table.sku',
|
139 |
+
'frame_callback' => array($this, 'callbackColumnSku')
|
140 |
+
));
|
141 |
+
|
142 |
+
$this->addColumn('general_id', array(
|
143 |
+
'header' => Mage::helper('M2ePro')->__('Rakuten.com SKU'),
|
144 |
+
'align' => 'left',
|
145 |
+
'width' => '80px',
|
146 |
+
'type' => 'text',
|
147 |
+
'index' => 'general_id',
|
148 |
+
'filter_index' => 'second_table.general_id',
|
149 |
+
'frame_callback' => array($this, 'callbackColumnGeneralId')
|
150 |
+
));
|
151 |
+
|
152 |
+
$this->addColumn('online_qty', array(
|
153 |
+
'header' => Mage::helper('M2ePro')->__('Rakuten.com QTY'),
|
154 |
+
'align' => 'right',
|
155 |
+
'width' => '70px',
|
156 |
+
'type' => 'number',
|
157 |
+
'index' => 'online_qty',
|
158 |
+
'filter_index' => 'second_table.online_qty',
|
159 |
+
'frame_callback' => array($this, 'callbackColumnAvailableQty')
|
160 |
+
));
|
161 |
+
|
162 |
+
$this->addColumn('online_price', array(
|
163 |
+
'header' => Mage::helper('M2ePro')->__('Rakuten.com Price'),
|
164 |
+
'align' => 'right',
|
165 |
+
'width' => '70px',
|
166 |
+
'type' => 'number',
|
167 |
+
'index' => 'online_price',
|
168 |
+
'filter_index' => 'second_table.online_price',
|
169 |
+
'frame_callback' => array($this, 'callbackColumnPrice')
|
170 |
+
));
|
171 |
+
|
172 |
+
$this->addColumn('status', array(
|
173 |
+
'header' => Mage::helper('M2ePro')->__('Status'),
|
174 |
+
'width' => '125px',
|
175 |
+
'index' => 'status',
|
176 |
+
'filter_index' => 'main_table.status',
|
177 |
+
'type' => 'options',
|
178 |
+
'sortable' => false,
|
179 |
+
'options' => array(
|
180 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED => Mage::helper('M2ePro')->__('Not Listed'),
|
181 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_LISTED => Mage::helper('M2ePro')->__('Active'),
|
182 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED => Mage::helper('M2ePro')->__('Inactive'),
|
183 |
+
),
|
184 |
+
'frame_callback' => array($this, 'callbackColumnStatus')
|
185 |
+
));
|
186 |
+
|
187 |
+
if (Mage::helper('M2ePro/Module')->isDevelopmentMode()) {
|
188 |
+
$this->addColumn('developer_action', array(
|
189 |
+
'header' => Mage::helper('M2ePro')->__('Actions'),
|
190 |
+
'align' => 'left',
|
191 |
+
'width' => '120px',
|
192 |
+
'type' => 'text',
|
193 |
+
'renderer' => 'M2ePro/adminhtml_listing_view_grid_column_renderer_developerAction',
|
194 |
+
'index' => 'value',
|
195 |
+
'filter' => false,
|
196 |
+
'sortable' => false,
|
197 |
+
'js_handler' => 'ListingGridHandlerObj'
|
198 |
+
));
|
199 |
+
}
|
200 |
+
|
201 |
+
return parent::_prepareColumns();
|
202 |
+
}
|
203 |
+
|
204 |
+
protected function _prepareMassaction()
|
205 |
+
{
|
206 |
+
// Set massaction identifiers
|
207 |
+
//--------------------------------
|
208 |
+
$this->setMassactionIdField('main_table.id');
|
209 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
210 |
+
//--------------------------------
|
211 |
+
|
212 |
+
// Set mass-action
|
213 |
+
//--------------------------------
|
214 |
+
$this->getMassactionBlock()->addItem('list', array(
|
215 |
+
'label' => Mage::helper('M2ePro')->__('List Item(s)'),
|
216 |
+
'url' => '',
|
217 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
218 |
+
));
|
219 |
+
|
220 |
+
$this->getMassactionBlock()->addItem('revise', array(
|
221 |
+
'label' => Mage::helper('M2ePro')->__('Revise Item(s)'),
|
222 |
+
'url' => '',
|
223 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
224 |
+
));
|
225 |
+
|
226 |
+
$this->getMassactionBlock()->addItem('relist', array(
|
227 |
+
'label' => Mage::helper('M2ePro')->__('Relist Item(s)'),
|
228 |
+
'url' => '',
|
229 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
230 |
+
));
|
231 |
+
|
232 |
+
$this->getMassactionBlock()->addItem('stop', array(
|
233 |
+
'label' => Mage::helper('M2ePro')->__('Stop Item(s)'),
|
234 |
+
'url' => '',
|
235 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
236 |
+
));
|
237 |
+
|
238 |
+
$this->getMassactionBlock()->addItem('stopAndRemove', array(
|
239 |
+
'label' => Mage::helper('M2ePro')->__('Stop on Channel / Remove from Listing'),
|
240 |
+
'url' => '',
|
241 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
242 |
+
));
|
243 |
+
|
244 |
+
$this->getMassactionBlock()->addItem('moving', array(
|
245 |
+
'label' => Mage::helper('M2ePro')->__('Move Item(s) to Another Listing'),
|
246 |
+
'url' => '',
|
247 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
248 |
+
));
|
249 |
+
|
250 |
+
$this->getMassactionBlock()->addItem('assignGeneralId', array(
|
251 |
+
'label' => Mage::helper('M2ePro')->__('Assign Rakuten.com SKU to Item(s)'),
|
252 |
+
'url' => '',
|
253 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
254 |
+
));
|
255 |
+
|
256 |
+
$this->getMassactionBlock()->addItem('newGeneralId', array(
|
257 |
+
'label' => Mage::helper('M2ePro')->__('Add New Rakuten.com SKU'),
|
258 |
+
'url' => '',
|
259 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
260 |
+
));
|
261 |
+
|
262 |
+
$this->getMassactionBlock()->addItem('unassignGeneralId', array(
|
263 |
+
'label' => Mage::helper('M2ePro')->__('Unassign Rakuten.com SKU'),
|
264 |
+
'url' => '',
|
265 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
266 |
+
));
|
267 |
+
|
268 |
+
$this->getMassactionBlock()->addItem('duplicate', array(
|
269 |
+
'label' => Mage::helper('M2ePro')->__('Duplicate'),
|
270 |
+
'url' => '',
|
271 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
272 |
+
));
|
273 |
+
//--------------------------------
|
274 |
+
|
275 |
+
return parent::_prepareMassaction();
|
276 |
+
}
|
277 |
+
|
278 |
+
// ####################################
|
279 |
+
|
280 |
+
public function callbackColumnProductId($value, $row, $column, $isExport)
|
281 |
+
{
|
282 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
283 |
+
|
284 |
+
$productId = (int)$row->getData('product_id');
|
285 |
+
$storeId = (int)$listingData['store_id'];
|
286 |
+
|
287 |
+
$withoutImageHtml = '<a href="'
|
288 |
+
.$this->getUrl('adminhtml/catalog_product/edit',
|
289 |
+
array('id' => $productId))
|
290 |
+
.'" target="_blank">'.$productId.'</a>';
|
291 |
+
|
292 |
+
$showProductsThumbnails = (bool)(int)Mage::helper('M2ePro/Module')->getConfig()
|
293 |
+
->getGroupValue('/view/','show_products_thumbnails');
|
294 |
+
if (!$showProductsThumbnails) {
|
295 |
+
return $withoutImageHtml;
|
296 |
+
}
|
297 |
+
|
298 |
+
/** @var $magentoProduct Ess_M2ePro_Model_Magento_Product */
|
299 |
+
$magentoProduct = Mage::getModel('M2ePro/Magento_Product');
|
300 |
+
$magentoProduct->setProductId($productId);
|
301 |
+
$magentoProduct->setStoreId($storeId);
|
302 |
+
|
303 |
+
$imageUrlResized = $magentoProduct->getThumbnailImageLink();
|
304 |
+
if (is_null($imageUrlResized)) {
|
305 |
+
return $withoutImageHtml;
|
306 |
+
}
|
307 |
+
|
308 |
+
$imageHtml = $productId.'<hr style="border: 1px solid silver; border-bottom: none;"><img src="'.
|
309 |
+
$imageUrlResized.'" />';
|
310 |
+
$withImageHtml = str_replace('>'.$productId.'<','>'.$imageHtml.'<',$withoutImageHtml);
|
311 |
+
|
312 |
+
return $withImageHtml;
|
313 |
+
}
|
314 |
+
|
315 |
+
public function callbackColumnProductTitle($productTitle, $row, $column, $isExport)
|
316 |
+
{
|
317 |
+
if (strlen($productTitle) > 60) {
|
318 |
+
$productTitle = substr($productTitle, 0, 60) . '...';
|
319 |
+
}
|
320 |
+
|
321 |
+
$productTitle = Mage::helper('M2ePro')->escapeHtml($productTitle);
|
322 |
+
|
323 |
+
$value = '<span>'.$productTitle.'</span>';
|
324 |
+
|
325 |
+
$tempSku = $row->getData('magento_sku');
|
326 |
+
is_null($tempSku)
|
327 |
+
&& $tempSku = Mage::getModel('M2ePro/Magento_Product')->setProductId($row->getData('product_id'))->getSku();
|
328 |
+
|
329 |
+
$value .= '<br/><strong>'.Mage::helper('M2ePro')->__('SKU') .
|
330 |
+
':</strong> '.Mage::helper('M2ePro')->escapeHtml($tempSku) . '<br>';
|
331 |
+
|
332 |
+
$listingProductId = (int)$row->getData('listing_product_id');
|
333 |
+
|
334 |
+
if (!$row->getChildObject()->isVariationProduct()) {
|
335 |
+
return $value;
|
336 |
+
}
|
337 |
+
|
338 |
+
$additionalData = $row->getData('additional_data');
|
339 |
+
$additionalData = (array)json_decode($additionalData, true);
|
340 |
+
$additionalData = array_filter($additionalData);
|
341 |
+
$variations = isset($additionalData['variation_options']) ? $additionalData['variation_options'] : array();
|
342 |
+
|
343 |
+
$value .= '<div style="font-size: 11px; color: grey; margin-left: 7px"><br>';
|
344 |
+
foreach ($variations as $attribute => $option) {
|
345 |
+
!$option && $option = '--';
|
346 |
+
$value .= '<strong>' . Mage::helper('M2ePro')->escapeHtml($attribute) .
|
347 |
+
'</strong>: ' . Mage::helper('M2ePro')->escapeHtml($option) . '<br>';
|
348 |
+
}
|
349 |
+
$value .= '</div>';
|
350 |
+
|
351 |
+
if (!$row->getChildObject()->isVariationMatched()) {
|
352 |
+
|
353 |
+
$popupTitle = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')->escapeHtml(
|
354 |
+
Mage::helper('M2ePro')->__('Manage "%product_title%" Options', $productTitle))
|
355 |
+
);
|
356 |
+
$linkTitle = Mage::helper('M2ePro')->__('Manage Options');
|
357 |
+
$linkContent = '<img height="12" width="12" src="'.$this->getSkinUrl('M2ePro').'/images/add.png'.'">';
|
358 |
+
|
359 |
+
$value.= <<<HTML
|
360 |
+
<div style="clear: both"></div>
|
361 |
+
<div style="float: left; margin: 0 0 0 5px">
|
362 |
+
<a href="javascript:"
|
363 |
+
onclick="ListingProductVariationHandlerObj
|
364 |
+
.setListingProductId({$listingProductId})
|
365 |
+
.showManagePopup('{$popupTitle}');"
|
366 |
+
title="{$linkTitle}">{$linkContent}</a>
|
367 |
+
</div>
|
368 |
+
HTML;
|
369 |
+
|
370 |
+
$linkContent = Mage::helper('M2ePro')->__('Manage Options');
|
371 |
+
|
372 |
+
$value .= <<<HTML
|
373 |
+
<div style="float: left; margin: 0 0 0 5px">
|
374 |
+
<a href="javascript:"
|
375 |
+
onclick="ListingProductVariationHandlerObj
|
376 |
+
.setListingProductId({$listingProductId})
|
377 |
+
.showManagePopup('{$popupTitle}');"
|
378 |
+
title="{$linkTitle}">{$linkContent}</a>
|
379 |
+
</div>
|
380 |
+
HTML;
|
381 |
+
|
382 |
+
return $value;
|
383 |
+
}
|
384 |
+
|
385 |
+
// ---------------------------------
|
386 |
+
$hasInActionLock = $this->getLockedData($row);
|
387 |
+
$hasInActionLock = $hasInActionLock['in_action'];
|
388 |
+
// ---------------------------------
|
389 |
+
|
390 |
+
if (!$hasInActionLock) {
|
391 |
+
|
392 |
+
$popupTitle = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')->escapeHtml(
|
393 |
+
Mage::helper('M2ePro')->__('Edit "%product_title%" Variation', $productTitle))
|
394 |
+
);
|
395 |
+
$linkTitle = Mage::helper('M2ePro')->__('Edit');
|
396 |
+
$linkContent = '<img width="12" height="12" src="'.$this->getSkinUrl('M2ePro').'/images/pencil.png'.'">';
|
397 |
+
|
398 |
+
$value .= <<<HTML
|
399 |
+
<div style="clear: both"></div>
|
400 |
+
<div style="margin: 0 0 0 7px; float: left;">
|
401 |
+
<a href="javascript:"
|
402 |
+
onclick="ListingProductVariationHandlerObj
|
403 |
+
.setListingProductId({$listingProductId})
|
404 |
+
.showEditPopup('{$popupTitle}');"
|
405 |
+
title="{$linkTitle}">{$linkContent}</a>
|
406 |
+
</div>
|
407 |
+
HTML;
|
408 |
+
}
|
409 |
+
|
410 |
+
$popupTitle = Mage::helper('M2ePro')->escapeJs(Mage::helper('M2ePro')->escapeHtml(
|
411 |
+
Mage::helper('M2ePro')->__('Add Another "%product_title%" Variations', $productTitle))
|
412 |
+
);
|
413 |
+
$linkTitle = Mage::helper('M2ePro')->__('Add Another Variation');
|
414 |
+
$linkContent = '<img width="12" height="12" src="'.$this->getSkinUrl('M2ePro').'/images/add.png'.'">';
|
415 |
+
|
416 |
+
$value.= <<<HTML
|
417 |
+
<div style="margin: 0 0 0 5px; float: left;">
|
418 |
+
<a href="javascript:"
|
419 |
+
onclick="ListingProductVariationHandlerObj
|
420 |
+
.setListingProductId({$listingProductId})
|
421 |
+
.showManagePopup('{$popupTitle}');"
|
422 |
+
title="{$linkTitle}">{$linkContent}</a>
|
423 |
+
</div>
|
424 |
+
HTML;
|
425 |
+
|
426 |
+
return $value;
|
427 |
+
}
|
428 |
+
|
429 |
+
public function callbackColumnStockAvailability($value, $row, $column, $isExport)
|
430 |
+
{
|
431 |
+
if ((int)$row->getData('is_in_stock') <= 0) {
|
432 |
+
return '<span style="color: red;">'.$value.'</span>';
|
433 |
+
}
|
434 |
+
|
435 |
+
return $value;
|
436 |
+
}
|
437 |
+
|
438 |
+
public function callbackColumnSku($value, $row, $column, $isExport)
|
439 |
+
{
|
440 |
+
if (is_null($value) || $value === '') {
|
441 |
+
return Mage::helper('M2ePro')->__('N/A');
|
442 |
+
}
|
443 |
+
return $value;
|
444 |
+
}
|
445 |
+
|
446 |
+
public function callbackColumnGeneralId($generalId, $row, $column, $isExport)
|
447 |
+
{
|
448 |
+
if (empty($generalId)) {
|
449 |
+
return $this->getGeneralIdColumnValueEmptyGeneralId($row);
|
450 |
+
}
|
451 |
+
|
452 |
+
return $this->getGeneralIdColumnValueNotEmptyGeneralId($row);
|
453 |
+
}
|
454 |
+
|
455 |
+
public function callbackColumnAvailableQty($value, $row, $column, $isExport)
|
456 |
+
{
|
457 |
+
if ((int)$row->getData('status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
458 |
+
if (is_null($value) || $value === '') {
|
459 |
+
return Mage::helper('M2ePro')->__('N/A');
|
460 |
+
}
|
461 |
+
} else {
|
462 |
+
if (is_null($value) || $value === '') {
|
463 |
+
return '<i style="color:gray;">receiving...</i>';
|
464 |
+
}
|
465 |
+
}
|
466 |
+
|
467 |
+
if ($value <= 0) {
|
468 |
+
return '<span style="color: red;">0</span>';
|
469 |
+
}
|
470 |
+
|
471 |
+
return $value;
|
472 |
+
}
|
473 |
+
|
474 |
+
public function callbackColumnPrice($value, $row, $column, $isExport)
|
475 |
+
{
|
476 |
+
if ((int)$row->getData('status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
477 |
+
if (is_null($value) || $value === '') {
|
478 |
+
return Mage::helper('M2ePro')->__('N/A');
|
479 |
+
}
|
480 |
+
} else {
|
481 |
+
if (is_null($value) || $value === '') {
|
482 |
+
return '<i style="color:gray;">receiving...</i>';
|
483 |
+
}
|
484 |
+
}
|
485 |
+
|
486 |
+
if ((float)$value <= 0) {
|
487 |
+
return '<span style="color: #f00;">0</span>';
|
488 |
+
}
|
489 |
+
|
490 |
+
return Mage::app()->getLocale()->currency('USD')->toCurrency($value);
|
491 |
+
}
|
492 |
+
|
493 |
+
public function callbackColumnStatus($value, $row, $column, $isExport)
|
494 |
+
{
|
495 |
+
switch ($row->getData('status')) {
|
496 |
+
|
497 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED:
|
498 |
+
$value = '<span style="color: gray;">' . $value . '</span>';
|
499 |
+
break;
|
500 |
+
|
501 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_LISTED:
|
502 |
+
$value = '<span style="color: green;">' . $value . '</span>';
|
503 |
+
break;
|
504 |
+
|
505 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED:
|
506 |
+
$value = '<span style="color: red;">'.$value.'</span>';
|
507 |
+
break;
|
508 |
+
|
509 |
+
default:
|
510 |
+
break;
|
511 |
+
}
|
512 |
+
|
513 |
+
$value .= $this->getViewLogIconHtml($row->getId());
|
514 |
+
|
515 |
+
$tempLocks = $this->getLockedData($row);
|
516 |
+
$tempLocks = $tempLocks['object_locks'];
|
517 |
+
|
518 |
+
foreach ($tempLocks as $lock) {
|
519 |
+
|
520 |
+
switch ($lock->getTag()) {
|
521 |
+
|
522 |
+
case 'new_sku_action':
|
523 |
+
$value .= '<br><span style="color: #605fff">[Add New SKU In Progress...]</span>';
|
524 |
+
break;
|
525 |
+
|
526 |
+
case 'list_action':
|
527 |
+
$value .= '<br><span style="color: #605fff">[List In Progress...]</span>';
|
528 |
+
break;
|
529 |
+
|
530 |
+
case 'relist_action':
|
531 |
+
$value .= '<br><span style="color: #605fff">[Relist In Progress...]</span>';
|
532 |
+
break;
|
533 |
+
|
534 |
+
case 'revise_action':
|
535 |
+
$value .= '<br><span style="color: #605fff">[Revise In Progress...]</span>';
|
536 |
+
break;
|
537 |
+
|
538 |
+
case 'stop_action':
|
539 |
+
$value .= '<br><span style="color: #605fff">[Stop In Progress...]</span>';
|
540 |
+
break;
|
541 |
+
|
542 |
+
case 'stop_and_remove_action':
|
543 |
+
$value .= '<br><span style="color: #605fff">[Stop And Remove In Progress...]</span>';
|
544 |
+
break;
|
545 |
+
|
546 |
+
default:
|
547 |
+
break;
|
548 |
+
}
|
549 |
+
}
|
550 |
+
|
551 |
+
return $value;
|
552 |
+
}
|
553 |
+
|
554 |
+
protected function callbackFilterTitle($collection, $column)
|
555 |
+
{
|
556 |
+
$value = $column->getFilter()->getValue();
|
557 |
+
|
558 |
+
if ($value == null) {
|
559 |
+
return;
|
560 |
+
}
|
561 |
+
|
562 |
+
$collection->getSelect()->where('cpev.value LIKE ? OR cpe.sku LIKE ?', '%'.$value.'%');
|
563 |
+
}
|
564 |
+
|
565 |
+
// ############################################
|
566 |
+
|
567 |
+
private function getGeneralIdColumnValueEmptyGeneralId($row)
|
568 |
+
{
|
569 |
+
// ---------------------------------
|
570 |
+
if ((int)$row->getData('status') != Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
571 |
+
return <<<HTML
|
572 |
+
<i style="color:gray;">receiving...</i>
|
573 |
+
HTML;
|
574 |
+
}
|
575 |
+
// ---------------------------------
|
576 |
+
|
577 |
+
// ---------------------------------
|
578 |
+
$iconPath = $this->getSkinUrl('M2ePro').'/images/search_statuses/';
|
579 |
+
// ---------------------------------
|
580 |
+
|
581 |
+
// ---------------------------------
|
582 |
+
$lpId = $row->getData('listing_product_id');
|
583 |
+
|
584 |
+
$productTitle = Mage::helper('M2ePro')->escapeHtml($row->getData('value'));
|
585 |
+
if (strlen($productTitle) > 60) {
|
586 |
+
$productTitle = substr($productTitle, 0, 60) . '...';
|
587 |
+
}
|
588 |
+
$productTitle = Mage::helper('M2ePro')->escapeJs($productTitle);
|
589 |
+
// ---------------------------------
|
590 |
+
|
591 |
+
// ---------------------------------
|
592 |
+
$hasInActionLock = $this->getLockedData($row);
|
593 |
+
$hasInActionLock = $hasInActionLock['in_action'];
|
594 |
+
// ---------------------------------
|
595 |
+
|
596 |
+
$na = Mage::helper('M2ePro')->__('N/A');
|
597 |
+
|
598 |
+
$templateNewProductId = $row->getData('template_new_product_id');
|
599 |
+
if (!empty($templateNewProductId)) {
|
600 |
+
|
601 |
+
$newSkuTemplateUrl = $this->getUrl(
|
602 |
+
'*/adminhtml_common_buy_template_newProduct/edit/',
|
603 |
+
array(
|
604 |
+
'id' => $templateNewProductId,
|
605 |
+
'listing_product_id' => $lpId,
|
606 |
+
'save_and_assign' => 0,
|
607 |
+
'back' => Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_buy_listing/view',array(
|
608 |
+
'id' => $row->getData('listing_id'),
|
609 |
+
))
|
610 |
+
)
|
611 |
+
);
|
612 |
+
|
613 |
+
$newSkuTemplateTitle = Mage::getModel('M2ePro/Buy_Template_NewProduct')
|
614 |
+
->load($templateNewProductId)
|
615 |
+
->getData('title');
|
616 |
+
|
617 |
+
if ($hasInActionLock) {
|
618 |
+
return $newSkuTemplateTitle;
|
619 |
+
}
|
620 |
+
|
621 |
+
$tip = Mage::helper('M2ePro')->__('Unassign New SKU Template');
|
622 |
+
$iconSrc = $iconPath.'unassign.png';
|
623 |
+
|
624 |
+
return <<<HTML
|
625 |
+
|
626 |
+
<a href="{$newSkuTemplateUrl}">{$newSkuTemplateTitle}</a>
|
627 |
+
<a href="javascript:;" title="{$tip}"
|
628 |
+
onclick="ListingGridHandlerObj.productSearchHandler.showUnmapFromGeneralIdPrompt('{$lpId}');">
|
629 |
+
<img src="{$iconSrc}" alt="" width="16" height="16">
|
630 |
+
</a>
|
631 |
+
HTML;
|
632 |
+
}
|
633 |
+
// ---------------------------------
|
634 |
+
|
635 |
+
// ---------------------------------
|
636 |
+
$generalIdSearchSuggestData = $row->getData('general_id_search_suggest_data');
|
637 |
+
|
638 |
+
if (!is_null($generalIdSearchSuggestData)) {
|
639 |
+
$generalIdSearchSuggestData = @json_decode($generalIdSearchSuggestData,true);
|
640 |
+
}
|
641 |
+
// ---------------------------------
|
642 |
+
|
643 |
+
if (isset($generalIdSearchSuggestData['message'])) {
|
644 |
+
|
645 |
+
$tip = Mage::helper('M2ePro')->escapeHtml($generalIdSearchSuggestData['message']);
|
646 |
+
$tip = Mage::helper('M2ePro')->escapeJs($tip);
|
647 |
+
|
648 |
+
$iconSrc = $iconPath.'error.png';
|
649 |
+
|
650 |
+
return <<<HTML
|
651 |
+
{$na}
|
652 |
+
<a href="javascript:;" title="{$tip}"
|
653 |
+
onclick="ListingGridHandlerObj.productSearchHandler.openPopUp(0,'{$productTitle}',{$lpId},'{$tip}');">
|
654 |
+
<img src="{$iconSrc}" alt="" width="16" height="16">
|
655 |
+
</a>
|
656 |
+
HTML;
|
657 |
+
}
|
658 |
+
|
659 |
+
if (!empty($generalIdSearchSuggestData)) {
|
660 |
+
|
661 |
+
$tip = Mage::helper('M2ePro')->__('Choose Rakuten.com SKU from the list');
|
662 |
+
$iconSrc = $iconPath.'list.png';
|
663 |
+
|
664 |
+
return <<<HTML
|
665 |
+
{$na}
|
666 |
+
<a href="javascript:;" title="{$tip}"
|
667 |
+
onclick="ListingGridHandlerObj.productSearchHandler.openPopUp(1,'{$productTitle}',{$lpId})">
|
668 |
+
<img src="{$iconSrc}" alt="" width="16" height="16">
|
669 |
+
</a>
|
670 |
+
HTML;
|
671 |
+
}
|
672 |
+
|
673 |
+
$tip = Mage::helper('M2ePro')->__('Search for Rakuten.com SKU');
|
674 |
+
$iconSrc = $iconPath.'search.png';
|
675 |
+
|
676 |
+
return <<<HTML
|
677 |
+
{$na}
|
678 |
+
<a href="javascript:;" title="{$tip}"
|
679 |
+
onclick="ListingGridHandlerObj.productSearchHandler.openPopUp(0,'{$productTitle}',{$lpId});">
|
680 |
+
<img src="{$iconSrc}" alt="" width="16" height="16">
|
681 |
+
</a>
|
682 |
+
HTML;
|
683 |
+
}
|
684 |
+
|
685 |
+
private function getGeneralIdColumnValueNotEmptyGeneralId($row)
|
686 |
+
{
|
687 |
+
$generalId = $row->getData('general_id');
|
688 |
+
|
689 |
+
$url = Mage::helper('M2ePro/Component_Buy')->getItemUrl($generalId);
|
690 |
+
|
691 |
+
if ((int)$row->getData('status') != Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
|
692 |
+
$conditionTitle = '';
|
693 |
+
switch ((int)$row->getData('condition')) {
|
694 |
+
case Ess_M2ePro_Model_Buy_Listing::CONDITION_NEW:
|
695 |
+
$conditionTitle = Mage::helper('M2ePro')->__('New');
|
696 |
+
break;
|
697 |
+
case Ess_M2ePro_Model_Buy_Listing::CONDITION_USED_LIKE_NEW:
|
698 |
+
$conditionTitle = Mage::helper('M2ePro')->__('Used - Like New');
|
699 |
+
break;
|
700 |
+
case Ess_M2ePro_Model_Buy_Listing::CONDITION_USED_VERY_GOOD:
|
701 |
+
$conditionTitle = Mage::helper('M2ePro')->__('Used - Very Good');
|
702 |
+
break;
|
703 |
+
case Ess_M2ePro_Model_Buy_Listing::CONDITION_USED_GOOD:
|
704 |
+
$conditionTitle = Mage::helper('M2ePro')->__('Used - Good');
|
705 |
+
break;
|
706 |
+
case Ess_M2ePro_Model_Buy_Listing::CONDITION_USED_ACCEPTABLE:
|
707 |
+
$conditionTitle = Mage::helper('M2ePro')->__('Used - Acceptable');
|
708 |
+
break;
|
709 |
+
case Ess_M2ePro_Model_Buy_Listing::CONDITION_REFURBISHED:
|
710 |
+
$conditionTitle = Mage::helper('M2ePro')->__('Refurbished');
|
711 |
+
break;
|
712 |
+
}
|
713 |
+
return <<<HTML
|
714 |
+
<a href="{$url}" target="_blank">{$generalId}</a><br/>
|
715 |
+
<span style="color:gray;">{$conditionTitle}</span>
|
716 |
+
HTML;
|
717 |
+
}
|
718 |
+
|
719 |
+
$iconPath = $this->getSkinUrl('M2ePro').'/images/search_statuses/';
|
720 |
+
|
721 |
+
$generalIdSearchStatus = $row->getData('general_id_search_status');
|
722 |
+
|
723 |
+
if (Ess_M2ePro_Model_Buy_Listing_Product::GENERAL_ID_SEARCH_STATUS_SET_AUTOMATIC == $generalIdSearchStatus) {
|
724 |
+
|
725 |
+
$tip = Mage::helper('M2ePro')->__('Rakuten.com was found automatically');
|
726 |
+
|
727 |
+
$text = <<<HTML
|
728 |
+
<a href="{$url}" target="_blank" title="{$tip}" style="color:#40AADB;">{$generalId}</a>
|
729 |
+
HTML;
|
730 |
+
|
731 |
+
} else {
|
732 |
+
|
733 |
+
$text = <<<HTML
|
734 |
+
<a href="{$url}" target="_blank">{$generalId}</a>
|
735 |
+
HTML;
|
736 |
+
|
737 |
+
}
|
738 |
+
|
739 |
+
// ---------------------------------
|
740 |
+
$hasInActionLock = $this->getLockedData($row);
|
741 |
+
$hasInActionLock = $hasInActionLock['in_action'];
|
742 |
+
// ---------------------------------
|
743 |
+
|
744 |
+
if ($hasInActionLock) {
|
745 |
+
return $text;
|
746 |
+
}
|
747 |
+
|
748 |
+
$tip = Mage::helper('M2ePro')->__('Unassign Rakuten.com SKU');
|
749 |
+
$iconSrc = $iconPath.'unassign.png';
|
750 |
+
|
751 |
+
$id = $row->getData('listing_product_id');
|
752 |
+
|
753 |
+
$text .= <<<HTML
|
754 |
+
<a href="javascript:;" onclick="ListingGridHandlerObj.productSearchHandler.showUnmapFromGeneralIdPrompt({$id});"
|
755 |
+
title="{$tip}">
|
756 |
+
<img src="{$iconSrc}" width="16" height="16"/>
|
757 |
+
</a>
|
758 |
+
HTML;
|
759 |
+
|
760 |
+
return $text;
|
761 |
+
}
|
762 |
+
|
763 |
+
// ############################################
|
764 |
+
|
765 |
+
public function getViewLogIconHtml($listingProductId)
|
766 |
+
{
|
767 |
+
$listingProductId = (int)$listingProductId;
|
768 |
+
|
769 |
+
// Get last messages
|
770 |
+
//--------------------------
|
771 |
+
/** @var $connRead Varien_Db_Adapter_Pdo_Mysql */
|
772 |
+
$connRead = Mage::getSingleton('core/resource')->getConnection('core_read');
|
773 |
+
|
774 |
+
$dbSelect = $connRead->select()
|
775 |
+
->from(
|
776 |
+
Mage::getResourceModel('M2ePro/Listing_Log')->getMainTable(),
|
777 |
+
array('action_id','action','type','description','create_date','initiator')
|
778 |
+
)
|
779 |
+
->where('`listing_product_id` = ?',$listingProductId)
|
780 |
+
->where('`action_id` IS NOT NULL')
|
781 |
+
->order(array('id DESC'))
|
782 |
+
->limit(30);
|
783 |
+
|
784 |
+
$logRows = $connRead->fetchAll($dbSelect);
|
785 |
+
//--------------------------
|
786 |
+
|
787 |
+
// Get grouped messages by action_id
|
788 |
+
//--------------------------
|
789 |
+
$actionsRows = array();
|
790 |
+
$tempActionRows = array();
|
791 |
+
$lastActionId = false;
|
792 |
+
|
793 |
+
foreach ($logRows as $row) {
|
794 |
+
|
795 |
+
$row['description'] = Mage::helper('M2ePro/View')->getModifiedLogMessage($row['description']);
|
796 |
+
|
797 |
+
if ($row['action_id'] !== $lastActionId) {
|
798 |
+
if (count($tempActionRows) > 0) {
|
799 |
+
$actionsRows[] = array(
|
800 |
+
'type' => $this->getMainTypeForActionId($tempActionRows),
|
801 |
+
'date' => $this->getMainDateForActionId($tempActionRows),
|
802 |
+
'action' => $this->getActionForAction($tempActionRows[0]),
|
803 |
+
'initiator' => $this->getInitiatorForAction($tempActionRows[0]),
|
804 |
+
'items' => $tempActionRows
|
805 |
+
);
|
806 |
+
$tempActionRows = array();
|
807 |
+
}
|
808 |
+
$lastActionId = $row['action_id'];
|
809 |
+
}
|
810 |
+
$tempActionRows[] = $row;
|
811 |
+
}
|
812 |
+
|
813 |
+
if (count($tempActionRows) > 0) {
|
814 |
+
$actionsRows[] = array(
|
815 |
+
'type' => $this->getMainTypeForActionId($tempActionRows),
|
816 |
+
'date' => $this->getMainDateForActionId($tempActionRows),
|
817 |
+
'action' => $this->getActionForAction($tempActionRows[0]),
|
818 |
+
'initiator' => $this->getInitiatorForAction($tempActionRows[0]),
|
819 |
+
'items' => $tempActionRows
|
820 |
+
);
|
821 |
+
}
|
822 |
+
|
823 |
+
if (count($actionsRows) <= 0) {
|
824 |
+
return '';
|
825 |
+
}
|
826 |
+
|
827 |
+
$tips = array(
|
828 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'Last action was completed successfully.',
|
829 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'Last action was completed with error(s).',
|
830 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'Last action was completed with warning(s).'
|
831 |
+
);
|
832 |
+
|
833 |
+
$icons = array(
|
834 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'normal',
|
835 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'error',
|
836 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'warning'
|
837 |
+
);
|
838 |
+
|
839 |
+
$summary = $this->getLayout()->createBlock('M2ePro/adminhtml_log_grid_summary', '', array(
|
840 |
+
'entity_id' => $listingProductId,
|
841 |
+
'rows' => $actionsRows,
|
842 |
+
'tips' => $tips,
|
843 |
+
'icons' => $icons,
|
844 |
+
'view_help_handler' => 'ListingGridHandlerObj.viewItemHelp',
|
845 |
+
'hide_help_handler' => 'ListingGridHandlerObj.hideItemHelp',
|
846 |
+
));
|
847 |
+
|
848 |
+
return $summary->toHtml();
|
849 |
+
}
|
850 |
+
|
851 |
+
public function getActionForAction($actionRows)
|
852 |
+
{
|
853 |
+
$string = '';
|
854 |
+
|
855 |
+
switch ($actionRows['action']) {
|
856 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_NEW_SKU_PRODUCT_ON_COMPONENT:
|
857 |
+
$string = Mage::helper('M2ePro')->__('New SKU');
|
858 |
+
break;
|
859 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_LIST_PRODUCT_ON_COMPONENT:
|
860 |
+
$string = Mage::helper('M2ePro')->__('List');
|
861 |
+
break;
|
862 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_RELIST_PRODUCT_ON_COMPONENT:
|
863 |
+
$string = Mage::helper('M2ePro')->__('Relist');
|
864 |
+
break;
|
865 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_REVISE_PRODUCT_ON_COMPONENT:
|
866 |
+
$string = Mage::helper('M2ePro')->__('Revise');
|
867 |
+
break;
|
868 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_STOP_PRODUCT_ON_COMPONENT:
|
869 |
+
$string = Mage::helper('M2ePro')->__('Stop');
|
870 |
+
break;
|
871 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_STOP_AND_REMOVE_PRODUCT:
|
872 |
+
$string = Mage::helper('M2ePro')->__('Stop on Channel / Remove from Listing');
|
873 |
+
break;
|
874 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_CHANGE_STATUS_ON_CHANNEL:
|
875 |
+
$string = Mage::helper('M2ePro')->__('Status Change');
|
876 |
+
break;
|
877 |
+
case Ess_M2ePro_Model_Listing_Log::ACTION_INVENTORY_SYNCHRONIZATION:
|
878 |
+
$string = Mage::helper('M2ePro')->__('Inventory Synchronization');
|
879 |
+
break;
|
880 |
+
}
|
881 |
+
|
882 |
+
return $string;
|
883 |
+
}
|
884 |
+
|
885 |
+
public function getInitiatorForAction($actionRows)
|
886 |
+
{
|
887 |
+
$string = '';
|
888 |
+
|
889 |
+
switch ((int)$actionRows['initiator']) {
|
890 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_UNKNOWN:
|
891 |
+
$string = '';
|
892 |
+
break;
|
893 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_USER:
|
894 |
+
$string = Mage::helper('M2ePro')->__('Manual');
|
895 |
+
break;
|
896 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION:
|
897 |
+
$string = Mage::helper('M2ePro')->__('Automatic');
|
898 |
+
break;
|
899 |
+
}
|
900 |
+
|
901 |
+
return $string;
|
902 |
+
}
|
903 |
+
|
904 |
+
public function getMainTypeForActionId($actionRows)
|
905 |
+
{
|
906 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS;
|
907 |
+
|
908 |
+
foreach ($actionRows as $row) {
|
909 |
+
if ($row['type'] == Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR) {
|
910 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR;
|
911 |
+
break;
|
912 |
+
}
|
913 |
+
if ($row['type'] == Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING) {
|
914 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING;
|
915 |
+
}
|
916 |
+
}
|
917 |
+
|
918 |
+
return $type;
|
919 |
+
}
|
920 |
+
|
921 |
+
public function getMainDateForActionId($actionRows)
|
922 |
+
{
|
923 |
+
$format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
|
924 |
+
return Mage::app()->getLocale()->date(strtotime($actionRows[0]['create_date']))->toString($format);
|
925 |
+
}
|
926 |
+
|
927 |
+
// ####################################
|
928 |
+
|
929 |
+
public function getGridUrl()
|
930 |
+
{
|
931 |
+
return $this->getUrl('*/adminhtml_common_buy_listing/viewGrid', array('_current'=>true));
|
932 |
+
}
|
933 |
+
|
934 |
+
public function getRowUrl($row)
|
935 |
+
{
|
936 |
+
return false;
|
937 |
+
}
|
938 |
+
|
939 |
+
// ####################################
|
940 |
+
|
941 |
+
protected function _toHtml()
|
942 |
+
{
|
943 |
+
$javascriptsMain = <<<JAVASCRIPT
|
944 |
+
<script type="text/javascript">
|
945 |
+
|
946 |
+
if (typeof ListingGridHandlerObj != 'undefined') {
|
947 |
+
ListingGridHandlerObj.afterInitPage();
|
948 |
+
}
|
949 |
+
|
950 |
+
Event.observe(window, 'load', function() {
|
951 |
+
setTimeout(function() {
|
952 |
+
ListingGridHandlerObj.afterInitPage();
|
953 |
+
}, 350);
|
954 |
+
});
|
955 |
+
|
956 |
+
</script>
|
957 |
+
JAVASCRIPT;
|
958 |
+
|
959 |
+
return parent::_toHtml().$javascriptsMain;
|
960 |
+
}
|
961 |
+
|
962 |
+
// ####################################
|
963 |
+
|
964 |
+
private function getLockedData($row)
|
965 |
+
{
|
966 |
+
$listingProductId = $row->getData('listing_product_id');
|
967 |
+
if (!isset($this->lockedDataCache[$listingProductId])) {
|
968 |
+
$objectLocks = $row->getObjectLocks();
|
969 |
+
$tempArray = array(
|
970 |
+
'object_locks' => $objectLocks,
|
971 |
+
'in_action' => !empty($objectLocks),
|
972 |
+
);
|
973 |
+
$this->lockedDataCache[$listingProductId] = $tempArray;
|
974 |
+
}
|
975 |
+
|
976 |
+
return $this->lockedDataCache[$listingProductId];
|
977 |
+
}
|
978 |
+
|
979 |
+
// ####################################
|
980 |
+
}
|
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/Order/Edit/ShippingAddress.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_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('reset', array(
|
59 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
60 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
61 |
+
'class' => 'reset'
|
62 |
+
));
|
63 |
+
//------------------------------
|
64 |
+
|
65 |
+
//------------------------------
|
66 |
+
$this->_addButton('save', array(
|
67 |
+
'label' => Mage::helper('M2ePro')->__('Save Order Address'),
|
68 |
+
'onclick' => 'CommonHandlerObj.save_click()',
|
69 |
+
'class' => 'save'
|
70 |
+
));
|
71 |
+
//------------------------------
|
72 |
+
}
|
73 |
+
}
|
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 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
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Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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/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_Order_Help extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
$this->setTemplate('M2ePro/common/buy/order/help.phtml');
|
14 |
+
}
|
15 |
+
|
16 |
+
public function getContainerId()
|
17 |
+
{
|
18 |
+
return 'block_notice_buy_orders_list';
|
19 |
+
}
|
20 |
+
}
|
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 @@
|
|
Â
|
|
Â
|
|
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
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
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 |
+
/*
|
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 |
+
'component' => $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 |
+
'component' => $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 |
+
'component' => $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/Synchronization/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_Buy_Synchronization_Help extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
$this->setTemplate('M2ePro/common/buy/synchronization/help.phtml');
|
13 |
+
}
|
14 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct.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_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 Templates For Rakuten.com (Beta)');
|
23 |
+
//------------------------------
|
24 |
+
|
25 |
+
// Set buttons actions
|
26 |
+
//------------------------------
|
27 |
+
$this->removeButton('back');
|
28 |
+
$this->removeButton('reset');
|
29 |
+
$this->removeButton('delete');
|
30 |
+
$this->removeButton('add');
|
31 |
+
$this->removeButton('save');
|
32 |
+
$this->removeButton('edit');
|
33 |
+
|
34 |
+
$listingProductIds = Mage::helper('M2ePro/Data_Session')->getValue('buy_listing_product_ids');
|
35 |
+
|
36 |
+
$listingId = Mage::helper('M2ePro/Component_Buy')
|
37 |
+
->getObject('Listing_Product',reset($listingProductIds))
|
38 |
+
->getListingId();
|
39 |
+
|
40 |
+
//------------------------------
|
41 |
+
$url = $this->getUrl(
|
42 |
+
'*/adminhtml_common_buy_listing/view',
|
43 |
+
array(
|
44 |
+
'id' => $listingId
|
45 |
+
)
|
46 |
+
);
|
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 |
+
$this->_addButton('reset', array(
|
56 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
57 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
58 |
+
'class' => 'reset'
|
59 |
+
));
|
60 |
+
//------------------------------
|
61 |
+
|
62 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_buy_template_newProduct');
|
63 |
+
|
64 |
+
//------------------------------
|
65 |
+
$url = $this->getUrl(
|
66 |
+
'*/adminhtml_common_buy_template_newProduct/add',
|
67 |
+
array(
|
68 |
+
'back' => $backUrl
|
69 |
+
)
|
70 |
+
);
|
71 |
+
$this->_addButton('new', array(
|
72 |
+
'label' => Mage::helper('M2ePro')->__('Add New SKU Template'),
|
73 |
+
'onclick' => 'setLocation(\''.$url.'\')',
|
74 |
+
'class' => 'add'
|
75 |
+
));
|
76 |
+
//------------------------------
|
77 |
+
}
|
78 |
+
|
79 |
+
public function getGridHtml()
|
80 |
+
{
|
81 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_template_newProduct_help');
|
82 |
+
|
83 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
84 |
+
}
|
85 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Edit.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_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 Template For Rakuten.com (Beta)')
|
27 |
+
: Mage::helper('M2ePro')->__('Add New SKU Template For Rakuten.com (Beta)');
|
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 |
+
$back = $this->getRequest()->getParam('back');
|
40 |
+
$buyListingProductIds = Mage::helper('M2ePro/Data_Session')->getValue('buy_listing_product_ids');
|
41 |
+
$listingProductId = $this->getRequest()->getParam('listing_product_id');
|
42 |
+
|
43 |
+
if ($back && ($buyListingProductIds || $listingProductId)) {
|
44 |
+
//------------------------------
|
45 |
+
$url = Mage::helper('M2ePro')->getBackUrl();
|
46 |
+
$this->_addButton('back', array(
|
47 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
48 |
+
'onclick' => 'CommonHandlerObj.back_click(\'' . $url .'\')',
|
49 |
+
'class' => 'back'
|
50 |
+
));
|
51 |
+
//------------------------------
|
52 |
+
}
|
53 |
+
|
54 |
+
//------------------------------
|
55 |
+
$this->_addButton('reset', array(
|
56 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
57 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
58 |
+
'class' => 'reset'
|
59 |
+
));
|
60 |
+
//------------------------------
|
61 |
+
|
62 |
+
//------------------------------
|
63 |
+
$params = array();
|
64 |
+
$listingProductId && $params['listing_product_id'] = $listingProductId;
|
65 |
+
$templateId && $params['id'] = $listingProductId;
|
66 |
+
|
67 |
+
$url = $this->getUrl('*/adminhtml_common_buy_template_newProduct/add', $params);
|
68 |
+
$this->_addButton('save', array(
|
69 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
70 |
+
'onclick' => 'CommonHandlerObj.save_click(\''.$url.'\')',
|
71 |
+
'class' => 'save'
|
72 |
+
));
|
73 |
+
//------------------------------
|
74 |
+
|
75 |
+
$saveAndAssign = (int)$this->getRequest()->getParam('save_and_assign', 1);
|
76 |
+
|
77 |
+
if ($saveAndAssign && $buyListingProductIds) {
|
78 |
+
//------------------------------
|
79 |
+
$url = $this->getUrl(
|
80 |
+
'*/adminhtml_common_buy_template_newProduct/add',
|
81 |
+
array(
|
82 |
+
'do_map' => true
|
83 |
+
)
|
84 |
+
);
|
85 |
+
$this->_addButton('save_and_map', array(
|
86 |
+
'label' => Mage::helper('M2ePro')->__('Save And Assign'),
|
87 |
+
'onclick' => 'CommonHandlerObj.save_click(\''.$url.'\')',
|
88 |
+
'class' => 'save'
|
89 |
+
));
|
90 |
+
//------------------------------
|
91 |
+
}
|
92 |
+
}
|
93 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Edit/Form.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_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 |
+
//------------------------------
|
65 |
+
$attributesSets = Mage::helper('M2ePro/Magento_AttributeSet')->getAll();
|
66 |
+
$this->setData('attributes_sets', $attributesSets);
|
67 |
+
|
68 |
+
$temp = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
69 |
+
|
70 |
+
$this->attribute_set_locked = false;
|
71 |
+
|
72 |
+
if (!is_null($temp)) {
|
73 |
+
$this->attribute_set_locked = (bool)Mage::getModel('M2ePro/Buy_Listing_Product')->getCollection()
|
74 |
+
->addFieldToFilter('template_new_product_id',$temp['category']['id'])
|
75 |
+
->getSize();
|
76 |
+
}
|
77 |
+
|
78 |
+
//------------------------------
|
79 |
+
$data = array(
|
80 |
+
'id' => 'attribute_sets_select_all_button',
|
81 |
+
'label' => Mage::helper('M2ePro')->__('Select All'),
|
82 |
+
'onclick' => 'AttributeSetHandlerObj.selectAllAttributeSets();',
|
83 |
+
'class' => 'attribute_sets_select_all_button'
|
84 |
+
);
|
85 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
86 |
+
$this->setChild('attribute_sets_select_all_button',$buttonBlock);
|
87 |
+
//------------------------------
|
88 |
+
|
89 |
+
//------------------------------
|
90 |
+
$data = array(
|
91 |
+
'id' => 'attribute_sets_confirm_button',
|
92 |
+
'label' => Mage::helper('M2ePro')->__('Confirm'),
|
93 |
+
'onclick' => 'BuyTemplateNewProductHandlerObj.confirmAttributeSets();',
|
94 |
+
'class' => 'attribute_sets_confirm_button',
|
95 |
+
'style' => 'display: none'
|
96 |
+
);
|
97 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
98 |
+
$this->setChild('attribute_sets_confirm_button',$buttonBlock);
|
99 |
+
//------------------------------
|
100 |
+
|
101 |
+
return parent::_beforeToHtml();
|
102 |
+
}
|
103 |
+
}
|
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,71 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
//------------------------------
|
25 |
+
$data = array(
|
26 |
+
'label' => Mage::helper('M2ePro')->__('Insert'),
|
27 |
+
'onclick' => "AttributeSetHandlerObj.appendToText('select_attributes_for_title', 'title_template');",
|
28 |
+
'class' => 'select_attributes_for_title_button'
|
29 |
+
);
|
30 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
31 |
+
$this->setChild('select_attributes_for_title_button',$buttonBlock);
|
32 |
+
//------------------------------
|
33 |
+
|
34 |
+
//------------------------------
|
35 |
+
$data = array(
|
36 |
+
'label' => Mage::helper('M2ePro')->__('Insert'),
|
37 |
+
'onclick' => "AttributeSetHandlerObj.appendToText(".
|
38 |
+
"'select_attributes_for_mfg_name'," . " 'manufacturer_template'".
|
39 |
+
");",
|
40 |
+
'class' => 'select_attributes_for_mfg_name_template_button'
|
41 |
+
);
|
42 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
43 |
+
$this->setChild('select_attributes_for_mfg_name_template_button',$buttonBlock);
|
44 |
+
//------------------------------
|
45 |
+
|
46 |
+
//------------------------------
|
47 |
+
$data = array(
|
48 |
+
'label' => Mage::helper('M2ePro')->__('Insert'),
|
49 |
+
'onclick' => "AttributeSetHandlerObj.appendToTextarea('#' + $('select_attributes').value + '#');",
|
50 |
+
'class' => 'add_product_attribute_button',
|
51 |
+
);
|
52 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
53 |
+
$this->setChild('add_product_attribute_button',$buttonBlock);
|
54 |
+
//------------------------------
|
55 |
+
|
56 |
+
//------------------------------
|
57 |
+
for ($i = 0; $i < Ess_M2ePro_Model_Buy_Template_NewProduct_Core::FEATURES_COUNT; $i++) {
|
58 |
+
$data = array(
|
59 |
+
'label' => Mage::helper('M2ePro')->__('Insert'),
|
60 |
+
'onclick' => "AttributeSetHandlerObj.appendToText('select_attributes_for_features_{$i}',"
|
61 |
+
. " 'features_{$i}');BuyTemplateNewProductHandlerObj.allowAddFeature(this);",
|
62 |
+
'class' => "select_attributes_for_features_{$i}_button"
|
63 |
+
);
|
64 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
65 |
+
$this->setChild("select_attributes_for_features_{$i}_button",$buttonBlock);
|
66 |
+
}
|
67 |
+
//------------------------------
|
68 |
+
|
69 |
+
return parent::_beforeToHtml();
|
70 |
+
}
|
71 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Edit/Tabs/General.php
ADDED
@@ -0,0 +1,177 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
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|
Â
|
|
Â
|
|
Â
|
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->listingAttributeSetsIds = array();
|
31 |
+
if (!$this->getRequest()->getParam('id') &&
|
32 |
+
$listingProductIds = Mage::helper('M2ePro/Data_Session')->getValue('buy_listing_product_ids')) {
|
33 |
+
|
34 |
+
$this->listingAttributeSetsIds = (array)Mage::helper('M2ePro/Component_Buy')
|
35 |
+
->getObject('Listing_Product',reset($listingProductIds))
|
36 |
+
->getListing()
|
37 |
+
->getAttributeSetsIds();
|
38 |
+
}
|
39 |
+
|
40 |
+
$this->nodes = $connRead->select()
|
41 |
+
->from(Mage::getSingleton('core/resource')->getTableName('m2epro_buy_dictionary_category'))
|
42 |
+
->where('parent_category_id = ?', 0)
|
43 |
+
->query()
|
44 |
+
->fetchAll();
|
45 |
+
!is_array($this->nodes) && $this->nodes = array();
|
46 |
+
|
47 |
+
//------------------------------
|
48 |
+
$data = array(
|
49 |
+
'id' => 'category_confirm_button',
|
50 |
+
'label' => Mage::helper('M2ePro')->__('Confirm'),
|
51 |
+
'onclick' => 'BuyTemplateNewProductHandlerObj.confirmCategory();',
|
52 |
+
);
|
53 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
54 |
+
$this->setChild('category_confirm_button',$buttonBlock);
|
55 |
+
//------------------------------
|
56 |
+
|
57 |
+
//------------------------------
|
58 |
+
$data = array(
|
59 |
+
'id' => 'category_change_button',
|
60 |
+
'label' => Mage::helper('M2ePro')->__('Change Category'),
|
61 |
+
'onclick' => 'BuyTemplateNewProductHandlerObj.changeCategory();',
|
62 |
+
);
|
63 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
64 |
+
$this->setChild('category_change_button',$buttonBlock);
|
65 |
+
//------------------------------
|
66 |
+
|
67 |
+
$attributesSets = Mage::helper('M2ePro/Magento_AttributeSet')->getAll();
|
68 |
+
$this->setData('attributes_sets', $attributesSets);
|
69 |
+
|
70 |
+
$temp = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
71 |
+
|
72 |
+
$this->attribute_set_locked = false;
|
73 |
+
|
74 |
+
if (!is_null($temp)) {
|
75 |
+
$this->attribute_set_locked = (bool)Mage::getModel('M2ePro/Buy_Listing_Product')->getCollection()
|
76 |
+
->addFieldToFilter('template_new_product_id',$temp['category']['id'])
|
77 |
+
->getSize();
|
78 |
+
}
|
79 |
+
|
80 |
+
//------------------------------
|
81 |
+
$data = array(
|
82 |
+
'id' => 'attribute_sets_select_all_button',
|
83 |
+
'label' => Mage::helper('M2ePro')->__('Select All'),
|
84 |
+
'onclick' => 'AttributeSetHandlerObj.selectAllAttributeSets();',
|
85 |
+
'class' => 'attribute_sets_select_all_button'
|
86 |
+
);
|
87 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
88 |
+
$this->setChild('attribute_sets_select_all_button',$buttonBlock);
|
89 |
+
//------------------------------
|
90 |
+
|
91 |
+
//------------------------------
|
92 |
+
$data = array(
|
93 |
+
'id' => 'attribute_sets_confirm_button',
|
94 |
+
'label' => Mage::helper('M2ePro')->__('Confirm'),
|
95 |
+
'onclick' => '',
|
96 |
+
'class' => 'attribute_sets_confirm_button',
|
97 |
+
'style' => 'display: none'
|
98 |
+
);
|
99 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
100 |
+
$this->setChild('attribute_sets_confirm_button',$buttonBlock);
|
101 |
+
//------------------------------
|
102 |
+
|
103 |
+
//------------------------------
|
104 |
+
$data = array(
|
105 |
+
'id' => 'browse_category_button',
|
106 |
+
'label' => Mage::helper('M2ePro')->__('Browse'),
|
107 |
+
'onclick' => 'BuyTemplateNewProductHandlerObj.browse_category.showCenter(true)'
|
108 |
+
);
|
109 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
110 |
+
$this->setChild('browse_category_button',$buttonBlock);
|
111 |
+
//------------------------------
|
112 |
+
|
113 |
+
//------------------------------
|
114 |
+
$data = array(
|
115 |
+
'id' => 'search_category_button',
|
116 |
+
'label' => Mage::helper('M2ePro')->__('Search By Keywords'),
|
117 |
+
'onclick' => 'BuyTemplateNewProductHandlerObj.search_category.showCenter(true)',
|
118 |
+
);
|
119 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
120 |
+
$this->setChild('search_category_button',$buttonBlock);
|
121 |
+
//------------------------------
|
122 |
+
|
123 |
+
//------------------------------
|
124 |
+
$data = array(
|
125 |
+
'id' => 'search_category_popup_button',
|
126 |
+
'label' => Mage::helper('M2ePro')->__('Search'),
|
127 |
+
'onclick' => 'BuyTemplateNewProductHandlerObj.searchClick()',
|
128 |
+
);
|
129 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
130 |
+
$this->setChild('search_category_popup_button',$buttonBlock);
|
131 |
+
//------------------------------
|
132 |
+
|
133 |
+
//------------------------------
|
134 |
+
$data = array(
|
135 |
+
'id' => 'reset_category_popup_button',
|
136 |
+
'label' => Mage::helper('M2ePro')->__('Reset'),
|
137 |
+
'onclick' => 'BuyTemplateNewProductHandlerObj.resetSearchClick()',
|
138 |
+
'style' => 'display: none'
|
139 |
+
);
|
140 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
141 |
+
$this->setChild('reset_category_popup_button',$buttonBlock);
|
142 |
+
//------------------------------
|
143 |
+
|
144 |
+
//------------------------------
|
145 |
+
$data = array(
|
146 |
+
'id' => 'close_browse_popup_button',
|
147 |
+
'label' => Mage::helper('M2ePro')->__('Close'),
|
148 |
+
'onclick' => 'BuyTemplateNewProductHandlerObj.closeBrowseCategoryPopup()',
|
149 |
+
);
|
150 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
151 |
+
$this->setChild('close_browse_popup_button',$buttonBlock);
|
152 |
+
//------------------------------
|
153 |
+
|
154 |
+
//------------------------------
|
155 |
+
$data = array(
|
156 |
+
'id' => 'close_search_popup_button',
|
157 |
+
'label' => Mage::helper('M2ePro')->__('Close'),
|
158 |
+
'onclick' => 'BuyTemplateNewProductHandlerObj.closeSearchCategoryPopup()',
|
159 |
+
);
|
160 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
161 |
+
$this->setChild('close_search_popup_button',$buttonBlock);
|
162 |
+
//------------------------------
|
163 |
+
|
164 |
+
return parent::_beforeToHtml();
|
165 |
+
}
|
166 |
+
|
167 |
+
// ########################################
|
168 |
+
|
169 |
+
public function isAllowedUpcExemption($formData)
|
170 |
+
{
|
171 |
+
$isAllowedUpcExemption = Ess_M2ePro_Model_Buy_Template_NewProduct_Source::isAllowedUpcExemption();
|
172 |
+
$gtinMode = $formData['category']['gtin_mode'];
|
173 |
+
return $isAllowedUpcExemption || $gtinMode == Ess_M2ePro_Model_Buy_Template_NewProduct_Core::GTIN_MODE_NONE;
|
174 |
+
}
|
175 |
+
|
176 |
+
// ########################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
{
|
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 |
+
$this->attributeSets = Mage::getResourceModel('eav/entity_attribute_set_collection')
|
27 |
+
->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
|
28 |
+
->load()->toOptionHash();
|
29 |
+
|
30 |
+
//------------------------------
|
31 |
+
$listingProductIds = Mage::helper('M2ePro/Data_Session')->getValue('buy_listing_product_ids');
|
32 |
+
$listingProductId = reset($listingProductIds);
|
33 |
+
|
34 |
+
$this->listingAttributes = Mage::helper('M2ePro/Component_Buy')
|
35 |
+
->getObject('Listing_Product',$listingProductId)
|
36 |
+
->getListing()
|
37 |
+
->getAttributeSetsIds();
|
38 |
+
}
|
39 |
+
|
40 |
+
protected function _prepareCollection()
|
41 |
+
{
|
42 |
+
$collection = Mage::getModel('M2ePro/Buy_Template_NewProduct')->getCollection();
|
43 |
+
$this->setCollection($collection);
|
44 |
+
return parent::_prepareCollection();
|
45 |
+
}
|
46 |
+
|
47 |
+
protected function _prepareColumns()
|
48 |
+
{
|
49 |
+
$this->addColumn('id', array(
|
50 |
+
'header' => Mage::helper('M2ePro')->__('ID'),
|
51 |
+
'align' => 'right',
|
52 |
+
'type' => 'number',
|
53 |
+
'width' => '50px',
|
54 |
+
'index' => 'id',
|
55 |
+
'filter_index' => 'id',
|
56 |
+
'frame_callback' => array($this, 'callbackColumnId')
|
57 |
+
));
|
58 |
+
|
59 |
+
$this->addColumn('title', array(
|
60 |
+
'header' => Mage::helper('M2ePro')->__('Title'),
|
61 |
+
'align' => 'left',
|
62 |
+
'type' => 'text',
|
63 |
+
'width' => '100px',
|
64 |
+
'index' => 'title',
|
65 |
+
'filter_index' => 'title',
|
66 |
+
'frame_callback' => array($this, 'callbackColumnTitle')
|
67 |
+
));
|
68 |
+
|
69 |
+
$this->addColumn('node_title', array(
|
70 |
+
'header' => Mage::helper('M2ePro')->__('Department'),
|
71 |
+
'align' => 'left',
|
72 |
+
'type' => 'text',
|
73 |
+
'width' => '100px',
|
74 |
+
'index' => 'node_title',
|
75 |
+
'filter_index' => 'node_title',
|
76 |
+
'frame_callback' => array($this, 'callbackColumnNodeTitle')
|
77 |
+
));
|
78 |
+
|
79 |
+
$this->addColumn('category_path', array(
|
80 |
+
'header' => Mage::helper('M2ePro')->__('Category'),
|
81 |
+
'align' => 'left',
|
82 |
+
'type' => 'text',
|
83 |
+
'width' => '350px',
|
84 |
+
'index' => 'category_path',
|
85 |
+
'filter_index' => 'category_path',
|
86 |
+
'frame_callback' => array($this, 'callbackColumnCategoryPath')
|
87 |
+
));
|
88 |
+
|
89 |
+
$this->addColumn('attribute_sets', array(
|
90 |
+
'header' => Mage::helper('M2ePro')->__('Attribute Sets'),
|
91 |
+
'align' => 'left',
|
92 |
+
'width' => '200px',
|
93 |
+
'filter' => false,
|
94 |
+
'sortable' => false,
|
95 |
+
'frame_callback' => array($this, 'callbackColumnAttributeSets')
|
96 |
+
));
|
97 |
+
|
98 |
+
$back = Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_buy_template_newProduct');
|
99 |
+
|
100 |
+
$this->addColumn('assignment', array(
|
101 |
+
'header' => Mage::helper('M2ePro')->__('Assignment'),
|
102 |
+
'align' => 'left',
|
103 |
+
'type' => 'text',
|
104 |
+
'width' => '130px',
|
105 |
+
'filter' => false,
|
106 |
+
'sortable' => false,
|
107 |
+
'frame_callback' => array($this, 'callbackColumnActions'),
|
108 |
+
));
|
109 |
+
|
110 |
+
$this->addColumn('actions', array(
|
111 |
+
'header' => Mage::helper('M2ePro')->__('Actions'),
|
112 |
+
'align' => 'left',
|
113 |
+
'width' => '100px',
|
114 |
+
'type' => 'action',
|
115 |
+
'index' => 'actions',
|
116 |
+
'filter' => false,
|
117 |
+
'sortable' => false,
|
118 |
+
'getter' => 'getId',
|
119 |
+
'actions' => array(
|
120 |
+
array(
|
121 |
+
'caption' => Mage::helper('M2ePro')->__('Edit Template'),
|
122 |
+
'url' => array('base'=> '*/adminhtml_common_buy_template_newProduct/edit/back/'.$back),
|
123 |
+
'field' => 'id'
|
124 |
+
),
|
125 |
+
array(
|
126 |
+
'caption' => Mage::helper('M2ePro')->__('Delete Template'),
|
127 |
+
'url' => array('base'=> '*/adminhtml_common_buy_template_newProduct/delete/back/'
|
128 |
+
.$this->getRequest()->getParam('back')),
|
129 |
+
'field' => 'ids',
|
130 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
131 |
+
),
|
132 |
+
)
|
133 |
+
));
|
134 |
+
}
|
135 |
+
|
136 |
+
// ####################################
|
137 |
+
|
138 |
+
protected function _prepareMassaction()
|
139 |
+
{
|
140 |
+
// Set massaction identifiers
|
141 |
+
//--------------------------------
|
142 |
+
$this->setMassactionIdField('id');
|
143 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
144 |
+
//--------------------------------
|
145 |
+
|
146 |
+
// Set delete action
|
147 |
+
//--------------------------------
|
148 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
149 |
+
'label' => Mage::helper('M2ePro')->__('Delete'),
|
150 |
+
'url' => $this->getUrl('*/*/delete'),
|
151 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
152 |
+
));
|
153 |
+
//--------------------------------
|
154 |
+
|
155 |
+
return parent::_prepareMassaction();
|
156 |
+
}
|
157 |
+
|
158 |
+
// ####################################
|
159 |
+
|
160 |
+
public function callbackColumnId($value, $row, $column, $isExport)
|
161 |
+
{
|
162 |
+
return $value.' ';
|
163 |
+
}
|
164 |
+
|
165 |
+
public function callbackColumnTitle($value, $row, $column, $isExport)
|
166 |
+
{
|
167 |
+
return ' '.$value;
|
168 |
+
}
|
169 |
+
|
170 |
+
public function callbackColumnNodeTitle($value, $row, $column, $isExport)
|
171 |
+
{
|
172 |
+
return ' '.$value;
|
173 |
+
}
|
174 |
+
|
175 |
+
public function callbackColumnCategoryPath($value, $row, $column, $isExport)
|
176 |
+
{
|
177 |
+
return ' '.$value;
|
178 |
+
}
|
179 |
+
|
180 |
+
public function callbackColumnAttributeSets($value, $row, $column, $isExport)
|
181 |
+
{
|
182 |
+
$attributeSets = Mage::getModel('M2ePro/AttributeSet')->getCollection()
|
183 |
+
->addFieldToFilter('object_type',Ess_M2ePro_Model_AttributeSet::OBJECT_TYPE_BUY_TEMPLATE_NEW_PRODUCT)
|
184 |
+
->addFieldToFilter('object_id',(int)$row->getId())
|
185 |
+
->toArray();
|
186 |
+
|
187 |
+
$value = '';
|
188 |
+
foreach ($attributeSets['items'] as $attributeSet) {
|
189 |
+
if (strlen($value) > 100) {
|
190 |
+
$value .= ', <strong>...</strong>';
|
191 |
+
break;
|
192 |
+
}
|
193 |
+
if (isset($this->attributeSets[$attributeSet['attribute_set_id']])) {
|
194 |
+
$value != '' && $value .= ', ';
|
195 |
+
$value .= $this->attributeSets[$attributeSet['attribute_set_id']];
|
196 |
+
}
|
197 |
+
}
|
198 |
+
|
199 |
+
return $value;
|
200 |
+
}
|
201 |
+
|
202 |
+
public function callbackColumnActions($value, $row, $column, $isExport)
|
203 |
+
{
|
204 |
+
$url = $this->getUrl(
|
205 |
+
'*/adminhtml_common_buy_template_newProduct/map/',
|
206 |
+
array(
|
207 |
+
'id' => $row->getId(),
|
208 |
+
)
|
209 |
+
);
|
210 |
+
$newSkuTemplateAttributes = $row->getAttributeSetsIds();
|
211 |
+
|
212 |
+
$listingAttributesAreIncludedInNewSkuTemplate = true;
|
213 |
+
foreach ($this->listingAttributes as $listingAttribute) {
|
214 |
+
if (array_search($listingAttribute,$newSkuTemplateAttributes) === false) {
|
215 |
+
$listingAttributesAreIncludedInNewSkuTemplate = false;
|
216 |
+
continue;
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
if ($listingAttributesAreIncludedInNewSkuTemplate) {
|
221 |
+
$confirmMessage = Mage::helper('M2ePro')->__('Are you sure?');
|
222 |
+
$actions = ' <a href="javascript:;" onclick="confirm(\''.$confirmMessage.'\') && ';
|
223 |
+
$actions .= 'setLocation(\''.$url.'\');">';
|
224 |
+
$actions .= Mage::helper('M2ePro')->__('Assign To This Template');
|
225 |
+
$actions .= '</a>';
|
226 |
+
} else {
|
227 |
+
$actions = '<span style="color: #808080;">';
|
228 |
+
$actions .= ' '.Mage::helper('M2ePro')->__('Attribute Sets Mismatch');
|
229 |
+
$actions .= '</span>';
|
230 |
+
}
|
231 |
+
|
232 |
+
return $actions;
|
233 |
+
}
|
234 |
+
|
235 |
+
// ####################################
|
236 |
+
|
237 |
+
public function getGridUrl()
|
238 |
+
{
|
239 |
+
return $this->getUrl('*/adminhtml_common_buy_template_newProduct/templateNewProductGrid',
|
240 |
+
array('_current'=>true));
|
241 |
+
}
|
242 |
+
|
243 |
+
public function getRowUrl($row)
|
244 |
+
{
|
245 |
+
$back = Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_buy_template_newProduct');
|
246 |
+
|
247 |
+
return $this->getUrl('*/adminhtml_common_buy_template_newProduct/edit', array(
|
248 |
+
'id' => $row->getId(),
|
249 |
+
'back' => $back
|
250 |
+
));
|
251 |
+
}
|
252 |
+
|
253 |
+
// ####################################
|
254 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/NewProduct/Help.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_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 |
+
|
21 |
+
public function getContainerId()
|
22 |
+
{
|
23 |
+
return 'block_notice_buy_template_newProduct';
|
24 |
+
}
|
25 |
+
}
|
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,109 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 = $helper->__(Ess_M2ePro_Helper_Component_Buy::TITLE);
|
27 |
+
$headerTextEdit = $helper->__("Edit %component_name% Selling Format Template", $componentName);
|
28 |
+
$headerTextAdd = $helper->__("Add %component_name% Selling Format Template", $componentName);
|
29 |
+
} else {
|
30 |
+
$headerTextEdit = $helper->__("Edit Selling Format Template");
|
31 |
+
$headerTextAdd = $helper->__("Add Selling Format Template");
|
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 |
+
//------------------------------
|
65 |
+
$this->_addButton('reset', array(
|
66 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
67 |
+
'onclick' => 'BuyTemplateSellingFormatHandlerObj.reset_click()',
|
68 |
+
'class' => 'reset'
|
69 |
+
));
|
70 |
+
//------------------------------
|
71 |
+
|
72 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data')
|
73 |
+
&& Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()
|
74 |
+
) {
|
75 |
+
//------------------------------
|
76 |
+
$this->_addButton('duplicate', array(
|
77 |
+
'label' => Mage::helper('M2ePro')->__('Duplicate'),
|
78 |
+
'onclick' => 'BuyTemplateSellingFormatHandlerObj.duplicate_click'
|
79 |
+
.'(\'common-buy-template-sellingFormat\')',
|
80 |
+
'class' => 'add M2ePro_duplicate_button'
|
81 |
+
));
|
82 |
+
//------------------------------
|
83 |
+
|
84 |
+
//------------------------------
|
85 |
+
$this->_addButton('delete', array(
|
86 |
+
'label' => Mage::helper('M2ePro')->__('Delete'),
|
87 |
+
'onclick' => 'BuyTemplateSellingFormatHandlerObj.delete_click()',
|
88 |
+
'class' => 'delete M2ePro_delete_button'
|
89 |
+
));
|
90 |
+
//------------------------------
|
91 |
+
}
|
92 |
+
|
93 |
+
//------------------------------
|
94 |
+
$this->_addButton('save', array(
|
95 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
96 |
+
'onclick' => 'BuyTemplateSellingFormatHandlerObj.save_click()',
|
97 |
+
'class' => 'save'
|
98 |
+
));
|
99 |
+
//------------------------------
|
100 |
+
|
101 |
+
//------------------------------
|
102 |
+
$this->_addButton('save_and_continue', array(
|
103 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
104 |
+
'onclick' => 'BuyTemplateSellingFormatHandlerObj.save_and_edit_click()',
|
105 |
+
'class' => 'save'
|
106 |
+
));
|
107 |
+
//------------------------------
|
108 |
+
}
|
109 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/SellingFormat/Edit/Form.php
ADDED
@@ -0,0 +1,83 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
$attributesSets = Mage::helper('M2ePro/Magento_AttributeSet')->getAll();
|
42 |
+
$this->setData('attributes_sets', $attributesSets);
|
43 |
+
//------------------------------
|
44 |
+
|
45 |
+
//------------------------------
|
46 |
+
$this->attribute_set_locked = false;
|
47 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data')
|
48 |
+
&& Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()
|
49 |
+
) {
|
50 |
+
$this->attribute_set_locked = Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->isLocked();
|
51 |
+
}
|
52 |
+
//------------------------------
|
53 |
+
|
54 |
+
//------------------------------
|
55 |
+
$data = array(
|
56 |
+
'id' => 'attribute_sets_select_all_button',
|
57 |
+
'label' => Mage::helper('M2ePro')->__('Select All'),
|
58 |
+
'onclick' => 'AttributeSetHandlerObj.selectAllAttributeSets();',
|
59 |
+
'class' => 'attribute_sets_select_all_button'
|
60 |
+
);
|
61 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
62 |
+
$this->setChild('attribute_sets_select_all_button',$buttonBlock);
|
63 |
+
//------------------------------
|
64 |
+
|
65 |
+
//------------------------------
|
66 |
+
$data = array(
|
67 |
+
'id' => 'attribute_sets_confirm_button',
|
68 |
+
'label' => Mage::helper('M2ePro')->__('Confirm'),
|
69 |
+
'onclick' => 'BuyTemplateSellingFormatHandlerObj.attribute_sets_confirm();',
|
70 |
+
'class' => 'attribute_sets_confirm_button',
|
71 |
+
'style' => 'display: none'
|
72 |
+
);
|
73 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
74 |
+
$this->setChild('attribute_sets_confirm_button',$buttonBlock);
|
75 |
+
//------------------------------
|
76 |
+
|
77 |
+
//------------------------------
|
78 |
+
$this->customerGroups = Mage::getModel('customer/group')->getCollection()->toOptionArray();
|
79 |
+
//------------------------------
|
80 |
+
|
81 |
+
return parent::_beforeToHtml();
|
82 |
+
}
|
83 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Buy/Template/Synchronization/Edit.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_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 = $helper->__(Ess_M2ePro_Helper_Component_Buy::TITLE);
|
27 |
+
$headerTextEdit = $helper->__("Edit %component_name% Synchronization Template", $componentName);
|
28 |
+
$headerTextAdd = $helper->__("Add %component_name% Synchronization Template", $componentName);
|
29 |
+
} else {
|
30 |
+
$headerTextEdit = $helper->__("Edit Synchronization Template");
|
31 |
+
$headerTextAdd = $helper->__("Add Synchronization Template");
|
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 |
+
//------------------------------
|
65 |
+
$this->_addButton('reset', array(
|
66 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
67 |
+
'onclick' => 'BuyTemplateSynchronizationHandlerObj.reset_click()',
|
68 |
+
'class' => 'reset'
|
69 |
+
));
|
70 |
+
//------------------------------
|
71 |
+
|
72 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data')
|
73 |
+
&& Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()
|
74 |
+
) {
|
75 |
+
//------------------------------
|
76 |
+
$this->_addButton('duplicate', array(
|
77 |
+
'label' => Mage::helper('M2ePro')->__('Duplicate'),
|
78 |
+
'onclick' => 'BuyTemplateSynchronizationHandlerObj.duplicate_click'
|
79 |
+
.'(\'common-buy-template-synchronization\')',
|
80 |
+
'class' => 'add M2ePro_duplicate_button'
|
81 |
+
));
|
82 |
+
//------------------------------
|
83 |
+
|
84 |
+
//------------------------------
|
85 |
+
$this->_addButton('delete', array(
|
86 |
+
'label' => Mage::helper('M2ePro')->__('Delete'),
|
87 |
+
'onclick' => 'BuyTemplateSynchronizationHandlerObj.delete_click()',
|
88 |
+
'class' => 'delete M2ePro_delete_button'
|
89 |
+
));
|
90 |
+
//------------------------------
|
91 |
+
}
|
92 |
+
|
93 |
+
//------------------------------
|
94 |
+
$this->_addButton('save', array(
|
95 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
96 |
+
'onclick' => 'BuyTemplateSynchronizationHandlerObj.save_click()',
|
97 |
+
'class' => 'save'
|
98 |
+
));
|
99 |
+
//------------------------------
|
100 |
+
|
101 |
+
//------------------------------
|
102 |
+
$this->_addButton('save_and_continue', array(
|
103 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
104 |
+
'onclick' => 'BuyTemplateSynchronizationHandlerObj.save_and_edit_click'
|
105 |
+
.'(\'\',\'buyTemplateSynchronizationEditTabs\')',
|
106 |
+
'class' => 'save'
|
107 |
+
));
|
108 |
+
//------------------------------
|
109 |
+
}
|
110 |
+
}
|
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/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
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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,295 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
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|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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_log/listing', array('back' => $backUrl));
|
37 |
+
$this->_addButton('general_log', array(
|
38 |
+
'label' => Mage::helper('M2ePro')->__('General Log'),
|
39 |
+
'onclick' => 'setLocation(\'' . $url .'\')',
|
40 |
+
'class' => 'button_link'
|
41 |
+
));
|
42 |
+
//------------------------------
|
43 |
+
|
44 |
+
//------------------------------
|
45 |
+
$url = $this->getUrl('*/adminhtml_common_listing/search', array('back' => $backUrl));
|
46 |
+
$this->_addButton('search_products', array(
|
47 |
+
'label' => Mage::helper('M2ePro')->__('Search Products'),
|
48 |
+
'onclick' => 'setLocation(\'' . $url . '\')',
|
49 |
+
'class' => 'button_link search'
|
50 |
+
));
|
51 |
+
//------------------------------
|
52 |
+
|
53 |
+
//------------------------------
|
54 |
+
$this->_addButton('reset', array(
|
55 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
56 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
57 |
+
'class' => 'reset'
|
58 |
+
));
|
59 |
+
//------------------------------
|
60 |
+
|
61 |
+
//------------------------------
|
62 |
+
$this->useAjax = true;
|
63 |
+
$this->tabsAjaxUrls = array(
|
64 |
+
self::TAB_ID_AMAZON => $this->getUrl('*/adminhtml_common_amazon_listing/index'),
|
65 |
+
self::TAB_ID_BUY => $this->getUrl('*/adminhtml_common_buy_listing/index'),
|
66 |
+
self::TAB_ID_PLAY => $this->getUrl('*/adminhtml_common_play_listing/index'),
|
67 |
+
);
|
68 |
+
//------------------------------
|
69 |
+
}
|
70 |
+
|
71 |
+
// ########################################
|
72 |
+
|
73 |
+
protected function getTabsContainerBlock()
|
74 |
+
{
|
75 |
+
return parent::getTabsContainerBlock()->setId('listing');
|
76 |
+
}
|
77 |
+
|
78 |
+
// ########################################
|
79 |
+
|
80 |
+
protected function getAmazonTabBlock()
|
81 |
+
{
|
82 |
+
if (!$this->getChild('amazon_tab')) {
|
83 |
+
$tutorialShown = Mage::helper('M2ePro/Module')->getConfig()
|
84 |
+
->getGroupValue('/view/common/amazon/listing/', 'tutorial_shown');
|
85 |
+
|
86 |
+
if (!$tutorialShown) {
|
87 |
+
$block = $this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_listing_tutorial');
|
88 |
+
} else {
|
89 |
+
$block = $this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_listing');
|
90 |
+
}
|
91 |
+
|
92 |
+
$this->setChild('amazon_tab', $block);
|
93 |
+
}
|
94 |
+
|
95 |
+
return $this->getChild('amazon_tab');
|
96 |
+
}
|
97 |
+
|
98 |
+
public function getAmazonTabHtml()
|
99 |
+
{
|
100 |
+
$tutorialShown = Mage::helper('M2ePro/Module')->getConfig()
|
101 |
+
->getGroupValue('/view/common/amazon/listing/', 'tutorial_shown');
|
102 |
+
|
103 |
+
if (!$tutorialShown) {
|
104 |
+
return parent::getAmazonTabHtml();
|
105 |
+
}
|
106 |
+
|
107 |
+
$javascript = '';
|
108 |
+
|
109 |
+
if ($this->getRequest()->isXmlHttpRequest()) {
|
110 |
+
$javascript = $this->getAmazonTabBlock()->getTemplatesButtonJavascript();
|
111 |
+
}
|
112 |
+
|
113 |
+
return $javascript .
|
114 |
+
$this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_listing_filter')->toHtml() .
|
115 |
+
parent::getAmazonTabHtml();
|
116 |
+
}
|
117 |
+
|
118 |
+
// ########################################
|
119 |
+
|
120 |
+
protected function getBuyTabBlock()
|
121 |
+
{
|
122 |
+
if (!$this->getChild('buy_tab')) {
|
123 |
+
$tutorialShown = Mage::helper('M2ePro/Module')->getConfig()
|
124 |
+
->getGroupValue('/view/common/buy/listing/', 'tutorial_shown');
|
125 |
+
|
126 |
+
if (!$tutorialShown) {
|
127 |
+
$block = $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_listing_tutorial');
|
128 |
+
} else {
|
129 |
+
$block = $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_listing');
|
130 |
+
}
|
131 |
+
|
132 |
+
$this->setChild('buy_tab', $block);
|
133 |
+
}
|
134 |
+
|
135 |
+
return $this->getChild('buy_tab');
|
136 |
+
}
|
137 |
+
|
138 |
+
public function getBuyTabHtml()
|
139 |
+
{
|
140 |
+
$tutorialShown = Mage::helper('M2ePro/Module')->getConfig()
|
141 |
+
->getGroupValue('/view/common/buy/listing/', 'tutorial_shown');
|
142 |
+
|
143 |
+
if (!$tutorialShown) {
|
144 |
+
return parent::getBuyTabHtml();
|
145 |
+
}
|
146 |
+
|
147 |
+
$javascript = '';
|
148 |
+
|
149 |
+
if ($this->getRequest()->isXmlHttpRequest()) {
|
150 |
+
$javascript = $this->getBuyTabBlock()->getTemplatesButtonJavascript();
|
151 |
+
}
|
152 |
+
|
153 |
+
return $javascript .
|
154 |
+
$this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_listing_filter')->toHtml() .
|
155 |
+
parent::getBuyTabHtml();
|
156 |
+
}
|
157 |
+
|
158 |
+
// ########################################
|
159 |
+
|
160 |
+
protected function getPlayTabBlock()
|
161 |
+
{
|
162 |
+
if (!$this->getChild('play_tab')) {
|
163 |
+
$tutorialShown = Mage::helper('M2ePro/Module')->getConfig()
|
164 |
+
->getGroupValue('/view/common/play/listing/', 'tutorial_shown');
|
165 |
+
|
166 |
+
if (!$tutorialShown) {
|
167 |
+
$block = $this->getLayout()->createBlock('M2ePro/adminhtml_common_play_listing_tutorial');
|
168 |
+
} else {
|
169 |
+
$block = $this->getLayout()->createBlock('M2ePro/adminhtml_common_play_listing');
|
170 |
+
}
|
171 |
+
|
172 |
+
$this->setChild('play_tab', $block);
|
173 |
+
}
|
174 |
+
|
175 |
+
return $this->getChild('play_tab');
|
176 |
+
}
|
177 |
+
|
178 |
+
public function getPlayTabHtml()
|
179 |
+
{
|
180 |
+
$tutorialShown = Mage::helper('M2ePro/Module')->getConfig()
|
181 |
+
->getGroupValue('/view/common/play/listing/', 'tutorial_shown');
|
182 |
+
|
183 |
+
if (!$tutorialShown) {
|
184 |
+
return parent::getPlayTabHtml();
|
185 |
+
}
|
186 |
+
|
187 |
+
$javascript = '';
|
188 |
+
|
189 |
+
if ($this->getRequest()->isXmlHttpRequest()) {
|
190 |
+
$javascript = $this->getPlayTabBlock()->getTemplatesButtonJavascript();
|
191 |
+
}
|
192 |
+
|
193 |
+
return $javascript .
|
194 |
+
$this->getLayout()->createBlock('M2ePro/adminhtml_common_play_listing_filter')->toHtml() .
|
195 |
+
parent::getPlayTabHtml();
|
196 |
+
}
|
197 |
+
|
198 |
+
// ########################################
|
199 |
+
|
200 |
+
protected function getTabHtmlById($id)
|
201 |
+
{
|
202 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
203 |
+
return parent::getTabHtmlById($id);
|
204 |
+
}
|
205 |
+
|
206 |
+
/** @var $singleBlock Mage_Core_Block_Abstract|Mage_Adminhtml_Block_Widget_Grid_Container */
|
207 |
+
$singleBlock = $this->getSingleBlock();
|
208 |
+
|
209 |
+
if (is_object($singleBlock) && $singleBlock instanceof Mage_Adminhtml_Block_Widget_Grid_Container) {
|
210 |
+
return $singleBlock->getGridHtml();
|
211 |
+
}
|
212 |
+
|
213 |
+
return parent::getTabHtmlById($id);
|
214 |
+
}
|
215 |
+
|
216 |
+
protected function _componentsToHtml()
|
217 |
+
{
|
218 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_listing_help');
|
219 |
+
$floatingToolbarFixer = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_floatingToolbarFixer');
|
220 |
+
|
221 |
+
return $helpBlock->toHtml() . $floatingToolbarFixer->toHtml() . parent::_componentsToHtml();
|
222 |
+
}
|
223 |
+
|
224 |
+
// ########################################
|
225 |
+
|
226 |
+
public function getButtonsHtml($area = null)
|
227 |
+
{
|
228 |
+
$javascript = $this->getButtonsJavascript();
|
229 |
+
|
230 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
231 |
+
return $javascript . parent::getButtonsHtml($area);
|
232 |
+
}
|
233 |
+
|
234 |
+
return $javascript . $this->getSingleBlock()->getButtonsHtml();
|
235 |
+
}
|
236 |
+
|
237 |
+
private function getButtonsJavascript()
|
238 |
+
{
|
239 |
+
if (count($this->tabs) <= 0) {
|
240 |
+
return '';
|
241 |
+
}
|
242 |
+
|
243 |
+
if (count($this->tabs) == 1) {
|
244 |
+
return $this->getSingleBlock()->getTemplatesButtonJavascript();
|
245 |
+
}
|
246 |
+
|
247 |
+
$javascript = '';
|
248 |
+
$javascript .= $this->getAmazonButtonsJavascript();
|
249 |
+
$javascript .= $this->getBuyButtonsJavascript();
|
250 |
+
$javascript .= $this->getPlayButtonsJavascript();
|
251 |
+
|
252 |
+
return $javascript;
|
253 |
+
}
|
254 |
+
|
255 |
+
private function getAmazonButtonsJavascript()
|
256 |
+
{
|
257 |
+
if (!Mage::helper('M2ePro/Component_Amazon')->isActive()) {
|
258 |
+
return '';
|
259 |
+
}
|
260 |
+
|
261 |
+
if ($this->getActiveTab() != self::TAB_ID_AMAZON) {
|
262 |
+
return '';
|
263 |
+
}
|
264 |
+
|
265 |
+
return $this->getAmazonTabBlock()->getTemplatesButtonJavascript();
|
266 |
+
}
|
267 |
+
|
268 |
+
private function getBuyButtonsJavascript()
|
269 |
+
{
|
270 |
+
if (!Mage::helper('M2ePro/Component_Buy')->isActive()) {
|
271 |
+
return '';
|
272 |
+
}
|
273 |
+
|
274 |
+
if ($this->getActiveTab() != self::TAB_ID_BUY) {
|
275 |
+
return '';
|
276 |
+
}
|
277 |
+
|
278 |
+
return $this->getBuyTabBlock()->getTemplatesButtonJavascript();
|
279 |
+
}
|
280 |
+
|
281 |
+
private function getPlayButtonsJavascript()
|
282 |
+
{
|
283 |
+
if (!Mage::helper('M2ePro/Component_Play')->isActive()) {
|
284 |
+
return '';
|
285 |
+
}
|
286 |
+
|
287 |
+
if ($this->getActiveTab() != self::TAB_ID_PLAY) {
|
288 |
+
return '';
|
289 |
+
}
|
290 |
+
|
291 |
+
return $this->getPlayTabBlock()->getTemplatesButtonJavascript();
|
292 |
+
}
|
293 |
+
|
294 |
+
// ########################################
|
295 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Category/Tree.php
ADDED
@@ -0,0 +1,155 @@
|
|
Â
|
|
Â
|
|
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|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
private $readConnection = NULL;
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('listingCategoryTree');
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$this->setTemplate('M2ePro/common/listing/category/tree.phtml');
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @return Varien_Db_Adapter_Interface
|
25 |
+
*/
|
26 |
+
private function getReadConnection()
|
27 |
+
{
|
28 |
+
if (is_null($this->readConnection)) {
|
29 |
+
$this->readConnection = Mage::getResourceModel('core/config')->getReadConnection();
|
30 |
+
}
|
31 |
+
|
32 |
+
return $this->readConnection;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function getCategoryCollection()
|
36 |
+
{
|
37 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
38 |
+
$storeId = (int)$listingData['store_id'];
|
39 |
+
|
40 |
+
$collection = $this->getData('category_collection');
|
41 |
+
|
42 |
+
if (is_null($collection)) {
|
43 |
+
|
44 |
+
$collection = Mage::getModel('catalog/category')->getCollection();
|
45 |
+
|
46 |
+
$collection->addAttributeToSelect('name')
|
47 |
+
->addAttributeToSelect('is_active')
|
48 |
+
->setProductStoreId($storeId)
|
49 |
+
->setLoadProductCount(true)
|
50 |
+
->setStoreId($storeId);
|
51 |
+
|
52 |
+
$this->setData('category_collection', $collection);
|
53 |
+
}
|
54 |
+
return $collection;
|
55 |
+
}
|
56 |
+
|
57 |
+
public function buildNodeName($node)
|
58 |
+
{
|
59 |
+
$treeSettings = $this->getData('tree_settings');
|
60 |
+
$result = $this->escapeHtml($node->getName());
|
61 |
+
|
62 |
+
$ccpTable = Mage::getSingleton('core/resource')->getTableName('catalog_category_product');
|
63 |
+
$cpeTable = Mage::getSingleton('core/resource')->getTableName('catalog_product_entity');
|
64 |
+
|
65 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
66 |
+
$attributeSetsSql = is_array($listingData['attribute_sets']) ? implode(',', $listingData['attribute_sets'])
|
67 |
+
: (int)$listingData['attribute_sets'];
|
68 |
+
|
69 |
+
$dbSelect = $this->getReadConnection()
|
70 |
+
->select()
|
71 |
+
->from(array('ccp'=>$ccpTable),new Zend_Db_Expr('DISTINCT `ccp`.`product_id`'))
|
72 |
+
->join(array('cpe'=>$cpeTable),'`cpe`.`entity_id` = `ccp`.`product_id`',array())
|
73 |
+
->where('`cpe`.`attribute_set_id` IN (' . $attributeSetsSql . ')')
|
74 |
+
->where('`ccp`.`category_id` = ?',(int)$node->getId());
|
75 |
+
|
76 |
+
//----------------------------
|
77 |
+
if ($treeSettings['show_products_amount'] != false) {
|
78 |
+
if ($treeSettings['hide_products_this_listing']) {
|
79 |
+
$fields = new Zend_Db_Expr('DISTINCT `product_id`');
|
80 |
+
$dbSelect3 = $this->getReadConnection()
|
81 |
+
->select()
|
82 |
+
->from(Mage::getResourceModel('M2ePro/Listing_Product')->getMainTable(),$fields)
|
83 |
+
->where('`component_mode` = ?',$this->getData('component'))
|
84 |
+
->where('`listing_id` = ?',$listingData['id']);
|
85 |
+
|
86 |
+
$dbSelect->where('`ccp`.`product_id` NOT IN ('.$dbSelect3->__toString().')');
|
87 |
+
}
|
88 |
+
$sqlQuery = " SELECT count(`rez`.`product_id`) as `count_products`
|
89 |
+
FROM ( ".$dbSelect->__toString()." ) as `rez` ";
|
90 |
+
|
91 |
+
$countProducts = $this->getReadConnection()
|
92 |
+
->fetchOne($sqlQuery);
|
93 |
+
|
94 |
+
$result .= ' (' . (int)$countProducts . ')';
|
95 |
+
}
|
96 |
+
//----------------------------
|
97 |
+
|
98 |
+
return $result;
|
99 |
+
}
|
100 |
+
|
101 |
+
public function getTreeJson($parentNodeCategory=null)
|
102 |
+
{
|
103 |
+
$rootArray = $this->_getNodeJson($this->getRoot($parentNodeCategory, 6));
|
104 |
+
$json = Zend_Json::encode(isset($rootArray['children']) ? $rootArray['children'] : array());
|
105 |
+
return $json;
|
106 |
+
}
|
107 |
+
|
108 |
+
public function _getNodeJson($node, $level = 0)
|
109 |
+
{
|
110 |
+
// create a node from data array
|
111 |
+
if (is_array($node)) {
|
112 |
+
$node = new Varien_Data_Tree_Node($node, 'entity_id', new Varien_Data_Tree);
|
113 |
+
}
|
114 |
+
|
115 |
+
$item = array();
|
116 |
+
$item['text'] = ''.$this->buildNodeName($node). '';
|
117 |
+
|
118 |
+
//$rootForStores = Mage::getModel('core/store')->getCollection()->loadByCategoryIds(array(
|
119 |
+
// $node->getEntityId()
|
120 |
+
//));
|
121 |
+
$rootForStores = in_array($node->getEntityId(), $this->getRootIds());
|
122 |
+
|
123 |
+
$item['id'] = $node->getId();
|
124 |
+
$item['store_id'] = (int)$this->getStore()->getId();
|
125 |
+
// $item['path'] = $node->getData('path');
|
126 |
+
|
127 |
+
// $item['cls'] = 'folder ' . ($node->getIsActive() ? 'active-category' : 'no-active-category');
|
128 |
+
//$item['allowDrop'] = ($level<3) ? true : false;
|
129 |
+
$allowMove = false;
|
130 |
+
$item['allowDrop'] = $allowMove;
|
131 |
+
// disallow drag if it's first level and category is root of a store
|
132 |
+
$item['allowDrag'] = $allowMove && (($node->getLevel()==1 && $rootForStores) ? false : true);
|
133 |
+
|
134 |
+
if ((int)$node->getChildrenCount()>0) {
|
135 |
+
$item['children'] = array();
|
136 |
+
}
|
137 |
+
|
138 |
+
$isParent = false;
|
139 |
+
|
140 |
+
if ($node->hasChildren()) {
|
141 |
+
$item['children'] = array();
|
142 |
+
if (!($this->getUseAjax() && $node->getLevel() > 1 && !$isParent)) {
|
143 |
+
foreach ($node->getChildren() as $child) {
|
144 |
+
$item['children'][] = $this->_getNodeJson($child, $level+1);
|
145 |
+
}
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
if ($isParent || $node->getLevel() < 2) {
|
150 |
+
$item['expanded'] = true;
|
151 |
+
}
|
152 |
+
|
153 |
+
return $item;
|
154 |
+
}
|
155 |
+
}
|
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,147 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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_Grid_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 |
+
// Set header text
|
23 |
+
//------------------------------
|
24 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
25 |
+
|
26 |
+
if (isset($listingData['id'])) {
|
27 |
+
|
28 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
29 |
+
$component = Mage::helper('M2ePro/Component')->getComponentTitle($listingData['component_mode']);
|
30 |
+
$headerText = Mage::helper('M2ePro')->__("Log For %component_name% Listing", $component);
|
31 |
+
} else {
|
32 |
+
$headerText = Mage::helper('M2ePro')->__("Log For Listing");
|
33 |
+
}
|
34 |
+
|
35 |
+
$this->_headerText = $headerText;
|
36 |
+
$this->_headerText .= ' "'.$this->escapeHtml($listingData['title']).'"';
|
37 |
+
} else {
|
38 |
+
$this->_headerText = Mage::helper('M2ePro')->__('Listings Log');
|
39 |
+
}
|
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 |
+
if (!is_null($this->getRequest()->getParam('back'))) {
|
52 |
+
//------------------------------
|
53 |
+
$url = Mage::helper('M2ePro')->getBackUrl('*/adminhtml_common_listing/index');
|
54 |
+
$this->_addButton('back', array(
|
55 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
56 |
+
'onclick' => 'CommonHandlerObj.back_click(\''.$url.'\')',
|
57 |
+
'class' => 'back'
|
58 |
+
));
|
59 |
+
//------------------------------
|
60 |
+
}
|
61 |
+
|
62 |
+
//------------------------------
|
63 |
+
$this->_addButton('goto_listings', array(
|
64 |
+
'label' => Mage::helper('M2ePro')->__('Listings'),
|
65 |
+
'onclick' => 'setLocation(\'' .$this->getUrl('*/adminhtml_common_listing/index').'\')',
|
66 |
+
'class' => 'button_link'
|
67 |
+
));
|
68 |
+
//------------------------------
|
69 |
+
|
70 |
+
//------------------------------
|
71 |
+
if (isset($listingData['id'])) {
|
72 |
+
//------------------------------
|
73 |
+
$url = Mage::helper('M2ePro/View')->getUrl(
|
74 |
+
new Varien_Object($listingData), 'listing', 'edit', array('id' => $listingData['id'])
|
75 |
+
);
|
76 |
+
$this->_addButton('goto_listing_settings', array(
|
77 |
+
'label' => Mage::helper('M2ePro')->__('Listing Settings'),
|
78 |
+
'onclick' => 'setLocation(\'' .$url.'\')',
|
79 |
+
'class' => 'button_link'
|
80 |
+
));
|
81 |
+
//------------------------------
|
82 |
+
|
83 |
+
//------------------------------
|
84 |
+
$url = Mage::helper('M2ePro/View')->getUrl(
|
85 |
+
new Varien_Object($listingData), 'listing', 'view', array('id' => $listingData['id'])
|
86 |
+
);
|
87 |
+
$this->_addButton('goto_listing_items', array(
|
88 |
+
'label' => Mage::helper('M2ePro')->__('Listing Items'),
|
89 |
+
'onclick' => 'setLocation(\'' .$url.'\')',
|
90 |
+
'class' => 'button_link'
|
91 |
+
));
|
92 |
+
//------------------------------
|
93 |
+
}
|
94 |
+
|
95 |
+
//------------------------------
|
96 |
+
$this->_addButton('reset', array(
|
97 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
98 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
99 |
+
'class' => 'reset'
|
100 |
+
));
|
101 |
+
//------------------------------
|
102 |
+
|
103 |
+
if (isset($listingData['id'])) {
|
104 |
+
//------------------------------
|
105 |
+
$url = $this->getUrl('*/*/*');
|
106 |
+
$this->_addButton('show_general_log', array(
|
107 |
+
'label' => Mage::helper('M2ePro')->__('Show General Log'),
|
108 |
+
'onclick' => 'setLocation(\'' . $url .'\')',
|
109 |
+
'class' => 'show_general_log'
|
110 |
+
));
|
111 |
+
//------------------------------
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
// ########################################
|
116 |
+
|
117 |
+
public function getGridHtml()
|
118 |
+
{
|
119 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_listing_log_help');
|
120 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
121 |
+
}
|
122 |
+
|
123 |
+
protected function _toHtml()
|
124 |
+
{
|
125 |
+
$translations = json_encode(array(
|
126 |
+
'Description' => Mage::helper('M2ePro')->__('Description')
|
127 |
+
));
|
128 |
+
|
129 |
+
$javascript = <<<JAVASCIRPT
|
130 |
+
|
131 |
+
<script type="text/javascript">
|
132 |
+
|
133 |
+
M2ePro.translator.add({$translations});
|
134 |
+
|
135 |
+
Event.observe(window, 'load', function() {
|
136 |
+
LogHandlerObj = new LogHandler();
|
137 |
+
});
|
138 |
+
|
139 |
+
</script>
|
140 |
+
|
141 |
+
JAVASCIRPT;
|
142 |
+
|
143 |
+
return $javascript . parent::_toHtml();
|
144 |
+
}
|
145 |
+
|
146 |
+
// ########################################
|
147 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Log/Grid.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_Listing_Log_Grid extends Ess_M2ePro_Block_Adminhtml_Listing_Log_Grid
|
8 |
+
{
|
9 |
+
// ########################################
|
10 |
+
|
11 |
+
protected function getActionTitles()
|
12 |
+
{
|
13 |
+
return Mage::getModel('M2ePro/Listing_Log')->getActionsTitles();
|
14 |
+
}
|
15 |
+
|
16 |
+
// ########################################
|
17 |
+
|
18 |
+
public function callbackColumnListingTitle($value, $row, $column, $isExport)
|
19 |
+
{
|
20 |
+
if (strlen($value) > 50) {
|
21 |
+
$value = substr($value, 0, 50) . '...';
|
22 |
+
}
|
23 |
+
|
24 |
+
$value = Mage::helper('M2ePro')->escapeHtml($value);
|
25 |
+
|
26 |
+
if ($row->getData('listing_id')) {
|
27 |
+
$url = $this->getUrl(
|
28 |
+
'*/adminhtml_common_'.$row->getData('component_mode').'_listing/view',
|
29 |
+
array('id' => $row->getData('listing_id'))
|
30 |
+
);
|
31 |
+
$value = '<a target="_blank" href="'.$url.'">' . $value . '</a>';
|
32 |
+
}
|
33 |
+
|
34 |
+
return $value;
|
35 |
+
}
|
36 |
+
|
37 |
+
// ########################################
|
38 |
+
}
|
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/listing/log/help.phtml');
|
19 |
+
}
|
20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
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing_Other 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')->__('3rd Party Listings');
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
// Set buttons actions
|
21 |
+
//------------------------------
|
22 |
+
$this->removeButton('back');
|
23 |
+
$this->removeButton('reset');
|
24 |
+
$this->removeButton('delete');
|
25 |
+
$this->removeButton('add');
|
26 |
+
$this->removeButton('save');
|
27 |
+
$this->removeButton('edit');
|
28 |
+
|
29 |
+
if (!is_null($this->getRequest()->getParam('back'))) {
|
30 |
+
//------------------------------
|
31 |
+
$url = Mage::helper('M2ePro')->getBackUrl('*/adminhtml_common_listing/index');
|
32 |
+
$this->_addButton('back', array(
|
33 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
34 |
+
'onclick' => 'CommonHandlerObj.back_click(\''.$url.'\')',
|
35 |
+
'class' => 'back'
|
36 |
+
));
|
37 |
+
//------------------------------
|
38 |
+
}
|
39 |
+
|
40 |
+
//------------------------------
|
41 |
+
$url = $this->getUrl('*/adminhtml_common_listing/index');
|
42 |
+
$this->_addButton('goto_listings', array(
|
43 |
+
'label' => Mage::helper('M2ePro')->__('Listings'),
|
44 |
+
'onclick' => 'setLocation(\''. $url .'\')',
|
45 |
+
'class' => 'button_link'
|
46 |
+
));
|
47 |
+
//------------------------------
|
48 |
+
|
49 |
+
//------------------------------
|
50 |
+
$url = $this->getUrl('*/adminhtml_common_log/listingOther');
|
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('reset', array(
|
60 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
61 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
62 |
+
'class' => 'reset'
|
63 |
+
));
|
64 |
+
//------------------------------
|
65 |
+
|
66 |
+
//------------------------------
|
67 |
+
$this->useAjax = true;
|
68 |
+
$this->tabsAjaxUrls = array(
|
69 |
+
self::TAB_ID_AMAZON => $this->getUrl('*/adminhtml_common_amazon_listing_other/index'),
|
70 |
+
self::TAB_ID_BUY => $this->getUrl('*/adminhtml_common_buy_listing_other/index'),
|
71 |
+
self::TAB_ID_PLAY => $this->getUrl('*/adminhtml_common_play_listing_other/index'),
|
72 |
+
);
|
73 |
+
|
74 |
+
$this->isAjax = json_encode($this->getRequest()->isXmlHttpRequest());
|
75 |
+
//------------------------------
|
76 |
+
}
|
77 |
+
|
78 |
+
// ########################################
|
79 |
+
|
80 |
+
protected function getAmazonTabBlock()
|
81 |
+
{
|
82 |
+
if (!$this->getChild('amazon_tab')) {
|
83 |
+
$this->setChild(
|
84 |
+
'amazon_tab', $this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_listing_other_grid')
|
85 |
+
);
|
86 |
+
}
|
87 |
+
return $this->getChild('amazon_tab');
|
88 |
+
}
|
89 |
+
|
90 |
+
public function getAmazonTabHtml()
|
91 |
+
{
|
92 |
+
/** @var $helper Ess_M2ePro_Helper_Data */
|
93 |
+
$helper = Mage::helper('M2ePro');
|
94 |
+
$componentMode = Ess_M2ePro_Helper_Component_Amazon::NICK;
|
95 |
+
|
96 |
+
$prepareData = $this->getUrl('*/adminhtml_listing_other_moving/prepareMoveToListing');
|
97 |
+
$createDefaultListingUrl = $this->getUrl('*/adminhtml_listing_other_moving/createDefaultListing');
|
98 |
+
$getMoveToListingGridHtml = $this->getUrl('*/adminhtml_listing_other_moving/moveToListingGrid');
|
99 |
+
$getFailedProductsGridHtml = $this->getUrl('*/adminhtml_listing_other_moving/getFailedProductsGrid');
|
100 |
+
$tryToMoveToListing = $this->getUrl('*/adminhtml_listing_other_moving/tryToMoveToListing');
|
101 |
+
$moveToListing = $this->getUrl('*/adminhtml_listing_other_moving/moveToListing');
|
102 |
+
|
103 |
+
$mapAutoToProductUrl = $this->getUrl('*/adminhtml_listing_other_mapping/autoMap');
|
104 |
+
|
105 |
+
$removingProductsUrl = $this->getUrl('*/adminhtml_common_listing_other/removing');
|
106 |
+
$unmappingProductsUrl = $this->getUrl('*/adminhtml_listing_other_mapping/unmapping');
|
107 |
+
|
108 |
+
$someProductsWereNotMappedMessage = 'No matches were found. Please change the mapping attributes in <strong>';
|
109 |
+
$someProductsWereNotMappedMessage .= 'Configuration > Account > 3rd Party Listings</strong> ';
|
110 |
+
$someProductsWereNotMappedMessage .= 'or try to map manually.';
|
111 |
+
$someProductsWereNotMappedMessage = $helper->escapeJs($helper->__($someProductsWereNotMappedMessage));
|
112 |
+
|
113 |
+
$successfullyMappedMessage = $helper->escapeJs($helper->__('Product was successfully mapped.'));
|
114 |
+
|
115 |
+
$createListing = $helper->escapeJs($helper->__(
|
116 |
+
'Listings, which have the same Marketplace and Account were not found.'
|
117 |
+
));
|
118 |
+
$createListing .= $helper->escapeJs($helper->__('Would you like to create one with default settings ?'));
|
119 |
+
$popupTitle = $helper->escapeJs($helper->__('Moving Amazon Items.'));
|
120 |
+
$failedProductsPopupTitle = $helper->escapeJs($helper->__('Products failed to move'));
|
121 |
+
|
122 |
+
$confirmMessage = $helper->escapeJs($helper->__('Are you sure?'));
|
123 |
+
|
124 |
+
$successfullyMovedMessage = $helper->escapeJs($helper->__('Product(s) was successfully moved.'));
|
125 |
+
$productsWereNotMovedMessage = $helper->escapeJs(
|
126 |
+
$helper->__('Products were not moved. <a target="_blank" href="%url%">View log</a> for details.')
|
127 |
+
);
|
128 |
+
$someProductsWereNotMovedMessage = $helper->escapeJs($helper->__(
|
129 |
+
'Some of the products were not moved. <a target="_blank" href="%url%">View log</a> for details.'
|
130 |
+
));
|
131 |
+
|
132 |
+
$notEnoughDataMessage = $helper->escapeJs($helper->__('Not enough data'));
|
133 |
+
$successfullyUnmappedMessage = $helper->escapeJs($helper->__('Product(s) was successfully unmapped.'));
|
134 |
+
$successfullyRemovedMessage = $helper->escapeJs($helper->__('Product(s) was successfully removed.'));
|
135 |
+
|
136 |
+
$viewAllProductLogMessage = $helper->escapeJs($helper->__('View All Product Log.'));
|
137 |
+
|
138 |
+
$selectItemsMessage = $helper->escapeJs(
|
139 |
+
$helper->__('Please select the products you want to perform the action on.')
|
140 |
+
);
|
141 |
+
$selectActionMessage = $helper->escapeJs($helper->__('Please select action.'));
|
142 |
+
|
143 |
+
$processingDataMessage = $helper->escapeJs($helper->__('Processing %product_title% product(s).'));
|
144 |
+
|
145 |
+
$autoMapProgressTitle = $helper->escapeJs($helper->__('Map Item(s) to Products'));
|
146 |
+
$selectOnlyMapped = $helper->escapeJs($helper->__('Only mapped products must be selected.'));
|
147 |
+
$selectTheSameTypeProducts = $helper->escapeJs(
|
148 |
+
$helper->__('Selected items must belong to the same Account and Marketplace.')
|
149 |
+
);
|
150 |
+
|
151 |
+
$successWord = $helper->escapeJs($helper->__('Success'));
|
152 |
+
$noticeWord = $helper->escapeJs($helper->__('Notice'));
|
153 |
+
$warningWord = $helper->escapeJs($helper->__('Warning'));
|
154 |
+
$errorWord = $helper->escapeJs($helper->__('Error'));
|
155 |
+
$closeWord = $helper->escapeJs($helper->__('Close'));
|
156 |
+
|
157 |
+
$javascriptsMain = <<<JAVASCRIPT
|
158 |
+
<script type="text/javascript">
|
159 |
+
|
160 |
+
M2eProAmazon = {};
|
161 |
+
M2eProAmazon.url = {};
|
162 |
+
M2eProAmazon.formData = {};
|
163 |
+
M2eProAmazon.customData = {};
|
164 |
+
M2eProAmazon.text = {};
|
165 |
+
|
166 |
+
M2eProAmazon.url.prepareData = '{$prepareData}';
|
167 |
+
M2eProAmazon.url.createDefaultListing = '{$createDefaultListingUrl}';
|
168 |
+
M2eProAmazon.url.getGridHtml = '{$getMoveToListingGridHtml}';
|
169 |
+
M2eProAmazon.url.getFailedProductsGridHtml = '{$getFailedProductsGridHtml}';
|
170 |
+
M2eProAmazon.url.tryToMoveToListing = '{$tryToMoveToListing}';
|
171 |
+
M2eProAmazon.url.moveToListing = '{$moveToListing}';
|
172 |
+
|
173 |
+
M2eProAmazon.url.mapAutoToProduct = '{$mapAutoToProductUrl}';
|
174 |
+
|
175 |
+
M2eProAmazon.url.removingProducts = '{$removingProductsUrl}';
|
176 |
+
M2eProAmazon.url.unmappingProducts = '{$unmappingProductsUrl}';
|
177 |
+
|
178 |
+
M2eProAmazon.text.create_listing = '{$createListing}';
|
179 |
+
M2eProAmazon.text.popup_title = '{$popupTitle}';
|
180 |
+
M2eProAmazon.text.failed_products_popup_title = '{$failedProductsPopupTitle}';
|
181 |
+
M2eProAmazon.text.confirm = '{$confirmMessage}';
|
182 |
+
M2eProAmazon.text.successfully_moved = '{$successfullyMovedMessage}';
|
183 |
+
M2eProAmazon.text.products_were_not_moved = '{$productsWereNotMovedMessage}';
|
184 |
+
M2eProAmazon.text.some_products_were_not_moved = '{$someProductsWereNotMovedMessage}';
|
185 |
+
M2eProAmazon.text.not_enough_data = '{$notEnoughDataMessage}';
|
186 |
+
M2eProAmazon.text.successfully_unmapped = '{$successfullyUnmappedMessage}';
|
187 |
+
M2eProAmazon.text.successfully_removed = '{$successfullyRemovedMessage}';
|
188 |
+
|
189 |
+
M2eProAmazon.text.select_items_message = '{$selectItemsMessage}';
|
190 |
+
M2eProAmazon.text.select_action_message = '{$selectActionMessage}';
|
191 |
+
|
192 |
+
M2eProAmazon.text.automap_progress_title = '{$autoMapProgressTitle}';
|
193 |
+
M2eProAmazon.text.processing_data_message = '{$processingDataMessage}';
|
194 |
+
M2eProAmazon.text.successfully_mapped = '{$successfullyMappedMessage}';
|
195 |
+
M2eProAmazon.text.failed_mapped = '{$someProductsWereNotMappedMessage}';
|
196 |
+
|
197 |
+
M2eProAmazon.text.select_only_mapped_products = '{$selectOnlyMapped}';
|
198 |
+
M2eProAmazon.text.select_the_same_type_products = '{$selectTheSameTypeProducts}';
|
199 |
+
|
200 |
+
M2eProAmazon.text.view_all_product_log_message = '{$viewAllProductLogMessage}';
|
201 |
+
|
202 |
+
M2eProAmazon.text.success_word = '{$successWord}';
|
203 |
+
M2eProAmazon.text.notice_word = '{$noticeWord}';
|
204 |
+
M2eProAmazon.text.warning_word = '{$warningWord}';
|
205 |
+
M2eProAmazon.text.error_word = '{$errorWord}';
|
206 |
+
M2eProAmazon.text.close_word = '{$closeWord}';
|
207 |
+
|
208 |
+
M2eProAmazon.customData.componentMode = '{$componentMode}';
|
209 |
+
M2eProAmazon.customData.gridId = 'amazonListingOtherGrid';
|
210 |
+
|
211 |
+
var init = function () {
|
212 |
+
AmazonListingOtherGridHandlerObj = new AmazonListingOtherGridHandler('amazonListingOtherGrid');
|
213 |
+
AmazonListingOtherMappingHandlerObj = new ListingOtherMappingHandler(
|
214 |
+
AmazonListingOtherGridHandlerObj,
|
215 |
+
'amazon'
|
216 |
+
);
|
217 |
+
|
218 |
+
AmazonListingOtherGridHandlerObj.movingHandler.setOptions(M2eProAmazon);
|
219 |
+
AmazonListingOtherGridHandlerObj.autoMappingHandler.setOptions(M2eProAmazon);
|
220 |
+
AmazonListingOtherGridHandlerObj.removingHandler.setOptions(M2eProAmazon);
|
221 |
+
AmazonListingOtherGridHandlerObj.unmappingHandler.setOptions(M2eProAmazon);
|
222 |
+
}
|
223 |
+
|
224 |
+
if ($$('.tabs-horiz').first()) {
|
225 |
+
var amazonTabId = $$('.tabs-horiz').first().id + '_amazon';
|
226 |
+
$(amazonTabId).observe('click', init);
|
227 |
+
}
|
228 |
+
|
229 |
+
{$this->isAjax} ? init()
|
230 |
+
: Event.observe(window, 'load', init);
|
231 |
+
|
232 |
+
</script>
|
233 |
+
JAVASCRIPT;
|
234 |
+
|
235 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_listing_other_help');
|
236 |
+
|
237 |
+
return $javascriptsMain .
|
238 |
+
$helpBlock->toHtml() .
|
239 |
+
$this->getAmazonTabBlockFilterHtml() .
|
240 |
+
parent::getAmazonTabHtml();
|
241 |
+
}
|
242 |
+
|
243 |
+
private function getAmazonTabBlockFilterHtml()
|
244 |
+
{
|
245 |
+
$marketplaceFilterBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_marketplace_switcher', '', array(
|
246 |
+
'component_mode' => Ess_M2ePro_Helper_Component_Amazon::NICK,
|
247 |
+
'controller_name' => 'adminhtml_common_listing_other'
|
248 |
+
));
|
249 |
+
$accountFilterBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_account_switcher', '', array(
|
250 |
+
'component_mode' => Ess_M2ePro_Helper_Component_Amazon::NICK,
|
251 |
+
'controller_name' => 'adminhtml_common_listing_other'
|
252 |
+
));
|
253 |
+
|
254 |
+
return '<div class="filter_block">' .
|
255 |
+
$marketplaceFilterBlock->toHtml() .
|
256 |
+
$accountFilterBlock->toHtml() .
|
257 |
+
'</div>';
|
258 |
+
}
|
259 |
+
|
260 |
+
// ########################################
|
261 |
+
|
262 |
+
protected function getBuyTabBlock()
|
263 |
+
{
|
264 |
+
if (!$this->getChild('buy_tab')) {
|
265 |
+
$this->setChild(
|
266 |
+
'buy_tab',
|
267 |
+
$this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_listing_other_grid')
|
268 |
+
);
|
269 |
+
}
|
270 |
+
return $this->getChild('buy_tab');
|
271 |
+
}
|
272 |
+
|
273 |
+
public function getBuyTabHtml()
|
274 |
+
{
|
275 |
+
/** @var $helper Ess_M2ePro_Helper_Data */
|
276 |
+
$helper = Mage::helper('M2ePro');
|
277 |
+
$componentMode = Ess_M2ePro_Helper_Component_Buy::NICK;
|
278 |
+
|
279 |
+
$logViewUrl = $this->getUrl(
|
280 |
+
'*/adminhtml_common_log/listingOther',
|
281 |
+
array(
|
282 |
+
'filter' => base64_encode('component_mode=' . Ess_M2ePro_Helper_Component_Buy::NICK),
|
283 |
+
'back' => $helper->makeBackUrlParam('*/adminhtml_common_listing_other/index/tab/' . $componentMode)
|
284 |
+
)
|
285 |
+
);
|
286 |
+
|
287 |
+
$prepareData = $this->getUrl('*/adminhtml_listing_other_moving/prepareMoveToListing');
|
288 |
+
$createDefaultListingUrl = $this->getUrl('*/adminhtml_listing_other_moving/createDefaultListing');
|
289 |
+
$getMoveToListingGridHtml = $this->getUrl('*/adminhtml_listing_other_moving/moveToListingGrid');
|
290 |
+
$getFailedProductsGridHtml = $this->getUrl('*/adminhtml_listing_other_moving/getFailedProductsGrid');
|
291 |
+
$tryToMoveToListing = $this->getUrl('*/adminhtml_listing_other_moving/tryToMoveToListing');
|
292 |
+
$moveToListing = $this->getUrl('*/adminhtml_listing_other_moving/moveToListing');
|
293 |
+
|
294 |
+
$mapAutoToProductUrl = $this->getUrl('*/adminhtml_listing_other_mapping/autoMap');
|
295 |
+
|
296 |
+
$removingProductsUrl = $this->getUrl('*/adminhtml_common_listing_other/removing');
|
297 |
+
$unmappingProductsUrl = $this->getUrl('*/adminhtml_listing_other_mapping/unmapping');
|
298 |
+
|
299 |
+
$someProductsWereNotMappedMessage = 'No matches were found. Please change the mapping attributes in <strong>';
|
300 |
+
$someProductsWereNotMappedMessage .= 'Configuration > Account > 3rd Party Listings</strong> ';
|
301 |
+
$someProductsWereNotMappedMessage .= 'or try to map manually.';
|
302 |
+
$someProductsWereNotMappedMessage = $helper->escapeJs($helper->__($someProductsWereNotMappedMessage));
|
303 |
+
|
304 |
+
$successfullyMappedMessage = $helper->escapeJs($helper->__('Product was successfully mapped.'));
|
305 |
+
|
306 |
+
$createListing = $helper->escapeJs($helper->__(
|
307 |
+
'Listings, which have the same Marketplace and Account were not found.'
|
308 |
+
));
|
309 |
+
$createListing .= $helper->escapeJs($helper->__('Would you like to create one with default settings ?'));
|
310 |
+
$popupTitle = $helper->escapeJs($helper->__('Moving Rakuten.com Items.'));
|
311 |
+
$failedProductsPopupTitle = $helper->escapeJs($helper->__('Products failed to move'));
|
312 |
+
|
313 |
+
$confirmMessage = $helper->escapeJs($helper->__('Are you sure?'));
|
314 |
+
|
315 |
+
$successfullyMovedMessage = $helper->escapeJs($helper->__('Product(s) was successfully moved.'));
|
316 |
+
$productsWereNotMovedMessage = $helper->escapeJs(
|
317 |
+
$helper->__('Products were not moved. <a target="_blank" href="%url%">View log</a> for details.')
|
318 |
+
);
|
319 |
+
$someProductsWereNotMovedMessage = $helper->escapeJs($helper->__(
|
320 |
+
'Some of the products were not moved. <a target="_blank" href="%url%">View log</a> for details.'
|
321 |
+
));
|
322 |
+
|
323 |
+
$notEnoughDataMessage = $helper->escapeJs($helper->__('Not enough data.'));
|
324 |
+
$successfullyUnmappedMessage = $helper->escapeJs($helper->__('Product(s) was successfully unmapped.'));
|
325 |
+
$successfullyRemovedMessage = $helper->escapeJs($helper->__('Product(s) was successfully removed.'));
|
326 |
+
|
327 |
+
$viewAllProductLogMessage = $helper->escapeJs($helper->__('View All Product Log.'));
|
328 |
+
|
329 |
+
$selectItemsMessage = $helper->escapeJs(
|
330 |
+
$helper->__('Please select the products you want to perform the action on.')
|
331 |
+
);
|
332 |
+
$selectActionMessage = $helper->escapeJs($helper->__('Please select action.'));
|
333 |
+
|
334 |
+
$processingDataMessage = $helper->escapeJs($helper->__('Processing %product_title% product(s).'));
|
335 |
+
|
336 |
+
$successWord = $helper->escapeJs($helper->__('Success'));
|
337 |
+
$noticeWord = $helper->escapeJs($helper->__('Notice'));
|
338 |
+
$warningWord = $helper->escapeJs($helper->__('Warning'));
|
339 |
+
$errorWord = $helper->escapeJs($helper->__('Error'));
|
340 |
+
$closeWord = $helper->escapeJs($helper->__('Close'));
|
341 |
+
|
342 |
+
$autoMapProgressTitle = $helper->escapeJs($helper->__('Map Item(s) to Products'));
|
343 |
+
$selectOnlyMapped = $helper->escapeJs($helper->__('Only mapped products must be selected.'));
|
344 |
+
$selectTheSameTypeProducts = $helper->escapeJs(
|
345 |
+
$helper->__('Selected items must belong to the same Account and Marketplace.')
|
346 |
+
);
|
347 |
+
|
348 |
+
$javascriptsMain = <<<JAVASCRIPT
|
349 |
+
<script type="text/javascript">
|
350 |
+
|
351 |
+
M2eProBuy = {};
|
352 |
+
M2eProBuy.url = {};
|
353 |
+
M2eProBuy.formData = {};
|
354 |
+
M2eProBuy.customData = {};
|
355 |
+
M2eProBuy.text = {};
|
356 |
+
|
357 |
+
M2eProBuy.url.logViewUrl = '{$logViewUrl}';
|
358 |
+
M2eProBuy.url.prepareData = '{$prepareData}';
|
359 |
+
M2eProBuy.url.createDefaultListing = '{$createDefaultListingUrl}';
|
360 |
+
M2eProBuy.url.getGridHtml = '{$getMoveToListingGridHtml}';
|
361 |
+
M2eProBuy.url.getFailedProductsGridHtml = '{$getFailedProductsGridHtml}';
|
362 |
+
M2eProBuy.url.tryToMoveToListing = '{$tryToMoveToListing}';
|
363 |
+
M2eProBuy.url.moveToListing = '{$moveToListing}';
|
364 |
+
M2eProBuy.url.mapAutoToProduct = '{$mapAutoToProductUrl}';
|
365 |
+
M2eProBuy.url.removingProducts = '{$removingProductsUrl}';
|
366 |
+
M2eProBuy.url.unmappingProducts = '{$unmappingProductsUrl}';
|
367 |
+
|
368 |
+
M2eProBuy.text.create_listing = '{$createListing}';
|
369 |
+
M2eProBuy.text.popup_title = '{$popupTitle}';
|
370 |
+
M2eProBuy.text.failed_products_popup_title = '{$failedProductsPopupTitle}';
|
371 |
+
M2eProBuy.text.confirm = '{$confirmMessage}';
|
372 |
+
M2eProBuy.text.successfully_moved = '{$successfullyMovedMessage}';
|
373 |
+
M2eProBuy.text.products_were_not_moved = '{$productsWereNotMovedMessage}';
|
374 |
+
M2eProBuy.text.some_products_were_not_moved = '{$someProductsWereNotMovedMessage}';
|
375 |
+
M2eProBuy.text.not_enough_data = '{$notEnoughDataMessage}';
|
376 |
+
M2eProBuy.text.successfully_unmapped = '{$successfullyUnmappedMessage}';
|
377 |
+
M2eProBuy.text.successfully_removed = '{$successfullyRemovedMessage}';
|
378 |
+
|
379 |
+
M2eProBuy.text.select_items_message = '{$selectItemsMessage}';
|
380 |
+
M2eProBuy.text.select_action_message = '{$selectActionMessage}';
|
381 |
+
|
382 |
+
M2eProBuy.text.automap_progress_title = '{$autoMapProgressTitle}';
|
383 |
+
M2eProBuy.text.processing_data_message = '{$processingDataMessage}';
|
384 |
+
M2eProBuy.text.successfully_mapped = '{$successfullyMappedMessage}';
|
385 |
+
M2eProBuy.text.failed_mapped = '{$someProductsWereNotMappedMessage}';
|
386 |
+
|
387 |
+
M2eProBuy.text.select_only_mapped_products = '{$selectOnlyMapped}';
|
388 |
+
M2eProBuy.text.select_the_same_type_products = '{$selectTheSameTypeProducts}';
|
389 |
+
|
390 |
+
M2eProBuy.text.view_all_product_log_message = '{$viewAllProductLogMessage}';
|
391 |
+
|
392 |
+
M2eProBuy.text.success_word = '{$successWord}';
|
393 |
+
M2eProBuy.text.notice_word = '{$noticeWord}';
|
394 |
+
M2eProBuy.text.warning_word = '{$warningWord}';
|
395 |
+
M2eProBuy.text.error_word = '{$errorWord}';
|
396 |
+
M2eProBuy.text.close_word = '{$closeWord}';
|
397 |
+
|
398 |
+
M2eProBuy.customData.componentMode = '{$componentMode}';
|
399 |
+
M2eProBuy.customData.gridId = 'buyListingOtherGrid';
|
400 |
+
|
401 |
+
var init = function () {
|
402 |
+
BuyListingOtherGridHandlerObj = new BuyListingOtherGridHandler('buyListingOtherGrid');
|
403 |
+
BuyListingOtherMappingHandlerObj = new ListingOtherMappingHandler(
|
404 |
+
BuyListingOtherGridHandlerObj,
|
405 |
+
'buy'
|
406 |
+
);
|
407 |
+
|
408 |
+
BuyListingOtherGridHandlerObj.movingHandler.setOptions(M2eProBuy);
|
409 |
+
BuyListingOtherGridHandlerObj.autoMappingHandler.setOptions(M2eProBuy);
|
410 |
+
BuyListingOtherGridHandlerObj.removingHandler.setOptions(M2eProBuy);
|
411 |
+
BuyListingOtherGridHandlerObj.unmappingHandler.setOptions(M2eProBuy);
|
412 |
+
}
|
413 |
+
|
414 |
+
if ($$('.tabs-horiz').first()) {
|
415 |
+
var buyTabId = $$('.tabs-horiz').first().id + '_buy';
|
416 |
+
$(buyTabId).observe('click', init);
|
417 |
+
}
|
418 |
+
|
419 |
+
{$this->isAjax} ? init()
|
420 |
+
: Event.observe(window, 'load', init);
|
421 |
+
</script>
|
422 |
+
JAVASCRIPT;
|
423 |
+
|
424 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_listing_other_help');
|
425 |
+
|
426 |
+
return $javascriptsMain .
|
427 |
+
$helpBlock->toHtml() .
|
428 |
+
$this->getBuyTabBlockFilterHtml() .
|
429 |
+
parent::getBuyTabHtml();
|
430 |
+
}
|
431 |
+
|
432 |
+
private function getBuyTabBlockFilterHtml()
|
433 |
+
{
|
434 |
+
$marketplaceFilterBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_marketplace_switcher', '', array(
|
435 |
+
'component_mode' => Ess_M2ePro_Helper_Component_Buy::NICK,
|
436 |
+
'controller_name' => 'adminhtml_common_listing_other'
|
437 |
+
));
|
438 |
+
$accountFilterBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_account_switcher', '', array(
|
439 |
+
'component_mode' => Ess_M2ePro_Helper_Component_Buy::NICK,
|
440 |
+
'controller_name' => 'adminhtml_common_listing_other'
|
441 |
+
));
|
442 |
+
|
443 |
+
return '<div class="filter_block">' .
|
444 |
+
$marketplaceFilterBlock->toHtml() .
|
445 |
+
$accountFilterBlock->toHtml() .
|
446 |
+
'</div>';
|
447 |
+
}
|
448 |
+
|
449 |
+
// ########################################
|
450 |
+
|
451 |
+
protected function getPlayTabBlock()
|
452 |
+
{
|
453 |
+
if (!$this->getChild('play_tab')) {
|
454 |
+
$this->setChild(
|
455 |
+
'play_tab',
|
456 |
+
$this->getLayout()->createBlock('M2ePro/adminhtml_common_play_listing_other_grid')
|
457 |
+
);
|
458 |
+
}
|
459 |
+
return $this->getChild('play_tab');
|
460 |
+
}
|
461 |
+
|
462 |
+
public function getPlayTabHtml()
|
463 |
+
{
|
464 |
+
/** @var $helper Ess_M2ePro_Helper_Data */
|
465 |
+
$helper = Mage::helper('M2ePro');
|
466 |
+
$componentMode = Ess_M2ePro_Helper_Component_Play::NICK;
|
467 |
+
|
468 |
+
$logViewUrl = $this->getUrl(
|
469 |
+
'*/adminhtml_common_log/listingOther',
|
470 |
+
array(
|
471 |
+
'filter' => base64_encode('component_mode=' . Ess_M2ePro_Helper_Component_Play::NICK),
|
472 |
+
'back' => $helper->makeBackUrlParam(
|
473 |
+
'*/adminhtml_common_listing_other/index',
|
474 |
+
array(
|
475 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_PLAY
|
476 |
+
)
|
477 |
+
)
|
478 |
+
)
|
479 |
+
);
|
480 |
+
|
481 |
+
$prepareData = $this->getUrl('*/adminhtml_listing_other_moving/prepareMoveToListing');
|
482 |
+
$createDefaultListingUrl = $this->getUrl('*/adminhtml_listing_other_moving/createDefaultListing');
|
483 |
+
$getMoveToListingGridHtml = $this->getUrl('*/adminhtml_listing_other_moving/moveToListingGrid');
|
484 |
+
$getFailedProductsGridHtml = $this->getUrl('*/adminhtml_listing_other_moving/getFailedProductsGrid');
|
485 |
+
$tryToMoveToListing = $this->getUrl('*/adminhtml_listing_other_moving/tryToMoveToListing');
|
486 |
+
$moveToListing = $this->getUrl('*/adminhtml_listing_other_moving/moveToListing');
|
487 |
+
|
488 |
+
$mapAutoToProductUrl = $this->getUrl('*/adminhtml_listing_other_mapping/autoMap');
|
489 |
+
|
490 |
+
$removingProductsUrl = $this->getUrl('*/adminhtml_common_listing_other/removing');
|
491 |
+
$unmappingProductsUrl = $this->getUrl('*/adminhtml_listing_other_mapping/unmapping');
|
492 |
+
|
493 |
+
$someProductsWereNotMappedMessage = 'No matches were found. Please change the mapping attributes in <strong>';
|
494 |
+
$someProductsWereNotMappedMessage .= 'Configuration > Account > 3rd Party Listings</strong> ';
|
495 |
+
$someProductsWereNotMappedMessage .= 'or try to map manually.';
|
496 |
+
$someProductsWereNotMappedMessage = $helper->escapeJs($helper->__($someProductsWereNotMappedMessage));
|
497 |
+
|
498 |
+
$successfullyMappedMessage = $helper->escapeJs($helper->__('Product was successfully mapped.'));
|
499 |
+
|
500 |
+
$createListing = $helper->escapeJs($helper->__(
|
501 |
+
'Listings, which have the same Marketplace and Account were not found.'
|
502 |
+
));
|
503 |
+
$createListing .= $helper->escapeJs($helper->__('Would you like to create one with default settings ?'));
|
504 |
+
$popupTitle = $helper->escapeJs($helper->__('Moving Play.com Items.'));
|
505 |
+
$failedProductsPopupTitle = $helper->escapeJs($helper->__('Products failed to move'));
|
506 |
+
|
507 |
+
$confirmMessage = $helper->escapeJs($helper->__('Are you sure?'));
|
508 |
+
|
509 |
+
$successfullyMovedMessage = $helper->escapeJs($helper->__('Product(s) was successfully moved.'));
|
510 |
+
$productsWereNotMovedMessage = $helper->escapeJs($helper->__(
|
511 |
+
'Products were not moved. <a target="_blank" href="%url%">View log</a> for details.'
|
512 |
+
));
|
513 |
+
$someProductsWereNotMovedMessage = $helper->escapeJs($helper->__(
|
514 |
+
'Some of the products were not moved. <a target="_blank" href="%url%">View log</a> for details.'
|
515 |
+
));
|
516 |
+
|
517 |
+
$notEnoughDataMessage = $helper->escapeJs($helper->__('Not enough data'));
|
518 |
+
$successfullyUnmappedMessage = $helper->escapeJs($helper->__('Product(s) was successfully unmapped.'));
|
519 |
+
$successfullyRemovedMessage = $helper->escapeJs($helper->__('Product(s) was successfully removed.'));
|
520 |
+
|
521 |
+
$viewAllProductLogMessage = $helper->escapeJs($helper->__('View All Product Log'));
|
522 |
+
|
523 |
+
$selectItemsMessage = $helper->escapeJs(
|
524 |
+
$helper->__('Please select the products you want to perform the action on.')
|
525 |
+
);
|
526 |
+
$selectActionMessage = $helper->escapeJs($helper->__('Please select action.'));
|
527 |
+
|
528 |
+
$processingDataMessage = $helper->escapeJs($helper->__('Processing %product_title% product(s).'));
|
529 |
+
|
530 |
+
$successWord = $helper->escapeJs($helper->__('Success'));
|
531 |
+
$noticeWord = $helper->escapeJs($helper->__('Notice'));
|
532 |
+
$warningWord = $helper->escapeJs($helper->__('Warning'));
|
533 |
+
$errorWord = $helper->escapeJs($helper->__('Error'));
|
534 |
+
$closeWord = $helper->escapeJs($helper->__('Close'));
|
535 |
+
|
536 |
+
$autoMapProgressTitle = $helper->escapeJs($helper->__('Map Item(s) to Products'));
|
537 |
+
$selectOnlyMapped = $helper->escapeJs($helper->__('Only mapped products must be selected.'));
|
538 |
+
$selectTheSameTypeProducts = $helper->escapeJs(
|
539 |
+
$helper->__('Selected items must belong to the same Account and Marketplace.')
|
540 |
+
);
|
541 |
+
|
542 |
+
$javascriptsMain = <<<JAVASCRIPT
|
543 |
+
<script type="text/javascript">
|
544 |
+
|
545 |
+
M2eProPlay = {};
|
546 |
+
M2eProPlay.url = {};
|
547 |
+
M2eProPlay.formData = {};
|
548 |
+
M2eProPlay.customData = {};
|
549 |
+
M2eProPlay.text = {};
|
550 |
+
|
551 |
+
M2eProPlay.url.logViewUrl = '{$logViewUrl}';
|
552 |
+
M2eProPlay.url.prepareData = '{$prepareData}';
|
553 |
+
M2eProPlay.url.createDefaultListing = '{$createDefaultListingUrl}';
|
554 |
+
M2eProPlay.url.getGridHtml = '{$getMoveToListingGridHtml}';
|
555 |
+
M2eProPlay.url.getFailedProductsGridHtml = '{$getFailedProductsGridHtml}';
|
556 |
+
M2eProPlay.url.tryToMoveToListing = '{$tryToMoveToListing}';
|
557 |
+
M2eProPlay.url.moveToListing = '{$moveToListing}';
|
558 |
+
M2eProPlay.url.mapAutoToProduct = '{$mapAutoToProductUrl}';
|
559 |
+
M2eProPlay.url.removingProducts = '{$removingProductsUrl}';
|
560 |
+
M2eProPlay.url.unmappingProducts = '{$unmappingProductsUrl}';
|
561 |
+
|
562 |
+
M2eProPlay.text.create_listing = '{$createListing}';
|
563 |
+
M2eProPlay.text.popup_title = '{$popupTitle}';
|
564 |
+
M2eProPlay.text.failed_products_popup_title = '{$failedProductsPopupTitle}';
|
565 |
+
M2eProPlay.text.confirm = '{$confirmMessage}';
|
566 |
+
M2eProPlay.text.successfully_moved = '{$successfullyMovedMessage}';
|
567 |
+
M2eProPlay.text.products_were_not_moved = '{$productsWereNotMovedMessage}';
|
568 |
+
M2eProPlay.text.some_products_were_not_moved = '{$someProductsWereNotMovedMessage}';
|
569 |
+
M2eProPlay.text.not_enough_data = '{$notEnoughDataMessage}';
|
570 |
+
M2eProPlay.text.successfully_unmapped = '{$successfullyUnmappedMessage}';
|
571 |
+
M2eProPlay.text.successfully_removed = '{$successfullyRemovedMessage}';
|
572 |
+
|
573 |
+
M2eProPlay.text.select_items_message = '{$selectItemsMessage}';
|
574 |
+
M2eProPlay.text.select_action_message = '{$selectActionMessage}';
|
575 |
+
|
576 |
+
M2eProPlay.text.automap_progress_title = '{$autoMapProgressTitle}';
|
577 |
+
M2eProPlay.text.processing_data_message = '{$processingDataMessage}';
|
578 |
+
M2eProPlay.text.successfully_mapped = '{$successfullyMappedMessage}';
|
579 |
+
M2eProPlay.text.failed_mapped = '{$someProductsWereNotMappedMessage}';
|
580 |
+
|
581 |
+
M2eProPlay.text.select_only_mapped_products = '{$selectOnlyMapped}';
|
582 |
+
M2eProPlay.text.select_the_same_type_products = '{$selectTheSameTypeProducts}';
|
583 |
+
|
584 |
+
M2eProPlay.text.view_all_product_log_message = '{$viewAllProductLogMessage}';
|
585 |
+
|
586 |
+
M2eProPlay.text.success_word = '{$successWord}';
|
587 |
+
M2eProPlay.text.notice_word = '{$noticeWord}';
|
588 |
+
M2eProPlay.text.warning_word = '{$warningWord}';
|
589 |
+
M2eProPlay.text.error_word = '{$errorWord}';
|
590 |
+
M2eProPlay.text.close_word = '{$closeWord}';
|
591 |
+
|
592 |
+
M2eProPlay.customData.componentMode = '{$componentMode}';
|
593 |
+
M2eProPlay.customData.gridId = 'playListingOtherGrid';
|
594 |
+
|
595 |
+
var init = function () {
|
596 |
+
PlayListingOtherGridHandlerObj = new PlayListingOtherGridHandler('playListingOtherGrid');
|
597 |
+
PlayListingOtherMappingHandlerObj = new ListingOtherMappingHandler(
|
598 |
+
PlayListingOtherGridHandlerObj,
|
599 |
+
'play'
|
600 |
+
);
|
601 |
+
|
602 |
+
PlayListingOtherGridHandlerObj.movingHandler.setOptions(M2eProPlay);
|
603 |
+
PlayListingOtherGridHandlerObj.autoMappingHandler.setOptions(M2eProPlay);
|
604 |
+
PlayListingOtherGridHandlerObj.removingHandler.setOptions(M2eProPlay);
|
605 |
+
PlayListingOtherGridHandlerObj.unmappingHandler.setOptions(M2eProPlay);
|
606 |
+
}
|
607 |
+
|
608 |
+
if ($$('.tabs-horiz').first()) {
|
609 |
+
var playTabId = $$('.tabs-horiz').first().id + '_play';
|
610 |
+
$(playTabId).observe('click', init);
|
611 |
+
}
|
612 |
+
|
613 |
+
{$this->isAjax} ? init()
|
614 |
+
: Event.observe(window, 'load', init);
|
615 |
+
|
616 |
+
</script>
|
617 |
+
JAVASCRIPT;
|
618 |
+
|
619 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_play_listing_other_help');
|
620 |
+
|
621 |
+
return $javascriptsMain .
|
622 |
+
$helpBlock->toHtml() .
|
623 |
+
$this->getPlayTabBlockFilterHtml() .
|
624 |
+
parent::getPlayTabHtml();
|
625 |
+
}
|
626 |
+
|
627 |
+
private function getPlayTabBlockFilterHtml()
|
628 |
+
{
|
629 |
+
$marketplaceFilterBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_marketplace_switcher', '', array(
|
630 |
+
'component_mode' => Ess_M2ePro_Helper_Component_Play::NICK,
|
631 |
+
'controller_name' => 'adminhtml_common_listing_other'
|
632 |
+
));
|
633 |
+
$accountFilterBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_account_switcher', '', array(
|
634 |
+
'component_mode' => Ess_M2ePro_Helper_Component_Play::NICK,
|
635 |
+
'controller_name' => 'adminhtml_common_listing_other'
|
636 |
+
));
|
637 |
+
|
638 |
+
return '<div class="filter_block">' .
|
639 |
+
$marketplaceFilterBlock->toHtml() .
|
640 |
+
$accountFilterBlock->toHtml() .
|
641 |
+
'</div>';
|
642 |
+
}
|
643 |
+
|
644 |
+
// ########################################
|
645 |
+
|
646 |
+
protected function _toHtml()
|
647 |
+
{
|
648 |
+
return '<div id="listing_other_progress_bar"></div>' .
|
649 |
+
'<div id="listing_container_errors_summary" class="errors_summary" style="display: none;"></div>' .
|
650 |
+
'<div id="listing_other_content_container">' .
|
651 |
+
parent::_toHtml() .
|
652 |
+
'</div>';
|
653 |
+
}
|
654 |
+
|
655 |
+
protected function _componentsToHtml()
|
656 |
+
{
|
657 |
+
/** @var $helper Ess_M2ePro_Helper_Data */
|
658 |
+
$helper = Mage::helper('M2ePro');
|
659 |
+
|
660 |
+
$translations = json_encode(array(
|
661 |
+
|
662 |
+
'Mapping Product' => $helper->__('Mapping Product'),
|
663 |
+
'Product does not exist.' => $helper->__('Product does not exist.'),
|
664 |
+
'Please enter correct product ID.' => $helper->__('Please enter correct product ID.'),
|
665 |
+
'Product(s) was successfully mapped.' => $helper->__('Product(s) was successfully mapped.'),
|
666 |
+
'Please enter correct product ID or SKU' => $helper->__('Please enter correct product ID or SKU'),
|
667 |
+
|
668 |
+
'Current version only supports simple products. Please, choose simple product.' => $helper->__(
|
669 |
+
'Current version only supports simple products. Please, choose simple product.'
|
670 |
+
),
|
671 |
+
|
672 |
+
'Item was not mapped as the chosen %product_id% Simple Product has Custom Options.' => $helper->__(
|
673 |
+
'Item was not mapped as the chosen %product_id% Simple Product has Custom Options.'
|
674 |
+
)
|
675 |
+
|
676 |
+
));
|
677 |
+
|
678 |
+
$urls = json_encode(array(
|
679 |
+
|
680 |
+
'adminhtml_common_log/listingOther' => $this->getUrl('*/adminhtml_common_log/listingOther',array(
|
681 |
+
'back' => $helper->makeBackUrlParam('*/adminhtml_common_listing_other/index')
|
682 |
+
)),
|
683 |
+
|
684 |
+
'adminhtml_listing_other_mapping/map' => $this->getUrl('*/adminhtml_listing_other_mapping/map'),
|
685 |
+
|
686 |
+
));
|
687 |
+
|
688 |
+
$javascriptsMain = <<<JAVASCRIPT
|
689 |
+
<script type="text/javascript">
|
690 |
+
|
691 |
+
M2ePro.url.add({$urls});
|
692 |
+
M2ePro.translator.add({$translations});
|
693 |
+
|
694 |
+
Event.observe(window, 'load', function() {
|
695 |
+
ListingProgressBarObj = new ProgressBar('listing_other_progress_bar');
|
696 |
+
GridWrapperObj = new AreaWrapper('listing_other_content_container');
|
697 |
+
});
|
698 |
+
|
699 |
+
</script>
|
700 |
+
JAVASCRIPT;
|
701 |
+
|
702 |
+
$mapToProductBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_listing_other_mapping');
|
703 |
+
|
704 |
+
return $javascriptsMain .
|
705 |
+
$mapToProductBlock->toHtml() .
|
706 |
+
parent::_componentsToHtml();
|
707 |
+
}
|
708 |
+
|
709 |
+
// ########################################
|
710 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Other/Log.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_Other_Log extends Mage_Adminhtml_Block_Widget_Grid_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('commonListingOtherLog');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_listing_other_log';
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
// Set header text
|
21 |
+
//------------------------------
|
22 |
+
$otherListingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
23 |
+
|
24 |
+
if (isset($otherListingData['id'])) {
|
25 |
+
|
26 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
27 |
+
$component = Mage::helper('M2ePro/Component')->getComponentTitle($otherListingData['component_mode']);
|
28 |
+
$headerText = Mage::helper('M2ePro')->__("Log For %component_name% 3rd Party Listing", $component);
|
29 |
+
} else {
|
30 |
+
$headerText = Mage::helper('M2ePro')->__("Log For 3rd Party Listing");
|
31 |
+
}
|
32 |
+
|
33 |
+
$tempTitle = Mage::helper('M2ePro/Component_'.ucfirst($otherListingData['component_mode']))
|
34 |
+
->getObject('Listing_Other',$otherListingData['id'])
|
35 |
+
->getChildObject()->getTitle();
|
36 |
+
|
37 |
+
$this->_headerText = $headerText;
|
38 |
+
$this->_headerText .= ' "' . $this->escapeHtml($tempTitle) . '"';
|
39 |
+
} else {
|
40 |
+
$this->_headerText = Mage::helper('M2ePro')->__('3rd Party Listings Log');
|
41 |
+
}
|
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('*/adminhtml_common_listing_other/index');
|
57 |
+
$this->_addButton('back', array(
|
58 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
59 |
+
'onclick' => 'CommonHandlerObj.back_click(\''.$url.'\')',
|
60 |
+
'class' => 'back'
|
61 |
+
));
|
62 |
+
//------------------------------
|
63 |
+
}
|
64 |
+
|
65 |
+
//------------------------------
|
66 |
+
$url = $this->getUrl('*/adminhtml_common_listing_other/index');
|
67 |
+
$this->_addButton('goto_listings_other', array(
|
68 |
+
'label' => Mage::helper('M2ePro')->__('3rd Party Listings'),
|
69 |
+
'onclick' => 'setLocation(\'' . $url .'\')',
|
70 |
+
'class' => 'button_link'
|
71 |
+
));
|
72 |
+
//------------------------------
|
73 |
+
|
74 |
+
//------------------------------
|
75 |
+
$this->_addButton('reset', array(
|
76 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
77 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
78 |
+
'class' => 'reset'
|
79 |
+
));
|
80 |
+
//------------------------------
|
81 |
+
|
82 |
+
//------------------------------
|
83 |
+
if (isset($otherListingData['id'])) {
|
84 |
+
$url = $this->getUrl('*/*/*');
|
85 |
+
$this->_addButton('show_general_log', array(
|
86 |
+
'label' => Mage::helper('M2ePro')->__('Show General Log'),
|
87 |
+
'onclick' => 'setLocation(\'' . $url .'\')',
|
88 |
+
'class' => 'show_general_log'
|
89 |
+
));
|
90 |
+
}
|
91 |
+
//------------------------------
|
92 |
+
}
|
93 |
+
|
94 |
+
// ########################################
|
95 |
+
|
96 |
+
public function getGridHtml()
|
97 |
+
{
|
98 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_listing_other_log_help');
|
99 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
100 |
+
}
|
101 |
+
|
102 |
+
protected function _toHtml()
|
103 |
+
{
|
104 |
+
$translations = json_encode(array(
|
105 |
+
'Description' => Mage::helper('M2ePro')->__('Description')
|
106 |
+
));
|
107 |
+
|
108 |
+
$javascript = <<<JAVASCIRPT
|
109 |
+
|
110 |
+
<script type="text/javascript">
|
111 |
+
|
112 |
+
M2ePro.translator.add({$translations});
|
113 |
+
|
114 |
+
Event.observe(window, 'load', function() {
|
115 |
+
LogHandlerObj = new LogHandler();
|
116 |
+
});
|
117 |
+
|
118 |
+
</script>
|
119 |
+
|
120 |
+
JAVASCIRPT;
|
121 |
+
|
122 |
+
return $javascript . parent::_toHtml();
|
123 |
+
}
|
124 |
+
|
125 |
+
// ########################################
|
126 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Other/Log/Grid.php
ADDED
@@ -0,0 +1,40 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing_Other_Log_Grid extends Ess_M2ePro_Block_Adminhtml_Listing_Other_Log_Grid
|
8 |
+
{
|
9 |
+
// ########################################
|
10 |
+
|
11 |
+
protected function getColumnTitles()
|
12 |
+
{
|
13 |
+
return array(
|
14 |
+
'create_date' => Mage::helper('M2ePro')->__('Creation Date'),
|
15 |
+
'identifier' => Mage::helper('M2ePro')->__('Identifier'),
|
16 |
+
'title' => Mage::helper('M2ePro')->__('Product Name'),
|
17 |
+
'action' => Mage::helper('M2ePro')->__('Action'),
|
18 |
+
'description' => Mage::helper('M2ePro')->__('Description'),
|
19 |
+
'initiator' => Mage::helper('M2ePro')->__('Run Mode'),
|
20 |
+
'type' => Mage::helper('M2ePro')->__('Type'),
|
21 |
+
'priority' => Mage::helper('M2ePro')->__('Priority'),
|
22 |
+
);
|
23 |
+
}
|
24 |
+
|
25 |
+
// ########################################
|
26 |
+
|
27 |
+
protected function getActionTitles()
|
28 |
+
{
|
29 |
+
$allActions = Mage::getModel('M2ePro/Listing_Other_Log')->getActionsTitles();
|
30 |
+
$excludeActions = array(
|
31 |
+
Ess_M2ePro_Model_Listing_Other_Log::ACTION_REVISE_PRODUCT => '',
|
32 |
+
Ess_M2ePro_Model_Listing_Other_Log::ACTION_RELIST_PRODUCT => '',
|
33 |
+
Ess_M2ePro_Model_Listing_Other_Log::ACTION_STOP_PRODUCT => '',
|
34 |
+
);
|
35 |
+
|
36 |
+
return array_diff_key($allActions, $excludeActions);
|
37 |
+
}
|
38 |
+
|
39 |
+
// ########################################
|
40 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Other/Log/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_Other_Log_Help extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
$this->setTemplate('M2ePro/common/listing/other/log/help.phtml');
|
13 |
+
}
|
14 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Product/Variation.php
ADDED
@@ -0,0 +1,152 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
abstract class Ess_M2ePro_Block_Adminhtml_Common_Listing_Product_Variation extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
//##############################################################
|
10 |
+
|
11 |
+
private $magentoVariationsSets = NULL;
|
12 |
+
private $magentoVariationsCombinations = NULL;
|
13 |
+
|
14 |
+
private $magentoVariationsTree = NULL;
|
15 |
+
|
16 |
+
private $listingProduct = NULL;
|
17 |
+
|
18 |
+
//##############################################################
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @return Ess_M2ePro_Model_Listing_Product
|
22 |
+
*/
|
23 |
+
public function getListingProduct()
|
24 |
+
{
|
25 |
+
if (is_null($this->listingProduct)) {
|
26 |
+
$this->listingProduct = Mage::helper('M2ePro/Component')->getComponentObject(
|
27 |
+
$this->getComponent(), 'Listing_Product', $this->getListingProductId()
|
28 |
+
);
|
29 |
+
$this->listingProduct->enableCache();
|
30 |
+
}
|
31 |
+
return $this->listingProduct;
|
32 |
+
}
|
33 |
+
|
34 |
+
public function getMagentoVariationsSets()
|
35 |
+
{
|
36 |
+
if (is_null($this->magentoVariationsSets)) {
|
37 |
+
$temp = $this->getListingProduct()->getMagentoProduct()->getProductVariations();
|
38 |
+
$this->magentoVariationsSets = $temp['set'];
|
39 |
+
}
|
40 |
+
|
41 |
+
return $this->magentoVariationsSets;
|
42 |
+
}
|
43 |
+
|
44 |
+
public function getMagentoVariationsCombinations()
|
45 |
+
{
|
46 |
+
if (is_null($this->magentoVariationsCombinations)) {
|
47 |
+
$temp = $this->getListingProduct()->getMagentoProduct()->getProductVariations();
|
48 |
+
$this->magentoVariationsCombinations = $temp['variations'];
|
49 |
+
}
|
50 |
+
|
51 |
+
return $this->magentoVariationsCombinations;
|
52 |
+
}
|
53 |
+
|
54 |
+
//##############################################################
|
55 |
+
|
56 |
+
public function getMagentoVariationsTree()
|
57 |
+
{
|
58 |
+
if (is_null($this->magentoVariationsTree)) {
|
59 |
+
|
60 |
+
$firstAttribute = $this->getMagentoVariationsSets();
|
61 |
+
$firstAttribute = key($firstAttribute);
|
62 |
+
|
63 |
+
$this->magentoVariationsTree = $this->prepareVariations(
|
64 |
+
$firstAttribute,$this->getMagentoVariationsCombinations()
|
65 |
+
);
|
66 |
+
}
|
67 |
+
|
68 |
+
return $this->magentoVariationsTree;
|
69 |
+
}
|
70 |
+
|
71 |
+
//--------------------------------------------------------------
|
72 |
+
|
73 |
+
private function prepareVariations($currentAttribute,$magentoVariations,$filters = array())
|
74 |
+
{
|
75 |
+
$return = false;
|
76 |
+
|
77 |
+
$magentoVariationsSets = $this->getMagentoVariationsSets();
|
78 |
+
|
79 |
+
$temp = array_flip(array_keys($magentoVariationsSets));
|
80 |
+
|
81 |
+
$lastAttributePosition = count($magentoVariationsSets) - 1;
|
82 |
+
$currentAttributePosition = $temp[$currentAttribute];
|
83 |
+
|
84 |
+
if ($currentAttributePosition != $lastAttributePosition) {
|
85 |
+
|
86 |
+
$temp = array_keys($magentoVariationsSets);
|
87 |
+
$nextAttribute = $temp[$currentAttributePosition + 1];
|
88 |
+
|
89 |
+
foreach ($magentoVariationsSets[$currentAttribute] as $value) {
|
90 |
+
|
91 |
+
$filters[$currentAttribute] = $value;
|
92 |
+
|
93 |
+
$result = $this->prepareVariations(
|
94 |
+
$nextAttribute,$magentoVariations,$filters
|
95 |
+
);
|
96 |
+
|
97 |
+
if (!$result) {
|
98 |
+
continue;
|
99 |
+
}
|
100 |
+
|
101 |
+
$return[$currentAttribute][$value] = $result;
|
102 |
+
}
|
103 |
+
|
104 |
+
return $return;
|
105 |
+
}
|
106 |
+
|
107 |
+
$return = false;
|
108 |
+
foreach ($magentoVariations as $key => $magentoVariation) {
|
109 |
+
foreach ($magentoVariation as $option) {
|
110 |
+
|
111 |
+
$value = $option['option'];
|
112 |
+
$attribute = $option['attribute'];
|
113 |
+
|
114 |
+
if ($attribute == $currentAttribute) {
|
115 |
+
|
116 |
+
if (count($magentoVariationsSets) != 1) {
|
117 |
+
continue;
|
118 |
+
}
|
119 |
+
|
120 |
+
$values = array_flip($magentoVariationsSets[$currentAttribute]);
|
121 |
+
$return = array($currentAttribute => $values);
|
122 |
+
|
123 |
+
foreach ($return[$currentAttribute] as &$value) {
|
124 |
+
$value = true;
|
125 |
+
}
|
126 |
+
|
127 |
+
return $return;
|
128 |
+
}
|
129 |
+
|
130 |
+
if ($value != $filters[$attribute]) {
|
131 |
+
unset($magentoVariations[$key]);
|
132 |
+
continue;
|
133 |
+
}
|
134 |
+
|
135 |
+
foreach ($magentoVariation as $tempOption) {
|
136 |
+
if ($tempOption['attribute'] == $currentAttribute) {
|
137 |
+
$value = $tempOption['option'];
|
138 |
+
$return[$currentAttribute][$value] = true;
|
139 |
+
}
|
140 |
+
}
|
141 |
+
}
|
142 |
+
}
|
143 |
+
|
144 |
+
if (count($magentoVariations) < 1) {
|
145 |
+
return false;
|
146 |
+
}
|
147 |
+
|
148 |
+
return $return;
|
149 |
+
}
|
150 |
+
|
151 |
+
//##############################################################
|
152 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Product/Variation/Edit.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_Listing_Product_Variation_Edit
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Common_Listing_Product_Variation
|
9 |
+
{
|
10 |
+
//##############################################################
|
11 |
+
|
12 |
+
public $currentVariation = array();
|
13 |
+
|
14 |
+
//##############################################################
|
15 |
+
|
16 |
+
public function __construct()
|
17 |
+
{
|
18 |
+
parent::__construct();
|
19 |
+
|
20 |
+
// Initialization block
|
21 |
+
//------------------------------
|
22 |
+
$this->setId('listingProductVariationEdit');
|
23 |
+
//------------------------------
|
24 |
+
|
25 |
+
$this->setTemplate('M2ePro/common/listing/product/variation/edit.phtml');
|
26 |
+
}
|
27 |
+
|
28 |
+
//##############################################################
|
29 |
+
|
30 |
+
protected function _beforeToHtml()
|
31 |
+
{
|
32 |
+
$this->_prepareButtons();
|
33 |
+
|
34 |
+
if (!$this->getListingProduct()->getChildObject()->isVariationMatched()) {
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
|
38 |
+
$variations = $this->getListingProduct()->getVariations(true);
|
39 |
+
/* @var $variation Ess_M2ePro_Model_Listing_Product_Variation */
|
40 |
+
$variation = reset($variations);
|
41 |
+
|
42 |
+
/* @var $optionInstance Ess_M2ePro_Model_Listing_Product_Variation_Option */
|
43 |
+
foreach ($variation->getOptions(true) as $optionInstance) {
|
44 |
+
$option = $optionInstance->getOption();
|
45 |
+
$attribute = $optionInstance->getAttribute();
|
46 |
+
$this->currentVariation[$attribute] = $option;
|
47 |
+
}
|
48 |
+
|
49 |
+
return parent::_beforeToHtml();
|
50 |
+
}
|
51 |
+
|
52 |
+
//##############################################################
|
53 |
+
|
54 |
+
protected function _prepareButtons()
|
55 |
+
{
|
56 |
+
$buttonBlock = $this->getLayout()
|
57 |
+
->createBlock('adminhtml/widget_button')
|
58 |
+
->setData(array(
|
59 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
60 |
+
'onclick' => '',
|
61 |
+
'class' => 'confirm',
|
62 |
+
'id' => 'variation_edit_confirm'
|
63 |
+
));
|
64 |
+
$this->setChild('variation_edit_confirm', $buttonBlock);
|
65 |
+
|
66 |
+
$buttonBlock = $this->getLayout()
|
67 |
+
->createBlock('adminhtml/widget_button')
|
68 |
+
->setData(array(
|
69 |
+
'label' => Mage::helper('M2ePro')->__('Close'),
|
70 |
+
'onclick' => 'ListingProductVariationHandlerObj.editPopup.close();',
|
71 |
+
'class' => 'close',
|
72 |
+
'id' => 'variation_edit_close'
|
73 |
+
));
|
74 |
+
$this->setChild('variation_edit_close', $buttonBlock);
|
75 |
+
}
|
76 |
+
|
77 |
+
//##############################################################
|
78 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Product/Variation/Manage.php
ADDED
@@ -0,0 +1,95 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Listing_Product_Variation_Manage
|
8 |
+
extends Ess_M2ePro_Block_Adminhtml_Common_Listing_Product_Variation
|
9 |
+
{
|
10 |
+
//##############################################################
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
// Initialization block
|
17 |
+
//------------------------------
|
18 |
+
$this->setId('listingProductVariationEdit');
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
$this->setTemplate('M2ePro/common/listing/product/variation/manage.phtml');
|
22 |
+
}
|
23 |
+
|
24 |
+
//##############################################################
|
25 |
+
|
26 |
+
protected function _beforeToHtml()
|
27 |
+
{
|
28 |
+
$this->_prepareButtons();
|
29 |
+
|
30 |
+
return parent::_beforeToHtml();
|
31 |
+
}
|
32 |
+
|
33 |
+
//##############################################################
|
34 |
+
|
35 |
+
protected function _prepareButtons()
|
36 |
+
{
|
37 |
+
$buttonBlock = $this->getLayout()
|
38 |
+
->createBlock('adminhtml/widget_button')
|
39 |
+
->setData(array(
|
40 |
+
'label' => Mage::helper('M2ePro')->__('Add More Variations'),
|
41 |
+
'onclick' => '',
|
42 |
+
'class' => 'add',
|
43 |
+
'id' => 'add_more_variation_button'
|
44 |
+
));
|
45 |
+
$this->setChild('add_more_variation_button', $buttonBlock);
|
46 |
+
|
47 |
+
//------------------------------
|
48 |
+
|
49 |
+
$buttonBlock = $this->getLayout()
|
50 |
+
->createBlock('adminhtml/widget_button')
|
51 |
+
->setData(array(
|
52 |
+
'label' => Mage::helper('M2ePro')->__('Confirm'),
|
53 |
+
'onclick' => '',
|
54 |
+
'class' => 'confirm',
|
55 |
+
'id' => 'variation_manage_confirm'
|
56 |
+
));
|
57 |
+
$this->setChild('variation_manage_confirm', $buttonBlock);
|
58 |
+
|
59 |
+
$buttonBlock = $this->getLayout()
|
60 |
+
->createBlock('adminhtml/widget_button')
|
61 |
+
->setData(array(
|
62 |
+
'label' => Mage::helper('M2ePro')->__('Close'),
|
63 |
+
'onclick' => 'ListingProductVariationHandlerObj.managePopup.close();',
|
64 |
+
'class' => 'close',
|
65 |
+
'id' => 'variation_manage_close'
|
66 |
+
));
|
67 |
+
$this->setChild('variation_manage_close', $buttonBlock);
|
68 |
+
|
69 |
+
//------------------------------
|
70 |
+
|
71 |
+
$onClick = 'ListingProductVariationHandlerObj.manageGenerateAction(false);';
|
72 |
+
$buttonBlock = $this->getLayout()
|
73 |
+
->createBlock('adminhtml/widget_button')
|
74 |
+
->setData(array(
|
75 |
+
'label' => Mage::helper('M2ePro')->__('Generate All Combinations'),
|
76 |
+
'onclick' => $onClick,
|
77 |
+
'class' => 'button',
|
78 |
+
'id' => 'variation_manage_generate_all'
|
79 |
+
));
|
80 |
+
$this->setChild('variation_manage_generate_all', $buttonBlock);
|
81 |
+
|
82 |
+
$onClick = 'ListingProductVariationHandlerObj.manageGenerateAction(true);';
|
83 |
+
$buttonBlock = $this->getLayout()
|
84 |
+
->createBlock('adminhtml/widget_button')
|
85 |
+
->setData(array(
|
86 |
+
'label' => Mage::helper('M2ePro')->__('Generate Non-Existing Combinations'),
|
87 |
+
'onclick' => $onClick,
|
88 |
+
'class' => 'button',
|
89 |
+
'id' => 'variation_manage_generate_unique'
|
90 |
+
));
|
91 |
+
$this->setChild('variation_manage_generate_unique', $buttonBlock);
|
92 |
+
}
|
93 |
+
|
94 |
+
//##############################################################
|
95 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Search.php
ADDED
@@ -0,0 +1,138 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_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('listingSearch');
|
18 |
+
$this->_blockGroup = 'M2ePro';
|
19 |
+
$this->_controller = 'adminhtml_common_listing_search';
|
20 |
+
//------------------------------
|
21 |
+
|
22 |
+
// Set header text
|
23 |
+
//------------------------------
|
24 |
+
$this->_headerText = Mage::helper('M2ePro')->__('Search Listings Items');
|
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_listing/search');
|
40 |
+
$this->_addButton('back', array(
|
41 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
42 |
+
'onclick' => 'CommonHandlerObj.back_click(\''.$url.'\')',
|
43 |
+
'class' => 'back'
|
44 |
+
));
|
45 |
+
//------------------------------
|
46 |
+
}
|
47 |
+
|
48 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_listing/search');
|
49 |
+
|
50 |
+
//------------------------------
|
51 |
+
$url = $this->getUrl('*/adminhtml_common_listing/index', array('back' => $backUrl));
|
52 |
+
$this->_addButton('goto_listings', array(
|
53 |
+
'label' => Mage::helper('M2ePro')->__('Listings'),
|
54 |
+
'onclick' => 'setLocation(\''.$url.'\')',
|
55 |
+
'class' => 'button_link'
|
56 |
+
));
|
57 |
+
//------------------------------
|
58 |
+
|
59 |
+
//------------------------------
|
60 |
+
$this->_addButton('goto_templates', array(
|
61 |
+
'label' => Mage::helper('M2ePro')->__('Templates'),
|
62 |
+
'onclick' => '',
|
63 |
+
'class' => 'button_link drop_down templates-drop-down'
|
64 |
+
));
|
65 |
+
//------------------------------
|
66 |
+
|
67 |
+
//------------------------------
|
68 |
+
$url = $this->getUrl('*/adminhtml_common_log/listing');
|
69 |
+
$this->_addButton('view_log', array(
|
70 |
+
'label' => Mage::helper('M2ePro')->__('View Log'),
|
71 |
+
'onclick' => 'window.open(\''.$url.'\')',
|
72 |
+
'class' => 'button_link'
|
73 |
+
));
|
74 |
+
//------------------------------
|
75 |
+
|
76 |
+
//------------------------------
|
77 |
+
$this->_addButton('reset', array(
|
78 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
79 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
80 |
+
'class' => 'reset'
|
81 |
+
));
|
82 |
+
//------------------------------
|
83 |
+
}
|
84 |
+
|
85 |
+
// ########################################
|
86 |
+
|
87 |
+
protected function _toHtml()
|
88 |
+
{
|
89 |
+
return $this->getTemplatesButtonJavascript() . parent::_toHtml();
|
90 |
+
}
|
91 |
+
|
92 |
+
public function getGridHtml()
|
93 |
+
{
|
94 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_listing_search_help');
|
95 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
96 |
+
}
|
97 |
+
|
98 |
+
// ########################################
|
99 |
+
|
100 |
+
protected function getTemplatesButtonJavascript()
|
101 |
+
{
|
102 |
+
$data = array(
|
103 |
+
'target_css_class' => 'templates-drop-down',
|
104 |
+
'items' => $this->getTemplatesButtonDropDownItems()
|
105 |
+
);
|
106 |
+
$dropDownBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_button_dropDown');
|
107 |
+
$dropDownBlock->setData($data);
|
108 |
+
|
109 |
+
return $dropDownBlock->toHtml();
|
110 |
+
}
|
111 |
+
|
112 |
+
protected function getTemplatesButtonDropDownItems()
|
113 |
+
{
|
114 |
+
$items = array();
|
115 |
+
|
116 |
+
//------------------------------
|
117 |
+
$url = $this->getUrl('*/adminhtml_common_template_sellingFormat/index');
|
118 |
+
$items[] = array(
|
119 |
+
'url' => $url,
|
120 |
+
'label' => Mage::helper('M2ePro')->__('Selling Format Templates'),
|
121 |
+
'target' => '_blank'
|
122 |
+
);
|
123 |
+
//------------------------------
|
124 |
+
|
125 |
+
//------------------------------
|
126 |
+
$url = $this->getUrl('*/adminhtml_common_template_synchronization/index');
|
127 |
+
$items[] = array(
|
128 |
+
'url' => $url,
|
129 |
+
'label' => Mage::helper('M2ePro')->__('Synchronization Templates'),
|
130 |
+
'target' => '_blank'
|
131 |
+
);
|
132 |
+
//------------------------------
|
133 |
+
|
134 |
+
return $items;
|
135 |
+
}
|
136 |
+
|
137 |
+
// ########################################
|
138 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Search/Grid.php
ADDED
@@ -0,0 +1,334 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_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('listingSearchGrid');
|
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 |
+
$activeComponents = Mage::helper('M2ePro/View_Common_Component')->getActiveComponents();
|
36 |
+
|
37 |
+
$collection = Mage::getModel('M2ePro/Listing_Product')->getCollection();
|
38 |
+
$collection->addFieldToFilter(
|
39 |
+
'`main_table`.`component_mode`', array('in' => $activeComponents)
|
40 |
+
);
|
41 |
+
$collection->getSelect()->distinct();
|
42 |
+
$collection->getSelect()->join(
|
43 |
+
array('l'=>Mage::getResourceModel('M2ePro/Listing')->getMainTable()),
|
44 |
+
'(`l`.`id` = `main_table`.`listing_id`)',
|
45 |
+
array('listing_title'=>'title','store_id')
|
46 |
+
);
|
47 |
+
//--------------------------------
|
48 |
+
|
49 |
+
// Communicate with magento product table
|
50 |
+
//--------------------------------
|
51 |
+
$table = Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar');
|
52 |
+
$dbSelect = Mage::getResourceModel('core/config')->getReadConnection()
|
53 |
+
->select()
|
54 |
+
->from($table,new Zend_Db_Expr('MAX(`store_id`)'))
|
55 |
+
->where("`entity_id` = `main_table`.`product_id`")
|
56 |
+
->where("`attribute_id` = `ea`.`attribute_id`")
|
57 |
+
->where("`store_id` = 0 OR `store_id` = `l`.`store_id`");
|
58 |
+
|
59 |
+
$collection->getSelect()->join(
|
60 |
+
array('cpe'=>Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')),
|
61 |
+
'(cpe.entity_id = `main_table`.product_id)',
|
62 |
+
array('sku')
|
63 |
+
);
|
64 |
+
$collection->getSelect()->join(
|
65 |
+
array('cisi'=>Mage::getSingleton('core/resource')->getTableName('cataloginventory_stock_item')),
|
66 |
+
'(cisi.product_id = `main_table`.product_id AND cisi.stock_id = 1)',
|
67 |
+
array('is_in_stock')
|
68 |
+
);
|
69 |
+
$collection->getSelect()->join(
|
70 |
+
array('cpev'=>Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')),
|
71 |
+
"(`cpev`.`entity_id` = `main_table`.product_id)",
|
72 |
+
array('value')
|
73 |
+
);
|
74 |
+
$collection->getSelect()->join(
|
75 |
+
array('ea'=>Mage::getSingleton('core/resource')->getTableName('eav_attribute')),
|
76 |
+
'(`cpev`.`attribute_id` = `ea`.`attribute_id` AND `ea`.`attribute_code` = \'name\')',
|
77 |
+
array()
|
78 |
+
);
|
79 |
+
$collection->getSelect()->where('`cpev`.`store_id` = ('.$dbSelect->__toString().')');
|
80 |
+
//--------------------------------
|
81 |
+
|
82 |
+
//exit($collection->getSelect()->__toString());
|
83 |
+
|
84 |
+
// Set collection to grid
|
85 |
+
$this->setCollection($collection);
|
86 |
+
|
87 |
+
return parent::_prepareCollection();
|
88 |
+
}
|
89 |
+
|
90 |
+
protected function _prepareColumns()
|
91 |
+
{
|
92 |
+
$this->addColumn('product_id', array(
|
93 |
+
'header' => Mage::helper('M2ePro')->__('Product ID'),
|
94 |
+
'align' => 'right',
|
95 |
+
'width' => '100px',
|
96 |
+
'type' => 'number',
|
97 |
+
'index' => 'product_id',
|
98 |
+
'filter_index' => 'main_table.product_id',
|
99 |
+
'frame_callback' => array($this, 'callbackColumnProductId')
|
100 |
+
));
|
101 |
+
|
102 |
+
$this->addColumn('name', array(
|
103 |
+
'header' => Mage::helper('M2ePro')->__('Product Title / Listing / SKU'),
|
104 |
+
'align' => 'left',
|
105 |
+
//'width' => '300px',
|
106 |
+
'type' => 'text',
|
107 |
+
'index' => 'value',
|
108 |
+
'filter_index' => 'cpev.value',
|
109 |
+
'frame_callback' => array($this, 'callbackColumnProductTitle'),
|
110 |
+
'filter_condition_callback' => array($this, 'callbackFilterTitle')
|
111 |
+
));
|
112 |
+
|
113 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
114 |
+
$options = Mage::helper('M2ePro/View_Common_Component')->getEnabledComponentsTitles();
|
115 |
+
|
116 |
+
$this->addColumn('component_mode', array(
|
117 |
+
'header' => Mage::helper('M2ePro')->__('Channel'),
|
118 |
+
'align' => 'left',
|
119 |
+
'width' => '120px',
|
120 |
+
'type' => 'options',
|
121 |
+
'index' => 'component_mode',
|
122 |
+
'filter_index' => 'main_table.component_mode',
|
123 |
+
'sortable' => false,
|
124 |
+
'options' => $options
|
125 |
+
));
|
126 |
+
}
|
127 |
+
|
128 |
+
$this->addColumn('stock_availability',
|
129 |
+
array(
|
130 |
+
'header'=> Mage::helper('M2ePro')->__('Stock Availability'),
|
131 |
+
'width' => '100px',
|
132 |
+
'index' => 'is_in_stock',
|
133 |
+
'filter_index' => 'cisi.is_in_stock',
|
134 |
+
'type' => 'options',
|
135 |
+
'sortable' => false,
|
136 |
+
'options' => array(
|
137 |
+
1 => Mage::helper('M2ePro')->__('In Stock'),
|
138 |
+
0 => Mage::helper('M2ePro')->__('Out of Stock')
|
139 |
+
),
|
140 |
+
'frame_callback' => array($this, 'callbackColumnStockAvailability')
|
141 |
+
));
|
142 |
+
|
143 |
+
$this->addColumn('status',
|
144 |
+
array(
|
145 |
+
'header'=> Mage::helper('M2ePro')->__('Status'),
|
146 |
+
'width' => '100px',
|
147 |
+
'index' => 'status',
|
148 |
+
'filter_index' => 'main_table.status',
|
149 |
+
'type' => 'options',
|
150 |
+
'sortable' => false,
|
151 |
+
'options' => array(
|
152 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_UNKNOWN => Mage::helper('M2ePro')->__('Unknown'),
|
153 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED => Mage::helper('M2ePro')->__('Not Listed'),
|
154 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_LISTED => Mage::helper('M2ePro')->__('Active'),
|
155 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED => Mage::helper('M2ePro')->__('Inactive'),
|
156 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_BLOCKED =>
|
157 |
+
Mage::helper('M2ePro')->__('Inactive (Blocked)')
|
158 |
+
),
|
159 |
+
'frame_callback' => array($this, 'callbackColumnStatus')
|
160 |
+
));
|
161 |
+
|
162 |
+
$this->addColumn('goto_listing_item', array(
|
163 |
+
'header' => Mage::helper('M2ePro')->__('Manage'),
|
164 |
+
'align' => 'center',
|
165 |
+
'width' => '50px',
|
166 |
+
'type' => 'text',
|
167 |
+
'filter' => false,
|
168 |
+
'sortable' => false,
|
169 |
+
'frame_callback' => array($this, 'callbackColumnActions')
|
170 |
+
));
|
171 |
+
|
172 |
+
return parent::_prepareColumns();
|
173 |
+
}
|
174 |
+
|
175 |
+
// ####################################
|
176 |
+
|
177 |
+
public function callbackColumnProductId($value, $row, $column, $isExport)
|
178 |
+
{
|
179 |
+
$productId = (int)$row->getData('product_id');
|
180 |
+
$storeId = (int)$row->getData('store_id');
|
181 |
+
|
182 |
+
$url = $this->getUrl('adminhtml/catalog_product/edit', array('id' => $productId));
|
183 |
+
$withoutImageHtml = '<a href="'.$url.'" target="_blank">'.$productId.'</a>';
|
184 |
+
|
185 |
+
$showProductsThumbnails = (bool)(int)Mage::helper('M2ePro/Module')->getConfig()->getGroupValue(
|
186 |
+
'/view/','show_products_thumbnails'
|
187 |
+
);
|
188 |
+
if (!$showProductsThumbnails) {
|
189 |
+
return $withoutImageHtml;
|
190 |
+
}
|
191 |
+
|
192 |
+
/** @var $magentoProduct Ess_M2ePro_Model_Magento_Product */
|
193 |
+
$magentoProduct = Mage::getModel('M2ePro/Magento_Product');
|
194 |
+
$magentoProduct->setProductId($productId);
|
195 |
+
$magentoProduct->setStoreId($storeId);
|
196 |
+
|
197 |
+
$imageUrlResized = $magentoProduct->getThumbnailImageLink();
|
198 |
+
if (is_null($imageUrlResized)) {
|
199 |
+
return $withoutImageHtml;
|
200 |
+
}
|
201 |
+
|
202 |
+
$imageHtml = $productId.'<hr/><img src="'.$imageUrlResized.'" />';
|
203 |
+
$withImageHtml = str_replace('>'.$productId.'<','>'.$imageHtml.'<',$withoutImageHtml);
|
204 |
+
|
205 |
+
return $withImageHtml;
|
206 |
+
}
|
207 |
+
|
208 |
+
public function callbackColumnProductTitle($value, $row, $column, $isExport)
|
209 |
+
{
|
210 |
+
if (strlen($value) > 60) {
|
211 |
+
$value = substr($value, 0, 60) . '...';
|
212 |
+
}
|
213 |
+
|
214 |
+
$value = '<span>'.Mage::helper('M2ePro')->escapeHtml($value).'</span>';
|
215 |
+
|
216 |
+
$urlParams = array();
|
217 |
+
$urlParams['id'] = $row->getData('listing_id');
|
218 |
+
$urlParams['back'] = Mage::helper('M2ePro')->makeBackUrlParam('*/adminhtml_common_listing/search');
|
219 |
+
|
220 |
+
$listingUrl = Mage::helper('M2ePro/View')->getUrl($row, 'listing', 'view', $urlParams);
|
221 |
+
$listingTitle = Mage::helper('M2ePro')->escapeHtml($row->getData('listing_title'));
|
222 |
+
|
223 |
+
if (strlen($listingTitle) > 50) {
|
224 |
+
$listingTitle = substr($listingTitle, 0, 50) . '...';
|
225 |
+
}
|
226 |
+
|
227 |
+
$value .= '<br/><hr style="border:none; border-top:1px solid silver; margin: 2px 0px;"/>';
|
228 |
+
$value .= '<strong>'.Mage::helper('M2ePro')->__('Listing').': </strong>';
|
229 |
+
$value .= '<a href="'.$listingUrl.'">'.$listingTitle.'</a>';
|
230 |
+
|
231 |
+
$tempSku = $row->getData('sku');
|
232 |
+
if (is_null($tempSku)) {
|
233 |
+
$tempSku = Mage::getModel('M2ePro/Magento_Product')->setProductId($row->getData('product_id'))->getSku();
|
234 |
+
}
|
235 |
+
|
236 |
+
$value .= '<br/><strong>'.Mage::helper('M2ePro')->__('SKU').':</strong> ';
|
237 |
+
$value .= Mage::helper('M2ePro')->escapeHtml($tempSku);
|
238 |
+
|
239 |
+
return $value;
|
240 |
+
}
|
241 |
+
|
242 |
+
public function callbackColumnStockAvailability($value, $row, $column, $isExport)
|
243 |
+
{
|
244 |
+
if ((int)$row->getData('is_in_stock') <= 0) {
|
245 |
+
return '<span style="color: red;">'.$value.'</span>';
|
246 |
+
}
|
247 |
+
|
248 |
+
return $value;
|
249 |
+
}
|
250 |
+
|
251 |
+
public function callbackColumnStatus($value, $row, $column, $isExport)
|
252 |
+
{
|
253 |
+
switch ($row->getData('status')) {
|
254 |
+
|
255 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_UNKNOWN:
|
256 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED:
|
257 |
+
$value = '<span style="color: gray;">'.$value.'</span>';
|
258 |
+
break;
|
259 |
+
|
260 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_LISTED:
|
261 |
+
$value = '<span style="color: green;">'.$value.'</span>';
|
262 |
+
break;
|
263 |
+
|
264 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_SOLD:
|
265 |
+
$value = '<span style="color: brown;">'.$value.'</span>';
|
266 |
+
break;
|
267 |
+
|
268 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED:
|
269 |
+
$value = '<span style="color: red;">'.$value.'</span>';
|
270 |
+
break;
|
271 |
+
|
272 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_FINISHED:
|
273 |
+
$value = '<span style="color: blue;">'.$value.'</span>';
|
274 |
+
break;
|
275 |
+
|
276 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_BLOCKED:
|
277 |
+
$value = '<span style="color: orange;">'.$value.'</span>';
|
278 |
+
break;
|
279 |
+
|
280 |
+
default:
|
281 |
+
break;
|
282 |
+
}
|
283 |
+
|
284 |
+
return $value;
|
285 |
+
}
|
286 |
+
|
287 |
+
public function callbackColumnActions($value, $row, $column, $isExport)
|
288 |
+
{
|
289 |
+
$altTitle = Mage::helper('M2ePro')->__('Go to listing');
|
290 |
+
$iconSrc = $this->getSkinUrl('M2ePro').'/images/goto_listing.png';
|
291 |
+
$url = $this->getUrl('*/adminhtml_common_'.$row->getData('component_mode').'_listing/view/',array(
|
292 |
+
'id' => $row->getData('listing_id'),
|
293 |
+
'filter' => base64_encode(
|
294 |
+
'product_id[from]='.(int)$row->getData('product_id')
|
295 |
+
.'&product_id[to]='.(int)$row->getData('product_id')
|
296 |
+
)
|
297 |
+
));
|
298 |
+
|
299 |
+
$html = <<<HTML
|
300 |
+
<div style="float:right; margin:5px 15px 0 0;">
|
301 |
+
<a title="{$altTitle}" target="_blank" href="{$url}"><img src="{$iconSrc}" /></a>
|
302 |
+
</div>
|
303 |
+
HTML;
|
304 |
+
|
305 |
+
return $html;
|
306 |
+
}
|
307 |
+
|
308 |
+
//-------------------------------------
|
309 |
+
|
310 |
+
protected function callbackFilterTitle($collection, $column)
|
311 |
+
{
|
312 |
+
$value = $column->getFilter()->getValue();
|
313 |
+
|
314 |
+
if ($value == null) {
|
315 |
+
return;
|
316 |
+
}
|
317 |
+
|
318 |
+
$collection->getSelect()->where('cpev.value LIKE ? OR cpe.sku LIKE ? OR l.title LIKE ?', '%'.$value.'%');
|
319 |
+
}
|
320 |
+
|
321 |
+
// ####################################
|
322 |
+
|
323 |
+
public function getGridUrl()
|
324 |
+
{
|
325 |
+
return $this->getUrl('*/adminhtml_common_listing/searchGrid', array('_current'=>true));
|
326 |
+
}
|
327 |
+
|
328 |
+
public function getRowUrl($row)
|
329 |
+
{
|
330 |
+
return false;
|
331 |
+
}
|
332 |
+
|
333 |
+
// ####################################
|
334 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Listing/Search/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_Search_Help extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
$this->setTemplate('M2ePro/common/listing/search/help.phtml');
|
13 |
+
}
|
14 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Marketplace.php
ADDED
@@ -0,0 +1,214 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Marketplace extends Ess_M2ePro_Block_Adminhtml_Common_Component_Tabs_Container
|
8 |
+
{
|
9 |
+
const TAB_ID_RAKUTEN = 'rakuten';
|
10 |
+
|
11 |
+
// ########################################
|
12 |
+
|
13 |
+
private $activeWizardNick = NULL;
|
14 |
+
|
15 |
+
// ########################################
|
16 |
+
|
17 |
+
public function __construct()
|
18 |
+
{
|
19 |
+
parent::__construct();
|
20 |
+
|
21 |
+
// Initialization block
|
22 |
+
//------------------------------
|
23 |
+
$this->setId('marketplace');
|
24 |
+
$this->_blockGroup = 'M2ePro';
|
25 |
+
$this->_controller = 'adminhtml_common_marketplace';
|
26 |
+
//------------------------------
|
27 |
+
|
28 |
+
// Form id of marketplace_general_form
|
29 |
+
//------------------------------
|
30 |
+
$this->tabsContainerId = 'edit_form';
|
31 |
+
//------------------------------
|
32 |
+
|
33 |
+
// Set header text
|
34 |
+
//------------------------------
|
35 |
+
$this->_headerText = Mage::helper('M2ePro')->__('Marketplaces');
|
36 |
+
//------------------------------
|
37 |
+
|
38 |
+
if ((bool)$this->getRequest()->getParam('wizard',false)) {
|
39 |
+
$this->activeWizardNick = Mage::helper('M2ePro/Module_Wizard')->getNick(
|
40 |
+
Mage::helper('M2ePro/Module_Wizard')->getActiveWizard(Ess_M2ePro_Helper_View_Common::NICK)
|
41 |
+
);
|
42 |
+
|
43 |
+
$this->setEnabledTab($this->getTabIdByWizardNick($this->activeWizardNick));
|
44 |
+
|
45 |
+
//------------------------------
|
46 |
+
$this->_addButton('reset', array(
|
47 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
48 |
+
'onclick' => 'MarketplaceHandlerObj.reset_click()',
|
49 |
+
'class' => 'reset'
|
50 |
+
));
|
51 |
+
//------------------------------
|
52 |
+
|
53 |
+
//------------------------------
|
54 |
+
$this->_addButton('close', array(
|
55 |
+
'label' => Mage::helper('M2ePro')->__('Save And Complete This Step'),
|
56 |
+
'onclick' => 'MarketplaceHandlerObj.completeStepAction();',
|
57 |
+
'class' => 'close'
|
58 |
+
));
|
59 |
+
//------------------------------
|
60 |
+
} else {
|
61 |
+
//------------------------------
|
62 |
+
$this->_addButton('reset', array(
|
63 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
64 |
+
'onclick' => 'MarketplaceHandlerObj.reset_click()',
|
65 |
+
'class' => 'reset'
|
66 |
+
));
|
67 |
+
//------------------------------
|
68 |
+
|
69 |
+
//------------------------------
|
70 |
+
$this->addButton('run_update_all', array(
|
71 |
+
'label' => Mage::helper('M2ePro')->__('Update All Now'),
|
72 |
+
'onclick' => 'MarketplaceHandlerObj.updateAction()',
|
73 |
+
'class' => 'save update_all_marketplace'
|
74 |
+
));
|
75 |
+
//------------------------------
|
76 |
+
|
77 |
+
//------------------------------
|
78 |
+
$this->_addButton('run_synch_now', array(
|
79 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
80 |
+
'onclick' => 'MarketplaceHandlerObj.saveAction();',
|
81 |
+
'class' => 'save save_and_update_marketplaces'
|
82 |
+
));
|
83 |
+
//------------------------------
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
protected function initializeTabs()
|
88 |
+
{
|
89 |
+
$this->initializeAmazon();
|
90 |
+
$this->initializeRakuten();
|
91 |
+
}
|
92 |
+
|
93 |
+
protected function initializeRakuten()
|
94 |
+
{
|
95 |
+
if (Mage::helper('M2ePro/Component')->isRakutenActive()) {
|
96 |
+
$this->initializeTab(self::TAB_ID_RAKUTEN);
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
// ########################################
|
101 |
+
|
102 |
+
public function setEnabledTab($id)
|
103 |
+
{
|
104 |
+
if ($id == self::TAB_ID_BUY || $id == self::TAB_ID_PLAY) {
|
105 |
+
$id = self::TAB_ID_RAKUTEN;
|
106 |
+
}
|
107 |
+
parent::setEnabledTab($id);
|
108 |
+
}
|
109 |
+
|
110 |
+
protected function getActiveTab()
|
111 |
+
{
|
112 |
+
$activeTab = $this->getRequest()->getParam('tab');
|
113 |
+
if (is_null($activeTab)) {
|
114 |
+
Mage::helper('M2ePro/View_Common_Component')->isAmazonDefault() && $activeTab = self::TAB_ID_AMAZON;
|
115 |
+
Mage::helper('M2ePro/View_Common_Component')->isRakutenDefault() && $activeTab = self::TAB_ID_RAKUTEN;
|
116 |
+
}
|
117 |
+
|
118 |
+
return $activeTab;
|
119 |
+
}
|
120 |
+
|
121 |
+
// ########################################
|
122 |
+
|
123 |
+
protected function getAmazonTabBlock()
|
124 |
+
{
|
125 |
+
if (!$this->getChild('amazon_tab')) {
|
126 |
+
$this->setChild(
|
127 |
+
'amazon_tab',
|
128 |
+
$this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_marketplace_form')
|
129 |
+
);
|
130 |
+
}
|
131 |
+
return $this->getChild('amazon_tab');
|
132 |
+
}
|
133 |
+
|
134 |
+
protected function getBuyTabBlock()
|
135 |
+
{
|
136 |
+
return null;
|
137 |
+
}
|
138 |
+
|
139 |
+
protected function getPlayTabBlock()
|
140 |
+
{
|
141 |
+
return null;
|
142 |
+
}
|
143 |
+
|
144 |
+
protected function getRakutenTabBlock()
|
145 |
+
{
|
146 |
+
if (!$this->getChild('rakuten_tab')) {
|
147 |
+
$this->setChild(
|
148 |
+
'rakuten_tab',
|
149 |
+
$this->getLayout()->createBlock('M2ePro/adminhtml_common_rakuten_marketplace_form','',
|
150 |
+
array('active_wizard' => $this->activeWizardNick))
|
151 |
+
);
|
152 |
+
}
|
153 |
+
return $this->getChild('rakuten_tab');
|
154 |
+
}
|
155 |
+
|
156 |
+
protected function getRakutenTabHtml()
|
157 |
+
{
|
158 |
+
return $this->getRakutenTabBlock()->toHtml();
|
159 |
+
}
|
160 |
+
|
161 |
+
// ########################################
|
162 |
+
|
163 |
+
protected function getTabLabelById($id)
|
164 |
+
{
|
165 |
+
if ($id == self::TAB_ID_RAKUTEN) {
|
166 |
+
return Mage::helper('M2ePro')->__('Rakuten (Beta)');
|
167 |
+
}
|
168 |
+
|
169 |
+
return parent::getTabLabelById($id);
|
170 |
+
}
|
171 |
+
|
172 |
+
protected function _toHtml()
|
173 |
+
{
|
174 |
+
return '<div id="marketplaces_progress_bar"></div>' .
|
175 |
+
'<div id="marketplaces_content_container">' .
|
176 |
+
parent::_toHtml() .
|
177 |
+
'</div>';
|
178 |
+
}
|
179 |
+
|
180 |
+
protected function _componentsToHtml()
|
181 |
+
{
|
182 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_marketplace_help');
|
183 |
+
|
184 |
+
$formBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_marketplace_general_form');
|
185 |
+
count($this->tabs) == 1 && $formBlock->setChildBlockId($this->getSingleBlock()->getContainerId());
|
186 |
+
|
187 |
+
return $helpBlock->toHtml() .
|
188 |
+
parent::_componentsToHtml() .
|
189 |
+
$formBlock->toHtml();
|
190 |
+
}
|
191 |
+
|
192 |
+
protected function getTabsContainerDestinationHtml()
|
193 |
+
{
|
194 |
+
return '';
|
195 |
+
}
|
196 |
+
|
197 |
+
protected function getTabIdByWizardNick($wizardNick)
|
198 |
+
{
|
199 |
+
if ($wizardNick == Ess_M2ePro_Helper_Component_Amazon::NICK) {
|
200 |
+
return self::TAB_ID_AMAZON;
|
201 |
+
}
|
202 |
+
|
203 |
+
return self::TAB_ID_RAKUTEN;
|
204 |
+
}
|
205 |
+
|
206 |
+
// ########################################
|
207 |
+
|
208 |
+
public function canShowUpdateNowButton()
|
209 |
+
{
|
210 |
+
return !(bool)$this->getRequest()->getParam('wizard',false);
|
211 |
+
}
|
212 |
+
|
213 |
+
// ########################################
|
214 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Marketplace/General/Form.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_Marketplace_General_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('marketplaceForm');
|
18 |
+
$this->setTemplate('M2ePro/common/marketplace/form.phtml');
|
19 |
+
//------------------------------
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _prepareForm()
|
23 |
+
{
|
24 |
+
$form = new Varien_Data_Form(array(
|
25 |
+
'id' => 'edit_form',
|
26 |
+
'action' => $this->getUrl('*/*/save'),
|
27 |
+
'method' => 'post',
|
28 |
+
'enctype' => 'multipart/form-data'
|
29 |
+
));
|
30 |
+
|
31 |
+
//$form->setUseContainer(true);
|
32 |
+
$this->setForm($form);
|
33 |
+
|
34 |
+
return parent::_prepareForm();
|
35 |
+
}
|
36 |
+
|
37 |
+
// ########################################
|
38 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Marketplace/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_Marketplace_Help extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
// ########################################
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
$this->setTemplate('M2ePro/common/marketplace/help.phtml');
|
15 |
+
}
|
16 |
+
|
17 |
+
// ########################################
|
18 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Order.php
ADDED
@@ -0,0 +1,217 @@
|
|
Â
|
|
Â
|
|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â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Order extends Ess_M2ePro_Block_Adminhtml_Common_Component_Tabs_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Set header text
|
14 |
+
//------------------------------
|
15 |
+
$this->_headerText = Mage::helper('M2ePro')->__('Orders');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
//------------------------------
|
19 |
+
$url = $this->getUrl('*/adminhtml_common_account/index');
|
20 |
+
$this->_addButton('accounts', array(
|
21 |
+
'label' => Mage::helper('M2ePro')->__('Accounts'),
|
22 |
+
'onclick' => 'setLocation(\'' . $url .'\')',
|
23 |
+
'class' => 'button_link'
|
24 |
+
));
|
25 |
+
//------------------------------
|
26 |
+
|
27 |
+
//------------------------------
|
28 |
+
$url = $this->getUrl('*/adminhtml_common_log/order');
|
29 |
+
$this->_addButton('logs', array(
|
30 |
+
'label' => Mage::helper('M2ePro')->__('View Logs'),
|
31 |
+
'onclick' => 'window.open(\'' . $url .'\')',
|
32 |
+
'class' => 'button_link'
|
33 |
+
));
|
34 |
+
//------------------------------
|
35 |
+
|
36 |
+
//------------------------------
|
37 |
+
$this->_addButton('reset', array(
|
38 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
39 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
40 |
+
'class' => 'reset'
|
41 |
+
));
|
42 |
+
//------------------------------
|
43 |
+
|
44 |
+
$this->useAjax = true;
|
45 |
+
$this->tabsAjaxUrls = array(
|
46 |
+
self::TAB_ID_AMAZON => $this->getUrl('*/adminhtml_common_amazon_order/index'),
|
47 |
+
self::TAB_ID_BUY => $this->getUrl('*/adminhtml_common_buy_order/index'),
|
48 |
+
self::TAB_ID_PLAY => $this->getUrl('*/adminhtml_common_play_order/index'),
|
49 |
+
);
|
50 |
+
}
|
51 |
+
|
52 |
+
// ########################################
|
53 |
+
|
54 |
+
protected function getHelpBlockJavascript($helpContainerId)
|
55 |
+
{
|
56 |
+
if (!$this->getRequest()->isXmlHttpRequest()) {
|
57 |
+
return '';
|
58 |
+
}
|
59 |
+
|
60 |
+
return <<<JAVASCRIPT
|
61 |
+
<script type="text/javascript">
|
62 |
+
setTimeout(function() {
|
63 |
+
OrderHandlerObj.initializeGrids();
|
64 |
+
}, 50);
|
65 |
+
</script>
|
66 |
+
JAVASCRIPT;
|
67 |
+
}
|
68 |
+
|
69 |
+
// ########################################
|
70 |
+
|
71 |
+
protected function getAmazonTabBlock()
|
72 |
+
{
|
73 |
+
if (!$this->getChild('amazon_tab')) {
|
74 |
+
$this->setChild('amazon_tab', $this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_order_grid'));
|
75 |
+
}
|
76 |
+
return $this->getChild('amazon_tab');
|
77 |
+
}
|
78 |
+
|
79 |
+
public function getAmazonTabHtml()
|
80 |
+
{
|
81 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_amazon_order_help');
|
82 |
+
$javascript = $this->getHelpBlockJavascript($helpBlock->getContainerId());
|
83 |
+
|
84 |
+
return $javascript . $helpBlock->toHtml() . $this->getAmazonTabBlockFilterHtml() . parent::getAmazonTabHtml();
|
85 |
+
}
|
86 |
+
|
87 |
+
private function getAmazonTabBlockFilterHtml()
|
88 |
+
{
|
89 |
+
$marketplaceFilterBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_marketplace_switcher', '', array(
|
90 |
+
'component_mode' => Ess_M2ePro_Helper_Component_Amazon::NICK,
|
91 |
+
'controller_name' => 'adminhtml_common_order'
|
92 |
+
));
|
93 |
+
$marketplaceFilterBlock->setUseConfirm(false);
|
94 |
+
|
95 |
+
$accountFilterBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_account_switcher', '', array(
|
96 |
+
'component_mode' => Ess_M2ePro_Helper_Component_Amazon::NICK,
|
97 |
+
'controller_name' => 'adminhtml_common_order'
|
98 |
+
));
|
99 |
+
$accountFilterBlock->setUseConfirm(false);
|
100 |
+
|
101 |
+
$orderStateSwitcherBlock = $this->getLayout()->createBlock(
|
102 |
+
'M2ePro/adminhtml_order_notCreatedFilter',
|
103 |
+
'',
|
104 |
+
array(
|
105 |
+
'component_mode' => Ess_M2ePro_Helper_Component_Amazon::NICK,
|
106 |
+
'controller' => 'adminhtml_common_order'
|
107 |
+
)
|
108 |
+
);
|
109 |
+
|
110 |
+
return '<div class="filter_block">'
|
111 |
+
. $marketplaceFilterBlock->toHtml()
|
112 |
+
. $accountFilterBlock->toHtml()
|
113 |
+
. $orderStateSwitcherBlock->toHtml()
|
114 |
+
. '</div>';
|
115 |
+
}
|
116 |
+
|
117 |
+
// ########################################
|
118 |
+
|
119 |
+
protected function getBuyTabBlock()
|
120 |
+
{
|
121 |
+
if (!$this->getChild('buy_tab')) {
|
122 |
+
$this->setChild('buy_tab', $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_order_grid'));
|
123 |
+
}
|
124 |
+
return $this->getChild('buy_tab');
|
125 |
+
}
|
126 |
+
|
127 |
+
public function getBuyTabHtml()
|
128 |
+
{
|
129 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_buy_order_help');
|
130 |
+
$javascript = $this->getHelpBlockJavascript($helpBlock->getContainerId());
|
131 |
+
|
132 |
+
return $javascript . $helpBlock->toHtml() . $this->getBuyTabBlockFilterHtml() . parent::getBuyTabHtml();
|
133 |
+
}
|
134 |
+
|
135 |
+
private function getBuyTabBlockFilterHtml()
|
136 |
+
{
|
137 |
+
$accountFilterBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_account_switcher', '', array(
|
138 |
+
'component_mode' => Ess_M2ePro_Helper_Component_Buy::NICK,
|
139 |
+
'controller_name' => 'adminhtml_common_order'
|
140 |
+
));
|
141 |
+
$accountFilterBlock->setUseConfirm(false);
|
142 |
+
|
143 |
+
$orderStateSwitcherBlock = $this->getLayout()->createBlock(
|
144 |
+
'M2ePro/adminhtml_order_notCreatedFilter',
|
145 |
+
'',
|
146 |
+
array(
|
147 |
+
'component_mode' => Ess_M2ePro_Helper_Component_Buy::NICK,
|
148 |
+
'controller' => 'adminhtml_common_order'
|
149 |
+
)
|
150 |
+
);
|
151 |
+
|
152 |
+
return '<div class="filter_block">'
|
153 |
+
. $accountFilterBlock->toHtml()
|
154 |
+
. $orderStateSwitcherBlock->toHtml()
|
155 |
+
. '</div>';
|
156 |
+
}
|
157 |
+
|
158 |
+
// ########################################
|
159 |
+
|
160 |
+
protected function getPlayTabBlock()
|
161 |
+
{
|
162 |
+
if (!$this->getChild('play_tab')) {
|
163 |
+
$this->setChild('play_tab', $this->getLayout()->createBlock('M2ePro/adminhtml_common_play_order_grid'));
|
164 |
+
}
|
165 |
+
return $this->getChild('play_tab');
|
166 |
+
}
|
167 |
+
|
168 |
+
public function getPlayTabHtml()
|
169 |
+
{
|
170 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_play_order_help');
|
171 |
+
$javascript = $this->getHelpBlockJavascript($helpBlock->getContainerId());
|
172 |
+
|
173 |
+
return $javascript . $helpBlock->toHtml() . $this->getPlayTabBlockFilterHtml() . parent::getPlayTabHtml();
|
174 |
+
}
|
175 |
+
|
176 |
+
private function getPlayTabBlockFilterHtml()
|
177 |
+
{
|
178 |
+
$accountFilterBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_account_switcher', '', array(
|
179 |
+
'component_mode' => Ess_M2ePro_Helper_Component_Play::NICK,
|
180 |
+
'controller_name' => 'adminhtml_common_order'
|
181 |
+
));
|
182 |
+
$accountFilterBlock->setUseConfirm(false);
|
183 |
+
|
184 |
+
$orderStateSwitcherBlock = $this->getLayout()->createBlock(
|
185 |
+
'M2ePro/adminhtml_order_notCreatedFilter',
|
186 |
+
'',
|
187 |
+
array(
|
188 |
+
'component_mode' => Ess_M2ePro_Helper_Component_Play::NICK,
|
189 |
+
'controller' => 'adminhtml_common_order'
|
190 |
+
)
|
191 |
+
);
|
192 |
+
|
193 |
+
return '<div class="filter_block">'
|
194 |
+
. $accountFilterBlock->toHtml()
|
195 |
+
. $orderStateSwitcherBlock->toHtml()
|
196 |
+
. '</div>';
|
197 |
+
}
|
198 |
+
|
199 |
+
// ########################################
|
200 |
+
|
201 |
+
protected function _componentsToHtml()
|
202 |
+
{
|
203 |
+
$tempGridIds = array();
|
204 |
+
Mage::helper('M2ePro/Component_Amazon')->isActive() && $tempGridIds[] = $this->getAmazonTabBlock()->getId();
|
205 |
+
Mage::helper('M2ePro/Component_Buy')->isActive() && $tempGridIds[] = $this->getBuyTabBlock()->getId();
|
206 |
+
Mage::helper('M2ePro/Component_Play')->isActive() && $tempGridIds[] = $this->getPlayTabBlock()->getId();
|
207 |
+
|
208 |
+
$generalBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_order_general');
|
209 |
+
$generalBlock->setGridIds($tempGridIds);
|
210 |
+
|
211 |
+
$editItemBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_order_item_edit');
|
212 |
+
|
213 |
+
return $generalBlock->toHtml() . $editItemBlock->toHtml() . parent::_componentsToHtml();
|
214 |
+
}
|
215 |
+
|
216 |
+
// ########################################
|
217 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Order/Log.php
ADDED
@@ -0,0 +1,93 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2011 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Order_Log 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('orderLog');
|
18 |
+
$this->_blockGroup = 'M2ePro';
|
19 |
+
$this->_controller = 'adminhtml_order_log';
|
20 |
+
//------------------------------
|
21 |
+
|
22 |
+
// Set header text
|
23 |
+
//------------------------------
|
24 |
+
$this->_headerText = Mage::helper('M2ePro')->__('Orders Log');
|
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 |
+
$backUrl = Mage::helper('M2ePro')->getBackUrl('*/adminhtml_common_order/index');
|
40 |
+
$this->_addButton('back', array(
|
41 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
42 |
+
'onclick' => 'CommonHandlerObj.back_click(\''.$backUrl.'\')',
|
43 |
+
'class' => 'back'
|
44 |
+
));
|
45 |
+
}
|
46 |
+
|
47 |
+
$this->_addButton('goto_orders', array(
|
48 |
+
'label' => Mage::helper('M2ePro')->__('Orders'),
|
49 |
+
'onclick' => 'setLocation(\'' .$this->getUrl('*/adminhtml_common_order/index').'\')',
|
50 |
+
'class' => 'button_link'
|
51 |
+
));
|
52 |
+
|
53 |
+
$this->_addButton('reset', array(
|
54 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
55 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
56 |
+
'class' => 'reset'
|
57 |
+
));
|
58 |
+
//------------------------------
|
59 |
+
}
|
60 |
+
|
61 |
+
// ########################################
|
62 |
+
|
63 |
+
public function getGridHtml()
|
64 |
+
{
|
65 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_order_log_help');
|
66 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
67 |
+
}
|
68 |
+
|
69 |
+
protected function _toHtml()
|
70 |
+
{
|
71 |
+
$translations = json_encode(array(
|
72 |
+
'Description' => Mage::helper('M2ePro')->__('Description')
|
73 |
+
));
|
74 |
+
|
75 |
+
$javascript = <<<JAVASCIRPT
|
76 |
+
|
77 |
+
<script type="text/javascript">
|
78 |
+
|
79 |
+
M2ePro.translator.add({$translations});
|
80 |
+
|
81 |
+
Event.observe(window, 'load', function() {
|
82 |
+
LogHandlerObj = new LogHandler();
|
83 |
+
});
|
84 |
+
|
85 |
+
</script>
|
86 |
+
|
87 |
+
JAVASCIRPT;
|
88 |
+
|
89 |
+
return $javascript . parent::_toHtml();
|
90 |
+
}
|
91 |
+
|
92 |
+
// ########################################
|
93 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Order/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_Order_Log_Help extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('commonOrderLogHelp');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/order/log/help.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common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 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Play_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('playAccountEdit');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_play_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')->__(Ess_M2ePro_Helper_Component_Play::TITLE);
|
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(
|
37 |
+
Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getTitle()
|
38 |
+
).'"';
|
39 |
+
} else {
|
40 |
+
$this->_headerText = $headerTextAdd;
|
41 |
+
}
|
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 |
+
/* @var $wizardHelper Ess_M2ePro_Helper_Module_Wizard */
|
55 |
+
$wizardHelper = Mage::helper('M2ePro/Module_Wizard');
|
56 |
+
|
57 |
+
if ($wizardHelper->isActive('play') &&
|
58 |
+
$wizardHelper->getStep('play') == 'account'
|
59 |
+
) {
|
60 |
+
//------------------------------
|
61 |
+
$this->_addButton('reset', array(
|
62 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
63 |
+
'onclick' => 'PlayAccountHandlerObj.reset_click()',
|
64 |
+
'class' => 'reset'
|
65 |
+
));
|
66 |
+
//------------------------------
|
67 |
+
|
68 |
+
//------------------------------
|
69 |
+
$this->_addButton('save_and_continue', array(
|
70 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
71 |
+
'onclick' => 'PlayAccountHandlerObj.save_and_edit_click(\'\',\'playAccountEditTabs\')',
|
72 |
+
'class' => 'save'
|
73 |
+
));
|
74 |
+
//------------------------------
|
75 |
+
|
76 |
+
if ($this->getRequest()->getParam('id')) {
|
77 |
+
//------------------------------
|
78 |
+
$url = $this->getUrl('*/adminhtml_common_play_account/new', array('wizard' => true));
|
79 |
+
$this->_addButton('add_new_account', array(
|
80 |
+
'label' => Mage::helper('M2ePro')->__('Add New Account'),
|
81 |
+
'onclick' => 'setLocation(\''. $url .'\')',
|
82 |
+
'class' => 'add_new_account'
|
83 |
+
));
|
84 |
+
//------------------------------
|
85 |
+
|
86 |
+
//------------------------------
|
87 |
+
$this->_addButton('close', array(
|
88 |
+
'label' => Mage::helper('M2ePro')->__('Complete This Step'),
|
89 |
+
'onclick' => 'PlayAccountHandlerObj.completeStep();',
|
90 |
+
'class' => 'close'
|
91 |
+
));
|
92 |
+
//------------------------------
|
93 |
+
}
|
94 |
+
} else {
|
95 |
+
//------------------------------
|
96 |
+
$url = Mage::helper('M2ePro')->getBackUrl('list');
|
97 |
+
$this->_addButton('back', array(
|
98 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
99 |
+
'onclick' => 'PlayAccountHandlerObj.back_click(\'' . $url .'\')',
|
100 |
+
'class' => 'back'
|
101 |
+
));
|
102 |
+
//------------------------------
|
103 |
+
|
104 |
+
//------------------------------
|
105 |
+
$this->_addButton('reset', array(
|
106 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
107 |
+
'onclick' => 'PlayAccountHandlerObj.reset_click()',
|
108 |
+
'class' => 'reset'
|
109 |
+
));
|
110 |
+
//------------------------------
|
111 |
+
|
112 |
+
if (Mage::helper('M2ePro/Data_Global')->getValue('temp_data') &&
|
113 |
+
Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()
|
114 |
+
) {
|
115 |
+
//------------------------------
|
116 |
+
$this->_addButton('delete', array(
|
117 |
+
'label' => Mage::helper('M2ePro')->__('Delete'),
|
118 |
+
'onclick' => 'PlayAccountHandlerObj.delete_click()',
|
119 |
+
'class' => 'delete M2ePro_delete_button'
|
120 |
+
));
|
121 |
+
//------------------------------
|
122 |
+
}
|
123 |
+
|
124 |
+
//------------------------------
|
125 |
+
$this->_addButton('save', array(
|
126 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
127 |
+
'onclick' => 'PlayAccountHandlerObj.save_click()',
|
128 |
+
'class' => 'save'
|
129 |
+
));
|
130 |
+
//------------------------------
|
131 |
+
|
132 |
+
//------------------------------
|
133 |
+
$this->_addButton('save_and_continue', array(
|
134 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
135 |
+
'onclick' => 'PlayAccountHandlerObj.save_and_edit_click(\'\',\'playAccountEditTabs\')',
|
136 |
+
'class' => 'save'
|
137 |
+
));
|
138 |
+
//------------------------------
|
139 |
+
}
|
140 |
+
}
|
141 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/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_Play_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('playAccountEditForm');
|
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/Play/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_Play_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('playAccountEditTabs');
|
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_play_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_play_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_play_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/Play/Account/Edit/Tabs/General.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_Play_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('playAccountEditTabsGeneral');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/play/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_Play')->getCachedObject('Account',$accountId)
|
39 |
+
);
|
40 |
+
}
|
41 |
+
} else {
|
42 |
+
$this->synchronizeProcessing = false;
|
43 |
+
}
|
44 |
+
|
45 |
+
$marketplaces = Mage::helper('M2ePro/Component_Play')->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 |
+
|
53 |
+
//------------------------------
|
54 |
+
$data = array(
|
55 |
+
'label' => Mage::helper('M2ePro')->__('Update Password'),
|
56 |
+
'onclick' => 'PlayAccountHandlerObj.update_password()',
|
57 |
+
'class' => 'scalable'
|
58 |
+
);
|
59 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
60 |
+
$this->setChild('play_update_password', $buttonBlock);
|
61 |
+
//------------------------------
|
62 |
+
|
63 |
+
return parent::_beforeToHtml();
|
64 |
+
}
|
65 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/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_Play_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('playAccountEditTabsListingOther');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/play/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/Play/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_Play_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('playAccountEditTabsOrder');
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$this->setTemplate('M2ePro/common/play/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/Play/Listing.php
ADDED
@@ -0,0 +1,164 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Play_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('playListing');
|
18 |
+
$this->_blockGroup = 'M2ePro';
|
19 |
+
$this->_controller = 'adminhtml_common_play_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_PLAY
|
43 |
+
)
|
44 |
+
);
|
45 |
+
|
46 |
+
//------------------------------
|
47 |
+
$url = $this->getUrl(
|
48 |
+
'*/adminhtml_common_listing_other/index',
|
49 |
+
array(
|
50 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_PLAY,
|
51 |
+
'back' => $backUrl
|
52 |
+
)
|
53 |
+
);
|
54 |
+
$this->_addButton('goto_listing_other', array(
|
55 |
+
'label' => Mage::helper('M2ePro')->__('3rd Party Listings'),
|
56 |
+
'onclick' => 'setLocation(\''.$url.'\')',
|
57 |
+
'class' => 'button_link'
|
58 |
+
));
|
59 |
+
//------------------------------
|
60 |
+
|
61 |
+
//------------------------------
|
62 |
+
$this->_addButton('goto_template', array(
|
63 |
+
'label' => Mage::helper('M2ePro')->__('Templates'),
|
64 |
+
'onclick' => '',
|
65 |
+
'class' => 'button_link play-templates-drop-down'
|
66 |
+
));
|
67 |
+
//------------------------------
|
68 |
+
|
69 |
+
//------------------------------
|
70 |
+
$url = $this->getUrl(
|
71 |
+
'*/adminhtml_common_log/listing',
|
72 |
+
array(
|
73 |
+
'filter' => base64_encode('component_mode=' . Ess_M2ePro_Helper_Component_Play::NICK)
|
74 |
+
)
|
75 |
+
);
|
76 |
+
$this->_addButton('view_log', array(
|
77 |
+
'label' => Mage::helper('M2ePro')->__('View Log'),
|
78 |
+
'onclick' => 'window.open(\''.$url.'\')',
|
79 |
+
'class' => 'button_link'
|
80 |
+
));
|
81 |
+
//------------------------------
|
82 |
+
|
83 |
+
//------------------------------
|
84 |
+
$url = $this->getUrl('*/adminhtml_common_play_listing/search', array('back' => $backUrl));
|
85 |
+
$this->_addButton('search_play_products', array(
|
86 |
+
'label' => Mage::helper('M2ePro')->__('Search Items'),
|
87 |
+
'onclick' => 'setLocation(\''.$url.'\')',
|
88 |
+
'class' => 'button_link search'
|
89 |
+
));
|
90 |
+
//------------------------------
|
91 |
+
|
92 |
+
//------------------------------
|
93 |
+
if (Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
94 |
+
$this->_addButton('reset', array(
|
95 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
96 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
97 |
+
'class' => 'reset'
|
98 |
+
));
|
99 |
+
}
|
100 |
+
//------------------------------
|
101 |
+
|
102 |
+
//------------------------------
|
103 |
+
$url = $this->getUrl('*/adminhtml_common_play_listing/add', array('step' => '1','clear'=>'yes'));
|
104 |
+
$this->_addButton('add', array(
|
105 |
+
'label' => Mage::helper('M2ePro')->__('Add Listing'),
|
106 |
+
'onclick' => 'setLocation(\'' .$url.'\')',
|
107 |
+
'class' => 'add'
|
108 |
+
));
|
109 |
+
//------------------------------
|
110 |
+
}
|
111 |
+
|
112 |
+
// ####################################
|
113 |
+
|
114 |
+
public function getTemplatesButtonJavascript()
|
115 |
+
{
|
116 |
+
$data = array(
|
117 |
+
'target_css_class' => 'play-templates-drop-down',
|
118 |
+
'items' => $this->getTemplatesButtonDropDownItems()
|
119 |
+
);
|
120 |
+
$dropDownBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_button_dropDown');
|
121 |
+
$dropDownBlock->setData($data);
|
122 |
+
|
123 |
+
return $dropDownBlock->toHtml();
|
124 |
+
}
|
125 |
+
|
126 |
+
protected function getTemplatesButtonDropDownItems()
|
127 |
+
{
|
128 |
+
$items = array();
|
129 |
+
|
130 |
+
$filter = base64_encode('component_mode=' . Ess_M2ePro_Helper_Component_Play::NICK);
|
131 |
+
|
132 |
+
//------------------------------
|
133 |
+
$url = $this->getUrl(
|
134 |
+
'*/adminhtml_common_template_sellingFormat/index',
|
135 |
+
array(
|
136 |
+
'filter' => $filter
|
137 |
+
)
|
138 |
+
);
|
139 |
+
$items[] = array(
|
140 |
+
'url' => $url,
|
141 |
+
'label' => Mage::helper('M2ePro')->__('Selling Format Templates'),
|
142 |
+
'target' => '_blank'
|
143 |
+
);
|
144 |
+
//------------------------------
|
145 |
+
|
146 |
+
//------------------------------
|
147 |
+
$url = $this->getUrl(
|
148 |
+
'*/adminhtml_common_template_synchronization/index',
|
149 |
+
array(
|
150 |
+
'filter' => $filter
|
151 |
+
)
|
152 |
+
);
|
153 |
+
$items[] = array(
|
154 |
+
'url' => $url,
|
155 |
+
'label' => Mage::helper('M2ePro')->__('Synchronization Templates'),
|
156 |
+
'target' => '_blank'
|
157 |
+
);
|
158 |
+
//------------------------------
|
159 |
+
|
160 |
+
return $items;
|
161 |
+
}
|
162 |
+
|
163 |
+
// ####################################
|
164 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Add/StepFive.php
ADDED
@@ -0,0 +1,91 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Play_Listing_Add_StepFive extends Mage_Adminhtml_Block_Widget_Grid_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('playListingAddStepFive');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_play_listing_product';
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
// Set header text
|
21 |
+
//------------------------------
|
22 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
23 |
+
$componentName = Mage::helper('M2ePro')->__(Ess_M2ePro_Helper_Component_Play::TITLE);
|
24 |
+
$headerText = Mage::helper('M2ePro')->__("Add %component_name% Listing [Select Categories Products]",
|
25 |
+
$componentName);
|
26 |
+
|
27 |
+
} else {
|
28 |
+
$headerText = Mage::helper('M2ePro')->__("Add Listing [Select Categories Products]");
|
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 |
+
$url = $this->getUrl('*/adminhtml_common_play_listing/add', array('step' => '4'));
|
46 |
+
$this->_addButton('back', array(
|
47 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
48 |
+
'onclick' => 'ProductGridHandlerObj.back_click(\'' . $url . '\')',
|
49 |
+
'class' => 'back'
|
50 |
+
));
|
51 |
+
//------------------------------
|
52 |
+
|
53 |
+
//------------------------------
|
54 |
+
$this->_addButton('reset', array(
|
55 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
56 |
+
'onclick' => 'ProductGridHandlerObj.reset_click()',
|
57 |
+
'class' => 'reset'
|
58 |
+
));
|
59 |
+
//------------------------------
|
60 |
+
|
61 |
+
//------------------------------
|
62 |
+
$this->_addButton('save_and_go_to_listings_list', array(
|
63 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
64 |
+
'onclick' => 'ProductGridHandlerObj.save_click(\'list\')',
|
65 |
+
'class' => 'save'
|
66 |
+
));
|
67 |
+
//------------------------------
|
68 |
+
|
69 |
+
//------------------------------
|
70 |
+
$this->_addButton('save_and_go_to_listing_view', array(
|
71 |
+
'label' => Mage::helper('M2ePro')->__('Save And View Listing'),
|
72 |
+
'onclick' => 'ProductGridHandlerObj.save_click(\'view\')',
|
73 |
+
'class' => 'save'
|
74 |
+
));
|
75 |
+
//------------------------------
|
76 |
+
}
|
77 |
+
|
78 |
+
public function getGridHtml()
|
79 |
+
{
|
80 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_play_listing_product_help');
|
81 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
82 |
+
}
|
83 |
+
|
84 |
+
protected function _toHtml()
|
85 |
+
{
|
86 |
+
return '<div id="add_products_progress_bar"></div>'.
|
87 |
+
'<div id="add_products_container">'.
|
88 |
+
parent::_toHtml().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/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Play_Listing_Add_StepFourCategory extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('PlayListingAddStepFourCategory');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_play_listing';
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$this->setTemplate('widget/view/container.phtml');
|
21 |
+
|
22 |
+
// Set header text
|
23 |
+
//------------------------------
|
24 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
25 |
+
$componentName = Mage::helper('M2ePro')->__(Ess_M2ePro_Helper_Component_Play::TITLE);
|
26 |
+
$headerText = Mage::helper('M2ePro')->__("Add %component_name% Listing [Select Categories]",
|
27 |
+
$componentName);
|
28 |
+
} else {
|
29 |
+
$headerText = Mage::helper('M2ePro')->__("Add Listing [Select Categories]");;
|
30 |
+
}
|
31 |
+
|
32 |
+
$this->_headerText = $headerText;
|
33 |
+
//------------------------------
|
34 |
+
|
35 |
+
// Set buttons actions
|
36 |
+
//------------------------------
|
37 |
+
$this->removeButton('back');
|
38 |
+
$this->removeButton('reset');
|
39 |
+
$this->removeButton('delete');
|
40 |
+
$this->removeButton('add');
|
41 |
+
$this->removeButton('save');
|
42 |
+
$this->removeButton('edit');
|
43 |
+
//------------------------------
|
44 |
+
|
45 |
+
//------------------------------
|
46 |
+
$url = $this->getUrl('*/adminhtml_common_play_listing/add', array('step' => '3'));
|
47 |
+
$this->_addButton('back', array(
|
48 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
49 |
+
'onclick' => 'PlayListingCategoryHandlerObj.back_click(\'' . $url . '\')',
|
50 |
+
'class' => 'back'
|
51 |
+
));
|
52 |
+
//------------------------------
|
53 |
+
|
54 |
+
//------------------------------
|
55 |
+
$this->_addButton('reset', array(
|
56 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
57 |
+
'onclick' => 'PlayListingCategoryHandlerObj.reset_click()',
|
58 |
+
'class' => 'reset'
|
59 |
+
));
|
60 |
+
//------------------------------
|
61 |
+
|
62 |
+
//------------------------------
|
63 |
+
$url = $this->getUrl(
|
64 |
+
'*/adminhtml_common_play_listing/add',
|
65 |
+
array(
|
66 |
+
'step' => '4',
|
67 |
+
'remember_categories' => 'yes'
|
68 |
+
)
|
69 |
+
);
|
70 |
+
$this->_addButton('save_and_next', array(
|
71 |
+
'label' => Mage::helper('M2ePro')->__('Next'),
|
72 |
+
'onclick' => 'PlayListingCategoryHandlerObj.save_click(\'' . $url . '\')',
|
73 |
+
'class' => 'next save_and_next_button'
|
74 |
+
));
|
75 |
+
//------------------------------
|
76 |
+
|
77 |
+
//------------------------------
|
78 |
+
$url = $this->getUrl(
|
79 |
+
'*/adminhtml_common_play_listing/add',
|
80 |
+
array(
|
81 |
+
'step' => '4',
|
82 |
+
'back' => 'list'
|
83 |
+
)
|
84 |
+
);
|
85 |
+
$this->_addButton('save_and_go_to_listings_list', array(
|
86 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
87 |
+
'onclick' => 'PlayListingCategoryHandlerObj.save_click(\'' . $url . '\')',
|
88 |
+
'class' => 'save save_and_go_to_listings_list_button'
|
89 |
+
));
|
90 |
+
//------------------------------
|
91 |
+
|
92 |
+
//------------------------------
|
93 |
+
$url = $this->getUrl(
|
94 |
+
'*/adminhtml_common_play_listing/add',
|
95 |
+
array(
|
96 |
+
'step' => '4',
|
97 |
+
'back' => 'view'
|
98 |
+
)
|
99 |
+
);
|
100 |
+
$this->_addButton('save_and_go_to_listing_view', array(
|
101 |
+
'label' => Mage::helper('M2ePro')->__('Save And View Listing'),
|
102 |
+
'onclick' => 'PlayListingCategoryHandlerObj.save_click(\'' . $url . '\')',
|
103 |
+
'class' => 'save save_and_go_to_listing_view_button'
|
104 |
+
));
|
105 |
+
//------------------------------
|
106 |
+
}
|
107 |
+
|
108 |
+
protected function _toHtml()
|
109 |
+
{
|
110 |
+
$treeSettings = array(
|
111 |
+
'show_products_amount' => true,
|
112 |
+
'hide_products_this_listing' => false
|
113 |
+
);
|
114 |
+
// todo next
|
115 |
+
$categoryTreeBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_listing_category_tree',
|
116 |
+
'',
|
117 |
+
array('component'=>Ess_M2ePro_Helper_Component_Play::NICK,
|
118 |
+
'tree_settings' => $treeSettings));
|
119 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_play_listing_category_help');
|
120 |
+
$categoryBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_play_listing_category');
|
121 |
+
|
122 |
+
return '<div id="add_products_progress_bar"></div>'.
|
123 |
+
'<div id="add_products_container">'.
|
124 |
+
parent::_toHtml() . $helpBlock->toHtml() . $categoryTreeBlock->toHtml() . $categoryBlock->toHtml().
|
125 |
+
'</div>';
|
126 |
+
}
|
127 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Add/StepFourProduct.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_Play_Listing_Add_StepFourProduct
|
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('playListingAddStepFourProduct');
|
17 |
+
$this->_blockGroup = 'M2ePro';
|
18 |
+
$this->_controller = 'adminhtml_common_play_listing_product';
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
// Set header text
|
22 |
+
//------------------------------
|
23 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
24 |
+
$componentName = Mage::helper('M2ePro')->__(Ess_M2ePro_Helper_Component_Play::TITLE);
|
25 |
+
$headerText = Mage::helper('M2ePro')->__("Add %component_name% Listing [Select Products]", $componentName);
|
26 |
+
} else {
|
27 |
+
$headerText = Mage::helper('M2ePro')->__("Add Listing [Select Products]");
|
28 |
+
}
|
29 |
+
|
30 |
+
$this->_headerText =$headerText;
|
31 |
+
//------------------------------
|
32 |
+
|
33 |
+
// Set buttons actions
|
34 |
+
//------------------------------
|
35 |
+
$this->removeButton('back');
|
36 |
+
$this->removeButton('reset');
|
37 |
+
$this->removeButton('delete');
|
38 |
+
$this->removeButton('add');
|
39 |
+
$this->removeButton('save');
|
40 |
+
$this->removeButton('edit');
|
41 |
+
//------------------------------
|
42 |
+
|
43 |
+
//------------------------------
|
44 |
+
$url = $this->getUrl('*/adminhtml_common_play_listing/add', array('step' => '3'));
|
45 |
+
$this->_addButton('back', array(
|
46 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
47 |
+
'onclick' => 'ProductGridHandlerObj.back_click(\'' . $url . '\')',
|
48 |
+
'class' => 'back'
|
49 |
+
));
|
50 |
+
//------------------------------
|
51 |
+
|
52 |
+
//------------------------------
|
53 |
+
$this->_addButton('reset', array(
|
54 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
55 |
+
'onclick' => 'ProductGridHandlerObj.reset_click()',
|
56 |
+
'class' => 'reset'
|
57 |
+
));
|
58 |
+
//------------------------------
|
59 |
+
|
60 |
+
//------------------------------
|
61 |
+
$this->_addButton('save_and_go_to_listings_list', array(
|
62 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
63 |
+
'onclick' => 'ProductGridHandlerObj.save_click(\'list\')',
|
64 |
+
'class' => 'save'
|
65 |
+
));
|
66 |
+
//------------------------------
|
67 |
+
|
68 |
+
//------------------------------
|
69 |
+
$this->_addButton('save_and_go_to_listing_view', array(
|
70 |
+
'label' => Mage::helper('M2ePro')->__('Save And View Listing'),
|
71 |
+
'onclick' => 'ProductGridHandlerObj.save_click(\'view\')',
|
72 |
+
'class' => 'save'
|
73 |
+
));
|
74 |
+
//------------------------------
|
75 |
+
}
|
76 |
+
|
77 |
+
public function getGridHtml()
|
78 |
+
{
|
79 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_play_listing_product_help');
|
80 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
81 |
+
}
|
82 |
+
|
83 |
+
protected function _toHtml()
|
84 |
+
{
|
85 |
+
return '<div id="add_products_progress_bar"></div>'.
|
86 |
+
'<div id="add_products_container">'.
|
87 |
+
parent::_toHtml().
|
88 |
+
'</div>';
|
89 |
+
}
|
90 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Add/StepOne.php
ADDED
@@ -0,0 +1,74 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Play_Listing_Add_StepOne extends Mage_Adminhtml_Block_Widget_Form_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('playListingAddStepOne');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_play_listing';
|
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')->__(Ess_M2ePro_Helper_Component_Play::TITLE);
|
25 |
+
$headerText = Mage::helper('M2ePro')->__("Add %component_name% Listing [Settings]", $componentName);
|
26 |
+
} else {
|
27 |
+
$headerText = Mage::helper('M2ePro')->__("Add Listing [Settings]");
|
28 |
+
}
|
29 |
+
|
30 |
+
$this->_headerText = $headerText;
|
31 |
+
//------------------------------
|
32 |
+
|
33 |
+
// Set buttons actions
|
34 |
+
//------------------------------
|
35 |
+
$this->removeButton('back');
|
36 |
+
$this->removeButton('reset');
|
37 |
+
$this->removeButton('delete');
|
38 |
+
$this->removeButton('add');
|
39 |
+
$this->removeButton('save');
|
40 |
+
$this->removeButton('edit');
|
41 |
+
//------------------------------
|
42 |
+
|
43 |
+
//------------------------------
|
44 |
+
$url = $this->getUrl(
|
45 |
+
'*/adminhtml_common_listing/index',
|
46 |
+
array(
|
47 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_PLAY
|
48 |
+
)
|
49 |
+
);
|
50 |
+
$this->_addButton('back', array(
|
51 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
52 |
+
'onclick' => 'PlayListingSettingsHandlerObj.back_click(\'' . $url . '\')',
|
53 |
+
'class' => 'back'
|
54 |
+
));
|
55 |
+
//------------------------------
|
56 |
+
|
57 |
+
//------------------------------
|
58 |
+
$this->_addButton('reset', array(
|
59 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
60 |
+
'onclick' => 'PlayListingSettingsHandlerObj.reset_click()',
|
61 |
+
'class' => 'reset'
|
62 |
+
));
|
63 |
+
//------------------------------
|
64 |
+
|
65 |
+
//------------------------------
|
66 |
+
$url = $this->getUrl('*/adminhtml_common_play_listing/add', array('step' => '1'));
|
67 |
+
$this->_addButton('save_and_next', array(
|
68 |
+
'label' => Mage::helper('M2ePro')->__('Next'),
|
69 |
+
'onclick' => 'PlayListingSettingsHandlerObj.save_click(\'' . $url . '\')',
|
70 |
+
'class' => 'next'
|
71 |
+
));
|
72 |
+
//------------------------------
|
73 |
+
}
|
74 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Add/StepThree.php
ADDED
@@ -0,0 +1,69 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Play_Listing_Add_StepThree extends Mage_Adminhtml_Block_Widget_Form_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('playListingAddStepThree');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_play_listing';
|
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')->__(Ess_M2ePro_Helper_Component_Play::TITLE);
|
25 |
+
$headerText = Mage::helper('M2ePro')->__("Add %component_name% Listing [Products Filter]", $componentName);
|
26 |
+
} else {
|
27 |
+
$headerText = Mage::helper('M2ePro')->__("Add Listing [Products Filter]");
|
28 |
+
}
|
29 |
+
|
30 |
+
$this->_headerText = $headerText;
|
31 |
+
//------------------------------
|
32 |
+
|
33 |
+
// Set buttons actions
|
34 |
+
//------------------------------
|
35 |
+
$this->removeButton('back');
|
36 |
+
$this->removeButton('reset');
|
37 |
+
$this->removeButton('delete');
|
38 |
+
$this->removeButton('add');
|
39 |
+
$this->removeButton('save');
|
40 |
+
$this->removeButton('edit');
|
41 |
+
//------------------------------
|
42 |
+
|
43 |
+
//------------------------------
|
44 |
+
$url = $this->getUrl('*/adminhtml_common_play_listing/add', array('step' => '2'));
|
45 |
+
$this->_addButton('back', array(
|
46 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
47 |
+
'onclick' => 'CommonHandlerObj.back_click(\'' . $url . '\')',
|
48 |
+
'class' => 'back'
|
49 |
+
));
|
50 |
+
//------------------------------
|
51 |
+
|
52 |
+
//------------------------------
|
53 |
+
$this->_addButton('reset', array(
|
54 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
55 |
+
'onclick' => 'CommonHandlerObj.reset_click()',
|
56 |
+
'class' => 'reset'
|
57 |
+
));
|
58 |
+
//------------------------------
|
59 |
+
|
60 |
+
//------------------------------
|
61 |
+
$url = $this->getUrl('*/adminhtml_common_play_listing/add', array('step' => '3'));
|
62 |
+
$this->_addButton('save_and_next', array(
|
63 |
+
'label' => Mage::helper('M2ePro')->__('Next'),
|
64 |
+
'onclick' => 'CommonHandlerObj.save_click(\'' . $url . '\')',
|
65 |
+
'class' => 'next'
|
66 |
+
));
|
67 |
+
//------------------------------
|
68 |
+
}
|
69 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Add/StepTwo.php
ADDED
@@ -0,0 +1,69 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Play_Listing_Add_StepTwo extends Mage_Adminhtml_Block_Widget_Form_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('playListingAddStepTwo');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_play_listing';
|
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')->__(Ess_M2ePro_Helper_Component_Play::TITLE);
|
25 |
+
$headerText = Mage::helper('M2ePro')->__("Add %component_name% Listing [Channel Settings]", $componentName);
|
26 |
+
} else {
|
27 |
+
$headerText = Mage::helper('M2ePro')->__("Add Listing [Channel Settings]");
|
28 |
+
}
|
29 |
+
|
30 |
+
$this->_headerText = $headerText;
|
31 |
+
//------------------------------
|
32 |
+
|
33 |
+
// Set buttons actions
|
34 |
+
//------------------------------
|
35 |
+
$this->removeButton('back');
|
36 |
+
$this->removeButton('reset');
|
37 |
+
$this->removeButton('delete');
|
38 |
+
$this->removeButton('add');
|
39 |
+
$this->removeButton('save');
|
40 |
+
$this->removeButton('edit');
|
41 |
+
//------------------------------
|
42 |
+
|
43 |
+
//------------------------------
|
44 |
+
$url = $this->getUrl('*/adminhtml_common_play_listing/add', array('step' => '1'));
|
45 |
+
$this->_addButton('back', array(
|
46 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
47 |
+
'onclick' => 'PlayListingChannelSettingsHandlerObj.back_click(\'' . $url . '\')',
|
48 |
+
'class' => 'back'
|
49 |
+
));
|
50 |
+
//------------------------------
|
51 |
+
|
52 |
+
//------------------------------
|
53 |
+
$this->_addButton('reset', array(
|
54 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
55 |
+
'onclick' => 'PlayListingChannelSettingsHandlerObj.reset_click()',
|
56 |
+
'class' => 'reset'
|
57 |
+
));
|
58 |
+
//------------------------------
|
59 |
+
|
60 |
+
//------------------------------
|
61 |
+
$url = $this->getUrl('*/adminhtml_common_play_listing/add', array('step' => '2'));
|
62 |
+
$this->_addButton('save_and_next', array(
|
63 |
+
'label' => Mage::helper('M2ePro')->__('Next'),
|
64 |
+
'onclick' => 'PlayListingChannelSettingsHandlerObj.save_click(\'' . $url . '\')',
|
65 |
+
'class' => 'next'
|
66 |
+
));
|
67 |
+
//------------------------------
|
68 |
+
}
|
69 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Category.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_Play_Listing_Category extends Mage_Adminhtml_Block_Template
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('playListingCategory');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/play/listing/category.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Category/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_Play_Listing_Category_Help extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('playListingProductHelp');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/play/listing/category/help.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Edit.php
ADDED
@@ -0,0 +1,98 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Play_Listing_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('playListingEdit');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_play_listing';
|
18 |
+
$this->_mode = 'edit';
|
19 |
+
//------------------------------
|
20 |
+
|
21 |
+
// Set header text
|
22 |
+
//------------------------------
|
23 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
24 |
+
|
25 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
26 |
+
$headerText = Mage::helper('M2ePro')->__(
|
27 |
+
'Edit "%listing_title%" %component_name% Listing [Settings]',
|
28 |
+
$this->escapeHtml($listingData['title']),
|
29 |
+
Mage::helper('M2ePro')->__(Ess_M2ePro_Helper_Component_Play::TITLE)
|
30 |
+
);
|
31 |
+
} else {
|
32 |
+
$headerText = Mage::helper('M2ePro')->__(
|
33 |
+
'Edit "%listing_title%" Listing [Settings]',
|
34 |
+
$this->escapeHtml($listingData['title'])
|
35 |
+
);
|
36 |
+
}
|
37 |
+
|
38 |
+
$this->_headerText = $headerText;
|
39 |
+
//------------------------------
|
40 |
+
|
41 |
+
// Set buttons actions
|
42 |
+
//------------------------------
|
43 |
+
$this->removeButton('back');
|
44 |
+
$this->removeButton('reset');
|
45 |
+
$this->removeButton('delete');
|
46 |
+
$this->removeButton('add');
|
47 |
+
$this->removeButton('save');
|
48 |
+
$this->removeButton('edit');
|
49 |
+
//------------------------------
|
50 |
+
|
51 |
+
if (!is_null($this->getRequest()->getParam('back'))) {
|
52 |
+
//------------------------------
|
53 |
+
$url = Mage::helper('M2ePro')->getBackUrl(
|
54 |
+
'*/adminhtml_common_listing/index',
|
55 |
+
array(
|
56 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_PLAY
|
57 |
+
)
|
58 |
+
);
|
59 |
+
$this->_addButton('back', array(
|
60 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
61 |
+
'onclick' => 'PlayListingSettingsHandlerObj.back_click(\''.$url.'\')',
|
62 |
+
'class' => 'back'
|
63 |
+
));
|
64 |
+
//------------------------------
|
65 |
+
}
|
66 |
+
|
67 |
+
//------------------------------
|
68 |
+
$this->_addButton('reset', array(
|
69 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
70 |
+
'onclick' => 'PlayListingSettingsHandlerObj.reset_click()',
|
71 |
+
'class' => 'reset'
|
72 |
+
));
|
73 |
+
//------------------------------
|
74 |
+
|
75 |
+
//------------------------------
|
76 |
+
$url = $this->getUrl(
|
77 |
+
'*/adminhtml_common_play_listing/save',
|
78 |
+
array(
|
79 |
+
'id' => $listingData['id'],
|
80 |
+
'back' => Mage::helper('M2ePro')->getBackUrlParam('list')
|
81 |
+
)
|
82 |
+
);
|
83 |
+
$this->_addButton('save', array(
|
84 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
85 |
+
'onclick' => 'PlayListingSettingsHandlerObj.save_click(\'' . $url . '\')',
|
86 |
+
'class' => 'save'
|
87 |
+
));
|
88 |
+
//------------------------------
|
89 |
+
|
90 |
+
//------------------------------
|
91 |
+
$this->_addButton('save_and_continue', array(
|
92 |
+
'label' => Mage::helper('M2ePro')->__('Save And Continue Edit'),
|
93 |
+
'onclick' => 'PlayListingSettingsHandlerObj.save_and_edit_click(\'\',\'playListingEditTabs\')',
|
94 |
+
'class' => 'save'
|
95 |
+
));
|
96 |
+
//------------------------------
|
97 |
+
}
|
98 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Edit/Form.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_Play_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('playListingEditForm');
|
16 |
+
//------------------------------
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _prepareForm()
|
20 |
+
{
|
21 |
+
// Prepare action
|
22 |
+
// -------------------
|
23 |
+
$step = $this->getRequest()->getParam('step');
|
24 |
+
|
25 |
+
if (is_null($step)) {
|
26 |
+
// Edit listing mode
|
27 |
+
$action = $this->getUrl('*/adminhtml_common_play_listing/save');
|
28 |
+
} else {
|
29 |
+
// Add listing mode
|
30 |
+
$action = $this->getUrl('*/adminhtml_common_play_listing/add', array('step' => (int)$step));
|
31 |
+
}
|
32 |
+
// -------------------
|
33 |
+
|
34 |
+
$form = new Varien_Data_Form(array(
|
35 |
+
'id' => 'edit_form',
|
36 |
+
'action' => $action,
|
37 |
+
'method' => 'post',
|
38 |
+
'enctype' => 'multipart/form-data'
|
39 |
+
));
|
40 |
+
|
41 |
+
$form->setUseContainer(true);
|
42 |
+
$this->setForm($form);
|
43 |
+
|
44 |
+
return parent::_prepareForm();
|
45 |
+
}
|
46 |
+
|
47 |
+
protected function _beforeToHtml()
|
48 |
+
{
|
49 |
+
// Add listing mode
|
50 |
+
// -------------------
|
51 |
+
$child = NULL;
|
52 |
+
$step = $this->getRequest()->getParam('step');
|
53 |
+
|
54 |
+
if ($step == 1) {
|
55 |
+
$child = $this->getLayout()->createBlock('M2ePro/adminhtml_common_play_listing_edit_tabs_settings');
|
56 |
+
} else if ($step == 2) {
|
57 |
+
$child = $this->getLayout()->createBlock('M2ePro/adminhtml_common_play_listing_edit_tabs_channelSettings');
|
58 |
+
} elseif ($step == 3) {
|
59 |
+
$child = $this->getLayout()->createBlock('M2ePro/adminhtml_common_play_listing_edit_tabs_productsFilter');
|
60 |
+
}
|
61 |
+
|
62 |
+
if (!is_null($child)) {
|
63 |
+
$this->setTemplate('M2ePro/common/play/listing/add.phtml');
|
64 |
+
$this->setChild('general',
|
65 |
+
$this->getLayout()->createBlock('M2ePro/adminhtml_common_play_listing_edit_tabs_general'));
|
66 |
+
$this->setChild('content', $child);
|
67 |
+
}
|
68 |
+
// -------------------
|
69 |
+
|
70 |
+
return parent::_beforeToHtml();
|
71 |
+
}
|
72 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/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_Play_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('playListingEditTabs');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTitle(Mage::helper('M2ePro')->__('Configuration'));
|
19 |
+
$this->setDestElementId('edit_form');
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _beforeToHtml()
|
23 |
+
{
|
24 |
+
$this->addTab('settings', array(
|
25 |
+
'label' => Mage::helper('M2ePro')->__('Settings'),
|
26 |
+
'title' => Mage::helper('M2ePro')->__('Settings'),
|
27 |
+
'content' => $this->getLayout()
|
28 |
+
->createBlock('M2ePro/adminhtml_common_play_listing_edit_tabs_settings')
|
29 |
+
->toHtml(),
|
30 |
+
));
|
31 |
+
|
32 |
+
$this->addTab('channel', array(
|
33 |
+
'label' => Mage::helper('M2ePro')->__('Channel Settings'),
|
34 |
+
'title' => Mage::helper('M2ePro')->__('Channel Settings'),
|
35 |
+
'content' => $this->getLayout()
|
36 |
+
->createBlock('M2ePro/adminhtml_common_play_listing_edit_tabs_channelSettings')
|
37 |
+
->toHtml(),
|
38 |
+
));
|
39 |
+
|
40 |
+
$this->addTab('products_filter', array(
|
41 |
+
'label' => Mage::helper('M2ePro')->__('Products Filter'),
|
42 |
+
'title' => Mage::helper('M2ePro')->__('Products Filter'),
|
43 |
+
'content' => $this->getLayout()
|
44 |
+
->createBlock('M2ePro/adminhtml_common_play_listing_edit_tabs_ProductsFilter')
|
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/Play/Listing/Edit/Tabs/ChannelSettings.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_Play_Listing_Edit_Tabs_ChannelSettings extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('playListingEditTabsChannelSettings');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/play/listing/tabs/channel_settings.phtml');
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _beforeToHtml()
|
22 |
+
{
|
23 |
+
//-------------------------------
|
24 |
+
$accounts = Mage::helper('M2ePro/Component_Play')->getCollection('Account')
|
25 |
+
->setOrder('title', 'ASC')
|
26 |
+
->toArray();
|
27 |
+
$this->setData('accounts', $accounts['items']);
|
28 |
+
//-------------------------------
|
29 |
+
|
30 |
+
//-------------------------------
|
31 |
+
$formData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
32 |
+
$this->setData('attributes',
|
33 |
+
Mage::helper('M2ePro/Magento_Attribute')->getByAttributeSets($formData['attribute_sets']));
|
34 |
+
//-------------------------------
|
35 |
+
|
36 |
+
return parent::_beforeToHtml();
|
37 |
+
}
|
38 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Edit/Tabs/General.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_Play_Listing_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('playListingEditTabsChannelGeneral');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/play/listing/tabs/general.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Edit/Tabs/ProductsFilter.php
ADDED
@@ -0,0 +1,53 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Play_Listing_Edit_Tabs_ProductsFilter extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('playListingEditTabsProductsFilter');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/play/listing/tabs/products_filter.phtml');
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _beforeToHtml()
|
22 |
+
{
|
23 |
+
//-------------------------------
|
24 |
+
$accounts = Mage::helper('M2ePro/Component_Play')->getCollection('Account')
|
25 |
+
->setOrder('title', 'ASC')
|
26 |
+
->toArray();
|
27 |
+
$this->setData('accounts', $accounts['items']);
|
28 |
+
//-------------------------------
|
29 |
+
|
30 |
+
//-------------------------------
|
31 |
+
$formData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
32 |
+
$this->setData('attributes',
|
33 |
+
Mage::helper('M2ePro/Magento_Attribute')->getByAttributeSets($formData['attribute_sets']));
|
34 |
+
//-------------------------------
|
35 |
+
|
36 |
+
//------------------------------
|
37 |
+
$treeSettings = array(
|
38 |
+
'show_products_amount' => false,
|
39 |
+
'hide_products_this_listing' => false
|
40 |
+
);
|
41 |
+
|
42 |
+
// todo next
|
43 |
+
$treeBlock = $this->getLayout()
|
44 |
+
->createBlock('M2ePro/adminhtml_common_listing_category_tree','',array(
|
45 |
+
'component'=>Ess_M2ePro_Helper_Component_Play::NICK,
|
46 |
+
'tree_settings' => $treeSettings
|
47 |
+
));
|
48 |
+
$this->setChild('categoriesTree', $treeBlock);
|
49 |
+
//------------------------------
|
50 |
+
|
51 |
+
return parent::_beforeToHtml();
|
52 |
+
}
|
53 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Edit/Tabs/Settings.php
ADDED
@@ -0,0 +1,146 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Play_Listing_Edit_Tabs_Settings extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('playListingEditTabsSettings');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/play/listing/tabs/settings.phtml');
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _beforeToHtml()
|
22 |
+
{
|
23 |
+
//-------------------------------
|
24 |
+
$maxRecordsQuantity = Mage::helper('M2ePro/View_Common')->getAutocompleteMaxItems();
|
25 |
+
//-------------------------------
|
26 |
+
|
27 |
+
// Get attribute sets
|
28 |
+
//------------------------------
|
29 |
+
$this->attributesSets = Mage::helper('M2ePro/Magento_AttributeSet')->getAll();
|
30 |
+
|
31 |
+
//------------------------------
|
32 |
+
$data = array(
|
33 |
+
'id' => 'attribute_sets_select_all_button',
|
34 |
+
'label' => Mage::helper('M2ePro')->__('Select All'),
|
35 |
+
'onclick' => 'AttributeSetHandlerObj.selectAllAttributeSets();',
|
36 |
+
'class' => 'attribute_sets_select_all_button'
|
37 |
+
);
|
38 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
39 |
+
$this->setChild('attribute_sets_select_all_button',$buttonBlock);
|
40 |
+
//------------------------------
|
41 |
+
|
42 |
+
//------------------------------
|
43 |
+
$data = array(
|
44 |
+
'id' => 'attribute_sets_confirm_button',
|
45 |
+
'label' => Mage::helper('M2ePro')->__('Confirm'),
|
46 |
+
'onclick' => 'PlayListingSettingsHandlerObj.attribute_sets_confirm();',
|
47 |
+
'class' => 'attribute_sets_confirm_button',
|
48 |
+
'style' => 'display: none'
|
49 |
+
);
|
50 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
51 |
+
$this->setChild('attribute_sets_confirm_button',$buttonBlock);
|
52 |
+
//------------------------------
|
53 |
+
|
54 |
+
//----------------------------
|
55 |
+
$this->sellingFormatTemplatesDropDown = Mage::helper('M2ePro/Component_Play')
|
56 |
+
->getCollection('Template_SellingFormat')
|
57 |
+
->getSize() < $maxRecordsQuantity;
|
58 |
+
//----------------------------
|
59 |
+
|
60 |
+
//----------------------------
|
61 |
+
$synchronizationTemplatesCollection = Mage::helper('M2ePro/Component_Play')
|
62 |
+
->getCollection('Template_Synchronization')
|
63 |
+
->setOrder('title', 'ASC');
|
64 |
+
|
65 |
+
if ($synchronizationTemplatesCollection->getSize() < $maxRecordsQuantity) {
|
66 |
+
$this->synchronizationsTemplatesDropDown = true;
|
67 |
+
$templates = $synchronizationTemplatesCollection->toArray();
|
68 |
+
|
69 |
+
foreach ($templates['items'] as $key => $value) {
|
70 |
+
$templates['items'][$key]['title'] = Mage::helper('M2ePro')
|
71 |
+
->escapeHtml($templates['items'][$key]['title']);
|
72 |
+
}
|
73 |
+
|
74 |
+
$this->synchronizationsTemplates = $templates['items'];
|
75 |
+
} else {
|
76 |
+
$this->synchronizationsTemplatesDropDown = false;
|
77 |
+
$this->synchronizationsTemplates = array();
|
78 |
+
}
|
79 |
+
//----------------------------
|
80 |
+
|
81 |
+
// Get selected categories
|
82 |
+
//----------------------------
|
83 |
+
if ($listingId = $this->getRequest()->getParam('id')) {
|
84 |
+
$listingCategories = Mage::helper('M2ePro/Component_Play')
|
85 |
+
->getCachedObject('Listing',$listingId)
|
86 |
+
->getCategories();
|
87 |
+
|
88 |
+
$categoriesIds = array();
|
89 |
+
foreach ($listingCategories as $listingCategory) {
|
90 |
+
$categoriesIds[] = $listingCategory['category_id'];
|
91 |
+
}
|
92 |
+
//----------------------------
|
93 |
+
|
94 |
+
Mage::helper('M2ePro/Data_Global')->setValue('temp_listing_categories', $categoriesIds);
|
95 |
+
}
|
96 |
+
//----------------------------
|
97 |
+
|
98 |
+
//------------------------------
|
99 |
+
$url = $this->getUrl('*/adminhtml_common_play_template_sellingFormat/new');
|
100 |
+
$data = array(
|
101 |
+
'label' => Mage::helper('M2ePro')->__('Add New'),
|
102 |
+
'onclick' => 'PlayListingSettingsHandlerObj.openWindow(\'' . $url . '\');',
|
103 |
+
'class' => 'add add_new_selling_format_template_button',
|
104 |
+
'style' => 'vertical-align: bottom'
|
105 |
+
);
|
106 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
107 |
+
$this->setChild('add_new_selling_format_template_button',$buttonBlock);
|
108 |
+
//------------------------------
|
109 |
+
|
110 |
+
//------------------------------
|
111 |
+
$data = array(
|
112 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
113 |
+
'onclick' => 'PlayListingSettingsHandlerObj.reloadSellingFormatTemplates();',
|
114 |
+
'class' => 'reload_selling_format_templates_button',
|
115 |
+
'style' => 'vertical-align: bottom'
|
116 |
+
);
|
117 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
118 |
+
$this->setChild('reload_selling_format_templates_button',$buttonBlock);
|
119 |
+
//------------------------------
|
120 |
+
|
121 |
+
//------------------------------
|
122 |
+
$url = $this->getUrl('*/adminhtml_common_play_template_synchronization/new');
|
123 |
+
$data = array(
|
124 |
+
'label' => Mage::helper('M2ePro')->__('Add New'),
|
125 |
+
'onclick' => 'PlayListingSettingsHandlerObj.openWindow(\'' . $url . '\');',
|
126 |
+
'class' => 'add add_new_synchronization_template_button',
|
127 |
+
'style' => 'vertical-align: bottom'
|
128 |
+
);
|
129 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
130 |
+
$this->setChild('add_new_synchronization_template_button',$buttonBlock);
|
131 |
+
//------------------------------
|
132 |
+
|
133 |
+
//------------------------------
|
134 |
+
$data = array(
|
135 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
136 |
+
'onclick' => 'PlayListingSettingsHandlerObj.reloadSynchronizationTemplates();',
|
137 |
+
'class' => 'reload_synchronization_templates_button',
|
138 |
+
'style' => 'vertical-align: bottom'
|
139 |
+
);
|
140 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($data);
|
141 |
+
$this->setChild('reload_synchronization_templates_button',$buttonBlock);
|
142 |
+
//------------------------------
|
143 |
+
|
144 |
+
return parent::_beforeToHtml();
|
145 |
+
}
|
146 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Filter.php
ADDED
@@ -0,0 +1,116 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Play_Listing_Filter extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('playListingFilter');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/play/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_play_selling_format_template');
|
30 |
+
$sellingFormatTemplatesCollection = Mage::helper('M2ePro/Component_Play')
|
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_Play')
|
48 |
+
->getCachedObject(
|
49 |
+
'Template_SellingFormat',
|
50 |
+
$this->selectedSellingFormatTemplate, NULL,
|
51 |
+
array('template')
|
52 |
+
)->getTitle();
|
53 |
+
} else {
|
54 |
+
$this->selectedSellingFormatTemplateValue = '';
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
$this->sellingFormatTemplateUrl = $this->makeCutUrlForTemplate('filter_play_selling_format_template');
|
59 |
+
//-------------------------------
|
60 |
+
|
61 |
+
//-------------------------------
|
62 |
+
$this->selectedSynchronizationTemplate = (int)$this->getRequest()
|
63 |
+
->getParam('filter_play_synchronization_template');
|
64 |
+
$synchronizationsTemplatesCollection = Mage::helper('M2ePro/Component_Play')
|
65 |
+
->getCollection('Template_Synchronization')
|
66 |
+
->setOrder('title', 'ASC');
|
67 |
+
|
68 |
+
if ($synchronizationsTemplatesCollection->getSize() < $maxRecordsQuantity) {
|
69 |
+
$this->synchronizationsTemplatesDropDown = true;
|
70 |
+
$synchronizationsTemplates = array();
|
71 |
+
|
72 |
+
foreach ($synchronizationsTemplatesCollection->getItems() as $item) {
|
73 |
+
$synchronizationsTemplates[$item->getId()] = Mage::helper('M2ePro')->escapeHtml($item->getTitle());
|
74 |
+
}
|
75 |
+
$this->synchronizationsTemplates = $synchronizationsTemplates;
|
76 |
+
} else {
|
77 |
+
$this->synchronizationsTemplatesDropDown = false;
|
78 |
+
$this->synchronizationsTemplates = array();
|
79 |
+
|
80 |
+
if ($this->selectedSynchronizationTemplate > 0) {
|
81 |
+
$this->selectedSynchronizationTemplateValue = Mage::helper('M2ePro/Component_Play')
|
82 |
+
->getCachedObject(
|
83 |
+
'Template_Synchronization',
|
84 |
+
$this->selectedSynchronizationTemplate, NULL,
|
85 |
+
array('template')
|
86 |
+
)->getTitle();
|
87 |
+
} else {
|
88 |
+
$this->selectedSynchronizationTemplateValue = '';
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
$this->synchronizationTemplateUrl = $this->makeCutUrlForTemplate('filter_play_synchronization_template');
|
93 |
+
//-------------------------------
|
94 |
+
|
95 |
+
return parent::_beforeToHtml();
|
96 |
+
}
|
97 |
+
|
98 |
+
protected function makeCutUrlForTemplate($templateUrlParamName)
|
99 |
+
{
|
100 |
+
$paramsFilters = array(
|
101 |
+
'filter_play_selling_format_template',
|
102 |
+
'filter_play_synchronization_template'
|
103 |
+
);
|
104 |
+
|
105 |
+
$params = array();
|
106 |
+
foreach ($paramsFilters as $value) {
|
107 |
+
if ($value != $templateUrlParamName) {
|
108 |
+
$params[$value] = $this->getRequest()->getParam($value);
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
$params['tab'] = Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_PLAY;
|
113 |
+
|
114 |
+
return $this->getUrl('*/adminhtml_common_listing/*',$params);
|
115 |
+
}
|
116 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Grid.php
ADDED
@@ -0,0 +1,335 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|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â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Play_Listing_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('playListingGrid');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
// Set default values
|
19 |
+
//------------------------------
|
20 |
+
$this->setDefaultSort('id');
|
21 |
+
$this->setDefaultDir('DESC');
|
22 |
+
$this->setSaveParametersInSession(true);
|
23 |
+
$this->setUseAjax(true);
|
24 |
+
//------------------------------
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getMassactionBlockName()
|
28 |
+
{
|
29 |
+
return 'M2ePro/adminhtml_grid_massaction';
|
30 |
+
}
|
31 |
+
|
32 |
+
protected function _prepareCollection()
|
33 |
+
{
|
34 |
+
// Update statistic table values
|
35 |
+
Mage::getResourceModel('M2ePro/Listing')->updateStatisticColumns();
|
36 |
+
|
37 |
+
// Get collection of listings
|
38 |
+
$collection = Mage::helper('M2ePro/Component_Play')->getCollection('Listing');
|
39 |
+
|
40 |
+
// Set global filters
|
41 |
+
//--------------------------
|
42 |
+
$filterSellingFormatTemplate = $this->getRequest()->getParam('filter_play_selling_format_template');
|
43 |
+
$filterSynchronizationTemplate = $this->getRequest()->getParam('filter_play_synchronization_template');
|
44 |
+
|
45 |
+
if ($filterSellingFormatTemplate != 0) {
|
46 |
+
$collection->addFieldToFilter(
|
47 |
+
'second_table.template_selling_format_id', (int)$filterSellingFormatTemplate
|
48 |
+
);
|
49 |
+
}
|
50 |
+
|
51 |
+
if ($filterSynchronizationTemplate != 0) {
|
52 |
+
$collection->addFieldToFilter(
|
53 |
+
'second_table.template_synchronization_id', (int)$filterSynchronizationTemplate
|
54 |
+
);
|
55 |
+
}
|
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 |
+
protected function _prepareColumns()
|
67 |
+
{
|
68 |
+
$this->addColumn('id', array(
|
69 |
+
'header' => Mage::helper('M2ePro')->__('ID'),
|
70 |
+
'align' => 'right',
|
71 |
+
'width' => '100px',
|
72 |
+
'type' => 'number',
|
73 |
+
'index' => 'id',
|
74 |
+
'filter_index' => 'main_table.id'
|
75 |
+
));
|
76 |
+
|
77 |
+
$this->addColumn('title', array(
|
78 |
+
'header' => Mage::helper('M2ePro')->__('Title'),
|
79 |
+
'align' => 'left',
|
80 |
+
//'width' => '200px',
|
81 |
+
'type' => 'text',
|
82 |
+
'index' => 'title',
|
83 |
+
'escape' => true,
|
84 |
+
'filter_index' => 'main_table.title'
|
85 |
+
));
|
86 |
+
|
87 |
+
$this->addColumn('products_total_count', array(
|
88 |
+
'header' => Mage::helper('M2ePro')->__('Total Items'),
|
89 |
+
'align' => 'right',
|
90 |
+
'width' => '100px',
|
91 |
+
'type' => 'number',
|
92 |
+
'index' => 'products_total_count',
|
93 |
+
'filter_index' => 'main_table.products_total_count',
|
94 |
+
'frame_callback' => array($this, 'callbackColumnTotalProducts')
|
95 |
+
));
|
96 |
+
|
97 |
+
$this->addColumn('products_active_count', array(
|
98 |
+
'header' => Mage::helper('M2ePro')->__('Active Items'),
|
99 |
+
'align' => 'right',
|
100 |
+
'width' => '100px',
|
101 |
+
'type' => 'number',
|
102 |
+
'index' => 'products_active_count',
|
103 |
+
'filter_index' => 'main_table.products_active_count',
|
104 |
+
'frame_callback' => array($this, 'callbackColumnListedProducts')
|
105 |
+
));
|
106 |
+
|
107 |
+
$this->addColumn('products_inactive_count', array(
|
108 |
+
'header' => Mage::helper('M2ePro')->__('Inactive Items'),
|
109 |
+
'align' => 'right',
|
110 |
+
'width' => '100px',
|
111 |
+
'type' => 'number',
|
112 |
+
'index' => 'products_inactive_count',
|
113 |
+
'filter_index' => 'main_table.products_inactive_count',
|
114 |
+
'frame_callback' => array($this, 'callbackColumnInactiveProducts')
|
115 |
+
));
|
116 |
+
|
117 |
+
$this->addColumn('create_date', array(
|
118 |
+
'header' => Mage::helper('M2ePro')->__('Creation Date'),
|
119 |
+
'align' => 'left',
|
120 |
+
'width' => '150px',
|
121 |
+
'type' => 'datetime',
|
122 |
+
'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM),
|
123 |
+
'index' => 'create_date',
|
124 |
+
'filter_index' => 'main_table.create_date'
|
125 |
+
));
|
126 |
+
|
127 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
128 |
+
'*/adminhtml_common_listing/index',
|
129 |
+
array(
|
130 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_PLAY
|
131 |
+
)
|
132 |
+
);
|
133 |
+
|
134 |
+
$this->addColumn('actions', array(
|
135 |
+
'header' => Mage::helper('M2ePro')->__('Actions'),
|
136 |
+
'align' => 'left',
|
137 |
+
'width' => '150px',
|
138 |
+
'type' => 'action',
|
139 |
+
'index' => 'actions',
|
140 |
+
'filter' => false,
|
141 |
+
'sortable' => false,
|
142 |
+
'getter' => 'getId',
|
143 |
+
'actions' => array(
|
144 |
+
array(
|
145 |
+
'caption' => Mage::helper('M2ePro')->__('View Products'),
|
146 |
+
'field' => 'id',
|
147 |
+
'url' => array(
|
148 |
+
'base' => '*/adminhtml_common_play_listing/view',
|
149 |
+
'params' => array('back' => $backUrl)
|
150 |
+
)
|
151 |
+
),
|
152 |
+
array(
|
153 |
+
'caption' => Mage::helper('M2ePro')->__('Add Products from Products List'),
|
154 |
+
'field' => 'id',
|
155 |
+
'url' => array(
|
156 |
+
'base' => '*/adminhtml_common_play_listing/product',
|
157 |
+
'params' => array('back' => $backUrl)
|
158 |
+
)
|
159 |
+
),
|
160 |
+
array(
|
161 |
+
'caption' => Mage::helper('M2ePro')->__('Add Products from Categories'),
|
162 |
+
'field' => 'id',
|
163 |
+
'url' => array(
|
164 |
+
'base' => '*/adminhtml_common_play_listing/categoryProduct',
|
165 |
+
'params' => array('back' => $backUrl)
|
166 |
+
)
|
167 |
+
),
|
168 |
+
array(
|
169 |
+
'caption' => Mage::helper('M2ePro')->__('Edit Settings'),
|
170 |
+
'field' => 'id',
|
171 |
+
'url' => array(
|
172 |
+
'base' => '*/adminhtml_common_play_listing/edit',
|
173 |
+
'params' => array('back' => $backUrl)
|
174 |
+
)
|
175 |
+
),
|
176 |
+
array(
|
177 |
+
'caption' => Mage::helper('M2ePro')->__('Delete Listing'),
|
178 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?'),
|
179 |
+
'field' => 'id',
|
180 |
+
'url' => array(
|
181 |
+
'base' => '*/adminhtml_common_play_listing/delete',
|
182 |
+
)
|
183 |
+
),
|
184 |
+
array(
|
185 |
+
'caption' => Mage::helper('M2ePro')->__('View Log'),
|
186 |
+
'field' => 'id',
|
187 |
+
'url' => array(
|
188 |
+
'base' => '*/adminhtml_common_log/listing',
|
189 |
+
'params' => array('back' => $backUrl)
|
190 |
+
)
|
191 |
+
),
|
192 |
+
array(
|
193 |
+
'caption' => Mage::helper('M2ePro')->__('Clear Log'),
|
194 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?'),
|
195 |
+
'field' => 'id',
|
196 |
+
'url' => array(
|
197 |
+
'base' => '*/adminhtml_listing/clearLog',
|
198 |
+
'params' => array('back' => $backUrl)
|
199 |
+
)
|
200 |
+
),
|
201 |
+
array(
|
202 |
+
'caption' => Mage::helper('M2ePro')->__('Edit Selling Format Template'),
|
203 |
+
'field' => 'id',
|
204 |
+
'url' => array(
|
205 |
+
'base' => '*/adminhtml_common_listing/goToSellingFormatTemplate',
|
206 |
+
'params' => array('back' => $backUrl)
|
207 |
+
)
|
208 |
+
),
|
209 |
+
array(
|
210 |
+
'caption' => Mage::helper('M2ePro')->__('Edit Synchronization Template'),
|
211 |
+
'field' => 'id',
|
212 |
+
'url' => array(
|
213 |
+
'base' => '*/adminhtml_common_listing/goToSynchronizationTemplate',
|
214 |
+
'params' => array('back' => $backUrl)
|
215 |
+
)
|
216 |
+
)
|
217 |
+
)
|
218 |
+
));
|
219 |
+
|
220 |
+
return parent::_prepareColumns();
|
221 |
+
}
|
222 |
+
|
223 |
+
// ####################################
|
224 |
+
|
225 |
+
protected function _prepareMassaction()
|
226 |
+
{
|
227 |
+
// Set massaction identifiers
|
228 |
+
//--------------------------------
|
229 |
+
$this->setMassactionIdField('id');
|
230 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
231 |
+
//--------------------------------
|
232 |
+
|
233 |
+
$tabIdPlay = Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_PLAY;
|
234 |
+
|
235 |
+
// Set clear log action
|
236 |
+
//--------------------------------
|
237 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
238 |
+
'*/adminhtml_common_listing/index',
|
239 |
+
array(
|
240 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_PLAY
|
241 |
+
)
|
242 |
+
);
|
243 |
+
|
244 |
+
$this->getMassactionBlock()->addItem('clear_logs', array(
|
245 |
+
'label' => Mage::helper('M2ePro')->__('Clear Log(s)'),
|
246 |
+
'url' => $this->getUrl('*/adminhtml_listing/clearLog', array('back' => $backUrl)),
|
247 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
248 |
+
));
|
249 |
+
//--------------------------------
|
250 |
+
|
251 |
+
// Set remove listings action
|
252 |
+
//--------------------------------
|
253 |
+
$this->getMassactionBlock()->addItem('delete_listings', array(
|
254 |
+
'label' => Mage::helper('M2ePro')->__('Delete Listing(s)'),
|
255 |
+
'url' => $this->getUrl('*/adminhtml_common_play_listing/delete'),
|
256 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
257 |
+
));
|
258 |
+
//--------------------------------
|
259 |
+
|
260 |
+
return parent::_prepareMassaction();
|
261 |
+
}
|
262 |
+
|
263 |
+
// ####################################
|
264 |
+
|
265 |
+
public function callbackColumnTotalProducts($value, $row, $column, $isExport)
|
266 |
+
{
|
267 |
+
if (is_null($value) || $value === '') {
|
268 |
+
$value = Mage::helper('M2ePro')->__('N/A');
|
269 |
+
} else if ($value <= 0) {
|
270 |
+
$value = '<span style="color: red;">0</span>';
|
271 |
+
}
|
272 |
+
|
273 |
+
return $value;
|
274 |
+
}
|
275 |
+
|
276 |
+
public function callbackColumnListedProducts($value, $row, $column, $isExport)
|
277 |
+
{
|
278 |
+
if (is_null($value) || $value === '') {
|
279 |
+
$value = Mage::helper('M2ePro')->__('N/A');
|
280 |
+
} else if ($value <= 0) {
|
281 |
+
$value = '<span style="color: red;">0</span>';
|
282 |
+
}
|
283 |
+
|
284 |
+
return $value;
|
285 |
+
}
|
286 |
+
|
287 |
+
public function callbackColumnSoldProducts($value, $row, $column, $isExport)
|
288 |
+
{
|
289 |
+
if (is_null($value) || $value === '') {
|
290 |
+
$value = Mage::helper('M2ePro')->__('N/A');
|
291 |
+
} else if ($value <= 0) {
|
292 |
+
$value = '<span style="color: red;">0</span>';
|
293 |
+
}
|
294 |
+
|
295 |
+
return $value;
|
296 |
+
}
|
297 |
+
|
298 |
+
public function callbackColumnInactiveProducts($value, $row, $column, $isExport)
|
299 |
+
{
|
300 |
+
if (is_null($value) || $value === '') {
|
301 |
+
$value = Mage::helper('M2ePro')->__('N/A');
|
302 |
+
} else if ($value <= 0) {
|
303 |
+
$value = '<span style="color: red;">0</span>';
|
304 |
+
}
|
305 |
+
|
306 |
+
return $value;
|
307 |
+
}
|
308 |
+
|
309 |
+
// ####################################
|
310 |
+
|
311 |
+
public function getGridUrl()
|
312 |
+
{
|
313 |
+
return $this->getUrl('*/adminhtml_common_play_listing/listingGrid', array('_current'=>true));
|
314 |
+
}
|
315 |
+
|
316 |
+
public function getRowUrl($row)
|
317 |
+
{
|
318 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
319 |
+
'*/adminhtml_common_listing/index',
|
320 |
+
array(
|
321 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_PLAY
|
322 |
+
)
|
323 |
+
);
|
324 |
+
|
325 |
+
return $this->getUrl(
|
326 |
+
'*/adminhtml_common_play_listing/view',
|
327 |
+
array(
|
328 |
+
'id' => $row->getId(),
|
329 |
+
'back' => $backUrl
|
330 |
+
)
|
331 |
+
);
|
332 |
+
}
|
333 |
+
|
334 |
+
// ####################################
|
335 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Other/Grid.php
ADDED
@@ -0,0 +1,543 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
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Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Play_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('playListingOtherGrid');
|
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_Play')->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('playAccount');
|
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')->__('Product Title / Reference Code'),
|
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')->__('Identifier'),
|
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')->__('Play.com 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_gbr', array(
|
105 |
+
'header' => Mage::helper('M2ePro')->__('Play.com GBP Price'),
|
106 |
+
'align' => 'right',
|
107 |
+
'width' => '100px',
|
108 |
+
'type' => 'number',
|
109 |
+
'index' => 'online_price_gbr',
|
110 |
+
'filter_index' => 'online_price_gbr',
|
111 |
+
'frame_callback' => array($this, 'callbackColumnPriceGbr')
|
112 |
+
));
|
113 |
+
|
114 |
+
$this->addColumn('online_price_euro', array(
|
115 |
+
'header' => Mage::helper('M2ePro')->__('Play.com EUR Price'),
|
116 |
+
'align' => 'right',
|
117 |
+
'width' => '100px',
|
118 |
+
'type' => 'number',
|
119 |
+
'index' => 'online_price_euro',
|
120 |
+
'filter_index' => 'online_price_euro',
|
121 |
+
'frame_callback' => array($this, 'callbackColumnPriceEuro')
|
122 |
+
));
|
123 |
+
|
124 |
+
$this->addColumn('status', array(
|
125 |
+
'header' => Mage::helper('M2ePro')->__('Status'),
|
126 |
+
'width' => '60px',
|
127 |
+
'index' => 'status',
|
128 |
+
'type' => 'options',
|
129 |
+
'filter_index' => 'main_table.status',
|
130 |
+
'sortable' => false,
|
131 |
+
'options' => array(
|
132 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_LISTED => Mage::helper('M2ePro')->__('Active'),
|
133 |
+
Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED => Mage::helper('M2ePro')->__('Inactive')
|
134 |
+
),
|
135 |
+
'frame_callback' => array($this, 'callbackColumnStatus')
|
136 |
+
));
|
137 |
+
|
138 |
+
$backUrl = Mage::helper('M2ePro')->makeBackUrlParam(
|
139 |
+
'*/adminhtml_common_listing_other/index',
|
140 |
+
array(
|
141 |
+
'tab' => Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::TAB_ID_PLAY
|
142 |
+
)
|
143 |
+
);
|
144 |
+
|
145 |
+
$this->addColumn('actions', array(
|
146 |
+
'header' => Mage::helper('M2ePro')->__('Actions'),
|
147 |
+
'align' => 'left',
|
148 |
+
'width' => '70px',
|
149 |
+
'type' => 'action',
|
150 |
+
'index' => 'actions',
|
151 |
+
'filter' => false,
|
152 |
+
'sortable' => false,
|
153 |
+
'getter' => 'getId',
|
154 |
+
'actions' => array(
|
155 |
+
array(
|
156 |
+
'caption' => Mage::helper('M2ePro')->__('View Log'),
|
157 |
+
'field' => 'id',
|
158 |
+
'url' => array(
|
159 |
+
'base' => '*/adminhtml_common_log/listingOther',
|
160 |
+
'params' => array(
|
161 |
+
'back' => $backUrl
|
162 |
+
)
|
163 |
+
)
|
164 |
+
),
|
165 |
+
array(
|
166 |
+
'caption' => Mage::helper('M2ePro')->__('Clear Log'),
|
167 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?'),
|
168 |
+
'field' => 'id',
|
169 |
+
'url' => array(
|
170 |
+
'base' => '*/adminhtml_listing_other/clearLog',
|
171 |
+
'params' => array(
|
172 |
+
'back' => $backUrl
|
173 |
+
)
|
174 |
+
)
|
175 |
+
)
|
176 |
+
)
|
177 |
+
));
|
178 |
+
|
179 |
+
return parent::_prepareColumns();
|
180 |
+
}
|
181 |
+
|
182 |
+
protected function _prepareMassaction()
|
183 |
+
{
|
184 |
+
// Set mass-action identifiers
|
185 |
+
//--------------------------------
|
186 |
+
$this->setMassactionIdField('`main_table`.id');
|
187 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
188 |
+
//--------------------------------
|
189 |
+
|
190 |
+
// Set mass-action
|
191 |
+
//--------------------------------
|
192 |
+
$this->getMassactionBlock()->addItem('autoMapping', array(
|
193 |
+
'label' => Mage::helper('M2ePro')->__('Map Item(s) Automatically'),
|
194 |
+
'url' => '',
|
195 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
196 |
+
));
|
197 |
+
$this->getMassactionBlock()->addItem('moving', array(
|
198 |
+
'label' => Mage::helper('M2ePro')->__('Move Item(s) To Listing'),
|
199 |
+
'url' => '',
|
200 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
201 |
+
));
|
202 |
+
$this->getMassactionBlock()->addItem('removing', array(
|
203 |
+
'label' => Mage::helper('M2ePro')->__('Remove Item(s)'),
|
204 |
+
'url' => '',
|
205 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
206 |
+
));
|
207 |
+
$this->getMassactionBlock()->addItem('unmapping', array(
|
208 |
+
'label' => Mage::helper('M2ePro')->__('Unmap Item(s)'),
|
209 |
+
'url' => '',
|
210 |
+
'confirm' => Mage::helper('M2ePro')->__('Are you sure?')
|
211 |
+
));
|
212 |
+
//--------------------------------
|
213 |
+
|
214 |
+
return parent::_prepareMassaction();
|
215 |
+
}
|
216 |
+
|
217 |
+
// ####################################
|
218 |
+
|
219 |
+
public function callbackColumnProductId($value, $row, $column, $isExport)
|
220 |
+
{
|
221 |
+
if (empty($value)) {
|
222 |
+
$productTitle = $row->getData('title');
|
223 |
+
|
224 |
+
if (is_null($productTitle) || $productTitle === '') {
|
225 |
+
$productTitle = Mage::helper('M2ePro')->__('N/A');
|
226 |
+
} else {
|
227 |
+
$productTitle = Mage::helper('M2ePro')->escapeHtml($productTitle);
|
228 |
+
$productTitle = Mage::helper('M2ePro')->escapeJs($productTitle);
|
229 |
+
if (strlen($productTitle) > 60) {
|
230 |
+
$productTitle = substr($productTitle, 0, 60) . '...';
|
231 |
+
}
|
232 |
+
}
|
233 |
+
|
234 |
+
$htmlValue = ' <a href="javascript:void(0);"
|
235 |
+
onclick="PlayListingOtherMappingHandlerObj.openPopUp(\''
|
236 |
+
.$productTitle
|
237 |
+
.'\','
|
238 |
+
.(int)$row->getId()
|
239 |
+
.');">'
|
240 |
+
.Mage::helper('M2ePro')->__('Map').'</a>';
|
241 |
+
|
242 |
+
if (Mage::helper('M2ePro/Module')->isDevelopmentMode()) {
|
243 |
+
$htmlValue .= '<br>' . $row->getId();
|
244 |
+
}
|
245 |
+
|
246 |
+
return $htmlValue;
|
247 |
+
}
|
248 |
+
|
249 |
+
$htmlValue = ' <a href="'
|
250 |
+
.$this->getUrl('adminhtml/catalog_product/edit',
|
251 |
+
array('id' => $row->getData('product_id')))
|
252 |
+
.'" target="_blank">'
|
253 |
+
.$row->getData('product_id')
|
254 |
+
.'</a>';
|
255 |
+
|
256 |
+
$htmlValue .= '   <a href="javascript:void(0);"'
|
257 |
+
.' onclick="PlayListingOtherGridHandlerObj.movingHandler.getGridHtml('
|
258 |
+
.json_encode(array((int)$row->getData('id')))
|
259 |
+
.')">'
|
260 |
+
.Mage::helper('M2ePro')->__('Move')
|
261 |
+
.'</a>';
|
262 |
+
|
263 |
+
if (Mage::helper('M2ePro/Module')->isDevelopmentMode()) {
|
264 |
+
$htmlValue .= '<br>' . $row->getId();
|
265 |
+
}
|
266 |
+
|
267 |
+
return $htmlValue;
|
268 |
+
}
|
269 |
+
|
270 |
+
public function callbackColumnProductTitle($value, $row, $column, $isExport)
|
271 |
+
{
|
272 |
+
$value = Mage::helper('M2ePro')->escapeHtml($value);
|
273 |
+
if (strlen($value) > 60) {
|
274 |
+
$value = substr($value, 0, 60) . '...';
|
275 |
+
}
|
276 |
+
$value = '<span>' . $value . '</span>';
|
277 |
+
|
278 |
+
$tempSku = $row->getData('sku');
|
279 |
+
is_null($tempSku) && $tempSku = Mage::helper('M2ePro')->__('N/A');
|
280 |
+
|
281 |
+
$value .= '<br/><strong>'.Mage::helper('M2ePro')->__('Reference Code').':</strong> '
|
282 |
+
.Mage::helper('M2ePro')->escapeHtml($tempSku);
|
283 |
+
|
284 |
+
return $value;
|
285 |
+
}
|
286 |
+
|
287 |
+
public function callbackColumnGeneralId($value, $row, $column, $isExport)
|
288 |
+
{
|
289 |
+
$generalIdType = $row->getData('general_id_type');
|
290 |
+
|
291 |
+
if (is_null($row->getData('link_info'))) {
|
292 |
+
return '<strong>'.Mage::helper('M2ePro')->__($generalIdType).':</strong><p>'.$value.'</p>';
|
293 |
+
}
|
294 |
+
|
295 |
+
$linkInfo = json_decode($row->getData('link_info'),true);
|
296 |
+
$url = Mage::helper('M2ePro/Component_Play')->getItemUrl($linkInfo['play_id'], $linkInfo['category_code']);
|
297 |
+
|
298 |
+
return '<strong>'.Mage::helper('M2ePro')->__($generalIdType).': </strong>
|
299 |
+
<a href="'.$url.'" target="_blank">'.$value.'</a>';
|
300 |
+
}
|
301 |
+
|
302 |
+
public function callbackColumnAvailableQty($value, $row, $column, $isExport)
|
303 |
+
{
|
304 |
+
if (is_null($value) || $value === '') {
|
305 |
+
return Mage::helper('M2ePro')->__('N/A');
|
306 |
+
}
|
307 |
+
|
308 |
+
if ($value <= 0) {
|
309 |
+
return '<span style="color: red;">0</span>';
|
310 |
+
}
|
311 |
+
|
312 |
+
return $value;
|
313 |
+
}
|
314 |
+
|
315 |
+
public function callbackColumnPriceGbr($value, $row, $column, $isExport)
|
316 |
+
{
|
317 |
+
if ((float)$value <= 0) {
|
318 |
+
return Mage::helper('M2ePro')->__('N/A');
|
319 |
+
}
|
320 |
+
|
321 |
+
return Mage::app()->getLocale()->currency('GBP')->toCurrency($value);
|
322 |
+
}
|
323 |
+
|
324 |
+
public function callbackColumnPriceEuro($value, $row, $column, $isExport)
|
325 |
+
{
|
326 |
+
if ((float)$value <= 0) {
|
327 |
+
return Mage::helper('M2ePro')->__('N/A');
|
328 |
+
}
|
329 |
+
|
330 |
+
return Mage::app()->getLocale()->currency('EUR')->toCurrency($value);
|
331 |
+
}
|
332 |
+
|
333 |
+
public function callbackColumnStatus($value, $row, $column, $isExport)
|
334 |
+
{
|
335 |
+
switch ($row->getData('status')) {
|
336 |
+
|
337 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED:
|
338 |
+
$value = '<span style="color: gray;">' . $value . '</span>';
|
339 |
+
break;
|
340 |
+
|
341 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_LISTED:
|
342 |
+
$value = '<span style="color: green;">' . $value . '</span>';
|
343 |
+
break;
|
344 |
+
|
345 |
+
case Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED:
|
346 |
+
$value = '<span style="color: red;">' . $value . '</span>';
|
347 |
+
break;
|
348 |
+
|
349 |
+
default:
|
350 |
+
break;
|
351 |
+
}
|
352 |
+
|
353 |
+
return $value.$this->getViewLogIconHtml($row->getId());
|
354 |
+
}
|
355 |
+
|
356 |
+
protected function callbackFilterTitle($collection, $column)
|
357 |
+
{
|
358 |
+
$value = $column->getFilter()->getValue();
|
359 |
+
|
360 |
+
if ($value == null) {
|
361 |
+
return;
|
362 |
+
}
|
363 |
+
|
364 |
+
$collection->getSelect()->where('second_table.title LIKE ? OR second_table.sku LIKE ?', '%'.$value.'%');
|
365 |
+
}
|
366 |
+
|
367 |
+
// ####################################
|
368 |
+
|
369 |
+
public function getViewLogIconHtml($listingOtherId)
|
370 |
+
{
|
371 |
+
$listingOtherId = (int)$listingOtherId;
|
372 |
+
|
373 |
+
// Get last messages
|
374 |
+
//--------------------------
|
375 |
+
$dbSelect = $this->connRead->select()
|
376 |
+
->from(
|
377 |
+
Mage::getResourceModel('M2ePro/Listing_Other_Log')->getMainTable(),
|
378 |
+
array('action_id','action','type','description','create_date','initiator')
|
379 |
+
)
|
380 |
+
->where('`listing_other_id` = ?', $listingOtherId)
|
381 |
+
->where('`action_id` IS NOT NULL')
|
382 |
+
->order(array('id DESC'))
|
383 |
+
->limit(30);
|
384 |
+
|
385 |
+
$logRows = $this->connRead->fetchAll($dbSelect);
|
386 |
+
//--------------------------
|
387 |
+
|
388 |
+
// Get grouped messages by action_id
|
389 |
+
//--------------------------
|
390 |
+
$actionsRows = array();
|
391 |
+
$tempActionRows = array();
|
392 |
+
$lastActionId = false;
|
393 |
+
|
394 |
+
foreach ($logRows as $row) {
|
395 |
+
|
396 |
+
$row['description'] = Mage::helper('M2ePro/View')->getModifiedLogMessage($row['description']);
|
397 |
+
|
398 |
+
if ($row['action_id'] !== $lastActionId) {
|
399 |
+
if (count($tempActionRows) > 0) {
|
400 |
+
$actionsRows[] = array(
|
401 |
+
'type' => $this->getMainTypeForActionId($tempActionRows),
|
402 |
+
'date' => $this->getMainDateForActionId($tempActionRows),
|
403 |
+
'action' => $this->getActionForAction($tempActionRows[0]),
|
404 |
+
'initiator' => $this->getInitiatorForAction($tempActionRows[0]),
|
405 |
+
'items' => $tempActionRows
|
406 |
+
);
|
407 |
+
$tempActionRows = array();
|
408 |
+
}
|
409 |
+
$lastActionId = $row['action_id'];
|
410 |
+
}
|
411 |
+
$tempActionRows[] = $row;
|
412 |
+
}
|
413 |
+
|
414 |
+
if (count($tempActionRows) > 0) {
|
415 |
+
$actionsRows[] = array(
|
416 |
+
'type' => $this->getMainTypeForActionId($tempActionRows),
|
417 |
+
'date' => $this->getMainDateForActionId($tempActionRows),
|
418 |
+
'action' => $this->getActionForAction($tempActionRows[0]),
|
419 |
+
'initiator' => $this->getInitiatorForAction($tempActionRows[0]),
|
420 |
+
'items' => $tempActionRows
|
421 |
+
);
|
422 |
+
}
|
423 |
+
|
424 |
+
if (count($actionsRows) <= 0) {
|
425 |
+
return '';
|
426 |
+
}
|
427 |
+
|
428 |
+
$tips = array(
|
429 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'Last action was completed successfully.',
|
430 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'Last action was completed with error(s).',
|
431 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'Last action was completed with warning(s).'
|
432 |
+
);
|
433 |
+
|
434 |
+
$icons = array(
|
435 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS => 'normal',
|
436 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR => 'error',
|
437 |
+
Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING => 'warning'
|
438 |
+
);
|
439 |
+
|
440 |
+
$summary = $this->getLayout()->createBlock('M2ePro/adminhtml_log_grid_summary', '', array(
|
441 |
+
'entity_id' => $listingOtherId,
|
442 |
+
'rows' => $actionsRows,
|
443 |
+
'tips' => $tips,
|
444 |
+
'icons' => $icons,
|
445 |
+
'view_help_handler' => 'PlayListingOtherGridHandlerObj.viewItemHelp',
|
446 |
+
'hide_help_handler' => 'PlayListingOtherGridHandlerObj.hideItemHelp',
|
447 |
+
));
|
448 |
+
|
449 |
+
return $summary->toHtml();
|
450 |
+
}
|
451 |
+
|
452 |
+
public function getActionForAction($actionRows)
|
453 |
+
{
|
454 |
+
$string = '';
|
455 |
+
|
456 |
+
switch ((int)$actionRows['action']) {
|
457 |
+
case Ess_M2ePro_Model_Listing_Other_Log::ACTION_CHANGE_STATUS_ON_CHANNEL:
|
458 |
+
$string = Mage::helper('M2ePro')->__('Status Change');
|
459 |
+
break;
|
460 |
+
}
|
461 |
+
|
462 |
+
return $string;
|
463 |
+
}
|
464 |
+
|
465 |
+
public function getInitiatorForAction($actionRows)
|
466 |
+
{
|
467 |
+
$string = '';
|
468 |
+
|
469 |
+
switch ($actionRows['initiator']) {
|
470 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_UNKNOWN:
|
471 |
+
$string = '';
|
472 |
+
break;
|
473 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_USER:
|
474 |
+
$string = Mage::helper('M2ePro')->__('Manual');
|
475 |
+
break;
|
476 |
+
case Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION:
|
477 |
+
$string = Mage::helper('M2ePro')->__('Automatic');
|
478 |
+
break;
|
479 |
+
}
|
480 |
+
|
481 |
+
return $string;
|
482 |
+
}
|
483 |
+
|
484 |
+
public function getMainTypeForActionId($actionRows)
|
485 |
+
{
|
486 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS;
|
487 |
+
|
488 |
+
foreach ($actionRows as $row) {
|
489 |
+
if ($row['type'] == Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR) {
|
490 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR;
|
491 |
+
break;
|
492 |
+
}
|
493 |
+
if ($row['type'] == Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING) {
|
494 |
+
$type = Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING;
|
495 |
+
}
|
496 |
+
}
|
497 |
+
|
498 |
+
return $type;
|
499 |
+
}
|
500 |
+
|
501 |
+
public function getMainDateForActionId($actionRows)
|
502 |
+
{
|
503 |
+
$format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
|
504 |
+
return Mage::app()->getLocale()->date(strtotime($actionRows[0]['create_date']))->toString($format);
|
505 |
+
}
|
506 |
+
|
507 |
+
// ####################################
|
508 |
+
|
509 |
+
protected function _toHtml()
|
510 |
+
{
|
511 |
+
$javascriptsMain = <<<JAVASCRIPT
|
512 |
+
<script type="text/javascript">
|
513 |
+
|
514 |
+
if (typeof PlayListingOtherGridHandlerObj != 'undefined') {
|
515 |
+
PlayListingOtherGridHandlerObj.afterInitPage();
|
516 |
+
}
|
517 |
+
|
518 |
+
Event.observe(window, 'load', function() {
|
519 |
+
setTimeout(function() {
|
520 |
+
PlayListingOtherGridHandlerObj.afterInitPage();
|
521 |
+
}, 350);
|
522 |
+
});
|
523 |
+
|
524 |
+
</script>
|
525 |
+
JAVASCRIPT;
|
526 |
+
|
527 |
+
return parent::_toHtml().$javascriptsMain;
|
528 |
+
}
|
529 |
+
|
530 |
+
// ####################################
|
531 |
+
|
532 |
+
public function getGridUrl()
|
533 |
+
{
|
534 |
+
return $this->getUrl('*/adminhtml_common_play_listing_other/grid', array('_current' => true));
|
535 |
+
}
|
536 |
+
|
537 |
+
public function getRowUrl($row)
|
538 |
+
{
|
539 |
+
return false;
|
540 |
+
}
|
541 |
+
|
542 |
+
// ####################################
|
543 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Other/Help.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_Play_Listing_Other_Help extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('playListingOtherHelp');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/play/listing/other/help.phtml');
|
19 |
+
}
|
20 |
+
|
21 |
+
public function getContainerId()
|
22 |
+
{
|
23 |
+
return 'block_notice_play_listings';
|
24 |
+
}
|
25 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Product.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_Play_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('playListingProduct');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_play_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')->__(Ess_M2ePro_Helper_Component_Play::TITLE),
|
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_play_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_PLAY
|
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('reset', array(
|
77 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
78 |
+
'onclick' => 'ProductGridHandlerObj.reset_click()',
|
79 |
+
'class' => 'reset'
|
80 |
+
));
|
81 |
+
//------------------------------
|
82 |
+
|
83 |
+
//------------------------------
|
84 |
+
$this->_addButton('save', array(
|
85 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
86 |
+
'onclick' => 'ProductGridHandlerObj.save_click(\'view\')',
|
87 |
+
'class' => 'save'
|
88 |
+
));
|
89 |
+
//------------------------------
|
90 |
+
}
|
91 |
+
|
92 |
+
public function getGridHtml()
|
93 |
+
{
|
94 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_play_listing_product_help');
|
95 |
+
return $helpBlock->toHtml() . parent::getGridHtml();
|
96 |
+
}
|
97 |
+
|
98 |
+
protected function _toHtml()
|
99 |
+
{
|
100 |
+
return '<div id="add_products_progress_bar"></div>'.
|
101 |
+
'<div id="add_products_container">'.
|
102 |
+
parent::_toHtml().
|
103 |
+
'</div>';
|
104 |
+
}
|
105 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Product/Category.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_Play_Listing_Product_Category extends Mage_Adminhtml_Block_Widget_Container
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('playListingProductCategory');
|
16 |
+
$this->_blockGroup = 'M2ePro';
|
17 |
+
$this->_controller = 'adminhtml_common_play_listing';
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
$this->setTemplate('widget/view/container.phtml');
|
21 |
+
|
22 |
+
// Set header text
|
23 |
+
//------------------------------
|
24 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
25 |
+
|
26 |
+
if (!Mage::helper('M2ePro/View_Common_Component')->isSingleActiveComponent()) {
|
27 |
+
$headerText = Mage::helper('M2ePro')->__(
|
28 |
+
'Add Products To %component_name% Listing "%listing_title%" From Categories',
|
29 |
+
Mage::helper('M2ePro')->__(Ess_M2ePro_Helper_Component_Play::TITLE),
|
30 |
+
$this->escapeHtml($listingData['title'])
|
31 |
+
);
|
32 |
+
} else {
|
33 |
+
$headerText = Mage::helper('M2ePro')->__(
|
34 |
+
'Add Products To Listing "%listing_title%" From Categories',
|
35 |
+
$this->escapeHtml($listingData['title'])
|
36 |
+
);
|
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 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
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_PLAY
|
60 |
+
)
|
61 |
+
);
|
62 |
+
$this->_addButton('back', array(
|
63 |
+
'label' => Mage::helper('M2ePro')->__('Back'),
|
64 |
+
'onclick' => 'PlayListingCategoryHandlerObj.back_click(\'' . $url . '\')',
|
65 |
+
'class' => 'back'
|
66 |
+
));
|
67 |
+
//------------------------------
|
68 |
+
} else {
|
69 |
+
//------------------------------
|
70 |
+
$url = $this->getUrl('*/adminhtml_common_play_listing/view', array('id' => $listingData['id']));
|
71 |
+
$this->_addButton('view_listing', array(
|
72 |
+
'label' => Mage::helper('M2ePro')->__('View Listing'),
|
73 |
+
'onclick' => 'setLocation(\''.$url.'\')',
|
74 |
+
'class' => 'button_link'
|
75 |
+
));
|
76 |
+
}
|
77 |
+
|
78 |
+
//------------------------------
|
79 |
+
$this->_addButton('reset', array(
|
80 |
+
'label' => Mage::helper('M2ePro')->__('Refresh'),
|
81 |
+
'onclick' => 'PlayListingCategoryHandlerObj.reset_click()',
|
82 |
+
'class' => 'reset'
|
83 |
+
));
|
84 |
+
//------------------------------
|
85 |
+
|
86 |
+
//------------------------------
|
87 |
+
$url = $this->getUrl(
|
88 |
+
'*/adminhtml_common_play_listing/categoryProduct',
|
89 |
+
array(
|
90 |
+
'id' => $listingData['id'],
|
91 |
+
'add_products' => 'yes',
|
92 |
+
'next' => 'yes'
|
93 |
+
)
|
94 |
+
);
|
95 |
+
$this->_addButton('save_and_next', array(
|
96 |
+
'label' => Mage::helper('M2ePro')->__('Next'),
|
97 |
+
'onclick' => 'PlayListingCategoryHandlerObj.save_click(\''.$url.'\')',
|
98 |
+
'class' => 'next save_and_next_button'
|
99 |
+
));
|
100 |
+
//------------------------------
|
101 |
+
|
102 |
+
//$url = $this->getUrl('*/adminhtml_common_play_listing/product',array(
|
103 |
+
// 'id' => $listingData['id'],
|
104 |
+
// 'back' => Mage::helper('M2ePro')->getBackUrlParam('*/adminhtml_common_listing/index')
|
105 |
+
//));
|
106 |
+
//$this->_addButton('save_and_list', array(
|
107 |
+
// 'label' => Mage::helper('M2ePro')->__('Save And List'),
|
108 |
+
// 'onclick' => 'PlayListingCategoryHandlerObj.save_and_list_click(\''.$url.'\')',
|
109 |
+
// 'class' => 'save save_and_list_button'
|
110 |
+
//));
|
111 |
+
|
112 |
+
//------------------------------
|
113 |
+
$url = $this->getUrl('*/adminhtml_common_play_listing/add',array('add_products'=>'yes'));
|
114 |
+
$this->_addButton('save_and_go_to_listing_view', array(
|
115 |
+
'label' => Mage::helper('M2ePro')->__('Save'),
|
116 |
+
'onclick' => 'PlayListingCategoryHandlerObj.save_click(\'' . $url .'\')',
|
117 |
+
'class' => 'save save_and_go_to_listings_view_button'
|
118 |
+
));
|
119 |
+
//------------------------------
|
120 |
+
}
|
121 |
+
|
122 |
+
protected function _toHtml()
|
123 |
+
{
|
124 |
+
// todo next
|
125 |
+
$categoryTreeBlock = $this->getLayout()->createBlock(
|
126 |
+
'M2ePro/adminhtml_common_listing_category_tree',
|
127 |
+
'',
|
128 |
+
array(
|
129 |
+
'component'=>Ess_M2ePro_Helper_Component_Play::NICK,
|
130 |
+
'tree_settings' => array(
|
131 |
+
'show_products_amount' => true,
|
132 |
+
'hide_products_this_listing' => true
|
133 |
+
)
|
134 |
+
)
|
135 |
+
);
|
136 |
+
$categoryBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_play_listing_product_category_edit');
|
137 |
+
$helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_common_play_listing_product_category_help');
|
138 |
+
|
139 |
+
return '<div id="add_products_progress_bar"></div>'.
|
140 |
+
'<div id="add_products_container">'.
|
141 |
+
parent::_toHtml() . $helpBlock->toHtml() . $categoryTreeBlock->toHtml() . $categoryBlock->toHtml().
|
142 |
+
'</div>';
|
143 |
+
}
|
144 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Product/Category/Edit.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_Play_Listing_Product_Category_Edit extends Mage_Adminhtml_Block_Template
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('playListingProductCategory');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/play/listing/product/category/edit.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Product/Category/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_Play_Listing_Product_Category_Help extends Mage_Adminhtml_Block_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
// Initialization block
|
14 |
+
//------------------------------
|
15 |
+
$this->setId('playListingProductCategoryHelp');
|
16 |
+
//------------------------------
|
17 |
+
|
18 |
+
$this->setTemplate('M2ePro/common/play/listing/product/category/help.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Play/Listing/Product/Grid.php
ADDED
@@ -0,0 +1,602 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
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|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @copyright Copyright (c) 2013 by ESS-UA.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Ess_M2ePro_Block_Adminhtml_Common_Play_Listing_Product_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
14 |
+
|
15 |
+
// Initialization block
|
16 |
+
//------------------------------
|
17 |
+
$this->setId('playListingProductGrid'.(isset($listingData['id'])?$listingData['id']:''));
|
18 |
+
//------------------------------
|
19 |
+
|
20 |
+
// Set default values
|
21 |
+
//------------------------------
|
22 |
+
$this->setDefaultSort('product_id');
|
23 |
+
$this->setDefaultDir('DESC');
|
24 |
+
$this->setSaveParametersInSession(true);
|
25 |
+
$this->setUseAjax(true);
|
26 |
+
//------------------------------
|
27 |
+
|
28 |
+
$this->isAjax = json_encode($this->getRequest()->isXmlHttpRequest());
|
29 |
+
}
|
30 |
+
|
31 |
+
// ####################################
|
32 |
+
|
33 |
+
protected function _prepareCollection()
|
34 |
+
{
|
35 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
36 |
+
|
37 |
+
// Get collection
|
38 |
+
//----------------------------
|
39 |
+
/* @var $collection Mage_Catalog_Model_Resource_Product_Collection */
|
40 |
+
$collection = Mage::getModel('catalog/product')->getCollection()
|
41 |
+
->addAttributeToSelect('sku')
|
42 |
+
->addAttributeToSelect('name')
|
43 |
+
->addAttributeToSelect('attribute_set_id')
|
44 |
+
->addAttributeToSelect('type_id')
|
45 |
+
->joinField('qty',
|
46 |
+
'cataloginventory/stock_item',
|
47 |
+
'qty',
|
48 |
+
'product_id=entity_id',
|
49 |
+
'{{table}}.stock_id=1',
|
50 |
+
'left')
|
51 |
+
->joinField('is_in_stock',
|
52 |
+
'cataloginventory/stock_item',
|
53 |
+
'is_in_stock',
|
54 |
+
'product_id=entity_id',
|
55 |
+
'{{table}}.stock_id=1',
|
56 |
+
'left');
|
57 |
+
|
58 |
+
/*$collection->getSelect()->joinLeft(
|
59 |
+
array('cisi' => Mage::getSingleton('core/resource')->getTableName('cataloginventory/stock_item')),
|
60 |
+
'(cisi.product_id = e.entity_id) AND (cisi.stock_id = 1)',
|
61 |
+
array('qty','is_in_stock')
|
62 |
+
);*/
|
63 |
+
//----------------------------
|
64 |
+
|
65 |
+
//----------------------------
|
66 |
+
$collection->getSelect()->distinct();
|
67 |
+
//----------------------------
|
68 |
+
|
69 |
+
// Add attribute set filter
|
70 |
+
//----------------------------
|
71 |
+
$collection->addFieldToFilter('attribute_set_id', array('in' => $listingData['attribute_sets']));
|
72 |
+
//----------------------------
|
73 |
+
|
74 |
+
// Set filter store
|
75 |
+
//----------------------------
|
76 |
+
$store = $this->_getStore();
|
77 |
+
|
78 |
+
if ($store->getId()) {
|
79 |
+
$collection->addStoreFilter($store);
|
80 |
+
$collection->joinAttribute('custom_name',
|
81 |
+
'catalog_product/name',
|
82 |
+
'entity_id',
|
83 |
+
null,
|
84 |
+
'inner',
|
85 |
+
$store->getId());
|
86 |
+
$collection->joinAttribute('status',
|
87 |
+
'catalog_product/status',
|
88 |
+
'entity_id',
|
89 |
+
null,
|
90 |
+
'inner',
|
91 |
+
$store->getId());
|
92 |
+
$collection->joinAttribute('visibility',
|
93 |
+
'catalog_product/visibility',
|
94 |
+
'entity_id',
|
95 |
+
null,
|
96 |
+
'inner',
|
97 |
+
$store->getId());
|
98 |
+
$collection->joinAttribute('price',
|
99 |
+
'catalog_product/price',
|
100 |
+
'entity_id',
|
101 |
+
null,
|
102 |
+
'left',
|
103 |
+
$store->getId());
|
104 |
+
$collection->joinAttribute('thumbnail',
|
105 |
+
'catalog_product/thumbnail',
|
106 |
+
'entity_id',
|
107 |
+
null,
|
108 |
+
'left',
|
109 |
+
$store->getId());
|
110 |
+
} else {
|
111 |
+
$collection->addAttributeToSelect('price');
|
112 |
+
$collection->addAttributeToSelect('status');
|
113 |
+
$collection->addAttributeToSelect('visibility');
|
114 |
+
$collection->addAttributeToSelect('thumbnail');
|
115 |
+
}
|
116 |
+
//----------------------------
|
117 |
+
|
118 |
+
// Hide products others listings
|
119 |
+
//----------------------------
|
120 |
+
$prefix = Mage::helper('M2ePro/Data_Global')->getValue('hide_products_others_listings_prefix');
|
121 |
+
is_null($hideParam = Mage::helper('M2ePro/Data_Session')->getValue($prefix)) && $hideParam = true;
|
122 |
+
|
123 |
+
if ($hideParam || isset($listingData['id'])) {
|
124 |
+
|
125 |
+
$dbExcludeSelect = Mage::getResourceModel('core/config')->getReadConnection()
|
126 |
+
->select()
|
127 |
+
->from(Mage::getResourceModel('M2ePro/Listing_Product')->getMainTable(),
|
128 |
+
new Zend_Db_Expr('DISTINCT `product_id`'));
|
129 |
+
|
130 |
+
if ($hideParam) {
|
131 |
+
|
132 |
+
$dbExcludeSelect->join(
|
133 |
+
array('l' => Mage::getResourceModel('M2ePro/Listing')->getMainTable()),
|
134 |
+
'`l`.`id` = `listing_id`', NULL
|
135 |
+
);
|
136 |
+
|
137 |
+
$dbExcludeSelect->where('`l`.`account_id` = ?', $listingData['account_id']);
|
138 |
+
$dbExcludeSelect->where('`l`.`marketplace_id` = ?', $listingData['marketplace_id']);
|
139 |
+
$dbExcludeSelect->where('`l`.`component_mode` = ?',Ess_M2ePro_Helper_Component_Play::NICK);
|
140 |
+
|
141 |
+
} else {
|
142 |
+
$dbExcludeSelect->where('`listing_id` = ?',(int)$listingData['id']);
|
143 |
+
}
|
144 |
+
|
145 |
+
// default sql select
|
146 |
+
$collection->getSelect()
|
147 |
+
->joinLeft(array('sq' => $dbExcludeSelect), 'sq.product_id = e.entity_id', array())
|
148 |
+
->where('sq.product_id IS NULL');
|
149 |
+
|
150 |
+
// alternatively sql select (for mysql v.5.1)
|
151 |
+
// $collection->getSelect()->where('`e`.`entity_id` NOT IN ('.$dbExcludeSelect->__toString().')');
|
152 |
+
}
|
153 |
+
//----------------------------
|
154 |
+
|
155 |
+
// Add categories filter
|
156 |
+
//----------------------------
|
157 |
+
$categoriesData = Mage::helper('M2ePro/Data_Global')->getValue('temp_listing_categories');
|
158 |
+
|
159 |
+
if (count($categoriesData) > 0) {
|
160 |
+
$dbSelect = Mage::getResourceModel('core/config')->getReadConnection()
|
161 |
+
->select()
|
162 |
+
->from(Mage::getSingleton('core/resource')->getTableName('catalog_category_product'),
|
163 |
+
new Zend_Db_Expr('DISTINCT `product_id`'))
|
164 |
+
->where('`category_id` IN ('.implode(',',$categoriesData).')');
|
165 |
+
|
166 |
+
$collection->getSelect()->where('`e`.`entity_id` IN ('.$dbSelect->__toString().')');
|
167 |
+
}
|
168 |
+
//----------------------------
|
169 |
+
|
170 |
+
$collection->addFieldToFilter(
|
171 |
+
array(
|
172 |
+
array('attribute'=>'type_id','neq'=>'virtual'),
|
173 |
+
)
|
174 |
+
);
|
175 |
+
|
176 |
+
/** @var $ruleModel Ess_M2ePro_Model_Magento_Product_Rule */
|
177 |
+
$ruleModel = Mage::helper('M2ePro/Data_Global')->getValue('rule_model');
|
178 |
+
$ruleModel->setAttributesFilterToCollection($collection);
|
179 |
+
|
180 |
+
//exit($collection->getSelect()->__toString());
|
181 |
+
|
182 |
+
// Set collection to grid
|
183 |
+
$this->setCollection($collection);
|
184 |
+
|
185 |
+
parent::_prepareCollection();
|
186 |
+
$this->getCollection()->addWebsiteNamesToResult();
|
187 |
+
|
188 |
+
return $this;
|
189 |
+
}
|
190 |
+
|
191 |
+
protected function _prepareColumns()
|
192 |
+
{
|
193 |
+
$this->addColumn('product_id', array(
|
194 |
+
'header' => Mage::helper('M2ePro')->__('Product ID'),
|
195 |
+
'align' => 'right',
|
196 |
+
'width' => '100px',
|
197 |
+
'type' => 'number',
|
198 |
+
'index' => 'entity_id',
|
199 |
+
'filter_index' => 'entity_id',
|
200 |
+
'frame_callback' => array($this, 'callbackColumnProductId')
|
201 |
+
));
|
202 |
+
|
203 |
+
$this->addColumn('name', array(
|
204 |
+
'header' => Mage::helper('M2ePro')->__('Product Title'),
|
205 |
+
'align' => 'left',
|
206 |
+
//'width' => '100px',
|
207 |
+
'type' => 'text',
|
208 |
+
'index' => 'name',
|
209 |
+
'filter_index' => 'name',
|
210 |
+
'frame_callback' => array($this, 'callbackColumnProductTitle')
|
211 |
+
));
|
212 |
+
|
213 |
+
$tempTypes = Mage::getSingleton('catalog/product_type')->getOptionArray();
|
214 |
+
if (isset($tempTypes['virtual'])) {
|
215 |
+
unset($tempTypes['virtual']);
|
216 |
+
}
|
217 |
+
|
218 |
+
$this->addColumn('type', array(
|
219 |
+
'header' => Mage::helper('M2ePro')->__('Type'),
|
220 |
+
'align' => 'left',
|
221 |
+
'width' => '90px',
|
222 |
+
'type' => 'options',
|
223 |
+
'sortable' => false,
|
224 |
+
'index' => 'type_id',
|
225 |
+
'filter_index' => 'type_id',
|
226 |
+
'options' => $tempTypes
|
227 |
+
));
|
228 |
+
|
229 |
+
$this->addColumn('is_in_stock', array(
|
230 |
+
'header' => Mage::helper('M2ePro')->__('Stock Availability'),
|
231 |
+
'align' => 'left',
|
232 |
+
'width' => '90px',
|
233 |
+
'type' => 'options',
|
234 |
+
'sortable' => false,
|
235 |
+
'index' => 'is_in_stock',
|
236 |
+
'filter_index' => 'is_in_stock',
|
237 |
+
'options' => array(
|
238 |
+
'1' => Mage::helper('M2ePro')->__('In Stock'),
|
239 |
+
'0' => Mage::helper('M2ePro')->__('Out of Stock')
|
240 |
+
),
|
241 |
+
'frame_callback' => array($this, 'callbackColumnIsInStock')
|
242 |
+
));
|
243 |
+
|
244 |
+
$this->addColumn('sku', array(
|
245 |
+
'header' => Mage::helper('M2ePro')->__('SKU'),
|
246 |
+
'align' => 'left',
|
247 |
+
'width' => '90px',
|
248 |
+
'type' => 'text',
|
249 |
+
'index' => 'sku',
|
250 |
+
'filter_index' => 'sku'
|
251 |
+
));
|
252 |
+
|
253 |
+
$store = $this->_getStore();
|
254 |
+
|
255 |
+
$this->addColumn('price', array(
|
256 |
+
'header' => Mage::helper('M2ePro')->__('Price'),
|
257 |
+
'align' => 'right',
|
258 |
+
'width' => '100px',
|
259 |
+
'type' => 'price',
|
260 |
+
'currency_code' => $store->getBaseCurrency()->getCode(),
|
261 |
+
'index' => 'price',
|
262 |
+
'filter_index' => 'price',
|
263 |
+
'frame_callback' => array($this, 'callbackColumnPrice')
|
264 |
+
));
|
265 |
+
|
266 |
+
$this->addColumn('qty', array(
|
267 |
+
'header' => Mage::helper('M2ePro')->__('Qty'),
|
268 |
+
'align' => 'right',
|
269 |
+
'width' => '100px',
|
270 |
+
'type' => 'number',
|
271 |
+
'index' => 'qty',
|
272 |
+
'filter_index' => 'qty',
|
273 |
+
'frame_callback' => array($this, 'callbackColumnQty')
|
274 |
+
));
|
275 |
+
|
276 |
+
$this->addColumn('visibility', array(
|
277 |
+
'header' => Mage::helper('M2ePro')->__('Visibility'),
|
278 |
+
'align' => 'left',
|
279 |
+
'width' => '90px',
|
280 |
+
'type' => 'options',
|
281 |
+
'sortable' => false,
|
282 |
+
'index' => 'visibility',
|
283 |
+
'filter_index' => 'visibility',
|
284 |
+
'options' => Mage::getModel('catalog/product_visibility')->getOptionArray()
|
285 |
+
));
|
286 |
+
|
287 |
+
$this->addColumn('status', array(
|
288 |
+
'header' => Mage::helper('M2ePro')->__('Status'),
|
289 |
+
'align' => 'left',
|
290 |
+
'width' => '90px',
|
291 |
+
'type' => 'options',
|
292 |
+
'sortable' => false,
|
293 |
+
'index' => 'status',
|
294 |
+
'filter_index' => 'status',
|
295 |
+
'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
|
296 |
+
'frame_callback' => array($this, 'callbackColumnStatus')
|
297 |
+
));
|
298 |
+
|
299 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
300 |
+
|
301 |
+
$this->addColumn('websites', array(
|
302 |
+
'header' => Mage::helper('M2ePro')->__('Websites'),
|
303 |
+
'align' => 'left',
|
304 |
+
'width' => '90px',
|
305 |
+
'type' => 'options',
|
306 |
+
'sortable' => false,
|
307 |
+
'index' => 'websites',
|
308 |
+
'filter_index' => 'websites',
|
309 |
+
'options' => Mage::getModel('core/website')->getCollection()->toOptionHash()
|
310 |
+
));
|
311 |
+
}
|
312 |
+
|
313 |
+
return parent::_prepareColumns();
|
314 |
+
}
|
315 |
+
|
316 |
+
protected function _prepareMassaction()
|
317 |
+
{
|
318 |
+
// Set massaction identifiers
|
319 |
+
//--------------------------------
|
320 |
+
$this->setMassactionIdField('entity_id');
|
321 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
322 |
+
//--------------------------------
|
323 |
+
|
324 |
+
// Set fake action
|
325 |
+
//--------------------------------
|
326 |
+
$this->getMassactionBlock()->addItem('attributes', array(
|
327 |
+
'label' => ' ',
|
328 |
+
'url' => $this->getUrl('*/adminhtml_common_play_listing/massStatus', array('_current'=>true)),
|
329 |
+
));
|
330 |
+
//--------------------------------
|
331 |
+
|
332 |
+
return parent::_prepareMassaction();
|
333 |
+
}
|
334 |
+
|
335 |
+
public function getMassactionBlockHtml()
|
336 |
+
{
|
337 |
+
$advancedFilterBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_listing_product_rule');
|
338 |
+
$advancedFilterBlock->setShowHideProductsOption();
|
339 |
+
$advancedFilterBlock->setGridJsObjectName($this->getJsObjectName());
|
340 |
+
|
341 |
+
return $advancedFilterBlock->toHtml() . parent::getMassactionBlockHtml();
|
342 |
+
}
|
343 |
+
|
344 |
+
// ####################################
|
345 |
+
|
346 |
+
public function callbackColumnProductId($value, $row, $column, $isExport)
|
347 |
+
{
|
348 |
+
$listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
|
349 |
+
|
350 |
+
$productId = (int)$value;
|
351 |
+
$storeId = (int)$listingData['store_id'];
|
352 |
+
|
353 |
+
$withoutImageHtml = '<a href="'
|
354 |
+
.$this->getUrl('adminhtml/catalog_product/edit',
|
355 |
+
array('id' => $productId))
|
356 |
+
.'" target="_blank">'
|
357 |
+
.$productId
|
358 |
+
.'</a>';
|
359 |
+
|
360 |
+
$showProductsThumbnails = (bool)(int)Mage::helper('M2ePro/Module')
|
361 |
+
->getConfig()
|
362 |
+
->getGroupValue('/view/','show_products_thumbnails');
|
363 |
+
if (!$showProductsThumbnails) {
|
364 |
+
return $withoutImageHtml;
|
365 |
+
}
|
366 |
+
|
367 |
+
/** @var $magentoProduct Ess_M2ePro_Model_Magento_Product */
|
368 |
+
$magentoProduct = Mage::getModel('M2ePro/Magento_Product');
|
369 |
+
$magentoProduct->s
|