diff --git a/Block/Adminhtml/Account/Grid.php b/Block/Adminhtml/Account/Grid.php index 473741acb..c5e851aae 100644 --- a/Block/Adminhtml/Account/Grid.php +++ b/Block/Adminhtml/Account/Grid.php @@ -46,6 +46,7 @@ protected function _prepareColumns() 'width' => '150px', 'type' => 'datetime', 'format' => \IntlDateFormatter::MEDIUM, + 'filter_time' => true, 'index' => 'create_date', 'filter_index' => 'main_table.create_date' )); @@ -56,6 +57,7 @@ protected function _prepareColumns() 'width' => '150px', 'type' => 'datetime', 'format' => \IntlDateFormatter::MEDIUM, + 'filter_time' => true, 'index' => 'update_date', 'filter_index' => 'main_table.update_date' )); diff --git a/Block/Adminhtml/Amazon/Account.php b/Block/Adminhtml/Amazon/Account.php index 536a34d70..a004b3e57 100644 --- a/Block/Adminhtml/Amazon/Account.php +++ b/Block/Adminhtml/Amazon/Account.php @@ -45,10 +45,9 @@ protected function _prepareLayout() 3rd Party Listings import including options of Mapping them to Magento Products and Moving them to M2E Pro Listings, etc. can be specified for each Account separately.


Note: Amazon Account can be deleted only if it is not being used -for any of M2E Pro Listings.


-

More detailed information you can find here.

+for any of M2E Pro Listings.

HTML - , $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/9gEtAQ')) +) ]); return parent::_prepareLayout(); diff --git a/Block/Adminhtml/Amazon/Account/Edit.php b/Block/Adminhtml/Amazon/Account/Edit.php index 30649ce2c..4d856c748 100644 --- a/Block/Adminhtml/Amazon/Account/Edit.php +++ b/Block/Adminhtml/Amazon/Account/Edit.php @@ -79,8 +79,8 @@ public function _construct() // --------------------------------------- // --------------------------------------- - if ($this->getHelper('Data\GlobalData')->getValue('temp_data') && - $this->getHelper('Data\GlobalData')->getValue('temp_data')->getId() + if ($this->getHelper('Data\GlobalData')->getValue('edit_account') && + $this->getHelper('Data\GlobalData')->getValue('edit_account')->getId() ) { // --------------------------------------- $this->addButton('delete', array( diff --git a/Block/Adminhtml/Amazon/Account/Edit/Tabs.php b/Block/Adminhtml/Amazon/Account/Edit/Tabs.php index 31241526e..23eb4834a 100644 --- a/Block/Adminhtml/Amazon/Account/Edit/Tabs.php +++ b/Block/Adminhtml/Amazon/Account/Edit/Tabs.php @@ -10,6 +10,7 @@ protected function _construct() { parent::_construct(); + $this->setId('amazonAccountEditTabs'); $this->setDestElementId('edit_form'); } @@ -33,19 +34,31 @@ protected function _beforeToHtml() 'content' => $this->createBlock('Amazon\Account\Edit\Tabs\Order')->toHtml(), )); - // TODO NOT SUPPORTED FEATURES -// if ($this->getHelper('Component\Amazon')->isRepricingEnabled() && -// $this->getHelper('Data\GlobalData')->getValue('temp_data')->getId()) { -// -// $this->addTab('repricing', array( -// 'label' => $this->__('Repricing Tool'), -// 'title' => $this->__('Repricing Tool'), -// 'content' => $this->getLayout() -// ->createBlock('M2ePro/adminhtml_common_amazon_account_edit_tabs_repricing')->toHtml(), -// )); -// } + if ($this->getHelper('Component\Amazon\Repricing')->isEnabled() && + $this->getHelper('Data\GlobalData')->getValue('edit_account')) { + + $this->addTab('repricing', array( + 'label' => $this->__('Repricing Tool'), + 'title' => $this->__('Repricing Tool'), + 'content' => $this->createBlock('Amazon\Account\Edit\Tabs\Repricing')->toHtml(), + )); + } $this->setActiveTab($this->getRequest()->getParam('tab', 'general')); + + $this->js->addOnReadyJs(<<getId()}').tabs( + 'option', 'active', jQuery('li[aria-labelledby="{$this->getId()}_' + urlHash + '"]').index() + ); + location.hash = ''; + }, 100); + } +JS + ); return parent::_beforeToHtml(); } diff --git a/Block/Adminhtml/Amazon/Account/Edit/Tabs/General.php b/Block/Adminhtml/Amazon/Account/Edit/Tabs/General.php index e756678a9..34ec93cd6 100644 --- a/Block/Adminhtml/Amazon/Account/Edit/Tabs/General.php +++ b/Block/Adminhtml/Amazon/Account/Edit/Tabs/General.php @@ -24,7 +24,7 @@ public function __construct( protected function _prepareForm() { /** @var $account \Ess\M2ePro\Model\Account */ - $account = $this->getHelper('Data\GlobalData')->getValue('temp_data'); + $account = $this->getHelper('Data\GlobalData')->getValue('edit_account'); $formData = !is_null($account) ? array_merge($account->getData(), $account->getChildObject()->getData()) : []; if (isset($formData['other_listings_mapping_settings'])) { @@ -44,12 +44,6 @@ protected function _prepareForm() $isEdit = !!$this->getRequest()->getParam('id'); - $licenseMessage = ''; - - if ($isEdit) { - $licenseMessage = (string)$this->getHelper('Data\GlobalData')->getValue('license_message'); - } - $marketplacesCollection = $this->getHelper('Component\Amazon')->getMarketplacesAvailableForApiCreation(); $marketplaces = []; foreach ($marketplacesCollection->getItems() as $item) { @@ -84,9 +78,9 @@ protected function _prepareForm()
  • The Merchant ID and MWS Auth Token will be automatically filled in.


  • More detailed information about how to work with this -Page you can find here.

    +Page you can find here.

    HTML - , $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/MgItAQ')) + , $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/MgItAQ')) ] ); @@ -200,7 +194,7 @@ protected function _prepareForm() 'onclick' => 'return AmazonAccountObj.getToken('.$marketplace['id'].')', 'target' => '_blank', 'value' => $this->__('Get Access Data'), - 'style' => 'text-decoration: underline;' //todo + 'style' => 'text-decoration: underline;' ] )->setFieldExtraAttributes('style="display: none"'); } @@ -247,7 +241,7 @@ protected function _prepareForm() $this->jsPhp->addConstants($this->getHelper('Data')->getClassConstants('\Ess\M2ePro\Model\Amazon\Account')); $this->jsPhp->addConstants($this->getHelper('Data')->getClassConstants('\Ess\M2ePro\Helper\Component\Amazon')); - $this->jsUrl->addUrls($this->getHelper('Data')->getControllerActions('Amazon\Account')); + $this->jsUrl->addUrls($this->getHelper('Data')->getControllerActions('Amazon\Account', ['_current' => true])); $this->jsUrl->addUrls([ 'formSubmit' => $this->getUrl( '*/amazon_account/save', array('_current' => true, 'id' => $this->getRequest()->getParam('id')) @@ -257,12 +251,14 @@ protected function _prepareForm() ) ]); + $this->jsTranslator->add('Please enter correct value.', $this->__('Please enter correct value.')); + $this->jsTranslator->add( - 'Be attentive! By Deleting Account you delete all information on it from M2E Pro Server. - This will cause inappropriate work of all Accounts\' copies.', + 'Be attentive! By Deleting Account you delete all information on it from M2E Pro Server. ' + . 'This will cause inappropriate work of all Accounts\' copies.', $this->__( - 'Be attentive! By Deleting Account you delete all information on it from M2E Pro Server. - This will cause inappropriate work of all Accounts\' copies.')); + 'Be attentive! By Deleting Account you delete all information on it from M2E Pro Server. ' + . 'This will cause inappropriate work of all Accounts\' copies.')); $id = $this->getRequest()->getParam('id'); $this->js->add("M2ePro.formData.id = '$id';"); @@ -282,7 +278,6 @@ protected function _prepareForm() window.AmazonAccountObj = new AmazonAccount(); AmazonAccountObj.initObservers(); jQuery(function(){ - {$licenseMessage} {$marketplaceJs} }); }); diff --git a/Block/Adminhtml/Amazon/Account/Edit/Tabs/ListingOther.php b/Block/Adminhtml/Amazon/Account/Edit/Tabs/ListingOther.php index 3d54e41a8..9223202cf 100644 --- a/Block/Adminhtml/Amazon/Account/Edit/Tabs/ListingOther.php +++ b/Block/Adminhtml/Amazon/Account/Edit/Tabs/ListingOther.php @@ -15,7 +15,7 @@ protected function _prepareForm() $attributes = $this->getHelper('Magento\Attribute')->getGeneralFromAllAttributeSets(); /** @var $account \Ess\M2ePro\Model\Account */ - $account = $this->getHelper('Data\GlobalData')->getValue('temp_data'); + $account = $this->getHelper('Data\GlobalData')->getValue('edit_account'); $formData = !is_null($account) ? array_merge($account->getData(), $account->getChildObject()->getData()) : []; if (isset($formData['other_listings_mapping_settings'])) { @@ -55,10 +55,10 @@ protected function _prepareForm() You can set preferences whether you would like to import 3rd Party Listings (Items that were Listed on eBay either directly on the channel or with the help of other than M2E Pro tool), automatically map them to Magento Product, etc..


    -

    More detailed information you can find here.

    +

    More detailed information you can find here.

    HTML , - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/NAItAQ') + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/NAItAQ') ) ] ); @@ -160,19 +160,23 @@ protected function _prepareForm() [ 'name' => 'mapping_sku_mode', 'label' => $this->__('SKU'), - 'class' => 'attribute-mode-select M2ePro-custom-attribute-can-be-created', + 'class' => 'attribute-mode-select', 'values' => [ Account::OTHER_LISTINGS_MAPPING_SKU_MODE_NONE => $this->__('None'), Account::OTHER_LISTINGS_MAPPING_SKU_MODE_DEFAULT => $this->__('Product SKU'), Account::OTHER_LISTINGS_MAPPING_SKU_MODE_PRODUCT_ID => $this->__('Product ID'), [ 'label' => $this->__('Magento Attributes'), - 'value' => $preparedAttributes + 'value' => $preparedAttributes, + 'attrs' => [ + 'is_magento_attribute' => true + ] ] ], 'value' => isset($mappingSettings['sku']['mode']) && $mappingSettings['sku']['mode'] != Account::OTHER_LISTINGS_MAPPING_SKU_MODE_CUSTOM_ATTRIBUTE ? $mappingSettings['sku']['mode'] : '', + 'create_magento_attribute' => true, ] )->setAfterElementHtml(<< @@ -222,17 +226,21 @@ class="input-text admin__control-text required-entry _required"> [ 'name' => 'mapping_general_id_mode', 'label' => $this->__('ASIN / ISBN'), - 'class' => 'attribute-mode-select M2ePro-custom-attribute-can-be-created', + 'class' => 'attribute-mode-select', 'values' => [ Account::OTHER_LISTINGS_MAPPING_GENERAL_ID_MODE_NONE => $this->__('None'), [ 'label' => $this->__('Magento Attributes'), - 'value' => $preparedAttributes + 'value' => $preparedAttributes, + 'attrs' => [ + 'is_magento_attribute' => true + ] ] ], 'value' => isset($mappingSettings['general_id']['mode']) && $mappingSettings['general_id']['mode'] != $modeCustomAttribute - ? $mappingSettings['general_id']['mode'] : '' + ? $mappingSettings['general_id']['mode'] : '', + 'create_magento_attribute' => true, ] )->setAfterElementHtml(<< @@ -280,18 +288,22 @@ class="input-text admin__control-text required-entry _required"> [ 'name' => 'mapping_title_mode', 'label' => $this->__('Listing Title'), - 'class' => 'attribute-mode-select M2ePro-custom-attribute-can-be-created', + 'class' => 'attribute-mode-select', 'values' => [ Account::OTHER_LISTINGS_MAPPING_TITLE_MODE_NONE => $this->__('None'), Account::OTHER_LISTINGS_MAPPING_TITLE_MODE_DEFAULT => $this->__('Product Name'), [ 'label' => $this->__('Magento Attributes'), - 'value' => $preparedAttributes + 'value' => $preparedAttributes, + 'attrs' => [ + 'is_magento_attribute' => true + ] ] ], 'value' => isset($mappingSettings['title']['mode']) && $mappingSettings['title']['mode'] != Account::OTHER_LISTINGS_MAPPING_TITLE_MODE_CUSTOM_ATTRIBUTE ? $mappingSettings['title']['mode'] : '', + 'create_magento_attribute' => true, ] )->setAfterElementHtml(<< diff --git a/Block/Adminhtml/Amazon/Account/Edit/Tabs/Order.php b/Block/Adminhtml/Amazon/Account/Edit/Tabs/Order.php index a4ff91e97..8508868ac 100644 --- a/Block/Adminhtml/Amazon/Account/Edit/Tabs/Order.php +++ b/Block/Adminhtml/Amazon/Account/Edit/Tabs/Order.php @@ -31,7 +31,7 @@ public function __construct( protected function _prepareForm() { - $account = $this->getHelper('Data\GlobalData')->getValue('temp_data'); + $account = $this->getHelper('Data\GlobalData')->getValue('edit_account'); $magentoOrdersSettings = !is_null($account) ? $account->getData('magento_orders_settings') : []; $magentoOrdersSettings = !empty($magentoOrdersSettings) ? json_decode($magentoOrdersSettings, true) : array(); @@ -142,10 +142,11 @@ protected function _prepareForm() M2E Pro or other tools.


    Note: If an Amazon Order is received, Magento Product QTY decreases only if a Magento Order is created.


    -

    More detailed information about how to work with this Page you can find here.

    +

    More detailed information about how to work with this Page you can find +here.

    HTML , - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/NgItAQ') + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/NgItAQ') ) ] ); @@ -235,7 +236,6 @@ protected function _prepareForm() 'container_id' => 'magento_orders_listings_other_store_id_container', 'name' => 'magento_orders_settings[listing_other][store_id]', 'label' => $this->__('Magento Store View'), - 'required' => true, 'value' => !empty($magentoOrdersSettings['listing_other']['store_id']) ? $magentoOrdersSettings['listing_other']['store_id'] : '', 'hasDefaultOption' => false, @@ -493,11 +493,11 @@ protected function _prepareForm() Default Guest Account will be defined as a Customer.
    Note: The Guest Checkout Option must be enabled in Magento. (Yes must be chosen in the Allow Guest Checkout Option in - Magento > System > Configuration > Sales > Checkout Tab).
    + Magento > Stores > Configuration > Sales > Checkout).
    Predefined Customer - the System uses one predefined Customer for all Amazon Orders related to this Account. You will be required to provide an ID of the existing Customer, which you can find in - Magento > Customers > Manage Customers Table.
    + Magento > Customers > All Customers.
    Create New - a new Customer will be created in Magento, using Amazon Customer data of Amazon Order.
    Note: A unique Customer Identifier is his e-mail address. @@ -533,7 +533,7 @@ protected function _prepareForm() 'label' => $this->__('Associate to Website'), 'values' => $values, 'value' => $formData['magento_orders_settings']['customer']['website_id'], - 'required' => true + 'required' => false ] ); @@ -550,7 +550,7 @@ protected function _prepareForm() 'label' => $this->__('Customer Group'), 'values' => $values, 'value' => $formData['magento_orders_settings']['customer']['group_id'], - 'required' => true + 'required' => false ] ); diff --git a/Block/Adminhtml/Amazon/Account/Edit/Tabs/Repricing.php b/Block/Adminhtml/Amazon/Account/Edit/Tabs/Repricing.php index a6784a0a2..645494e2b 100644 --- a/Block/Adminhtml/Amazon/Account/Edit/Tabs/Repricing.php +++ b/Block/Adminhtml/Amazon/Account/Edit/Tabs/Repricing.php @@ -8,11 +8,931 @@ class Repricing extends AbstractForm { protected function _prepareForm() { + /** @var \Ess\M2ePro\Model\Account $account */ + $account = $this->getHelper('Data\GlobalData')->getValue('edit_account'); + + /** @var \Ess\M2ePro\Helper\Magento\Attribute $magentoAttributeHelper */ + $magentoAttributeHelper = $this->getHelper('Magento\Attribute'); + + $generalAttributes = $magentoAttributeHelper->getGeneralFromAllAttributeSets(); + + $attributesByInputTypes = array( + 'text_price' => $magentoAttributeHelper->filterByInputTypes($generalAttributes, array('text', 'price')), + 'boolean' => $magentoAttributeHelper->filterByInputTypes($generalAttributes, array('boolean')), + ); + $form = $this->_formFactory->create(); + $form->addField( + 'amazon_accounts_repricing', + self::HELP_BLOCK, + [ + 'content' => $this->__(<<Repricing Tool developed by M2E Pro Team. This Tool allows to improve the position + of your offer. + It will review your Competitors' pricing and change + your Product prices accordingly.

    + + To start working with the Tool you should Add the information about your M2E Pro Amazon Account to the Repricing + Service and Link it + by clicking on the Button Link Now. Futher, you will need to complete the Wizard which allows + Setting Up all necessary data.

    + + After your Account is successfully Linked, you will be able to review the information about the Products + which are automatically + managed by the Repricer. Also, Additional Options of Automatic Product Adding and + Editing become available. + To use them you should switch your Listing to the Seller Central View Mode and select the appropriate + Option in the Actions bulk + at the top of the Grid.

    + + In case you decide to Stop using the Repricing Tool for M2E Pro Listings, + you can click on Unlink Button. + It will break the Connection between your M2E Pro Amazon Account and Repricing Service.

    + More detailed information on how to work with the Repricing Service you can find + here +HTML + , $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/bwAkAQ')) + ] + ); + + $fieldset = $form->addFieldset( + 'general', + [ + 'legend' => $this->__('General'), + 'collapsable' => false + ] + ); + + $isRepricingLinked = $account->getChildObject()->isRepricing(); + + if ($isRepricingLinked) { + + $fieldset->addField('unlink_repricing', + 'note', + [ + 'text' => <<{$this->__('This Amazon Account is successfully linked with Amazon Repricing Tool')}  + +HTML + , + 'style' => 'text-align: center;' + ] + ); + + /** @var \Ess\M2ePro\Model\Amazon\Account\Repricing $repricing */ + $repricing = $account->getChildObject()->getRepricing(); + + $fieldset->addField('customer', + self::CUSTOM_CONTAINER, + [ + 'label' => $this->__('Customer'), + 'style' => '', + 'text' => <<{$repricing->getEmail()}  +
    + + {$this->__('Go to Amazon Repricing Tool')} + +HTML + , + 'field_extra_attributes' => '', + ] + ); + + $m2eProRepricingProducts = $this->getRepricingProductsCount(); + + $fieldset = $form->addFieldset( + 'statistic', + [ + 'legend' => $this->__('Statistic'), + 'collapsable' => false + ] + ); + + $fieldset->addField('repricing_products', + self::CUSTOM_CONTAINER, + [ + 'label' => $this->__('Repricing Products'), + 'style' => '', + 'text' => <<{$repricing->getTotalProducts()} +HTML + , + 'tooltip' => $this->__( + 'This is a total number of Products managed by the Repricing Tool Linked to your + M2E Pro Amazon Account.' + ), + 'field_extra_attributes' => '', + ] + ); + + $fieldset->addField('m2epro_products', + self::CUSTOM_CONTAINER, + [ + 'label' => $this->__('M2E Pro Products'), + 'style' => '', + 'text' => <<{$m2eProRepricingProducts} +HTML + , + 'tooltip' => $this->__( + 'This is a number of Products managed by the Repricing Tool in your M2E Pro.' + ), + 'field_extra_attributes' => '', + ] + ); + + if ($m2eProRepricingProducts > 0) { + + $fieldset = $form->addFieldset( + 'additional_settings', + [ + 'legend' => $this->__('Additional Settings'), + 'collapsable' => false + ] + ); + + // Regular price + // -------------------------- + + $fieldset->addField( + 'regular_price_attribute', + 'hidden', + [ + 'name' => 'repricing[regular_price_attribute]', + 'value' => $repricing->getData('regular_price_attribute') + ] + ); + + $preparedAttributes = []; + + $priceModeAttribute = \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_MODE_ATTRIBUTE; + + if ($repricing->getRegularPriceMode() == $priceModeAttribute && + !$magentoAttributeHelper->isExistInAttributesArray( + $repricing->getData('regular_price_attribute'), $attributesByInputTypes['text_price'] + ) && $repricing->getData('regular_price_attribute') != '') { + + $attrs = [ + 'attribute_code' => $repricing->getData('regular_price_attribute'), + 'selected' => 'selected' + ]; + + $preparedAttributes[] = [ + 'attrs' => $attrs, + 'value' => \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_MODE_ATTRIBUTE, + 'label' => $magentoAttributeHelper->getAttributeLabel( + $repricing->getData('regular_price_attribute') + ), + ]; + } + + foreach ($attributesByInputTypes['text_price'] as $attribute) { + $attrs = ['attribute_code' => $attribute['code']]; + if ( + $repricing->getRegularPriceMode() == $priceModeAttribute + && $attribute['code'] == $repricing->getData('regular_price_attribute') + ) { + $attrs['selected'] = 'selected'; + } + $preparedAttributes[] = [ + 'attrs' => $attrs, + 'value' => \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_MODE_ATTRIBUTE, + 'label' => $attribute['label'], + ]; + } + + $priceCoefficient = $this->elementFactory->create('text', ['data' => [ + 'html_id' => 'regular_price_coefficient', + 'name' => 'repricing[regular_price_coefficient]', + 'label' => '', + 'value' => $repricing->getData('regular_price_coefficient'), + 'class' => 'M2ePro-validate-price-coefficient', + ]]); + $priceCoefficient->setForm($form); + + $fieldTooltip = '
    ' . + $this->getTooltipHtml( + $this->__(' + Regular Price is a common Price without any changes. This value is used for Repricing Rules configuration + and plays the role of the roll-back Price in case the Rules cannot be applied or the Goals provided + in the Repricing Rules cannot be achieved. You can find more detailed information about it + here.

    + You can select the configurations for automatic updating of the Regular Price value + by selecting from these options:
    + Manually - means that the according value will be manually provided for the Products;
    + According to Selling Format Policy settings - means that the Price value will + be taken based on the Selling Format Policy settings, which is used for this Item in the Listing;
    + From Product Price - means that the Price value from Magento Product Price will be taken;
    + From Special Price - means that the Price value from Magento Special Price will be taken;
    + From Magento Attribute - means that the Price value will + be taken from the selected Attribute.

    + + Please note, only common (available in all Attribute sets in your Magento), + Text or Price field Attributes are available for selection.

    + + More detailed information on how to work with this option you can find + here.', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/igAkAQ'), + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/JQMkAQ')) + ) . + '
    '; + + $tooltipPriceCoefficient = '
    ' . + $this->getTooltipHtml( + $this->__('Absolute figure (+8,-3), percentage (+15%, -20%) or Currency rate (1.44)') + ) . + '
    '; + + $value = ( + $repricing->getRegularPriceMode() == + \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_MODE_ATTRIBUTE + ) ? '' : $repricing->getRegularPriceMode(); + + $fieldset->addField( + 'regular_price_mode', + self::SELECT, + [ + 'name' => 'repricing[regular_price_mode]', + 'label' => $this->__('Update Regular Price'), + 'values' => [ + \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_MODE_MANUAL => $this->__('Manually'), + \Ess\M2ePro\Model\Amazon\Account\Repricing::REGULAR_PRICE_MODE_PRODUCT_POLICY => + $this->__('According to Selling Format Policy'), + \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_MODE_PRODUCT => + $this->__('From Product Price'), + \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_MODE_SPECIAL => + $this->__('From Special Price'), + [ + 'label' => $this->__('Magento Attributes'), + 'value' => $preparedAttributes, + 'attrs' => [ + 'is_magento_attribute' => true + ] + ] + ], + 'create_magento_attribute' => true, + 'value' => $value, + 'css_class' => 'price_mode', + 'after_element_html' => $fieldTooltip . '' . + $priceCoefficient->toHtml() . $tooltipPriceCoefficient . + '' + ] + )->addCustomAttribute('allowed_attribute_types', 'text,price'); + + $fieldset->addField('regular_price_variation_mode', + self::SELECT, + [ + 'container_id' => 'regular_price_variation_mode_tr', + 'label' => $this->__('Regular Variation Price Source'), + 'class' => 'select-main', + 'name' => 'repricing[regular_price_variation_mode]', + 'values' => [ + \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_VARIATION_MODE_PARENT => + $this->__('Main Product'), + \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_VARIATION_MODE_CHILDREN => + $this->__('Associated Products') + ], + 'value' => $repricing->getRegularPriceVariationMode(), + 'tooltip' => $this->__( + 'Determines where the Price for Bundle Products Options should be taken from.' + ), + 'field_extra_attributes' => 'style="display: none;"' + ] + ); + + // Min Price + // -------------------------- + + $fieldset->addField( + 'min_price_attribute', + 'hidden', + [ + 'name' => 'repricing[min_price_attribute]', + 'value' => $repricing->getData('min_price_attribute') + ] + ); + + $preparedAttributes = []; + + if ($repricing->getMinPriceMode() == \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_MODE_ATTRIBUTE && + !$magentoAttributeHelper->isExistInAttributesArray( + $repricing->getData('min_price_attribute'), $attributesByInputTypes['text_price'] + ) && $repricing->getData('min_price_attribute') != '') { + + $attrs = [ + 'attribute_code' => $repricing->getData('min_price_attribute'), + 'selected' => 'selected' + ]; + + $preparedAttributes[] = [ + 'attrs' => $attrs, + 'value' => \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_MODE_ATTRIBUTE, + 'label' => $magentoAttributeHelper->getAttributeLabel( + $repricing->getData('min_price_attribute') + ), + ]; + } + + foreach ($attributesByInputTypes['text_price'] as $attribute) { + $attrs = ['attribute_code' => $attribute['code']]; + if ( + $repricing->getMinPriceMode() == $priceModeAttribute + && $attribute['code'] == $repricing->getData('min_price_attribute') + ) { + $attrs['selected'] = 'selected'; + } + $preparedAttributes[] = [ + 'attrs' => $attrs, + 'value' => \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_MODE_ATTRIBUTE, + 'label' => $attribute['label'], + ]; + } + + $priceCoefficient = $this->elementFactory->create('text', ['data' => [ + 'html_id' => 'min_price_coefficient', + 'name' => 'repricing[min_price_coefficient]', + 'label' => '', + 'value' => $repricing->getData('min_price_coefficient'), + 'class' => 'M2ePro-validate-price-coefficient', + ]]); + $priceCoefficient->setForm($form); + + $fieldTooltip = '
    ' . + $this->getTooltipHtml( + $this->__(' + Min Price value is the lowest Price which you could sell your Item for.
    + You can find more detailed information about it + here.

    + + You can select the configurations for automatic updating of the Min Price value by selecting from these options: +
    + Manually - means that the according value will be manually provided for the Products;
    + Less than Regular Price by Value - means that the Min Price value will be taken as a Regular Price + decreased by the value you set.
    + For example, you set the Value 5. Your Regular price is 17. So the Min Price will be 12.
    + Less than Regular Price by Percent - means that the Min Price value will be taken as a + Regular Price decreased by the percent you set.
    + For example, you set 50 Percent. Your regular price is 10. So the Min Price will be 5.
    + From Magento Attribute - means that the Min Price value will be taken from the selected Attribute. +

    + Please note, only common (available in all Attribute sets in your Magento), Text or Price field Attributes are + available for selection.

    + + More detailed information on how to work with this option you can find + here.', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/igAkAQ'), + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/JQMkAQ') + ) + ) . + '
    '; + + $value = ( + $repricing->getMinPriceMode() == + \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_MODE_ATTRIBUTE + ) ? '' : $repricing->getMinPriceMode(); + + $fieldset->addField( + 'min_price_mode', + self::SELECT, + [ + 'name' => 'repricing[min_price_mode]', + 'label' => $this->__('Update Min Price'), + 'values' => [ + \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_MODE_MANUAL => $this->__('Manually'), + [ + 'label' => $this->__('Less than Regular Price by Value'), + 'value' => \Ess\M2ePro\Model\Amazon\Account\Repricing::MIN_PRICE_MODE_REGULAR_VALUE, + 'attrs' => [ + 'class' => 'repricing-min-price-mode-regular-depended' + ] + ], + [ + 'label' => $this->__('Less than Regular Price by Percent'), + 'value' => \Ess\M2ePro\Model\Amazon\Account\Repricing::MIN_PRICE_MODE_REGULAR_PERCENT, + 'attrs' => [ + 'class' => 'repricing-min-price-mode-regular-depended' + ] + ], + [ + 'label' => $this->__('Magento Attributes'), + 'value' => $preparedAttributes, + 'attrs' => [ + 'is_magento_attribute' => true + ] + ] + ], + 'create_magento_attribute' => true, + 'value' => $value, + 'css_class' => 'price_mode', + 'after_element_html' => $fieldTooltip . '' + . $priceCoefficient->toHtml() . $tooltipPriceCoefficient . + '' + ] + )->addCustomAttribute('allowed_attribute_types', 'text,price'); + + $fieldset->addField('min_price_value', + 'text', + [ + 'container_id' => 'min_price_value_tr', + 'label' => $this->__('Min Price Value'), + 'name' => 'repricing[min_price_value]', + 'value' => $repricing->getData('min_price_value'), + 'class' => 'M2ePro-required-when-visible M2ePro-account-repricing-price-value', + 'required' => true, + 'tooltip' => $this->__( + 'Provide the Value which you would like to decrease the Regular Price by.' + ), + 'field_extra_attributes' => 'style="display: none;"' + ] + ); + + $fieldset->addField('min_price_percent', + 'text', + [ + 'container_id' => 'min_price_percent_tr', + 'label' => $this->__('Min Price Percent'), + 'name' => 'repricing[min_price_percent]', + 'value' => $repricing->getData('min_price_percent'), + 'class' => 'M2ePro-required-when-visible M2ePro-account-repricing-price-value', + 'required' => true, + 'tooltip' => $this->__( + 'Provide the Percent Value which you would like to decrease the Regular Price by.' + ), + 'field_extra_attributes' => 'style="display: none;"' + ] + ); + + $fieldset->addField('min_price_variation_mode', + self::SELECT, + [ + 'container_id' => 'min_price_variation_mode_tr', + 'label' => $this->__('Min Variation Price Source'), + 'class' => 'select-main', + 'name' => 'repricing[min_price_variation_mode]', + 'values' => [ + \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_VARIATION_MODE_PARENT => + $this->__('Main Product'), + \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_VARIATION_MODE_CHILDREN => + $this->__('Associated Products') + ], + 'value' => $repricing->getMinPriceVariationMode(), + 'tooltip' => $this->__( + 'Determines where the Price for Bundle Products Options should be taken from.' + ), + 'field_extra_attributes' => 'style="display: none;"' + ] + ); + + $fieldset->addField('min_price_warning', + self::CUSTOM_CONTAINER, + [ + 'container_id' => 'min_price_warning_tr', + 'css_class' => 'm2epro-custom-container-full-width', + 'style' => '', + 'text' => << +
    +
    + {$this->__('Min Price value is required to be specified to guarantee that M2E + Amazon Repricing Service will never set the Price of your Offer + lower than Min allowed Price. It allows Sellers to automatically + prevent any incorrect Price values to be set for their Items.

    + The dynamic updating of the Min Price value cannot give the 100% + assurance that all the data will be properly set and the correct + Price will be used for the Item. Thus, more preferable and reliable + option is Manual updating of the Min Price value.')} +
    +
    + +HTML + , + 'field_extra_attributes' => 'style="display: none;"' + ] + ); + + // Max Price + // -------------------------- + + $fieldset->addField( + 'max_price_attribute', + 'hidden', + [ + 'name' => 'repricing[max_price_attribute]', + 'value' => $repricing->getData('max_price_attribute') + ] + ); + + $preparedAttributes = []; + + if ($repricing->getMaxPriceMode() == \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_MODE_ATTRIBUTE && + !$magentoAttributeHelper->isExistInAttributesArray( + $repricing->getData('max_price_attribute'), $attributesByInputTypes['text_price'] + ) && $repricing->getData('max_price_attribute') != '') { + + $attrs = [ + 'attribute_code' => $repricing->getData('max_price_attribute'), + 'selected' => 'selected' + ]; + + $preparedAttributes[] = [ + 'attrs' => $attrs, + 'value' => \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_MODE_ATTRIBUTE, + 'label' => $magentoAttributeHelper->getAttributeLabel( + $repricing->getData('max_price_attribute') + ), + ]; + } + + foreach ($attributesByInputTypes['text_price'] as $attribute) { + $attrs = ['attribute_code' => $attribute['code']]; + if ( + $repricing->getMaxPriceMode() == $priceModeAttribute + && $attribute['code'] == $repricing->getData('max_price_attribute') + ) { + $attrs['selected'] = 'selected'; + } + $preparedAttributes[] = [ + 'attrs' => $attrs, + 'value' => \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_MODE_ATTRIBUTE, + 'label' => $attribute['label'], + ]; + } + + $fieldTooltip = '
    ' . + $this->getTooltipHtml( + $this->__(' + Max Price value is the highest Price which you could sell your Item for.
    + You can find more detailed information about it + here.

    + + Manually - means that the according value will be manually provided for the Products;
    + More than Regular Price by Value - means that the Max Price value will be taken as a Regular + Price increased by the value you set.
    + For example, you set the Value 5. Your Regular price is 17. So the Max Price will be 22.
    + More than Regular Price by Percent - means that the Max Price value will be taken as a Regular + Price increased by the percent you set.
    + For example, you set 50 Percent. Your regular price is 10. So the Max Price will be 15.
    + From Magento Attribute - means that the Max Price value will be taken from the selected Attribute. +

    + + Please note, only common (available in all Attribute sets in your Magento), Text or Price field Attributes are + available for selection.

    + + More detailed information on how to work with this option you can find + here.', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/igAkAQ'), + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/JQMkAQ') + ) + ) . + '
    '; + + $priceCoefficient = $this->elementFactory->create('text', ['data' => [ + 'html_id' => 'max_price_coefficient', + 'name' => 'repricing[max_price_coefficient]', + 'label' => '', + 'value' => $repricing->getData('max_price_coefficient'), + 'class' => 'M2ePro-validate-price-coefficient', + ]]); + $priceCoefficient->setForm($form); + + $value = ( + $repricing->getMaxPriceMode() == + \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_MODE_ATTRIBUTE + ) ? '' : $repricing->getMaxPriceMode(); + + $fieldset->addField( + 'max_price_mode', + self::SELECT, + [ + 'name' => 'repricing[max_price_mode]', + 'label' => $this->__('Update Max Price'), + 'values' => [ + \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_MODE_MANUAL => $this->__('Manually'), + [ + 'label' => $this->__('More than Regular Price by Value'), + 'value' => \Ess\M2ePro\Model\Amazon\Account\Repricing::MAX_PRICE_MODE_REGULAR_VALUE, + 'attrs' => [ + 'class' => 'repricing-max-price-mode-regular-depended' + ] + ], + [ + 'label' => $this->__('More than Regular Price by Percent'), + 'value' => \Ess\M2ePro\Model\Amazon\Account\Repricing::MAX_PRICE_MODE_REGULAR_PERCENT, + 'attrs' => [ + 'class' => 'repricing-max-price-mode-regular-depended' + ] + ], + [ + 'label' => $this->__('Magento Attributes'), + 'value' => $preparedAttributes, + 'attrs' => [ + 'is_magento_attribute' => true + ] + ] + ], + 'create_magento_attribute' => true, + 'value' => $value, + 'css_class' => 'price_mode', + 'after_element_html' => $fieldTooltip . '' + . $priceCoefficient->toHtml() . $tooltipPriceCoefficient . + '' + ] + )->addCustomAttribute('allowed_attribute_types', 'text,price'); + + $fieldset->addField('max_price_value', + 'text', + [ + 'container_id' => 'max_price_value_tr', + 'label' => $this->__('Max Price Value'), + 'name' => 'repricing[max_price_value]', + 'value' => $repricing->getData('max_price_value'), + 'class' => 'M2ePro-required-when-visible M2ePro-account-repricing-price-value', + 'required' => true, + 'tooltip' => $this->__( + 'Provide the Value which you would like to decrease the Regular Price by.' + ), + 'field_extra_attributes' => 'style="display: none;"' + ] + ); + + $fieldset->addField('max_price_percent', + 'text', + [ + 'container_id' => 'max_price_percent_tr', + 'label' => $this->__('Max Price Percent'), + 'name' => 'repricing[max_price_percent]', + 'value' => $repricing->getData('max_price_percent'), + 'class' => 'M2ePro-required-when-visible M2ePro-account-repricing-price-value', + 'required' => true, + 'tooltip' => $this->__( + 'Provide the Percent Value which you would like to decrease the Regular Price by.' + ), + 'field_extra_attributes' => 'style="display: none;"' + ] + ); + + $fieldset->addField('max_price_variation_mode', + self::SELECT, + [ + 'container_id' => 'max_price_variation_mode_tr', + 'label' => $this->__('Max Variation Price Source'), + 'class' => 'select-main', + 'name' => 'repricing[max_price_variation_mode]', + 'values' => [ + \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_VARIATION_MODE_PARENT => + $this->__('Main Product'), + \Ess\M2ePro\Model\Amazon\Account\Repricing::PRICE_VARIATION_MODE_CHILDREN => + $this->__('Associated Products') + ], + 'value' => $repricing->getMaxPriceVariationMode(), + 'tooltip' => $this->__( + 'Determaxes where the Price for Bundle Products Options should be taken from.' + ), + 'field_extra_attributes' => 'style="display: none;"' + ] + ); + + $fieldset->addField('max_price_warning', + self::CUSTOM_CONTAINER, + [ + 'container_id' => 'max_price_warning_tr', + 'style' => '', + 'text' => << +
    +
    + {$this->__('Max Price value is required to be specified to guarantee that M2E + Amazon Repricing Service will never set the Price of your Offer + higher than Max allowed Price. It allows Sellers to automatically + prevent any incorrect Price values to be set for their Items.

    + The dynamic updating of the Max Price value cannot give the 100% + assurance that all the data will be properly set and the correct + Price will be used for the Item. Thus, more preferable and reliable + option is Manual updating of the Max Price value.')} +
    +
    + +HTML + , + 'field_extra_attributes' => 'style="display: none;"' + ] + ); + + // Disable Repricing + // ---------------------- + + $fieldset->addField( + 'disable_mode_attribute', + 'hidden', + [ + 'name' => 'repricing[disable_mode_attribute]', + 'value' => $repricing->getData('disable_mode_attribute') + ] + ); + + $preparedAttributes = []; + + $priceModeAttribute = \Ess\M2ePro\Model\Amazon\Account\Repricing::DISABLE_MODE_ATTRIBUTE; + + if ($repricing->getDisableMode() == $priceModeAttribute && + !$magentoAttributeHelper->isExistInAttributesArray( + $repricing->getData('disable_mode_attribute'), $attributesByInputTypes['boolean'] + ) && $repricing->getData('disable_mode_attribute') != '') { + + $attrs = [ + 'attribute_code' => $repricing->getData('disable_mode_attribute'), + 'selected' => 'selected' + ]; + + $preparedAttributes[] = [ + 'attrs' => $attrs, + 'value' => \Ess\M2ePro\Model\Amazon\Account\Repricing::DISABLE_MODE_ATTRIBUTE, + 'label' => $magentoAttributeHelper->getAttributeLabel( + $repricing->getData('disable_mode_attribute') + ), + ]; + } + + foreach ($attributesByInputTypes['boolean'] as $attribute) { + $attrs = ['attribute_code' => $attribute['code']]; + if ( + $repricing->getDisableMode() == $priceModeAttribute + && $attribute['code'] == $repricing->getData('disable_mode_attribute') + ) { + $attrs['selected'] = 'selected'; + } + $preparedAttributes[] = [ + 'attrs' => $attrs, + 'value' => \Ess\M2ePro\Model\Amazon\Account\Repricing::DISABLE_MODE_ATTRIBUTE, + 'label' => $attribute['label'], + ]; + } + + $value = ( + $repricing->getDisableMode() == + \Ess\M2ePro\Model\Amazon\Account\Repricing::DISABLE_MODE_ATTRIBUTE + ) ? '' : $repricing->getDisableMode(); + + $fieldset->addField( + 'disable_mode', + self::SELECT, + [ + 'name' => 'repricing[disable_mode]', + 'label' => $this->__('Disable Repricing'), + 'values' => [ + \Ess\M2ePro\Model\Amazon\Account\Repricing::DISABLE_MODE_MANUAL => $this->__('Manually'), + \Ess\M2ePro\Model\Amazon\Account\Repricing::DISABLE_MODE_PRODUCT_STATUS => + $this->__('When Status is Disabled'), + [ + 'label' => $this->__('Magento Attributes'), + 'value' => $preparedAttributes, + 'attrs' => [ + 'is_magento_attribute' => true + ] + ] + ], + 'create_magento_attribute' => true, + 'value' => $value, + 'tooltip' => $this->__(' + This feature allows you to set when you would like to disable dynamic price repricing for your items.
    + You can find more detailed information about it + here.

    + + Manually - means that the dynamic repricing can be disabled only manually;
    + When Status is Disabled - means that the dynamic repricing will be automatically stopped for + the Product which has Disabled status in Magento;
    + From Magento Attribute - means that the dynamic repricing will be automatically stopped for + the product if Yes value is provided in the selected Attribute.

    + Please note, only common (available in all Attribute sets in your Magento), Text or Price field Attributes are + available for selection.

    + + More detailed information on how to work with this option you can find + here.', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/PAMkAQ'), + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/JQMkAQ') + ) + ] + )->addCustomAttribute('allowed_attribute_types', 'boolean'); + + $this->js->addOnReadyJs(<<addField('link_repricing', + 'note', + [ + 'text' => <<{$this->__('First, you have to link this Amazon Account with Amazon Repricing Tool')}  + +HTML + , + 'style' => 'text-align: center;' + ] + ); + } + + $this->css->add( +<<jsPhp->addConstants( + $this->getHelper('Data')->getClassConstants('\Ess\M2ePro\Model\Amazon\Account\Repricing') + ); + + $this->jsUrl->addUrls($this->getHelper('Data')->getControllerActions('Amazon\Account\Repricing', [ + 'id' => $account->getId() + ])); + $this->setForm($form); return parent::_prepareForm(); } + protected function getRepricingProductsCount() + { + $account = $this->getHelper('Data\GlobalData')->getValue('edit_account'); + + $listingProductObject = $this->parentFactory->getObject( + \Ess\M2ePro\Helper\Component\Amazon::NICK, 'Listing\Product' + ); + + /** @var \Ess\M2ePro\Model\ResourceModel\Amazon\Listing\Product\Collection $collection */ + $collection = $listingProductObject->getCollection(); + + $collection->getSelect()->join( + array('l' => $this->activeRecordFactory->getObject('Listing')->getResource()->getMainTable()), + '(`l`.`id` = `main_table`.`listing_id`)', + array() + ); + + $collection->getSelect()->where("`second_table`.`is_variation_parent` = 0"); + $collection->getSelect()->where("`l`.`account_id` = ?", $account->getId()); + + $collection->getSelect()->join( + [ + 'malpr' => $this->activeRecordFactory->getObject('Amazon\Listing\Product\Repricing') + ->getResource()->getMainTable() + ], + '(`second_table`.`listing_product_id` = `malpr`.`listing_product_id`)', + [] + ); + + return $collection->count(); + } } \ No newline at end of file diff --git a/Block/Adminhtml/Amazon/Grid/Column/Filter/Price.php b/Block/Adminhtml/Amazon/Grid/Column/Filter/Price.php index 7ea7b29bc..87cca68f7 100644 --- a/Block/Adminhtml/Amazon/Grid/Column/Filter/Price.php +++ b/Block/Adminhtml/Amazon/Grid/Column/Filter/Price.php @@ -19,8 +19,12 @@ public function getHtml() $html = <<
    - {$this->__('Repricing')}: - + {$this->__('Repricing')} +   + diff --git a/Block/Adminhtml/Amazon/Grid/Column/Filter/Qty.php b/Block/Adminhtml/Amazon/Grid/Column/Filter/Qty.php index 477de2edf..c5ba9e5b0 100644 --- a/Block/Adminhtml/Amazon/Grid/Column/Filter/Qty.php +++ b/Block/Adminhtml/Amazon/Grid/Column/Filter/Qty.php @@ -19,12 +19,15 @@ public function getHtml() $html = <<
    +   - +
    HTML; diff --git a/Block/Adminhtml/Amazon/Listing/AutoAction/Mode.php b/Block/Adminhtml/Amazon/Listing/AutoAction/Mode.php index b941aa373..9c33c5f8b 100644 --- a/Block/Adminhtml/Amazon/Listing/AutoAction/Mode.php +++ b/Block/Adminhtml/Amazon/Listing/AutoAction/Mode.php @@ -15,7 +15,7 @@ class Mode extends \Ess\M2ePro\Block\Adminhtml\Listing\AutoAction\Mode public function getHelpPageUrl() { return $this->getHelper('Module\Support') - ->getDocumentationUrl(NULL, NULL, 'x/kAYtAQ'); + ->getDocumentationArticleUrl('x/kAYtAQ'); } diff --git a/Block/Adminhtml/Amazon/Listing/AutoAction/Mode/Category.php b/Block/Adminhtml/Amazon/Listing/AutoAction/Mode/Category.php index de31cc37c..380d825c3 100644 --- a/Block/Adminhtml/Amazon/Listing/AutoAction/Mode/Category.php +++ b/Block/Adminhtml/Amazon/Listing/AutoAction/Mode/Category.php @@ -55,12 +55,13 @@ protected function _toHtml() is added to the Magento Category with regard to the Store View selected for the M2E Pro Listing. In other words, after a Magento Product is added to the selected Magento Category, it can be automatically added to M2E Pro Listing if the settings are enabled.


    -

    Accordingly, if a Magento Product present in the the M2E Pro Listing is removed from the +

    Accordingly, if a Magento Product present in the M2E Pro Listing is removed from the Magento Category, the Item will be removed from the Listing and its sale will be stopped on Channel.


    -

    More detailed information you can find here.

    ', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/lgYtAQ') +

    More detailed information you can find + here.

    ', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/lgYtAQ') ) ]); diff --git a/Block/Adminhtml/Amazon/Listing/AutoAction/Mode/Category/Form.php b/Block/Adminhtml/Amazon/Listing/AutoAction/Mode/Category/Form.php index b78c40907..25ee460ce 100644 --- a/Block/Adminhtml/Amazon/Listing/AutoAction/Mode/Category/Form.php +++ b/Block/Adminhtml/Amazon/Listing/AutoAction/Mode/Category/Form.php @@ -118,7 +118,7 @@ protected function _prepareForm() 'field_extra_attributes' => 'id="auto_action_amazon_add_and_create_asin"', 'tooltip' => $this->__( 'Should M2E Pro try to create new ASIN/ISBN in case Search - Settings are not set or contain the incorrect values ?' + Settings are not set or contain the incorrect values?' ) ] ); @@ -154,7 +154,8 @@ protected function _prepareForm() $url = $this->getUrl('*/amazon_template_description/new', array( 'is_new_asin_accepted' => 1, - 'marketplace_id' => $this->getListing()->getMarketplaceId() + 'marketplace_id' => $this->getListing()->getMarketplaceId(), + 'close_on_save' => true )); $fieldSet->addField('adding_description_template_id', diff --git a/Block/Adminhtml/Amazon/Listing/AutoAction/Mode/GlobalMode.php b/Block/Adminhtml/Amazon/Listing/AutoAction/Mode/GlobalMode.php index da199d704..30a4bf63c 100644 --- a/Block/Adminhtml/Amazon/Listing/AutoAction/Mode/GlobalMode.php +++ b/Block/Adminhtml/Amazon/Listing/AutoAction/Mode/GlobalMode.php @@ -26,11 +26,12 @@ protected function _prepareForm() '

    These Rules of the automatic product adding and removal act globally for all Magento Catalog. When a new Magento Product is added to Magento Catalog, it will be automatically added to the current M2E Pro Listing if the settings are enabled.


    -

    Accordingly, if a Magento Product present in the the M2E Pro Listing is removed from +

    Accordingly, if a Magento Product present in the M2E Pro Listing is removed from Magento Catalog, the Item will be removed from the Listing and its sale will be stopped on Channel.


    -

    More detailed information you can find here.

    ', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/kgYtAQ') +

    More detailed information you can find + here.

    ', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/kgYtAQ') ) ] ); @@ -104,7 +105,7 @@ protected function _prepareForm() 'field_extra_attributes' => 'id="auto_action_amazon_add_and_create_asin"', 'tooltip' => $this->__( 'Should M2E Pro try to create new ASIN/ISBN in case Search - Settings are not set or contain the incorrect values ?' + Settings are not set or contain the incorrect values?' ) ] ); @@ -140,7 +141,8 @@ protected function _prepareForm() $url = $this->getUrl('*/amazon_template_description/new', array( 'is_new_asin_accepted' => 1, - 'marketplace_id' => $this->getListing()->getMarketplaceId() + 'marketplace_id' => $this->getListing()->getMarketplaceId(), + 'close_on_save' => true )); $fieldSet->addField('adding_description_template_id', diff --git a/Block/Adminhtml/Amazon/Listing/AutoAction/Mode/Website.php b/Block/Adminhtml/Amazon/Listing/AutoAction/Mode/Website.php index 5b7f2e636..956cb6435 100644 --- a/Block/Adminhtml/Amazon/Listing/AutoAction/Mode/Website.php +++ b/Block/Adminhtml/Amazon/Listing/AutoAction/Mode/Website.php @@ -26,11 +26,12 @@ protected function _prepareForm() Magento Product is added to the Website with regard to the Store View selected for the M2E Pro Listing. In other words, after a Magento Product is added to the selected Website, it can be automatically added to M2E Pro Listing if the settings are enabled.


    -

    Accordingly, if a Magento Product present in the the M2E Pro Listing is removed +

    Accordingly, if a Magento Product present in the M2E Pro Listing is removed from the Website, the Item will be removed from the Listing and its sale will be stopped on Channel.


    -

    More detailed information you can find here.

    ', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/lAYtAQ') +

    More detailed information you can find + here.

    ', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/lAYtAQ') ) ] ); @@ -106,7 +107,7 @@ protected function _prepareForm() 'field_extra_attributes' => 'id="auto_action_amazon_add_and_create_asin"', 'tooltip' => $this->__( 'Should M2E Pro try to create new ASIN/ISBN in case Search - Settings are not set or contain the incorrect values ?' + Settings are not set or contain the incorrect values?' ) ] ); @@ -142,7 +143,8 @@ protected function _prepareForm() $url = $this->getUrl('*/amazon_template_description/new', array( 'is_new_asin_accepted' => 1, - 'marketplace_id' => $this->getListing()->getMarketplaceId() + 'marketplace_id' => $this->getListing()->getMarketplaceId(), + 'close_on_save' => true )); $fieldSet->addField('adding_description_template_id', diff --git a/Block/Adminhtml/Amazon/Listing/Create/General.php b/Block/Adminhtml/Amazon/Listing/Create/General.php index a9eda42b8..bf556d218 100644 --- a/Block/Adminhtml/Amazon/Listing/Create/General.php +++ b/Block/Adminhtml/Amazon/Listing/Create/General.php @@ -58,8 +58,9 @@ protected function _toHtml() a Marketplace that you are going to sell Magento Products on.

    It is also important to specify a Store View in accordance with which Magento Attribute values will be used in the Listing settings.


    -

    More detailed information you can find here.

    ', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/XQItAQ') +

    More detailed information you can find + here.

    ', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/XQItAQ') ) ]); diff --git a/Block/Adminhtml/Amazon/Listing/Create/General/Form.php b/Block/Adminhtml/Amazon/Listing/Create/General/Form.php index a1eed6278..e4eece3c3 100644 --- a/Block/Adminhtml/Amazon/Listing/Create/General/Form.php +++ b/Block/Adminhtml/Amazon/Listing/Create/General/Form.php @@ -8,13 +8,11 @@ class Form extends AbstractForm { protected $amazonFactory; - protected $elementFactory; //######################################## public function __construct( \Ess\M2ePro\Model\ActiveRecord\Component\Parent\Amazon\Factory $amazonFactory, - \Magento\Framework\Data\Form\Element\Factory $elementFactory, \Ess\M2ePro\Block\Adminhtml\Magento\Context\Template $context, \Magento\Framework\Registry $registry, \Magento\Framework\Data\FormFactory $formFactory, @@ -22,7 +20,6 @@ public function __construct( ) { $this->amazonFactory = $amazonFactory; - $this->elementFactory = $elementFactory; parent::__construct($context, $registry, $formFactory, $data); } @@ -113,7 +110,6 @@ protected function _prepareForm() [ 'label' => $this->__('Account'), 'style' => 'line-height: 32px; display: initial;', - 'required' => count($accounts) > 1, 'text' => << {$accountSelect->toHtml()} diff --git a/Block/Adminhtml/Amazon/Listing/Create/Search.php b/Block/Adminhtml/Amazon/Listing/Create/Search.php index 248b040cc..daaeb7fb7 100644 --- a/Block/Adminhtml/Amazon/Listing/Create/Search.php +++ b/Block/Adminhtml/Amazon/Listing/Create/Search.php @@ -93,8 +93,8 @@ protected function _toHtml()
    More detailed information you can find - here.', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/YQItAQ') + here.', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/YQItAQ') ) ]); diff --git a/Block/Adminhtml/Amazon/Listing/Create/Search/Form.php b/Block/Adminhtml/Amazon/Listing/Create/Search/Form.php index e26c08f1e..212d342ba 100644 --- a/Block/Adminhtml/Amazon/Listing/Create/Search/Form.php +++ b/Block/Adminhtml/Amazon/Listing/Create/Search/Form.php @@ -14,13 +14,11 @@ class Form extends AbstractForm protected $listing; protected $amazonFactory; - protected $elementFactory; //######################################## public function __construct( \Ess\M2ePro\Model\ActiveRecord\Component\Parent\Amazon\Factory $amazonFactory, - \Magento\Framework\Data\Form\Element\Factory $elementFactory, \Ess\M2ePro\Block\Adminhtml\Magento\Context\Template $context, \Magento\Framework\Registry $registry, \Magento\Framework\Data\FormFactory $formFactory, @@ -28,7 +26,6 @@ public function __construct( ) { $this->amazonFactory = $amazonFactory; - $this->elementFactory = $elementFactory; parent::__construct($context, $registry, $formFactory, $data); } @@ -74,7 +71,6 @@ protected function _prepareForm() $preparedAttributes = []; - $showWarning = false; if ($formData['general_id_mode'] == \Ess\M2ePro\Model\Amazon\Listing::GENERAL_ID_MODE_CUSTOM_ATTRIBUTE && !$magentoAttributeHelper->isExistInAttributesArray( $formData['general_id_custom_attribute'], $attributesByTypes['text'] @@ -113,38 +109,25 @@ protected function _prepareForm() [ 'name' => 'general_id_mode', 'label' => $this->__('ASIN / ISBN'), - 'class' => 'M2ePro-custom-attribute-can-be-created', 'values' => [ \Ess\M2ePro\Model\Amazon\Listing::GENERAL_ID_MODE_NOT_SET => $this->__('Not Set'), [ 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], 'value' => $formData['general_id_mode'] != Listing::GENERAL_ID_MODE_CUSTOM_ATTRIBUTE ? $formData['general_id_mode'] : '', - 'tooltip' => $this->__( - 'This Setting is the source of value for ASIN/ISBN will be used at the time of - Automatic Search of Amazon Products.'), - 'after_element_html' => !$showWarning ? - '' : << -
    - -
    - Magento Attribute you have chosen earlier is using not for all - Attribute Sets or has type different from acceptable to use for this Option.

    - Please, select another valid Magento Attribute from the list or add selected - Attribute to all Attributes Sets of Magento. -
    -
    - -HTML + 'create_magento_attribute' => true, + 'after_element_html' => $this->getTooltipHtml($this->__( + 'This setting is a source for ASIN/ISBN value which will be used + at the time of Automatic Search of Amazon Products.' + ), true) ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text'); $fieldset->addField( 'worldwide_id_custom_attribute', @@ -157,7 +140,6 @@ protected function _prepareForm() $preparedAttributes = []; - $showWarning = false; if ($formData['worldwide_id_mode'] == \Ess\M2ePro\Model\Amazon\Listing::WORLDWIDE_ID_MODE_CUSTOM_ATTRIBUTE && !$magentoAttributeHelper->isExistInAttributesArray( $formData['worldwide_id_custom_attribute'], $attributesByTypes['text'] @@ -196,38 +178,25 @@ protected function _prepareForm() [ 'name' => 'worldwide_id_mode', 'label' => $this->__('UPC / EAN'), - 'class' => 'M2ePro-custom-attribute-can-be-created', 'values' => [ \Ess\M2ePro\Model\Amazon\Listing::WORLDWIDE_ID_MODE_NOT_SET => $this->__('Not Set'), [ 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], 'value' => $formData['worldwide_id_mode'] != Listing::WORLDWIDE_ID_MODE_CUSTOM_ATTRIBUTE ? $formData['worldwide_id_mode'] : '', - 'tooltip' => $this->__( - 'This Setting is the source of value for UPC/EAN will be used at the time of - Automatic Search of Amazon Products.'), - 'after_element_html' => !$showWarning ? - '' : << -
    - -
    - Magento Attribute you have chosen earlier is used not for all Attribute Sets or has type - different from acceptable to use for this Option.

    - Please, select another valid Magento Attribute from the list or add selected Attribute to - all Attributes Sets of Magento. -
    -
    - -HTML + 'create_magento_attribute' => true, + 'after_element_html' => $this->getTooltipHtml($this->__( + 'This setting is a source for UPC/EAN value which will be used + at the time of Automatic Search of Amazon Products.' + ), true) ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text'); // Additional Settings $fieldset = $form->addFieldset( @@ -244,7 +213,6 @@ protected function _prepareForm() [ 'name' => 'search_by_magento_title_mode', 'label' => $this->__('Search by Product Name'), - 'class' => 'M2ePro-custom-attribute-can-be-created', 'values' => [ \Ess\M2ePro\Model\Amazon\Listing::SEARCH_BY_MAGENTO_TITLE_MODE_NONE => $this->__('Disable'), \Ess\M2ePro\Model\Amazon\Listing::SEARCH_BY_MAGENTO_TITLE_MODE_YES => $this->__('Enable') diff --git a/Block/Adminhtml/Amazon/Listing/Create/Selling.php b/Block/Adminhtml/Amazon/Listing/Create/Selling.php index 965282e1a..29be730e6 100644 --- a/Block/Adminhtml/Amazon/Listing/Create/Selling.php +++ b/Block/Adminhtml/Amazon/Listing/Create/Selling.php @@ -74,7 +74,7 @@ protected function _toHtml() 'On this Page you can specify main Selling Settings for Amazon Items you are going to sell using this M2E Pro Listing.

    - You can provide a settings for SKU formating, appropriate Condition, + You can provide settings for SKU formating, appropriate Condition, Condition Note, Gift Wrap, Gift Message and also specify Additional Settings - Handling Time and Restock Date.

    @@ -83,8 +83,8 @@ protected function _toHtml() of Price, Quantity etc. and Synchronization Policy that describes Rules of Automatic Synchronization of Magento Product and Amazon Item.

    More detailed information you can find - here.', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/XwItAQ') + here.', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/XwItAQ') ) ]); diff --git a/Block/Adminhtml/Amazon/Listing/Create/Selling/Form.php b/Block/Adminhtml/Amazon/Listing/Create/Selling/Form.php index 8b00c4345..8eb06692a 100644 --- a/Block/Adminhtml/Amazon/Listing/Create/Selling/Form.php +++ b/Block/Adminhtml/Amazon/Listing/Create/Selling/Form.php @@ -14,13 +14,11 @@ class Form extends AbstractForm protected $listing; protected $amazonFactory; - protected $elementFactory; //######################################## public function __construct( \Ess\M2ePro\Model\ActiveRecord\Component\Parent\Amazon\Factory $amazonFactory, - \Magento\Framework\Data\Form\Element\Factory $elementFactory, \Ess\M2ePro\Block\Adminhtml\Magento\Context\Template $context, \Magento\Framework\Registry $registry, \Magento\Framework\Data\FormFactory $formFactory, @@ -28,7 +26,6 @@ public function __construct( ) { $this->amazonFactory = $amazonFactory; - $this->elementFactory = $elementFactory; parent::__construct($context, $registry, $formFactory, $data); } @@ -112,7 +109,6 @@ protected function _prepareForm() [ 'name' => 'sku_mode', 'label' => $this->__('Source'), - 'class' => 'M2ePro-custom-attribute-can-be-created', 'values' => [ \Ess\M2ePro\Model\Amazon\Listing::SKU_MODE_PRODUCT_ID => $this->__('Product ID'), \Ess\M2ePro\Model\Amazon\Listing::SKU_MODE_DEFAULT => $this->__('Product SKU'), @@ -120,11 +116,12 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], 'value' => $formData['sku_mode'] != Listing::SKU_MODE_CUSTOM_ATTRIBUTE ? $formData['sku_mode'] : '', + 'create_magento_attribute' => true, 'tooltip' => $this->__( 'Is used to identify Amazon Items, which you list, in Amazon Seller Central Inventory.
    @@ -132,11 +129,11 @@ protected function _prepareForm() Note: If you list a Magento Product and M2E Pro find an Amazon Item with the same Merchant SKU in Amazon Inventory, they will be Mapped.') ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text'); $fieldset->addField( 'sku_modification_mode', - 'select', + self::SELECT, [ 'label' => $this->__('Modification'), 'name' => 'sku_modification_mode', @@ -176,7 +173,7 @@ protected function _prepareForm() $fieldset->addField( 'generate_sku_mode', - 'select', + self::SELECT, [ 'label' => $this->__('Generate'), 'name' => 'generate_sku_mode', @@ -225,7 +222,7 @@ protected function _prepareForm() $editPolicyTooltip = $this->getTooltipHtml($this->__( 'You can edit the saved Policy any time you need. However, the changes you make will automatically - affect all of the Products which are listed using this Policy..' + affect all of the Products which are listed using this Policy.' )); $style = count($sellingFormatTemplates) === 0 ? '' : 'display: none'; @@ -237,26 +234,35 @@ protected function _prepareForm() 'style' => 'line-height: 34px; display: initial;', 'required' => true, 'text' => <<{$this->__('No Policies available.')} + + {$this->__('No Policies available.')} + {$templateSellingFormat->toHtml()} HTML , 'after_element_html' => << + {$this->__('View')} / {$this->__('Edit')} -
    +
    {$editPolicyTooltip}
    {$this->__('or')} {$this->__('Add New')} HTML @@ -291,26 +297,39 @@ protected function _prepareForm() 'field_extra_attributes' => 'style="margin-bottom: 5px"', 'required' => true, 'text' => <<{$this->__('No Policies available.')} + + {$this->__('No Policies available.')} + {$templateSynchronization->toHtml()} HTML , 'after_element_html' => << + {$this->__('View')} / {$this->__('Edit')} -
    +
    {$editPolicyTooltip}
    {$this->__('or')} {$this->__('Add New')} HTML @@ -366,7 +385,6 @@ protected function _prepareForm() [ 'name' => 'condition_mode', 'label' => $this->__('Condition'), - 'class' => 'M2ePro-custom-attribute-can-be-created', 'values' => [ [ 'label' => $this->__('Recommended Value'), @@ -376,10 +394,11 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], + 'create_magento_attribute' => true, 'tooltip' => $this->__( <<The Condition settings will be used not only to create new Amazon Products, but @@ -399,11 +418,11 @@ protected function _prepareForm() HTML ) ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text,select'); $fieldset->addField( 'condition_note_mode', - 'select', + self::SELECT, [ 'container_id' => 'condition_note_mode_tr', 'label' => $this->__('Condition Note'), @@ -436,7 +455,11 @@ protected function _prepareForm() 'destination_id' => 'condition_note_value', 'magento_attributes' => $preparedAttributes, 'class' => 'primary', - 'style' => 'display: block; margin: 0; float: right;' + 'style' => 'display: block; margin: 0; float: right;', + 'select_custom_attributes' => [ + 'allowed_attribute_types' => 'text,textarea', + 'apply_to_all_attribute_sets' => 0 + ], ])->toHtml(), 'value' => $this->getHelper('Data')->escapeHtml($this->getData('condition_note_value')) ] @@ -465,7 +488,7 @@ protected function _prepareForm() $attrs = ['attribute_code' => $attribute['code']]; if ( $formData['image_main_mode'] == \Ess\M2ePro\Model\Amazon\Listing::IMAGE_MAIN_MODE_ATTRIBUTE - && $attribute['code'] == $formData['sku_custom_attribute'] + && $attribute['code'] == $formData['image_main_attribute'] ) { $attrs['selected'] = 'selected'; } @@ -482,7 +505,6 @@ protected function _prepareForm() [ 'name' => 'image_main_mode', 'label' => $this->__('Main Image'), - 'class' => 'M2ePro-custom-attribute-can-be-created', 'required' => true, 'values' => [ \Ess\M2ePro\Model\Amazon\Listing::IMAGE_MAIN_MODE_NONE => $this->__('None'), @@ -491,18 +513,19 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], 'value' => $formData['image_main_mode'] != Listing::IMAGE_MAIN_MODE_ATTRIBUTE ? $formData['image_main_mode'] : '', + 'create_magento_attribute' => true, 'tooltip' => $this->__( 'You have an ability to add Photos for your Items to be displayed on the More Buying Choices Page.
    It is available only for Items with Used or Collectible Condition.' ) ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text,textarea,select,multiselect'); $fieldset->addField( 'gallery_images_limit', @@ -566,7 +589,6 @@ protected function _prepareForm() 'container_id' => 'gallery_images_mode_tr', 'name' => 'gallery_images_mode', 'label' => $this->__('Additional Images'), - 'class' => 'M2ePro-custom-attribute-can-be-created', 'values' => [ \Ess\M2ePro\Model\Amazon\Listing::GALLERY_IMAGES_MODE_NONE => $this->__('None'), [ @@ -577,10 +599,11 @@ protected function _prepareForm() 'label' => $this->__('Magento Attribute'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] - ] + ], + 'create_magento_attribute' => true, ]; if ($formData['gallery_images_mode'] == \Ess\M2ePro\Model\Amazon\Listing::GALLERY_IMAGES_MODE_NONE) { @@ -591,7 +614,7 @@ protected function _prepareForm() 'gallery_images_mode', self::SELECT, $fieldConfig - ); + )->addCustomAttribute('allowed_attribute_types', 'text,textarea,select,multiselect'); // Gift Wrap $fieldset = $form->addFieldset( @@ -633,7 +656,6 @@ protected function _prepareForm() [ 'name' => 'gift_wrap_mode', 'label' => $this->__('Gift Wrap'), - 'class' => 'M2ePro-custom-attribute-can-be-created', 'values' => [ \Ess\M2ePro\Model\Amazon\Listing::GIFT_WRAP_MODE_NO => $this->__('No'), \Ess\M2ePro\Model\Amazon\Listing::GIFT_WRAP_MODE_YES => $this->__('Yes'), @@ -641,18 +663,20 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true, + 'new_option_value' => \Ess\M2ePro\Model\Amazon\Listing::GIFT_WRAP_MODE_ATTRIBUTE ] ] ], 'value' => $formData['gift_wrap_mode'] != Listing::GIFT_WRAP_MODE_ATTRIBUTE ? $formData['gift_wrap_mode'] : '', + 'create_magento_attribute' => true, 'tooltip' => $this->__( 'Enable this Option in case you want Gift Wrapped Option be applied to the Products you are going to sell.' ) ] - ); + )->addCustomAttribute('allowed_attribute_types', 'boolean'); $fieldset->addField( 'gift_message_attribute', @@ -685,7 +709,6 @@ protected function _prepareForm() [ 'name' => 'gift_message_mode', 'label' => $this->__('Gift Message'), - 'class' => 'M2ePro-custom-attribute-can-be-created', 'values' => [ \Ess\M2ePro\Model\Amazon\Listing::GIFT_MESSAGE_MODE_NO => $this->__('No'), \Ess\M2ePro\Model\Amazon\Listing::GIFT_MESSAGE_MODE_YES => $this->__('Yes'), @@ -693,18 +716,20 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true, + 'new_option_value' => \Ess\M2ePro\Model\Amazon\Listing::GIFT_MESSAGE_MODE_ATTRIBUTE ] ] ], 'value' => $formData['gift_message_mode'] != Listing::GIFT_MESSAGE_MODE_ATTRIBUTE ? $formData['gift_message_mode'] : '', + 'create_magento_attribute' => true, 'tooltip' => $this->__( 'Enable this Option in case you want Gift Message Option be applied to the Products you are going to sell.' ) ] - ); + )->addCustomAttribute('allowed_attribute_types', 'boolean'); // Gift Wrap $fieldset = $form->addFieldset( @@ -767,7 +792,6 @@ protected function _prepareForm() $fieldConfig = [ 'name' => 'handling_time_mode', 'label' => $this->__('Handling Time'), - 'class' => 'M2ePro-custom-attribute-can-be-created', 'values' => [ \Ess\M2ePro\Model\Amazon\Listing::HANDLING_TIME_MODE_NONE => $this->__('None'), [ @@ -778,10 +802,11 @@ protected function _prepareForm() 'label' => $this->__('Magento Attribute'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], + 'create_magento_attribute' => true, 'tooltip' => $this->__('Time that is needed to prepare an Item to be shipped.') ]; @@ -793,7 +818,7 @@ protected function _prepareForm() 'handling_time_mode', self::SELECT, $fieldConfig - ); + )->addCustomAttribute('allowed_attribute_types', 'text,select'); $fieldset->addField( 'restock_date_custom_attribute', @@ -808,14 +833,14 @@ protected function _prepareForm() foreach ($attributesByTypes['text_date'] as $attribute) { $attrs = ['attribute_code' => $attribute['code']]; if ( - $formData['restock_date_mode'] == \Ess\M2ePro\Model\Amazon\Listing::GIFT_MESSAGE_MODE_ATTRIBUTE + $formData['restock_date_mode'] == \Ess\M2ePro\Model\Amazon\Listing::RESTOCK_DATE_MODE_CUSTOM_ATTRIBUTE && $attribute['code'] == $formData['restock_date_custom_attribute'] ) { $attrs['selected'] = 'selected'; } $preparedAttributes[] = [ 'attrs' => $attrs, - 'value' => \Ess\M2ePro\Model\Amazon\Listing::GIFT_MESSAGE_MODE_ATTRIBUTE, + 'value' => \Ess\M2ePro\Model\Amazon\Listing::RESTOCK_DATE_MODE_CUSTOM_ATTRIBUTE, 'label' => $attribute['label'], ]; } @@ -826,7 +851,6 @@ protected function _prepareForm() [ 'name' => 'restock_date_mode', 'label' => $this->__('Restock Date'), - 'class' => 'M2ePro-custom-attribute-can-be-created', 'values' => [ \Ess\M2ePro\Model\Amazon\Listing::RESTOCK_DATE_MODE_NONE => $this->__('None'), \Ess\M2ePro\Model\Amazon\Listing::RESTOCK_DATE_MODE_CUSTOM_VALUE => $this->__('Custom Value'), @@ -834,17 +858,18 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], - 'value' => $formData['restock_date_mode'] != Listing::GIFT_MESSAGE_MODE_ATTRIBUTE + 'create_magento_attribute' => true, + 'value' => $formData['restock_date_mode'] != Listing::RESTOCK_DATE_MODE_CUSTOM_ATTRIBUTE ? $formData['restock_date_mode'] : '', 'tooltip' => $this->__( 'The date you will be able to ship any back-ordered Items to a Customer.' ) ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text,date'); $fieldset->addField( 'restock_date_value', diff --git a/Block/Adminhtml/Amazon/Listing/Edit.php b/Block/Adminhtml/Amazon/Listing/Edit.php index b80fd7fd7..dfdba22fa 100644 --- a/Block/Adminhtml/Amazon/Listing/Edit.php +++ b/Block/Adminhtml/Amazon/Listing/Edit.php @@ -82,7 +82,7 @@ public function _construct() 'label' => $this->__('Save And Continue Edit'), 'class' => 'add', 'button_class' => '', - 'onclick' => 'AmazonListingSettingsObj.saveAndEitClick(\''.$url.'\', 1)', + 'onclick' => 'AmazonListingSettingsObj.saveAndEditClick(\''.$url.'\', 1)', 'class_name' => 'Ess\M2ePro\Block\Adminhtml\Magento\Button\SplitButton', 'options' => $saveButtonsProps ]; diff --git a/Block/Adminhtml/Amazon/Listing/Grid.php b/Block/Adminhtml/Amazon/Listing/Grid.php index 82bf71c2c..7d07f6ecf 100644 --- a/Block/Adminhtml/Amazon/Listing/Grid.php +++ b/Block/Adminhtml/Amazon/Listing/Grid.php @@ -11,20 +11,17 @@ class Grid extends \Ess\M2ePro\Block\Adminhtml\Listing\Grid { protected $amazonFactory; - protected $storeManager; //######################################## public function __construct( \Ess\M2ePro\Model\ActiveRecord\Component\Parent\Amazon\Factory $amazonFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, \Ess\M2ePro\Block\Adminhtml\Magento\Context\Template $context, \Magento\Backend\Helper\Data $backendHelper, array $data = [] ) { $this->amazonFactory = $amazonFactory; - $this->storeManager = $storeManager; parent::__construct($context, $backendHelper, $data); } @@ -235,12 +232,10 @@ public function callbackColumnTitle($value, $row, $column, $isExport) $accountTitle = $row->getData('account_title'); $marketplaceTitle = $row->getData('marketplace_title'); - // TODO - //$storeModel = $this->storeManager->getStore($row->getStoreId()); - $storeModel = $this->storeManager->getStore(); - $storeView = $storeModel->getWebsite()->getName(); + $storeModel = $this->_storeManager->getStore($row->getStoreId()); + $storeView = $this->_storeManager->getWebsite($storeModel->getWebsiteId())->getName(); if (strtolower($storeView) != 'admin') { - $storeView .= ' > '.$storeModel->getGroup()->getName(); + $storeView .= ' > '.$this->_storeManager->getGroup($storeModel->getStoreGroupId())->getName(); $storeView .= ' > '.$storeModel->getName(); } else { $storeView = $this->__('Admin (Default Values)'); diff --git a/Block/Adminhtml/Amazon/Listing/Log/Grid.php b/Block/Adminhtml/Amazon/Listing/Log/Grid.php index 4d1f231a2..b1534b50c 100644 --- a/Block/Adminhtml/Amazon/Listing/Log/Grid.php +++ b/Block/Adminhtml/Amazon/Listing/Log/Grid.php @@ -44,7 +44,7 @@ public function callbackColumnListingTitleID($value, $row, $column, $isExport) if ($row->getData('listing_id')) { $url = $this->getUrl( - '*/adminhtml_amazon_listing/view', + '*/amazon_listing/view', array('id' => $row->getData('listing_id')) ); diff --git a/Block/Adminhtml/Amazon/Listing/Other/View.php b/Block/Adminhtml/Amazon/Listing/Other/View.php index b8b48ed7c..5dd1d89bb 100644 --- a/Block/Adminhtml/Amazon/Listing/Other/View.php +++ b/Block/Adminhtml/Amazon/Listing/Other/View.php @@ -115,7 +115,7 @@ protected function _toHtml() 'prepareData' => $this->getUrl('*/listing_other_moving/prepareMoveToListing'), 'createDefaultListing' => $this->getUrl('*/listing_other_moving/createDefaultListing'), 'moveToListingGridHtml' => $this->getUrl('*/listing_other_moving/moveToListingGrid'), - 'getFailedProductsGridHtml' => $this->getUrl('*/listing_other_moving/getFailedProductsGrid'), + 'getFailedProductsHtml' => $this->getUrl('*/listing_other_moving/getFailedProducts'), 'tryToMoveToListing' => $this->getUrl('*/listing_other_moving/tryToMoveToListing'), 'moveToListing' => $this->getUrl('*/listing_other_moving/moveToListing'), @@ -127,6 +127,8 @@ protected function _toHtml() 'amazon_listing/getAFNQtyBySku' => $this->getUrl('*/amazon_listing/getAFNQtyBySku') ]); + $this->jsUrl->add($this->getUrl('*/amazon_listing_product_repricing/getUpdatedPriceBySkus')); + $someProductsWereNotMappedMessage = 'No matches were found. Please change the Mapping Attributes in '; $someProductsWereNotMappedMessage .= 'Configuration > Account > 3rd Party Listings '; $someProductsWereNotMappedMessage .= 'or try to map manually.'; @@ -153,6 +155,7 @@ protected function _toHtml() 'Item was not Mapped as the chosen %product_id% Simple Product has Custom Options.' => $this->__( 'Item was not Mapped as the chosen %product_id% Simple Product has Custom Options.' ), + 'Add New Listing' => $this->__('Add New Listing'), 'create_listing' => $createListing, 'popup_title' => $this->__('Moving Amazon Items'), @@ -205,8 +208,9 @@ protected function _toHtml() 'lor' => 'M2ePro/Listing/Other/Removing', 'lou' => 'M2ePro/Listing/Other/Unmapping', - 'elog' => 'M2ePro/Amazon/Listing/Other/Grid', - 'eloa' => 'M2ePro/Amazon/Listing/AfnQty' + 'alog' => 'M2ePro/Amazon/Listing/Other/Grid', + 'aloa' => 'M2ePro/Amazon/Listing/AfnQty', + 'alprp' => 'M2ePro/Amazon/Listing/Product/Repricing/Price' ], << array($this, 'callbackFilterPrice') ); -// if (Mage::helper('M2ePro/Component_Amazon')->isRepricingEnabled()) { -// $priceColumn['filter'] = 'M2ePro/adminhtml_common_amazon_grid_column_filter_price'; -// } + $account = $this->amazonFactory->getObjectLoaded('Account', $this->getRequest()->getParam('account')); + + if ($this->getHelper('Component\Amazon\Repricing')->isEnabled() && + $account->getChildObject()->isRepricing()) { + $priceColumn['filter'] = 'Ess\M2ePro\Block\Adminhtml\Amazon\Grid\Column\Filter\Price'; + } $this->addColumn('online_price', $priceColumn); @@ -158,15 +161,6 @@ protected function _prepareColumns() 'frame_callback' => array($this, 'callbackColumnStatus') )); - $backUrl = $this->getHelper('Data')->makeBackUrlParam( - '*/amazon_listing_other/view', - array( - 'account' => $this->getRequest()->getParam('account'), - 'marketplace' => $this->getRequest()->getParam('marketplace'), - 'back' => $this->getRequest()->getParam('back', null) - ) - ); - return parent::_prepareColumns(); } @@ -305,9 +299,7 @@ public function callbackColumnAvailableQty($value, $row, $column, $isExport)
    {$inStock}:
    - {$afn} - + onclick="AmazonListingAfnQtyObj.showAfnQty(this,'{$sku}',{$productId}, {$accountId})">{$afn}
    HTML; } @@ -328,39 +320,31 @@ public function callbackColumnPrice($value, $row, $column, $isExport) $html =''; $value = $row->getChildObject()->getData('online_price'); - /* - if ($this->getHelper('Component_Amazon')->isRepricingEnabled() && - (int)$row->getData('is_repricing') === Ess_M2ePro_Model_Amazon_Listing_Other::IS_REPRICING_YES) { - $image = 'money'; + if ($this->getHelper('Component\Amazon\Repricing')->isEnabled() && + (int)$row->getChildObject()->getData('is_repricing') == 1) { + + $icon = 'repricing-enabled'; $text = $this->__( 'This product is used by Amazon Repricing Tool. The Price cannot be updated through the M2E Pro.' ); - $isRepricingDisabled = Ess_M2ePro_Model_Amazon_Listing_Other::IS_REPRICING_DISABLED_YES; - - if ((int)$row->getData('is_repricing_disabled') === $isRepricingDisabled) { - $image = 'money_disabled'; + if ((int)$row->getChildObject()->getData('is_repricing_disabled') == 1) { + $icon = 'repricing-disabled'; $text = $this->__( - 'This product is disabled for Amazon Repricing Tool. - The Price cannot be updated through the M2E Pro. TODO TEXT' + 'This product is disabled on Amazon Repricing Tool. + The Price is updated through the M2E Pro.' ); } $html = <<  - - -
    + {$this->getTooltipHtml($text)} +
    HTML; } - */ + if (is_null($value) || $value === '') { return $this->__('N/A') . $html; @@ -375,6 +359,26 @@ public function callbackColumnPrice($value, $row, $column, $isExport) ->getChildObject() ->getDefaultCurrency(); + $priceValue = $this->localeCurrency->getCurrency($currency)->toCurrency($value) . $html; + + if ($row->getData('is_repricing') && + !$row->getData('is_repricing_disabled') + ) { + $accountId = $row->getData('account_id'); + $sku = $row->getData('sku'); + + $priceValue =<<{$priceValue} +HTML; + + return $priceValue.$html; + } + return $this->localeCurrency->getCurrency($currency)->toCurrency($value) . $html; } @@ -461,12 +465,12 @@ protected function callbackFilterPrice($collection, $column) $where .= 'online_price <= ' . $value['to']; } -// if ($this->getHelper('M2ePro/Component_Amazon')->isRepricingEnabled() && !empty($value['is_repricing'])) { -// if (!empty($where)) { -// $where = '(' . $where . ') OR '; -// } -// $where .= 'is_repricing = ' . Ess_M2ePro_Model_Amazon_Listing_Other::IS_REPRICING_YES; -// } + if ($this->getHelper('Component\Amazon\Repricing')->isEnabled() && !empty($value['is_repricing'])) { + if (!empty($where)) { + $where = '(' . $where . ') OR '; + } + $where .= 'is_repricing = ' . 1; + } $collection->getSelect()->where($where); } @@ -533,15 +537,15 @@ public function getViewLogIconHtml($listingOtherId) } $tips = array( - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS => 'Last Action was completed successfully.', - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR => 'Last Action was completed with error(s).', - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING => 'Last Action was completed with warning(s).' + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_SUCCESS => 'Last Action was completed successfully.', + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR => 'Last Action was completed with error(s).', + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_WARNING => 'Last Action was completed with warning(s).' ); $icons = array( - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS => 'normal', - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR => 'error', - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING => 'warning' + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_SUCCESS => 'normal', + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR => 'error', + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_WARNING => 'warning' ); $summary = $this->createBlock('Log\Grid\Summary', '', [ @@ -592,15 +596,15 @@ public function getInitiatorForAction($actionRows) public function getMainTypeForActionId($actionRows) { - $type = \Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS; + $type = \Ess\M2ePro\Model\Log\AbstractModel::TYPE_SUCCESS; foreach ($actionRows as $row) { - if ($row['type'] == \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR) { - $type = \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR; + if ($row['type'] == \Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR) { + $type = \Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR; break; } - if ($row['type'] == \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING) { - $type = \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING; + if ($row['type'] == \Ess\M2ePro\Model\Log\AbstractModel::TYPE_WARNING) { + $type = \Ess\M2ePro\Model\Log\AbstractModel::TYPE_WARNING; } } diff --git a/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin.php b/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin.php index fa7649886..6e35d1dbe 100644 --- a/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin.php +++ b/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin.php @@ -66,8 +66,8 @@ protected function _prepareLayout()

    More detailed information about creation of New Amazon Products and Description Policies you can find in the following article article - here.

    ', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/LQgtAQ') + here.

    ', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/LQgtAQ') ), ]); diff --git a/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin/Category.php b/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin/Category.php index 0932f7750..00cfda34e 100644 --- a/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin/Category.php +++ b/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin/Category.php @@ -83,9 +83,9 @@ protected function _toHtml() $this->getHelper('Data')->getControllerActions('Amazon\Listing\Product\Template\Description') ); - $this->jsUrl->add($this->getUrl('*/amazon_listing_product_template_description/viewTemplateDescriptionsGrid', [ + $this->jsUrl->add($this->getUrl('*/amazon_listing_product_template_description/viewGrid', [ 'map_to_template_js_fn' => 'selectTemplateDescription' - ]), 'amazon_listing_product_template_description/viewTemplateDescriptionsGrid'); + ]), 'amazon_listing_product_template_description/viewGrid'); $this->jsUrl->add( $this->getUrl('*/amazon_listing_product_add/checkNewAsinCategoryProducts', ['_current' => true]), diff --git a/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin/Category/Grid.php b/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin/Category/Grid.php index 9e13cd41d..9d2298e6c 100644 --- a/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin/Category/Grid.php +++ b/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin/Category/Grid.php @@ -283,6 +283,8 @@ protected function _toHtml() ); } + $this->css->add('.grid-listing-column-actions { width:100px; }'); + return parent::_toHtml(); } diff --git a/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin/Form.php b/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin/Form.php index a58547905..09be3f5a8 100644 --- a/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin/Form.php +++ b/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin/Form.php @@ -91,9 +91,9 @@ protected function _prepareForm() - + HTML ] ); @@ -213,32 +213,18 @@ protected function _toHtml() loadTemplateDescriptionGrid = function() { new Ajax.Request( - '{$this->getUrl('*/amazon_listing_product_template_description/viewTemplateDescriptionsGrid' + '{$this->getUrl('*/amazon_listing_product_template_description/viewGrid' )}', { method: 'post', parameters: { products_ids : filteredProductsIds, check_is_new_asin_accepted : 1, - map_to_template_js_fn : 'selectTemplateDescription' + map_to_template_js_fn : 'selectTemplateDescription', + create_new_template_js_fn : 'createTemplateDescriptionInNewTab' }, onSuccess: function (transport) { $('template_description_grid').update(transport.responseText); $('template_description_grid').show(); - - var newLink = $('template_description_addNew_link'), - refreshBtn = $('description_template_refresh_btn'); - - if (newLink) { - $('template_description_addNew_link').onclick = function () { - createTemplateDescriptionInNewTab(M2ePro.url.get('newTemplateDescriptionUrl')) - }; - } - - if (refreshBtn) { - $('description_template_refresh_btn').onclick = function () { - loadTemplateDescriptionGrid(); - }; - } } }) }; diff --git a/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin/Manual.php b/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin/Manual.php index 72332d512..452783fde 100644 --- a/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin/Manual.php +++ b/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin/Manual.php @@ -83,9 +83,9 @@ protected function _toHtml() $this->getHelper('Data')->getControllerActions('Amazon\Listing\Product\Template\Description') ); - $this->jsUrl->add($this->getUrl('*/amazon_listing_product_template_description/viewTemplateDescriptionsGrid', [ + $this->jsUrl->add($this->getUrl('*/amazon_listing_product_template_description/viewGrid', [ 'map_to_template_js_fn' => 'selectTemplateDescription' - ]), 'amazon_listing_product_template_description/viewTemplateDescriptionsGrid'); + ]), 'amazon_listing_product_template_description/viewGrid'); $this->jsUrl->add( $this->getUrl('*/amazon_listing_product_add/checkNewAsinManualProducts', ['_current' => true]), diff --git a/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin/Manual/Grid.php b/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin/Manual/Grid.php index c9092a677..afef3673a 100644 --- a/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin/Manual/Grid.php +++ b/Block/Adminhtml/Amazon/Listing/Product/Add/NewAsin/Manual/Grid.php @@ -51,6 +51,8 @@ public function _construct() $this->setDefaultDir('DESC'); $this->setUseAjax(true); // --------------------------------------- + + $this->useAdvancedFilter = false; } //######################################## diff --git a/Block/Adminhtml/Amazon/Listing/Product/Add/SearchAsin.php b/Block/Adminhtml/Amazon/Listing/Product/Add/SearchAsin.php index d97455cc7..b2a118767 100644 --- a/Block/Adminhtml/Amazon/Listing/Product/Add/SearchAsin.php +++ b/Block/Adminhtml/Amazon/Listing/Product/Add/SearchAsin.php @@ -91,10 +91,10 @@ protected function _prepareLayout()

    Note: The process of Automatic Search might be time-consuming, depending on the number of added Products the Search is applied to.


    More detailed information about how to work with this Page you can find - here.

    + here.

    HTML , - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/mAYtAQ') + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/mAYtAQ') ) ]); diff --git a/Block/Adminhtml/Amazon/Listing/Product/Add/SearchAsin/Grid.php b/Block/Adminhtml/Amazon/Listing/Product/Add/SearchAsin/Grid.php index 253cb4bb4..91f7382db 100644 --- a/Block/Adminhtml/Amazon/Listing/Product/Add/SearchAsin/Grid.php +++ b/Block/Adminhtml/Amazon/Listing/Product/Add/SearchAsin/Grid.php @@ -509,7 +509,7 @@ private function getGeneralIdColumnValueNotEmptyGeneralId($row) $generalIdSearchInfo = $row->getData('general_id_search_info'); if (!empty($generalIdSearchInfo)) { - $generalIdSearchInfo = @json_decode($generalIdSearchInfo, true); + $generalIdSearchInfo = json_decode($generalIdSearchInfo, true); } if (!empty($generalIdSearchInfo['is_set_automatic'])) { @@ -639,6 +639,9 @@ protected function _toHtml() ); ListingGridHandlerObj.actionHandler.setOptions(M2ePro); + ListingGridHandlerObj.actionHandler.setProgressBar('search_asin_progress_bar'); + ListingGridHandlerObj.actionHandler.setGridWrapper('search_asin_content_container'); + ListingGridHandlerObj.productSearchHandler.setOptions(M2ePro); ListingGridHandlerObj.afterInitPage(); @@ -676,14 +679,21 @@ protected function _toHtml() $this->js->add( <<' . + '
    ' . + parent::_toHtml() . + '
    '; } //######################################## diff --git a/Block/Adminhtml/Amazon/Listing/Product/Add/SearchAsin/NewAsinPopup.php b/Block/Adminhtml/Amazon/Listing/Product/Add/SearchAsin/NewAsinPopup.php index 91cc1e0c8..83302eef3 100644 --- a/Block/Adminhtml/Amazon/Listing/Product/Add/SearchAsin/NewAsinPopup.php +++ b/Block/Adminhtml/Amazon/Listing/Product/Add/SearchAsin/NewAsinPopup.php @@ -10,20 +10,6 @@ class NewAsinPopup extends \Ess\M2ePro\Block\Adminhtml\Magento\AbstractBlock { - protected $elementFactory; - - //######################################## - - public function __construct( - \Magento\Framework\Data\Form\Element\Factory $elementFactory, - \Ess\M2ePro\Block\Adminhtml\Magento\Context\Template $context, - array $data = [] - ) - { - $this->elementFactory = $elementFactory; - parent::__construct($context, $data); - } - //######################################## public function _construct() @@ -72,8 +58,8 @@ protected function _prepareLayout() public function getTitleHelpTipsHtml() { $helpLinkBlock = $this->createBlock('PageHelpLink')->setData([ - 'page_help_link' => $this->getHelper('Module\Support')->getDocumentationUrl( - NULL, 'pages/viewpage.action?pageId=19728203' + 'page_help_link' => $this->getHelper('Module\Support')->getDocumentationArticleUrl( + '/x/NQctAQ' ) ]); diff --git a/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Category.php b/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Category.php index 576651fef..db64f4dca 100644 --- a/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Category.php +++ b/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Category.php @@ -35,11 +35,12 @@ public function _construct() // --------------------------------------- if (is_null($this->getRequest()->getParam('back'))) { $url = $this->getUrl('*/amazon_listing_product_add/index', array( - 'id' => $this->getRequest()->getParam('id') + 'id' => $this->getRequest()->getParam('id'), + 'wizard' => $this->getRequest()->getParam('wizard') )); } else { $url = $this->getHelper('Data')->getBackUrl( - '*/adminhtml_amazon_listing/index' + '*/amazon_listing/index' ); } $this->addButton('back', array( @@ -112,8 +113,19 @@ public function getGridHtml() }); JS ); + + $hideOthersListingsProductsFilterBlock = $this->createBlock( + 'Listing\Product\ShowOthersListingsProductsFilter' + )->setData([ + 'component_mode' => \Ess\M2ePro\Helper\Component\Amazon::NICK, + 'controller' => 'amazon_listing_product_add' + ]); - return $viewHeaderBlock->toHtml() . parent::getGridHtml(); + return $viewHeaderBlock->toHtml() + . '
    ' + . $hideOthersListingsProductsFilterBlock->toHtml() + . '
    ' + . parent::getGridHtml(); } protected function _toHtml() diff --git a/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Category/Grid.php b/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Category/Grid.php index aa28f7436..b46fc2907 100644 --- a/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Category/Grid.php +++ b/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Category/Grid.php @@ -62,6 +62,28 @@ protected function _prepareMassaction() $this->getRequest()->setPostValue($this->getMassactionBlock()->getFormFieldNameInternal(), implode(',',$ids)); + $this->css->add(<<getId()} > .admin__data-grid-header > .admin__data-grid-header-row:first-child { + width: 100% !important; + margin-top: 1.1em; + } + #{$this->getId()} > .admin__data-grid-header > .admin__data-grid-header-row:last-child { + width: 100% !important; + } + + #{$this->getId()} > .admin__data-grid-header > + .admin__data-grid-header-row:last-child .admin__control-support-text { + margin-left: 0; + } + + #{$this->getId()} > .admin__data-grid-header > + .admin__data-grid-header-row:last-child .mass-select-wrap { + margin-left: -1.3em !important; + } +CSS + ); + return parent::_prepareMassaction(); } diff --git a/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Category/Tree.php b/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Category/Tree.php index 8a29dcfaf..5c9623868 100644 --- a/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Category/Tree.php +++ b/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Category/Tree.php @@ -220,8 +220,8 @@ public function buildNodeName($node) $collection = $this->resourceConnection->getConnection(); - $ccpTable = $collection->getTableName('catalog_category_product'); - $cpeTable = $collection->getTableName('catalog_product_entity'); + $ccpTable = $this->resourceConnection->getTableName('catalog_category_product'); + $cpeTable = $this->resourceConnection->getTableName('catalog_product_entity'); $dbSelect = $collection->select() ->from(array('ccp' => $ccpTable),new \Zend_Db_Expr('DISTINCT `ccp`.`product_id`')) @@ -276,7 +276,7 @@ public function getAffectedCategoriesCount() $collection = $this->_categoryFactory->create()->getCollection(); $dbSelect = $collection->getConnection()->select() - ->from($collection->getConnection()->getTableName('catalog_category_product'), 'category_id') + ->from($this->resourceConnection->getTableName('catalog_category_product'), 'category_id') ->where('`product_id` IN(?)',$this->getSelectedIds()); $affectedCategoriesCount = $collection->getSelectCountSql() @@ -304,8 +304,8 @@ public function getProductsForEachCategory() $collection = $this->_categoryFactory->create()->getCollection(); $select = $collection->getSelect(); $select->joinLeft( - $collection->getConnection()->getTableName('catalog_category_product'), - "entity_id = category_id AND product_id IN ({$ids})", + ['ccp' => $this->resourceConnection->getTableName('catalog_category_product')], + "e.entity_id = ccp.category_id AND ccp.product_id IN ({$ids})", array('product_id') ); @@ -369,7 +369,7 @@ protected function loadProductsCount($collection) $select = $collection->getConnection()->select(); $select->from( - array('main_table' => $collection->getTable('catalog_category_product')), + array('main_table' => $this->resourceConnection->getTableName('catalog_category_product')), array('category_id', new \Zend_Db_Expr('COUNT(main_table.product_id)')) ) ->where($collection->getConnection()->quoteInto('main_table.category_id IN(?)', array_keys($items))) diff --git a/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Form.php b/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Form.php index bc6026a79..b83bae715 100644 --- a/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Form.php +++ b/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Form.php @@ -31,8 +31,8 @@ protected function _prepareForm()

    There are several different options of how Magento products can be found/selected and added to the Listing


    More detailed information you can find - here.

    ', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/jgYtAQ') + here.

    ', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/jgYtAQ') ) ] ); diff --git a/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Product.php b/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Product.php index 12216763d..af53dea29 100644 --- a/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Product.php +++ b/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Product.php @@ -35,11 +35,12 @@ public function _construct() // --------------------------------------- if (is_null($this->getRequest()->getParam('back'))) { $url = $this->getUrl('*/amazon_listing_product_add/index', array( - 'id' => $this->getRequest()->getParam('id') + 'id' => $this->getRequest()->getParam('id'), + 'wizard' => $this->getRequest()->getParam('wizard') )); } else { $url = $this->getHelper('Data')->getBackUrl( - '*/adminhtml_amazon_listing/index' + '*/amazon_listing/index' ); } $this->addButton('back', array( @@ -111,7 +112,18 @@ public function getGridHtml() JS ); - return $viewHeaderBlock->toHtml() . parent::getGridHtml(); + $hideOthersListingsProductsFilterBlock = $this->createBlock( + 'Listing\Product\ShowOthersListingsProductsFilter' + )->setData([ + 'component_mode' => \Ess\M2ePro\Helper\Component\Amazon::NICK, + 'controller' => 'amazon_listing_product_add' + ]); + + return $viewHeaderBlock->toHtml() + . '
    ' + . $hideOthersListingsProductsFilterBlock->toHtml() + . '
    ' + . parent::getGridHtml(); } protected function _toHtml() diff --git a/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Product/Grid.php b/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Product/Grid.php index d2dc8e7f1..2a104cb1b 100644 --- a/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Product/Grid.php +++ b/Block/Adminhtml/Amazon/Listing/Product/Add/SourceMode/Product/Grid.php @@ -63,6 +63,7 @@ public function _construct() // --------------------------------------- $this->hideMassactionDropDown = true; + $this->showAdvancedFilterProductsOption = false; } //######################################## @@ -134,8 +135,10 @@ protected function _prepareCollection() // Hide products others listings // --------------------------------------- - $prefix = $this->getHelper('Data\GlobalData')->getValue('hide_products_others_listings_prefix'); - is_null($hideParam = $this->getHelper('Data\Session')->getValue($prefix)) && $hideParam = true; + $hideParam = true; + if ($this->getRequest()->has('show_products_others_listings')) { + $hideParam = false; + } if ($hideParam || isset($this->listing['id'])) { @@ -351,6 +354,7 @@ protected function _getStore() protected function _toHtml() { if ($this->getRequest()->isXmlHttpRequest()) { + $this->massactionMassSelectStyleFix(); return parent::_toHtml(); } @@ -397,9 +401,30 @@ protected function _toHtml() }); JS ); + + $this->massactionMassSelectStyleFix(); return parent::_toHtml(); } //######################################## + + protected function massactionMassSelectStyleFix() + { + $this->js->add(<<addItem(new \Magento\Framework\DataObject($temp)); } - $collection->setCustomSize(count($data)); + $collection->setCustomSize(count($data['data'])); $this->setCollection($collection); parent::_prepareCollection(); @@ -449,7 +449,7 @@ class="select admin__control-select amazon_product_attribute_{$id}" display: inline-block;">'; $attributeValues = ''; foreach ($variations['set'] as $specificName => $specific) { - $attributesNames .= ''. + $attributesNames .= ''. ucfirst(strtolower($specificName)). '
    '; $attributeValues .= 'here.', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/uYgVAQ') + here.', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/uYgVAQ') ) ]); } else { diff --git a/Block/Adminhtml/Amazon/Listing/Product/Template/Description/Grid.php b/Block/Adminhtml/Amazon/Listing/Product/Template/Description/Grid.php index 6ac3607ab..c0167553e 100644 --- a/Block/Adminhtml/Amazon/Listing/Product/Template/Description/Grid.php +++ b/Block/Adminhtml/Amazon/Listing/Product/Template/Description/Grid.php @@ -22,6 +22,8 @@ class Grid extends \Ess\M2ePro\Block\Adminhtml\Magento\Grid\AbstractGrid protected $checkNewAsinAccepted = false; protected $productsIds; protected $mapToTemplateJsFn = 'ListingGridHandlerObj.templateDescriptionHandler.mapToTemplateDescription'; + protected $createNewTemplateJsFn = + 'ListingGridHandlerObj.templateDescriptionHandler.createTemplateDescriptionInNewTab'; protected $customCollectionFactory; protected $resourceConnection; @@ -61,6 +63,24 @@ public function setMapToTemplateJsFn($mapToTemplateLink) // --------------------------------------- + /** + * @return string + */ + public function getCreateNewTemplateJsFn() + { + return $this->createNewTemplateJsFn; + } + + /** + * @param string $createNewTemplateJsFn + */ + public function setCreateNewTemplateJsFn($createNewTemplateJsFn) + { + $this->createNewTemplateJsFn = $createNewTemplateJsFn; + } + + // --------------------------------------- + /** * @param boolean $checkNewAsinAccepted */ @@ -255,7 +275,10 @@ public function getMainButtonsHtml() public function callbackColumnTitle($value, $row, $column, $isExport) { $templateDescriptionEditUrl = $this->getUrl('*/amazon_template_description/edit', array( - 'id' => $row->getData('id') + 'id' => $row->getData('id'), + 'wizard' => $this->getHelper('Module\Wizard')->isActive( + \Ess\M2ePro\Helper\View\Amazon::WIZARD_INSTALLATION_NICK + ) )); $title = $this->getHelper('Data')->escapeHtml($row->getData('title')); @@ -279,13 +302,11 @@ public function callbackColumnStatus($value, $row, $column, $isExport) case self::ACTION_STATUS_NEW_ASIN_NOT_ACCEPTED: return '' . $this->__('New ASIN/ISBN feature is disabled') . ''; - break; case self::ACTION_STATUS_VARIATIONS_NOT_SUPPORTED: return '' . $this->__( 'Selected Category doesn\'t support Variational Products' ) . ''; - break; } return '' . $this->__('Ready to be assigned') . ''; @@ -303,10 +324,8 @@ public function callbackColumnAction($value, $row, $column, $isExport) switch($row->getData('description_template_action_status')) { case self::ACTION_STATUS_NEW_ASIN_NOT_ACCEPTED: return '' . $assignText . ''; - break; case self::ACTION_STATUS_VARIATIONS_NOT_SUPPORTED: return '' . $assignText . ''; - break; } return 'jsUrl->add($this->getNewTemplateDescriptionUrl(), 'newTemplateDescriptionUrl'); - $this->js->add( -<<getUrl('*/*/viewTemplateDescriptionsGrid', array( + return $this->getUrl('*/*/viewGrid', array( '_current' => true, '_query' => array( - 'check_is_new_asin_accepted' => $this->getCheckNewAsinAccepted() + 'check_is_new_asin_accepted' => $this->getCheckNewAsinAccepted(), + 'map_to_template_js_fn' => $this->getMapToTemplateJsFn(), + 'create_new_template_js_fn' => $this->getCreateNewTemplateJsFn() ), 'products_ids' => implode(',', $this->getProductsIds()), )); @@ -381,8 +390,7 @@ protected function setNoTemplatesText() $message = <<{$messageTxt} {$linkTitle} + onclick="{$this->getCreateNewTemplateJsFn()}('{$templateDescriptionEditUrl}');">{$linkTitle}

    HTML; diff --git a/Block/Adminhtml/Amazon/Listing/Product/Template/ShippingOverride.php b/Block/Adminhtml/Amazon/Listing/Product/Template/ShippingOverride.php new file mode 100644 index 000000000..59f43e0e4 --- /dev/null +++ b/Block/Adminhtml/Amazon/Listing/Product/Template/ShippingOverride.php @@ -0,0 +1,57 @@ +setTemplate('amazon/listing/product/template/shipping_override.phtml'); + } + + //######################################## + + /** + * @param array $messages + */ + public function setMessages($messages) + { + $this->messages = $messages; + } + + /** + * @return array + */ + public function getMessages() + { + return $this->messages; + } + + //######################################## + + public function getWarnings() + { + /** @var \Magento\Framework\View\Element\Messages $messages */ + $messages = $this->getLayout()->createBlock('\Magento\Framework\View\Element\Messages'); + + foreach ($this->getMessages() as $message) { + $addMethod = 'add'.ucfirst($message['type']); + $messages->$addMethod($message['text']); + + } + return $messages->toHtml(); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/Amazon/Listing/Product/Template/ShippingOverride/Grid.php b/Block/Adminhtml/Amazon/Listing/Product/Template/ShippingOverride/Grid.php new file mode 100644 index 000000000..8ef28e177 --- /dev/null +++ b/Block/Adminhtml/Amazon/Listing/Product/Template/ShippingOverride/Grid.php @@ -0,0 +1,204 @@ +setId('amazonTemplateShippingOverrideGrid'); + + // Set default values + // --------------------------------------- + $this->setFilterVisibility(false); + $this->setDefaultSort('id'); + $this->setDefaultDir('ASC'); + $this->setSaveParametersInSession(false); + $this->setUseAjax(true); + // --------------------------------------- + } + + // --------------------------------------- + + /** + * @return mixed + */ + public function getMarketplaceId() + { + return $this->marketplaceId; + } + + /** + * @param mixed $marketplaceId + */ + public function setMarketplaceId($marketplaceId) + { + $this->marketplaceId = $marketplaceId; + } + + // --------------------------------------- + + protected function _prepareCollection() + { + $this->setNoTemplatesText(); + + /** @var \Ess\M2ePro\Model\ResourceModel\Amazon\Template\ShippingOverride\Collection $collection */ + $collection = $this->activeRecordFactory->getObject('Amazon\Template\ShippingOverride')->getCollection(); + $collection->addFieldToFilter('marketplace_id', $this->getMarketplaceId()); + + $this->setCollection($collection); + + return parent::_prepareCollection(); + } + + protected function _prepareColumns() + { + $this->addColumn('title', array( + 'header' => $this->__('Title'), + 'align' => 'left', + 'type' => 'text', + 'index' => 'title', + 'filter' => false, + 'sortable' => false, + 'frame_callback' => array($this, 'callbackColumnTitle') + )); + + $this->addColumn('action', array( + 'header' => $this->__('Action'), + 'align' => 'left', + 'type' => 'number', + 'width' => '55px', + 'index' => 'id', + 'filter' => false, + 'sortable' => false, + 'frame_callback' => array($this, 'callbackColumnAction') + )); + } + + protected function _prepareLayout() + { + $this->setChild('refresh_button', + $this->createBlock('Magento\Button') + ->setData(array( + 'id' => 'shipping_override_template_refresh_btn', + 'label' => $this->__('Refresh'), + 'class' => 'action primary', + 'onclick' => $this->getJsObjectName().'.reload()' + )) + ); + + return parent::_prepareLayout(); + } + + //######################################## + + public function getRefreshButtonHtml() + { + return $this->getChildHtml('refresh_button'); + } + + //######################################## + + public function getMainButtonsHtml() + { + return $this->getRefreshButtonHtml() . parent::getMainButtonsHtml(); + } + + //######################################## + + public function callbackColumnTitle($value, $row, $column, $isExport) + { + $templateDescriptionEditUrl = $this->getUrl('*/amazon_template_shippingOverride/edit', array( + 'id' => $row->getData('id') + )); + + $title = $this->getHelper('Data')->escapeHtml($value); + + return <<{$title} +HTML; + + } + + public function callbackColumnAction($value, $row, $column, $isExport) + { + $assignText = $this->__('Assign'); + + return << + {$assignText} + +HTML; + + } + + //######################################## + + protected function _toHtml() + { + $this->js->add( + <<getUrl('*/*/viewGrid', array( + '_current' => true, + '_query' => array( + 'marketplace_id' => $this->getMarketplaceId() + ) + )); + } + + public function getRowUrl($row) + { + return false; + } + + //######################################## + + protected function setNoTemplatesText() + { + $messageTxt = $this->__('Shipping Override Policies are not found for current Marketplace.'); + $linkTitle = $this->__('Create New Shipping Override Policy.'); + + $message = <<{$messageTxt} {$linkTitle} +

    +HTML; + + $this->setEmptyText($message); + } + + protected function getNewTemplateShippingOverrideUrl() + { + return $this->getUrl('*/amazon_template_shippingOverride/new', array( + 'marketplace_id' => $this->getMarketplaceId(), + 'close_on_save' => 1 + )); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/Amazon/Listing/Product/Variation/Manage/Tabs/Settings/Form.php b/Block/Adminhtml/Amazon/Listing/Product/Variation/Manage/Tabs/Settings/Form.php index daf3a47d0..b479ae553 100644 --- a/Block/Adminhtml/Amazon/Listing/Product/Variation/Manage/Tabs/Settings/Form.php +++ b/Block/Adminhtml/Amazon/Listing/Product/Variation/Manage/Tabs/Settings/Form.php @@ -30,22 +30,6 @@ class Form extends \Ess\M2ePro\Block\Adminhtml\Magento\Form\AbstractForm protected $messages = array(); - protected $elementFactory; - - //######################################## - - public function __construct( - \Magento\Framework\Data\Form\Element\Factory $elementFactory, - \Ess\M2ePro\Block\Adminhtml\Magento\Context\Template $context, - \Magento\Framework\Registry $registry, - \Magento\Framework\Data\FormFactory $formFactory, - array $data = [] - ) - { - $this->elementFactory = $elementFactory; - parent::__construct($context, $registry, $formFactory, $data); - } - //######################################## protected function _prepareForm() @@ -198,7 +182,7 @@ protected function _prepareForm() if (!empty($channelThemeNote)) { $html .= << +
    {$channelThemeNote} @@ -368,7 +352,7 @@ class="m2epro-field-tooltip m2epro-field-tooltip-right admin__field-tooltip"> ); $html = << + +HTML; + } if (is_null($value) || $value === '') { return $this->__('N/A') . $repricingHtml; @@ -636,9 +628,7 @@ class="m2epro-repricing-price-value" sku="{$sku}" account_id="{$accountId}" href="javascript:void(0)" - onclick="CommonAmazonListingRepricingPriceHandlerObj.showRepricingPrice()"> - {$priceValue} - + onclick="AmazonListingProductRepricingPriceObj.showRepricingPrice()">{$priceValue} HTML; } @@ -920,13 +910,12 @@ protected function callbackFilterPrice($collection, $column) } -// TODO -// if (Mage::helper('M2ePro/Component_Amazon_Repricing')->isEnabled() && !empty($value['is_repricing'])) { -// if (!empty($condition)) { -// $condition = '(' . $condition . ') OR '; -// } -// $condition .= '`malpr`.`listing_product_id` IS NOT NULL'; -// } + if ($this->getHelper('Component\Amazon\Repricing')->isEnabled() && !empty($value['is_repricing'])) { + if (!empty($condition)) { + $condition = '(' . $condition . ') OR '; + } + $condition .= '`malpr`.`listing_product_id` IS NOT NULL'; + } $collection->getSelect()->where($condition); } @@ -1002,9 +991,9 @@ public function getViewLogIconHtml($listingProduct) usort($actionsRow['items'], function($a, $b) { $sortOrder = array( - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS => 1, - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR => 2, - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING => 3, + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_SUCCESS => 1, + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR => 2, + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_WARNING => 3, ); return $sortOrder[$a["type"]] > $sortOrder[$b["type"]]; @@ -1012,15 +1001,15 @@ public function getViewLogIconHtml($listingProduct) } $tips = array( - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS => 'Last Action was completed successfully.', - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR => 'Last Action was completed with error(s).', - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING => 'Last Action was completed with warning(s).' + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_SUCCESS => 'Last Action was completed successfully.', + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR => 'Last Action was completed with error(s).', + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_WARNING => 'Last Action was completed with warning(s).' ); $icons = array( - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS => 'normal', - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR => 'error', - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING => 'warning' + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_SUCCESS => 'normal', + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR => 'error', + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_WARNING => 'warning' ); $summary = $this->createBlock('Log\Grid\Summary', '', ['data' => [ @@ -1096,15 +1085,15 @@ public function getInitiatorForAction($actionRows) public function getMainTypeForActionId($actionRows) { - $type = \Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS; + $type = \Ess\M2ePro\Model\Log\AbstractModel::TYPE_SUCCESS; foreach ($actionRows as $row) { - if ($row['type'] == \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR) { - $type = \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR; + if ($row['type'] == \Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR) { + $type = \Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR; break; } - if ($row['type'] == \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING) { - $type = \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING; + if ($row['type'] == \Ess\M2ePro\Model\Log\AbstractModel::TYPE_WARNING) { + $type = \Ess\M2ePro\Model\Log\AbstractModel::TYPE_WARNING; } } @@ -1276,14 +1265,12 @@ public function getRowUrl($row) public function getTooltipHtml($content, $id = '') { return << -
    +
    {$content}
    -
    HTML; } @@ -1636,7 +1623,7 @@ private function parseGroupedData($data) private function convertAndFormatPriceCurrency($price, $currency) { - return $this->priceCurrency->convertAndFormat($price, null, null, null, $currency); + return $this->localeCurrency->getCurrency($currency)->toCurrency($price); } //######################################## diff --git a/Block/Adminhtml/Amazon/Listing/Product/Variation/Manage/Tabs/Variations/NewChild/Form.php b/Block/Adminhtml/Amazon/Listing/Product/Variation/Manage/Tabs/Variations/NewChild/Form.php index 473e92162..7bb508415 100644 --- a/Block/Adminhtml/Amazon/Listing/Product/Variation/Manage/Tabs/Variations/NewChild/Form.php +++ b/Block/Adminhtml/Amazon/Listing/Product/Variation/Manage/Tabs/Variations/NewChild/Form.php @@ -130,25 +130,26 @@ class="{$generalIdOwnerClass} data-grid data-grid-not-hovered" if ($this->isGeneralIdOwner() && $this->hasChannelTheme()) { $html .= << + HTML; if ($this->hasUnusedChannelVariations()) { $html .= << - {$this->__('or')}   - - {$this->__('Create New ASIN/ISBN')} - -
    - +
    + {$this->__('or')}   + + {$this->__('Create New ASIN/ISBN')} + +
    + HTML; } else { @@ -180,7 +181,7 @@ class="{$generalIdOwnerClass} data-grid data-grid-not-hovered" - '; } - $fieldSet->addField('new_asin_accepted', $selectElementType, + $fieldSet->addField('new_asin_accepted', self::SELECT, array_merge( [ 'name' => 'general[is_new_asin_accepted]', @@ -229,7 +223,7 @@ protected function _prepareForm() $defaultValue = Description::WORLDWIDE_ID_MODE_NONE; } - $fieldSet->addField('registered_parameter', $selectElementType, + $fieldSet->addField('registered_parameter', self::SELECT, [ 'name' => 'general[registered_parameter]', 'label' => $this->__('Product ID Override'), @@ -253,7 +247,7 @@ protected function _prepareForm() ] ); - $fieldSet->addField('worldwide_id_mode', $selectElementType, + $fieldSet->addField('worldwide_id_mode', self::SELECT, [ 'name' => 'general[worldwide_id_mode]', 'label' => $this->__('UPC / EAN'), @@ -263,6 +257,7 @@ protected function _prepareForm() 'class' => 'M2ePro-required-when-visible', 'css_class' => 'hide-when-asin-is-disabled', 'required' => true, + 'create_magento_attribute' => true, 'field_extra_attributes' => 'allowed_attribute_types="text" data-current-value="'.$this->formData['worldwide_id_custom_attribute'].'"', 'tooltip' => $this->__( @@ -274,7 +269,7 @@ protected function _prepareForm() In case UPC/EAN doesn’t exist for your Product you can try to use Product ID Override Option.' ) ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text'); // --------------------------------------- @@ -404,7 +399,7 @@ public function getUpcEanOptions() 'opt_group' => [ 'value' => [], 'label' => 'Magento Attribute', - 'attrs' => ['class' => 'M2ePro-custom-attribute-optgroup'] + 'attrs' => ['is_magento_attribute' => true] ] ]; diff --git a/Block/Adminhtml/Amazon/Template/Description/Edit/Tabs/Specifics.php b/Block/Adminhtml/Amazon/Template/Description/Edit/Tabs/Specifics.php index aea0e4f7a..ff02e611b 100644 --- a/Block/Adminhtml/Amazon/Template/Description/Edit/Tabs/Specifics.php +++ b/Block/Adminhtml/Amazon/Template/Description/Edit/Tabs/Specifics.php @@ -73,8 +73,8 @@ protected function _beforeToHtml()
    More detailed information about ability to work with this Page you can find - here.', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/J4MVAQ') + here.', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/J4MVAQ') ) ]); diff --git a/Block/Adminhtml/Amazon/Template/Grid.php b/Block/Adminhtml/Amazon/Template/Grid.php index 2697a0eea..fdc22991d 100644 --- a/Block/Adminhtml/Amazon/Template/Grid.php +++ b/Block/Adminhtml/Amazon/Template/Grid.php @@ -36,12 +36,12 @@ public function __construct( //######################################## - //######################################## - public function _construct() { parent::_construct(); + $this->css->addFile('policy/grid.css'); + // Initialization block // --------------------------------------- $this->setId('amazonTemplateGrid'); @@ -234,6 +234,7 @@ protected function _prepareColumns() 'align' => 'left', 'width' => '150px', 'type' => 'datetime', + 'filter_time' => true, // 'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM), 'index' => 'create_date', 'filter_index' => 'main_table.create_date' @@ -244,6 +245,7 @@ protected function _prepareColumns() 'align' => 'left', 'width' => '150px', 'type' => 'datetime', + 'filter_time' => true, // 'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM), 'index' => 'update_date', 'filter_index' => 'main_table.update_date' @@ -259,18 +261,9 @@ protected function _prepareColumns() 'sortable' => false, 'getter' => 'getTemplateId', 'actions' => array( - array( - 'caption' => $this->__('Edit'), - 'url' => array( - 'base' => '*/amazon_template/edit', - 'params' => array( - 'type' => '$type' - ) - ), - 'field' => 'id' - ), array( 'caption' => $this->__('Delete'), + 'class' => 'action-default scalable add primary policy-delete-btn', 'url' => array( 'base' => '*/amazon_template/delete', 'params' => array( @@ -287,9 +280,9 @@ protected function _prepareColumns() $options = array( self::TEMPLATE_SELLING_FORMAT => $this->__('Selling Format'), -// self::TEMPLATE_SHIPPING_OVERRIDE => $this->__('Shipping Override'), self::TEMPLATE_DESCRIPTION => $this->__('Description'), - self::TEMPLATE_SYNCHRONIZATION => $this->__('Synchronization') + self::TEMPLATE_SYNCHRONIZATION => $this->__('Synchronization'), + self::TEMPLATE_SHIPPING_OVERRIDE => $this->__('Shipping Override') ); $this->getColumn('type')->setData('options', $options); diff --git a/Block/Adminhtml/Amazon/Template/SellingFormat/Edit/Form.php b/Block/Adminhtml/Amazon/Template/SellingFormat/Edit/Form.php index e872c004d..bae42abf7 100644 --- a/Block/Adminhtml/Amazon/Template/SellingFormat/Edit/Form.php +++ b/Block/Adminhtml/Amazon/Template/SellingFormat/Edit/Form.php @@ -7,20 +7,6 @@ class Form extends AbstractForm { - protected $elementFactory; - - public function __construct( - \Magento\Framework\Data\Form\Element\Factory $elementFactory, - \Ess\M2ePro\Block\Adminhtml\Magento\Context\Template $context, - \Magento\Framework\Registry $registry, - \Magento\Framework\Data\FormFactory $formFactory, - array $data = [] - ) - { - $this->elementFactory = $elementFactory; - parent::__construct($context, $registry, $formFactory, $data); - } - protected function _prepareForm() { $template = $this->getHelper('Data\GlobalData')->getValue('tmp_template'); @@ -130,10 +116,25 @@ protected function _prepareForm() $preparedAttributes = [ [ 'value' => \Ess\M2ePro\Model\Template\SellingFormat::QTY_MODE_PRODUCT_FIXED, - 'label' => $this->__('QTY') //todo discuss + 'label' => $this->__('QTY') ] ]; + if ( + $formData['qty_mode'] == \Ess\M2ePro\Model\Template\SellingFormat::QTY_MODE_ATTRIBUTE + && !$magentoAttributeHelper->isExistInAttributesArray($formData['qty_custom_attribute'], $attributes) + && $formData['qty_custom_attribute'] != '' + ) { + $preparedAttributes[] = [ + 'attrs' => [ + 'attribute_code' => $formData['qty_custom_attribute'], + 'selected' => 'selected', + ], + 'value' => \Ess\M2ePro\Model\Template\SellingFormat::QTY_MODE_ATTRIBUTE, + 'label' => $magentoAttributeHelper->getAttributeLabel($formData['qty_custom_attribute']), + ]; + } + foreach ($attributesByInputTypes['text'] as $attribute) { $attrs = ['attribute_code' => $attribute['code']]; if ( @@ -155,7 +156,6 @@ protected function _prepareForm() 'container_id' => 'qty_mode_tr', 'label' => $this->__('Quantity'), 'name' => 'qty_mode', - 'class' => 'M2ePro-custom-attribute-can-be-created', 'values' => [ \Ess\M2ePro\Model\Template\SellingFormat::QTY_MODE_PRODUCT => $this->__('Product Quantity'), \Ess\M2ePro\Model\Template\SellingFormat::QTY_MODE_SINGLE => $this->__('Single Item'), @@ -165,15 +165,16 @@ protected function _prepareForm() 'value' => $preparedAttributes, 'attrs' => [ 'new_option_value' => \Ess\M2ePro\Model\Template\SellingFormat::QTY_MODE_ATTRIBUTE, - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], 'value' => $formData['qty_mode'] != \Ess\M2ePro\Model\Template\SellingFormat::QTY_MODE_ATTRIBUTE ? $formData['qty_mode'] : '', + 'create_magento_attribute' => true, 'tooltip' => $this->__('Product Quantity for Amazon Listing(s).') ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text'); $fieldset->addField('qty_custom_attribute', 'hidden', @@ -204,7 +205,7 @@ protected function _prepareForm() } $fieldset->addField('qty_percentage', - 'select', + self::SELECT, [ 'container_id' => 'qty_percentage_tr', 'label' => $this->__('Quantity Percentage'), @@ -313,7 +314,7 @@ protected function _prepareForm() self::SELECT, [ 'label' => $this->__('Price'), - 'class' => 'select-main M2ePro-custom-attribute-can-be-created', + 'class' => 'select-main', 'name' => 'price_mode', 'values' => [ \Ess\M2ePro\Model\Template\SellingFormat::PRICE_PRODUCT => $this->__('Product Price'), @@ -322,18 +323,19 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], 'value' => $formData['price_mode'] != \Ess\M2ePro\Model\Template\SellingFormat::PRICE_ATTRIBUTE ? $formData['price_mode'] : '', + 'create_magento_attribute' => true, 'after_element_html' => $tooltipPriceMode . '' . $priceCoefficient->toHtml() . $tooltipPriceCoefficient . '' ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text,price'); $fieldset->addField('price_custom_attribute', 'hidden', @@ -344,10 +346,10 @@ protected function _prepareForm() ); $fieldset->addField('price_variation_mode', - 'select', + self::SELECT, [ 'label' => $this->__('Variation Price Source'), - 'class' => 'select-main M2ePro-custom-attribute-can-be-created', + 'class' => 'select-main', 'name' => 'price_variation_mode', 'values' => [ SellingFormat::PRICE_VARIATION_MODE_PARENT => $this->__('Main Product'), @@ -380,7 +382,7 @@ protected function _prepareForm() self::SELECT, [ 'label' => $this->__('Minimum Advertised Price'), - 'class' => 'select-main M2ePro-custom-attribute-can-be-created', + 'class' => 'select-main', 'name' => 'map_price_mode', 'values' => [ \Ess\M2ePro\Model\Template\SellingFormat::PRICE_NONE => $this->__('None'), @@ -390,12 +392,13 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], 'value' => $formData['map_price_mode'] != \Ess\M2ePro\Model\Template\SellingFormat::PRICE_ATTRIBUTE ? $formData['map_price_mode'] : '', + 'create_magento_attribute' => true, 'tooltip' => $this->__( 'The Selling Price for your Product will not be displayed on the Product Detail Page or Offer Listing Page if it is less than the Minimum Advertised Price. @@ -403,7 +406,7 @@ protected function _prepareForm() Item to their Shopping Cart.' ) ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text,price'); $fieldset->addField('map_price_custom_attribute', 'hidden', @@ -450,7 +453,7 @@ protected function _prepareForm() self::SELECT, [ 'label' => $this->__('Sale Price'), - 'class' => 'select-main M2ePro-custom-attribute-can-be-created', + 'class' => 'select-main', 'name' => 'sale_price_mode', 'values' => [ \Ess\M2ePro\Model\Template\SellingFormat::PRICE_NONE => $this->__('None'), @@ -460,18 +463,19 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], 'value' => $formData['sale_price_mode'] != \Ess\M2ePro\Model\Template\SellingFormat::PRICE_ATTRIBUTE ? $formData['sale_price_mode'] : '', + 'create_magento_attribute' => true, 'after_element_html' => $tooltipSalePriceMode . '' . $salePriceCoefficient->toHtml() . $tooltipSalePriceCoefficient . '' ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text'); $this->css->add( 'label.mage-error[for="price_coefficient"], label.mage-error[for="sale_price_coefficient"] @@ -487,7 +491,7 @@ protected function _prepareForm() ); $preparedAttributes = []; - foreach ($attributesByInputTypes['text_price'] as $attribute) { + foreach ($attributesByInputTypes['text_date'] as $attribute) { $attrs = ['attribute_code' => $attribute['code']]; if ( $formData['sale_price_start_date_mode'] == SellingFormat::DATE_ATTRIBUTE @@ -507,7 +511,7 @@ protected function _prepareForm() [ 'container_id' => 'sale_price_start_date_mode_tr', 'label' => $this->__('Start Date'), - 'class' => 'select-main M2ePro-custom-attribute-can-be-created', + 'class' => 'select-main', 'name' => 'sale_price_start_date_mode', 'values' => [ SellingFormat::DATE_VALUE => $this->__('Custom Value'), @@ -515,15 +519,16 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], 'value' => $formData['sale_price_start_date_mode'] != SellingFormat::DATE_ATTRIBUTE ? $formData['sale_price_start_date_mode'] : '', + 'create_magento_attribute' => true, 'tooltip' => $this->__('Time and date when the Sale Price will be displayed on Amazon.') ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text,date'); $fieldset->addField('sale_price_start_date_custom_attribute', 'hidden', @@ -546,7 +551,7 @@ protected function _prepareForm() ); $preparedAttributes = []; - foreach ($attributesByInputTypes['text_price'] as $attribute) { + foreach ($attributesByInputTypes['text_date'] as $attribute) { $attrs = ['attribute_code' => $attribute['code']]; if ( $formData['sale_price_end_date_mode'] == SellingFormat::DATE_ATTRIBUTE @@ -566,7 +571,7 @@ protected function _prepareForm() [ 'container_id' => 'sale_price_end_date_mode_tr', 'label' => $this->__('End Date'), - 'class' => 'select-main M2ePro-custom-attribute-can-be-created', + 'class' => 'select-main', 'name' => 'sale_price_end_date_mode', 'values' => [ SellingFormat::DATE_VALUE => $this->__('Custom Value'), @@ -574,15 +579,16 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], 'value' => $formData['sale_price_end_date_mode'] != SellingFormat::DATE_ATTRIBUTE ? $formData['sale_price_end_date_mode'] : '', + 'create_magento_attribute' => true, 'tooltip' => $this->__('Time and date when the Sale Price will be hidden on Amazon.') ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text,date'); $fieldset->addField('sale_price_end_date_custom_attribute', 'hidden', @@ -605,7 +611,7 @@ protected function _prepareForm() ); $fieldset->addField('price_increase_vat_percent', - 'select', + self::SELECT, [ 'label' => $this->__('Add VAT Percentage'), 'class' => 'select-main', @@ -614,7 +620,7 @@ protected function _prepareForm() 0 => $this->__('No'), 1 => $this->__('Yes') ], - 'value' => (int)($formData['price_vat_percent'] > 0), //todo check + 'value' => (int)($formData['price_vat_percent'] > 0), 'tooltip' => $this->__(' Choose whether you want to add VAT to the Price when a Product is Listed on Amazon and provide the appropriate VAT Percent Value.

    diff --git a/Block/Adminhtml/Amazon/Template/ShippingOverride/Edit.php b/Block/Adminhtml/Amazon/Template/ShippingOverride/Edit.php new file mode 100644 index 000000000..0cda98cd4 --- /dev/null +++ b/Block/Adminhtml/Amazon/Template/ShippingOverride/Edit.php @@ -0,0 +1,107 @@ +_controller = 'adminhtml_amazon_template_shippingOverride'; + + $this->removeButton('back'); + $this->removeButton('reset'); + $this->removeButton('delete'); + $this->removeButton('add'); + $this->removeButton('save'); + $this->removeButton('edit'); + // --------------------------------------- + + // --------------------------------------- + $url = $this->getHelper('Data')->getBackUrl('list'); + $this->addButton('back', array( + 'label' => $this->__('Back'), + 'onclick' => 'AmazonTemplateShippingOverrideObj.backClick(\'' . $url . '\')', + 'class' => 'back' + )); + // --------------------------------------- + + $isSaveAndClose = (bool)$this->getRequest()->getParam('close_on_save', false); + + if (!$isSaveAndClose + && $this->getHelper('Data\GlobalData')->getValue('tmp_template') + && $this->getHelper('Data\GlobalData')->getValue('tmp_template')->getId() + ) { + // --------------------------------------- + $this->addButton('duplicate', array( + 'label' => $this->__('Duplicate'), + 'onclick' => 'AmazonTemplateShippingOverrideObj.duplicateClick' + .'(\'amazon-template-shippingOverride\')', + 'class' => 'action-primary M2ePro_duplicate_button' + )); + // --------------------------------------- + + // --------------------------------------- + $this->addButton('delete', array( + 'label' => $this->__('Delete'), + 'onclick' => 'AmazonTemplateShippingOverrideObj.deleteClick()', + 'class' => 'action-primary delete M2ePro_delete_button' + )); + // --------------------------------------- + } + + // --------------------------------------- + + $saveButtonOptions = []; + + if ($isSaveAndClose) { + $saveButtonOptions['save'] = [ + 'label' => $this->__('Save And Close'), + 'onclick' => "AmazonTemplateShippingOverrideObj.saveAndCloseClick()" + ]; + $this->removeButton('back'); + } else { + $saveButtonOptions['save'] = [ + 'label' => $this->__('Save And Back'), + 'onclick' =>'AmazonTemplateShippingOverrideObj.saveClick(' + . '\'\',' + . '\'' . $this->getSaveConfirmationText() . '\',' + . '\'' . \Ess\M2ePro\Block\Adminhtml\Amazon\Template\Grid::TEMPLATE_SHIPPING_OVERRIDE . '\'' + . ')', + 'class' => 'save primary' + ]; + } + // --------------------------------------- + + $saveButtons = [ + 'id' => 'save_and_continue', + 'label' => $this->__('Save And Continue Edit'), + 'class' => 'add', + 'button_class' => '', + 'onclick' => 'AmazonTemplateShippingOverrideObj.saveAndEditClick(' + . '\'\',' + . 'undefined,' + . '\'' . $this->getSaveConfirmationText() . '\',' + . '\'' . \Ess\M2ePro\Block\Adminhtml\Amazon\Template\Grid::TEMPLATE_SHIPPING_OVERRIDE . '\'' + . ')', + 'class_name' => 'Ess\M2ePro\Block\Adminhtml\Magento\Button\SplitButton', + 'options' => $saveButtonOptions, + ]; + + $this->addButton('save_buttons', $saveButtons); + + $this->css->addFile('amazon/template.css'); + // --------------------------------------- + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/Amazon/Template/ShippingOverride/Edit/Form.php b/Block/Adminhtml/Amazon/Template/ShippingOverride/Edit/Form.php new file mode 100644 index 000000000..86e7b6105 --- /dev/null +++ b/Block/Adminhtml/Amazon/Template/ShippingOverride/Edit/Form.php @@ -0,0 +1,369 @@ +resourceConnection = $resourceConnection; + parent::__construct($context, $registry, $formFactory, $data); + } + + //######################################## + + /** + * @return \Ess\M2ePro\Model\ActiveRecord\Factory + */ + public function getActiveRecordFactory() + { + return $this->activeRecordFactory; + } + + //######################################## + + protected function _prepareForm() + { + /** @var \Ess\M2ePro\Model\Amazon\Template\ShippingOverride $model */ + $model = $this->getHelper('Data\GlobalData')->getValue('tmp_template'); + + $formData = array(); + if ($model) { + $formData = $model->toArray(); + } + + if (!empty($formData)) { + $formData['shipping_override_rule'] = $model->getServices(); + } + + $default = array( + 'id' => '', + 'title' => '', + 'marketplace_id' => '', + 'shipping_override_rule' => array() + ); + + $default['marketplace_id'] = $this->getRequest()->getParam('marketplace_id', ''); + + $formData = array_merge($default, $formData); + + $this->formData = $formData; + + $form = $this->_formFactory->create( + [ + 'data' => [ + 'id' => 'edit_form', + 'method' => 'post', + 'action' => $this->getUrl('*/*/save'), + 'enctype' => 'multipart/form-data', + 'class' => 'admin__scope-old' + ] + ] + ); + + $fieldset = $form->addFieldset( + 'magento_block_amazon_template_shipping_override_general', + [ + 'legend' => $this->__('General'), + 'collapsable' => false + ] + ); + + $fieldset->addField( + 'title', + 'text', + [ + 'name' => 'title', + 'label' => $this->__('Title'), + 'value' => $formData['title'], + 'class' => 'M2ePro-shipping-override-tpl-title', + 'tooltip' => $this->__('Short meaningful Policy Title for your internal use.'), + 'required' => true, + ] + ); + + if (!empty($formData['marketplace_id'])) { + $marketplace = $this->activeRecordFactory->getObjectLoaded('Marketplace', $formData['marketplace_id']); + + $marketplaceInput = $this->elementFactory->create('hidden', ['data' => [ + 'html_id' => 'marketplace_id', + 'name' => 'marketplace_id', + 'no_span' => true, + 'value' => $formData['marketplace_id'] + ]]); + $marketplaceInput->setForm($form); + + $fieldset->addField('marketplace_id_container', + self::CUSTOM_CONTAINER, + [ + 'label' => $this->__('Marketplace'), + 'title' => $this->__('Marketplace'), + 'text' => <<toHtml()} +{$marketplace->getTitle()} +HTML + ] + ); + + } else { + $marketplaces = [['value' => '', 'label' => '']]; + foreach ($this->getEnabledMarketplaces() as $marketplace) { + $marketplaces[] = [ + 'attrs' => [ + 'currency' => $marketplace->getChildObject()->getCurrency() + ], + 'value' => $marketplace->getId(), + 'label' => $marketplace->getTitle() + ]; + } + + $fieldset->addField( + 'marketplace_id', + self::SELECT, + [ + 'name' => 'marketplace_id', + 'label' => $this->__('Marketplace'), + 'title' => $this->__('Marketplace'), + 'values' => $marketplaces, + 'value' => $formData['marketplace_id'], + 'required' => true, + ] + ); + } + + $fieldset = $form->addFieldset( + 'magento_block_amazon_template_shipping_override_rules', + [ + 'legend' => $this->__('Overrides'), + 'collapsable' => false + ] + ); + + $fieldset->addField( + 'reles_container', + self::CUSTOM_CONTAINER, + [ + 'text' => '
    ', + 'css_class' => 'm2epro-custom-container-full-width' + ] + ); + + $form->setUseContainer(true); + $this->setForm($form); + + return parent::_prepareForm(); + } + + protected function _prepareLayout() + { + $this->appendHelpBlock([ + 'content' => $this->__(' + The Shipping Override Policy allows to override Shipping Settings provided in your Amazon Seller Central. So you + can add/edit selected Shipping Service and Locale as well as the Shipping Cost Settings.

    + + Note: the Settings specified in Shipping Override Policy are not visible in Seller Central. + They become available only after the Buyer add the Item with such Settings into a Cart in selected Locale. +

    + + More detailed information about ability to work with this Page you can find + here.', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/d44VAQ') + ) + ]); + + return parent::_prepareLayout(); + } + + protected function _beforeToHtml() + { + parent::_beforeToHtml(); + + // --------------------------------------- + $buttonBlock = $this->createBlock('Magento\Button') + ->setData(array( + 'label' => $this->__('Add Override'), + 'onclick' => 'AmazonTemplateShippingOverrideObj.addRow();', + 'class' => 'action primary add_shipping_override_rule_button' + )); + $this->setChild('add_shipping_override_rule_button', $buttonBlock); + // --------------------------------------- + + // --------------------------------------- + $buttonBlock = $this->createBlock('Magento\Button') + ->setData(array( + 'label' => $this->__('Remove'), + 'onclick' => 'AmazonTemplateShippingOverrideObj.removeRow(this);', + 'class' => 'delete icon-btn remove_shipping_override_rule_button' + )); + $this->setChild('remove_shipping_override_rule_button', $buttonBlock); + // --------------------------------------- + } + + public function _toHtml() + { + $this->jsPhp->addConstants( + $this->getHelper('Data')->getClassConstants('\Ess\M2ePro\Helper\Component\Amazon') + ); + + $this->jsPhp->addConstants( + $this->getHelper('Data')->getClassConstants('\Ess\M2ePro\Model\Amazon\Template\ShippingOverride\Service') + ); + + $this->jsUrl->addUrls([ + 'formSubmit' => $this->getUrl('*/amazon_template_shippingOverride/save', [ + '_current' => $this->getRequest()->getParam('id'), + 'close_on_save' => $this->getRequest()->getParam('close_on_save') + ]), + 'formSubmitNew' => $this->getUrl('*/amazon_template_shippingOverride/save'), + 'deleteAction' => $this->getUrl('*/amazon_template_shippingOverride/delete', [ + 'id' => $this->getRequest()->getParam('id'), + 'close_on_save' => $this->getRequest()->getParam('close_on_save') + ]) + ]); + + $this->jsTranslator->addTranslations([ + 'Any' => $this->__('Any'), + 'Add Shipping Override Policy' => $this->__('Add Shipping Override Policy'), + 'The specified Title is already used for other Policy. Policy Title must be unique.' => + $this->__('The specified Title is already used for other Policy. Policy Title must be unique.'), + ]); + + $title = $this->getHelper('Data')->escapeJs($this->getHelper('Data')->escapeHtml($this->formData['title'])); + $overrideServicesData = json_encode($this->getOverrideDictionaryData()); + + if ($this->formData['id'] != '') { + $rules = json_encode($this->formData['shipping_override_rule']); + $rulesRenderJs = 'AmazonTemplateShippingOverrideObj.renderRules(' . $rules . ')'; + } else { + $rulesRenderJs = <<js->addOnReadyJs(<<getForm()->getId()}').observe('change', function(e) { + if (e.target.tagName != 'SELECT') { + return; + } + + $(e.target).select('.empty') && + $(e.target).select('.empty').length && $(e.target).select('.empty')[0].hide(); + }); + }); +JS + ); + + return parent::_toHtml(); + } + + //######################################## + + public function getAttributes() + { + if (is_null($this->attributes)) { + + /** @var \Ess\M2ePro\Helper\Magento\Attribute $magentoAttributeHelper */ + $magentoAttributeHelper = $this->getHelper('Magento\Attribute'); + $this->attributes = $magentoAttributeHelper->getGeneralFromAllAttributeSets(); + + if ($this->formData['id']) { + foreach ($this->formData['shipping_override_rule'] as $rule) { + + if ($rule['cost_mode'] != Service::COST_MODE_CUSTOM_ATTRIBUTE || + $magentoAttributeHelper->isExistInAttributesArray($rule['cost_value'], $this->attributes) || + $rule['cost_value'] == '') { + continue; + } + + $this->attributes[] = [ + 'code' => $rule['cost_value'], + 'label' => $magentoAttributeHelper->getAttributeLabel($rule['cost_value']) + ]; + } + } + } + + return $this->attributes; + } + + //######################################## + + public function getEnabledMarketplaces() + { + if (is_null($this->enabledMarketplaces)) { + $collection = $this->activeRecordFactory->getObject('Marketplace')->getCollection(); + $collection->addFieldToFilter('component_mode', \Ess\M2ePro\Helper\Component\Amazon::NICK); + $collection->addFieldToFilter('status', \Ess\M2ePro\Model\Marketplace::STATUS_ENABLE); + $collection->setOrder('sorder', 'ASC'); + + $this->enabledMarketplaces = $collection; + } + + return $this->enabledMarketplaces->getItems(); + } + + //######################################## + + public function getOverrideDictionaryData() + { + if (is_null($this->overrideDictionaryData)) { + $connection = $this->resourceConnection->getConnection(); + $table = $this->resourceConnection->getTableName('m2epro_amazon_dictionary_shipping_override'); + + $this->overrideDictionaryData = $connection->select()->from($table)->query()->fetchAll(); + } + + return $this->overrideDictionaryData; + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/Amazon/Template/Synchronization/Edit/Tabs.php b/Block/Adminhtml/Amazon/Template/Synchronization/Edit/Tabs.php index bf9b9a50c..abe03ade8 100644 --- a/Block/Adminhtml/Amazon/Template/Synchronization/Edit/Tabs.php +++ b/Block/Adminhtml/Amazon/Template/Synchronization/Edit/Tabs.php @@ -60,8 +60,6 @@ protected function _prepareLayout() ] ); - $this->setActiveTab($this->getRequest()->getParam('tab', 'list')); - return parent::_prepareLayout(); } diff --git a/Block/Adminhtml/Amazon/Template/Synchronization/Edit/Tabs/ListRules.php b/Block/Adminhtml/Amazon/Template/Synchronization/Edit/Tabs/ListRules.php index 1864522ed..f73ebb582 100644 --- a/Block/Adminhtml/Amazon/Template/Synchronization/Edit/Tabs/ListRules.php +++ b/Block/Adminhtml/Amazon/Template/Synchronization/Edit/Tabs/ListRules.php @@ -48,10 +48,10 @@ protected function _prepareForm() Synchronization (Amazon Integration > Configuration > Settings > Synchronization). Otherwise, Synchronization Policy Rules will not take effect.


    More detailed information about how to work with this Page you can find - here.

    + here.

    HTML , - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/RQItAQ') + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/RQItAQ') ) ] ); @@ -64,9 +64,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'list_mode', - 'select', + $fieldset->addField('list_mode', + self::SELECT, [ 'name' => 'list_mode', 'label' => $this->__('List Action'), @@ -90,9 +89,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'list_status_enabled', - 'select', + $fieldset->addField('list_status_enabled', + self::SELECT, [ 'name' => 'list_status_enabled', 'label' => $this->__('Product Status'), @@ -109,9 +107,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'list_is_in_stock', - 'select', + $fieldset->addField('list_is_in_stock', + self::SELECT, [ 'name' => 'list_is_in_stock', 'label' => $this->__('Stock Availability'), @@ -128,9 +125,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'list_qty_magento', - 'select', + $fieldset->addField('list_qty_magento', + self::SELECT, [ 'name' => 'list_qty_magento', 'label' => $this->__('Magento Quantity'), @@ -176,9 +172,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'list_qty_calculated', - 'select', + $fieldset->addField('list_qty_calculated', + self::SELECT, [ 'name' => 'list_qty_calculated', 'label' => $this->__('Calculated Quantity'), diff --git a/Block/Adminhtml/Amazon/Template/Synchronization/Edit/Tabs/RelistRules.php b/Block/Adminhtml/Amazon/Template/Synchronization/Edit/Tabs/RelistRules.php index c12e79430..7e7a48fe4 100644 --- a/Block/Adminhtml/Amazon/Template/Synchronization/Edit/Tabs/RelistRules.php +++ b/Block/Adminhtml/Amazon/Template/Synchronization/Edit/Tabs/RelistRules.php @@ -35,7 +35,7 @@ protected function _prepareForm() $form = $this->_formFactory->create(); $form->addField( - 'amazon_template_synchronization_general', + 'amazon_template_synchronization_relist', self::HELP_BLOCK, [ 'content' => $this->__( @@ -47,10 +47,10 @@ protected function _prepareForm() by Amazon), M2E Pro will attempt to relist the Item again only if there is a change of Product Status, Stock Availability or Quantity in Magento.


    More detailed information about how to work with this Page you can find - here.

    + here.

    HTML , - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/SQItAQ') + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/SQItAQ') ) ] ); @@ -63,9 +63,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'relist_mode', - 'select', + $fieldset->addField('relist_mode', + self::SELECT, [ 'name' => 'relist_mode', 'label' => $this->__('Relist Action'), @@ -80,9 +79,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'relist_filter_user_lock', - 'select', + $fieldset->addField('relist_filter_user_lock', + self::SELECT, [ 'container_id' => 'relist_filter_user_lock_tr_container', 'name' => 'relist_filter_user_lock', @@ -98,9 +96,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'relist_send_data', - 'select', + $fieldset->addField('relist_send_data', + self::SELECT, [ 'container_id' => 'relist_send_data_tr_container', 'name' => 'relist_send_data', @@ -127,9 +124,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'relist_status_enabled', - 'select', + $fieldset->addField('relist_status_enabled', + self::SELECT, [ 'name' => 'relist_status_enabled', 'label' => $this->__('Product Status'), @@ -147,9 +143,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'relist_is_in_stock', - 'select', + $fieldset->addField('relist_is_in_stock', + self::SELECT, [ 'name' => 'relist_is_in_stock', 'label' => $this->__('Stock Availability'), @@ -167,9 +162,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'relist_qty_magento', - 'select', + $fieldset->addField('relist_qty_magento', + self::SELECT, [ 'name' => 'relist_qty_magento', 'label' => $this->__('Magento Quantity'), @@ -216,9 +210,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'relist_qty_calculated', - 'select', + $fieldset->addField('relist_qty_calculated', + self::SELECT, [ 'name' => 'relist_qty_calculated', 'label' => $this->__('Calculated Quantity'), diff --git a/Block/Adminhtml/Amazon/Template/Synchronization/Edit/Tabs/ReviseRules.php b/Block/Adminhtml/Amazon/Template/Synchronization/Edit/Tabs/ReviseRules.php index 746eeb583..1fdfb4d08 100644 --- a/Block/Adminhtml/Amazon/Template/Synchronization/Edit/Tabs/ReviseRules.php +++ b/Block/Adminhtml/Amazon/Template/Synchronization/Edit/Tabs/ReviseRules.php @@ -36,7 +36,6 @@ protected function _prepareForm() ); $formData = array_merge($defaults, $formData); - $isEdit = !!$this->getRequest()->getParam('id'); $form = $this->_formFactory->create(); @@ -61,10 +60,10 @@ protected function _prepareForm() fully Revised.


    More detailed information about how to work with this Page you can find - here.

    + here.

    HTML , - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/RwItAQ') + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/RwItAQ') ) ] ); @@ -77,9 +76,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'revise_update_qty', - 'select', + $fieldset->addField('revise_update_qty', + self::SELECT, [ 'name' => 'revise_update_qty', 'label' => $this->__('Quantity'), @@ -95,9 +93,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'revise_update_qty_max_applied_value_mode', - 'select', + $fieldset->addField('revise_update_qty_max_applied_value_mode', + self::SELECT, [ 'container_id' => 'revise_update_qty_max_applied_value_mode_tr', 'name' => 'revise_update_qty_max_applied_value_mode', @@ -137,9 +134,8 @@ protected function _prepareForm() [] ); - $fieldset->addField( - 'revise_update_price', - 'select', + $fieldset->addField('revise_update_price', + self::SELECT, [ 'name' => 'revise_update_price', 'label' => $this->__('Price'), @@ -155,9 +151,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'revise_update_price_max_allowed_deviation_mode', - 'select', + $fieldset->addField('revise_update_price_max_allowed_deviation_mode', + self::SELECT, [ 'container_id' => 'revise_update_price_max_allowed_deviation_mode_tr', 'name' => 'revise_update_price_max_allowed_deviation_mode', @@ -181,9 +176,8 @@ protected function _prepareForm() $priceDeviationValue >= 5 && $percentageStep = 1; } - $fieldset->addField( - 'revise_update_price_max_allowed_deviation', - 'select', + $fieldset->addField('revise_update_price_max_allowed_deviation', + self::SELECT, [ 'container_id' => 'revise_update_price_max_allowed_deviation_tr', 'name' => 'revise_update_price_max_allowed_deviation', @@ -214,9 +208,8 @@ protected function _prepareForm() [] ); - $fieldset->addField( - 'revise_update_details', - 'select', + $fieldset->addField('revise_update_details', + self::SELECT, [ 'name' => 'revise_update_details', 'label' => $this->__('Details'), @@ -233,9 +226,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'revise_update_images', - 'select', + $fieldset->addField('revise_update_images', + self::SELECT, [ 'name' => 'revise_update_images', 'label' => $this->__('Images'), @@ -259,9 +251,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'revise_change_listing', - 'select', + $fieldset->addField('revise_change_listing', + self::SELECT, [ 'name' => 'revise_change_listing', 'label' => $this->__('Listing Settings'), @@ -274,9 +265,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'revise_change_selling_format_template', - 'select', + $fieldset->addField('revise_change_selling_format_template', + self::SELECT, [ 'name' => 'revise_change_selling_format_template', 'label' => $this->__('Selling Format Policy'), @@ -293,9 +283,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'revise_change_description_template', - 'select', + $fieldset->addField('revise_change_description_template', + self::SELECT, [ 'name' => 'revise_change_description_template', 'label' => $this->__('Description Policy'), @@ -308,21 +297,22 @@ protected function _prepareForm() ] ); - // TODO NOT SUPPORTED FEATURES -// $fieldset->addField( -// 'revise_change_shipping_override_template', -// 'select', -// [ -// 'name' => 'revise_change_shipping_override_template', -// 'label' => $this->__('Shipping Override Policy'), -// 'value' => $formData['revise_change_shipping_override_template'], -// 'values' => [ -// Synchronization::REVISE_CHANGE_SHIPPING_OVERRIDE_TEMPLATE_NONE => $this->__('No'), -// Synchronization::REVISE_CHANGE_SHIPPING_OVERRIDE_TEMPLATE_YES => $this->__('Yes'), -// ], -// 'tooltip' => $this->__('Automatically revises Amazon Listing(s) if its Shipping Override Policy was changed.') -// ] -// ); + $fieldset->addField( + 'revise_change_shipping_override_template', + self::SELECT, + [ + 'name' => 'revise_change_shipping_override_template', + 'label' => $this->__('Shipping Override Policy'), + 'value' => $formData['revise_change_shipping_override_template'], + 'values' => [ + Synchronization::REVISE_CHANGE_SHIPPING_OVERRIDE_TEMPLATE_NONE => $this->__('No'), + Synchronization::REVISE_CHANGE_SHIPPING_OVERRIDE_TEMPLATE_YES => $this->__('Yes'), + ], + 'tooltip' => $this->__( + 'Automatically revises Amazon Listing(s) if its Shipping Override Policy was changed.' + ) + ] + ); $form->addField( 'revise_qty_max_applied_value_confirmation_popup_template', diff --git a/Block/Adminhtml/Amazon/Template/Synchronization/Edit/Tabs/StopRules.php b/Block/Adminhtml/Amazon/Template/Synchronization/Edit/Tabs/StopRules.php index 9110e163f..1cdf6e59c 100644 --- a/Block/Adminhtml/Amazon/Template/Synchronization/Edit/Tabs/StopRules.php +++ b/Block/Adminhtml/Amazon/Template/Synchronization/Edit/Tabs/StopRules.php @@ -42,8 +42,8 @@ protected function _prepareForm() If all Stop Conditions are enabled, then an Item will be inactivated if at least one of the Stop Conditions is met.

    More detailed information about ability to work with this Page you can find - here.', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/HIMVAQ') + here.', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/HIMVAQ') ) ] ); @@ -56,9 +56,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'stop_status_disabled', - 'select', + $fieldset->addField('stop_status_disabled', + self::SELECT, [ 'name' => 'stop_status_disabled', 'label' => $this->__('Stop When Status Disabled'), @@ -73,9 +72,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'stop_out_off_stock', - 'select', + $fieldset->addField('stop_out_off_stock', + self::SELECT, [ 'name' => 'stop_out_off_stock', 'label' => $this->__('Stop When Out Of Stock'), @@ -91,9 +89,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'stop_qty_magento', - 'select', + $fieldset->addField('stop_qty_magento', + self::SELECT, [ 'name' => 'stop_qty_magento', 'label' => $this->__('Stop When Magento Quantity Is'), @@ -135,9 +132,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'stop_qty_calculated', - 'select', + $fieldset->addField('stop_qty_calculated', + self::SELECT, [ 'name' => 'stop_qty_calculated', 'label' => $this->__('Stop When Calculated Quantity Is'), diff --git a/Block/Adminhtml/Category/Grid.php b/Block/Adminhtml/Category/Grid.php index 411d83de1..925cc582c 100644 --- a/Block/Adminhtml/Category/Grid.php +++ b/Block/Adminhtml/Category/Grid.php @@ -85,8 +85,6 @@ protected function _prepareCache($collection) ) ->where('ccev.entity_id IN ('.implode(',',$ids).')') ->where('ccev.attribute_id = ?', $attribute->getAttributeId()) - // TODO no type id ? -// ->where('ccev.entity_type_id = ?', $attribute->getEntityTypeId()) ->where('ccev.store_id = ('.$dbSelect1->__toString().')'); $cacheData = array(); diff --git a/Block/Adminhtml/Component/Switcher.php b/Block/Adminhtml/Component/Switcher.php index 8b90b3399..99d6c60b8 100644 --- a/Block/Adminhtml/Component/Switcher.php +++ b/Block/Adminhtml/Component/Switcher.php @@ -42,28 +42,6 @@ public function getParamName() return $this->getData('component_mode') . ucfirst($this->paramName); } - public function getSwitchUrl() - { - //todo -// $params = array( -// '_current' => true, -// $this->getParamName() => $this->getParamPlaceHolder() -// ); -// -// $tabId = Ess_M2ePro_Block_Adminhtml_Common_Component_Abstract::getTabIdByComponent( -// $this->getData('component_mode') -// ); -// -// if (!is_null($tabId)) { -// $params['tab'] = $tabId; -// } -// -// $controllerName = $this->getData('controller_name') ? $this->getData('controller_name') : '*'; -// -// return $this->getUrl("*/{$controllerName}/*", $params); - return parent::getSwitchUrl(); - } - public function getSwitchCallback() { return 'switch' . ucfirst($this->getParamName()); diff --git a/Block/Adminhtml/ControlPanel.php b/Block/Adminhtml/ControlPanel.php new file mode 100644 index 000000000..c0adcf676 --- /dev/null +++ b/Block/Adminhtml/ControlPanel.php @@ -0,0 +1,38 @@ +removeButton('back'); + $this->removeButton('reset'); + $this->removeButton('delete'); + $this->removeButton('add'); + $this->removeButton('save'); + $this->removeButton('edit'); + // --------------------------------------- + } + + //######################################## + + protected function _toHtml() + { + return parent::_toHtml().'
    '; + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Info/Actual.php b/Block/Adminhtml/ControlPanel/Info/Actual.php new file mode 100644 index 000000000..7a995a54d --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Info/Actual.php @@ -0,0 +1,72 @@ +setId('controlPanelSummaryInfo'); + // --------------------------------------- + + $this->setTemplate('control_panel/info/actual.phtml'); + } + + //######################################## + + protected function _beforeToHtml() + { + $this->magentoInfo = $this->__(ucwords($this->getHelper('Magento')->getEditionName())) . + ' (' . $this->getHelper('Magento')->getVersion() . ')'; + + // --------------------------------------- + $this->moduleVersion = $this->getHelper('Module')->getVersion(); + // --------------------------------------- + + // --------------------------------------- + $this->phpVersion = $this->getHelper('Client')->getPhpVersion(); + $this->phpApi = $this->getHelper('Client')->getPhpApiName(); + // --------------------------------------- + + // --------------------------------------- + $this->memoryLimit = $this->getHelper('Client')->getMemoryLimit(true); + $this->maxExecutionTime = ini_get('max_execution_time'); + // --------------------------------------- + + // --------------------------------------- + $this->mySqlVersion = $this->getHelper('Client')->getMysqlVersion(); + $this->mySqlDatabaseName = $this->getHelper('Magento')->getDatabaseName(); + // --------------------------------------- + + // --------------------------------------- + $this->cronLastRunTime = 'N/A'; + $this->cronIsNotWorking = false; + $this->cronCurrentRunner = ucfirst($this->getHelper('Module\Cron')->getRunner()); + + $cronLastRunTime = $this->getHelper('Module\Cron')->getLastRun(); + + if (!is_null($cronLastRunTime)) { + $this->cronLastRunTime = $cronLastRunTime; + $this->cronIsNotWorking = $this->getHelper('Module\Cron')->isLastRunMoreThan(12,true); + } + // --------------------------------------- + + return parent::_beforeToHtml(); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Info/Inspection.php b/Block/Adminhtml/ControlPanel/Info/Inspection.php new file mode 100644 index 000000000..18c29e4f8 --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Info/Inspection.php @@ -0,0 +1,44 @@ +setId('controlPanelSummaryInspection'); + // --------------------------------------- + + $this->setTemplate('control_panel/info/inspection.phtml'); + } + + //######################################## + + protected function _beforeToHtml() + { + $this->mainChecks = sprintf( + '%s', + $this->getUrl('*/controlPanel_inspection/mainChecks'), + $this->__('Show') + ); + // --------------------------------------- + + return parent::_beforeToHtml(); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Info/Installation.php b/Block/Adminhtml/ControlPanel/Info/Installation.php new file mode 100644 index 000000000..40bc1249c --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Info/Installation.php @@ -0,0 +1,39 @@ +setId('controlPanelInfoInstallation'); + // --------------------------------------- + + $this->setTemplate('control_panel/info/installation.phtml'); + } + + //######################################## + + protected function _beforeToHtml() + { + $this->setupData = $this->activeRecordFactory->getObject('Setup')->getCollection()->toArray()['items']; + + return parent::_beforeToHtml(); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Info/Location.php b/Block/Adminhtml/ControlPanel/Info/Location.php new file mode 100644 index 000000000..59ebddb7e --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Info/Location.php @@ -0,0 +1,42 @@ +setId('controlPanelAboutLocation'); + // --------------------------------------- + + $this->setTemplate('control_panel/info/location.phtml'); + } + + //######################################## + + protected function _beforeToHtml() + { + $this->locationHost = $this->getHelper('Client')->getHost(); + $this->locationDomain = $this->getHelper('Client')->getDomain(); + $this->locationIp = $this->getHelper('Client')->getIp(); + $this->locationDirectory = $this->getHelper('Client')->getBaseDirectory(); + + return parent::_beforeToHtml(); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Info/Magento.php b/Block/Adminhtml/ControlPanel/Info/Magento.php new file mode 100644 index 000000000..fa19e674e --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Info/Magento.php @@ -0,0 +1,41 @@ +setId('controlPanelAboutMagento'); + // --------------------------------------- + + $this->setTemplate('control_panel/info/magento.phtml'); + } + + //######################################## + + protected function _beforeToHtml() + { + $this->platformMode = $this->__(ucwords($this->getHelper('Magento')->getEditionName())); + $this->platformVersion = $this->getHelper('Magento')->getVersion(); + $this->platformIsSecretKey = $this->getHelper('Magento')->isSecretKeyToUrl(); + + return parent::_beforeToHtml(); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Info/Module.php b/Block/Adminhtml/ControlPanel/Info/Module.php new file mode 100644 index 000000000..d6b915494 --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Info/Module.php @@ -0,0 +1,41 @@ +setId('controlPanelAboutModule'); + // --------------------------------------- + + $this->setTemplate('control_panel/info/module.phtml'); + } + + //######################################## + + protected function _beforeToHtml() + { + $this->moduleName = $this->getHelper('Module')->getName(); + $this->moduleVersion = $this->getHelper('Module')->getVersion(); + $this->moduleRevision = $this->getHelper('Module')->getRevision(); + + return parent::_beforeToHtml(); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Info/Mysql/Info.php b/Block/Adminhtml/ControlPanel/Info/Mysql/Info.php new file mode 100644 index 000000000..ce59cac31 --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Info/Mysql/Info.php @@ -0,0 +1,43 @@ +setId('controlPanelAboutMysqlInfo'); + // --------------------------------------- + + $this->setTemplate('control_panel/info/mysql/info.phtml'); + } + + //######################################## + + protected function _beforeToHtml() + { + $this->mySqlDatabaseName = $this->getHelper('Magento')->getDatabaseName(); + $this->mySqlVersion = $this->getHelper('Client')->getMysqlVersion(); + $this->mySqlApi = $this->getHelper('Client')->getMysqlApiName(); + $this->mySqlPrefix = $this->getHelper('Magento')->getDatabaseTablesPrefix(); + $this->mySqlSettings = $this->getHelper('Client')->getMysqlSettings(); + + return parent::_beforeToHtml(); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Info/Mysql/Integration.php b/Block/Adminhtml/ControlPanel/Info/Mysql/Integration.php new file mode 100644 index 000000000..33f8f8dcb --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Info/Mysql/Integration.php @@ -0,0 +1,104 @@ +setId('controlPanelDatabaseIntegration'); + // --------------------------------------- + + $this->setTemplate('control_panel/info/mysql/integration.phtml'); + } + + //######################################## + + public function getInfoTables() + { + $tablesData = array_merge($this->getGeneralTables(), + $this->getEbayTables(), + $this->getAmazonTables()); + + /** @var Structure $helper */ + $helper = $this->getHelper('Module\Database\Structure'); + + $tablesInfo = array(); + foreach ($tablesData as $category => $tables) { + foreach ($tables as $tableName) { + + $tablesInfo[$category][$tableName] = array( + 'count' => 0, 'url' => '#' + ); + + if (!$helper->isTableReady($tableName)) { + continue; + } + + $tablesInfo[$category][$tableName]['count'] = $helper->getCountOfRecords($tableName); + $tablesInfo[$category][$tableName]['url'] = $this->getUrl( + '*/controlPanel_database/manageTable', array('table' => $tableName) + ); + } + } + + return $tablesInfo; + } + + //######################################## + + private function getGeneralTables() + { + return array( + 'General' => array( + 'm2epro_account', + 'm2epro_listing', + 'm2epro_listing_product', + 'm2epro_listing_other' + ) + ); + } + + private function getAmazonTables() + { + return array( + 'Amazon' => array( + 'm2epro_amazon_account', + 'm2epro_amazon_item', + 'm2epro_amazon_listing', + 'm2epro_amazon_listing_product', + 'm2epro_amazon_listing_other' + ) + ); + } + + private function getEbayTables() + { + return array( + 'Ebay' => array( + 'm2epro_ebay_account', + 'm2epro_ebay_item', + 'm2epro_ebay_listing', + 'm2epro_ebay_listing_product', + 'm2epro_ebay_listing_other' + ) + ); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Info/Mysql/Module.php b/Block/Adminhtml/ControlPanel/Info/Mysql/Module.php new file mode 100644 index 000000000..926834460 --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Info/Mysql/Module.php @@ -0,0 +1,104 @@ +setId('controlPanelDatabaseModule'); + // --------------------------------------- + + $this->setTemplate('control_panel/info/mysql/module.phtml'); + } + + //######################################## + + public function getInfoTables() + { + $tablesData = array_merge($this->getConfigTables(), + $this->getLocksAndChangeTables(), + $this->getAdditionalTables()); + + /** @var Structure $helper */ + $helper = $this->getHelper('Module\Database\Structure'); + + $tablesInfo = array(); + foreach ($tablesData as $category => $tables) { + foreach ($tables as $tableName) { + + $tablesInfo[$category][$tableName] = array( + 'count' => 0, 'url' => '#' + ); + + if (!$helper->isTableReady($tableName)) { + continue; + } + + $tablesInfo[$category][$tableName]['count'] = $helper->getCountOfRecords($tableName); + $tablesInfo[$category][$tableName]['url'] = $this->getUrl( + '*/controlPanel_database/manageTable', array('table' => $tableName) + ); + } + } + + return $tablesInfo; + } + + //######################################## + + private function getConfigTables() + { + return array( + 'Config' => array( + 'm2epro_module_config', + 'm2epro_primary_config', + 'm2epro_synchronization_config', + 'm2epro_cache_config' + ) + ); + } + + private function getLocksAndChangeTables() + { + return array( + 'Additional' => array( + 'm2epro_lock_item', + 'm2epro_product_change', + 'm2epro_order_change', + 'm2epro_operation_history' + ) + ); + } + + private function getAdditionalTables() + { + return array( + 'Processing' => array( + 'm2epro_processing', + 'm2epro_processing_lock', + 'm2epro_request_pending_single', + 'm2epro_request_pending_partial', + 'm2epro_connector_pending_requester_single', + 'm2epro_connector_pending_requester_partial', + ) + ); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Info/Mysql/Summary.php b/Block/Adminhtml/ControlPanel/Info/Mysql/Summary.php new file mode 100644 index 000000000..74e294f5a --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Info/Mysql/Summary.php @@ -0,0 +1,39 @@ +setId('controlPanelAboutMysqlSummary'); + // --------------------------------------- + + $this->setTemplate('control_panel/info/mysql/summary.phtml'); + } + + //######################################## + + protected function _beforeToHtml() + { + $this->mySqlTotal = $this->getHelper('Client')->getMysqlTotals(); + + return parent::_beforeToHtml(); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Info/Php.php b/Block/Adminhtml/ControlPanel/Info/Php.php new file mode 100644 index 000000000..8668dfa3c --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Info/Php.php @@ -0,0 +1,41 @@ +setId('controlPanelAboutPhp'); + // --------------------------------------- + + $this->setTemplate('control_panel/info/php.phtml'); + } + + //######################################## + + protected function _beforeToHtml() + { + $this->phpVersion = $this->getHelper('Client')->getPhpVersion(); + $this->phpApi = $this->getHelper('Client')->getPhpApiName(); + $this->phpSettings = $this->getHelper('Client')->getPhpSettings(); + + return parent::_beforeToHtml(); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Info/System.php b/Block/Adminhtml/ControlPanel/Info/System.php new file mode 100644 index 000000000..9fce27e56 --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Info/System.php @@ -0,0 +1,40 @@ +setId('controlPanelAboutSystem'); + // --------------------------------------- + + $this->setTemplate('control_panel/info/system.phtml'); + } + + //######################################## + + protected function _beforeToHtml() + { + $this->systemName = $this->getHelper('Client')->getSystem(); + $this->systemTime = $this->getHelper('Data')->getCurrentGmtDate(); + + return parent::_beforeToHtml(); + } + + //######################################## +} \ No newline at end of file diff --git a/Plugin/Controller/Adminhtml/System/Config/Edit.php b/Block/Adminhtml/ControlPanel/Inspection/AbstractInspection.php similarity index 52% rename from Plugin/Controller/Adminhtml/System/Config/Edit.php rename to Block/Adminhtml/ControlPanel/Inspection/AbstractInspection.php index 83bde0312..aedccea31 100644 --- a/Plugin/Controller/Adminhtml/System/Config/Edit.php +++ b/Block/Adminhtml/ControlPanel/Inspection/AbstractInspection.php @@ -6,16 +6,17 @@ * @license Commercial use is forbidden */ -namespace Ess\M2ePro\Plugin\Controller\Adminhtml\System\Config; +namespace Ess\M2ePro\Block\Adminhtml\ControlPanel\Inspection; -class Edit +use Ess\M2ePro\Block\Adminhtml\Magento\AbstractBlock; + +abstract class AbstractInspection extends AbstractBlock { //######################################## - public function afterExecute($subject, $result) + public function isShown() { - $result->getConfig()->addPageAsset("Ess_M2ePro::css/help_block.css"); - return $result; + return true; } //######################################## diff --git a/Block/Adminhtml/ControlPanel/Inspection/Caches.php b/Block/Adminhtml/ControlPanel/Inspection/Caches.php new file mode 100644 index 000000000..149a178d5 --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Inspection/Caches.php @@ -0,0 +1,35 @@ +setId('controlPanelInspectionCaches'); + // --------------------------------------- + + $this->setTemplate('control_panel/inspection/caches.phtml'); + } + + //######################################## + + public function isShown() + { + return $this->getHelper('Client\Cache')->isApcAvailable(); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Inspection/ConflictedModules.php b/Block/Adminhtml/ControlPanel/Inspection/ConflictedModules.php new file mode 100644 index 000000000..6a3256a3f --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Inspection/ConflictedModules.php @@ -0,0 +1,35 @@ +setId('controlPanelInspectionConflictedModules'); + // --------------------------------------- + + $this->setTemplate('control_panel/inspection/conflictedModules.phtml'); + } + + //######################################## + + public function isShown() + { + return count($this->getHelper('Magento')->getConflictedModules()) > 0; + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/Development/Inspection/Cron.php b/Block/Adminhtml/ControlPanel/Inspection/Cron.php similarity index 85% rename from Block/Adminhtml/Development/Inspection/Cron.php rename to Block/Adminhtml/ControlPanel/Inspection/Cron.php index 4772f4c27..6271e161a 100644 --- a/Block/Adminhtml/Development/Inspection/Cron.php +++ b/Block/Adminhtml/ControlPanel/Inspection/Cron.php @@ -6,7 +6,7 @@ * @license Commercial use is forbidden */ -namespace Ess\M2ePro\Block\Adminhtml\Development\Inspection; +namespace Ess\M2ePro\Block\Adminhtml\ControlPanel\Inspection; class Cron extends AbstractInspection { @@ -15,7 +15,13 @@ class Cron extends AbstractInspection public function _construct() { parent::_construct(); - $this->setTemplate('Ess_M2ePro::development/inspection/cron.phtml'); + + // Initialization block + // --------------------------------------- + $this->setId('controlPanelInspectionCron'); + // --------------------------------------- + + $this->setTemplate('control_panel/inspection/cron.phtml'); } //######################################## @@ -30,7 +36,7 @@ protected function _beforeToHtml() $this->cronServiceAuthKey = $moduleConfig->getGroupValue('/cron/service/', 'auth_key'); $baseDir = $this->getHelper('Client')->getBaseDirectory(); - $this->cronPhp = 'php -q '.$baseDir.'cron.php -mdefault 1'; + $this->cronPhp = 'php -q '.$baseDir.DIRECTORY_SEPARATOR.'cron.php -mdefault 1'; $baseUrl = $this->getHelper('Magento')->getBaseUrl(); $this->cronGet = 'GET '.$baseUrl.'cron.php'; diff --git a/Block/Adminhtml/ControlPanel/Inspection/DatabaseBrokenTables.php b/Block/Adminhtml/ControlPanel/Inspection/DatabaseBrokenTables.php new file mode 100644 index 000000000..742fac321 --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Inspection/DatabaseBrokenTables.php @@ -0,0 +1,115 @@ +setId('controlPanelInspectionDatabaseBrokenTables'); + // --------------------------------------- + + $this->setTemplate('control_panel/inspection/databaseBrokenTables.phtml'); + + $this->prepareTablesInfo(); + } + + //######################################## + + public function isShown() + { + return !empty($this->emptyTables) || + !empty($this->notInstalledTables) || + !empty($this->crashedTables); + } + + //######################################## + + private function prepareTablesInfo() + { + $this->emptyTables = $this->getEmptyTables(); + $this->notInstalledTables = $this->getNotInstalledTables(); + $this->crashedTables = $this->getCrashedTables(); + } + + //######################################## + + private function getEmptyTables() + { + $helper = $this->getHelper('Module\Database\Structure'); + + $emptyTables = array(); + foreach ($this->getGeneralTables() as $table) { + + if (!$helper->isTableReady($table)) { + continue; + } + + !$helper->getCountOfRecords($table) && $emptyTables[] = $table; + } + + return $emptyTables; + } + + private function getNotInstalledTables() + { + $helper = $this->getHelper('Module\Database\Structure'); + + $notInstalledTables = array(); + foreach ($helper->getMySqlTables() as $tableName) { + !$helper->isTableExists($tableName) && $notInstalledTables[] = $tableName; + } + + return $notInstalledTables; + } + + private function getCrashedTables() + { + $helper = $this->getHelper('Module\Database\Structure'); + + $crashedTables = array(); + foreach ($helper->getMySqlTables() as $tableName) { + + if (!$helper->isTableExists($tableName)) { + continue; + } + + !$helper->isTableStatusOk($tableName) && $crashedTables[] = $tableName; + } + + return $crashedTables; + } + + //######################################## + + private function getGeneralTables() + { + return array( + 'm2epro_primary_config', + 'm2epro_module_config', + 'm2epro_synchronization_config', + 'm2epro_wizard', + 'm2epro_marketplace', + 'm2epro_amazon_marketplace', + 'm2epro_ebay_marketplace', + ); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Inspection/Installation.php b/Block/Adminhtml/ControlPanel/Inspection/Installation.php new file mode 100644 index 000000000..a605ad632 --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Inspection/Installation.php @@ -0,0 +1,63 @@ +cacheConfig = $cacheConfig; + + parent::__construct($context, $data); + } + + //######################################## + + public function _construct() + { + parent::_construct(); + + // Initialization block + // --------------------------------------- + $this->setId('controlPanelInspectionInstallation'); + // --------------------------------------- + + $this->setTemplate('control_panel/inspection/installation.phtml'); + + $this->prepareInfo(); + } + + //######################################## + + protected function prepareInfo() + { + $this->publicLatestVersion = $this->cacheConfig->getGroupValue('/installation/', 'public_last_version'); + $this->buildLatestVersion = $this->cacheConfig->getGroupValue('/installation/', 'build_last_version'); + + $setupCollection = $this->activeRecordFactory->getObject('Setup')->getCollection(); + $setupCollection->addFieldToFilter('version_from', array('notnull' => true)); + $setupCollection->addFieldToFilter('version_to', array('notnull' => true)); + + $this->lastUpgradeDate = $setupCollection->getLastItem()->getData('create_date'); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Inspection/OtherIssues.php b/Block/Adminhtml/ControlPanel/Inspection/OtherIssues.php new file mode 100644 index 000000000..9421e9e2e --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Inspection/OtherIssues.php @@ -0,0 +1,88 @@ +resourceConnection = $resourceConnection; + } + + //######################################## + + public function _construct() + { + parent::_construct(); + + // Initialization block + // --------------------------------------- + $this->setId('controlPanelInspectionOtherIssues'); + // --------------------------------------- + + $this->setTemplate('control_panel/inspection/otherIssues.phtml'); + } + + //######################################## + + public function isShown() + { + return $this->isMagicQuotesEnabled() || + $this->isGdLibraryUnAvailable() || + $this->isZendOpcacheAvailable(); + } + + //######################################## + + public function isMagicQuotesEnabled() + { + return (bool)ini_get('magic_quotes_gpc'); + } + + public function isGdLibraryUnAvailable() + { + return !extension_loaded('gd') || !function_exists('gd_info'); + } + + public function isZendOpcacheAvailable() + { + return $this->getHelper('Client\Cache')->isZendOpcacheAvailable(); + } + + public function isSystemLogNotEmpty() + { + $table = $this->activeRecordFactory->getObject('Log\System')->getResource()->getMainTable(); + + if (!$this->getHelper('Module\Database\Structure')->isTableExists($table)) { + return false; + } + + $totalCount = $this->resourceConnection->getConnection() + ->select() + ->from( + array('log' => $table), + array('count' => new \Zend_Db_Expr('COUNT(*)')) + ) + ->query()->fetchColumn(); + + return (bool)(int)$totalCount; + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/Development/Inspection/Requirements.php b/Block/Adminhtml/ControlPanel/Inspection/Requirements.php similarity index 63% rename from Block/Adminhtml/Development/Inspection/Requirements.php rename to Block/Adminhtml/ControlPanel/Inspection/Requirements.php index ceacd50a0..7eba6ab28 100644 --- a/Block/Adminhtml/Development/Inspection/Requirements.php +++ b/Block/Adminhtml/ControlPanel/Inspection/Requirements.php @@ -6,7 +6,7 @@ * @license Commercial use is forbidden */ -namespace Ess\M2ePro\Block\Adminhtml\Development\Inspection; +namespace Ess\M2ePro\Block\Adminhtml\ControlPanel\Inspection; class Requirements extends AbstractInspection { @@ -15,7 +15,13 @@ class Requirements extends AbstractInspection public function _construct() { parent::_construct(); - $this->setTemplate('Ess_M2ePro::development/inspection/requirements.phtml'); + + // Initialization block + // --------------------------------------- + $this->setId('controlPanelInspectionRequirements'); + // --------------------------------------- + + $this->setTemplate('control_panel/inspection/requirements.phtml'); } //######################################## @@ -23,6 +29,7 @@ public function _construct() protected function _beforeToHtml() { $this->requirements = $this->getHelper('Module')->getRequirementsInfo(); + return parent::_beforeToHtml(); } diff --git a/Block/Adminhtml/ControlPanel/Tabs.php b/Block/Adminhtml/ControlPanel/Tabs.php new file mode 100644 index 000000000..401925b75 --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Tabs.php @@ -0,0 +1,98 @@ +setDestElementId('control_panel_tab_container'); + } + + //######################################## + + protected function _prepareLayout() + { + $activeTab = $this->getRequest()->getParam('tab'); + $allowedTabs = array( + HelperControlPanel::TAB_OVERVIEW, + HelperControlPanel::TAB_INSPECTION, + HelperControlPanel::TAB_DATABASE, + HelperControlPanel::TAB_TOOLS_GENERAL, + HelperControlPanel::TAB_TOOLS_MODULE, + HelperControlPanel::TAB_DEBUG, + ); + + if (!in_array($activeTab, $allowedTabs)) { + $activeTab = HelperControlPanel::TAB_OVERVIEW; + } + + // --------------------------------------- + $params = array('label' => $this->helperFactory->getObject('Module\Translation')->__('Overview')); + if ($activeTab == HelperControlPanel::TAB_OVERVIEW) { + $params['content'] = $this->createBlock('ControlPanel\Tabs\Overview')->toHtml(); + } else { + $params['url'] = $this->getUrl('*/controlPanel/overviewTab'); + } + $this->addTab(HelperControlPanel::TAB_OVERVIEW, $params); + // --------------------------------------- + + $this->addTab(HelperControlPanel::TAB_INSPECTION, array( + 'label' => $this->helperFactory->getObject('Module\Translation')->__('Inspection'), + 'content' => $this->createBlock('ControlPanel\Tabs\Inspection')->toHtml(), + )); + + $this->addTab(HelperControlPanel::TAB_SETUP, array( + 'label' => $this->helperFactory->getObject('Module\Translation')->__('Setup'), + 'content' => $this->createBlock('ControlPanel\Tabs\Setup')->toHtml(), + )); + + // --------------------------------------- + $params = array('label' => $this->helperFactory->getObject('Module\Translation')->__('Database')); + if ($activeTab == HelperControlPanel::TAB_DATABASE) { + $params['content'] = $this->createBlock('ControlPanel\Tabs\Database')->toHtml(); + } else { + $params['url'] = $this->getUrl('*/controlPanel/databaseTab'); + } + $this->addTab(HelperControlPanel::TAB_DATABASE, $params); + // --------------------------------------- + + $this->addTab(HelperControlPanel::TAB_TOOLS_GENERAL, array( + 'label' => $this->helperFactory->getObject('Module\Translation')->__('General Tools'), + 'content' => $this->createBlock('ControlPanel\Tabs\ToolsGeneral')->toHtml(), + )); + + $this->addTab(HelperControlPanel::TAB_TOOLS_MODULE, array( + 'label' => $this->helperFactory->getObject('Module\Translation')->__('Module Tools'), + 'content' => $this->createBlock('ControlPanel\Tabs\ToolsModule')->toHtml(), + )); + + $this->addTab(HelperControlPanel::TAB_DEBUG, array( + 'label' => $this->helperFactory->getObject('Module\Translation')->__('Debug'), + 'content' => $this->createBlock('ControlPanel\Tabs\Debug')->toHtml(), + )); + + $this->setActiveTab($activeTab); + + return parent::_prepareLayout(); + } + + public function _toHtml() + { + return parent::_toHtml() . '
    '; + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Tabs/Command/Group.php b/Block/Adminhtml/ControlPanel/Tabs/Command/Group.php new file mode 100644 index 000000000..d69c6bfc8 --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Tabs/Command/Group.php @@ -0,0 +1,65 @@ +setTemplate('control_panel/tabs/command/group.phtml'); + } + + //######################################## + + protected function _beforeToHtml() + { + $this->enabledComponents = $this->getHelper('Component')->getEnabledComponents(); + + $this->commands = $this->getHelper('View\ControlPanel\Command') + ->parseGeneralCommandsData($this->getControllerName()); + + return parent::_beforeToHtml(); + } + + //######################################## + + public function getCommandLauncherHtml(array $commandRow, $component = null) + { + $href = $commandRow['url']; + $component && $href = rtrim($commandRow['url'], '/')."/component/{$component}/"; + + $target = ''; + $commandRow['new_window'] && $target = 'target="_blank"'; + + $onClick = ''; + $commandRow['confirm'] && $onClick = "return confirm('{$commandRow['confirm']}');"; + if (!empty($commandRow['prompt']['text']) && !empty($commandRow['prompt']['var'])) { + $onClick = <<{$title} +HTML; + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Tabs/Database.php b/Block/Adminhtml/ControlPanel/Tabs/Database.php new file mode 100644 index 000000000..e51f88752 --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Tabs/Database.php @@ -0,0 +1,28 @@ +setId('controlPanelDatabase'); + + $this->_controller = 'adminhtml_controlPanel_tabs_database'; + // --------------------------------------- + + $this->setTemplate('magento/grid/container/only_content.phtml'); + } +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Tabs/Database/Grid.php b/Block/Adminhtml/ControlPanel/Tabs/Database/Grid.php new file mode 100644 index 000000000..9d98e6875 --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Tabs/Database/Grid.php @@ -0,0 +1,375 @@ +customCollectionFactory = $customCollectionFactory; + parent::__construct($context, $backendHelper, $data); + } + + //######################################## + + public function _construct() + { + parent::_construct(); + + $this->_isExport = true; + + // Initialization block + // --------------------------------------- + $this->setId('controlPanelDatabaseGrid'); + // --------------------------------------- + + // Set default values + // --------------------------------------- + $this->setDefaultSort('component'); + $this->setDefaultDir('ASC'); + $this->setSaveParametersInSession(true); + $this->setUseAjax(true); + // --------------------------------------- + } + + protected function _prepareLayout() + { + $this->setPagerVisibility(false); + + return parent::_prepareLayout(); + } + + //######################################## + + protected function _prepareCollection() + { + $magentoHelper = $this->helperFactory->getObject('Magento'); + $structureHelper = $this->helperFactory->getObject('Module\Database\Structure'); + + $tablesList = $magentoHelper->getMySqlTables(); + foreach ($tablesList as &$tableName) { + $tableName = str_replace($magentoHelper->getDatabaseTablesPrefix(), '', $tableName); + } + + $tablesList = array_unique(array_merge($tablesList, $structureHelper->getMySqlTables())); + + /** @var Custom $collection */ + $collection = $this->customCollectionFactory->create(); + + foreach ($tablesList as $tableName) { + + if (!$structureHelper->isModuleTable($tableName)) { + continue; + } + + $tableRow = array( + 'table_name' => $tableName, + 'component' => '', + 'group' => '', + 'is_exist' => $isExists = $structureHelper->isTableExists($tableName), + 'is_crashed' => $isExists ? !$structureHelper->isTableStatusOk($tableName) : false, + 'records' => 0, + 'size' => 0, + 'model' => $structureHelper->getTableModel($tableName) + ); + + if ($tableRow['is_exist'] && !$tableRow['is_crashed']) { + + $tableRow['component'] = $structureHelper->getTableComponent($tableName); + $tableRow['group'] = $structureHelper->getTableGroup($tableName); + $tableRow['size'] = $structureHelper->getDataLength($tableName); + $tableRow['records'] = $structureHelper->getCountOfRecords($tableName); + } + + $collection->addItem(new \Magento\Framework\DataObject($tableRow)); + } + + $collection->setCustomSize($collection->count()); + $this->setCollection($collection); + parent::_prepareCollection(); + $collection->setCustomIsLoaded(true); + + return $this; + } + + protected function _prepareColumns() + { + $this->addColumn('table_name', array( + 'header' => $this->__('Table Name'), + 'align' => 'left', + 'index' => 'table_name', + 'filter_index' => 'table_name', + 'frame_callback' => array($this, 'callbackColumnTableName'), + 'filter_condition_callback' => array($this, '_customColumnFilter'), + )); + + // --------------------------------------- + $options['general'] = 'General'; + $options = array_merge($options, $this->helperFactory->getObject('Component')->getComponentsTitles()); + + $this->addColumn('component', array( + 'header' => $this->__('Component'), + 'align' => 'right', + 'width' => '120px', + 'index' => 'component', + 'type' => 'options', + 'options' => $options, + 'filter_index' => 'component', + 'filter_condition_callback' => array($this, '_customColumnFilter'), + )); + // --------------------------------------- + + // --------------------------------------- + $options = array( + \Ess\M2ePro\Helper\Module\Database\Structure::TABLE_GROUP_CONFIGS => 'Configs', + \Ess\M2ePro\Helper\Module\Database\Structure::TABLE_GROUP_ACCOUNTS => 'Accounts', + \Ess\M2ePro\Helper\Module\Database\Structure::TABLE_GROUP_MARKETPLACES => 'Marketplaces', + \Ess\M2ePro\Helper\Module\Database\Structure::TABLE_GROUP_LISTINGS => 'Listings', + \Ess\M2ePro\Helper\Module\Database\Structure::TABLE_GROUP_LISTINGS => 'Listings', + \Ess\M2ePro\Helper\Module\Database\Structure::TABLE_GROUP_LISTINGS_PRODUCTS => 'Listings Products', + \Ess\M2ePro\Helper\Module\Database\Structure::TABLE_GROUP_LISTINGS_OTHER => 'Listings Other', + \Ess\M2ePro\Helper\Module\Database\Structure::TABLE_GROUP_LOGS => 'Logs', + \Ess\M2ePro\Helper\Module\Database\Structure::TABLE_GROUP_ITEMS => 'Items', + \Ess\M2ePro\Helper\Module\Database\Structure::TABLE_GROUP_PROCESSING => 'Processing', + \Ess\M2ePro\Helper\Module\Database\Structure::TABLE_GROUP_CONNECTORS => 'Connectors', + \Ess\M2ePro\Helper\Module\Database\Structure::TABLE_GROUP_DICTIONARY => 'Dictionary', + \Ess\M2ePro\Helper\Module\Database\Structure::TABLE_GROUP_ORDERS => 'Orders', + \Ess\M2ePro\Helper\Module\Database\Structure::TABLE_GROUP_TEMPLATES => 'Templates', + \Ess\M2ePro\Helper\Module\Database\Structure::TABLE_GROUP_OTHER => 'Other' + ); + + $this->addColumn('group', array( + 'header' => $this->__('Group'), + 'align' => 'right', + 'width' => '100px', + 'index' => 'group', + 'type' => 'options', + 'options' => $options, + 'filter_index' => 'group', + 'filter_condition_callback' => array($this, '_customColumnFilter'), + )); + // --------------------------------------- + + $this->addColumn('records', array( + 'header' => $this->__('Records'), + 'align' => 'right', + 'width' => '100px', + 'index' => 'records', + 'type' => 'number', + 'filter' => false, + )); + + $this->addColumn('size', array( + 'header' => $this->__('Size (Mb)'), + 'align' => 'right', + 'width' => '100px', + 'index' => 'size', + 'filter' => false, + )); + + return parent::_prepareColumns(); + } + + //######################################## + + public function callbackColumnTableName($value, $row, $column, $isExport) + { + if (!$row->getData('is_exist')) { + return "

    {$value} [table is not exists]

    "; + } + + if ($row->getData('is_crashed')) { + return "

    {$value} [table is crashed]

    "; + } + + if (!$row->getData('model')) { + return "

    {$value}

    "; + } + + return "

    {$value}

    "; + } + + //######################################## + + protected function _prepareMassaction() + { + // Set massaction identifiers + // --------------------------------------- + $this->setMassactionIdField('table_name'); + $this->getMassactionBlock()->setFormFieldName('tables'); + $this->getMassactionBlock()->setUseSelectAll(false); + // --------------------------------------- + + // Set edit action + // --------------------------------------- + $this->getMassactionBlock()->addItem('edit', array( + 'label' => $this->__('Edit Table(s)'), + 'url' => $this->getUrl('*/controlPanel_database/manageTables') + )); + // --------------------------------------- + + // Set truncate action + // --------------------------------------- + $this->getMassactionBlock()->addItem('truncate', array( + 'label' => $this->__('Truncate Table(s)'), + 'url' => $this->getUrl('*/controlPanel_database/truncateTables'), + 'confirm' => $this->__('Are you sure?') + )); + // --------------------------------------- + + return parent::_prepareMassaction(); + } + + //######################################## + + protected function _beforeToHtml() + { + parent::_beforeToHtml(); + + $gridJsObj = $this->getId().'JsObject'; + + $this->js->addRequireJs([ + 'jQuery' => 'jquery' + ], <<getUrl('*/controlPanel/databaseTab', array('_current'=>true)); + } + + public function getRowUrl($row) + { + if (!$row->getData('is_exist') || $row->getData('is_crashed') || !$row->getData('model')) { + return false; + } + + return $this->getUrl('*/controlPanel_database/manageTable', + array('table' => $row->getData('table_name'))); + } + + //######################################## + + protected function _addColumnFilterToCollection($column) + { + if ($this->getCollection() && $column->getFilterConditionCallback()) { + call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column); + } + return $this; + } + + //######################################## + + protected function _customColumnFilter($collection, $column) + { + $field = ($column->getFilterIndex()) ? $column->getFilterIndex() : $column->getIndex(); + $condition = $column->getFilter()->getCondition(); + $value = array_pop($condition); + + if ($field && isset($condition)) { + $field == 'table_name' && $this->_filterByTableNameField($field, $value); + ($field == 'component' || $field == 'group') && $this->_filterByField($field, $value); + } + + return $this; + } + + // --------------------------------------- + + protected function _filterByTableNameField($field, $value) + { + /** @var Custom $filteredCollection */ + $filteredCollection = $this->customCollectionFactory->create(); + $value = str_replace(array(' ','%','\\','\''),'',$value); + + foreach ($this->getCollection()->getItems() as $item) { + if (strpos($item->getData($field),$value) !== false) { + $filteredCollection->addItem($item); + } + } + $this->setCollection($filteredCollection); + $filteredCollection->setCustomSize($filteredCollection->count()); + } + + protected function _filterByField($field, $value) + { + /** @var Custom $filteredCollection */ + $filteredCollection = $this->customCollectionFactory->create(); + $filteredItems = $this->getCollection()->getItemsByColumnValue($field,$value); + + foreach ($filteredItems as $item) { + $filteredCollection->addItem($item); + } + $this->setCollection($filteredCollection); + $filteredCollection->setCustomSize($filteredCollection->count()); + } + + //######################################## + + protected function _setCollectionOrder($column) + { + $field = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex(); + $direction = $column->getDir(); + + if ($field && isset($direction)) { + $this->_orderByColumn($field, $direction); + } + + return $this; + } + + // --------------------------------------- + + protected function _orderByColumn($column, $direction) + { + /** @var Custom $sortedCollection */ + $sortedCollection = $this->customCollectionFactory->create(); + + $collection = $this->getCollection()->toArray(); + $collection = $collection['items']; + + $sortByColumn = array(); + foreach ($collection as $item) { + $sortByColumn[] = $item[$column]; + } + + strtolower($direction) == 'asc' && array_multisort($sortByColumn, SORT_ASC, $collection); + strtolower($direction) == 'desc' && array_multisort($sortByColumn, SORT_DESC, $collection); + + foreach ($collection as $item) { + $sortedCollection->addItem(new \Magento\Framework\DataObject($item)); + } + $this->setCollection($sortedCollection); + $sortedCollection->setCustomSize($sortedCollection->count()); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Tabs/Database/Table.php b/Block/Adminhtml/ControlPanel/Tabs/Database/Table.php new file mode 100644 index 000000000..a72ccd228 --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Tabs/Database/Table.php @@ -0,0 +1,138 @@ +cookieManager = $cookieManager; + parent::__construct($context, $data); + } + + //######################################## + + public function _construct() + { + parent::_construct(); + + // Initialization block + // --------------------------------------- + $this->setId('controlPanelDatabaseTable'); + $this->_controller = 'adminhtml_controlPanel_tabs_database_table'; + // --------------------------------------- + + // Set header text + // --------------------------------------- + $tableName = $this->getRequest()->getParam('table'); + $component = $this->getRequest()->getParam('component'); + + $title = $this->__('Manage Table "%table_name%"', $tableName); + if ($this->isMergeModeEnabled() && $component && + $this->getHelper('Module\Database\Structure')->isTableHorizontalParent($tableName)) { + $title .= " [merged {$component} data]"; + } + + $this->pageConfig->getTitle()->prepend($title); + $this->_headerText = $this->__($title); + // --------------------------------------- + + // Set buttons actions + // --------------------------------------- + $this->removeButton('back'); + $this->removeButton('reset'); + $this->removeButton('delete'); + $this->removeButton('add'); + $this->removeButton('save'); + $this->removeButton('edit'); + // --------------------------------------- + + // --------------------------------------- + $url = $this->getHelper('View\ControlPanel')->getPageDatabaseTabUrl(); + $this->addButton('back', array( + 'label' => $this->__('Back'), + 'onclick' => "window.open('{$url}','_blank')", + 'class' => 'back' + )); + // --------------------------------------- + + // --------------------------------------- + $url = $this->getUrl('*/controlPanel_tools/magento', ['action' => 'clearMagentoCache']); + $this->addButton('additional-actions', array( + 'label' => $this->__('Additional Actions'), + 'onclick' => '', + 'class' => 'action-secondary', + 'sort_order' => 100, + 'class_name' => 'Ess\M2ePro\Block\Adminhtml\Magento\Button\DropDown', + 'options' => [ + 'clear-cache' => [ + 'label' => $this->__('Flush Cache'), + 'onclick' => "window.open('{$url}', '_blank');" + ], + ], + )); + // --------------------------------------- + + // --------------------------------------- + $url = $this->getUrl('*/*/truncateTables', array('tables' => $tableName)); + $this->addButton('delete_all', array( + 'label' => $this->__('Truncate Table'), + 'onclick' => 'deleteConfirm(\'Are you sure?\', \''.$url.'\')', + 'class' => 'action-error', + 'sort_order' => 80, + )); + // --------------------------------------- + + // --------------------------------------- + $this->addButton('add_row', array( + 'label' => $this->__('Append Row'), + 'onclick' => 'ControlPanelDatabaseGridObj.openTableCellsPopup(\'add\')', + 'class' => 'action-success', + 'sort_order' => 90, + )); + // --------------------------------------- + + // --------------------------------------- + $helper = $this->getHelper('Module\Database\Structure'); + + if ($helper->isTableHorizontalChild($tableName) || + ($helper->isTableHorizontalParent($tableName) && $this->isMergeModeEnabled() && $component)) { + + $labelAdd = $this->isMergeModeEnabled() ? 'disable' : 'enable'; + + $this->addButton('merge_mode', array( + 'label' => $this->__("Join Full Collection [{$labelAdd}]"), + 'onclick' => 'ControlPanelDatabaseGridObj.switchMergeMode()', + 'class' => !$this->isMergeModeEnabled() ? 'action-success' : 'action-warning', + 'sort_order' => 70, + )); + } + // --------------------------------------- + } + + //######################################## + + public function isMergeModeEnabled() + { + $key = \Ess\M2ePro\Block\Adminhtml\ControlPanel\Tabs\Database\Table\Grid::MERGE_MODE_COOKIE_KEY; + return (bool)$this->cookieManager->getCookie($key); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Tabs/Database/Table/Grid.php b/Block/Adminhtml/ControlPanel/Tabs/Database/Table/Grid.php new file mode 100644 index 000000000..ec87dca3a --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Tabs/Database/Table/Grid.php @@ -0,0 +1,404 @@ +cookieManager = $cookieManager; + $this->databaseTableFactory = $databaseTableFactory; + parent::__construct($context, $backendHelper, $data); + } + + //######################################## + + public function _construct() + { + parent::_construct(); + + // Initialization block + // --------------------------------------- + $this->setId('controlPanelTable'.$this->getRequest()->getParam('table').'Grid'); + // --------------------------------------- + + // Set default values + // --------------------------------------- + $this->setDefaultSort('id'); + $this->setDefaultDir('ASC'); + $this->setSaveParametersInSession(true); + $this->setUseAjax(true); + // --------------------------------------- + + $this->init(); + } + + private function init() + { + $tableName = $this->getRequest()->getParam('table'); + $component = $this->getRequest()->getParam('component'); + $mergeMode = $this->cookieManager->getCookie(self::MERGE_MODE_COOKIE_KEY); + + /** @var \Ess\M2ePro\Model\ControlPanel\Database\TableModel $model */ + $model = $this->databaseTableFactory->create(['data' => [ + 'table_name' => $tableName, + 'merge_mode' => $mergeMode, + 'merge_mode_component' => $component + ]]); + + $this->tableModel = $model; + } + + //######################################## + + protected function _prepareCollection() + { + $this->setCollection($this->tableModel->getModel()->getCollection()); + return parent::_prepareCollection(); + } + + protected function _prepareColumns() + { + foreach ($this->tableModel->getColumns() as $column) { + + $mergeMarkerHtml = ''; + if ($column['is_parent']) { + $mergeMarkerHtml = '[p]'; + } + if ($column['is_child']) { + $mergeMarkerHtml = '[ch]'; + } + + $header = "{$column['name']} {$mergeMarkerHtml}
    "; + $header .= "({$column['type']})"; + + $filterIndex = 'main_table.' . strtolower($column['name']); + if ($column['is_child']) { + $filterIndex = 'second_table.' . strtolower($column['name']); + } + + $params = array( + 'header' => $header, + 'align' => 'left', + 'type' => $this->getColumnType($column), + 'string_limit' => 10000, + 'index' => strtolower($column['name']), + 'filter_index' => $filterIndex, + 'frame_callback' => array($this, 'callbackColumnData'), + + 'is_auto_increment' => strpos($column['extra'], 'increment') !== false, + + 'is_parent' => $column['is_parent'], + 'is_child' => $column['is_child'], + ); + + if ($this->getColumnType($column) == 'datetime') { + $params['filter_time'] = true; + $params['format'] = \IntlDateFormatter::MEDIUM; + } + + $this->addColumn($column['name'], $params); + } + + $this->addColumn('actions_row', array( + 'header' => ' '.$this->__('Actions'), + 'align' => 'left', + 'width' => '70px', + 'type' => 'text', + 'index' => 'actions_row', + 'filter' => false, + 'sortable' => false, + 'frame_callback' => array($this, 'callbackColumnActions') + )); + + return parent::_prepareColumns(); + } + + protected function _beforeToHtml() + { + parent::_beforeToHtml(); + + $urlParams = [ + 'table' => urlencode($this->tableModel->getTableName()), + 'component' => urlencode($this->tableModel->getMergeModeComponent()), + 'merge' => urlencode($this->tableModel->getIsMergeModeEnabled()) + ]; + + $urls = [ + 'controlPanel/deleteTableRows' => $this->getUrl('*/*/deleteTableRows', $urlParams), + 'controlPanel/updateTableCells' => $this->getUrl('*/*/updateTableCells', $urlParams), + 'controlPanel/addTableRow' => $this->getUrl('*/*/addTableRow', $urlParams), + 'controlPanel/getTableCellsPopupHtml' => $this->getUrl('*/*/getTableCellsPopupHtml', $urlParams), + + 'controlPanel/manageTable' => $this->getUrl( + '*/*/manageTable', ['table' => $this->tableModel->getTableName()] + ), + ]; + $this->jsUrl->addUrls($urls); + + $key = self::MERGE_MODE_COOKIE_KEY; + $this->js->addRequireJs([ + 'jQuery' => 'jquery', + 'l' => 'M2ePro/ControlPanel/Database/Grid' + ], <<getId()}'); + window.ControlPanelDatabaseGridObj.afterInitPage(); + window.ControlPanelDatabaseGridObj.setMergeModeCookieKey('{$key}'); + + $$('div.main_cell_container.edit-allowed-class').each(function(el){ + el.observe('mouseover', ControlPanelDatabaseGridObj.mouseOverCell.bind(el)); + el.observe('mouseout', ControlPanelDatabaseGridObj.mouseOutCell.bind(el)); + }); +JS + ); + } + + //######################################## + + protected function _prepareMassaction() + { + // Set massaction identifiers + // --------------------------------------- + $this->setMassactionIdField('id'); + $this->getMassactionBlock()->setFormFieldName('ids'); + // --------------------------------------- + + // --------------------------------------- + $this->getMassactionBlock()->addItem('deleteTableRows', array( + 'label' => $this->__('Delete'), + 'url' => '', + )); + // --------------------------------------- + + // --------------------------------------- + $this->getMassactionBlock()->addItem('updateTableCells', array( + 'label' => $this->__('Update'), + 'url' => '' + )); + // --------------------------------------- + + return parent::_prepareMassaction(); + } + + //######################################## + + public function callbackColumnData($value, $row, $column, $isExport) + { + $rowId = $row->getId(); + $columnId = $column->getId(); + $cellId = 'table_row_cell_'.$columnId.'_'.$rowId; + + if ($this->tableModel->getIsMergeModeEnabled() && $row instanceof ParentAbstractModel && $column['is_child']) { + $value = $row->getChildObject()->getData($columnId); + } + + $tempValue = 'NULL'; + if (!is_null($value)) { + $tempValue = $this->isColumnValueShouldBeCut($value) ? $this->cutColumnValue($value) : $value; + $tempValue = $this->escapeHtml($tempValue); + } + + $inputValue = 'NULL'; + if (!is_null($value)) { + $inputValue = $this->escapeHtml($value); + } + + $editAllowedClass = ''; + if (!$column->getData('is_auto_increment') && strlen($inputValue) < $column->getData('string_limit')) { + $editAllowedClass = 'edit-allowed-class'; + } + + return << + + {$tempValue} + + + + + + +
    +HTML; + } + + public function callbackColumnActions($value, $row, $column, $isExport) + { + $html = << + delete + +HTML; + $helper = $this->getHelper('Module\Database\Structure'); + $componentMode = $row->getData('component_mode'); + + if (!$this->tableModel->getIsMergeModeEnabled() && $componentMode && + $helper->isTableHorizontalParent($this->tableModel->getTableName())) { + + $html .= << + + join + +HTML; + } + + return $html; + } + + //######################################## + + protected function isColumnValueShouldBeCut($originalValue) + { + if (is_null($originalValue)) { + return false; + } + + return strlen($originalValue) > self::MAX_COLUMN_VALUE_LENGTH; + } + + protected function cutColumnValue($originalValue) + { + if (is_null($originalValue)) { + return $originalValue; + } + + return substr($originalValue, 0, self::MAX_COLUMN_VALUE_LENGTH) . ' ...'; + } + + //######################################## + + protected function _addColumnFilterToCollection($column) + { + if (!$this->getCollection()) { + return $this; + } + + $value = $column->getFilter()->getValue(); + $field = ( $column->getFilterIndex() ) ? $column->getFilterIndex() + : $column->getIndex(); + + if ($this->isNullFilter($value)) { + $this->getCollection()->addFieldToFilter($field, array('null' => true)); + return $this; + } + + if ($this->isNotIsNullFilter($value)) { + $this->getCollection()->addFieldToFilter($field, array('notnull' => true)); + return $this; + } + + if ($this->isUnEqualFilter($value)) { + $this->getCollection()->addFieldToFilter($field, array('neq' => preg_replace('/^!=/', '', $value))); + return $this; + + } + + return parent::_addColumnFilterToCollection($column); + } + + private function isNullFilter($value) + { + if (is_string($value) && $value === 'isnull') { + return true; + } + + if (isset($value['from'] ,$value['to']) && $value['from'] === 'isnull' && $value['to'] === 'isnull') { + return true; + } + + return false; + } + + private function isNotIsNullFilter($value) + { + if (is_string($value) && $value === '!isnull') { + return true; + } + + if (isset($value['from'] ,$value['to']) && $value['from'] === '!isnull' && $value['to'] === '!isnull') { + return true; + } + + return false; + } + + private function isUnEqualFilter($value) + { + if (is_string($value) && strpos($value, '!=') === 0) { + return true; + } + + return false; + } + + //######################################## + + public function getGridUrl() + { + return $this->getUrl('*/*/databaseTableGrid', array('_current'=>true)); + } + + public function getRowUrl($row) + { + //return $this->getUrl('*/*/editTableRow', array('id' => $row->getId())); + } + + //######################################## + + private function getColumnType($columnData) + { + if ($columnData['type'] == 'datetime') { + return 'datetime'; + } + + if (preg_match('/int|float|decimal/', $columnData['type'])) { + return 'number'; + } + + return 'text'; + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Tabs/Database/Table/TableCellsPopup.php b/Block/Adminhtml/ControlPanel/Tabs/Database/Table/TableCellsPopup.php new file mode 100644 index 000000000..8f2c87265 --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Tabs/Database/Table/TableCellsPopup.php @@ -0,0 +1,91 @@ +databaseTableFactory = $databaseTableFactory; + parent::__construct($context, $data); + } + + public function _construct() + { + parent::_construct(); + + // Initialization block + // --------------------------------------- + $this->setId('controlPanelDatabaseTableCellsPopup'); + // --------------------------------------- + + $this->setTemplate('control_panel/tabs/database/table_cells_popup.phtml'); + + $this->init(); + } + + private function init() + { + $this->tableName = $this->getRequest()->getParam('table'); + $this->mode = $this->getRequest()->getParam('mode'); + $this->rowsIds = explode(',', $this->getRequest()->getParam('ids')); + + $component = $this->getRequest()->getParam('component'); + $mergeMode = (bool)$this->getRequest()->getParam('merge', false); + + /** @var \Ess\M2ePro\Model\ControlPanel\Database\TableModel $model */ + $model = $this->databaseTableFactory->create(['data' => [ + 'table_name' => $this->tableName, + 'merge_mode' => $mergeMode, + 'merge_mode_component' => $component + ]]); + + $this->tableModel = $model; + } + + //######################################## + + public function isUpdateCellsMode() + { + return $this->mode == self::MODE_UPDATE; + } + + //######################################## + + public function getTableName() + { + return $this->tableName; + } + + public function getIds() + { + return $this->rowsIds; + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Tabs/Debug.php b/Block/Adminhtml/ControlPanel/Tabs/Debug.php new file mode 100644 index 000000000..f8550240a --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Tabs/Debug.php @@ -0,0 +1,84 @@ +setId('controlPanelDebug'); + // --------------------------------------- + + $this->setTemplate('control_panel/tabs/debug.phtml'); + } + + //######################################## + + protected function _beforeToHtml() + { + $this->isMagentoDevelopmentModeEnabled = $this->getHelper('Magento')->isDeveloper(); + $this->isDevelopmentModeEnabled = $this->getHelper('Module')->isDevelopmentMode(); + $this->isMaintenanceEnabled = $this->getHelper('Module\Maintenance\Debug')->isEnabled(); + + $this->commands = $this->getHelper('View\ControlPanel\Command') + ->parseDebugCommandsData(\Ess\M2ePro\Helper\View\ControlPanel\Command::CONTROLLER_DEBUG); + + // --------------------------------------- + $url = $this->getUrl('*/controlPanel_debug/enableMaintenanceMode/'); + $data = array( + 'label' => $this->__('Enable'), + 'onclick' => 'setLocation(\'' . $url . '\');', + 'class' => 'enable_maintenance' + ); + $buttonBlock = $this->createBlock('Magento\Button')->setData($data); + $this->setChild('enable_maintenance',$buttonBlock); + + $url = $this->getUrl('*/controlPanel_debug/disableMaintenanceMode/'); + $data = array( + 'label' => $this->__('Disable'), + 'onclick' => 'setLocation(\'' . $url . '\');', + 'class' => 'disable_maintenance' + ); + $buttonBlock = $this->createBlock('Magento\Button')->setData($data); + $this->setChild('disable_maintenance',$buttonBlock); + // --------------------------------------- + + // --------------------------------------- + $url = $this->getUrl('*/controlPanel_debug/enableDevelopmentMode/'); + $data = array( + 'label' => $this->__('Enable'), + 'onclick' => 'setLocation(\'' . $url . '\');', + 'class' => 'enable_development_mode' + ); + $buttonBlock = $this->createBlock('Magento\Button')->setData($data); + $this->setChild('enable_development_mode',$buttonBlock); + + $url = $this->getUrl('*/controlPanel_debug/disableDevelopmentMode/'); + $data = array( + 'label' => $this->__('Disable'), + 'onclick' => 'setLocation(\'' . $url . '\');', + 'class' => 'disable_development_mode' + ); + $buttonBlock = $this->createBlock('Magento\Button')->setData($data); + $this->setChild('disable_development_mode',$buttonBlock); + // --------------------------------------- + + return parent::_beforeToHtml(); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Tabs/Inspection.php b/Block/Adminhtml/ControlPanel/Tabs/Inspection.php new file mode 100644 index 000000000..6c6be6e81 --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Tabs/Inspection.php @@ -0,0 +1,61 @@ +setId('controlPanelInspection'); + // --------------------------------------- + + $this->setTemplate('control_panel/tabs/inspection.phtml'); + } + + //######################################## + + protected function _beforeToHtml() + { + // --------------------------------------- + $this->setChild('requirements', $this->getLayout()->createBlock( + '\Ess\M2ePro\Block\Adminhtml\ControlPanel\Inspection\Requirements' + )); + $this->setChild('cron', $this->getLayout()->createBlock( + '\Ess\M2ePro\Block\Adminhtml\ControlPanel\Inspection\Cron' + )); + // --------------------------------------- + + // --------------------------------------- + $this->setChild('caches', $this->getLayout()->createBlock( + '\Ess\M2ePro\Block\Adminhtml\ControlPanel\Inspection\Caches' + )); + $this->setChild('conflicted_modules', $this->getLayout()->createBlock( + '\Ess\M2ePro\Block\Adminhtml\ControlPanel\Inspection\ConflictedModules' + )); + $this->setChild('database_broken', $this->getLayout()->createBlock( + '\Ess\M2ePro\Block\Adminhtml\ControlPanel\Inspection\DatabaseBrokenTables' + )); + $this->setChild('other_issues', $this->getLayout()->createBlock( + '\Ess\M2ePro\Block\Adminhtml\ControlPanel\Inspection\OtherIssues' + )); + // --------------------------------------- + + return parent::_beforeToHtml(); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Tabs/Overview.php b/Block/Adminhtml/ControlPanel/Tabs/Overview.php new file mode 100644 index 000000000..c16b8afd5 --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Tabs/Overview.php @@ -0,0 +1,56 @@ +setId('controlPanelOverview'); + // --------------------------------------- + + $this->setTemplate('control_panel/tabs/overview.phtml'); + } + + //######################################## + + protected function _beforeToHtml() + { + $this->setChild('actual_info', $this->getLayout()->createBlock( + '\Ess\M2ePro\Block\Adminhtml\ControlPanel\Info\Actual' + )); + + $this->setChild('location_info', $this->getLayout()->createBlock( + '\Ess\M2ePro\Block\Adminhtml\ControlPanel\Info\Location' + )); + + $this->setChild('database_module', $this->getLayout()->createBlock( + '\Ess\M2ePro\Block\Adminhtml\ControlPanel\Info\Mysql\Module' + )); + + $this->setChild('database_integration', $this->getLayout()->createBlock( + '\Ess\M2ePro\Block\Adminhtml\ControlPanel\Info\Mysql\Integration' + )); + + return parent::_beforeToHtml(); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Tabs/Setup.php b/Block/Adminhtml/ControlPanel/Tabs/Setup.php new file mode 100644 index 000000000..e4ba76c4a --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Tabs/Setup.php @@ -0,0 +1,48 @@ +setId('controlPanelSetup'); + // --------------------------------------- + + $this->setTemplate('control_panel/tabs/setup.phtml'); + } + + //######################################## + + protected function _beforeToHtml() + { + $this->setChild('inspection', $this->getLayout()->createBlock( + '\Ess\M2ePro\Block\Adminhtml\ControlPanel\Inspection\Installation' + )); + + $this->setChild('setup_info', $this->getLayout()->createBlock( + '\Ess\M2ePro\Block\Adminhtml\ControlPanel\Info\Installation' + )); + + return parent::_beforeToHtml(); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Tabs/ToolsGeneral.php b/Block/Adminhtml/ControlPanel/Tabs/ToolsGeneral.php new file mode 100644 index 000000000..a294e721e --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Tabs/ToolsGeneral.php @@ -0,0 +1,39 @@ +setId('controlPanelToolsGeneral'); + // --------------------------------------- + + $this->setTemplate('control_panel/tabs/tools_general.phtml'); + } + + //######################################## + + protected function _beforeToHtml() + { + $this->setChild('tabs', $this->createBlock('ControlPanel\Tabs\ToolsGeneral\Tabs')); + return parent::_beforeToHtml(); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Tabs/ToolsGeneral/Tabs.php b/Block/Adminhtml/ControlPanel/Tabs/ToolsGeneral/Tabs.php new file mode 100644 index 000000000..4c278834d --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Tabs/ToolsGeneral/Tabs.php @@ -0,0 +1,106 @@ +setId('controlPanelToolsGeneralTabs'); + // --------------------------------------- + + $this->setDestElementId('tools_general_tabs'); + } + + //######################################## + + protected function _beforeToHtml() + { + $this->addTab( + 'general', + [ + 'label' => __('General'), + 'title' => __('General'), + 'content' => $this->getLayout()->createBlock( + '\Ess\M2ePro\Block\Adminhtml\ControlPanel\Tabs\Command\Group', + '', + [ + 'data' => [ + 'controller_name' => Command::CONTROLLER_TOOLS_M2EPRO_GENERAL + ] + ] + )->toHtml() + ] + ); + + $this->addTab( + 'install', + [ + 'label' => __('Install'), + 'title' => __('Install'), + 'content' => $this->getLayout()->createBlock( + '\Ess\M2ePro\Block\Adminhtml\ControlPanel\Tabs\Command\Group', + '', + [ + 'data' => [ + 'controller_name' => Command::CONTROLLER_TOOLS_M2EPRO_INSTALL + ] + ] + )->toHtml() + ] + ); + + $this->addTab( + 'magento', + [ + 'label' => __('Magento'), + 'title' => __('Magento'), + 'content' => $this->getLayout()->createBlock( + '\Ess\M2ePro\Block\Adminhtml\ControlPanel\Tabs\Command\Group', + '', + [ + 'data' => [ + 'controller_name' => Command::CONTROLLER_TOOLS_MAGENTO + ] + ] + )->toHtml() + ] + ); + + $this->addTab( + 'additional', + [ + 'label' => __('Additional'), + 'title' => __('Additional'), + 'content' => $this->getLayout()->createBlock( + '\Ess\M2ePro\Block\Adminhtml\ControlPanel\Tabs\Command\Group', + '', + [ + 'data' => [ + 'controller_name' => Command::CONTROLLER_TOOLS_ADDITIONAL + ] + ] + )->toHtml() + ] + ); + + return parent::_beforeToHtml(); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Tabs/ToolsModule.php b/Block/Adminhtml/ControlPanel/Tabs/ToolsModule.php new file mode 100644 index 000000000..27794390b --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Tabs/ToolsModule.php @@ -0,0 +1,38 @@ +setId('controlPanelToolsModule'); + // --------------------------------------- + + $this->setTemplate('control_panel/tabs/tools_module.phtml'); + } + + //######################################## + + protected function _beforeToHtml() + { + $this->setChild('tabs', $this->createBlock('ControlPanel\Tabs\ToolsModule\Tabs')); + return parent::_beforeToHtml(); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/ControlPanel/Tabs/ToolsModule/Tabs.php b/Block/Adminhtml/ControlPanel/Tabs/ToolsModule/Tabs.php new file mode 100644 index 000000000..e1322646b --- /dev/null +++ b/Block/Adminhtml/ControlPanel/Tabs/ToolsModule/Tabs.php @@ -0,0 +1,89 @@ +setId('controlPanelToolsModuleTabs'); + // --------------------------------------- + + $this->setDestElementId('tools_module_tabs'); + } + + //######################################## + + protected function _beforeToHtml() + { + $this->addTab( + 'module', + [ + 'label' => __('Module'), + 'title' => __('Module'), + 'content' => $this->getLayout()->createBlock( + '\Ess\M2ePro\Block\Adminhtml\ControlPanel\Tabs\Command\Group', + '', + [ + 'data' => [ + 'controller_name' => Command::CONTROLLER_MODULE_MODULE + ] + ] + )->toHtml() + ] + ); + + $this->addTab( + 'synchronization', + [ + 'label' => __('Synchronization'), + 'title' => __('Synchronization'), + 'content' => $this->getLayout()->createBlock( + '\Ess\M2ePro\Block\Adminhtml\ControlPanel\Tabs\Command\Group', + '', + [ + 'data' => [ + 'controller_name' => Command::CONTROLLER_MODULE_SYNCHRONIZATION + ] + ] + )->toHtml() + ] + ); + + $this->addTab( + 'integration', + [ + 'label' => __('Integration'), + 'title' => __('Integration'), + 'content' => $this->getLayout()->createBlock( + '\Ess\M2ePro\Block\Adminhtml\ControlPanel\Tabs\Command\Group', + '', + [ + 'data' => [ + 'controller_name' => Command::CONTROLLER_MODULE_INTEGRATION + ] + ] + )->toHtml() + ] + ); + + return parent::_beforeToHtml(); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/Developers/Tabs/CronJobDetails.php b/Block/Adminhtml/Developers/Tabs/CronJobDetails.php index 5b5c15d86..8ba468c25 100644 --- a/Block/Adminhtml/Developers/Tabs/CronJobDetails.php +++ b/Block/Adminhtml/Developers/Tabs/CronJobDetails.php @@ -57,10 +57,10 @@ protected function _prepareLayout()

    To provide proper work of Magento Cron Job, primary correct settings are required.

    +

    In the list below you can find which Cron Job type is used in your system, the date of the last synchronization run and notices about the Magento Cron settings which might be helpful if you need to configure Magento Cron.

    - HTML ) ] @@ -102,8 +102,8 @@ protected function _prepareLayout() 'note', [ 'label' => $this->__('Last Run'), - 'text' => "{$cronLastRunTime}" - . ($this->cronIsNotWorking ? '' : ' (' . $this->__('not working') . ')'), + 'text' => "{$cronLastRunTime}" . + $this->cronIsNotWorking ?: ' (' .$this->__('not working'). ')', 'style' => !$this->cronIsNotWorking ?: 'color: red' ] ); @@ -186,20 +186,6 @@ protected function _prepareLayout() ); } - if (!$this->getData('is_support_mode')) { - $fieldSet->addField('setup_instruction_schedule', - 'note', - [ - 'label' => $this->__('Cron Schedule Table'), - 'text' => "getUrl('*/adminhtml_development_inspection/cronScheduleTable')} - \" target=\"_blank\"> - {$this->__('Show')} - " - ] - ); - } - $fieldSet->addField('recommendation_message', 'note', [ diff --git a/Block/Adminhtml/Developers/Tabs/DirectDatabaseChanges.php b/Block/Adminhtml/Developers/Tabs/DirectDatabaseChanges.php index 1d655cf43..d5c11e1c4 100644 --- a/Block/Adminhtml/Developers/Tabs/DirectDatabaseChanges.php +++ b/Block/Adminhtml/Developers/Tabs/DirectDatabaseChanges.php @@ -55,19 +55,20 @@ protected function _prepareForm() change leads to inability to deliver these changes to the channels (eBay, Amazon, etc.).


    If you are using Magmi Import Tool to update the Product Data, which implements changes directly into the Magento Database, please, use a - Magmi Plugin However, if you are a developer and + Magmi Plugin + However, if you are a developer and change the Product Data directly in the Database, you can use a predefined - M2E Pro Models


    + M2E Pro Models


    Only in case you cannot use these features, we would recommend you to enable
    an additional option - Track Direct Database Changes.


    -

    Warning: Track Вirect Database changes feature is resource-intensive and may +

    Warning: Track Direct Database changes feature is resource-intensive and may affect Performance of your Magento Site and Synchronization with Channels. Choose 'Yes' only if you cannot use other predefined M2E Pro Models and you are absolutely confident that you need to use this functionality.

    HTML , - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/yIQVAQ'), - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/xYQVAQ') + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/yIQVAQ'), + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/xYQVAQ') ) ] ); diff --git a/Block/Adminhtml/Developers/Tabs/MagmiPlugin.php b/Block/Adminhtml/Developers/Tabs/MagmiPlugin.php index 0f0885917..a5f1e8e96 100644 --- a/Block/Adminhtml/Developers/Tabs/MagmiPlugin.php +++ b/Block/Adminhtml/Developers/Tabs/MagmiPlugin.php @@ -32,16 +32,16 @@ protected function _toHtml()

    Note: It is strongly recommended to install M2E Pro Plugin for Magmi Import Tool to prevent data re-synchronization between eBay/Amazon and Magento values.

    More detailed information about the Plugin, i.e. how to install, update and use it, you can find - here


    + here


    Please, remember that, along with the Plugin for Magmi Import Tool, the predefined M2E Pro Models could be used by developers to modify the code in case the Product Changes are implemented directly into the Magento Database via an external script/tool. - More detailed information can be found here

    + More detailed information can be found here

    HTML , - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/yIQVAQ'), - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/xYQVAQ') + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/yIQVAQ'), + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/xYQVAQ') ); return "
    {$text}
    " . parent::_toHtml(); } diff --git a/Block/Adminhtml/Developers/Tabs/PerformanceNotes.php b/Block/Adminhtml/Developers/Tabs/PerformanceNotes.php index 2bb45a3bd..fbc05c15b 100644 --- a/Block/Adminhtml/Developers/Tabs/PerformanceNotes.php +++ b/Block/Adminhtml/Developers/Tabs/PerformanceNotes.php @@ -62,10 +62,11 @@ protected function _toHtml() to one M2E Pro Listing, this will make your interface work more slowly.


    -

    Full detailed information you can find here

    +

    Full detailed information you can find + here

    HTML , - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/z4QVAQ') + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/z4QVAQ') ) ]]); return $helpBlock->toHtml() . parent::_toHtml(); diff --git a/Block/Adminhtml/Developers/Tabs/SynchronizationLog.php b/Block/Adminhtml/Developers/Tabs/SynchronizationLog.php index d7970e622..2c592e36d 100644 --- a/Block/Adminhtml/Developers/Tabs/SynchronizationLog.php +++ b/Block/Adminhtml/Developers/Tabs/SynchronizationLog.php @@ -55,7 +55,7 @@ protected function _toHtml() 3rd Party Listings Synchronization.


    The records about Orders, Inventory and 3rd party Listings Synchronization are displayed
    only in those cases when it results in warning or error messages.

    ', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/MAAJAQ#Logs.-SynchronizationLog') + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/MAAJAQ#Logs.-SynchronizationLog') ) ]]); diff --git a/Block/Adminhtml/Developers/Tabs/SynchronizationLog/Grid.php b/Block/Adminhtml/Developers/Tabs/SynchronizationLog/Grid.php index 4f1afc2f0..9393ae43f 100644 --- a/Block/Adminhtml/Developers/Tabs/SynchronizationLog/Grid.php +++ b/Block/Adminhtml/Developers/Tabs/SynchronizationLog/Grid.php @@ -89,6 +89,7 @@ protected function _prepareColumns() 'header' => $this->__('Creation Date'), 'align' => 'left', 'type' => 'datetime', + 'filter_time' => true, // 'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM), 'index' => 'create_date' )); diff --git a/Block/Adminhtml/Developers/Tabs/SystemRequirements.php b/Block/Adminhtml/Developers/Tabs/SystemRequirements.php index 4d41338ad..5bcb457ac 100644 --- a/Block/Adminhtml/Developers/Tabs/SystemRequirements.php +++ b/Block/Adminhtml/Developers/Tabs/SystemRequirements.php @@ -130,6 +130,19 @@ protected function _beforeToHtml() ] ); + $tablesPrefix = $this->getHelper('Magento')->getDatabaseTablesPrefix(); + if (empty($tablesPrefix)) { + $tablesPrefix = ''.$this->__('disabled').''; + } + + $fieldSet->addField('mysql_tables_prefix', + 'note', + [ + 'label' => $this->__('Tables Prefix'), + 'text' => $tablesPrefix + ] + ); + $mySqlSettings = $this->getHelper('Client')->getMysqlSettings(); $fieldSet->addField('mysql_timeout', diff --git a/Block/Adminhtml/Development/Inspection/AbstractInspection.php b/Block/Adminhtml/Development/Inspection/AbstractInspection.php deleted file mode 100644 index 0ed602db1..000000000 --- a/Block/Adminhtml/Development/Inspection/AbstractInspection.php +++ /dev/null @@ -1,37 +0,0 @@ -formFactory = $formFactory; - parent::__construct($context, $data); - } - - //######################################## - - protected function isShown() - { - return true; - } - - //######################################## -} \ No newline at end of file diff --git a/Block/Adminhtml/Ebay/Account.php b/Block/Adminhtml/Ebay/Account.php index 59da50ed4..77f344440 100644 --- a/Block/Adminhtml/Ebay/Account.php +++ b/Block/Adminhtml/Ebay/Account.php @@ -24,13 +24,36 @@ protected function _prepareLayout() 3rd Party Listings import including options of Mapping them to Magento Products and Moving them to M2E Pro Listings, etc. can be specified for each Account separately.


    Note: eBay Account can be deleted only if it is not being used for any of M2E Pro Listings.


    -

    More detailed information you can find here.

    HTML - , - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/4gEtAQ') + ) ]); + $this->jsUrl->addUrls($this->getHelper('Data')->getControllerActions('Ebay\Account\Feedback')); + + $this->jsTranslator->addTranslations([ + 'Should be between 2 and 80 characters long.' => $this->__('Should be between 2 and 80 characters long.') + ]); + return parent::_prepareLayout(); } + + protected function _toHtml() + { + $this->js->add(<<getChildBlock('grid')->getId()}' + ); + }); +JS + ); + + return parent::_toHtml(); + } + } \ No newline at end of file diff --git a/Block/Adminhtml/Ebay/Account/Edit.php b/Block/Adminhtml/Ebay/Account/Edit.php index 77d06c36e..5286c65ff 100644 --- a/Block/Adminhtml/Ebay/Account/Edit.php +++ b/Block/Adminhtml/Ebay/Account/Edit.php @@ -46,8 +46,8 @@ protected function _construct() )); $saveButtonsProps = []; - if ($this->getHelper('Data\GlobalData')->getValue('temp_data') && - $this->getHelper('Data\GlobalData')->getValue('temp_data')->getId()) { + if ($this->getHelper('Data\GlobalData')->getValue('edit_account') && + $this->getHelper('Data\GlobalData')->getValue('edit_account')->getId()) { $this->addButton('delete', array( 'label' => $this->__('Delete'), @@ -69,7 +69,7 @@ protected function _construct() 'label' => $this->__('Save And Continue Edit'), 'class' => 'add', 'button_class' => '', - 'onclick' => 'EbayAccountObj.saveAndEditClick(\'\')', + 'onclick' => 'EbayAccountObj.saveAndEditClick(\'\', \'ebayAccountEditTabs\')', 'class_name' => 'Ess\M2ePro\Block\Adminhtml\Magento\Button\SplitButton', 'options' => $saveButtonsProps ]; diff --git a/Block/Adminhtml/Ebay/Account/Edit/Tabs.php b/Block/Adminhtml/Ebay/Account/Edit/Tabs.php index 8fdb36c3c..411eee675 100644 --- a/Block/Adminhtml/Ebay/Account/Edit/Tabs.php +++ b/Block/Adminhtml/Ebay/Account/Edit/Tabs.php @@ -9,6 +9,8 @@ class Tabs extends AbstractTabs protected function _construct() { parent::_construct(); + + $this->setId('ebayAccountEditTabs'); $this->setDestElementId('edit_form'); } @@ -25,8 +27,8 @@ protected function _beforeToHtml() ] ); - if ($this->getHelper('Data\GlobalData')->getValue('temp_data') && - $this->getHelper('Data\GlobalData')->getValue('temp_data')->getId()) { + if ($this->getHelper('Data\GlobalData')->getValue('edit_account') && + $this->getHelper('Data\GlobalData')->getValue('edit_account')->getId()) { $this->addTab('listingOther', array( 'label' => $this->__('3rd Party Listings'), @@ -51,20 +53,22 @@ protected function _beforeToHtml() 'Ebay\Account\Edit\Tabs\Order' )->toHtml() )); - - // TODO NOT SUPPORTED FEATURES -/* $this->addTab('feedback', array( + + $this->addTab('feedback', array( 'label' => $this->__('Feedback'), 'title' => $this->__('Feedback'), 'content' => $this->createBlock( 'Ebay\Account\Edit\Tabs\Feedback' )->toHtml() - ));*/ + )); } $this->setActiveTab($this->getRequest()->getParam('tab', 'general')); $this->jsUrl->addUrls($this->getHelper('Data')->getControllerActions('Ebay\Account')); + $this->jsUrl->addUrls($this->getHelper('Data')->getControllerActions('Ebay\Account\Feedback\Template', [ + 'account_id' => $this->getRequest()->getParam('id') + ])); $this->jsUrl->add( $this->getUrl('*/ebay_account/beforeGetToken',array('_current' => true)), 'ebay_account/beforeGetToken' ); @@ -82,10 +86,10 @@ protected function _beforeToHtml() 'The specified Title is already used for other Account. Account Title must be unique.' => $this->__( 'The specified Title is already used for other Account. Account Title must be unique.' ), - 'Be attentive! By Deleting Account you delete all information on it from M2E Pro Server. - This will cause inappropriate work of all Accounts\' copies.' => $this->__( - 'Be attentive! By Deleting Account you delete all information on it from M2E Pro Server. - This will cause inappropriate work of all Accounts\' copies.' + 'Be attentive! By Deleting Account you delete all information on it from M2E Pro Server. ' + . 'This will cause inappropriate work of all Accounts\' copies.' => $this->__( + 'Be attentive! By Deleting Account you delete all information on it from M2E Pro Server. ' + . 'This will cause inappropriate work of all Accounts\' copies.' ), 'No Customer entry is found for specified ID.' => $this->__('No Customer entry is found for specified ID.'), 'If Yes is chosen, you must select at least one Attribute for Product Mapping.' => $this->__( diff --git a/Block/Adminhtml/Ebay/Account/Edit/Tabs/Feedback.php b/Block/Adminhtml/Ebay/Account/Edit/Tabs/Feedback.php new file mode 100644 index 000000000..f02358e1e --- /dev/null +++ b/Block/Adminhtml/Ebay/Account/Edit/Tabs/Feedback.php @@ -0,0 +1,254 @@ +getHelper('Data\GlobalData')->getValue('edit_account'); + $formData = !is_null($account) ? array_merge($account->getData(), $account->getChildObject()->getData()) : []; + + $defaults = array( + 'feedbacks_receive' => \Ess\M2ePro\Model\Ebay\Account::FEEDBACKS_RECEIVE_NO, + 'feedbacks_auto_response' => \Ess\M2ePro\Model\Ebay\Account::FEEDBACKS_AUTO_RESPONSE_NONE, + 'feedbacks_auto_response_only_positive' => + \Ess\M2ePro\Model\Ebay\Account::FEEDBACKS_AUTO_RESPONSE_ONLY_POSITIVE_NO + ); + $formData = array_merge($defaults, $formData); + $this->setData('form_data', $formData); + + $feedbacksReceive = $this->getHelper('Data')->escapeJs($formData['feedbacks_receive']); + $feedbacksAutoResponse = $this->getHelper('Data')->escapeJs($formData['feedbacks_auto_response']); + + $form = $this->_formFactory->create(); + + $form->addField( + 'ebay_accounts_feedback', + self::HELP_BLOCK, + [ + 'content' => $this->__( + 'Choose how you want to deal with Feedback from your eBay Buyers.

    + If you enable Import Feedback from Buyers option, you can also choose whether to set up automatic responses.

    + More detailed information about ability to work with this Page you can find + here.', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/OAAJAQ')) + ] + ); + + $fieldset = $form->addFieldset( + 'general', + [ + 'legend' => $this->__('General'), + 'collapsable' => false + ] + ); + + $fieldset->addField( + 'feedbacks_receive', + 'select', + [ + 'html_id' => 'feedbacks_receive', + 'name' => 'feedbacks_receive', + 'label' => $this->__('Import Feedback'), + 'values' => [ + Account::FEEDBACKS_RECEIVE_YES => $this->__('Yes'), + Account::FEEDBACKS_RECEIVE_NO => $this->__('No'), + ], + 'value' => $formData['feedbacks_receive'], + 'tooltip' => $this->__( + 'Choose whether to Import Feedback from eBay Buyers into Magento.' + ) + ] + ); + + $fieldset->addField( + 'feedbacks_auto_response', + 'select', + [ + 'html_id' => 'feedbacks_auto_response', + 'name' => 'feedbacks_auto_response', + 'label' => $this->__('Auto-response'), + 'values' => [ + Account::FEEDBACKS_AUTO_RESPONSE_NONE => $this->__('Disabled'), + Account::FEEDBACKS_AUTO_RESPONSE_CYCLED => $this->__('Cycle Mode'), + Account::FEEDBACKS_AUTO_RESPONSE_RANDOM => $this->__('Random Mode') + ], + 'value' => $formData['feedbacks_auto_response'], + 'tooltip' => $this->__( + 'Cycle Mode cycles through the template responses you set up below in turn.
    + Random Mode uses a random template response.
    + Disabled means no automatic responses to Feedback will be made.' + ), + 'field_extra_attributes' => 'id="feedbacks_auto_response_container" ' . + (($formData['feedbacks_receive'] == Account::FEEDBACKS_RECEIVE_NO) ? + 'style="display: none;"' : '') + ] + ); + + $fieldset->addField( + 'feedbacks_auto_response_only_positive', + 'select', + [ + 'html_id' => 'feedbacks_auto_response_only_positive', + 'name' => 'feedbacks_auto_response_only_positive', + 'label' => $this->__('Send to'), + 'values' => [ + Account::FEEDBACKS_AUTO_RESPONSE_ONLY_POSITIVE_NO => $this->__('All'), + Account::FEEDBACKS_AUTO_RESPONSE_ONLY_POSITIVE_YES => $this->__('Positive') + ], + 'value' => $formData['feedbacks_auto_response_only_positive'], + 'tooltip' => $this->__( + 'Choose whether to respond to All Feedback (positive, neutral or negative) or Positive Feedback only.' + ), + 'field_extra_attributes' => 'id="feedbacks_auto_response_only_positive_container" ' . + (($formData['feedbacks_receive'] == Account::FEEDBACKS_RECEIVE_NO || + $formData['feedbacks_auto_response'] == Account::FEEDBACKS_AUTO_RESPONSE_NONE) ? + 'style="display: none;"' : '') + ] + ); + + $this->setForm($form); + + $this->js->add(<<css->add(<< table { + margin-left: calc(50% - 115px); +} + +CSS + ); + + $addBtn = $this->createBlock('Magento\Button') + ->setData(array( + 'onclick' => 'EbayAccountObj.openFeedbackTemplatePopup();', + 'label' => $this->__('Add Template'), + 'class' => 'add_feedback_template_button primary' + ))->toHtml(); + + $formData = $this->getData('form_data'); + + + /** @var \Ess\M2ePro\Block\Adminhtml\Ebay\Account\Edit\Tabs\Feedback\Template\Grid $grid */ + $grid = $this->createBlock('Ebay\Account\Edit\Tabs\Feedback\Template\Grid'); + $gridHtml = $grid->toHtml(); + + $showTemplates = ( + $formData['feedbacks_receive'] == Account::FEEDBACKS_RECEIVE_YES && + $formData['feedbacks_auto_response'] != Account::FEEDBACKS_AUTO_RESPONSE_NONE + ); + $gridContainerStyle = $showTemplates ? '' : 'style="display: none;"'; + + $gridStyle = $grid->getCollection()->getSize() > 0 ? + '' : 'style="display: none;"'; + + $showAddTemplateBtn = $grid->getCollection()->getSize() > 0 ? + 'style="display: none;"' : ''; + + $html = parent::_toHtml(); + + return << +
    + + + + + + + +
    + {$addBtn} +
    + +
    +
    + {$gridHtml} + + + + + + +
    + {$addBtn} +
    +
    + +HTML; + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/Ebay/Account/Edit/Tabs/Feedback/Template/Form.php b/Block/Adminhtml/Ebay/Account/Edit/Tabs/Feedback/Template/Form.php new file mode 100644 index 000000000..fba16c3f1 --- /dev/null +++ b/Block/Adminhtml/Ebay/Account/Edit/Tabs/Feedback/Template/Form.php @@ -0,0 +1,68 @@ +getHelper('Data\GlobalData')->getValue('edit_template'); + + $form = $this->_formFactory->create( + ['data' => [ + 'id' => 'edit_feedback_template_form', + 'action' => 'javascript:void(0)', + 'method' => 'post', + ]] + ); + + $form->addField( + 'id', + 'hidden', + [ + 'name' => 'id' + ] + ); + + $form->addField( + 'account_id', + 'hidden', + [ + 'name' => 'account_id', + 'value' => $this->getRequest()->getParam('account_id') + ] + ); + + + $fieldset = $form->addFieldset( + 'edit_feedback_template', + [] + ); + + $fieldset->addField( + 'body', + 'textarea', + [ + 'name' => 'body', + 'required' => true, + 'label' => $this->__('Message'), + 'field_extra_attributes' => 'style="margin-top: 30px;"' + ] + ); + + if ($template) { + $form->addValues($template->getData()); + } + + $form->setUseContainer(true); + $this->setForm($form); + + return parent::_prepareForm(); + } +} \ No newline at end of file diff --git a/Block/Adminhtml/Ebay/Account/Edit/Tabs/Feedback/Template/Grid.php b/Block/Adminhtml/Ebay/Account/Edit/Tabs/Feedback/Template/Grid.php new file mode 100644 index 000000000..459637909 --- /dev/null +++ b/Block/Adminhtml/Ebay/Account/Edit/Tabs/Feedback/Template/Grid.php @@ -0,0 +1,148 @@ +setId('ebayAccountEditTabsFeedbackGrid'); + // --------------------------------------- + + // Set default values + // --------------------------------------- + $this->setDefaultSort('id'); + $this->setDefaultDir('DESC'); + $this->setUseAjax(true); + $this->setFilterVisibility(false); + $this->setPagerVisibility(false); + // --------------------------------------- + } + + //######################################## + + protected function _prepareCollection() + { + $accountData = $this->getHelper('Data\GlobalData')->getValue('edit_account'); + + // Get collection of synchronizations + $collection = $this->activeRecordFactory->getObject('Ebay\Feedback\Template')->getCollection() + ->addFieldToFilter('main_table.account_id', $accountData->getId()); + + $this->setCollection($collection); + + return parent::_prepareCollection(); + } + + protected function _prepareColumns() + { + $this->addColumn('ft_title', array( + 'header' => $this->__('Message'), + 'align' => 'left', + 'type' => 'text', + 'index' => 'body', + 'filter' => false, + 'escape' => true, + 'filter_index' => 'main_table.body', + 'frame_callback' => array($this, 'callbackBody') + )); + + $this->addColumn('ft_create_date', array( + 'header' => $this->__('Creation Date'), + 'align' => 'left', + 'width' => '150px', + 'type' => 'datetime', + 'filter' => false, + 'format' => \IntlDateFormatter::MEDIUM, + 'filter_time' => true, + 'index' => 'create_date', + 'filter_index' => 'main_table.create_date' + )); + + $this->addColumn('ft_update_date', array( + 'header' => $this->__('Update Date'), + 'align' => 'left', + 'width' => '150px', + 'type' => 'datetime', + 'filter' => false, + 'format' => \IntlDateFormatter::MEDIUM, + 'filter_time' => true, + 'index' => 'update_date', + 'filter_index' => 'main_table.update_date' + )); + + $this->addColumn('ft_action_delete', array( + 'header' => $this->__('Delete'), + 'align' => 'left', + 'width' => '50px', + 'type' => 'action', + 'index' => 'actions', + 'filter' => false, + 'sortable' => false, + 'getter' => 'getId', + 'frame_callback' => array($this, 'callbackActionDelete') + )); + + return parent::_prepareColumns(); + } + + //######################################## + + public function callbackBody($value, $row, $column, $isExport) + { + return << + {$this->__('Edit')} + +HTML; + + } + + public function callbackActionDelete($value, $row, $column, $isExport) + { + return $this + ->createBlock('Magento\Button') + ->setData(array( + 'onclick' => 'EbayAccountObj.feedbacksDeleteAction(\''.$row->getData('id').'\');', + 'label' => $this->__('Delete'), + 'class' => 'action-default scalable delete icon-btn' + ))->toHtml(); + + } + + //######################################## + + public function getGridUrl() + { + return $this->getUrl('*/ebay_account_feedback_template/getGrid', ['_current'=>true]); + } + + public function getRowUrl($row) + { + return false; + } + + //######################################## + + public function getEmptyText() + { + return ''; + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/Ebay/Account/Edit/Tabs/General.php b/Block/Adminhtml/Ebay/Account/Edit/Tabs/General.php index af52634c1..80f6f1019 100644 --- a/Block/Adminhtml/Ebay/Account/Edit/Tabs/General.php +++ b/Block/Adminhtml/Ebay/Account/Edit/Tabs/General.php @@ -9,7 +9,7 @@ class General extends AbstractForm { protected function _prepareForm() { - $account = $this->getHelper('Data\GlobalData')->getValue('temp_data'); + $account = $this->getHelper('Data\GlobalData')->getValue('edit_account'); $formData = !is_null($account) ? array_merge($account->getData(), $account->getChildObject()->getData()) : []; $ebayUserId = null; @@ -40,12 +40,6 @@ protected function _prepareForm() $isEdit = !!$this->getRequest()->getParam('id'); - $licenseMessage = ''; - - if ($isEdit) { - $licenseMessage = (string)$this->getHelper('Data\GlobalData')->getValue('license_message'); - } - $form = $this->_formFactory->create(); if (!$isEdit) { @@ -62,7 +56,7 @@ protected function _prepareForm() Note: A Production (Live) eBay Account only works on a live Marketplace. A Sandbox (Test) Account only works on the eBay Sandbox test Environment. To register for a Sandbox Account, register at -developer.ebay.com/join. +developer.ebay.com/join. HTML ); } else { @@ -71,9 +65,9 @@ protected function _prepareForm() to your eBay Account.

    If your token has expired or is not activated, click Get Token.

    More detailed information about ability to work with this Page you can find -here. +here. HTML - , $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/KgItAQ')); + , $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/KgItAQ')); } $form->addField( @@ -126,7 +120,7 @@ protected function _prepareForm() ), 'class' => 'control-value', 'target' => '_blank', - 'style' => 'text-decoration: underline;' //todo + 'style' => 'text-decoration: underline;' ] ); } else { @@ -147,7 +141,6 @@ protected function _prepareForm() [ 'label' => $this->__('Environment'), 'name' => 'mode', - 'required' => true, 'values' => [ Account::MODE_PRODUCTION => $this->__('Production (Live)'), Account::MODE_SANDBOX => $this->__('Sandbox (Test)'), @@ -234,7 +227,6 @@ protected function _prepareForm() $this->setForm($form); - $this->js->add($licenseMessage); $this->js->add("M2ePro.formData.mode = '" . $this->getHelper('Data')->escapeJs($formData['mode']) . "';"); $this->js->add( "M2ePro.formData.token_session diff --git a/Block/Adminhtml/Ebay/Account/Edit/Tabs/ListingOther.php b/Block/Adminhtml/Ebay/Account/Edit/Tabs/ListingOther.php index 9c7d5f43f..84dfca184 100644 --- a/Block/Adminhtml/Ebay/Account/Edit/Tabs/ListingOther.php +++ b/Block/Adminhtml/Ebay/Account/Edit/Tabs/ListingOther.php @@ -43,8 +43,8 @@ protected function _prepareForm() // --------------------------------------- // --------------------------------------- - $account = $this->getHelper('Data\GlobalData')->getValue('temp_data') - ? $this->getHelper('Data\GlobalData')->getValue('temp_data') : array(); + $account = $this->getHelper('Data\GlobalData')->getValue('edit_account') + ? $this->getHelper('Data\GlobalData')->getValue('edit_account') : array(); $formData = !is_null($account) ? array_merge($account->getData(), $account->getChildObject()->getData()) : []; $marketplacesData = $formData['marketplaces_data']; @@ -88,10 +88,10 @@ protected function _prepareForm() You can set preferences whether you would like to import 3rd Party Listings (Items that were Listed on eBay either directly on the channel or with the help of other than M2E Pro tool), automatically map them to Magento Product, etc.


    -

    More detailed information you can find here.

    +

    More detailed information you can find here.

    HTML , - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/LAItAQ')) + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/LAItAQ')) ]); $fieldset = $form->addFieldset( @@ -182,19 +182,23 @@ protected function _prepareForm() [ 'name' => 'mapping_sku_mode', 'label' => $this->__('Custom Label (SKU)'), - 'class' => 'attribute-mode-select M2ePro-custom-attribute-can-be-created', + 'class' => 'attribute-mode-select', 'values' => [ Account::OTHER_LISTINGS_MAPPING_SKU_MODE_NONE => $this->__('None'), Account::OTHER_LISTINGS_MAPPING_SKU_MODE_DEFAULT => $this->__('Product SKU'), Account::OTHER_LISTINGS_MAPPING_SKU_MODE_PRODUCT_ID => $this->__('Product ID'), [ 'label' => $this->__('Magento Attributes'), - 'value' => $preparedAttributes + 'value' => $preparedAttributes, + 'attrs' => [ + 'is_magento_attribute' => true + ] ] ], 'value' => isset($mappingSettings['sku']['mode']) && $mappingSettings['sku']['mode'] != Account::OTHER_LISTINGS_MAPPING_SKU_MODE_CUSTOM_ATTRIBUTE ? $mappingSettings['sku']['mode'] : '', + 'create_magento_attribute' => true, ] )->setAfterElementHtml(<< @@ -241,18 +245,22 @@ class="input-text admin__control-text required-entry _required"> [ 'name' => 'mapping_title_mode', 'label' => $this->__('Listing Title'), - 'class' => 'attribute-mode-select M2ePro-custom-attribute-can-be-created', + 'class' => 'attribute-mode-select', 'values' => [ Account::OTHER_LISTINGS_MAPPING_TITLE_MODE_NONE => $this->__('None'), Account::OTHER_LISTINGS_MAPPING_TITLE_MODE_DEFAULT => $this->__('Product Name'), [ 'label' => $this->__('Magento Attributes'), - 'value' => $preparedAttributes + 'value' => $preparedAttributes, + 'attrs' => [ + 'is_magento_attribute' => true + ] ] ], 'value' => isset($mappingSettings['title']['mode']) && $mappingSettings['title']['mode'] != Account::OTHER_LISTINGS_MAPPING_TITLE_MODE_CUSTOM_ATTRIBUTE ? $mappingSettings['title']['mode'] : '', + 'create_magento_attribute' => true, ] )->setAfterElementHtml(<< diff --git a/Block/Adminhtml/Ebay/Account/Edit/Tabs/Order.php b/Block/Adminhtml/Ebay/Account/Edit/Tabs/Order.php index 261fd35c5..7824bda6a 100644 --- a/Block/Adminhtml/Ebay/Account/Edit/Tabs/Order.php +++ b/Block/Adminhtml/Ebay/Account/Edit/Tabs/Order.php @@ -30,7 +30,7 @@ public function __construct( protected function _prepareForm() { - $account = $this->getHelper('Data\GlobalData')->getValue('temp_data'); + $account = $this->getHelper('Data\GlobalData')->getValue('edit_account'); $websites = $this->getHelper('Magento\Store\Website')->getWebsites(true); @@ -49,8 +49,6 @@ protected function _prepareForm() array_unshift($productTaxClasses, $none); // --------------------------------------- - // TODO NOT SUPPORTED FEATURES -// $this->isStorePickupEnabled = $account->getChildObject()->isPickupStoreEnabled(); $formData = !is_null($account) ? array_merge($account->getData(), $account->getChildObject()->getData()) : []; $formData['magento_orders_settings'] = !empty($formData['magento_orders_settings']) @@ -127,10 +125,10 @@ protected function _prepareForm()

    Note: If an eBay Order is received, Magento Product QTY decreases only if a Magento Order is created.


    More detailed information about how to work with this -Page you can find here.

    +Page you can find here.

    HTML , - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/LgItAQ')) + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/LgItAQ')) ] ); @@ -220,7 +218,7 @@ protected function _prepareForm() 'container_id' => 'magento_orders_listings_other_store_id_container', 'name' => 'magento_orders_settings[listing_other][store_id]', 'label' => $this->__('Magento Store View'), - 'required' => true, + 'required' => false, 'value' => $formData['magento_orders_settings']['listing_other']['store_id'], 'has_empty_option' => false, 'has_default_option' => false, @@ -396,8 +394,7 @@ protected function _prepareForm() 'name' => 'magento_orders_settings[customer][website_id]', 'label' => $this->__('Associate to Website'), 'values' => $values, - 'value' => $formData['magento_orders_settings']['customer']['website_id'], - 'required' => true + 'value' => $formData['magento_orders_settings']['customer']['website_id'] ] ); @@ -414,7 +411,7 @@ protected function _prepareForm() 'label' => $this->__('Customer Group'), 'values' => $values, 'value' => $formData['magento_orders_settings']['customer']['group_id'], - 'required' => true + 'required' => false ] ); diff --git a/Block/Adminhtml/Ebay/Account/Edit/Tabs/Store.php b/Block/Adminhtml/Ebay/Account/Edit/Tabs/Store.php index 63d70c7b0..1c0f5ccae 100644 --- a/Block/Adminhtml/Ebay/Account/Edit/Tabs/Store.php +++ b/Block/Adminhtml/Ebay/Account/Edit/Tabs/Store.php @@ -9,8 +9,8 @@ class Store extends AbstractForm { protected function _prepareForm() { - $account = $this->getHelper('Data\GlobalData')->getValue('temp_data') - ? $this->getHelper('Data\GlobalData')->getValue('temp_data') : array(); + $account = $this->getHelper('Data\GlobalData')->getValue('edit_account') + ? $this->getHelper('Data\GlobalData')->getValue('edit_account') : array(); $formData = !is_null($account) ? array_merge($account->getData(), $account->getChildObject()->getData()) : []; $defaults = array( @@ -43,9 +43,9 @@ protected function _prepareForm() 'content' => $this->__(<<This tab displays information about your eBay Store and might be helpful for the Category settings via M2E Pro.


    -

    More detailed information you can find here.

    +

    More detailed information you can find here.

    HTML - , $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/MAItAQ')) + , $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/MAItAQ')) ] ); diff --git a/Block/Adminhtml/Ebay/Account/Feedback.php b/Block/Adminhtml/Ebay/Account/Feedback.php new file mode 100644 index 000000000..330323832 --- /dev/null +++ b/Block/Adminhtml/Ebay/Account/Feedback.php @@ -0,0 +1,68 @@ +_controller = 'adminhtml_ebay_account_feedback'; + + // Set buttons actions + // --------------------------------------- + $this->removeButton('add'); + // --------------------------------------- + } + + protected function _toHtml() + { + $helpBlock = $this->createBlock('HelpBlock'); + $helpBlock->setData([ + 'content' => $this->__(<<
    +You can respond to a newly received Feedback by clicking the Send Response button for the Order.
    +Note: Auto-responses to Feedback are sent according to the eBay Accounts > Feedback Settings. +

    +More detailed information about ability to work with this Page you can find +here +HTML + , + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/OAAJAQ') + ) + ]); + + $this->css->add(<<js->add(<<' . + $helpBlock->toHtml() . + parent::_toHtml(); + } +} \ No newline at end of file diff --git a/Block/Adminhtml/Ebay/Account/Feedback/Grid.php b/Block/Adminhtml/Ebay/Account/Feedback/Grid.php new file mode 100644 index 000000000..39e31b966 --- /dev/null +++ b/Block/Adminhtml/Ebay/Account/Feedback/Grid.php @@ -0,0 +1,306 @@ +setId('ebayFeedbackGrid'); + // --------------------------------------- + + // Set default values + // --------------------------------------- + $this->setDefaultSort('buyer_feedback_date'); + $this->setDefaultDir('DESC'); + $this->setSaveParametersInSession(true); + $this->setUseAjax(true); + // --------------------------------------- + } + + protected function _prepareCollection() + { + $accountId = $this->getRequest()->getParam('id'); + if (is_null($accountId)) { + return parent::_prepareCollection(); + } + + $collection = $this->activeRecordFactory->getObject('Ebay\Feedback')->getCollection(); + + $dbExpr = new \Zend_Db_Expr('if(`main_table`.`seller_feedback_text` = \'\', 0, 1)'); + $collection->getSelect() + ->joinLeft( + array('mea' => $this->activeRecordFactory->getObject('Ebay\Account')->getResource()->getMainTable()), + '(`mea`.`account_id` = `main_table`.`account_id`)', + array('account_mode'=>'mode','have_seller_feedback' => $dbExpr) + ); + + $collection->addFieldToFilter('main_table.account_id', $accountId); + + $this->setCollection($collection); + + return parent::_prepareCollection(); + } + + /** + * Add column filtering conditions to collection + * + * @param \Magento\Backend\Block\Widget\Grid\Column $column + * @return $this + */ + protected function _addColumnFilterToCollection($column) + { + if ($this->getCollection()) { + $field = ( $column->getFilterIndex() ) ? $column->getFilterIndex() : $column->getIndex(); + if ($column->getFilterConditionCallback()) { + call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column); + } else { + $cond = $column->getFilter()->getCondition(); + if ($field && isset($cond)) { + if ($field == 'have_seller_feedback') { + if ((int)$cond['eq'] == 0) { + $this->getCollection()->getSelect()->where('`main_table`.`seller_feedback_text` = \'\''); + } else if ((int)$cond['eq'] == 1) { + $this->getCollection()->getSelect()->where('`main_table`.`seller_feedback_text` != \'\''); + } + } else { + $this->getCollection()->addFieldToFilter($field , $cond); + } + } + } + } + return $this; + } + + protected function _prepareColumns() + { + $this->addColumn('ebay_item_id', array( + 'header' => $this->__('Item ID'), + 'align' => 'right', + 'type' => 'text', + 'width' => '50px', + 'index' => 'ebay_item_id', + 'frame_callback' => array($this, 'callbackColumnEbayItemId') + )); + + $this->addColumn('transaction_id', array( + 'header' => $this->__('Transaction ID'), + 'align' => 'right', + 'type' => 'text', + 'width' => '105px', + 'index' => 'ebay_transaction_id', + 'frame_callback' => array($this, 'callbackColumnTransactionId') + )); + + $this->addColumn('buyer_feedback', array( + 'header' => $this->__('Buyer Feedback'), + 'width' => '155px', + 'type' => 'text', + 'index' => 'buyer_feedback_text', + 'frame_callback' => array($this, 'callbackColumnBuyerFeedback') + )); + + $this->addColumn('buyer_feedback_date', array( + 'header' => $this->__('Buyer Feedback Date'), + 'width' => '155px', + 'type' => 'datetime', + 'format' => \IntlDateFormatter::MEDIUM, + 'filter_time' => true, + 'index' => 'buyer_feedback_date', + 'frame_callback' => array($this, 'callbackColumnBuyerFeedbackDate') + )); + + $this->addColumn('seller_feedback', array( + 'header' => $this->__('Seller Feedback'), + 'width' => '155px', + 'type' => 'text', + 'index' => 'seller_feedback_text', + 'frame_callback' => array($this, 'callbackColumnSellerFeedback') + )); + + $this->addColumn('seller_feedback_date', array( + 'header' => $this->__('Seller Feedback Date'), + 'width' => '155px', + 'type' => 'datetime', + 'format' => \IntlDateFormatter::MEDIUM, + 'filter_time' => true, + 'index' => 'seller_feedback_date', + 'frame_callback' => array($this, 'callbackColumnSellerFeedbackDate') + )); + + $this->addColumn('buyer_feedback_type', array( + 'header' => $this->__('Type'), + 'width' => '50px', + 'align' => 'center', + 'type' => 'options', + 'filter_index' => 'buyer_feedback_type', + 'sortable' => false, + 'options' => array( + 'Neutral' => $this->__('Neutral'), + 'Positive' => $this->__('Positive'), + 'Negative' => $this->__('Negative') + ), + 'frame_callback' => array($this, 'callbackColumnFeedbackType'), + 'filter_condition_callback' => array($this, 'callbackFilterFeedbackType'), + )); + + $this->addColumn('feedback_respond_status', array( + 'header' => $this->__('Status'), + 'align' => 'center', + 'type' => 'options', + 'index' => 'have_seller_feedback', + 'filter_index' => 'have_seller_feedback', + 'sortable' => false, + 'options' => array( + 0 => $this->__('Unresponded'), + 1 => $this->__('Responded') + ) + )); + + return parent::_prepareColumns(); + } + + //######################################## + + public function callbackColumnEbayItemId($value, $row, $column, $isExport) + { + $url = $this->getUrl('*/*/goToItem', array('feedback_id' => $row->getData('id'))); + + return ''.$this->getHelper('Data')->escapeHtml($value).''; + } + + public function callbackColumnTransactionId($value, $row, $column, $isExport) + { + $value == 0 && $value = $this->__('No ID For Auction'); + $url = $this->getUrl('*/*/goToOrder/', array('feedback_id' => $row->getData('id'))); + + return ''.$this->getHelper('Data')->escapeHtml($value).''; + } + + public function callbackColumnBuyerFeedback($value, $row, $column, $isExport) + { + $feedbackType = $row->getData('buyer_feedback_type'); + + switch ($feedbackType) { + case \Ess\M2ePro\Model\Ebay\Feedback::TYPE_POSITIVE: + $color = 'green'; + break; + case \Ess\M2ePro\Model\Ebay\Feedback::TYPE_NEGATIVE: + $color = 'red'; + break; + default: + $color = 'gray'; + break; + } + + return "{$value}"; + } + + public function callbackColumnBuyerFeedbackDate($value, $row, $column, $isExport) + { + if (strtotime($row->getData('buyer_feedback_date')) < strtotime('2001-01-02')) { + return $this->__('N/A'); + } + + return $value; + } + + public function callbackColumnSellerFeedback($value, $row, $column, $isExport) + { + if ($value) { + return $value; + } else { + return <<{$this->__('Send Response')} +HTML; + } + } + + public function callbackColumnSellerFeedbackDate($value, $row, $column, $isExport) + { + if (strtotime($row->getData('seller_feedback_date')) < strtotime('2001-01-02')) { + return $this->__('N/A'); + } + + return $value; + } + + public function callbackColumnFeedbackType($value, $row, $column, $isExport) + { + $feedbackType = $row->getData('buyer_feedback_type'); + + switch ($feedbackType) { + case \Ess\M2ePro\Model\Ebay\Feedback::TYPE_POSITIVE: + $feedbackTypeText = $this->__('Positive'); + $color = 'green'; + break; + case \Ess\M2ePro\Model\Ebay\Feedback::TYPE_NEGATIVE: + $feedbackTypeText = $this->__('Negative'); + $color = 'red'; + break; + default: + $feedbackTypeText = $this->__('Neutral'); + $color = 'gray'; + break; + } + + return "{$feedbackTypeText}"; + } + + //######################################## + + public function callbackFilterFeedbackType($collection, $column) + { + $value = $column->getFilter()->getValue(); + if ($value == null) { + return; + } + + switch ($value) { + case \Ess\M2ePro\Model\Ebay\Feedback::TYPE_NEGATIVE: + $this->getCollection()->addFieldToFilter('buyer_feedback_type', + \Ess\M2ePro\Model\Ebay\Feedback::TYPE_NEGATIVE); + break; + case \Ess\M2ePro\Model\Ebay\Feedback::TYPE_NEUTRAL: + $this->getCollection()->addFieldToFilter('buyer_feedback_type', + \Ess\M2ePro\Model\Ebay\Feedback::TYPE_NEUTRAL); + break; + case \Ess\M2ePro\Model\Ebay\Feedback::TYPE_POSITIVE: + $this->getCollection()->addFieldToFilter('buyer_feedback_type', + \Ess\M2ePro\Model\Ebay\Feedback::TYPE_POSITIVE); + break; + } + } + + //######################################## + + public function getGridUrl() + { + return $this->getUrl('*/*/getGrid', array('_current'=>true)); + } + + public function getRowUrl($row) + { + return false; + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/Ebay/Account/Feedback/SendResponseForm.php b/Block/Adminhtml/Ebay/Account/Feedback/SendResponseForm.php new file mode 100644 index 000000000..f757c6dc8 --- /dev/null +++ b/Block/Adminhtml/Ebay/Account/Feedback/SendResponseForm.php @@ -0,0 +1,177 @@ +getHelper('Data\GlobalData')->getValue('feedback'); + + $form = $this->_formFactory->create( + ['data' => [ + 'id' => 'send_response_form', + 'action' => 'javascript:void(0)', + 'method' => 'post', + ]] + ); + + $form->addField( + 'feedback_id', + 'hidden', + [ + 'name' => 'feedback_id', + 'value' => $feedback->getId() + ] + ); + + + $fieldset = $form->addFieldset( + 'send_response_fieldset', + [] + ); + + $transaction = $feedback->getEbayTransactionId() == 0 ? + $this->__('No ID For Auction') : $feedback->getEbayTransactionId(); + $url = $this->getUrl('*/*/goToOrder/', ['feedback_id' => $feedback->getId()]); + + $fieldset->addField( + 'transaction_id', + self::CUSTOM_CONTAINER, + [ + 'label' => $this->__('Transaction ID'), + 'text' => <<{$transaction} +HTML + ] + ); + + $url = $this->getUrl('*/*/goToItem', array('feedback_id' => $feedback->getId())); + + $fieldset->addField( + 'item_id', + self::CUSTOM_CONTAINER, + [ + 'label' => $this->__('Item ID'), + 'text' => <<{$feedback->getEbayItemId()} +HTML + ] + ); + + $fieldset->addField( + 'buyer_text', + self::CUSTOM_CONTAINER, + [ + 'label' => $this->__('Buyer\'s Feedback'), + 'text' => <<getData('buyer_feedback_text')} +HTML + ] + ); + + $templates = $this->activeRecordFactory->getObject('Ebay\Feedback\Template')->getCollection() + ->addFieldToFilter('main_table.account_id', $feedback->getData('account_id')); + + $fieldset->addField('feedback_template_type', + self::SELECT, + [ + 'html_id' => 'feedback_template_type', + 'name' => 'feedback_template_type', + 'label' => $this->__('Response Type'), + 'values' => [ + [ + 'value' => '', + 'label' => '', + 'attrs' => ['style' => 'display: none'] + ], + [ + 'value' => 'custom', + 'label' => $this->__('Custom') + ], + [ + 'value' => 'predefined', + 'label' => $this->__('Predefined Template') + ] + ], + 'value' => $templates->getSize() > 0 ? '' : 'custom', + 'required' => true, + 'class' => 'M2ePro-required-when-visible', + 'field_extra_attributes' => $templates->getSize() > 0 ? '' : 'style="display: none"' + ] + ); + + $templatesValue = [[ + 'value' => '', + 'label' => '', + 'attrs' => ['style' => 'display: none'] + ]]; + foreach ($templates as $template) { + $text = $template->getData('body'); + + if (strlen($text) > 40) { + $text = substr($text, 0, 40) . '...'; + } + + $templatesValue[] = [ + 'value' => $template->getData('body'), + 'label' => $text + ]; + } + + $fieldset->addField('feedback_template', + self::SELECT, + [ + 'html_id' => 'feedback_template', + 'container_id' => 'feedback_template_container', + 'name' => 'feedback_template', + 'label' => $this->__('Template'), + 'values' => $templatesValue, + 'required' => true, + 'class' => 'M2ePro-required-when-visible', + 'field_extra_attributes' => 'style="display: none"' + ] + ); + + $fieldset->addField('feedback_text', + 'textarea', + [ + 'html_id' => 'feedback_text', + 'container_id' => 'feedback_text_container', + 'name' => 'feedback_text', + 'label' => $this->__('Message'), + 'required' => true, + 'class' => 'M2ePro-validate-feedback-response-max-length', + 'field_extra_attributes' => $templates->getSize() > 0 ? 'style="display: none"' : '' + ] + ); + + $form->setUseContainer(true); + $this->setForm($form); + + $this->js->add(<< array($this, 'callbackFilterTitle') )); - if ($this->getHelper('View\Ebay')->isAdvancedMode() && - $this->getHelper('View\Ebay')->isFeedbacksShouldBeShown()) { + if ($this->getHelper('View\Ebay')->isFeedbacksShouldBeShown()) { $this->addColumn('feedbacks', array( 'header' => $this->__('Feedback'), @@ -86,7 +85,7 @@ public function callbackColumnTitle($value, $row, $column, $isExport) } $environmentLabel = $this->__('Environment'); - $environment = (int)$row->getData('mode') == \Ess\M2ePro\Model\Ebay\Account::MODE_SANDBOX ? + $environment = (int)$row->getChildObject()->getData('mode') == \Ess\M2ePro\Model\Ebay\Account::MODE_SANDBOX ? 'Sandbox (Test)' : 'Production (Live)'; $environment = $this->__($environment); @@ -103,6 +102,23 @@ public function callbackColumnTitle($value, $row, $column, $isExport) return $value; } + public function callbackColumnFeedbacks($value, $row, $column, $isExport) + { + if ($this->getHelper('View\Ebay')->isFeedbacksShouldBeShown($row->getData('id'))) { + $link = <<{$this->__('Feedback')} +HTML; + } else { + $link = '' . $this->__("Disabled") . ''; + } + + return $link; + } + + //######################################## + protected function callbackFilterTitle($collection, $column) { $value = $column->getFilter()->getValue(); @@ -129,18 +145,5 @@ protected function callbackFilterTitle($collection, $column) ); } -// TODO NOT SUPPORTED FEATURES -// public function callbackColumnFeedbacks($value, $row, $column, $isExport) -// { -// if ($this->getHelper('View\Ebay')->isFeedbacksShouldBeShown($row->getData('id'))) { -// $url = $this->getUrl('*/adminhtml_ebay_feedback/index', array('account' => $row->getId())); -// $link = ''. $this->__("Feedback") . ''; -// } else { -// $link = '' -// . $this->__("Disabled") . -// ''; -// } -// -// return $link; -// } + //######################################## } \ No newline at end of file diff --git a/Block/Adminhtml/Ebay/Grid/Column/Filter/OrderId.php b/Block/Adminhtml/Ebay/Grid/Column/Filter/OrderId.php index 55df03620..d0f9b0dbb 100644 --- a/Block/Adminhtml/Ebay/Grid/Column/Filter/OrderId.php +++ b/Block/Adminhtml/Ebay/Grid/Column/Filter/OrderId.php @@ -31,44 +31,11 @@ public function getHelper($helper, array $arguments = []) return $this->helperFactory->getObject($helper, $arguments); } - public function getHtml() - { - // TODO NOT SUPPORTED FEATURES - if (!$this->getHelper('Component\Ebay\PickupStore')->isFeatureEnabled()) { - return parent::getHtml(); - } - $isInStorePickup = ($this->getValue('is_in_store_pickup') == 1) ? 'checked="checked"' : ''; - - $html = '
    '; - - return $html . - '' . - ' ' - .$this->getHelper('Module\Translation')->__('In-Store Pickup'); - } - //######################################## public function getValue($index=null) { - // TODO NOT SUPPORTED FEATURES - if (!$this->getHelper('Component\Ebay\PickupStore')->isFeatureEnabled()) { - return $this->getData('value', $index); - } - - if ($index) { - return $this->getData('value', $index); - } - - $value = $this->getData('value'); - if (isset($value['is_in_store_pickup']) && $value['is_in_store_pickup'] == 1) { - return $value; - } - - return null; + return $this->getData('value', $index); } //######################################## diff --git a/Block/Adminhtml/Ebay/Listing/AutoAction/Mode.php b/Block/Adminhtml/Ebay/Listing/AutoAction/Mode.php index fa661be9b..5d3cca5b8 100644 --- a/Block/Adminhtml/Ebay/Listing/AutoAction/Mode.php +++ b/Block/Adminhtml/Ebay/Listing/AutoAction/Mode.php @@ -27,7 +27,7 @@ public function _construct() public function getHelpPageUrl() { return $this->getHelper('Module\Support') - ->getDocumentationUrl(NULL, NULL, 'x/kgItAQ'); + ->getDocumentationArticleUrl('x/kgItAQ'); } //######################################## diff --git a/Block/Adminhtml/Ebay/Listing/AutoAction/Mode/Category.php b/Block/Adminhtml/Ebay/Listing/AutoAction/Mode/Category.php index a71abf88f..ab2f6ab1c 100644 --- a/Block/Adminhtml/Ebay/Listing/AutoAction/Mode/Category.php +++ b/Block/Adminhtml/Ebay/Listing/AutoAction/Mode/Category.php @@ -55,11 +55,12 @@ protected function _toHtml() is added to the Magento Category with regard to the Store View selected for the M2E Pro Listing. In other words, after a Magento Product is added to the selected Magento Category, it can be automatically added to M2E Pro Listing if the settings are enabled.


    -

    Accordingly, if a Magento Product present in the the M2E Pro Listing is removed from +

    Accordingly, if a Magento Product present in the M2E Pro Listing is removed from the Magento Category, the Item will be removed from the Listing and its sale will be stopped on Channel.


    -

    More detailed information you can find here.

    ', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/-QItAQ') +

    More detailed information you can find + here.

    ', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/-QItAQ') ) ]); diff --git a/Block/Adminhtml/Ebay/Listing/AutoAction/Mode/GlobalMode.php b/Block/Adminhtml/Ebay/Listing/AutoAction/Mode/GlobalMode.php index 7b76fb6a6..525a7ddef 100644 --- a/Block/Adminhtml/Ebay/Listing/AutoAction/Mode/GlobalMode.php +++ b/Block/Adminhtml/Ebay/Listing/AutoAction/Mode/GlobalMode.php @@ -59,11 +59,12 @@ protected function _toHtml() '

    These Rules of the automatic product adding and removal act globally for all Magento Catalog. When a new Magento Product is added to Magento Catalog, it will be automatically added to the current M2E Pro Listing if the settings are enabled.


    -

    Accordingly, if a Magento Product present in the the M2E Pro Listing is removed from +

    Accordingly, if a Magento Product present in the M2E Pro Listing is removed from Magento Catalog, the Item will be removed from the Listing and its sale will be stopped on Channel.


    -

    More detailed information you can find here.

    ', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/_QItAQ') +

    More detailed information you can find + here.

    ', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/_QItAQ') ) ] ); diff --git a/Block/Adminhtml/Ebay/Listing/AutoAction/Mode/Website.php b/Block/Adminhtml/Ebay/Listing/AutoAction/Mode/Website.php index 640e82033..35271021d 100644 --- a/Block/Adminhtml/Ebay/Listing/AutoAction/Mode/Website.php +++ b/Block/Adminhtml/Ebay/Listing/AutoAction/Mode/Website.php @@ -64,11 +64,12 @@ protected function _toHtml() the M2E Pro Listing. In other words, after a Magento Product is added to the selected Website, it can be automatically added to M2E Pro Listing if the settings are enabled.


    -

    Accordingly, if a Magento Product present in the the M2E Pro Listing is removed from +

    Accordingly, if a Magento Product present in the M2E Pro Listing is removed from the Website, the Item will be removed from the Listing and its sale will be stopped on Channel.


    -

    More detailed information you can find here.

    ', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/_wItAQ') +

    More detailed information you can find + here.

    ', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/_wItAQ') ) ] ); diff --git a/Block/Adminhtml/Ebay/Listing/Create/General.php b/Block/Adminhtml/Ebay/Listing/Create/General.php index 09c825f8e..e5ee543c6 100644 --- a/Block/Adminhtml/Ebay/Listing/Create/General.php +++ b/Block/Adminhtml/Ebay/Listing/Create/General.php @@ -61,8 +61,9 @@ protected function _toHtml() Marketplace that you are going to sell Magento Products on.


    It is also important to specify a Store View in accordance with which Magento Attribute values will be used in the Listing settings.


    -

    More detailed information you can find here.

    ', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/6wItAQ') +

    More detailed information you can find + here.

    ', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/6wItAQ') ), 'style' => 'margin-top: 30px' ]); diff --git a/Block/Adminhtml/Ebay/Listing/Create/General/Form.php b/Block/Adminhtml/Ebay/Listing/Create/General/Form.php index 2a8acc3cf..8ad00a2dc 100644 --- a/Block/Adminhtml/Ebay/Listing/Create/General/Form.php +++ b/Block/Adminhtml/Ebay/Listing/Create/General/Form.php @@ -13,13 +13,11 @@ class Form extends \Ess\M2ePro\Block\Adminhtml\Magento\Form\AbstractForm { protected $ebayFactory; - protected $elementFactory; //######################################## public function __construct( \Ess\M2ePro\Model\ActiveRecord\Component\Parent\Ebay\Factory $ebayFactory, - \Magento\Framework\Data\Form\Element\Factory $elementFactory, \Ess\M2ePro\Block\Adminhtml\Magento\Context\Template $context, \Magento\Framework\Registry $registry, \Magento\Framework\Data\FormFactory $formFactory, @@ -27,7 +25,6 @@ public function __construct( ) { $this->ebayFactory = $ebayFactory; - $this->elementFactory = $elementFactory; parent::__construct($context, $registry, $formFactory, $data); } @@ -188,7 +185,6 @@ protected function _prepareForm() 'label' => $this->__('Marketplace'), 'value' => $marketplaceId, 'values' => $marketplaces, - 'required' => true, 'tooltip' => $this->__( 'Choose the Marketplace you want to list on using this M2E Pro Listing. Currency will be set automatically based on the Marketplace you choose.' diff --git a/Block/Adminhtml/Ebay/Listing/Edit/Tabs/General.php b/Block/Adminhtml/Ebay/Listing/Edit/Tabs/General.php index bbe0d73a7..925a5e8a4 100644 --- a/Block/Adminhtml/Ebay/Listing/Edit/Tabs/General.php +++ b/Block/Adminhtml/Ebay/Listing/Edit/Tabs/General.php @@ -33,8 +33,8 @@ protected function _prepareLayout() 'content' => $this->__( '

    You should specify settings for Payment, Shipping and Return configurations for current Listing.


    - More detailed information you can find here.', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/7QItAQ') + More detailed information you can find here.', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/7QItAQ') ) ]); $this->setChild('help', $helpBlock); diff --git a/Block/Adminhtml/Ebay/Listing/Edit/Tabs/Selling.php b/Block/Adminhtml/Ebay/Listing/Edit/Tabs/Selling.php index b3897456b..115425527 100644 --- a/Block/Adminhtml/Ebay/Listing/Edit/Tabs/Selling.php +++ b/Block/Adminhtml/Ebay/Listing/Edit/Tabs/Selling.php @@ -34,9 +34,10 @@ protected function _prepareLayout() 'content' => $this->__( '

    On this step you should specify main settings according to which your Items will be sold - Price-, Quantity-related configurations, etc.


    -

    More detailed information you can find here.

    ', +

    More detailed information you can find + here.

    ', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/9gItAQ') + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/9gItAQ') ) ]); $this->setChild('help', $helpBlock); diff --git a/Block/Adminhtml/Ebay/Listing/Edit/Tabs/Synchronization.php b/Block/Adminhtml/Ebay/Listing/Edit/Tabs/Synchronization.php index 385031abf..4e468e2c8 100644 --- a/Block/Adminhtml/Ebay/Listing/Edit/Tabs/Synchronization.php +++ b/Block/Adminhtml/Ebay/Listing/Edit/Tabs/Synchronization.php @@ -33,9 +33,7 @@ protected function _prepareLayout() $helpBlock->setData([ 'content' => $this->__( '

    You should configure rules for the automatic data update between a Magento Product - and an eBay Item.


    -

    More detailed information you can find here.

    ', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/OwItAQ') + and an eBay Item.

    ' ) ]); $this->setChild('help', $helpBlock); diff --git a/Block/Adminhtml/Ebay/Listing/Grid.php b/Block/Adminhtml/Ebay/Listing/Grid.php index 223343d5f..e1992f3f9 100644 --- a/Block/Adminhtml/Ebay/Listing/Grid.php +++ b/Block/Adminhtml/Ebay/Listing/Grid.php @@ -13,20 +13,17 @@ class Grid extends \Ess\M2ePro\Block\Adminhtml\Listing\Grid { protected $ebayFactory; - protected $storeManager; //######################################## public function __construct( \Ess\M2ePro\Model\ActiveRecord\Component\Parent\Ebay\Factory $ebayFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, \Ess\M2ePro\Block\Adminhtml\Magento\Context\Template $context, \Magento\Backend\Helper\Data $backendHelper, array $data = [] ) { $this->ebayFactory = $ebayFactory; - $this->storeManager = $storeManager; parent::__construct($context, $backendHelper, $data); } @@ -232,10 +229,10 @@ public function callbackColumnTitle($value, $row, $column, $isExport) $accountTitle = $row->getData('account_title'); $marketplaceTitle = $row->getData('marketplace_title'); - $storeModel = $this->storeManager->getStore($row->getStoreId()); - $storeView = $this->storeManager->getWebsite($storeModel->getWebsiteId())->getName(); + $storeModel = $this->_storeManager->getStore($row->getStoreId()); + $storeView = $this->_storeManager->getWebsite($storeModel->getWebsiteId())->getName(); if (strtolower($storeView) != 'admin') { - $storeView .= ' > '.$this->storeManager->getGroup($storeModel->getStoreGroupId())->getName(); + $storeView .= ' > '.$this->_storeManager->getGroup($storeModel->getStoreGroupId())->getName(); $storeView .= ' > '.$storeModel->getName(); } else { $storeView = $this->__('Admin (Default Values)'); diff --git a/Block/Adminhtml/Ebay/Listing/Moving/Grid.php b/Block/Adminhtml/Ebay/Listing/Moving/Grid.php index f63764774..1da79c145 100644 --- a/Block/Adminhtml/Ebay/Listing/Moving/Grid.php +++ b/Block/Adminhtml/Ebay/Listing/Moving/Grid.php @@ -12,9 +12,8 @@ class Grid extends \Ess\M2ePro\Block\Adminhtml\Listing\Moving\Grid { //######################################## - protected function getNewListingBtnHtml() + protected function getNewListingUrl() { - // --------------------------------------- $newListingUrl = $this->getUrl('*/ebay_listing_create/index', array( 'step' => 1, 'clear' => 1, @@ -23,17 +22,7 @@ protected function getNewListingBtnHtml() 'creation_mode' => \Ess\M2ePro\Helper\View::LISTING_CREATION_MODE_LISTING_ONLY )); - $data = array( - 'id' => 'listingProductMoving_addNew_listing_button', - 'label' => $this->__('Add New Listing'), - 'style' => 'float: right;', - 'class' => 'primary', - 'onclick' => $this->getData('moving_handler_js') . '.startListingCreation(\''.$newListingUrl.'\')' - ); - $buttonBlock = $this->createBlock('Magento\Button')->setData($data); - // --------------------------------------- - - return $buttonBlock->toHtml(); + return $newListingUrl; } //######################################## diff --git a/Block/Adminhtml/Ebay/Listing/Other/Log.php b/Block/Adminhtml/Ebay/Listing/Other/Log.php index ae9098bb6..dedcbabc5 100644 --- a/Block/Adminhtml/Ebay/Listing/Other/Log.php +++ b/Block/Adminhtml/Ebay/Listing/Other/Log.php @@ -61,9 +61,9 @@ protected function _prepareLayout() 'content' => $this->__('This Log contains all information about Actions, which were done on 3rd Party Listings.

    More detailed information about ability to work with this Page you can find - here.', - $this->getHelper('Module\Support')->getDocumentationUrl( - NULL, NULL, 'x/MAAJAQ#Logs.-3rdPartyListingsLog(advancedmodeonly)' + here.', + $this->getHelper('Module\Support')->getDocumentationArticleUrl( + 'x/MAAJAQ#Logs.-3rdPartyListingsLog(advancedmodeonly)' ) ) ]); diff --git a/Block/Adminhtml/Ebay/Listing/Other/View.php b/Block/Adminhtml/Ebay/Listing/Other/View.php index 14f44f134..3095cdceb 100644 --- a/Block/Adminhtml/Ebay/Listing/Other/View.php +++ b/Block/Adminhtml/Ebay/Listing/Other/View.php @@ -138,7 +138,7 @@ protected function _toHtml() 'mapAutoToProduct' => $this->getUrl('*/listing_other_mapping/autoMap'), 'prepareData' => $this->getUrl('*/listing_other_moving/prepareMoveToListing'), 'moveToListingGridHtml' => $this->getUrl('*/ebay_listing_other_moving/moveToListingGrid'), - 'getFailedProductsGridHtml' => $this->getUrl('*/listing_other_moving/getFailedProductsGrid'), + 'getFailedProductsHtml' => $this->getUrl('*/listing_other_moving/getFailedProducts'), 'tryToMoveToListing' => $this->getUrl('*/listing_other_moving/tryToMoveToListing'), 'moveToListing' => $this->getUrl('*/listing_other_moving/moveToListing'), 'removingProducts' => $this->getUrl('*/ebay_listing_other/removing'), @@ -153,6 +153,7 @@ protected function _toHtml() 'Please enter correct Product ID.' => $this->__('Please enter correct Product ID.'), 'Product(s) was successfully Mapped.' => $this->__('Product(s) was successfully Mapped.'), 'Please enter correct Product ID or SKU' => $this->__('Please enter correct Product ID or SKU'), + 'Add New Listing' => $this->__('Add New Listing'), 'failed_mapped' => $someProductsWereNotMappedMessage, 'successfully_mapped' => $this->__('Product was successfully Mapped.'), 'mapping_product_title' => $this->__('Mapping Product'), @@ -214,8 +215,7 @@ protected function _toHtml() 'lor' => 'M2ePro/Listing/Other/Removing', 'lou' => 'M2ePro/Listing/Other/Unmapping', - 'elog' => 'M2ePro/Ebay/Listing/Other/Grid', - 'eloa' => 'M2ePro/Ebay/Listing/Other/Action' + 'elog' => 'M2ePro/Ebay/Listing/Other/Grid' ], << 'right', 'width' => '150px', 'type' => 'datetime', + 'filter_time' => true, 'index' => 'end_date', 'filter_index' => 'second_table.end_date', 'frame_callback' => array($this, 'callbackColumnEndTime') @@ -494,15 +495,15 @@ public function getViewLogIconHtml($listingOtherId) } $tips = array( - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS => 'Last Action was completed successfully.', - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR => 'Last Action was completed with error(s).', - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING => 'Last Action was completed with warning(s).' + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_SUCCESS => 'Last Action was completed successfully.', + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR => 'Last Action was completed with error(s).', + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_WARNING => 'Last Action was completed with warning(s).' ); $icons = array( - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS => 'normal', - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR => 'error', - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING => 'warning' + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_SUCCESS => 'normal', + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR => 'error', + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_WARNING => 'warning' ); $summary = $this->createBlock('Log\Grid\Summary', '', [ @@ -553,15 +554,15 @@ public function getInitiatorForAction($actionRows) public function getMainTypeForActionId($actionRows) { - $type = \Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS; + $type = \Ess\M2ePro\Model\Log\AbstractModel::TYPE_SUCCESS; foreach ($actionRows as $row) { - if ($row['type'] == \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR) { - $type = \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR; + if ($row['type'] == \Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR) { + $type = \Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR; break; } - if ($row['type'] == \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING) { - $type = \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING; + if ($row['type'] == \Ess\M2ePro\Model\Log\AbstractModel::TYPE_WARNING) { + $type = \Ess\M2ePro\Model\Log\AbstractModel::TYPE_WARNING; } } diff --git a/Block/Adminhtml/Ebay/Listing/Preview.php b/Block/Adminhtml/Ebay/Listing/Preview.php new file mode 100644 index 000000000..5e09456cf --- /dev/null +++ b/Block/Adminhtml/Ebay/Listing/Preview.php @@ -0,0 +1,933 @@ +ebayFactory = $ebayFactory; + $this->currency = $currency; + parent::__construct($context, $data); + } + + public function _construct() + { + parent::_construct(); + + $id = $this->getRequest()->getParam('currentProductId'); + + $this->ebayListingProduct = $this->ebayFactory->getObjectLoaded( + 'Listing\Product', $id + )->getChildObject(); + + $this->setTemplate('ebay/listing/preview.phtml'); + $this->css->addFile('ebay/listing/preview.css'); + } + + protected function _beforeToHtml() + { + $this->jsTranslator->add('This is Item Preview Mode', $this->__('This is Item Preview Mode')); + + $variations = json_encode($this->getVariations()); + $images = json_encode($this->getImages()); + + $this->js->add(<<filterManager->truncate($text, ['length' => $length]); + } + + //######################################## + + public function getProductShortInfo($direction) + { + $currentProductId = $this->getRequest()->getParam('currentProductId'); + $productIds = $this->getRequest()->getParam('productIds'); + + $parsedProductIds = explode(',', $productIds); + + do { + if ($currentProductId === current($parsedProductIds)) { + break; + } + } while (next($parsedProductIds)); + + if ($direction === self::NEXT && next($parsedProductIds) === false) { + return null; + } + if ($direction === self::PREVIOUS && prev($parsedProductIds) === false) { + return null; + } + + /** @var \Ess\M2ePro\Model\Ebay\Listing\Product $tempEbayListingProduct */ + + $tempEbayListingProduct = $this->ebayFactory->getObjectLoaded( + 'Listing\Product', current($parsedProductIds) + )->getChildObject(); + + return array( + 'title' => $tempEbayListingProduct->getMagentoProduct()->getName(), + 'id' => $tempEbayListingProduct->getMagentoProduct()->getProductId(), + 'url' => $this->getUrl('*/ebay_listing/previewItems', array( + 'currentProductId' => current($parsedProductIds), + 'productIds' => $productIds, + )) + ); + } + + //######################################## + + public function getTitle() + { + return $this->getHelper('Data') + ->escapeHtml($this->ebayListingProduct->getDescriptionTemplateSource()->getTitle()); + } + + public function getSubtitle() + { + return $this->getHelper('Data') + ->escapeHtml($this->ebayListingProduct->getDescriptionTemplateSource()->getSubTitle()); + } + + public function getDescription() + { + return $this->ebayListingProduct->getDescriptionRenderer()->parseTemplate( + $this->ebayListingProduct->getDescriptionTemplateSource()->getDescription() + ); + } + + public function getCondition() + { + return $this->getConditionHumanTitle($this->ebayListingProduct->getDescriptionTemplateSource()->getCondition()); + } + + public function getConditionNote() + { + return $this->getHelper('Data') + ->escapeHtml($this->ebayListingProduct->getDescriptionTemplateSource()->getConditionNote()); + } + + // --------------------------------------- + + public function getPrice(array $variations) + { + $data = array( + 'price' => null, + 'price_stp' => null, + 'price_map' => null + ); + + if ($this->ebayListingProduct->isListingTypeFixed()) { + $data['price_fixed'] = number_format($this->ebayListingProduct->getFixedPrice(), 2); + + if ($this->ebayListingProduct->isPriceDiscountStp() && + $this->ebayListingProduct->getPriceDiscountStp() > $this->ebayListingProduct->getFixedPrice()) { + $data['price_stp'] = number_format($this->ebayListingProduct->getPriceDiscountStp(), 2); + } elseif ($this->ebayListingProduct->isPriceDiscountMap() && + $this->ebayListingProduct->getPriceDiscountMap() > $this->ebayListingProduct->getFixedPrice()) { + $data['price_map'] = number_format($this->ebayListingProduct->getPriceDiscountMap(), 2); + } + } else { + $data['price_start'] = number_format($this->ebayListingProduct->getStartPrice(), 2); + } + + $productPrice = null; + + if (empty($variations)) { + $productPrice = isset($data['price_fixed']) ? $data['price_fixed'] : $data['price_start']; + } else { + $variationPrices = array(); + + foreach ($variations['variations'] as $variation) { + if ($variation['data']['qty']) { + $variationPrices[] = $variation['data']; + } + } + + if (!empty($variationPrices)) { + + $min = $variationPrices[0]['price']; + $productPrice = $min; + $data['price_stp'] = $variationPrices[0]['price_stp']; + $data['price_map'] = $variationPrices[0]['price_map']; + + foreach ($variationPrices as $variationPrice) { + if ($variationPrice['price'] < $min) { + $productPrice = $variationPrice['price']; + $data['price_stp'] = $variationPrice['price_stp']; + $data['price_map'] = $variationPrice['price_map']; + } + } + } + } + + $data['price'] = $productPrice; + + return $data; + } + + public function getQty() + { + return $this->ebayListingProduct->getQty(); + } + + public function getCurrency() + { + return $this->ebayListingProduct->getEbayMarketplace()->getCurrency(); + } + + public function getCurrencySymbol() + { + return $this->currency->getCurrency($this->getCurrency())->getSymbol(); + } + + // --------------------------------------- + + public function getVariations() + { + if (!is_null($this->variations)) { + return $this->variations; + } + + $variations = $this->ebayListingProduct->getVariations(true); + $data = array(); + + if ($this->ebayListingProduct->getEbaySellingFormatTemplate()->isIgnoreVariationsEnabled()) { + return $this->variations = array(); + } + + if (!$this->ebayListingProduct->isListingTypeFixed()) { + return $this->variations = array(); + } + + if (!$this->ebayListingProduct->getEbayMarketplace()->isMultivariationEnabled()) { + return $this->variations = array(); + } + + foreach ($variations as $variation) { + + /** @var $variation \Ess\M2ePro\Model\Listing\Product\Variation */ + /** @var $productVariation \Ess\M2ePro\Model\Ebay\Listing\Product\Variation */ + + $productVariation = $variation->getChildObject(); + + $variationQty = $productVariation->getQty(); + if ($variationQty == 0) { + continue; + } + + /** @var $option \Ess\M2ePro\Model\Listing\Product\Variation\Option */ + + $options = $productVariation->getOptions(true); + + $variationData = array( + 'price' => number_format($productVariation->getPrice(), 2), + 'qty' => $variationQty, + 'price_stp' => null, + 'price_map' => null + ); + + if ($this->ebayListingProduct->isPriceDiscountStp() + && $productVariation->getPriceDiscountStp() > $productVariation->getPrice()) { + $variationData['price_stp'] = number_format($productVariation->getPriceDiscountStp(), 2); + } elseif ($this->ebayListingProduct->isPriceDiscountMap() + && $productVariation->getPriceDiscountMap() > $productVariation->getPrice()) { + $variationData['price_map'] = number_format($productVariation->getPriceDiscountMap(), 2); + } + + $variationSpecifics = array(); + + foreach ($options as $option) { + + $optionTitle = trim($option->getOption()); + $attributeTitle = trim($option->getAttribute()); + + $variationSpecifics[$attributeTitle] = $optionTitle; + $data['variation_sets'][$attributeTitle][] = $optionTitle; + } + + $variationData = array( + 'data' => $variationData, + 'specifics' => $variationSpecifics + ); + + $data['variations'][] = $variationData; + } + + if (!empty($data['variation_sets'])) { + foreach ($data['variation_sets'] as &$variationSets) { + $variationSets = array_unique($variationSets); + } + } + + return $this->variations = $data; + } + + // --------------------------------------- + + private function getConfigurableImagesAttributeLabels() + { + $descriptionTemplate = $this->ebayListingProduct->getEbayDescriptionTemplate(); + + if (!$descriptionTemplate->isVariationConfigurableImages()) { + return array(); + } + + $product = $this->ebayListingProduct->getMagentoProduct()->getProduct(); + + $attributeCodes = $descriptionTemplate->getDecodedVariationConfigurableImages(); + $attributes = array(); + + foreach ($attributeCodes as $attributeCode) { + /** @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */ + $attribute = $product->getResource()->getAttribute($attributeCode); + + if (!$attribute) { + continue; + } + + $attribute->setStoreId($product->getStoreId()); + $attributes[] = $attribute; + } + + if (empty($attributes)) { + return array(); + } + + $attributeLabels = array(); + + /** @var $productTypeInstance \Magento\ConfigurableProduct\Model\Product\Type\Configurable */ + $productTypeInstance = $this->ebayListingProduct->getMagentoProduct()->getTypeInstance(); + + foreach ($productTypeInstance->getConfigurableAttributes($product) as $configurableAttribute) { + + /** @var $configurableAttribute \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute */ + $configurableAttribute->setStoteId($product->getStoreId()); + + foreach ($attributes as $attribute) { + + if ((int)$attribute->getAttributeId() == (int)$configurableAttribute->getAttributeId()) { + + $attributeLabels = array_values($attribute->getStoreLabels()); + $attributeLabels[] = $configurableAttribute->getData('label'); + $attributeLabels[] = $attribute->getFrontendLabel(); + + $attributeLabels = array_filter($attributeLabels); + + break 2; + } + } + } + + return $attributeLabels; + } + + private function getImagesDataByAttributeLabels(array $attributeLabels) + { + $images = array(); + $attributeLabel = false; + + $variations = $this->ebayListingProduct->getVariations(true); + + foreach ($variations as $variation) { + + /** @var $variation \Ess\M2ePro\Model\Listing\Product\Variation */ + + if ($variation->getChildObject()->isDelete() || !$variation->getChildObject()->getQty()) { + continue; + } + + $options = $variation->getOptions(true); + + foreach ($options as $option) { + + /** @var $option \Ess\M2ePro\Model\Listing\Product\Variation\Option */ + + $foundAttributeLabel = false; + foreach ($attributeLabels as $tempLabel) { + if (strtolower($tempLabel) == strtolower($option->getAttribute())) { + $foundAttributeLabel = $option->getAttribute(); + break; + } + } + + if ($foundAttributeLabel === false) { + continue; + } + + $attributeLabel = $foundAttributeLabel; + + $optionImages = $this->ebayListingProduct->getEbayDescriptionTemplate() + ->getSource($option->getMagentoProduct()) + ->getVariationImages(); + + $links = array(); + foreach ($optionImages as $image) { + + if (!$image->getUrl()) { + continue; + } + + $links[] = $image->getUrl(); + } + + if (count($links) <= 0) { + continue; + } + + $images[$option->getOption()] = $links; + } + } + + if (!$attributeLabel || !$images) { + return array(); + } + + return array( + 'specific' => $attributeLabel, + 'images' => $images + ); + } + + public function getImages() + { + if (!is_null($this->images)) { + return $this->images; + } + + $images = array(); + + if ($this->ebayListingProduct->isVariationMode()) { + + $attributeLabels = array(); + $images['variations'] = array(); + + if ($this->ebayListingProduct->getMagentoProduct()->isConfigurableType()) { + $attributeLabels = $this->getConfigurableImagesAttributeLabels(); + } + + if ($this->ebayListingProduct->getMagentoProduct()->isGroupedType()) { + $attributeLabels = array(\Ess\M2ePro\Model\Magento\Product\Variation::GROUPED_PRODUCT_ATTRIBUTE_LABEL); + } + + if (count($attributeLabels) > 0) { + $images['variations'] = $this->getImagesDataByAttributeLabels($attributeLabels); + } + } + + $links = array(); + foreach ($this->ebayListingProduct->getDescriptionTemplateSource()->getGalleryImages() as $image) { + + if (!$image->getUrl()) { + continue; + } + $links[] = $image->getUrl(); + } + + $images['gallery'] = $links; + return $this->images = $images; + } + + // --------------------------------------- + + public function getCategory() + { + $finalCategory = ''; + $marketplaceId = $this->ebayListingProduct->getMarketplace()->getId(); + + if (is_null($this->ebayListingProduct->getCategoryTemplateSource())) { + return $finalCategory; + } + + $categoryId = $this->ebayListingProduct->getCategoryTemplateSource()->getMainCategory(); + $categoryTitle = $this->getHelper('Component\Ebay\Category\Ebay')->getPath($categoryId, $marketplaceId); + + if (!$categoryTitle) { + return $categoryTitle; + } + + $finalCategory = '' . str_replace('>', ' > ', $categoryTitle) . ' (' . $categoryId . ')'; + + return $finalCategory; + } + + public function getOtherCategories() + { + $otherCategoriesFinalTitles = array(); + + $marketplaceId = $this->ebayListingProduct->getMarketplace()->getId(); + $accountId = $this->ebayListingProduct->getEbayAccount()->getId(); + + $otherCategoryTemplateSource = $this->ebayListingProduct->getOtherCategoryTemplateSource(); + + if (is_null($otherCategoryTemplateSource)) { + return $otherCategoriesFinalTitles; + } + + $otherCategoriesIds = array( + 'secondary' => $otherCategoryTemplateSource->getSecondaryCategory(), + 'primary_store' => $otherCategoryTemplateSource->getStoreCategoryMain(), + 'secondary_store' => $otherCategoryTemplateSource->getStoreCategorySecondary() + ); + + $otherCategoriesTitles = array( + 'secondary' => $this->getHelper('Component\Ebay\Category\Ebay') + ->getPath($otherCategoriesIds['secondary'], $marketplaceId), + 'primary_store' => $this->getHelper('Component\Ebay\Category\Store') + ->getPath($otherCategoriesIds['primary_store'], $accountId), + 'secondary_store' => $this->getHelper('Component\Ebay\Category\Store') + ->getPath($otherCategoriesIds['secondary_store'], $accountId) + ); + + foreach ($otherCategoriesTitles as $otherCategoryType => $otherCategoryTitle) { + if ($otherCategoryTitle) { + $otherCategoriesFinalTitles[$otherCategoryType] = + '' . str_replace('>', ' > ', $otherCategoryTitle) + . ' (' . $otherCategoriesIds[$otherCategoryType] . ')'; + } + } + + return $otherCategoriesFinalTitles; + } + + public function getSpecifics() + { + $data = array(); + + if (is_null($this->ebayListingProduct->getCategoryTemplate())) { + return $data; + } + + foreach ($this->ebayListingProduct->getCategoryTemplate()->getSpecifics(true) as $specific) { + + /** @var $specific \Ess\M2ePro\Model\Ebay\Template\Category\Specific */ + + $tempAttributeLabel = $specific->getSource($this->ebayListingProduct->getMagentoProduct()) + ->getLabel(); + $tempAttributeValues = $specific->getSource($this->ebayListingProduct->getMagentoProduct()) + ->getValues(); + + $values = array(); + foreach ($tempAttributeValues as $tempAttributeValue) { + if ($tempAttributeValue == '--') { + continue; + } + $values[] = $tempAttributeValue; + } + + if (empty($values)) { + continue; + } + + $data[] = array( + 'name' => $tempAttributeLabel, + 'value' => $values + ); + } + + return $data; + } + + //######################################## + + private function getConditionHumanTitle($code) + { + $codes = array( + \Ess\M2ePro\Model\Ebay\Template\Description::CONDITION_EBAY_NEW => + $this->__('New'), + \Ess\M2ePro\Model\Ebay\Template\Description::CONDITION_EBAY_NEW_OTHER => + $this->__('New Other'), + \Ess\M2ePro\Model\Ebay\Template\Description::CONDITION_EBAY_NEW_WITH_DEFECT => + $this->__('New With Defects'), + \Ess\M2ePro\Model\Ebay\Template\Description::CONDITION_EBAY_MANUFACTURER_REFURBISHED => + $this->__('Manufacturer Refurbished'), + \Ess\M2ePro\Model\Ebay\Template\Description::CONDITION_EBAY_SELLER_REFURBISHED => + $this->__('Seller Refurbished, Re-manufactured'), + \Ess\M2ePro\Model\Ebay\Template\Description::CONDITION_EBAY_USED => + $this->__('Used'), + \Ess\M2ePro\Model\Ebay\Template\Description::CONDITION_EBAY_VERY_GOOD => + $this->__('Very Good'), + \Ess\M2ePro\Model\Ebay\Template\Description::CONDITION_EBAY_GOOD => + $this->__('Good'), + \Ess\M2ePro\Model\Ebay\Template\Description::CONDITION_EBAY_ACCEPTABLE => + $this->__('Acceptable'), + \Ess\M2ePro\Model\Ebay\Template\Description::CONDITION_EBAY_NOT_WORKING => + $this->__('For Parts or Not Working') + ); + + if (!isset($codes[$code])) { + return ''; + } + + return $codes[$code]; + } + + private function getCountryHumanTitle($countryId) + { + $countries = $this->getHelper('Magento')->getCountries(); + + foreach ($countries as $country) { + if ($countryId === $country['value']) { + return $this->__($country['label']); + } + } + return ''; + } + + private function getShippingServiceHumanTitle($serviceMethodId) + { + $shippingServicesInfo = $this->ebayListingProduct->getEbayMarketplace()->getShippingInfo(); + + foreach ($shippingServicesInfo as $shippingServiceInfo) { + foreach ($shippingServiceInfo['methods'] as $shippingServiceMethod) { + if ($serviceMethodId == $shippingServiceMethod['ebay_id']) { + return $this->__($shippingServiceMethod['title']); + } + } + } + return ''; + } + + private function getShippingLocationHumanTitle(array $locationIds) + { + $locationsTitle = array(); + $locationsInfo = $this->ebayListingProduct->getEbayMarketplace()->getShippingLocationInfo(); + + foreach ($locationIds as $locationId) { + foreach ($locationsInfo as $locationInfo) { + if ($locationId == $locationInfo['ebay_id']) { + $locationsTitle[] = $this->__($locationInfo['title']); + } + } + } + return $locationsTitle; + } + + private function getShippingExcludeLocationHumanTitle($excludeLocationId) + { + $excludeLocationsInfo = $this->ebayListingProduct->getEbayMarketplace()->getShippingLocationExcludeInfo(); + + foreach ($excludeLocationsInfo as $excludeLocationInfo) { + if ($excludeLocationId == $excludeLocationInfo['ebay_id']) { + return $this->__($excludeLocationInfo['title']); + } + } + return ''; + } + + public function getItemLocation() + { + $itemLocation = array( + $this->ebayListingProduct->getShippingTemplateSource()->getPostalCode(), + $this->ebayListingProduct->getShippingTemplateSource()->getAddress(), + $this->getCountryHumanTitle($this->ebayListingProduct->getShippingTemplateSource()->getCountry()) + ); + return implode($itemLocation, ', '); + } + + public function getShippingDispatchTime() + { + $dispatchTime = null; + + if ($this->ebayListingProduct->getShippingTemplate()->isLocalShippingFlatEnabled() || + $this->ebayListingProduct->getShippingTemplate()->isLocalShippingCalculatedEnabled() + ) { + + $dispatchTimeId = $this->ebayListingProduct->getShippingTemplate()->getDispatchTime(); + + if ($dispatchTimeId == 0) { + return $this->__('Same Business Day'); + } else { + $dispatchInfo = $this->ebayListingProduct->getEbayMarketplace()->getDispatchInfo(); + + foreach ($dispatchInfo as $dispatch) { + if ($dispatch['ebay_id'] == $dispatchTimeId) { + $dispatchTime = $dispatch['title']; + break; + } + } + + return $this->__($dispatchTime); + } + } + + return $dispatchTime; + } + + public function getShippingLocalHandlingCost() + { + if ($this->ebayListingProduct->getShippingTemplate()->isLocalShippingCalculatedEnabled()) { + return $this->ebayListingProduct->getShippingTemplate()->getCalculatedShipping() + ->getLocalHandlingCost(); + } + return 0; + } + + public function getShippingInternationalHandlingCost() + { + if ($this->ebayListingProduct->getShippingTemplate()->isLocalShippingCalculatedEnabled()) { + return $this->ebayListingProduct->getShippingTemplate()->getCalculatedShipping() + ->getInternationalHandlingCost(); + } + return 0; + } + + public function getShippingLocalType() + { + if ($this->ebayListingProduct->getShippingTemplate()->isLocalShippingLocalEnabled()) { + return $this->__('No Shipping - local pickup only'); + } + if ($this->ebayListingProduct->getShippingTemplate()->isLocalShippingFreightEnabled()) { + return $this->__('Freight - large Items'); + } + if ($this->ebayListingProduct->getShippingTemplate()->isLocalShippingFlatEnabled()) { + return $this->__('Flat - same cost to all Buyers'); + } + if ($this->ebayListingProduct->getShippingTemplate()->isLocalShippingCalculatedEnabled()) { + return $this->__('Calculated - cost varies by Buyer Location'); + } + + return ''; + } + + public function getShippingInternationalType() + { + if ($this->ebayListingProduct->getShippingTemplate()->isInternationalShippingNoInternationalEnabled()) { + return ''; + } + if ($this->ebayListingProduct->getShippingTemplate()->isInternationalShippingFlatEnabled()) { + return $this->__('Flat - same cost to all Buyers'); + } + if ($this->ebayListingProduct->getShippingTemplate()->isInternationalShippingCalculatedEnabled()) { + return $this->__('Calculated - cost varies by Buyer Location'); + } + + return ''; + } + + public function isLocalShippingCalculated() + { + return $this->ebayListingProduct->getShippingTemplate()->isLocalShippingCalculatedEnabled(); + } + + public function isInternationalShippingCalculated() + { + return $this->ebayListingProduct->getShippingTemplate()->isInternationalShippingCalculatedEnabled(); + } + + public function getShippingLocalServices() + { + $services = array(); + + foreach ($this->ebayListingProduct->getShippingTemplate()->getServices(true) as $service) { + + /** @var $service \Ess\M2ePro\Model\Ebay\Template\Shipping\Service */ + + if (!$service->isShippingTypeLocal()) { + continue; + } + + $tempDataMethod = array( + 'service' => $this->getShippingServiceHumanTitle($service->getShippingValue()) + ); + + if ($this->ebayListingProduct->getShippingTemplate()->isLocalShippingFlatEnabled()) { + + $tempDataMethod['cost'] = $service->getSource($this->ebayListingProduct->getMagentoProduct()) + ->getCost(); + + $tempDataMethod['cost_additional'] = $service->getSource($this->ebayListingProduct->getMagentoProduct()) + ->getCostAdditional(); + } + + if ($this->ebayListingProduct->getShippingTemplate()->isLocalShippingCalculatedEnabled()) { + $tempDataMethod['is_free'] = $service->isCostModeFree(); + } + + $services[] = $tempDataMethod; + } + + return $services; + } + + public function getShippingInternationalServices() + { + $services = array(); + + foreach ($this->ebayListingProduct->getShippingTemplate()->getServices(true) as $service) { + + /** @var $service \Ess\M2ePro\Model\Ebay\Template\Shipping\Service */ + + if (!$service->isShippingTypeInternational()) { + continue; + } + + $tempDataMethod = array( + 'service' => $this->getShippingServiceHumanTitle($service->getShippingValue()), + 'locations' => implode(', ', $this->getShippingLocationHumanTitle($service->getLocations())) + ); + + if ($this->ebayListingProduct->getShippingTemplate()->isInternationalShippingFlatEnabled()) { + + $tempDataMethod['cost'] = $service->getSource($this->ebayListingProduct->getMagentoProduct()) + ->getCost(); + + $tempDataMethod['cost_additional'] = $service->getSource($this->ebayListingProduct->getMagentoProduct()) + ->getCostAdditional(); + } + + $services[] = $tempDataMethod; + } + + return $services; + } + + public function getPayment() + { + $data = array(); + + if ($this->ebayListingProduct->getPaymentTemplate()->isPayPalEnabled()) { + $data['paypal'] = true; + } + + $services = $this->ebayListingProduct->getPaymentTemplate()->getServices(true); + $paymentMethodsInfo = $this->ebayListingProduct->getMarketplace()->getChildObject()->getPaymentInfo(); + + $paymentMethods = array(); + foreach ($services as $service) { + /** @var $service \Ess\M2ePro\Model\Ebay\Template\Payment\Service */ + + foreach ($paymentMethodsInfo as $paymentMethodInfo) { + if ($service->getCodeName() == $paymentMethodInfo['ebay_id']) { + $paymentMethods[] = $paymentMethodInfo['title']; + } + } + } + + $data['paymentMethods'] = $paymentMethods; + + return $data; + } + + public function getShippingExcludedLocations() + { + $locations = array(); + + foreach ($this->ebayListingProduct->getShippingTemplate()->getExcludedLocations() as $location) { + $locations[] = $this->getShippingExcludeLocationHumanTitle($location['code']); + } + + return implode(', ', $locations); + } + + public function getShippingInternationalGlobalOffer() + { + return $this->ebayListingProduct->getShippingTemplate()->isGlobalShippingProgramEnabled(); + } + + public function getReturnPolicy() + { + $returnPolicyInfo = $this->ebayListingProduct->getEbayMarketplace()->getReturnPolicyInfo(); + + $returnAccepted = $this->ebayListingProduct->getReturnTemplate()->getAccepted(); + if ($returnAccepted === 'ReturnsNotAccepted') { + return array(); + } + + $returnPolicyTitles = array( + 'returns_accepted' => '', + 'returns_within' => '', + 'refund' => '', + 'shipping_cost_paid_by' => '', + 'restocking_fee_value' => '' + ); + + foreach ($returnPolicyInfo['returns_accepted'] as $returnAcceptedId) { + if ($returnAccepted === $returnAcceptedId['ebay_id']) { + $returnPolicyTitles['returns_accepted'] = $this->__($returnAcceptedId['title']); + break; + } + } + + $returnWithin = $this->ebayListingProduct->getReturnTemplate()->getWithin(); + foreach ($returnPolicyInfo['returns_within'] as $returnWithinId) { + if ($returnWithin === $returnWithinId['ebay_id']) { + $returnPolicyTitles['returns_within'] = $this->__($returnWithinId['title']); + break; + } + } + + $returnRefund = $this->ebayListingProduct->getReturnTemplate()->getOption(); + foreach ($returnPolicyInfo['refund'] as $returnRefundId) { + if ($returnRefund === $returnRefundId['ebay_id']) { + $returnPolicyTitles['refund'] = $this->__($returnRefundId['title']); + break; + } + } + + $returnShippingCost = $this->ebayListingProduct->getReturnTemplate()->getShippingCost(); + foreach ($returnPolicyInfo['shipping_cost_paid_by'] as $returnShippingCostId) { + if ($returnShippingCost === $returnShippingCostId['ebay_id']) { + $returnPolicyTitles['shipping_cost_paid_by'] = + $this->__($returnShippingCostId['title']); + break; + } + } + + $returnRestockingFee = $this->ebayListingProduct->getReturnTemplate()->getRestockingFee(); + if ($returnRestockingFee === "NoRestockingFee") { + $returnPolicyTitles['restocking_fee_value'] = ''; + } else { + foreach ($returnPolicyInfo['restocking_fee_value'] as $returnRestockingFeeId) { + if ($returnRestockingFee === $returnRestockingFeeId['ebay_id']) { + $returnPolicyTitles['restocking_fee_value'] = + $this->__($returnRestockingFeeId['title']); + break; + } + } + } + + $returnPolicyTitles['is_holiday_enabled'] = $this->ebayListingProduct->getReturnTemplate()->isHolidayEnabled(); + $returnPolicyTitles['description'] = $this->ebayListingProduct->getReturnTemplate()->getDescription(); + + return $returnPolicyTitles; + } +} \ No newline at end of file diff --git a/Block/Adminhtml/Ebay/Listing/Product/Add.php b/Block/Adminhtml/Ebay/Listing/Product/Add.php index 1b04026a9..0b700b286 100644 --- a/Block/Adminhtml/Ebay/Listing/Product/Add.php +++ b/Block/Adminhtml/Ebay/Listing/Product/Add.php @@ -95,8 +95,18 @@ public function getGridHtml() 'data' => ['listing' => $this->getHelper('Data\GlobalData')->getValue('listing_for_products_add')] ]); - return $viewHeaderBlock->toHtml() . - parent::getGridHtml(); + $hideOthersListingsProductsFilterBlock = $this->createBlock( + 'Listing\Product\ShowOthersListingsProductsFilter' + )->setData([ + 'component_mode' => \Ess\M2ePro\Helper\Component\Ebay::NICK, + 'controller' => 'ebay_listing_product_add' + ]); + + return $viewHeaderBlock->toHtml() + . '
    ' + . $hideOthersListingsProductsFilterBlock->toHtml() + . '
    ' + . parent::getGridHtml(); } protected function _toHtml() diff --git a/Block/Adminhtml/Ebay/Listing/Product/Add/Category/Grid.php b/Block/Adminhtml/Ebay/Listing/Product/Add/Category/Grid.php index 4fb36a2a3..b570c1afa 100644 --- a/Block/Adminhtml/Ebay/Listing/Product/Add/Category/Grid.php +++ b/Block/Adminhtml/Ebay/Listing/Product/Add/Category/Grid.php @@ -49,6 +49,28 @@ protected function _prepareMassaction() $this->getRequest()->setPostValue($this->getMassactionBlock()->getFormFieldNameInternal(), implode(',',$ids)); + $this->css->add(<<getId()} > .admin__data-grid-header > .admin__data-grid-header-row:first-child { + width: 100% !important; + margin-top: 1.1em; + } + #{$this->getId()} > .admin__data-grid-header > .admin__data-grid-header-row:last-child { + width: 100% !important; + } + + #{$this->getId()} > .admin__data-grid-header > + .admin__data-grid-header-row:last-child .admin__control-support-text { + margin-left: 0; + } + + #{$this->getId()} > .admin__data-grid-header > + .admin__data-grid-header-row:last-child .mass-select-wrap { + margin-left: -1.3em !important; + } +CSS + ); + return parent::_prepareMassaction(); } diff --git a/Block/Adminhtml/Ebay/Listing/Product/Add/Category/Tree.php b/Block/Adminhtml/Ebay/Listing/Product/Add/Category/Tree.php index 1d768a9ff..2534df375 100644 --- a/Block/Adminhtml/Ebay/Listing/Product/Add/Category/Tree.php +++ b/Block/Adminhtml/Ebay/Listing/Product/Add/Category/Tree.php @@ -18,11 +18,13 @@ class Tree extends \Ess\M2ePro\Block\Adminhtml\Listing\Category\Tree /* @var \Magento\Framework\Data\Tree\Node */ protected $currentNode = NULL; + protected $resourceConnection; protected $categoryTreeFactory; //######################################## public function __construct( + \Magento\Framework\App\ResourceConnection $resourceConnection, \Magento\Catalog\Model\ResourceModel\Category\TreeFactory $categoryTreeFactory, \Ess\M2ePro\Block\Adminhtml\Magento\Context\Template $blockContext, \Magento\Backend\Block\Template\Context $context, @@ -32,6 +34,7 @@ public function __construct( array $data = [] ) { + $this->resourceConnection = $resourceConnection; $this->categoryTreeFactory = $categoryTreeFactory; parent::__construct( $blockContext, @@ -236,7 +239,7 @@ public function getAffectedCategoriesCount() $collection = $this->_categoryFactory->create()->getCollection(); $dbSelect = $collection->getConnection()->select() - ->from($collection->getResource()->getTable('catalog_category_product'), 'category_id') + ->from($this->resourceConnection->getTableName('catalog_category_product'), 'category_id') ->where('`product_id` IN(?)',$this->getSelectedIds()); $affectedCategoriesCount = $collection->getSelectCountSql() @@ -264,8 +267,8 @@ public function getProductsForEachCategory() $collection = $this->_categoryFactory->create()->getCollection(); $select = $collection->getSelect(); $select->joinLeft( - $collection->getResource()->getTable('catalog_category_product'), - "entity_id = category_id AND product_id IN ({$ids})", + ['ccp' => $this->resourceConnection->getTableName('catalog_category_product')], + "e.entity_id = ccp.category_id AND ccp.product_id IN ({$ids})", array('product_id') ); @@ -329,7 +332,7 @@ protected function loadProductsCount($collection) $select = $collection->getConnection()->select(); $select->from( - array('main_table' => $collection->getTable('catalog_category_product')), + array('main_table' => $this->resourceConnection->getTableName('catalog_category_product')), array('category_id', new \Zend_Db_Expr('COUNT(main_table.product_id)')) ) ->where($collection->getConnection()->quoteInto('main_table.category_id IN(?)', array_keys($items))) diff --git a/Block/Adminhtml/Ebay/Listing/Product/Add/Grid.php b/Block/Adminhtml/Ebay/Listing/Product/Add/Grid.php index 569085cc9..00675ff63 100644 --- a/Block/Adminhtml/Ebay/Listing/Product/Add/Grid.php +++ b/Block/Adminhtml/Ebay/Listing/Product/Add/Grid.php @@ -45,6 +45,7 @@ public function _construct() // --------------------------------------- $this->hideMassactionDropDown = true; + $this->showAdvancedFilterProductsOption = false; } //######################################## @@ -98,8 +99,10 @@ protected function _prepareCollection() // Hide products others listings // --------------------------------------- - $prefix = $this->getHelper('Data\GlobalData')->getValue('hide_products_others_listings_prefix'); - is_null($hideParam = $this->getHelper('Data\Session')->getValue($prefix)) && $hideParam = true; + $hideParam = true; + if ($this->getRequest()->has('show_products_others_listings')) { + $hideParam = false; + } if ($hideParam || isset($this->listing['id'])) { @@ -273,9 +276,27 @@ protected function _getStore() //######################################## + abstract protected function getSelectedProductsCallback(); + + //######################################## + protected function _toHtml() { if ($this->getRequest()->isXmlHttpRequest()) { + $this->js->add(<< The Products you add to the Listing will further be Listed on eBay.


    There are several different options of how Magento products can be found/selected and added to the Listing.


    -

    More detailed information you can find here.

    ', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/dwItAQ') +

    More detailed information you can find + here.

    ', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/dwItAQ') ) ] ); diff --git a/Block/Adminhtml/Ebay/Listing/Product/Category/Settings/Chooser.php b/Block/Adminhtml/Ebay/Listing/Product/Category/Settings/Chooser.php index 6a6e37ca0..ec8955ed3 100644 --- a/Block/Adminhtml/Ebay/Listing/Product/Category/Settings/Chooser.php +++ b/Block/Adminhtml/Ebay/Listing/Product/Category/Settings/Chooser.php @@ -320,11 +320,12 @@ public function getHelpBlockHtml() { $helpBlock = $this->createBlock('HelpBlock', '', ['data' => [ 'content' => $this->__( - '

    To have new eBay Items listed automatically, eBay Primary Category must be specified along with - the M2E Pro Listing Policy settings.


    -

    Also, you can select an eBay Store category if needed.


    -

    More detailed information you can find here.

    ', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/lAItAQ') + '

    To have new eBay Items listed automatically, eBay Catalog Primary Category must be + specified along with the M2E Pro Listing Policy settings.


    +

    Also, you can select an eBay Store Catalog category if needed.


    +

    More detailed information you can find + here.

    ', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/lAItAQ') ) ]])->toHtml(); diff --git a/Block/Adminhtml/Ebay/Listing/Product/Category/Settings/Chooser/Tabs/Browse.php b/Block/Adminhtml/Ebay/Listing/Product/Category/Settings/Chooser/Tabs/Browse.php index 96c69dc01..971d10031 100644 --- a/Block/Adminhtml/Ebay/Listing/Product/Category/Settings/Chooser/Tabs/Browse.php +++ b/Block/Adminhtml/Ebay/Listing/Product/Category/Settings/Chooser/Tabs/Browse.php @@ -27,5 +27,10 @@ public function _construct() // --------------------------------------- } + public function isWizardActive() + { + return $this->getHelper('Module\Wizard')->isActive(\Ess\M2ePro\Helper\View\Ebay::WIZARD_INSTALLATION_NICK); + } + //######################################## } \ No newline at end of file diff --git a/Block/Adminhtml/Ebay/Listing/Product/Category/Settings/Mode/Category/Grid.php b/Block/Adminhtml/Ebay/Listing/Product/Category/Settings/Mode/Category/Grid.php index e2b16298f..5325a1986 100644 --- a/Block/Adminhtml/Ebay/Listing/Product/Category/Settings/Mode/Category/Grid.php +++ b/Block/Adminhtml/Ebay/Listing/Product/Category/Settings/Mode/Category/Grid.php @@ -366,6 +366,8 @@ protected function _toHtml() JS ); + $this->css->add('.grid-listing-column-actions { width:100px; }'); + return parent::_toHtml(); } diff --git a/Block/Adminhtml/Ebay/Listing/Product/Category/Settings/Mode/Form.php b/Block/Adminhtml/Ebay/Listing/Product/Category/Settings/Mode/Form.php index b3774c03a..84155dc5a 100644 --- a/Block/Adminhtml/Ebay/Listing/Product/Category/Settings/Mode/Form.php +++ b/Block/Adminhtml/Ebay/Listing/Product/Category/Settings/Mode/Form.php @@ -1,9 +1,9 @@ __($text); // M2ePro_TRANSLATIONS - // Set eBay Primary Category for Product(s) - $text = 'Set eBay Primary Category for Product(s)'; + // Set eBay Catalog Primary Category for Product(s) + $text = 'Set eBay Catalog Primary Category for Product(s)'; $translations[$text] = $this->__($text); $this->jsTranslator->addTranslations($translations); diff --git a/Block/Adminhtml/Ebay/Listing/Search/Grid.php b/Block/Adminhtml/Ebay/Listing/Search/Grid.php index a8c28cc8d..dffbc6833 100644 --- a/Block/Adminhtml/Ebay/Listing/Search/Grid.php +++ b/Block/Adminhtml/Ebay/Listing/Search/Grid.php @@ -67,11 +67,20 @@ protected function _prepareCollection() // Get collection products in listing // --------------------------------------- $nameAttribute = $this->resourceCatalogProduct->getAttribute('name'); - $nameAttributeId = $nameAttribute ? (int)$nameAttribute->getId() : 0; $listingProductCollection = $this->ebayFactory->getObject('Listing\Product')->getCollection(); $listingProductCollection->getSelect()->distinct(); + // Communicate with magento product table + // --------------------------------------- + $dbSelect = $this->resourceConnection->getConnection() + ->select() + ->from($this->resourceConnection->getTableName('catalog_product_entity_varchar'), + new \Zend_Db_Expr('MAX(`store_id`)')) + ->where("`entity_id` = `main_table`.`product_id`") + ->where("`attribute_id` = `ea`.`attribute_id`") + ->where("`store_id` = 0 OR `store_id` = `l`.`store_id`"); + $listingProductCollection->getSelect()->join( array('l' => $this->activeRecordFactory->getObject('Listing')->getResource()->getMainTable()), '`l`.`id` = `main_table`.`listing_id`' @@ -84,14 +93,14 @@ protected function _prepareCollection() $listingProductCollection->getSelect()->join( array('cpe' => $this->resourceConnection->getTableName('catalog_product_entity')), - 'cpe.entity_id = `main_table`.product_id' + 'cpe.entity_id = `main_table`.product_id', + array('magento_sku'=>'sku') ); $listingProductCollection->getSelect()->joinLeft( array('cpev' => $this->resourceConnection->getTableName('catalog_product_entity_varchar')), - '`cpev`.`entity_id` = `main_table`.`product_id`' - . ' AND `cpev`.`attribute_id` = ' . $nameAttributeId - . ' AND `cpev`.`store_id` = 0' + "(`cpev`.`entity_id` = `main_table`.product_id)", + array('value') ); $listingProductCollection->getSelect()->joinLeft( @@ -99,6 +108,14 @@ protected function _prepareCollection() '(`ebit`.`id` = `second_table`.`ebay_item_id`)', array('item_id') ); + + $listingProductCollection->getSelect()->join( + array('ea'=> $this->resourceConnection->getTableName('eav_attribute')), + '(`cpev`.`attribute_id` = `ea`.`attribute_id` AND `ea`.`attribute_code` = \'name\')', + array() + ); + + $listingProductCollection->getSelect()->where('`cpev`.`store_id` = ('.$dbSelect->__toString().')'); // --------------------------------------- // add stock availability, status & visibility to select @@ -114,6 +131,7 @@ protected function _prepareCollection() $listingProductCollection->getSelect()->columns( array( 'account_id' => 'l.account_id', + 'store_id' => 'l.store_id', 'marketplace_id' => 'l.marketplace_id', 'product_id' => 'main_table.product_id', 'product_name' => 'cpev.value', @@ -192,6 +210,7 @@ protected function _prepareCollection() $listingOtherCollection->getSelect()->columns( array( 'account_id' => 'main_table.account_id', + 'store_id' => new \Zend_Db_Expr(0), 'marketplace_id' => 'main_table.marketplace_id', 'product_id' => 'main_table.product_id', 'product_name' => 'second_table.title', @@ -238,6 +257,7 @@ protected function _prepareCollection() array('main_table' => $unionSelect), array( 'account_id', + 'store_id', 'marketplace_id', 'product_id', 'product_name', @@ -625,8 +645,6 @@ public function callbackColumnPrice($value, $row, $column, $isExport) $startPriceText = $this->__('Start Price'); - $iconHelpPath = $this->getViewFileUrl('Ess_M2ePro::images/i_logo.png'); - $toolTipIconPath = $this->getSkinUrl('Ess_M2ePro::images/i_icon.png'); $onlineCurrentPriceHtml = ''; $onlineReservePriceHtml = ''; $onlineBuyItNowPriceHtml = ''; @@ -649,17 +667,18 @@ public function callbackColumnPrice($value, $row, $column, $isExport) $onlineBuyItNowPriceHtml = ''.$buyItNowText.': '.$onlineBuyItNowStr; } - $intervalHtml = << +HTML + ); + + $intervalHtml = <<{$intervalHtml} HTML; if ($onlineCurrentPrice > $onlineStartPrice) { diff --git a/Block/Adminhtml/Ebay/Listing/Template/NewTemplate/Form.php b/Block/Adminhtml/Ebay/Listing/Template/NewTemplate/Form.php index c3c4efabb..0b9573378 100644 --- a/Block/Adminhtml/Ebay/Listing/Template/NewTemplate/Form.php +++ b/Block/Adminhtml/Ebay/Listing/Template/NewTemplate/Form.php @@ -1,9 +1,9 @@ Saving Policy under a distinctive title will let you easily and quickly search for it in case you need to use it in a different M2E Pro Listing in the future.


    More detailed information you can find - here.

    ', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/8wItAQ') + here.

    ', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/8wItAQ') ) ] ); diff --git a/Block/Adminhtml/Ebay/Listing/Template/Switcher.php b/Block/Adminhtml/Ebay/Listing/Template/Switcher.php index fadd0a51c..474165476 100644 --- a/Block/Adminhtml/Ebay/Listing/Template/Switcher.php +++ b/Block/Adminhtml/Ebay/Listing/Template/Switcher.php @@ -26,6 +26,10 @@ public function _construct() public function getHeaderText() { + if ($this->getData('custom_header_text')) { + return $this->getData('custom_header_text'); + } + $title = ''; switch ($this->getTemplateNick()) { diff --git a/Block/Adminhtml/Ebay/Listing/View.php b/Block/Adminhtml/Ebay/Listing/View.php index 60b26322c..64c8975b0 100644 --- a/Block/Adminhtml/Ebay/Listing/View.php +++ b/Block/Adminhtml/Ebay/Listing/View.php @@ -58,9 +58,7 @@ protected function _prepareLayout() '

    M2E Pro Listing is a group of Magento Products sold on a certain Marketplace from a particular Account. M2E Pro has several options to display the content of Listings referring to different data details. Each of the view options contains a - unique set of available Actions accessible in the Mass Actions drop-down.


    -

    More detailed information you can find here.

    ', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/eQItAQ') + unique set of available Actions accessible in the Mass Actions drop-down.

    ' ) ]); @@ -82,21 +80,6 @@ protected function _prepareLayout() )); // --------------------------------------- - // --------------------------------------- - // TODO NOT SUPPORTED FEATURES "PickupStore" -// if ($this->listing->getAccount()->getChildObject()->isPickupStoreEnabled() && -// $this->getHelper('Component\Ebay\PickupStore')->isFeatureEnabled()) { -// $pickupStoreUrl = $this->getUrl('*/ebay_listing_pickupStore/index', array( -// 'id' => $this->listing->getId() -// )); -// $this->addButton('pickup_store_management', array( -// 'label' => $this->__('In-Store Pickup Management'), -// 'onclick' => 'window.open(\'' . $pickupStoreUrl . '\',\'_current\')', -// 'class' => 'success' -// )); -// } - // --------------------------------------- - $url = $this->getUrl( '*/ebay_listing_log', array( @@ -169,63 +152,6 @@ protected function getParam($paramName, $default = NULL) //######################################## - // TODO NOT SUPPORTED FEATURES "Listing header selector" -// public function getHeaderHtml() -// { -// // --------------------------------------- -// $collection = Mage::getModel('M2ePro/Listing')->getCollection(); -// $collection->addFieldToFilter('component_mode', Ess_M2ePro_Helper_Component_Ebay::NICK); -// $collection->addFieldToFilter('id', array('neq' => $this->listing->getId())); -// $collection->setPageSize(200); -// $collection->setOrder('title', 'ASC'); -// -// $items = array(); -// foreach ($collection->getItems() as $item) { -// $items[] = array( -// 'label' => $item->getTitle(), -// 'url' => $this->getUrl('*/*/view', array('id' => $item->getId())) -// ); -// } -// // --------------------------------------- -// -// if (count($items) == 0) { -// return parent::getHeaderHtml(); -// } -// -// // --------------------------------------- -// $data = array( -// 'target_css_class' => 'listing-profile-title', -// 'style' => 'max-height: 120px; overflow: auto; width: 200px;', -// 'items' => $items -// ); -// $dropDownBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_button_dropDown'); -// $dropDownBlock->setData($data); -// // --------------------------------------- -// -// return parent::getHeaderHtml() . $dropDownBlock->toHtml(); -// } - -// TODO NOT SUPPORTED FEATURES "Listing header selector" -// public function getHeaderText() -// { -// // --------------------------------------- -// $changeProfile = $this->__('Change Listing'); -// $headerText = parent::getHeaderText(); -// $listingTitle = Mage::helper('M2ePro')->escapeHtml($this->listing->getTitle()); -// // --------------------------------------- -// -// return <<"{$listingTitle}" -//HTML; -// } - - //######################################## - protected function _toHtml() { return '
    ' . @@ -245,8 +171,6 @@ public function getGridHtml() $html = ''; - // TODO NOT SUPPORTED FEATURES "Listing header selector" - // --------------------------------------- $viewHeaderBlock = $this->createBlock('Listing\View\Header','', [ 'data' => ['listing' => $this->listing] @@ -259,7 +183,6 @@ public function getGridHtml() // --------------------------------------- - // TODO NOT SUPPORTED FEATURES $this->jsUrl->addUrls(array_merge( array(), $helper->getControllerActions( @@ -268,23 +191,8 @@ public function getGridHtml() $helper->getControllerActions( 'Ebay\Listing\AutoAction', array('id' => $this->getRequest()->getParam('id')) ), -// $helper->getControllerActions( -// 'ebay_listing_transferring', array('listing_id' => $this->getRequest()->getParam('id')) -// ), -// $helper->getControllerActions('ebay_account'), -// $helper->getControllerActions('ebay_listing_product_category_settings'), -// $helper->getControllerActions('ebay_marketplace'), -// array('logViewUrl' => -// $this->getUrl('*/amazon_listing_log/synchronization', -// array('back'=>$helper->makeBackUrlParam('*/common_synchronization/index')))), -// array('runSynchNow' => -// $this->getUrl('*/common_marketplace/runSynchNow')), -// array('synchCheckProcessingNow' => -// $this->getUrl('*/common_synchronization/synchCheckProcessingNow')), array('variationProductManage' => $this->getUrl('*/ebay_listing_variation_product_manage/index')) -// array('getListingProductBids' => -// $this->getUrl('*/ebay_listing/getListingProductBids')) )); // --------------------------------------- diff --git a/Block/Adminhtml/Ebay/Listing/View/Ebay/Fee/Details.php b/Block/Adminhtml/Ebay/Listing/View/Ebay/Fee/Details.php new file mode 100644 index 000000000..497f9e30f --- /dev/null +++ b/Block/Adminhtml/Ebay/Listing/View/Ebay/Fee/Details.php @@ -0,0 +1,67 @@ +localeCurrency = $localeCurrency; + parent::__construct($context, $data); + } + + //######################################## + + public function _construct() + { + parent::_construct(); + + // Initialization block + // --------------------------------------- + $this->setId('ebayListingViewFeeDetails'); + // --------------------------------------- + + $this->setTemplate('ebay/listing/view/ebay/fee/details.phtml'); + } + + public function getFees() + { + if (empty($this->_data['fees']) || !is_array($this->_data['fees'])) { + throw new \Ess\M2ePro\Model\Exception\Logic('Fees are not set.'); + } + + $preparedData = array(); + + foreach ($this->_data['fees'] as $feeName => $feeData) { + if ($feeData['fee'] <= 0 && $feeName != 'listing_fee') { + continue; + } + + $camelCasedFeeName = str_replace('_', ' ', $feeName); + $camelCasedFeeName = ucwords($camelCasedFeeName); + + $preparedData[$feeName] = array( + 'label' => $camelCasedFeeName, + 'value' => $this->localeCurrency->getCurrency($feeData['currency'])->toCurrency($feeData['fee']) + ); + } + + return $preparedData; + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/Ebay/Listing/View/Ebay/Fee/Errors.php b/Block/Adminhtml/Ebay/Listing/View/Ebay/Fee/Errors.php new file mode 100644 index 000000000..c04a5887d --- /dev/null +++ b/Block/Adminhtml/Ebay/Listing/View/Ebay/Fee/Errors.php @@ -0,0 +1,37 @@ +setId('ebayListingViewFeeErrors'); + // --------------------------------------- + + $this->setTemplate('ebay/listing/view/ebay/fee/errors.phtml'); + } + + public function getErrors() + { + if (empty($this->_data['errors']) || !is_array($this->_data['errors'])) { + throw new \Ess\M2ePro\Model\Exception\Logic('Errors are not set.'); + } + + return $this->_data['errors']; + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/Ebay/Listing/View/Ebay/Fee/Product.php b/Block/Adminhtml/Ebay/Listing/View/Ebay/Fee/Product.php new file mode 100644 index 000000000..8c105b1fd --- /dev/null +++ b/Block/Adminhtml/Ebay/Listing/View/Ebay/Fee/Product.php @@ -0,0 +1,60 @@ +setId('ebayListingViewFeePreview'); + // --------------------------------------- + + $this->setTemplate('ebay/listing/view/ebay/fee/product.phtml'); + } + + public function getFees() + { + if (empty($this->_data['fees']) || !is_array($this->_data['fees'])) { + throw new \Ess\M2ePro\Model\Exception\Logic('Fees are not set.'); + } + + return $this->_data['fees']; + } + + public function getTotalFee() + { + $fees = $this->getFees(); + + return $this->modelFactory->getObject('Currency')->formatPrice( + $fees['listing_fee']['currency'], + $fees['listing_fee']['fee'] + ); + } + + protected function _beforeToHtml() + { + // --------------------------------------- + $details = $this->createBlock('Ebay\Listing\View\Ebay\Fee\Details'); + $details->setData('fees', $this->getFees()); + $details->setData('product_name', $this->getData('product_name')); + + $this->setChild('details', $details); + // --------------------------------------- + + return parent::_beforeToHtml(); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/Ebay/Listing/View/Ebay/Grid.php b/Block/Adminhtml/Ebay/Listing/View/Ebay/Grid.php index 6a33970d6..b27f8807c 100644 --- a/Block/Adminhtml/Ebay/Listing/View/Ebay/Grid.php +++ b/Block/Adminhtml/Ebay/Listing/View/Ebay/Grid.php @@ -13,10 +13,8 @@ class Grid extends \Ess\M2ePro\Block\Adminhtml\Listing\View\Grid protected $magentoProductCollectionFactory; protected $ebayFactory; - protected $priceCurrency; - protected $scopeConfig; + protected $localeCurrency; protected $resourceConnection; - protected $timeZone; protected $productResource; //######################################## @@ -24,10 +22,8 @@ class Grid extends \Ess\M2ePro\Block\Adminhtml\Listing\View\Grid public function __construct( \Ess\M2ePro\Model\ResourceModel\Magento\Product\CollectionFactory $magentoProductCollectionFactory, \Ess\M2ePro\Model\ActiveRecord\Component\Parent\Ebay\Factory $ebayFactory, - \Magento\Directory\Model\PriceCurrency $priceCurrency, - \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, + \Magento\Framework\Locale\CurrencyInterface $localeCurrency, \Magento\Framework\App\ResourceConnection $resourceConnection, - \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timeZone, \Magento\Catalog\Model\ResourceModel\Product $productResource, \Ess\M2ePro\Block\Adminhtml\Magento\Context\Template $context, \Magento\Backend\Helper\Data $backendHelper, @@ -36,10 +32,8 @@ public function __construct( { $this->magentoProductCollectionFactory = $magentoProductCollectionFactory; $this->ebayFactory = $ebayFactory; - $this->priceCurrency = $priceCurrency; - $this->scopeConfig = $scopeConfig; + $this->localeCurrency = $localeCurrency; $this->resourceConnection = $resourceConnection; - $this->timeZone = $timeZone; $this->productResource = $productResource; parent::__construct($context, $backendHelper, $data); @@ -254,6 +248,7 @@ protected function _prepareColumns() 'width' => '150px', 'type' => 'datetime', 'format' => \IntlDateFormatter::MEDIUM, + 'filter_time' => true, 'index' => 'end_date', 'frame_callback' => array($this, 'callbackColumnEndTime') )); @@ -277,21 +272,6 @@ protected function _prepareColumns() 'frame_callback' => array($this, 'callbackColumnStatus') )); - // TODO -// if ($this->getHelper('Module')->isDevelopmentMode()) { -// $this->addColumn('developer_action', array( -// 'header' => $this->__('Actions'), -// 'align' => 'left', -// 'width' => '150px', -// 'type' => 'text', -// 'renderer' => 'M2ePro/listing_view_grid_column_renderer_developerAction', -// 'index' => 'value', -// 'filter' => false, -// 'sortable' => false, -// 'js_handler' => 'EbayListingViewEbayGridObj' -// )); -// } - return parent::_prepareColumns(); } @@ -343,17 +323,17 @@ protected function _prepareMassaction() 'confirm' => $this->__('Are you sure?') ), 'actions'); + $this->getMassactionBlock()->addItem('previewItems', array( + 'label' => $this->__('Preview Items'), + 'url' => '', + 'confirm' => $this->__('Are you sure?') + ), 'other'); + $this->getMassactionBlock()->addItem('remove', array( 'label' => $this->__('Remove From Listing'), 'url' => '', 'confirm' => $this->__('Are you sure?') - ), 'actions'); - -// $this->getMassactionBlock()->addItem('previewItems', array( -// 'label' => $this->__('Preview Items'), -// 'url' => '', -// 'confirm' => '' -// ), 'other'); + ), 'other'); // --------------------------------------- @@ -374,7 +354,10 @@ public function callbackColumnTitle($value, $row, $column, $isExport) $valueHtml = '' . $title . ''; if (!empty($onlineTitle) && $this->isTerapeakWidgetEnabled) { - //$valueHtml .= $this->getTerapeakButtonHtml($row); + $valueHtml = '' . + $valueHtml . + $this->getTerapeakButtonHtml($row) . + ''; } if (is_null($sku = $row->getData('sku'))) { @@ -396,11 +379,6 @@ public function callbackColumnTitle($value, $row, $column, $isExport) $this->getHelper('Data')->escapeHtml($category); } - // TODO Item Fee -// $valueHtml .= '
    ' . -// '' . $this->__('eBay Fee') . ': ' . -// $this->getItemFeeHtml($row); - /** @var \Ess\M2ePro\Model\Listing\Product $listingProduct */ $listingProduct = $this->ebayFactory->getObjectLoaded('Listing\Product',$row->getData('listing_product_id')); @@ -447,25 +425,34 @@ private function getItemFeeHtml($row) $additionalData = (array)json_decode($row->getData('additional_data'), true); if (empty($additionalData['ebay_item_fees']['listing_fee']['fee'])) { - return $this->modelFactory->getObject('Currency')->formatPrice( + + $price = $this->modelFactory->getObject('Currency')->formatPrice( $this->listing->getMarketplace()->getChildObject()->getCurrency(), 0 ); + + return <<{$this->__('eBay Fee')}: {$price} +HTML; } - $fee = $this->getLayout()->createBlock('M2ePro/ebay_listing_view_fee_product'); + $fee = $this->createBlock('Ebay\Listing\View\Ebay\Fee\Product'); $fee->setData('fees', $additionalData['ebay_item_fees']); $fee->setData('product_name', $row->getData('name')); - return $fee->toHtml(); + return <<{$this->__('eBay Fee')}: {$fee->toHtml()} +HTML; } $listingProductId = (int)$row->getData('listing_product_id'); - $label = $this->__('estimate'); + $label = $this->__('estimate fee'); return <<{$label}] + HTML; } @@ -504,25 +491,26 @@ private function getTerapeakButtonHtml($row) public function callbackColumnEbayItemId($value, $row, $column, $isExport) { if ($row->getData('ebay_status') == \Ess\M2ePro\Model\Listing\Product::STATUS_NOT_LISTED) { - return '' . $this->__('Not Listed') . ''; - } - - if (is_null($value) || $value === '') { - return $this->__('N/A'); + $html = '' . $this->__('Not Listed') . ''; + } else if (is_null($value) || $value === '') { + $html = $this->__('N/A'); + } else { + $listingData = $this->listing->getData(); + + $url = $this->getUrl( + '*/ebay_listing/gotoEbay/', + array( + 'item_id' => $value, + 'account_id' => $listingData['account_id'], + 'marketplace_id' => $listingData['marketplace_id'] + ) + ); + $html = ''.$value.''; } - $listingData = $this->listing->getData(); + $html .= $this->getItemFeeHtml($row); - $url = $this->getUrl( - '*/ebay_listing/gotoEbay/', - array( - 'item_id' => $value, - 'account_id' => $listingData['account_id'], - 'marketplace_id' => $listingData['marketplace_id'] - ) - ); - - return ''.$value.''; + return $html; } public function callbackColumnOnlineAvailableQty($value, $row, $column, $isExport) @@ -593,8 +581,6 @@ public function callbackColumnPrice($value, $row, $column, $isExport) $startPriceText = $this->__('Start Price'); - $iconHelpPath = $this->getViewFileUrl('Ess_M2ePro::images/i_logo.png'); - $toolTipIconPath = $this->getViewFileUrl('Ess_M2ePro::images/i_icon.png'); $onlineCurrentPriceHtml = ''; $onlineReservePriceHtml = ''; $onlineBuyItNowPriceHtml = ''; @@ -617,17 +603,18 @@ public function callbackColumnPrice($value, $row, $column, $isExport) $onlineBuyItNowPriceHtml = ''.$buyItNowText.': '.$onlineBuyItNowStr; } - $intervalHtml = << +HTML + ); + + $intervalHtml = <<{$intervalHtml} HTML; if ($onlineCurrentPrice > $onlineStartPrice) { @@ -897,9 +884,9 @@ public function getViewLogIconHtml($listingProductId) usort($actionsRow['items'], function($a, $b) { $sortOrder = array( - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS => 1, - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR => 2, - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING => 3, + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_SUCCESS => 1, + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR => 2, + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_WARNING => 3, ); return $sortOrder[$a["type"]] > $sortOrder[$b["type"]]; @@ -907,15 +894,15 @@ public function getViewLogIconHtml($listingProductId) } $tips = array( - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS => 'Last Action was completed successfully.', - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR => 'Last Action was completed with error(s).', - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING => 'Last Action was completed with warning(s).' + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_SUCCESS => 'Last Action was completed successfully.', + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR => 'Last Action was completed with error(s).', + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_WARNING => 'Last Action was completed with warning(s).' ); $icons = array( - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS => 'normal', - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR => 'error', - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING => 'warning' + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_SUCCESS => 'normal', + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR => 'error', + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_WARNING => 'warning' ); $summary = $this->createBlock('Log\Grid\Summary', '', ['data' => [ @@ -982,15 +969,15 @@ public function getInitiatorForAction($actionRows) public function getMainTypeForActionId($actionRows) { - $type = \Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS; + $type = \Ess\M2ePro\Model\Log\AbstractModel::TYPE_SUCCESS; foreach ($actionRows as $row) { - if ($row['type'] == \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR) { - $type = \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR; + if ($row['type'] == \Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR) { + $type = \Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR; break; } - if ($row['type'] == \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING) { - $type = \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING; + if ($row['type'] == \Ess\M2ePro\Model\Log\AbstractModel::TYPE_WARNING) { + $type = \Ess\M2ePro\Model\Log\AbstractModel::TYPE_WARNING; } } @@ -1018,6 +1005,8 @@ public function getRowUrl($row) protected function _toHtml() { + $this->getInitTerapeakWidgetHtml(); + $allIdsStr = implode(',', $this->getCollection()->getAllIds()); if ($this->getRequest()->isXmlHttpRequest()) { @@ -1029,8 +1018,7 @@ protected function _toHtml() JS ); - return parent::_toHtml() . - $this->getInitTerapeakWidgetHtml(); + return parent::_toHtml(); } $component = \Ess\M2ePro\Helper\Component\Ebay::NICK; @@ -1047,7 +1035,8 @@ protected function _toHtml() 'runReviseProducts' => $this->getUrl('*/ebay_listing/runReviseProducts'), 'runStopProducts' => $this->getUrl('*/ebay_listing/runStopProducts'), 'runStopAndRemoveProducts' => $this->getUrl('*/ebay_listing/runStopAndRemoveProducts'), - 'runRemoveProducts' => $this->getUrl('*/ebay_listing/runRemoveProducts') + 'runRemoveProducts' => $this->getUrl('*/ebay_listing/runRemoveProducts'), + 'previewItems' => $this->getUrl('*/ebay_listing/previewItems'), ]); $this->jsUrl->add( @@ -1104,7 +1093,7 @@ protected function _toHtml() // "%task_title%" task has completed with errors. View Log for details. $taskCompletedErrorMessage = '"%task_title%" task has completed with errors. '; $taskCompletedErrorMessage .= 'View Log for details.'; - + $this->jsTranslator->addTranslations([ 'task_completed_message' => $this->__('Task completed. Please wait ...'), @@ -1121,7 +1110,7 @@ protected function _toHtml() $this->__('The Listing was locked by another process. Please try again later.'), 'Listing is empty.' => $this->__('Listing is empty.'), - + 'listing_all_items_message' => $this->__('Listing All Items On eBay'), 'listing_selected_items_message' => $this->__('Listing Selected Items On eBay'), 'revising_selected_items_message' => $this->__('Revising Selected Items On eBay'), @@ -1130,7 +1119,7 @@ protected function _toHtml() 'stopping_and_removing_selected_items_message' => $this->__( 'Stopping On eBay And Removing From Listing Selected Items' ), - 'removing_selected_items_message' => $this->__('Removing From Listing Selected Items'), + 'removing_selected_items_message' => $this->__('Removing From Listing Selected Items'), 'Please select the Products you want to perform the Action on.' => $this->__('Please select the Products you want to perform the Action on.'), @@ -1150,14 +1139,11 @@ protected function _toHtml() 'Product(s) failed to Move' => $this->__('Product(s) failed to Move'), 'eBay Categories' => $this->__('eBay Categories'), 'of Product' => $this->__('of Product'), - 'Specifics' => $this->__('Specifics'), - 'Estimated Fee Details' => $this->__('Estimated Fee Details') + 'Specifics' => $this->__('Specifics') ]); $showAutoAction = json_encode((bool)$this->getRequest()->getParam('auto_actions')); - $showMotorNotification = json_encode((bool)$this->isShowMotorNotification()); - // M2ePro_TRANSLATIONS // Please check eBay Motors compatibility attribute.You can find it in %menu_label% > Configuration > General. $motorNotification = $this->getHelper('Data')->escapeJs($this->__( @@ -1194,8 +1180,6 @@ protected function _toHtml() EbayListingViewEbayGridObj.actionHandler.setOptions(M2ePro); EbayListingViewEbayGridObj.variationProductManageHandler.setOptions(M2ePro); - //TODO Bids popup - // EbayListingViewEbayGridObj.listingProductBidsHandler.setOptions(M2ePro); EbayListingViewEbayGridObj.actionHandler.setProgressBar('listing_view_progress_bar'); EbayListingViewEbayGridObj.actionHandler.setGridWrapper('listing_view_content_container'); @@ -1213,16 +1197,11 @@ function () { ListingAutoActionObj.loadAutoActionHtml(); }, ); } - if ({$showMotorNotification}) { - ListingEbayGridHandlerObj.showMotorsNotificationPopUp('{$motorNotification}'); - } - }); JS ); - return parent::_toHtml() . - $this->getInitTerapeakWidgetHtml(); + return parent::_toHtml(); } private function getLockedTag($row) @@ -1268,23 +1247,44 @@ private function getLockedTag($row) private function getInitTerapeakWidgetHtml() { - return ''; if (!$this->isTerapeakWidgetEnabled) { + return; } - $protocolMode = $this->scopeConfig->isSetFlag('web/secure/use_in_adminhtml') == '1' ? 'https' : 'http'; + if ($this->getRequest()->isXmlHttpRequest()) { - return << - div.tp-research { display: inline-block; } - a.tp-button { cursor: pointer; text-decoration: none; } - + $this->js->add( + <<css->add(<< + $this->js->addOnReadyJs(<< -HTML; - } - - //######################################## - - // TODO NOT SUPPORTED FEATURES "ebay motors" - protected function isShowMotorNotification() - { - return false; - if ($this->listing->getMarketplaceId() != \Ess\M2ePro\Helper\Component\Ebay::MARKETPLACE_MOTORS) { - return false; - } - - $configValue = $this->getHelper('Module')->getConfig()->getGroupValue( - '/view/ebay/motors_epids_attribute/', 'listing_notification_shown' - ); - - if ($configValue) { - return false; - } - - $this->getHelper('Module')->getConfig()->setGroupValue( - '/view/ebay/motors_epids_attribute/', 'listing_notification_shown', 1 +JS ); - - return true; } //######################################## private function convertAndFormatPriceCurrency($price, $currency) { - return $this->priceCurrency->convertAndFormat($price, null, null, null, $currency); + return $this->localeCurrency->getCurrency($currency)->toCurrency($price); } //######################################## diff --git a/Block/Adminhtml/Ebay/Listing/View/Magento/Grid.php b/Block/Adminhtml/Ebay/Listing/View/Magento/Grid.php index ff8b15906..b6dd68bc3 100644 --- a/Block/Adminhtml/Ebay/Listing/View/Magento/Grid.php +++ b/Block/Adminhtml/Ebay/Listing/View/Magento/Grid.php @@ -56,30 +56,6 @@ public function _construct() //######################################## - public function getAdvancedFilterButtonHtml() - { - return ''; - // TODO NOT SUPPORTED FEATURES "Advanced filters" -// if (!Mage::helper('M2ePro/View_Ebay')->isAdvancedMode()) { -// } -// -// return parent::getAdvancedFilterButtonHtml(); - } - - //######################################## - - // TODO NOT SUPPORTED FEATURES "Advanced filters" -// protected function isShowRuleBlock() -// { -// if (Mage::helper('M2ePro/View_Ebay')->isSimpleMode()) { -// return false; -// } -// -// return parent::isShowRuleBlock(); -// } - - //######################################## - protected function _prepareCollection() { /** @var \Ess\M2ePro\Model\Listing $listing */ @@ -211,11 +187,6 @@ protected function _prepareCollection() return parent::_prepareCollection(); } - protected function _prepareMassactionBlock() - { - return $this; - } - protected function _prepareColumns() { $this->addColumn('product_id', array( diff --git a/Block/Adminhtml/Ebay/Listing/View/Settings/Edit/Policy.php b/Block/Adminhtml/Ebay/Listing/View/Settings/Edit/Policy.php new file mode 100644 index 000000000..26606bf76 --- /dev/null +++ b/Block/Adminhtml/Ebay/Listing/View/Settings/Edit/Policy.php @@ -0,0 +1,23 @@ +_controller = 'adminhtml_ebay_listing_view_settings_edit'; + $this->_mode = 'policy'; + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/Ebay/Listing/View/Settings/Edit/Policy/Form.php b/Block/Adminhtml/Ebay/Listing/View/Settings/Edit/Policy/Form.php new file mode 100644 index 000000000..c896951dd --- /dev/null +++ b/Block/Adminhtml/Ebay/Listing/View/Settings/Edit/Policy/Form.php @@ -0,0 +1,84 @@ +_formFactory->create(['data' => [ + 'id' => 'edit_form', + 'action' => $this->getUrl('*/ebay_template/save'), + 'method' => 'post', + 'enctype' => 'multipart/form-data' + ]]); + + $templateNick = $this->getRequest()->getParam('templateNick'); + + $switcherBlock = $this->createBlock( + 'Ebay\Listing\Template\Switcher','', + ['data' => [ + 'template_nick' => $templateNick, + 'policy_localization' => $this->getData('policy_localization'), + 'custom_header_text' => $this->__('Source Mode') + ]] + ); + + $form->addField('template_wrapper', + self::CUSTOM_CONTAINER, + [ + 'text' => $switcherBlock->toHtml() + ] + ); + + $form->setUseContainer(true); + $this->setForm($form); + parent::_prepareLayout(); + } + + protected function _toHtml() + { + $templateNick = $this->getRequest()->getParam('templateNick'); + + return $this->getHelpLinkHtmlForTemplate($templateNick) + . parent::_toHtml(); + } + + protected function getHelpLinkHtmlForTemplate($templateNick) + { + $articles = [ + \Ess\M2ePro\Model\Ebay\Template\Manager::TEMPLATE_RETURN_POLICY => 'x/TgMtAQ', + \Ess\M2ePro\Model\Ebay\Template\Manager::TEMPLATE_PAYMENT => 'x/LwMtAQ', + \Ess\M2ePro\Model\Ebay\Template\Manager::TEMPLATE_SHIPPING => 'x/OgMtAQ', + \Ess\M2ePro\Model\Ebay\Template\Manager::TEMPLATE_DESCRIPTION => 'x/VQItAQ ', + \Ess\M2ePro\Model\Ebay\Template\Manager::TEMPLATE_SELLING_FORMAT => + 'x/UwItAQ', + \Ess\M2ePro\Model\Ebay\Template\Manager::TEMPLATE_SYNCHRONIZATION => 'x/OwItAQ', + ]; + + if (!isset($articles[$templateNick])) { + return ''; + } + + $helpLinkBlock = $this->createBlock('PageHelpLink')->setData([ + 'page_help_link' => $this->getHelper('Module\Support')->getDocumentationUrl( + $articles[$templateNick] + ) + ]); + + return '' ; + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/Ebay/Listing/View/Settings/Grid.php b/Block/Adminhtml/Ebay/Listing/View/Settings/Grid.php index 1e8172ba4..9b3f0a1a1 100644 --- a/Block/Adminhtml/Ebay/Listing/View/Settings/Grid.php +++ b/Block/Adminhtml/Ebay/Listing/View/Settings/Grid.php @@ -12,11 +12,6 @@ class Grid extends \Ess\M2ePro\Block\Adminhtml\Listing\View\Grid { - // TODO NOT SUPPORTED FEATURES "ebay motors" -// /** @var Mage_Eav_Model_Entity_Attribute_Abstract */ -// private $motorsAttribute = NULL; -// private $productsMotorsData = array(); - protected $templateManager; protected $magentoProductCollectionFactory; protected $ebayFactory; @@ -50,42 +45,13 @@ public function _construct() $this->setId('ebayListingViewSettingsGrid'.$this->listing->getId()); // --------------------------------------- - // TODO NOT SUPPORTED FEATURES "ebay motors" -// if ($this->isMotorsAvailable()) { -// $attributeCode = Mage::helper('M2ePro/Component_Ebay_Motors') -// ->getAttribute($this->getMotorsType()); -// -// -// $this->motorsAttribute = Mage::getModel('catalog/product')->getResource()->getAttribute($attributeCode); -// } + $this->css->addFile('ebay/template.css'); + + $this->showAdvancedFilterProductsOption = false; } //######################################## - // TODO NOT SUPPORTED FEATURES "ebay motors" -// public function getMotorsType() -// { -// if (!$this->isMotorsAvailable()) { -// return null; -// } -// -// if ($this->isMotorEpidsAvailable()) { -// return Ess_M2ePro_Helper_Component_Ebay_Motors::TYPE_EPID; -// } -// -// return Ess_M2ePro_Helper_Component_Ebay_Motors::TYPE_KTYPE; -// } - - //######################################## - - // TODO NOT SUPPORTED FEATURES "Advanced filters" -// protected function isShowRuleBlock() -// { -// return parent::isShowRuleBlock(); -// } - - //######################################## - protected function _prepareCollection() { // --------------------------------------- @@ -220,21 +186,6 @@ protected function _prepareCollection() 'left' ); - // TODO NOT SUPPORTED FEATURES "ebay motors" -// if ($this->motorsAttribute) { -// $collection->addAttributeToSelect($this->motorsAttribute->getAttributeCode()); -// -// $collection->joinTable( -// array('eea' => Mage::getSingleton('core/resource')->getTableName('eav_entity_attribute')), -// 'attribute_set_id=attribute_set_id', -// array( -// 'is_motors_attribute_in_product_attribute_set' => 'entity_attribute_id', -// ), -// '{{table}}.attribute_id = ' . $this->motorsAttribute->getAttributeId(), -// 'left' -// ); -// } - $lpvTable = $this->activeRecordFactory->getObject('Listing\Product\Variation')->getResource()->getMainTable(); $elpvTable = $this->activeRecordFactory->getObject('Ebay\Listing\Product\Variation') ->getResource()->getMainTable(); @@ -264,11 +215,6 @@ protected function _prepareCollection() parent::_prepareCollection(); - // TODO NOT SUPPORTED FEATURES "ebay motors" -// if ($this->isMotorsAvailable()) { -// $this->prepareExistingMotorsData(); -// } - return $this; } @@ -294,37 +240,21 @@ protected function _prepareColumns() )); $title = $this->__('eBay Categories'); - if ($this->isExistsListingSettingsOverwrites()) { - $title = $this->__('eBay Categories / Listing Settings Overwrites'); + $isExistsListingSettingsOverwrites = $this->isExistsListingSettingsOverwrites(); + if ($isExistsListingSettingsOverwrites) { + $title = $this->__('eBay Categories / Listing Policies Overrides'); } $this->addColumn('category', array( 'header' => $title, 'align' => 'left', 'type' => 'text', 'index' => 'name', + 'is_exists_listing_settings_overwrites' => $isExistsListingSettingsOverwrites, 'filter' => '\Ess\M2ePro\Block\Adminhtml\Ebay\Listing\View\Settings\Grid\Column\Filter\Category', 'frame_callback' => array($this, 'callbackColumnCategory'), 'filter_condition_callback' => array($this, 'callbackFilterCategory') )); - // TODO NOT SUPPORTED FEATURES "ebay motors" -// if ($this->isMotorsAvailable() && $this->motorsAttribute) { -// $this->addColumnAfter('parts_motors_attribute_value', array( -// 'header' => $this->__('Compatibility'), -// 'align' => 'left', -// 'width' => '100px', -// 'type' => 'options', -// 'index' => $this->motorsAttribute->getAttributeCode(), -// 'sortable' => false, -// 'options' => array( -// 1 => $this->__('Filled'), -// 0 => $this->__('Empty') -// ), -// 'frame_callback' => array($this, 'callbackColumnMotorsAttribute'), -// 'filter_condition_callback' => array($this, 'callbackFilterMotorsAttribute'), -// ), 'name'); -// } - $this->addColumn('actions', array( 'header' => $this->__('Actions'), 'align' => 'left', @@ -363,7 +293,7 @@ protected function _prepareMassaction() protected function _prepareMassactionGroup() { $this->getMassactionBlock()->setGroups(array( - 'edit_settings' => $this->__('Edit General Settings'), + 'edit_settings' => $this->__('Edit Listing Policies Overrides'), 'edit_categories_settings' => $this->__('Edit eBay Categories'), 'other' => $this->__('Other') )); @@ -373,26 +303,47 @@ protected function _prepareMassactionGroup() protected function _prepareMassactionItems() { - // TODO -// $this->getMassactionBlock()->addItem('editAllSettings', array( -// 'label' => $this->__('All Settings'), -// 'url' => '', -// ), 'edit_settings'); -// -// $this->getMassactionBlock()->addItem('editSellingSettings', array( -// 'label' => $this->__('Selling'), -// 'url' => '', -// ), 'edit_settings'); -// -// $this->getMassactionBlock()->addItem('editSynchSettings', array( -// 'label' => $this->__('Synchronization'), -// 'url' => '', -// ), 'edit_settings'); -// -// $this->getMassactionBlock()->addItem('editGeneralSettings', array( -// 'label' => $this->__('Payment and Shipping'), -// 'url' => '', -// ), 'edit_settings'); + // --- Payment and Shipping Settings ----- + + $this->getMassactionBlock()->addItem('editPaymentSettings', array( + 'label' => $this->__('Payment'), + 'url' => '', + ), 'edit_settings'); + + $this->getMassactionBlock()->addItem('editShippingSettings', array( + 'label' => $this->__('Shipping'), + 'url' => '', + ), 'edit_settings'); + + $this->getMassactionBlock()->addItem('editReturnSettings', array( + 'label' => $this->__('Return'), + 'url' => '', + ), 'edit_settings'); + + // --------------------------------------- + + // ---------- Selling Settings ----------- + + $this->getMassactionBlock()->addItem('editPriceQuantityFormatSettings', array( + 'label' => $this->__('Price, Quantity and Format'), + 'url' => '', + ), 'edit_settings'); + + $this->getMassactionBlock()->addItem('editDescriptionSettings', array( + 'label' => $this->__('Description'), + 'url' => '', + ), 'edit_settings'); + + // --------------------------------------- + + // ---------- Synchronization ------------ + + $this->getMassactionBlock()->addItem('editSynchSettings', array( + 'label' => $this->__('Synchronization'), + 'url' => '', + ), 'edit_settings'); + + // --------------------------------------- $this->getMassactionBlock()->addItem('editCategorySettings', array( 'label' => $this->__('All Categories'), @@ -411,26 +362,12 @@ protected function _prepareMassactionItems() ), 'edit_categories_settings'); } - // TODO NOT SUPPORTED FEATURES "ebay motors" -// if ($this->isMotorsAvailable() && $this->motorsAttribute) { -// $this->getMassactionBlock()->addItem('editMotors', array( -// 'label' => $this->__('Add Compatible Vehicles'), -// 'url' => '' -// ), 'other'); -// } - $this->getMassactionBlock()->addItem('moving', array( 'label' => $this->__('Move Item(s) to Another Listing'), 'url' => '', 'confirm' => $this->__('Are you sure?') ), 'other'); - // TODO -// $this->getMassactionBlock()->addItem('transferring', array( -// 'label' => $this->__('Sell on Another eBay Site'), -// 'url' => '', -// ), 'other'); - return $this; } @@ -472,7 +409,9 @@ public function callbackColumnCategory($value, $row, $column, $isExport) if ($row->getData('category_main_mode') == \Ess\M2ePro\Model\Ebay\Template\Category::CATEGORY_MODE_NONE) { $value .= $this->getCategoryInfoHtml( - $this->__('eBay Primary Category'), + $this->getHelper('Component\Ebay\Category')->getCategoryTitle( + \Ess\M2ePro\Helper\Component\Ebay\Category::TYPE_EBAY_MAIN + ), ''.$this->__('Not Set').'' ); } else { @@ -493,8 +432,8 @@ public function callbackColumnCategory($value, $row, $column, $isExport) Manager::TEMPLATE_PAYMENT => $this->__('Payment'), Manager::TEMPLATE_SHIPPING => $this->__('Shipping'), Manager::TEMPLATE_RETURN_POLICY => $this->__('Return'), - Manager::TEMPLATE_DESCRIPTION => $this->__('Description'), Manager::TEMPLATE_SELLING_FORMAT => $this->__('Price, Quantity and Format'), + Manager::TEMPLATE_DESCRIPTION => $this->__('Description'), Manager::TEMPLATE_SYNCHRONIZATION => $this->__('Synchronization'), ]; @@ -514,31 +453,29 @@ public function callbackColumnCategory($value, $row, $column, $isExport) } else if ($templateMode == Manager::MODE_TEMPLATE) { + $id = (int)$row->getData('template_' .$templateNick. '_id'); $url = $this->getUrl('m2epro/ebay_template/edit', [ - 'id' => (int)$row->getData('template_' .$templateNick. '_id'), + 'id' => $id, 'nick' => $templateNick ]); + $objTitle = $this->templateManager->setTemplate($templateNick) + ->getTemplateModel() + ->load($id) + ->getTitle(); $templateLink = '' - . $templateTitle . ' ' . $this->__('Template') + . $objTitle . ''; } - $removeUrl = $this->getUrl('m2epro/ebay_listing/DeleteTemplateFromListingProduct', [ - 'id' => (int)$row->getData('listing_product_id'), - 'nick' => $templateNick - ]); $productTemplatesHtml .= "
    {$templateTitle}: {$templateLink} -
    "; } if (!empty($productTemplatesHtml)) { $value .= "
    - {$this->__('Listing Settings Overwrites')} + {$this->__('Listing Policies Overrides')}
    " . $productTemplatesHtml; } @@ -836,7 +773,7 @@ private function getCategoryInfoHtml($modeTitle, $category) protected function getGroupOrder() { return array( - 'edit_general_settings' => $this->__('Edit General Settings'), + 'edit_general_settings' => $this->__('Edit Listing Policies Overrides'), 'edit_categories_settings' => $this->__('Edit eBay Categories'), 'other' => $this->__('Other') ); @@ -870,44 +807,58 @@ protected function getColumnActionsItems() ); } - // TODO NOT SUPPORTED FEATURES "ebay motors" -// if ($this->isMotorsAvailable() && $this->motorsAttribute) { -// $actions['addCompatibleVehicles'] = array( -// 'caption' => $this->__('Add Compatible Vehicles'), -// 'group' => 'other', -// 'field' => 'id', -// 'onclick_action' => 'EbayListingViewSettingsGridObj.actions[\'editMotorsAction\']' -// ); -// } - - // TODO -// $actions['allSettings'] = array( -// 'caption' => $this->__('All Settings'), -// 'group' => 'edit_general_settings', -// 'field' => 'id', -// 'onclick_action' => 'EbayListingViewSettingsGridObj.actions[\'editAllSettingsAction\']' -// ); -// -// $actions['editSelling'] = array( -// 'caption' => $this->__('Selling'), -// 'group' => 'edit_general_settings', -// 'field' => 'id', -// 'onclick_action' => 'EbayListingViewSettingsGridObj.actions[\'editSellingSettingsAction\']' -// ); -// -// $actions['editSynchSettings'] = array( -// 'caption' => $this->__('Synchronization'), -// 'group' => 'edit_general_settings', -// 'field' => 'id', -// 'onclick_action' => 'EbayListingViewSettingsGridObj.actions[\'editSynchSettingsAction\']' -// ); -// -// $actions['paymentAndShipping'] = array( -// 'caption' => $this->__('Payment and Shipping'), -// 'group' => 'edit_general_settings', -// 'field' => 'id', -// 'onclick_action' => 'EbayListingViewSettingsGridObj.actions[\'editGeneralSettingsAction\']' -// ); + // --- Payment and Shipping Settings ----- + + $actions['editPayment'] = [ + 'caption' => $this->__('Payment'), + 'group' => 'edit_general_settings', + 'field' => 'id', + 'onclick_action' => 'EbayListingViewSettingsGridObj.actions[\'editPaymentSettingsAction\']' + ]; + + $actions['editShipping'] = [ + 'caption' => $this->__('Shipping'), + 'group' => 'edit_general_settings', + 'field' => 'id', + 'onclick_action' => 'EbayListingViewSettingsGridObj.actions[\'editShippingSettingsAction\']' + ]; + + $actions['editReturn'] = [ + 'caption' => $this->__('Return'), + 'group' => 'edit_general_settings', + 'field' => 'id', + 'onclick_action' => 'EbayListingViewSettingsGridObj.actions[\'editReturnSettingsAction\']' + ]; + + // --------------------------------------- + + // ---------- Selling Settings ----------- + $actions['priceQuantityFormat'] = [ + 'caption' => $this->__('Price, Quantity and Format'), + 'group' => 'edit_general_settings', + 'field' => 'id', + 'onclick_action' => 'EbayListingViewSettingsGridObj.actions[\'editPriceQuantityFormatSettingsAction\']' + ]; + + $actions['editDescription'] = [ + 'caption' => $this->__('Description'), + 'group' => 'edit_general_settings', + 'field' => 'id', + 'onclick_action' => 'EbayListingViewSettingsGridObj.actions[\'editDescriptionSettingsAction\']' + ]; + + // --------------------------------------- + + // ---------- Synchronization ------------ + + $actions['editSynchSettings'] = [ + 'caption' => $this->__('Synchronization'), + 'group' => 'edit_general_settings', + 'field' => 'id', + 'onclick_action' => 'EbayListingViewSettingsGridObj.actions[\'editSynchSettingsAction\']' + ]; + + // --------------------------------------- return $actions; } @@ -933,6 +884,7 @@ protected function _toHtml() // --------------------------------------- $this->jsPhp->addConstants($helper->getClassConstants('\Ess\M2ePro\Helper\Component\Ebay\Category')); + $this->jsPhp->addConstants($helper->getClassConstants('\Ess\M2ePro\Model\Ebay\Template\Manager')); // --------------------------------------- // --------------------------------------- @@ -962,23 +914,21 @@ protected function _toHtml() 'moveToListingGridHtml' ); $this->jsUrl->add($this->getUrl('*/listing_moving/prepareMoveToListing'), 'prepareData'); - $this->jsUrl->add($this->getUrl('*/listing_moving/getFailedProductsGrid'), 'getFailedProductsGridHtml'); + $this->jsUrl->add($this->getUrl('*/listing_moving/getFailedProducts'), 'getFailedProductsHtml'); $this->jsUrl->add($this->getUrl('*/listing_moving/tryToMoveToListing'), 'tryToMoveToListing'); $this->jsUrl->add($this->getUrl('*/listing_moving/moveToListing'), 'moveToListing'); - $this->jsUrl->add($this->getUrl('*/ebay_template/editListingProduct'), 'ebay_template/editListingProduct'); - $this->jsUrl->add($this->getUrl('*/ebay_template/saveListingProduct'), 'ebay_template/saveListingProduct'); + $this->jsUrl->add( + $this->getUrl('*/ebay_template/editListingProductsPolicy'), + 'ebay_template/editListingProductsPolicy' + ); + $this->jsUrl->add( + $this->getUrl('*/ebay_template/saveListingProductsPolicy'), + 'ebay_template/saveListingProductsPolicy' + ); // --------------------------------------- - // TODO NOT SUPPORTED FEATURES "ebay motors" -// $this->jsUrl->addUrls($helper->getControllerActions('adminhtml_ebay_motor')); -// if ($this->getMotorsType() == Ess_M2ePro_Helper_Component_Ebay_Motors::TYPE_EPID) { -// $motorsTypeTitle = 'ePID'; -// } else { -// $motorsTypeTitle = 'kType'; -// } - // M2ePro_TRANSLATIONS // %task_title%" Task has completed with warnings. View Log for details. $taskCompletedWarningMessage = '"%task_title%" Task has completed with warnings.' @@ -991,9 +941,13 @@ protected function _toHtml() //------------------------------ $this->jsTranslator->addTranslations([ - 'Edit Payment and Shipping Settings' => $this->__('Edit Payment and Shipping Settings'), - 'Edit Selling Settings' => $this->__('Edit Selling Settings'), - 'Edit Synchronization Settings' => $this->__('Edit Synchronization Settings'), + 'Edit Return Policy Setting' => $this->__('Edit Return Policy Setting'), + 'Edit Payment Policy Setting' => $this->__('Edit Payment Policy Setting'), + 'Edit Shipping Policy Setting' => $this->__('Edit Shipping Policy Setting'), + 'Edit Description Policy Setting' => $this->__('Edit Description Policy Setting'), + 'Edit Price, Quantity and Format Policy Setting' => + $this->__('Edit Price, Quantity and Format Policy Setting'), + 'Edit Synchronization Policy Setting' => $this->__('Edit Synchronization Policy Setting'), 'Edit Settings' => $this->__('Edit Settings'), 'for' => $this->__('for'), 'eBay Categories' => $this->__('eBay Categories'), @@ -1007,7 +961,7 @@ protected function _toHtml() .' If you are planning to order more Items for Translation in future,' .' you can credit the sum greater than the one needed for current Translation.' .' Click here to find out more.', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, + $this->getHelper('Module\Support')->getDocumentationArticleUrl( 'x/BQAJAQ#SellonanothereBaySite-Account') ), 'Amount to Pay.' => $this->__('Amount to Pay'), @@ -1052,15 +1006,10 @@ protected function _toHtml() $this->__('Some Product(s) was not Moved. View Log for details.'), 'task_completed_warning_message' => $this->__($taskCompletedWarningMessage), - $taskCompletedErrorMessage => $this->__($taskCompletedErrorMessage) + $taskCompletedErrorMessage => $this->__($taskCompletedErrorMessage), + 'Add New Listing' => $this->__('Add New Listing') ]); - // TODO NOT SUPPORTED FEATURES "ebay motors" -// $motorsType = ''; -// if ($this->isMotorsAvailable()) { -// $motorsType = $this->getMotorsType(); -// } - $temp = $this->getHelper('Data\Session')->getValue('products_ids_for_list',true); $productsIdsForList = empty($temp) ? '' : $temp; @@ -1077,8 +1026,6 @@ protected function _toHtml() JS ); - // TODO NOT SUPPORTED FEATURES "ebay motors" -// EbayMotorsHandlerObj = new EbayMotorsHandler({$this->listing->getId()}, '{$motorsType}'); $this->js->addOnReadyJs( <<isMotorEpidsAvailable() || $this->isMotorKtypesAvailable(); -// } -// -// private function isMotorEpidsAvailable() -// { -// return Mage::helper('M2ePro/Component_Ebay_Motors')->isMarketplaceSupportsEpid( -// $this->listing->getMarketplaceId() -// ); -// } -// -// private function isMotorKtypesAvailable() -// { -// return Mage::helper('M2ePro/Component_Ebay_Motors')->isMarketplaceSupportsKtype( -// $this->listing->getMarketplaceId() -// ); -// } - - //######################################## - - // TODO NOT SUPPORTED FEATURES "ebay motors" -// private function prepareExistingMotorsData() -// { -// $motorsHelper = Mage::helper('M2ePro/Component_Ebay_Motors'); -// -// $products = $this->getCollection()->getItems(); -// -// $productsMotorsData = array(); -// -// $items = array(); -// $filters = array(); -// $groups = array(); -// -// foreach ($products as $product) { -// if (!$product->getData('is_motors_attribute_in_product_attribute_set')) { -// continue; -// } -// -// $productId = $product->getData('listing_product_id'); -// -// $attributeCode = $this->motorsAttribute->getAttributeCode(); -// $attributeValue = $product->getData($attributeCode); -// -// $productsMotorsData[$productId] = $motorsHelper->parseAttributeValue($attributeValue); -// -// $items = array_merge($items, array_keys($productsMotorsData[$productId]['items'])); -// $filters = array_merge($filters, $productsMotorsData[$productId]['filters']); -// $groups = array_merge($groups, $productsMotorsData[$productId]['groups']); -// } -// -// //------------------------------- -// $typeIdentifier = $motorsHelper->getIdentifierKey($this->getMotorsType()); -// -// $select = Mage::getResourceModel('core/config')->getReadConnection() -// ->select() -// ->from( -// $motorsHelper->getDictionaryTable($this->getMotorsType()), -// array($typeIdentifier) -// ) -// ->where('`'.$typeIdentifier.'` IN (?)', $items); -// -// $existedItems = $select->query()->fetchAll(PDO::FETCH_COLUMN); -// //------------------------------- -// -// //------------------------------- -// $filtersTable = Mage::getSingleton('core/resource')->getTableName('m2epro_ebay_motor_filter'); -// $select = Mage::getResourceModel('core/config')->getReadConnection() -// ->select() -// ->from( -// $filtersTable, -// array('id') -// ) -// ->where('`id` IN (?)', $filters); -// -// $existedFilters = $select->query()->fetchAll(PDO::FETCH_COLUMN); -// //------------------------------- -// -// //------------------------------- -// $groupsTable = Mage::getSingleton('core/resource')->getTableName('m2epro_ebay_motor_group'); -// $select = Mage::getResourceModel('core/config')->getReadConnection() -// ->select() -// ->from( -// $groupsTable, -// array('id') -// ) -// ->where('`id` IN (?)', $groups); -// -// $existedGroups = $select->query()->fetchAll(PDO::FETCH_COLUMN); -// //------------------------------- -// -// foreach ($productsMotorsData as $productId => $productMotorsData) { -// -// foreach ($productMotorsData['items'] as $item => $itemData) { -// if (!in_array($item, $existedItems)) { -// unset($productsMotorsData[$productId]['items'][$item]); -// } -// } -// -// foreach ($productMotorsData['filters'] as $key => $filterId) { -// if (!in_array($filterId, $existedFilters)) { -// unset($productsMotorsData[$productId]['filters'][$key]); -// } -// } -// -// foreach ($productMotorsData['groups'] as $key => $groupId) { -// if (!in_array($groupId, $existedGroups)) { -// unset($productsMotorsData[$productId]['groups'][$key]); -// } -// } -// } -// -// $this->productsMotorsData = $productsMotorsData; -// -// return $this; -// } - - //######################################## } \ No newline at end of file diff --git a/Block/Adminhtml/Ebay/Listing/View/Settings/Grid/Column/Filter/Category.php b/Block/Adminhtml/Ebay/Listing/View/Settings/Grid/Column/Filter/Category.php index 6d3f6f9a8..70933cae0 100644 --- a/Block/Adminhtml/Ebay/Listing/View/Settings/Grid/Column/Filter/Category.php +++ b/Block/Adminhtml/Ebay/Listing/View/Settings/Grid/Column/Filter/Category.php @@ -25,6 +25,11 @@ public function getHtml() $value = $this->getValue('select'); $checkbox = $this->getValue('checkbox') ? 'checked' : ''; + $hideListingSettingsOverwritesFilter = 'display: none;'; + if ($this->getColumn()->getData('is_exists_listing_settings_overwrites')) { + $hideListingSettingsOverwritesFilter = ''; + } + $optionsHtml = ''; foreach ($this->_getOptions() as $option) { $optionsHtml .= $this->_renderOption($option, $value); @@ -32,13 +37,13 @@ public function getHtml() //eBay Catalog Primary Category Assigned $label = $this->getHelper('Component\Ebay\Category') - ->getCategoryTitles()[\Ess\M2ePro\Helper\Component\Ebay\Category::TYPE_EBAY_MAIN]; + ->getCategoryTitle(\Ess\M2ePro\Helper\Component\Ebay\Category::TYPE_EBAY_MAIN); $label = $this->__('%1% Assigned', $label); $html = << + value="{$this->getEscapedValue('input')}" class="input-text admin__control-text no-changes"/>
    @@ -48,9 +53,9 @@ public function getHtml() {$optionsHtml}
    -
    +
    ebayFactory->getObject('Listing\Product')->getCollection(); -// $listingProductCollection->addFieldToFilter('listing_id', (int)$this->getRequest()->getParam('id')); -// $listingProductCollection->addFieldToFilter('translation_status', array('neq' => -// \Ess\M2ePro\Model\Ebay\Listing\Product::TRANSLATION_STATUS_NONE -// )); -// -// if ($listingProductCollection->getSize()) { -// $data[] = array( -// 'value' => 'translation', -// 'label' => $this->__('Translation') -// ); -// } - return $data; } @@ -93,10 +79,11 @@ protected function _toHtml() Using this Mode, you can easily find Products based on Magento Product information (i.e. Magento QTY, Stock Status, etc);

    -

    More detailed information you can find here.

    +

    More detailed information you can find + here.

    HTML , - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/mAItAQ') + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/mAItAQ') ) ); } diff --git a/Block/Adminhtml/Ebay/Log/Tabs.php b/Block/Adminhtml/Ebay/Log/Tabs.php index 2c3df2726..361f921fe 100644 --- a/Block/Adminhtml/Ebay/Log/Tabs.php +++ b/Block/Adminhtml/Ebay/Log/Tabs.php @@ -111,8 +111,8 @@ protected function _toHtml() $accountFilterHtml = $accountFilterBlock->toHtml(); if (trim($marketplaceFilterHtml) || trim($accountFilterHtml)) { $pageActionsHtml = '
    ' - . $marketplaceFilterBlock->toHtml() - . $accountFilterBlock->toHtml() + . $marketplaceFilterHtml + . $accountFilterHtml . '
    '; } diff --git a/Block/Adminhtml/Ebay/Marketplace.php b/Block/Adminhtml/Ebay/Marketplace.php index 582a30305..0694eb36e 100644 --- a/Block/Adminhtml/Ebay/Marketplace.php +++ b/Block/Adminhtml/Ebay/Marketplace.php @@ -49,13 +49,11 @@ protected function _prepareLayout() '

    This Page contains a list of eBay international Marketplaces where you can sell your Items.


    Enable only those Marketplaces that you want to sell on. - High number of enabled Marketplaces will take longer to process the necessary data.


    -

    More detailed information you can find here.

    ', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/4AEtAQ') + High number of enabled Marketplaces will take longer to process the necessary data.

    ' ) ]); - return parent::_prepareLayout(); // TODO: Change the autogenerated stub + return parent::_prepareLayout(); } protected function _toHtml() diff --git a/Block/Adminhtml/Ebay/Marketplace/Edit/Form.php b/Block/Adminhtml/Ebay/Marketplace/Edit/Form.php index ceea06377..95a99742f 100644 --- a/Block/Adminhtml/Ebay/Marketplace/Edit/Form.php +++ b/Block/Adminhtml/Ebay/Marketplace/Edit/Form.php @@ -12,32 +12,8 @@ class Form extends AbstractForm { - /** - * @var \Magento\Framework\View\Asset\Repository - */ - protected $assetRepo; - - /** - * @var \Magento\Framework\Data\Form\Element\Factory - */ - protected $factoryElement; - //######################################## - public function __construct( - \Magento\Framework\View\Asset\Repository $assetRepo, - \Magento\Framework\Data\Form\Element\Factory $factoryElement, - \Ess\M2ePro\Block\Adminhtml\Magento\Context\Template $context, - \Magento\Framework\Registry $registry, - \Magento\Framework\Data\FormFactory $formFactory, - array $data = [] - ) - { - $this->assetRepo = $assetRepo; - $this->factoryElement = $factoryElement; - parent::__construct($context, $registry, $formFactory, $data); - } - public function _construct() { parent::_construct(); @@ -109,8 +85,6 @@ class="value" style="display: none;"> ]; if ($marketplace['params']['locked']) { - // todo NOT SUPPORTED FEATURES -// if ($marketplace['params']['locked'] || $marketplace['params']['lockedByPickupStore']) { $lockedText = ''; if ($marketplace['params']['locked']) { $lockedText = $this->__('Used in Listing(s)'); @@ -191,14 +165,6 @@ protected function _beforeToHtml() ->addFieldToFilter('marketplace_id', $tempMarketplace->getId()) ->getSize(); -// $isLockedByPickupStore = false; -// todo NOT SUPPORTED FEATURES -// if (Mage::helper('M2ePro/Component_Ebay_PickupStore')->isFeatureEnabled()) { -// $isLockedByPickupStore = (bool)Mage::getModel('M2ePro/Ebay_Account_PickupStore')->getCollection() -// ->addFieldToFilter('marketplace_id', $tempMarketplace->getId()) -// ->getSize(); -// } - $storedStatuses[] = array( 'marketplace_id' => $tempMarketplace->getId(), 'status' => $tempMarketplace->getStatus() diff --git a/Block/Adminhtml/Ebay/Order.php b/Block/Adminhtml/Ebay/Order.php index d12813d4b..9531302c8 100644 --- a/Block/Adminhtml/Ebay/Order.php +++ b/Block/Adminhtml/Ebay/Order.php @@ -39,7 +39,7 @@ protected function _prepareLayout()

    In this section, you can find the list of the Orders imported from eBay.

    An eBay Order, for which Magento Order is created, contains a value in Magento Order # column of the grid. You can find the corresponding - Magento Order in
    Sales > Orders section of your Magento


    + Magento Order in Sales > Orders section of your Magento


    To manage the imported eBay Orders, you can use Mass Action options available in the Actions bulk: Reserve QTY, Cancel QTY Reserve, Mark Order(s) as Shipped or Paid and Resend @@ -72,4 +72,13 @@ public function getGridHtml() $editItemBlock->toHtml() . parent::getGridHtml(); } + + protected function _beforeToHtml() + { + $this->jsPhp->addConstants( + $this->getHelper('Data')->getClassConstants('\Ess\M2ePro\Controller\Adminhtml\Order\EditItem') + ); + + return parent::_beforeToHtml(); + } } \ No newline at end of file diff --git a/Block/Adminhtml/Ebay/Order/Grid.php b/Block/Adminhtml/Ebay/Order/Grid.php index 95c01acb5..f4bcd0e6e 100644 --- a/Block/Adminhtml/Ebay/Order/Grid.php +++ b/Block/Adminhtml/Ebay/Order/Grid.php @@ -55,7 +55,7 @@ protected function _prepareCollection() '(mea.account_id = `main_table`.account_id)', array('account_mode' => 'mode')) ->joinLeft( - array('so' => $this->resourceConnection->getTableName('sales_order')), //todo + array('so' => $this->resourceConnection->getTableName('sales_order')), '(so.entity_id = `main_table`.magento_order_id)', array('magento_order_num' => 'increment_id')); @@ -100,6 +100,7 @@ protected function _prepareColumns() 'align' => 'left', 'type' => 'datetime', 'format' => \IntlDateFormatter::MEDIUM, + 'filter_time' => true, 'index' => 'purchase_create_date', 'width' => '170px', 'frame_callback' => array($this, 'callbackPurchaseCreateDate'), @@ -221,11 +222,6 @@ protected function _prepareMassaction() 'general' => $this->__('General'), ); - // TODO NOT SUPPORTED FEATURES -// if ($this->getHelper('Component\Ebay\PickupStore')->isFeatureEnabled()) { -// $groups['in_store_pickup'] = $this->__('In-Store Pickup'); -// } - $this->getMassactionBlock()->setGroups($groups); // Set mass-action @@ -261,29 +257,6 @@ protected function _prepareMassaction() ), 'general'); // --------------------------------------- - // TODO NOT SUPPORTED FEATURES -// if (!$this->getHelper('Component\Ebay\PickupStore')->isFeatureEnabled()) { -// return parent::_prepareMassaction(); -// } - -// $this->getMassactionBlock()->addItem('mark_as_ready_for_pickup', array( -// 'label' => $this->__('Mark as Ready For Pickup'), -// 'url' => $this->getUrl('*/ebay_order/markAsReadyForPickup'), -// 'confirm' => $this->__('Are you sure?') -// ), 'in_store_pickup'); -// -// $this->getMassactionBlock()->addItem('mark_as_picked_up', array( -// 'label' => $this->__('Mark as Picked Up'), -// 'url' => $this->getUrl('*/ebay_order/markAsPickedUp'), -// 'confirm' => $this->__('Are you sure?') -// ), 'in_store_pickup'); -// -// $this->getMassactionBlock()->addItem('mark_as_cancelled', array( -// 'label' => $this->__('Mark as Cancelled'), -// 'url' => $this->getUrl('*/ebay_order/markAsCancelled'), -// 'confirm' => $this->__('Are you sure?') -// ), 'in_store_pickup'); - return parent::_prepareMassaction(); } @@ -305,7 +278,13 @@ public function callbackColumnMagentoOrder($value, $row, $column, $isExport) } } - return $returnString.$this->getViewLogIconHtml($row->getId()); + $logIconHtml = $this->getViewLogIconHtml($row->getId()); + + if ($logIconHtml !== '') { + return '

    ' . $returnString . $logIconHtml . '
    '; + } + + return $returnString; } private function getViewLogIconHtml($orderId) @@ -342,21 +321,21 @@ private function getViewLogIconHtml($orderId) // --------------------------------------- $tips = array( - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS => $this->__( + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_SUCCESS => $this->__( 'Last order Action was completed successfully.' ), - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR => $this->__( + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR => $this->__( 'Last order Action was completed with error(s).' ), - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING => $this->__( + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_WARNING => $this->__( 'Last order Action was completed with warning(s).' ) ); $icons = array( - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS => 'normal', - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR => 'error', - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING => 'warning' + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_SUCCESS => 'normal', + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR => 'error', + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_WARNING => 'warning' ); $summary = $this->createBlock('Log\Grid\Summary')->setData(array( @@ -405,26 +384,6 @@ public function callbackColumnEbayOrder($value, $row, $column, $isExport) $returnString .= '
    [ SM: # ' . $row->getChildObject()->getData('selling_manager_id') . ' ]'; } - // TODO NOT SUPPORTED FEATURES - if (!$this->getHelper('Component\Ebay\PickupStore')->isFeatureEnabled()) { - return $returnString; - } - - if (empty($row->getChildObject()->getData('shipping_details'))) { - return $returnString; - } - - $shippingDetails = json_decode($row->getChildObject()->getData('shipping_details'), true); - - // TODO NOT SUPPORTED FEATURES - if (empty($shippingDetails['in_store_pickup_details'])) { - return $returnString; - } - - $skinUrl = $this->getViewFileUrl('M2ePro'); - - $returnString = ' '.$returnString; - return $returnString; } @@ -465,7 +424,7 @@ public function callbackColumnItems($value, $row, $column, $isExport) $orderItemId = $item->getId(); $orderItemEditLabel = $this->__('edit'); - $js = "{OrderEditItemHandlerObj.edit('{$gridId}', {$orderItemId});}"; + $js = "{OrderEditItemObj.edit('{$gridId}', {$orderItemId});}"; $editItemHtml = << [{$orderItemEditLabel}] @@ -698,7 +657,7 @@ protected function _toHtml() $this->getHelper('Component\Ebay')->isEnabled() && $tempGridIds[] = $this->getId(); $tempGridIds = json_encode($tempGridIds); - $this->jsPhp->addConstants($this->getHelper('Data')->getClassConstants('\Ess\M2ePro\Model\Log\AbstractLog')); + $this->jsPhp->addConstants($this->getHelper('Data')->getClassConstants('\Ess\M2ePro\Model\Log\AbstractModel')); $this->jsUrl->addUrls([ 'ebay_order/view' => $this->getUrl( diff --git a/Block/Adminhtml/Ebay/Order/View/ExternalTransaction.php b/Block/Adminhtml/Ebay/Order/View/ExternalTransaction.php index 5c7cc6f9c..6e1990b28 100644 --- a/Block/Adminhtml/Ebay/Order/View/ExternalTransaction.php +++ b/Block/Adminhtml/Ebay/Order/View/ExternalTransaction.php @@ -83,6 +83,7 @@ protected function _prepareColumns() 'index' => 'transaction_date', 'type' => 'datetime', 'format' => \IntlDateFormatter::MEDIUM, + 'filter_time' => true, 'sortable' => false )); diff --git a/Block/Adminhtml/Ebay/Order/View/Item.php b/Block/Adminhtml/Ebay/Order/View/Item.php index cd33ba356..710d55a3f 100644 --- a/Block/Adminhtml/Ebay/Order/View/Item.php +++ b/Block/Adminhtml/Ebay/Order/View/Item.php @@ -62,7 +62,6 @@ protected function _prepareCollection() ->getCollection() ->addFieldToFilter('order_id', $this->order->getId()); - //todo $collection->getSelect()->joinLeft( array('cisi' => $this->resourceConnection->getTableName('cataloginventory_stock_item')), '(cisi.product_id = `main_table`.product_id AND cisi.stock_id = 1)', diff --git a/Block/Adminhtml/Ebay/Settings/Tabs/Main.php b/Block/Adminhtml/Ebay/Settings/Tabs/Main.php index f6542edef..3dc2c38e0 100644 --- a/Block/Adminhtml/Ebay/Settings/Tabs/Main.php +++ b/Block/Adminhtml/Ebay/Settings/Tabs/Main.php @@ -119,7 +119,8 @@ protected function _prepareForm() ], 'value' => $checkTheSameProductAlreadyListedMode, 'tooltip' => $this->__( - '

    Choose \'Yes\' to prevent M2E Pro from adding a Product if it + '

    Choose \'Yes\' to prevent M2E Pro from adding a Product + if it has already been presented in the Listing

    Essentially, this option is useful if you have Automatic Add/Remove Rules set up. It will ensure that each Product is listed only once, when Products are added to the Listing automatically.


    diff --git a/Block/Adminhtml/Ebay/Template/Description/Edit/Form/Data.php b/Block/Adminhtml/Ebay/Template/Description/Edit/Form/Data.php index f37722941..4baaebc43 100644 --- a/Block/Adminhtml/Ebay/Template/Description/Edit/Form/Data.php +++ b/Block/Adminhtml/Ebay/Template/Description/Edit/Form/Data.php @@ -7,50 +7,31 @@ class Data extends AbstractForm { + protected $attributes = []; + protected $generalAttributes = []; + protected $M2eProAttributes = []; + + protected function _construct() + { + parent::_construct(); + + /** @var \Ess\M2ePro\Helper\Magento\Attribute $magentoAttributeHelper */ + $magentoAttributeHelper = $this->getHelper('Magento\Attribute'); + + $this->attributes = $magentoAttributeHelper->getAll(); + } + protected function _prepareForm() { /** @var \Ess\M2ePro\Helper\Magento\Attribute $magentoAttributeHelper */ $magentoAttributeHelper = $this->getHelper('Magento\Attribute'); - $attributeSets = $this->getHelper('Data\GlobalData')->getValue('ebay_attribute_sets'); - $attributes = $magentoAttributeHelper->getAll(); $generalAttributes = $magentoAttributeHelper->getGeneralFromAllAttributeSets(); $attributesConfigurable = $magentoAttributeHelper->getAllConfigurable(); - $M2eProAttributes = array( - 'title' => $this->__('Title'), - 'subtitle' => $this->__('Subtitle'), - 'condition' => $this->__('Condition'), - 'condition_description' => $this->__('Seller Notes'), - 'fixed_price' => $this->__('Fixed Price'), - 'start_price' => $this->__('Start Price'), - 'reserve_price' => $this->__('Reserve Price'), - 'buyitnow_price' => $this->__('Buy It Now Price'), - 'qty' => $this->__('QTY'), - 'listing_type' => $this->__('Listing Type'), - 'listing_duration' => $this->__('Listing Duration'), - 'handling_time' => $this->__('Dispatch Time'), - 'primary_category_id' => $this->__('Primary Category Id'), - 'secondary_category_id' => $this->__('Secondary Category Id'), - 'store_primary_category_id' => $this->__('Store Primary Category Id'), - 'store_secondary_category_id' => $this->__('Store Secondary Category Id'), - 'primary_category_name' => $this->__('Primary Category Name'), - 'secondary_category_name' => $this->__('Secondary Category Name'), - 'store_primary_category_name' => $this->__('Store Primary Category Name'), - 'store_secondary_category_name' => $this->__('Store Secondary Category Name'), - 'domestic_shipping_method[1]' => $this->__('Domestic Shipping First Method'), - 'domestic_shipping_cost[1]' => $this->__('Domestic Shipping First Cost'), - 'domestic_shipping_additional_cost[1]' => - $this->__('Domestic Shipping First Additional Cost'), - 'international_shipping_method[1]' => $this->__('International Shipping First Method'), - 'international_shipping_cost[1]' => $this->__('International Shipping First Cost'), - 'international_shipping_additional_cost[1]' => - $this->__('International Shipping First Additional Cost'), - ); - $attributesByInputTypes = array( - 'text' => $magentoAttributeHelper->filterByInputTypes($attributes, array('text')), - 'text_select' => $magentoAttributeHelper->filterByInputTypes($attributes, array('text', 'select')), + 'text' => $magentoAttributeHelper->filterByInputTypes($this->attributes, array('text')), + 'text_select' => $magentoAttributeHelper->filterByInputTypes($this->attributes, array('text', 'select')), ); $generalAttributesByTypes = array( @@ -67,8 +48,6 @@ protected function _prepareForm() $default = $this->getDefault(); $formData = $this->getHelper('Data')->arrayReplaceRecursive($default, $formData); - $tinymceEnabledForJavascript = $formData['editor_type'] == Description::EDITOR_TYPE_TINYMCE ? 'true' : 'false'; - $isCustomDescription = ($formData['description_mode'] == Description::DESCRIPTION_MODE_CUSTOM); $form = $this->_formFactory->create(); @@ -185,7 +164,6 @@ protected function _prepareForm() [ 'name' => 'description[condition_mode]', 'label' => $this->__('Condition'), - 'class' => 'M2ePro-custom-attribute-can-be-created', 'values' => [ Description::CONDITION_MODE_NONE => $this->__('None'), [ @@ -196,16 +174,18 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'duration_attribute M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true, + 'class' => 'duration_attribute' ] ] ], 'value' => $formData['condition_mode'] == Description::CONDITION_MODE_NONE ? $formData['condition_mode'] : -1, + 'create_magento_attribute' => true, 'tooltip' => $this->__('Condition is one of the top factors Buyers consider when deciding whether to purchase an Item. When you create your Listing, let your Buyers know exactly what they\'ll - be receiving by specifying its Condition + be receiving by specifying its Condition. Some Conditions, such as \'new\', are grouped as single selections because they appear on eBay under slightly different names depending on the Category of the Item. @@ -215,7 +195,7 @@ protected function _prepareForm() href="http://developer.ebay.com/devzone/finding/callref/Enums/conditionIdList.html"> the eBay API reference: Item Condition IDs and Names for more details.') ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text,select'); $fieldset->addField('condition_value', 'hidden', @@ -234,26 +214,26 @@ protected function _prepareForm() ); $fieldset->addField('condition_note_mode', - 'select', - [ - 'container_id' => 'condition_note_tr', - 'label' => $this->__('Seller Notes'), - 'name' => 'description[condition_note_mode]', - 'values' => [ - Description::CONDITION_NOTE_MODE_NONE => $this->__('None'), - Description::CONDITION_NOTE_MODE_CUSTOM => $this->__('Custom Value'), - ], - 'value' => $formData['condition_note_mode'], - 'tooltip' => $this->__( - 'If Item is not new, you can provide additional details about the Item\'s Condition, + 'select', + [ + 'container_id' => 'condition_note_tr', + 'label' => $this->__('Seller Notes'), + 'name' => 'description[condition_note_mode]', + 'values' => [ + Description::CONDITION_NOTE_MODE_NONE => $this->__('None'), + Description::CONDITION_NOTE_MODE_CUSTOM => $this->__('Custom Value'), + ], + 'value' => $formData['condition_note_mode'], + 'tooltip' => $this->__( + 'If Item is not new, you can provide additional details about the Item\'s Condition, such as whether it has defects, missing parts, scratches, or other wear and tear. You have up to 1000 characters.' - ) - ] - ); + ) + ] + ); $preparedAttributes = []; - foreach ($attributes as $attribute) { + foreach ($this->attributes as $attribute) { $preparedAttributes[] = [ 'value' => $attribute['code'], 'label' => $attribute['label'], @@ -312,7 +292,6 @@ protected function _prepareForm() [ 'name' => 'description[image_main_mode]', 'label' => $this->__('Main Image'), - 'class' => 'M2ePro-custom-attribute-can-be-created', 'values' => [ Description::IMAGE_MAIN_MODE_NONE => $this->__('None'), Description::IMAGE_MAIN_MODE_PRODUCT => $this->__('Product Base Image'), @@ -320,12 +299,13 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], 'value' => $formData['image_main_mode'] != Description::IMAGE_MAIN_MODE_ATTRIBUTE ? $formData['image_main_mode'] : '', + 'create_magento_attribute' => true, 'tooltip' => $this->__( 'The first photo appears in the top left of your eBay Item and next to your Item\'s Title in Search results. @@ -333,7 +313,7 @@ protected function _prepareForm() e.g. http://mymagentostore.com/images/baseimage.jpg' ) ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text,textarea,select,multiselect'); $fieldset->addField('image_main_attribute', 'hidden', @@ -359,7 +339,7 @@ protected function _prepareForm() ); $fieldset->addField('use_supersize_images', - 'select', + self::SELECT, [ 'container_id' => 'use_supersize_images_tr', 'label' => $this->__('Super Size'), @@ -430,7 +410,6 @@ protected function _prepareForm() 'container_id' => 'gallery_images_mode_tr', 'name' => 'description[gallery_images_mode]', 'label' => $this->__('Gallery Images'), - 'class' => 'M2ePro-custom-attribute-can-be-created', 'values' => [ Description::GALLERY_IMAGES_MODE_NONE => $this->__('None'), [ @@ -441,10 +420,11 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], + 'create_magento_attribute' => true, 'tooltip' => $this->__( 'Adds small thumbnails that appear under the large Base Image. You can add up to 11 additional photos to each Listing on eBay. @@ -455,7 +435,7 @@ protected function _prepareForm() http://mymagentostore.com/images/baseimage2.jpg' ) ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text,textarea,select,multiselect'); if (count($attributesConfigurable) > 0) { $preparedAttributes = []; @@ -547,7 +527,6 @@ protected function _prepareForm() 'container_id' => 'variation_images_mode_tr', 'name' => 'description[variation_images_mode]', 'label' => $this->__('Variation Attribute Images'), - 'class' => 'M2ePro-custom-attribute-can-be-created', 'values' => [ Description::VARIATION_IMAGES_MODE_NONE => $this->__('None'), [ @@ -558,13 +537,14 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], 'value' => $formData['variation_images_mode'] != Description::VARIATION_IMAGES_MODE_ATTRIBUTE && $formData['variation_images_mode'] != Description::VARIATION_IMAGES_MODE_PRODUCT ? $formData['variation_images_mode'] : '', + 'create_magento_attribute' => true, 'tooltip' => $this->__( 'Allows to add Images from Product Variations. You can add up to 12 additional photos for each Variation. Please be thoughtful, as the the big number of added Images can decrease the Performance @@ -576,10 +556,152 @@ protected function _prepareForm() http://mymagentostore.com/images/baseimage2.jpg ') ] + )->addCustomAttribute('allowed_attribute_types', 'text,textarea,select,multiselect'); + + $watermarkFieldset = $fieldset->addFieldset('watermark_block', []); + + $watermarkFieldset->addField('old_watermark_settings_transparent', + 'hidden', + [ + 'name' => 'description[old_watermark_settings][transparent]', + 'value' => $formData['watermark_settings']['transparent'], + ] + ); + + $watermarkFieldset->addField('old_watermark_settings_scale', + 'hidden', + [ + 'name' => 'description[old_watermark_settings][scale]', + 'value' => $formData['watermark_settings']['scale'], + ] + ); + + $watermarkFieldset->addField('old_watermark_settings_position', + 'hidden', + [ + 'name' => 'description[old_watermark_settings][position]', + 'value' => $formData['watermark_settings']['position'], + ] + ); + + $watermarkFieldset->addField('old_watermark_settings_hashes_current', + 'hidden', + [ + 'name' => 'description[old_watermark_settings][hashes][current]', + 'value' => $formData['watermark_settings']['hashes']['current'], + ] + ); + + $watermarkFieldset->addField('old_watermark_settings_hashes_previous', + 'hidden', + [ + 'name' => 'description[old_watermark_settings][hashes][previous]', + 'value' => $formData['watermark_settings']['hashes']['previous'], + ] ); - // TODO NOT SUPPORTED FEATURES - // watermark + $watermarkFieldset->addField('watermark_mode', + 'select', + [ + 'label' => $this->__('Use Watermark'), + 'name' => 'description[watermark_mode]', + 'values' => [ + Description::WATERMARK_MODE_NO => $this->__('No'), + Description::WATERMARK_MODE_YES => $this->__('Yes'), + ], + 'value' => $formData['watermark_mode'], + 'tooltip' => $this->__( + 'Choose if you want to add a watermark to your gallery images. + More Options will be available if you select Yes.' + ) + ] + ); + + $watermarkFieldset->addField('watermark_image', + 'file', + [ + 'container_id' => 'watermark_image_container', + 'label' => $this->__('Watermark Upload'), + 'name' => 'watermark_image', + 'required' => is_null($formData['watermark_image']), + 'values' => [ + Description::WATERMARK_MODE_NO => $this->__('No'), + Description::WATERMARK_MODE_YES => $this->__('Yes'), + ], + 'value' => $formData['watermark_mode'], + 'tooltip' => $this->__('Select image that you want to add as a watermark.'), + ] + )->addCustomAttribute('accept', 'image/png'); + + if (!is_null($formData['watermark_image'])) { + + $encodedImage = base64_encode($formData['watermark_image']); + $watermarkFieldset->addField('old_watermark_image', + 'hidden', + [ + 'name' => 'description[old_watermark_image]', + 'value' => $encodedImage + ] + ); + + $watermarkFieldset->addField('watermark_uploaded_image', + 'note', + [ + 'label' => $this->__('Watermark Preview'), + 'container_id' => 'watermark_uploaded_image_container', + 'text' => << +HTML + ] + ); + } + + $watermarkFieldset->addField('watermark_transparent', + 'select', + [ + 'container_id' => 'watermark_transparent_container', + 'label' => $this->__('Watermark Transparency'), + 'name' => 'description[watermark_settings][transparent]', + 'values' => [ + Description::WATERMARK_TRANSPARENT_MODE_NO => $this->__('Disable'), + Description::WATERMARK_TRANSPARENT_MODE_YES => $this->__('Enable'), + ], + 'value' => $formData['watermark_settings']['transparent'], + 'tooltip' => $this->__('Sets transparency of watermark image to 30 %.') + ] + ); + + $watermarkFieldset->addField('watermark_scale', + 'select', + [ + 'container_id' => 'watermark_scale_container', + 'label' => $this->__('Scale Watermark Image'), + 'name' => 'description[watermark_settings][scale]', + 'values' => [ + Description::WATERMARK_SCALE_MODE_NONE => $this->__('None'), + Description::WATERMARK_SCALE_MODE_IN_WIDTH => $this->__('In Width'), + Description::WATERMARK_SCALE_MODE_STRETCH => $this->__('Full Image'), + ], + 'value' => $formData['watermark_settings']['scale'], + 'tooltip' => $this->__('Scales watermark image in width or full image.') + ] + ); + + $watermarkFieldset->addField('watermark_position', + 'select', + [ + 'container_id' => 'watermark_position_container', + 'label' => $this->__('Watermark Position'), + 'name' => 'description[watermark_settings][position]', + 'values' => [ + Description::WATERMARK_POSITION_TOP => $this->__('Top'), + Description::WATERMARK_POSITION_MIDDLE => $this->__('Middle'), + Description::WATERMARK_POSITION_BOTTOM => $this->__('Bottom'), + ], + 'value' => $formData['watermark_settings']['position'], + 'tooltip' => $this->__('Watermark position on the image.') + ] + ); $fieldset = $form->addFieldset('magento_block_ebay_template_description_form_data_details', [ @@ -606,7 +728,7 @@ protected function _prepareForm() ); $preparedAttributes = []; - foreach ($attributes as $attribute) { + foreach ($this->attributes as $attribute) { $preparedAttributes[] = [ 'value' => $attribute['code'], 'label' => $attribute['label'], @@ -626,7 +748,10 @@ protected function _prepareForm() 'label' => $this->__('Insert Attribute'), 'destination_id' => 'title_template', 'magento_attributes' => $preparedAttributes, - 'class' => 'select_attributes_for_title_button primary' + 'class' => 'select_attributes_for_title_button primary', + 'select_custom_attributes' => [ + 'apply_to_all_attribute_sets' => 0 + ], ])->toHtml() ] ); @@ -651,7 +776,7 @@ protected function _prepareForm() ); $preparedAttributes = []; - foreach ($attributes as $attribute) { + foreach ($this->attributes as $attribute) { $preparedAttributes[] = [ 'value' => $attribute['code'], 'label' => $attribute['label'], @@ -671,7 +796,10 @@ protected function _prepareForm() 'label' => $this->__('Insert Attribute'), 'destination_id' => 'subtitle_template', 'magento_attributes' => $preparedAttributes, - 'class' => 'select_attributes_for_title_button primary' + 'class' => 'select_attributes_for_title_button primary', + 'select_custom_attributes' => [ + 'apply_to_all_attribute_sets' => 0 + ], ])->toHtml() ] ); @@ -699,12 +827,12 @@ protected function _prepareForm() ] ); - // TODO NOT SUPPORTED FEATURES -// $button = $this->createBlock('Magento\Button')->addData([ -// 'label' => $this->__('Preview'), -// 'onclick' => 'EbayTemplateDescriptionObj.preview_click(\''.implode(',', $attributeSets).'\')', -// 'class' => 'bt_preview' -// ]); + $button = $this->createBlock('Magento\Button')->addData([ + 'label' => $this->__('Preview'), + 'onclick' => 'EbayTemplateDescriptionObj.openPreviewPopup()', + 'class' => 'action-primary', + 'style' => 'margin-left: 70px;' + ]); $fieldset->addField('description_mode', 'select', @@ -717,15 +845,14 @@ protected function _prepareForm() Description::DESCRIPTION_MODE_CUSTOM => $this->__('Custom Value'), ], 'value' => $formData['description_mode'], -// 'after_element_html' => $button->toHtml(), - 'tooltip' => $this->__( - <<Choose whether to use Magento Product Description or Product Short + 'after_element_html' => $this->getTooltipHtml( + $this->__(<<Choose whether to use Magento Product Description or Product Short Description for the eBay Listing Description


    -

    Alternatively, you can create a Custom Description and apply it to all +

    Alternatively, you can create a Custom Description and apply it to all of the Items Listed on eBay using this M2E Pro Listing.

    HTML - ) + )) . $button->toHtml() ] ); @@ -738,26 +865,47 @@ protected function _prepareForm() 'value' => $this->__('View / Edit Custom Description'), 'onclick' => 'EbayTemplateDescriptionObj.view_edit_custom_change()', 'href' => 'javascript://', - 'style' => 'text-decoration: underline;' //todo + 'style' => 'text-decoration: underline;' ] ); } + $showHideWYSIWYGButton = $this->createBlock('Magento\Button')->setData([ + 'id' => 'description_template_show_hide_wysiwyg', + 'label' => ($formData['editor_type'] == Description::EDITOR_TYPE_SIMPLE) + ? $this->__('Show Editor') : $this->__('Hide Editor'), + 'class' => 'action-primary' + ]); + + $openCustomInsertsButton = $this->createBlock('Magento\Button')->setData([ + 'id' => 'custom_inserts_open_popup', + 'label' => $this->__('Insert Customs'), + 'class' => 'action-primary' + ]); + $fieldset->addField('description_template', - 'textarea', + 'editor', [ - 'css_class' => 'c-custom_description_tr', + 'container_id' => 'description_template_tr', + 'css_class' => 'c-custom_description_tr _required', 'label' => $this->__('Description Value'), 'name' => 'description[description_template]', 'value' => $formData['description_template'], - 'required' => true + 'class' => ' admin__control-textarea left M2ePro-validate-description-template', + 'wysiwyg' => true, + 'force_load' => true, + 'config' => new \Magento\Framework\DataObject([ + 'enabled' => true + ]), + 'after_element_html' => << + {$showHideWYSIWYGButton->toHtml()} + {$openCustomInsertsButton->toHtml()} +
    +HTML ] ); - // TODO NOT SUPPORTED FEATURES - // WYSWYG editor - // custom inserts - $fieldset = $form->addFieldset('magento_block_ebay_template_description_form_data_product_details', [ 'legend' => $this->__('eBay Catalog Identifiers'), @@ -780,7 +928,7 @@ protected function _prepareForm() Variations pop-up, only for that Variation the Settings of this section will be ignored.

    Note: some eBay Categories require some of these Values. Once you select such - eBay Primary Category, you will see a notification which will + eBay Catalog Primary Category, you will see a notification which will show what Identifier(s) must be specified. ') ] @@ -815,10 +963,11 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], + 'create_magento_attribute' => true, 'value' => $formData['product_details']['upc']['mode'] != Description::PRODUCT_DETAILS_MODE_ATTRIBUTE ? $formData['product_details']['upc']['mode'] : '', 'tooltip' => $this->__(' @@ -827,7 +976,7 @@ protected function _prepareForm() The UPC or Universal Product Code is a 12 digit unique Identifier for a Product. ') ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text'); $fieldset->addField('product_details_upc_attribute', 'hidden', @@ -866,12 +1015,13 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], 'value' => $formData['product_details']['ean']['mode'] != Description::PRODUCT_DETAILS_MODE_ATTRIBUTE ? $formData['product_details']['ean']['mode'] : '', + 'create_magento_attribute' => true, 'tooltip' => $this->__(' Choose the Magento Attribute that contains the EAN for a Product or use a "Does not apply" Option in case your Product does not have an EAN Value.

    @@ -879,7 +1029,7 @@ protected function _prepareForm() the 13 digit unique Identifier for a Product. ') ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text'); $fieldset->addField('product_details_ean_attribute', 'hidden', @@ -918,19 +1068,20 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], 'value' => $formData['product_details']['isbn']['mode'] != Description::PRODUCT_DETAILS_MODE_ATTRIBUTE ? $formData['product_details']['isbn']['mode'] : '', + 'create_magento_attribute' => true, 'tooltip' => $this->__(' Choose the Magento Attribute that contains the ISBN for a Product or use a "Does not apply" Option in case your Product does not have an ISBN Value.

    The ISBN or International Standard Book Number is a unique Identifier for a book. ') ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text'); $fieldset->addField('product_details_isbn_attribute', 'hidden', @@ -968,15 +1119,16 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], 'value' => $formData['product_details']['epid']['mode'] != Description::PRODUCT_DETAILS_MODE_ATTRIBUTE ? $formData['product_details']['epid']['mode'] : '', + 'create_magento_attribute' => true, 'tooltip' => $this->__('An eBay Product ID is eBay\'s global reference ID for a Catalog Product.') ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text'); $fieldset->addField('product_details_epid_attribute', 'hidden', @@ -1015,18 +1167,19 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], 'value' => $formData['product_details']['brand']['mode'] != Description::PRODUCT_DETAILS_MODE_ATTRIBUTE ? $formData['product_details']['brand']['mode'] : '', + 'create_magento_attribute' => true, 'tooltip' => $this->__( 'Choose the Magento Attribute that contains the Brand for a Product or use an "Unbranded" Option in case your Product does not have an Brand Value.' ) ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text,select'); $fieldset->addField('product_details_brand_attribute', 'hidden', @@ -1064,19 +1217,20 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], 'value' => $formData['product_details']['mpn']['mode'] != Description::PRODUCT_DETAILS_MODE_ATTRIBUTE ? $formData['product_details']['mpn']['mode'] : '', + 'create_magento_attribute' => true, 'tooltip' => $this->__(' Choose the Magento Attribute that contains the MPN for a Product or use a "Does not apply" Option in case your Product does not have an MPN Value.

    The MPN or Manufacturer Part Number is a Identifier specified by the manufacturer. ') ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text'); $fieldset->addField('product_details_mpn_attribute', 'hidden', @@ -1233,9 +1387,20 @@ protected function _prepareForm() $this->jsTranslator->addTranslations([ 'Adding Image' => $this->__('Adding Image'), - 'Seller Notes must be less then 1000 symbols.' => $this->__('Seller Notes must be less then 1000 symbols.') + 'Seller Notes must be less then 1000 symbols.' => $this->__('Seller Notes must be less then 1000 symbols.'), + 'Custom Insertions' => $this->__('Custom Insertions'), + 'Show Editor' => $this->__('Show Editor'), + 'Hide Editor' => $this->__('Hide Editor'), + 'Description Preview' => $this->__('Description Preview'), + 'Please enter a valid Magento product ID.' => $this->__('Please enter a valid Magento product ID.'), + 'Please enter Description Value.' => $this->__('Please enter Description Value.') ]); + $initWYSIWYG = ''; + if ($this->getRequest()->isXmlHttpRequest()) { + $initWYSIWYG = 'EbayTemplateDescriptionObj.initWYSIWYG();'; + } + $this->js->add(<<getCustomInsertsHtml() . $this->getDescriptionPreviewHtml(); + } + public function isCustom() { if (isset($this->_data['is_custom'])) { @@ -1349,4 +1520,336 @@ public function getDefault() return $default; } + + //######################################## + + protected function getCustomInsertsHtml() + { + $form = $this->_formFactory->create(); + + $fieldset = $form->addFieldset('custom_inserts', ['legend' => $this->__('Attribute')]); + + $preparedAttributes = []; + foreach ($this->attributes as $attribute) { + $preparedAttributes[] = [ + 'value' => $attribute['code'], + 'label' => $attribute['label'], + ]; + } + + $button = $this->createBlock('Magento\Button')->setData([ + 'label' => $this->__('Insert'), + 'class' => 'action-primary', + 'onclick' => 'EbayTemplateDescriptionObj.insertProductAttribute()', + 'style' => 'margin-left: 15px;' + ]); + + $fieldset->addField('custom_inserts_product_attribute', + self::SELECT, + [ + 'label' => $this->__('Magento Product'), + 'class' => 'M2ePro-custom-attribute-can-be-created', + 'values' => $preparedAttributes, + 'after_element_html' => $button->toHtml(), + 'apply_to_all_attribute_sets' => 0 + ] + )->addCustomAttribute('apply_to_all_attribute_sets', 0); + + $M2eProAttributes = array( + 'title' => $this->__('Title'), + 'subtitle' => $this->__('Subtitle'), + 'condition' => $this->__('Condition'), + 'condition_description' => $this->__('Seller Notes'), + 'fixed_price' => $this->__('Fixed Price'), + 'start_price' => $this->__('Start Price'), + 'reserve_price' => $this->__('Reserve Price'), + 'buyitnow_price' => $this->__('Buy It Now Price'), + 'qty' => $this->__('QTY'), + 'listing_type' => $this->__('Listing Type'), + 'listing_duration' => $this->__('Listing Duration'), + 'handling_time' => $this->__('Dispatch Time'), + 'primary_category_id' => $this->__('Primary Category Id'), + 'secondary_category_id' => $this->__('Secondary Category Id'), + 'store_primary_category_id' => $this->__('Store Primary Category Id'), + 'store_secondary_category_id' => $this->__('Store Secondary Category Id'), + 'primary_category_name' => $this->__('Primary Category Name'), + 'secondary_category_name' => $this->__('Secondary Category Name'), + 'store_primary_category_name' => $this->__('Store Primary Category Name'), + 'store_secondary_category_name' => $this->__('Store Secondary Category Name'), + 'domestic_shipping_method[1]' => $this->__('Domestic Shipping First Method'), + 'domestic_shipping_cost[1]' => $this->__('Domestic Shipping First Cost'), + 'domestic_shipping_additional_cost[1]' => + $this->__('Domestic Shipping First Additional Cost'), + 'international_shipping_method[1]' => $this->__('International Shipping First Method'), + 'international_shipping_cost[1]' => $this->__('International Shipping First Cost'), + 'international_shipping_additional_cost[1]' => + $this->__('International Shipping First Additional Cost'), + ); + + $button->setData('onclick', 'EbayTemplateDescriptionObj.insertM2eProAttribute()'); + + $fieldset->addField('custom_inserts_m2epro_attribute', + 'select', + [ + 'label' => $this->__('M2E Pro'), + 'values' => $M2eProAttributes, + 'after_element_html' => $button->toHtml() + ] + ); + + $fieldset = $form->addFieldset('product_images', ['legend' => $this->__('Image(s)')]); + + $fieldset->addField('select_attributes_image', + 'select', + [ + 'label' => $this->__('Insert'), + 'values' => [ + 'image' => $this->__('Image'), + 'media_gallery' => $this->__('Gallery'), + ], + 'value' => 'image' + ] + ); + + $preparedValues = [ + 0 => $this->__('Base Image') + ]; + + for ($i = 1; $i <= 20; $i++) { + $preparedValues[$i] = $i; + } + + $fieldset->addField('select_attributes_image_order_position', + 'select', + [ + 'label' => $this->__('Position'), + 'values' => $preparedValues, + 'css_class' => 'all-products-image' + ] + ); + + $preparedValues[0] = $this->__('All'); + + $fieldset->addField('select_attributes_image_count', + 'select', + [ + 'label' => $this->__('Quantity'), + 'values' => $preparedValues, + 'css_class' => 'all-products-images' + ] + ); + + $fieldset->addField('display_products_images', + 'select', + [ + 'label' => $this->__('Displaying'), + 'values' => [ + 'custom_settings' => $this->__('Custom Settings'), + 'gallery_view' => $this->__('Gallery View'), + ], + 'css_class' => 'all-products-images' + ] + ); + + $imageWidth = $this->elementFactory->create('text')->setData([ + 'html_id' => 'image_width', + 'name' => 'image_width', + 'class' => 'custom_inserts_images_input M2ePro-required-when-visible validate-digits' + ])->setForm($form); + + $fieldset->addField('image_width_mode', + 'select', + [ + 'label' => $this->__('Width'), + 'values' => [ + 0 => $this->__('Original'), + 1 => $this->__('Custom'), + ], + 'after_element_html' => <<{$imageWidth->toHtml()} px + + +HTML + , + 'css_class' => 'products-images-mode-change-label' + ] + ); + + $imageHeight = $this->elementFactory->create('text')->setData([ + 'html_id' => 'image_height', + 'name' => 'image_height', + 'class' => 'custom_inserts_images_input M2ePro-required-when-visible validate-digits' + ])->setForm($form); + + $fieldset->addField('image_height_mode', + 'select', + [ + 'label' => $this->__('Height'), + 'values' => [ + 0 => $this->__('Original'), + 1 => $this->__('Custom'), + ], + 'after_element_html' => <<{$imageHeight->toHtml()} px + + +HTML + , + 'css_class' => 'products-images-mode-change-label' + ] + ); + + $imageMargin = $this->elementFactory->create('text')->setData([ + 'html_id' => 'image_margin', + 'name' => 'image_margin', + 'class' => 'custom_inserts_images_input M2ePro-required-when-visible validate-digits' + ])->setForm($form); + + $fieldset->addField('image_margin_mode', + 'select', + [ + 'label' => $this->__('Margin'), + 'values' => [ + 0 => $this->__('None'), + 1 => $this->__('Custom'), + ], + 'after_element_html' => '' . $imageMargin->toHtml() . ' px', + 'css_class' => 'products-images-custom-settings' + ] + ); + + $fieldset->addField('select_attributes_image_layout', + 'select', + [ + 'label' => $this->__('Layout'), + 'values' => [ + 'row' => $this->__('Horizontal'), + 'column' => $this->__('Vertical'), + ], + 'css_class' => 'all-products-images' + ] + ); + + $fieldset->addField('gallery_hint_text', + 'textarea', + [ + 'label' => $this->__('Gallery Hint'), + 'value' => $this->__('Click on the image below to get zoomed view of the Item'), + 'css_class' => 'products-images-gallery-view' + ] + ); + + $fieldset->addField('image_linked_mode', + 'select', + [ + 'label' => $this->__('Open Original Size in a New Window'), + 'values' => [ + 0 => $this->__('No'), + 1 => $this->__('Yes'), + ], + 'css_class' => 'products-images-custom-settings' + ] + ); + + $fieldset->addField('image_insertion_watermark_mode', + 'select', + [ + 'container_id' => 'products_images_watermark_mode', + 'label' => $this->__('Use Watermark'), + 'values' => [ + Description::WATERMARK_MODE_NO => $this->__('No'), + Description::WATERMARK_MODE_YES => $this->__('Yes'), + ], + ] + ); + + $fieldset->addField($this->mathRandom->getUniqueHash('id_'), + 'button', + [ + 'label' => '', + 'onclick' => 'EbayTemplateDescriptionObj.insertGallery();', + 'value' => $this->__('Insert'), + 'class' => 'action-primary' + ] + ); + + return << +
    {$form->toHtml()}
    +
    +HTML; + } + + protected function getDescriptionPreviewHtml() + { + $form = $this->_formFactory->create(); + + $fieldset = $form->addFieldset('description_preview_fieldset', ['legend' => '']); + + $fieldset->addField('description_preview_help_block', + self::HELP_BLOCK, + [ + 'content' => $this->__(' + If you would like to preview the Description data for the particular Magento Product, please, + provide its ID into the Magento Product ID input and select + a Magento Store View the values + should be taken from. As a result you will see the Item Description which will be sent to + eBay basing on the settings you specified.
    + + Also, you can press a Select Randomly button to allow M2E Pro to automatically + select the most suitable Product for its previewing.' + ) + ] + ); + + $button = $this->createBlock('Magento\Button')->addData([ + 'label' => $this->__('Select Randomly'), + 'onclick' => 'EbayTemplateDescriptionObj.selectProductIdRandomly()', + 'class' => 'action-primary', + 'style' => 'margin-left: 25px' + ]); + + $fieldset->addField('description_preview_magento_product_id', + 'text', + [ + 'label' => $this->__('Magento Product ID'), + 'after_element_html' => $button->toHtml(), + 'class' => 'M2ePro-required-when-visible validate-digits M2ePro-validate-magento-product-id', + 'css_class' => '_required', + 'style' => 'width: 200px', + 'name' => 'description_preview[magento_product_id]' + ] + ); + + $fieldset->addField('description_preview_store_id', + self::STORE_SWITCHER, + [ + 'label' => $this->__('Store View'), + 'name' => 'description_preview[store_id]' + ] + ); + + $fieldset->addField('description_preview_description_mode', 'hidden', [ + 'name' => 'description_preview[description_mode]' + ]); + $fieldset->addField('description_preview_description_template', 'hidden', [ + 'name' => 'description_preview[description_template]' + ]); + $fieldset->addField('description_preview_watermark_mode', 'hidden', [ + 'name' => 'description_preview[watermark_mode]' + ]); + + $fieldset->addField('description_preview_form_key', 'hidden', [ + 'name' => 'form_key', + 'value' => $this->formKey->getFormKey() + ]); + + return << +
    {$form->toHtml()}
    +
    +HTML; + } + + //######################################## } \ No newline at end of file diff --git a/Block/Adminhtml/Ebay/Template/Description/Preview.php b/Block/Adminhtml/Ebay/Template/Description/Preview.php new file mode 100644 index 000000000..32b418b70 --- /dev/null +++ b/Block/Adminhtml/Ebay/Template/Description/Preview.php @@ -0,0 +1,17 @@ +css->addFile('ebay/template.css'); + } +} \ No newline at end of file diff --git a/Block/Adminhtml/Ebay/Template/Edit/Form.php b/Block/Adminhtml/Ebay/Template/Edit/Form.php index 2e45098ae..693002428 100644 --- a/Block/Adminhtml/Ebay/Template/Edit/Form.php +++ b/Block/Adminhtml/Ebay/Template/Edit/Form.php @@ -46,9 +46,12 @@ public function _construct() protected function _prepareForm() { - $form = $this->_formFactory->create( - ['data' => ['id' => 'edit_form', 'action' => 'javascript:void(0)', 'method' => 'post']] - ); + $form = $this->_formFactory->create(['data' => [ + 'id' => 'edit_form', + 'action' => 'javascript:void(0)', + 'method' => 'post', + 'enctype' => 'multipart/form-data' + ]]); $fieldset = $form->addFieldset( 'general_fieldset', diff --git a/Block/Adminhtml/Ebay/Template/Grid.php b/Block/Adminhtml/Ebay/Template/Grid.php index dc5b83db8..13bf785fc 100644 --- a/Block/Adminhtml/Ebay/Template/Grid.php +++ b/Block/Adminhtml/Ebay/Template/Grid.php @@ -32,6 +32,8 @@ public function _construct() { parent::_construct(); + $this->css->addFile('policy/grid.css'); + // Initialization block // --------------------------------------- $this->setId('ebayTemplateGrid'); @@ -233,6 +235,7 @@ protected function _prepareColumns() 'align' => 'left', 'width' => '150px', 'type' => 'datetime', + 'filter_time' => true, // 'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage\Core\Model\Locale::FORMAT_TYPE_MEDIUM), 'index' => 'create_date', 'filter_index' => 'main_table.create_date' @@ -243,6 +246,7 @@ protected function _prepareColumns() 'align' => 'left', 'width' => '150px', 'type' => 'datetime', + 'filter_time' => true, // 'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage\Core\Model\Locale::FORMAT_TYPE_MEDIUM), 'index' => 'update_date', 'filter_index' => 'main_table.update_date' @@ -258,16 +262,9 @@ protected function _prepareColumns() 'sortable' => false, 'getter' => 'getTemplateId', 'actions' => array( - array( - 'caption' => $this->__('Edit'), - 'url' => array( - 'base' => '*/ebay_template/edit', - 'params' => array('nick' => '$nick') - ), - 'field' => 'id' - ), array( 'caption' => $this->__('Delete'), + 'class' => 'action-default scalable add primary policy-delete-btn', 'url' => array( 'base' => '*/ebay_template/delete', 'params' => array('nick' => '$nick') diff --git a/Block/Adminhtml/Ebay/Template/Payment/Edit/Form/Data.php b/Block/Adminhtml/Ebay/Template/Payment/Edit/Form/Data.php index 2313297c3..4141fd4d6 100644 --- a/Block/Adminhtml/Ebay/Template/Payment/Edit/Form/Data.php +++ b/Block/Adminhtml/Ebay/Template/Payment/Edit/Form/Data.php @@ -3,7 +3,6 @@ class Data extends \Ess\M2ePro\Block\Adminhtml\Magento\Form\AbstractForm { - protected $elementFactory; protected $paypalConfigFactory; public $formData = []; @@ -12,7 +11,6 @@ class Data extends \Ess\M2ePro\Block\Adminhtml\Magento\Form\AbstractForm //######################################## public function __construct( - \Magento\Framework\Data\Form\ElementFactory $elementFactory, \Magento\Paypal\Model\Config\Factory $paypalConfigFactory, \Ess\M2ePro\Block\Adminhtml\Magento\Context\Template $context, \Magento\Framework\Registry $registry, @@ -20,7 +18,6 @@ public function __construct( array $data = [] ) { - $this->elementFactory = $elementFactory; $this->paypalConfigFactory = $paypalConfigFactory; parent::__construct($context, $registry, $formFactory, $data); } @@ -105,12 +102,13 @@ protected function _prepareForm() 'label' => $this->__('Immediate Payment Required'), 'value' => 1, 'checked' => (bool)$this->formData['pay_pal_immediate_payment'], - 'class' => 'input-text admin__control-checkbox', - 'after_element_html' => '', + 'class' => 'admin__control-checkbox', 'field_extra_attributes' => 'id="pay_pal_immediate_payment_container" style="display: none;"', - 'tooltip' => $this->__('This is only applicable to Items Listed on PayPal-enabled - Marketplaces in Categories that support immediate payment, - when a Seller has a Premier or Business PayPal Account.') + 'after_element_html' => ''.$this->getTooltipHtml($this->__( + 'This is only applicable to Items Listed on PayPal-enabled + Marketplaces in Categories that support immediate payment, + when a Seller has a Premier or Business PayPal Account.' + ), true) ] ); @@ -217,9 +215,9 @@ public function getDefault() $payPalConfig = $this->paypalConfigFactory->create('Magento\Paypal\Model\Config'); $payPalConfig->setStoreId($store->getId()); - if ($payPalConfig->getValue('business_account')) { + if ($businessAccount = $payPalConfig->getValue('business_account')) { $default['pay_pal_mode'] = 1; - $default['pay_pal_email_address'] = $payPalConfig->business_account; + $default['pay_pal_email_address'] = $businessAccount; } // --------------------------------------- @@ -242,11 +240,6 @@ public function getMarketplaceData() $policyLocalization = $this->getData('policy_localization'); if (!empty($policyLocalization)) { - /** @var ]Ess\M2ePro\Model\Magento\Translate $translator */ - //TODO -// $translator = Mage::getModel('M2ePro/Magento\Translate'); -// $translator->setLocale($policyLocalization); -// $translator->init(); $translator = $this->getHelper('Module\Translation'); foreach ($data['services'] as $key => $item) { diff --git a/Block/Adminhtml/Ebay/Template/ReturnPolicy/Edit/Form/Data.php b/Block/Adminhtml/Ebay/Template/ReturnPolicy/Edit/Form/Data.php index 1379105c3..e49630c42 100644 --- a/Block/Adminhtml/Ebay/Template/ReturnPolicy/Edit/Form/Data.php +++ b/Block/Adminhtml/Ebay/Template/ReturnPolicy/Edit/Form/Data.php @@ -12,7 +12,7 @@ class Data extends \Ess\M2ePro\Block\Adminhtml\Magento\Form\AbstractForm //######################################## public function __construct( - \Ess\M2ePro\Model\Ebay\Template\Returnpolicy $returnPolicyTemplate, + \Ess\M2ePro\Model\Ebay\Template\ReturnPolicy $returnPolicyTemplate, \Ess\M2ePro\Block\Adminhtml\Magento\Context\Template $context, \Magento\Framework\Registry $registry, \Magento\Framework\Data\FormFactory $formFactory, @@ -76,14 +76,13 @@ protected function _prepareForm() if (!empty($this->marketplaceData['info']['returns_accepted'])) { $fieldset->addField('return_accepted', - 'select', + self::SELECT, [ 'name' => 'return_policy[accepted]', 'label' => __('Return Policy'), 'title' => __('Return Policy'), 'values' => $this->getMarketplaceDataToOptions('returns_accepted'), 'value' => $this->formData['accepted'], - 'required' => true, 'tooltip' => $this->__( 'Buyers are more comfortable shopping from Sellers who offer marketplaceData['info']['refund'])) { - $fieldset->addField( - 'return_option', - 'select', + $fieldset->addField('return_option', + self::SELECT, [ 'name' => 'return_policy[option]', 'label' => __('Refund Will Be Given As'), @@ -110,9 +108,8 @@ protected function _prepareForm() } if (!empty($this->marketplaceData['info']['returns_within'])) { - $fieldset->addField( - 'return_within', - 'select', + $fieldset->addField('return_within', + self::SELECT, [ 'name' => 'return_policy[within]', 'label' => __('Item Must Be Returned Within'), @@ -124,9 +121,8 @@ protected function _prepareForm() } if ($this->canShowHolidayReturnOption()) { - $fieldset->addField( - 'return_holiday_mode', - 'select', + $fieldset->addField('return_holiday_mode', + self::SELECT, [ 'name' => 'return_policy[holiday_mode]', 'label' => __('Extended Holiday Returns'), @@ -158,9 +154,8 @@ protected function _prepareForm() } if (!empty($this->marketplaceData['info']['shipping_cost_paid_by'])) { - $fieldset->addField( - 'return_shipping_cost', - 'select', + $fieldset->addField('return_shipping_cost', + self::SELECT, [ 'name' => 'return_policy[shipping_cost]', 'label' => __('Return Shipping Will Be Paid By'), @@ -172,9 +167,8 @@ protected function _prepareForm() } if (!empty($this->marketplaceData['info']['restocking_fee_value'])) { - $fieldset->addField( - 'return_restocking_fee', - 'select', + $fieldset->addField('return_restocking_fee', + self::SELECT, [ 'name' => 'return_policy[restocking_fee]', 'label' => __('Restocking Fee Value'), @@ -186,8 +180,7 @@ protected function _prepareForm() ); } - $fieldset->addField( - 'return_description', + $fieldset->addField('return_description', 'textarea', [ 'name' => 'return_policy[description]', @@ -261,12 +254,7 @@ public function getMarketplaceData() $policyLocalization = $this->getData('policy_localization'); if (!empty($policyLocalization)) { - /** @var \Ess\M2ePro\Model\Magento\Translate $translator */ - //TODO -// $translator = Mage::getModel('M2ePro/Magento_Translate'); - $translator = $this->getHelper('Module\Translation'); - $translator->setLocale($policyLocalization); - $translator->init(); + /** @var \Ess\M2ePro\Helper\Module\Translation $translator */ foreach ($data['info']['returns_within'] as $key => $item) { $data['info']['returns_within'][$key]['title'] = $translator->__($item['title']); diff --git a/Block/Adminhtml/Ebay/Template/SellingFormat/Edit/Form/Data.php b/Block/Adminhtml/Ebay/Template/SellingFormat/Edit/Form/Data.php index eb4b9c011..6e1d6e35a 100644 --- a/Block/Adminhtml/Ebay/Template/SellingFormat/Edit/Form/Data.php +++ b/Block/Adminhtml/Ebay/Template/SellingFormat/Edit/Form/Data.php @@ -7,13 +7,11 @@ class Data extends AbstractForm { - protected $elementFactory; protected $currency; protected $cacheConfig; protected $ebayFactory; public function __construct( - \Magento\Framework\Data\Form\Element\Factory $elementFactory, \Magento\Framework\Locale\Currency $currency, \Ess\M2ePro\Model\Config\Manager\Cache $cacheConfig, \Ess\M2ePro\Model\ActiveRecord\Component\Parent\Ebay\Factory $ebayFactory, @@ -23,7 +21,6 @@ public function __construct( array $data = [] ) { - $this->elementFactory = $elementFactory; $this->currency = $currency; $this->cacheConfig = $cacheConfig; $this->ebayFactory = $ebayFactory; @@ -44,10 +41,6 @@ protected function _prepareForm() $default = $this->getDefault(); $formData = array_merge($default, $formData); - //TODO NOT SUPPORTED FEATURES -// $charitiesDict = $this->getData('charities'); -// $charitySelf = json_decode($formData['charity'], true); - $taxCategories = $this->getTaxCategoriesInfo(); $form = $this->_formFactory->create(); @@ -118,13 +111,11 @@ protected function _prepareForm() ]; } - $fieldset->addField( - 'listing_type', + $fieldset->addField('listing_type', self::SELECT, [ 'name' => 'selling_format[listing_type]', 'label' => $this->__('Listing Type'), - 'class' => 'M2ePro-custom-attribute-can-be-created', 'values' => [ SellingFormat::LISTING_TYPE_AUCTION => $this->__('Auction'), SellingFormat::LISTING_TYPE_FIXED => $this->__('Fixed Price'), @@ -132,12 +123,13 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], 'value' => $formData['listing_type'] != SellingFormat::LISTING_TYPE_ATTRIBUTE ? $formData['listing_type'] : '', + 'create_magento_attribute' => true, 'tooltip' => $this->__( 'Choose whether Products Listed with this Policy on eBay Auction-style or Fixed Price.
    Auction-style Listings are best if you are unsure of the value of your Item, @@ -150,7 +142,7 @@ protected function _prepareForm() An empty or wrong value in Attribute will be considered as Fixed Price Listing Type.' ) ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text,select'); $fieldset->addField( 'listing_type_attribute', @@ -160,9 +152,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'listing_is_private', - 'select', + $fieldset->addField('listing_is_private', + self::SELECT, [ 'label' => $this->__('Private Listing'), 'name' => 'selling_format[listing_is_private]', @@ -182,9 +173,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'restricted_to_business', - 'select', + $fieldset->addField('restricted_to_business', + self::SELECT, [ 'label' => $this->__('For Business Users Only'), 'name' => 'selling_format[restricted_to_business]', @@ -236,8 +226,7 @@ protected function _prepareForm() ) . '
    '; - $fieldset->addField( - 'duration_mode', + $fieldset->addField('duration_mode', self::SELECT, [ 'container_id' => 'duration_mode_container', @@ -249,16 +238,7 @@ protected function _prepareForm() ] ); - $preparedAttributes = [ - [ - 'label' => '', - 'value' => '', - 'attrs' => [ - 'style' => 'display: none' - ] - ] - ]; - + $preparedAttributes = []; if ( $formData['duration_mode'] == SellingFormat::LISTING_TYPE_ATTRIBUTE && !$magentoAttributeHelper->isExistInAttributesArray($formData['duration_attribute'], $attributes) @@ -289,26 +269,29 @@ protected function _prepareForm() ]; } - $fieldset->addField( - 'duration_attribute', + $fieldset->addField('duration_attribute', self::SELECT, [ 'container_id' => 'duration_attribute_container', 'label' => $this->__('Listing Duration'), - 'class' => 'M2ePro-custom-attribute-can-be-created', 'values' => [ + [ + 'label' => '', 'value' => '', + 'attrs' => ['style' => 'display: none'] + ], [ 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'duration_attribute M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], + 'create_magento_attribute' => true, 'required' => true, 'tooltip' => $durationTooltip ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text'); $fieldset->addField( 'listing_duration_attribute_value', @@ -319,8 +302,7 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'out_of_stock_control_mode', + $fieldset->addField('out_of_stock_control_mode', self::SELECT, [ 'name' => 'selling_format[out_of_stock_control]', @@ -350,7 +332,7 @@ protected function _prepareForm() ]; if ( - $formData['listing_type'] == \Ess\M2ePro\Model\Template\SellingFormat::QTY_MODE_ATTRIBUTE + $formData['qty_mode'] == \Ess\M2ePro\Model\Template\SellingFormat::QTY_MODE_ATTRIBUTE && !$magentoAttributeHelper->isExistInAttributesArray($formData['qty_custom_attribute'], $attributes) && $formData['qty_custom_attribute'] != '' ) { @@ -379,14 +361,12 @@ protected function _prepareForm() ]; } - $fieldset->addField( - 'qty_mode', + $fieldset->addField('qty_mode', self::SELECT, [ 'container_id' => 'qty_mode_tr', 'name' => 'selling_format[qty_mode]', 'label' => $this->__('Quantity'), - 'class' => 'M2ePro-custom-attribute-can-be-created', 'values' => [ \Ess\M2ePro\Model\Template\SellingFormat::QTY_MODE_PRODUCT => $this->__('Product Quantity'), \Ess\M2ePro\Model\Template\SellingFormat::QTY_MODE_SINGLE => $this->__('Single Item'), @@ -395,12 +375,14 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true, + 'new_option_value' => \Ess\M2ePro\Model\Template\SellingFormat::QTY_MODE_ATTRIBUTE ] ] ], 'value' => $formData['qty_mode'] != \Ess\M2ePro\Model\Template\SellingFormat::QTY_MODE_ATTRIBUTE ? $formData['qty_mode'] : '', + 'create_magento_attribute' => true, 'tooltip' => $this->__( 'The number of Items you want to sell on eBay.

    Product Quantity: the number of Items on eBay will be the same as in Magento.
    @@ -409,18 +391,16 @@ protected function _prepareForm() Magento Attribute: takes the number from the Attribute you specify.' ) ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text'); - $fieldset->addField( - 'qty_custom_attribute', + $fieldset->addField('qty_custom_attribute', 'hidden', [ 'name' => 'selling_format[qty_custom_attribute]', ] ); - $fieldset->addField( - 'qty_custom_value', + $fieldset->addField('qty_custom_value', 'text', [ 'container_id' => 'qty_mode_cv_tr', @@ -440,9 +420,8 @@ protected function _prepareForm() ]; } - $fieldset->addField( - 'qty_percentage', - 'select', + $fieldset->addField('qty_percentage', + self::SELECT, [ 'container_id' => 'qty_percentage_tr', 'label' => $this->__('Quantity Percentage'), @@ -458,9 +437,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'qty_modification_mode', - 'select', + $fieldset->addField('qty_modification_mode', + self::SELECT, [ 'container_id' => 'qty_modification_mode_tr', 'label' => $this->__('Conditional Quantity'), @@ -479,8 +457,7 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'qty_min_posted_value', + $fieldset->addField('qty_min_posted_value', 'text', [ 'container_id' => 'qty_min_posted_value_tr', @@ -498,8 +475,7 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'qty_max_posted_value', + $fieldset->addField('qty_max_posted_value', 'text', [ 'container_id' => 'qty_max_posted_value_tr', @@ -515,9 +491,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'ignore_variations_value', - 'select', + $fieldset->addField('ignore_variations_value', + self::SELECT, [ 'container_id' => 'ignore_variations_value_tr', 'label' => $this->__('Ignore Variations'), @@ -543,8 +518,7 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'vat_percent', + $fieldset->addField('vat_percent', 'text', [ 'container_id' => 'vat_percent_tr', @@ -560,9 +534,8 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'tax_table_mode', - 'select', + $fieldset->addField('tax_table_mode', + self::SELECT, [ 'container_id' => 'tax_table_mode_tr', 'label' => $this->__('Use eBay Tax Table'), @@ -605,7 +578,7 @@ protected function _prepareForm() $preparedValues[] = [ 'label' => $this->__('Ebay Recommended'), - 'values' => $preparedAttributesCategories + 'value' => $preparedAttributesCategories ]; } @@ -629,29 +602,27 @@ protected function _prepareForm() $preparedValues[] = [ 'label' => $this->__('Magento Attributes'), - 'values' => $preparedAttributes, - 'attrs' => ['class' => 'M2ePro-custom-attribute-optgroup'] + 'value' => $preparedAttributes, + 'attrs' => ['is_magento_attribute' => true] ]; } - $fieldset->addField( - 'tax_category_mode', + $fieldset->addField('tax_category_mode', self::SELECT, [ 'label' => $this->__('Tax Category'), - 'class' => 'M2ePro-custom-attribute-can-be-created', - 'values' => [ - SellingFormat::TAX_CATEGORY_MODE_NONE => $this->__('None'), - $preparedValues, - ], + 'values' => array_merge( + [SellingFormat::TAX_CATEGORY_MODE_NONE => $this->__('None')], + $preparedValues + ), 'value' => $formData['tax_category_mode'] != SellingFormat::TAX_CATEGORY_MODE_VALUE && $formData['tax_category_mode'] != SellingFormat::TAX_CATEGORY_MODE_ATTRIBUTE ? $formData['tax_category_mode'] : '', + 'create_magento_attribute' => true, ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text'); - $fieldset->addField( - 'tax_category_value', + $fieldset->addField('tax_category_value', 'hidden', [ 'name' => 'selling_format[tax_category_value]', @@ -659,8 +630,7 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'tax_category_attribute', + $fieldset->addField('tax_category_attribute', 'hidden', [ 'name' => 'selling_format[tax_category_attribute]', @@ -669,8 +639,7 @@ protected function _prepareForm() ); } - $fieldset = $form->addFieldset( - 'magento_block_ebay_template_selling_format_edit_form_prices', + $fieldset = $form->addFieldset('magento_block_ebay_template_selling_format_edit_form_prices', [ 'legend' => $this->__('Price'), 'collapsable' => true @@ -678,8 +647,7 @@ protected function _prepareForm() ); $currencyAvailabilityMessage = $this->getCurrencyAvailabilityMessage(); - $fieldset->addField( - 'template_selling_format_messages', + $fieldset->addField('template_selling_format_messages', self::CUSTOM_CONTAINER, [ 'text' => $currencyAvailabilityMessage, @@ -693,21 +661,16 @@ protected function _prepareForm() . ' ' . $this->__('and') . ' ' . end($currencies); - $fieldset->addField( - 'multi_currency_notification', + $fieldset->addField('multi_currency_notification', self::MESSAGES, [ 'messages' => [ [ 'type' => 'notice', 'content' => $this->__( - 'eBay %marketplace_title% supports %currency_code% Currencies. - To switch the Currency you want to sell for, go to %menu_path% > -
    General', + 'eBay %marketplace_title% supports %currency_code% Currencies.', $this->getMarketplace()->getTitle(), - $currencies, - $this->getHelper('View\Ebay')->getPageNavigationPath('configuration'), - $this->getUrl('*/ebay_configuration') + $currencies ) ] ] @@ -715,9 +678,8 @@ protected function _prepareForm() ); } - $fieldset->addField( - 'price_increase_vat_percent', - 'select', + $fieldset->addField('price_increase_vat_percent', + self::SELECT, [ 'label' => $this->__('Add VAT Percentage'), 'name' => 'selling_format[price_increase_vat_percent]', @@ -741,8 +703,7 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'price_table_container', + $fieldset->addField('price_table_container', self::CUSTOM_CONTAINER, [ 'text' => $this->getPriceTableHtml(), @@ -750,17 +711,15 @@ protected function _prepareForm() ] ); - $fieldset = $form->addFieldset( - 'magento_block_ebay_template_selling_format_edit_form_best_offer', + $fieldset = $form->addFieldset('magento_block_ebay_template_selling_format_edit_form_best_offer', [ 'legend' => $this->__('Best Offer'), 'collapsable' => true ] ); - $fieldset->addField( - 'best_offer_mode', - 'select', + $fieldset->addField('best_offer_mode', + self::SELECT, [ 'label' => $this->__('Allow Best Offer'), 'name' => 'selling_format[best_offer_mode]', @@ -818,8 +777,7 @@ protected function _prepareForm() ]; } - $fieldset->addField( - 'best_offer_accept_mode', + $fieldset->addField('best_offer_accept_mode', self::SELECT, [ 'css_class' => 'best_offer_respond_table_container', @@ -838,20 +796,20 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], 'value' => $formData['best_offer_accept_mode'] != SellingFormat::BEST_OFFER_ACCEPT_MODE_ATTRIBUTE ? $formData['best_offer_accept_mode'] : '', + 'create_magento_attribute' => true, 'note' => !is_null($this->getCurrency()) ? $this->__('Currency') . ': ' . $this->getCurrency() : '', 'after_element_html' => '' . $bestOfferAcceptValue->toHtml() . '' ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text,price'); - $fieldset->addField( - 'best_offer_accept_custom_attribute', + $fieldset->addField('best_offer_accept_custom_attribute', 'hidden', [ 'name' => 'selling_format[best_offer_accept_attribute]' @@ -901,8 +859,7 @@ protected function _prepareForm() ]; } - $fieldset->addField( - 'best_offer_reject_mode', + $fieldset->addField('best_offer_reject_mode', self::SELECT, [ 'css_class' => 'best_offer_respond_table_container', @@ -921,20 +878,20 @@ protected function _prepareForm() 'label' => $this->__('Magento Attributes'), 'value' => $preparedAttributes, 'attrs' => [ - 'class' => 'M2ePro-custom-attribute-optgroup' + 'is_magento_attribute' => true ] ] ], 'value' => $formData['best_offer_reject_mode'] != SellingFormat::BEST_OFFER_REJECT_MODE_ATTRIBUTE ? $formData['best_offer_reject_mode'] : '', + 'create_magento_attribute' => true, 'note' => !is_null($this->getCurrency()) ? $this->__('Currency') . ': ' . $this->getCurrency() : '', 'after_element_html' => '' . $bestOfferRejectValue->toHtml() . '' ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text,price'); - $fieldset->addField( - 'best_offer_reject_custom_attribute', + $fieldset->addField('best_offer_reject_custom_attribute', 'hidden', [ 'name' => 'selling_format[best_offer_reject_attribute]' diff --git a/Block/Adminhtml/Ebay/Template/SellingFormat/Messages.php b/Block/Adminhtml/Ebay/Template/SellingFormat/Messages.php deleted file mode 100644 index f548db941..000000000 --- a/Block/Adminhtml/Ebay/Template/SellingFormat/Messages.php +++ /dev/null @@ -1,37 +0,0 @@ -Magento documentation - //$helpText = 'More about Currency rate set-up can be found in the '; - //$helpText .= 'Magento documentation'; - //$helpText = $this->__($helpText, $docUrl); - - return $messageText; - } - - //######################################## -} \ No newline at end of file diff --git a/Block/Adminhtml/Ebay/Template/Shipping/Edit/Form/Data.php b/Block/Adminhtml/Ebay/Template/Shipping/Edit/Form/Data.php index 713e12cc2..69827a57e 100644 --- a/Block/Adminhtml/Ebay/Template/Shipping/Edit/Form/Data.php +++ b/Block/Adminhtml/Ebay/Template/Shipping/Edit/Form/Data.php @@ -6,7 +6,6 @@ class Data extends \Ess\M2ePro\Block\Adminhtml\Magento\Form\AbstractForm { - protected $elementFactory; protected $regionFactory; protected $ebayFactory; @@ -21,7 +20,6 @@ class Data extends \Ess\M2ePro\Block\Adminhtml\Magento\Form\AbstractForm //######################################## public function __construct( - \Magento\Framework\Data\Form\Element\Factory $elementFactory, \Magento\Directory\Model\RegionFactory $regionFactory, \Ess\M2ePro\Model\ActiveRecord\Component\Parent\Ebay\Factory $ebayFactory, \Ess\M2ePro\Block\Adminhtml\Magento\Context\Template $context, @@ -30,7 +28,6 @@ public function __construct( array $data = [] ) { - $this->elementFactory = $elementFactory; $this->regionFactory = $regionFactory; $this->ebayFactory = $ebayFactory; parent::__construct($context, $registry, $formFactory, $data); @@ -71,7 +68,6 @@ public function _construct() protected function _prepareForm() { $form = $this->_formFactory->create(); - $selectElementType = 'Ess\M2ePro\Block\Adminhtml\Magento\Form\Element\Select'; // --------------------------------------- @@ -130,7 +126,7 @@ protected function _prepareForm() ] ); - $fieldSet->addField('country_mode', $selectElementType, + $fieldSet->addField('country_mode', self::SELECT, [ 'name' => 'shipping[country_mode]', 'label' => $this->__('Country'), @@ -143,7 +139,8 @@ function ($attribute) { && $attribute['code'] == $this->formData['country_custom_attribute']; }) ], - 'class' => 'required-entry' + 'class' => 'required-entry', + 'create_magento_attribute' => true ] ); @@ -161,7 +158,7 @@ function ($attribute) { $defaultValue = $this->formData['postal_code_mode']; } - $fieldSet->addField('postal_code_mode', $selectElementType, + $fieldSet->addField('postal_code_mode', self::SELECT, [ 'name' => 'shipping[postal_code_mode]', 'label' => $this->__('Zip/Postal Code'), @@ -177,9 +174,10 @@ function($attribute) { ) ], 'value' => $defaultValue, - 'class' => 'M2ePro-location-or-postal-required M2ePro-required-if-calculated' + 'class' => 'M2ePro-location-or-postal-required M2ePro-required-if-calculated', + 'create_magento_attribute' => true ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text'); $fieldSet->addField('postal_code_custom_value', 'text', [ @@ -207,7 +205,7 @@ function($attribute) { $defaultValue = $this->formData['address_mode']; } - $fieldSet->addField('address_mode', $selectElementType, + $fieldSet->addField('address_mode', self::SELECT, [ 'name' => 'shipping[address_mode]', 'label' => $this->__('City, State'), @@ -224,10 +222,10 @@ function($attribute) { ) ], 'value' => $defaultValue, - 'class' => 'M2ePro-location-or-postal-required - M2ePro-required-if-calculated M2ePro-custom-attribute-can-be-created' + 'class' => 'M2ePro-location-or-postal-required M2ePro-required-if-calculated', + 'create_magento_attribute' => true ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text'); $fieldSet->addField('address_custom_value', 'text', [ @@ -251,7 +249,7 @@ function($attribute) { ['legend' => __('Domestic Shipping'), 'collapsable' => true] ); - $fieldSet->addField('local_shipping_mode', $selectElementType, + $fieldSet->addField('local_shipping_mode', self::SELECT, [ 'name' => 'shipping[local_shipping_mode]', 'label' => $this->__('Type'), @@ -264,7 +262,7 @@ function($attribute) { // --------------------------------------- if ($this->canDisplayLocalShippingRateTable()) { - $fieldSet->addField('local_shipping_rate_table_mode', $selectElementType, + $fieldSet->addField('local_shipping_rate_table_mode', self::SELECT, [ 'name' => 'shipping[local_shipping_rate_table_mode]', 'label' => $this->__('Use eBay Shipping Rate Table'), @@ -287,8 +285,7 @@ function($attribute) { // --------------------------------------- - $fieldSet->addField('local_shipping_methods_tr_wrapper', - self::CUSTOM_CONTAINER, + $fieldSet->addField('local_shipping_methods_tr_wrapper', self::CUSTOM_CONTAINER, [ 'text' => $this->getShippingLocalTable(), 'css_class' => 'm2epro-fieldset-table', @@ -298,7 +295,7 @@ function($attribute) { // --------------------------------------- - $fieldSet->addField('dispatch_time', $selectElementType, + $fieldSet->addField('dispatch_time', self::SELECT, [ 'name' => 'shipping[dispatch_time]', 'label' => $this->__('Dispatch Time'), @@ -320,7 +317,7 @@ function($attribute) { // --------------------------------------- if ($this->canDisplayClickAndCollectOption()) { - $fieldSet->addField('click_and_collect_mode', $selectElementType, + $fieldSet->addField('click_and_collect_mode', self::SELECT, [ 'name' => 'shipping[click_and_collect_mode]', 'label' => $this->__('Click And Collect Opt-out'), @@ -337,7 +334,7 @@ function($attribute) { suits them from over 650 Argos Stores across the UK.
    For more details please read this documentation.' + target="_blank" class="external-link">this documentation.' ) ] ); @@ -370,7 +367,7 @@ function($attribute) { ); $fieldsetCombined->addField('local_shipping_discount_profile_id_'.$this->getAccountId(), - $selectElementType, + self::SELECT, [ 'name' => 'shipping[local_shipping_discount_profile_id]['.$this->getAccountId().']', 'label' => $this->__('Combined Shipping Profile'), @@ -405,7 +402,7 @@ function($attribute) { // --------------------------------------- - $fieldSet->addField('local_shipping_discount_mode', $selectElementType, + $fieldSet->addField('local_shipping_discount_mode', self::SELECT, [ 'name' => 'shipping[local_shipping_discount_mode]', 'label' => $this->__('Promotional Shipping Rule'), @@ -453,7 +450,7 @@ function($attribute) { if ($this->canDisplayNorthAmericaCrossBorderTradeOption() || $this->canDisplayUnitedKingdomCrossBorderTradeOption()) { - $fieldSet->addField('cross_border_trade', $selectElementType, + $fieldSet->addField('cross_border_trade', self::SELECT, [ 'name' => 'shipping[cross_border_trade]', 'label' => $this->__('Cross Border Trade'), @@ -464,7 +461,7 @@ function($attribute) { 'tooltip' => $this->__( 'The international Site visibility feature allows qualifying Listings to be posted on international Marketplaces. -
    Buyers on these MarketplacesF will see the Listings exactly as you originally post them. +
    Buyers on these Marketplaces will see the Listings exactly as you originally post them.

    Note: There may be additional eBay charges for this option.' ) ] @@ -472,7 +469,7 @@ function($attribute) { } if ($this->canDisplayGlobalShippingProgram()) { - $fieldSet->addField('global_shipping_program', $selectElementType, + $fieldSet->addField('global_shipping_program', self::SELECT, [ 'name' => 'shipping[global_shipping_program]', 'label' => $this->__('Offer Global Shipping Program'), @@ -485,7 +482,7 @@ function($attribute) { 'tooltip' => $this->__( 'Simplifies selling an Item to an international Buyer. Click here to find out more. + target="_blank" class="external-link">here to find out more.

    Note: This option is available for eBay Motors only under "Parts & Accessories" Category.' ) @@ -495,7 +492,7 @@ function($attribute) { // --------------------------------------- - $fieldSet->addField('international_shipping_mode', $selectElementType, + $fieldSet->addField('international_shipping_mode', self::SELECT, [ 'name' => 'shipping[international_shipping_mode]', 'label' => $this->__('Type'), @@ -508,7 +505,7 @@ function($attribute) { // --------------------------------------- if ($this->canDisplayInternationalShippingRateTable()) { - $fieldSet->addField('international_shipping_rate_table_mode', $selectElementType, + $fieldSet->addField('international_shipping_rate_table_mode', self::SELECT, [ 'name' => 'shipping[international_shipping_rate_table_mode]', 'label' => $this->__('Use eBay Shipping Rate Table'), @@ -568,7 +565,7 @@ function($attribute) { ); $fieldsetCombined->addField('international_shipping_discount_profile_id_'.$this->getAccountId(), - $selectElementType, + self::SELECT, [ 'name' => 'shipping[international_shipping_discount_profile_id]['.$this->getAccountId().']', 'label' => $this->__('Combined Shipping Profile'), @@ -604,7 +601,7 @@ function($attribute) { // --------------------------------------- - $fieldSet->addField('international_shipping_discount_mode', $selectElementType, + $fieldSet->addField('international_shipping_discount_mode', self::SELECT, [ 'name' => 'shipping[international_shipping_discount_mode]', 'label' => $this->__('Promotional Shipping Rule'), @@ -630,7 +627,7 @@ function($attribute) { ['legend' => __('Package details'), 'collapsable' => true] ); - $fieldSet->addField('measurement_system', $selectElementType, + $fieldSet->addField('measurement_system', self::SELECT, [ 'name' => 'shipping[measurement_system]', 'label' => $this->__('Measurement System'), @@ -666,20 +663,20 @@ function($attribute) { // --------------------------------------- - $fieldSet->addField('package_size', $selectElementType, + $fieldSet->addField('package_size', self::SELECT, [ 'name' => 'shipping[measurement_system]', 'label' => $this->__('Package Size Source'), 'title' => $this->__('Package Size Source'), 'values' => $this->getPackageSizeSourceOptions(), - 'class' => 'M2ePro-custom-attribute-can-be-created', - 'field_extra_attributes' => 'id="package_size_tr"' + 'field_extra_attributes' => 'id="package_size_tr"', + 'create_magento_attribute' => true ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text,select'); // --------------------------------------- - $fieldSet->addField('dimension_mode', $selectElementType, + $fieldSet->addField('dimension_mode', self::SELECT, [ 'name' => 'shipping[dimension_mode]', 'label' => $this->__('Dimension Source'), @@ -712,43 +709,48 @@ function($attribute) { // Dimensions // --------------------------------------- - $heightAttrBlock = $this->elementFactory->create($selectElementType, ['data' => [ + $heightAttrBlock = $this->elementFactory->create(self::SELECT, ['data' => [ + 'html_id' => 'shipping_dimension_length_attribute', 'name' => 'shipping[dimension_length_attribute]', 'values' => $this->getDimensionsOptions('dimension_length_attribute'), 'value' => $this->formData['dimension_length_attribute'], - 'class' => 'M2ePro-required-when-visible M2ePro-custom-attribute-can-be-created', - ]]); + 'class' => 'M2ePro-required-when-visible dimension-custom-input', + 'create_magento_attribute' => true + ]])->addCustomAttribute('allowed_attribute_types', 'text'); $heightAttrBlock->setForm($form); - $depthAttrBlock = $this->elementFactory->create($selectElementType, ['data' => [ + $depthAttrBlock = $this->elementFactory->create(self::SELECT, ['data' => [ + 'html_id' => 'shipping_dimension_depth_attribute', 'name' => 'shipping[dimension_depth_attribute]', 'values' => $this->getDimensionsOptions('dimension_depth_attribute'), 'value' => $this->formData['dimension_depth_attribute'], - 'class' => 'M2ePro-required-when-visible M2ePro-custom-attribute-can-be-created', - ]]); + 'class' => 'M2ePro-required-when-visible dimension-custom-input', + 'create_magento_attribute' => true + ]])->addCustomAttribute('allowed_attribute_types', 'text'); $depthAttrBlock->setForm($form); - $fieldSet->addField('dimension', $selectElementType, + $fieldSet->addField('dimension', self::SELECT, [ 'css_class' => 'dimensions_ca_tr', 'name' => 'shipping[dimension_width_attribute]', 'label' => $this->__('Dimensions (Width×Height×Depth)'), 'values' => $this->getDimensionsOptions('dimension_width_attribute'), 'value' => $this->formData['dimension_width_attribute'], - 'class' => 'M2ePro-required-when-visible M2ePro-custom-attribute-can-be-created', + 'class' => 'M2ePro-required-when-visible dimension-custom-input', 'required' => true, 'note' => $this->__('inches'), + 'create_magento_attribute' => true, 'after_element_html' => ' × ' . $heightAttrBlock->toHtml() . ' × ' . $depthAttrBlock->toHtml() ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text'); $heightValBlock = $this->elementFactory->create('text', ['data' => [ 'name' => 'shipping[dimension_length_value]', 'value' => $this->formData['dimension_length_value'], - 'class' => 'input-text M2ePro-required-when-visible M2ePro-validation-float', + 'class' => 'input-text M2ePro-required-when-visible M2ePro-validation-float dimension-custom-input', 'style' => 'width: 125px;' ]]); $heightValBlock->setForm($form); @@ -756,8 +758,7 @@ function($attribute) { $depthValBlock = $this->elementFactory->create('text', ['data' => [ 'name' => 'shipping[dimension_depth_value]', 'value' => $this->formData['dimension_depth_value'], - 'class' => 'input-text M2ePro-required-when-visible M2ePro-validation-float', - 'style' => 'width: 125px;' + 'class' => 'input-text M2ePro-required-when-visible M2ePro-validation-float dimension-custom-input', ]]); $depthValBlock->setForm($form); @@ -767,8 +768,7 @@ function($attribute) { 'name' => 'shipping[dimension_width_value]', 'label' => $this->__('Dimensions (Width×Height×Depth)'), 'value' => $this->formData['dimension_width_value'], - 'class' => 'input-text M2ePro-required-when-visible M2ePro-validation-float', - 'style' => 'width: 125px;', + 'class' => 'input-text M2ePro-required-when-visible M2ePro-validation-float dimension-custom-input', 'required' => true, 'note' => $this->__('inches'), 'after_element_html' => ' × ' @@ -796,19 +796,21 @@ function($attribute) { // --------------------------------------- - $fieldSet->addField('weight', $selectElementType, + $fieldSet->addField('weight', self::SELECT, [ 'name' => 'shipping[test]', 'label' => $this->__('Weight Source'), 'title' => $this->__('Weight Source'), 'values' => $this->getWeightSourceOptions(), - 'value' => $this->formData['weight_mode'], - 'class' => 'select M2ePro-custom-attribute-can-be-created', + 'value' => $this->formData['weight_mode'] != Shipping\Calculated::WEIGHT_CUSTOM_ATTRIBUTE + ? $this->formData['weight_mode'] : '', + 'class' => 'select', 'field_extra_attributes' => 'id="weight_tr"', 'tooltip' => $this->__('The Weight Attribute must have the weight of the Item.'), 'note' => $this->__('lbs. oz.'), + 'create_magento_attribute' => true ] - ); + )->addCustomAttribute('allowed_attribute_types', 'text'); $weightMinorBlock = $this->elementFactory->create('text', ['data' => [ 'name' => 'shipping[weight_minor]', @@ -1084,7 +1086,11 @@ class="shipping-discount-profile-table data-grid data-grid-not-hovered data-grid public function getAttributesOptions($attributeValue, $conditionCallback = false) { - $options = ['value' => [], 'label' => $this->__('Magento Attribute')]; + $options = [ + 'value' => [], + 'label' => $this->__('Magento Attribute'), + 'attrs' => ['is_magento_attribute' => true] + ]; $helper = $this->getHelper('Data'); foreach ($this->attributes as $attribute) { @@ -1291,7 +1297,11 @@ public function getPackageSizeSourceOptions() $ebayValues['value'][] = $tmp; } - $attributesOptions = ['value' => [], 'label' => $this->__('Magento Attributes')]; + $attributesOptions = [ + 'value' => [], + 'label' => $this->__('Magento Attributes'), + 'attrs' => ['is_magento_attribute' => true] + ]; if (isset($this->missingAttributes['package_size_attribute'])) { $attributesOptions['value'][] = [ 'value' => Shipping\Calculated::PACKAGE_SIZE_CUSTOM_ATTRIBUTE, @@ -1359,24 +1369,41 @@ public function getWeightSourceOptions() 'value' => Shipping\Calculated::WEIGHT_CUSTOM_VALUE, 'label' => $this->__('Custom Value') ], - 'option_group' => ['value' => [], 'label' => $this->__('Magento Attributes')] + 'option_group' => [ + 'value' => [], + 'label' => $this->__('Magento Attributes'), + 'attrs' => ['is_magento_attribute' => true] + ] ]; $helper = $this->getHelper('Data'); - if (isset($missingAttributes['weight_attribute'])) { - $options['option_group']['value'][] = [ + if (isset($this->missingAttributes['weight_attribute'])) { + $tmpOption = [ 'value' => Shipping\Calculated::WEIGHT_CUSTOM_ATTRIBUTE, - 'label' => $helper->escapeHtml($missingAttributes['weight_attribute']), + 'label' => $helper->escapeHtml($this->missingAttributes['weight_attribute']), 'attrs' => ['attribute_code' => $this->formData['weight_attribute']] ]; + + if ($this->formData['weight_mode'] == Shipping\Calculated::WEIGHT_CUSTOM_ATTRIBUTE) { + $tmpOption['attrs']['selected'] = 'selected'; + } + + $options['option_group']['value'][] = $tmpOption; } foreach ($this->attributesByInputTypes['text_weight'] as $attribute) { - $options['option_group']['value'][] = [ + $tmpOption = [ 'value' => Shipping\Calculated::WEIGHT_CUSTOM_ATTRIBUTE, 'label' => $helper->escapeHtml($attribute['label']), 'attrs' => ['attribute_code' => $attribute['code']] ]; + + if ($this->formData['weight_mode'] == Shipping\Calculated::WEIGHT_CUSTOM_ATTRIBUTE + && $this->formData['weight_attribute'] == $attribute['code']) { + $tmpOption['attrs']['selected'] = 'selected'; + } + + $options['option_group']['value'][] = $tmpOption; } return $options; @@ -1597,12 +1624,8 @@ public function getMarketplaceData() $policyLocalization = $this->getData('policy_localization'); if (!empty($policyLocalization)) { - /** @var \Ess\M2ePro\Model\Magento\Translate $translator */ - //TODO -// $translator = Mage::getModel('M2ePro/Magento_Translate'); + $translator = $this->getHelper('Module\Translation'); -// $translator->setLocale($policyLocalization); -// $translator->init(); foreach ($data['services'] as $serviceKey => $service) { $data['services'][$serviceKey]['title'] = $translator->__($service['title']); diff --git a/Block/Adminhtml/Ebay/Template/Switcher.php b/Block/Adminhtml/Ebay/Template/Switcher.php index 6afd4cd04..83913483c 100644 --- a/Block/Adminhtml/Ebay/Template/Switcher.php +++ b/Block/Adminhtml/Ebay/Template/Switcher.php @@ -82,50 +82,6 @@ public function getHeaderWidth() //######################################## - public static function getSwitcherUrlHtml() - { - //TODO - $params = array(); - - // initiate account param - // --------------------------------------- - $account = Mage::helper('M2ePro/Data\Global')->getValue('ebay_account'); - $params['account_id'] = $account->getId(); - // --------------------------------------- - - // initiate marketplace param - // --------------------------------------- - $marketplace = Mage::helper('M2ePro/Data\Global')->getValue('ebay_marketplace'); - $params['marketplace_id'] = $marketplace->getId(); - // --------------------------------------- - - // initiate attribute sets param - // --------------------------------------- - $attributeSets = Mage::helper('M2ePro/Data\Global')->getValue('ebay_attribute_sets'); - $params['attribute_sets'] = implode(',', $attributeSets); - // --------------------------------------- - - // initiate display use default option param - // --------------------------------------- - $displayUseDefaultOption = Mage::helper('M2ePro/Data\Global')->getValue('ebay_display_use_default_option'); - $params['display_use_default_option'] = (int)(bool)$displayUseDefaultOption; - // --------------------------------------- - - $url = Mage::helper('adminhtml')->getUrl('M2ePro/adminhtml_ebay_template/getTemplateHtml', $params); - - $urls = json_encode(array( - 'adminhtml_ebay_template/getTemplateHtml' => $url - )); - - return << - M2ePro.url.add({$urls}); - -HTML; - } - - //######################################## - public function getTemplateNick() { if (!isset($this->_data['template_nick'])) { diff --git a/Block/Adminhtml/Ebay/Template/Synchronization/Edit/Form/Tabs/ListRules.php b/Block/Adminhtml/Ebay/Template/Synchronization/Edit/Form/Tabs/ListRules.php index 22ecdb4b9..06f955a35 100644 --- a/Block/Adminhtml/Ebay/Template/Synchronization/Edit/Form/Tabs/ListRules.php +++ b/Block/Adminhtml/Ebay/Template/Synchronization/Edit/Form/Tabs/ListRules.php @@ -55,10 +55,10 @@ protected function _prepareForm() Otherwise, Synchronization Policy Rules will not take effect.


    More detailed information about how to work with this Page you can find - here.

    + here.

    HTML , - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/PQItAQ') + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/PQItAQ') ) ] ); @@ -71,7 +71,7 @@ protected function _prepareForm() ); $fieldset->addField('list_mode', - 'select', + self::SELECT, [ 'name' => 'synchronization[list_mode]', 'label' => $this->__('List Action'), @@ -91,7 +91,7 @@ protected function _prepareForm() ); $fieldset->addField('list_status_enabled', - 'select', + self::SELECT, [ 'name' => 'synchronization[list_status_enabled]', 'label' => $this->__('Product Status'), @@ -109,7 +109,7 @@ protected function _prepareForm() ); $fieldset->addField('list_is_in_stock', - 'select', + self::SELECT, [ 'name' => 'synchronization[list_is_in_stock]', 'label' => $this->__('Stock Availability'), @@ -126,7 +126,7 @@ protected function _prepareForm() ); $fieldset->addField('list_qty_magento', - 'select', + self::SELECT, [ 'name' => 'synchronization[list_qty_magento]', 'label' => $this->__('Magento Quantity'), @@ -171,7 +171,7 @@ protected function _prepareForm() ); $fieldset->addField('list_qty_calculated', - 'select', + self::SELECT, [ 'name' => 'synchronization[list_qty_calculated]', 'label' => $this->__('Calculated Quantity'), diff --git a/Block/Adminhtml/Ebay/Template/Synchronization/Edit/Form/Tabs/RelistRules.php b/Block/Adminhtml/Ebay/Template/Synchronization/Edit/Form/Tabs/RelistRules.php index e6d84a688..4542b8528 100644 --- a/Block/Adminhtml/Ebay/Template/Synchronization/Edit/Form/Tabs/RelistRules.php +++ b/Block/Adminhtml/Ebay/Template/Synchronization/Edit/Form/Tabs/RelistRules.php @@ -30,10 +30,10 @@ protected function _prepareForm() Stock Availability or Quantity in Magento.


    More detailed information about how to work with this Page you can find - here.

    + here.

    HTML , - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/QQItAQ') + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/QQItAQ') ) ] ); @@ -46,7 +46,7 @@ protected function _prepareForm() ); $fieldset->addField('relist_mode', - 'select', + self::SELECT, [ 'name' => 'synchronization[relist_mode]', 'label' => $this->__('Relist Action'), @@ -63,7 +63,7 @@ protected function _prepareForm() ); $fieldset->addField('relist_filter_user_lock', - 'select', + self::SELECT, [ 'container_id' => 'relist_filter_user_lock_tr_container', 'name' => 'synchronization[relist_filter_user_lock]', @@ -81,7 +81,7 @@ protected function _prepareForm() ); $fieldset->addField('relist_send_data', - 'select', + self::SELECT, [ 'container_id' => 'relist_send_data_tr_container', 'name' => 'synchronization[relist_send_data]', @@ -125,7 +125,7 @@ protected function _prepareForm() ); $fieldset->addField('relist_status_enabled', - 'select', + self::SELECT, [ 'name' => 'synchronization[relist_status_enabled]', 'label' => $this->__('Product Status'), @@ -145,7 +145,7 @@ protected function _prepareForm() ); $fieldset->addField('relist_is_in_stock', - 'select', + self::SELECT, [ 'name' => 'synchronization[relist_is_in_stock]', 'label' => $this->__('Stock Availability'), @@ -164,7 +164,7 @@ protected function _prepareForm() ); $fieldset->addField('relist_qty_magento', - 'select', + self::SELECT, [ 'name' => 'synchronization[relist_qty_magento]', 'label' => $this->__('Magento Quantity'), @@ -210,7 +210,7 @@ protected function _prepareForm() ); $fieldset->addField('relist_qty_calculated', - 'select', + self::SELECT, [ 'name' => 'synchronization[relist_qty_calculated]', 'label' => $this->__('Calculated Quantity'), diff --git a/Block/Adminhtml/Ebay/Template/Synchronization/Edit/Form/Tabs/ReviseRules.php b/Block/Adminhtml/Ebay/Template/Synchronization/Edit/Form/Tabs/ReviseRules.php index f6fd27678..eedf13742 100644 --- a/Block/Adminhtml/Ebay/Template/Synchronization/Edit/Form/Tabs/ReviseRules.php +++ b/Block/Adminhtml/Ebay/Template/Synchronization/Edit/Form/Tabs/ReviseRules.php @@ -27,8 +27,8 @@ protected function _prepareForm() If Conditions here are met, eBay Items will be updated in full, with all data being sent to eBay.

    More detailed information about ability to work with this Page you can find - here.', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/PwItAQ') + here.', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/PwItAQ') ) ] ); @@ -41,7 +41,7 @@ protected function _prepareForm() ); $fieldset->addField('revise_update_qty', - 'select', + self::SELECT, [ 'name' => 'synchronization[revise_update_qty]', 'label' => $this->__('Quantity'), @@ -58,7 +58,7 @@ protected function _prepareForm() ); $fieldset->addField('revise_update_qty_max_applied_value_mode', - 'select', + self::SELECT, [ 'container_id' => 'revise_update_qty_max_applied_value_mode_tr', 'name' => 'synchronization[revise_update_qty_max_applied_value_mode]', @@ -96,7 +96,7 @@ protected function _prepareForm() ); $fieldset->addField('revise_update_price', - 'select', + self::SELECT, [ 'name' => 'synchronization[revise_update_price]', 'label' => $this->__('Price'), @@ -113,7 +113,7 @@ protected function _prepareForm() ); $fieldset->addField('revise_update_price_max_allowed_deviation_mode', - 'select', + self::SELECT, [ 'container_id' => 'revise_update_price_max_allowed_deviation_mode_tr', 'name' => 'synchronization[revise_update_price_max_allowed_deviation_mode]', @@ -138,7 +138,7 @@ protected function _prepareForm() } $fieldset->addField('revise_update_price_max_allowed_deviation', - 'select', + self::SELECT, [ 'container_id' => 'revise_update_price_max_allowed_deviation_tr', 'name' => 'synchronization[revise_update_price_max_allowed_deviation]', @@ -169,7 +169,7 @@ protected function _prepareForm() ); $fieldset->addField('revise_update_title', - 'select', + self::SELECT, [ 'name' => 'synchronization[revise_update_title]', 'label' => $this->__('Title'), @@ -186,7 +186,7 @@ protected function _prepareForm() ); $fieldset->addField('revise_update_sub_title', - 'select', + self::SELECT, [ 'name' => 'synchronization[revise_update_sub_title]', 'label' => $this->__('Subtitle'), @@ -203,7 +203,7 @@ protected function _prepareForm() ); $fieldset->addField('revise_update_description', - 'select', + self::SELECT, [ 'name' => 'synchronization[revise_update_description]', 'label' => $this->__('Description'), @@ -220,7 +220,7 @@ protected function _prepareForm() ); $fieldset->addField('revise_update_images', - 'select', + self::SELECT, [ 'name' => 'synchronization[revise_update_images]', 'label' => $this->__('Images'), @@ -244,7 +244,7 @@ protected function _prepareForm() ); $fieldset->addField('revise_change_selling_format_template', - 'select', + self::SELECT, [ 'name' => 'synchronization[revise_change_selling_format_template]', 'label' => $this->__('Price, Quantity and Format'), @@ -263,7 +263,7 @@ protected function _prepareForm() ); $fieldset->addField('revise_change_description_template', - 'select', + self::SELECT, [ 'name' => 'synchronization[revise_change_description_template]', 'label' => $this->__('Description'), @@ -280,7 +280,7 @@ protected function _prepareForm() ); $fieldset->addField('revise_change_category_template', - 'select', + self::SELECT, [ 'name' => 'synchronization[revise_change_category_template]', 'label' => $this->__('Category/Specifics'), @@ -297,7 +297,7 @@ protected function _prepareForm() ); $fieldset->addField('revise_change_payment_template', - 'select', + self::SELECT, [ 'name' => 'synchronization[revise_change_payment_template]', 'label' => $this->__('Payment'), @@ -314,7 +314,7 @@ protected function _prepareForm() ); $fieldset->addField('revise_change_shipping_template', - 'select', + self::SELECT, [ 'name' => 'synchronization[revise_change_shipping_template]', 'label' => $this->__('Shipping'), @@ -331,7 +331,7 @@ protected function _prepareForm() ); $fieldset->addField('revise_change_return_policy_template', - 'select', + self::SELECT, [ 'name' => 'synchronization[revise_change_return_policy_template]', 'label' => $this->__('Return'), diff --git a/Block/Adminhtml/Ebay/Template/Synchronization/Edit/Form/Tabs/StopRules.php b/Block/Adminhtml/Ebay/Template/Synchronization/Edit/Form/Tabs/StopRules.php index 597e20dbd..b27f8a54e 100644 --- a/Block/Adminhtml/Ebay/Template/Synchronization/Edit/Form/Tabs/StopRules.php +++ b/Block/Adminhtml/Ebay/Template/Synchronization/Edit/Form/Tabs/StopRules.php @@ -26,8 +26,8 @@ protected function _prepareForm() If all Options are enabled, then an Item will be Stopped if at least one of the Stop Conditions is met.

    More detailed information about ability to work with this Page you can find - here.', - $this->getHelper('Module\Support')->getDocumentationUrl(NULL, NULL, 'x/QwItAQ') + here.', + $this->getHelper('Module\Support')->getDocumentationArticleUrl('x/QwItAQ') ) ] ); @@ -58,7 +58,7 @@ protected function _prepareForm() ); $fieldset->addField('stop_status_disabled', - 'select', + self::SELECT, [ 'name' => 'synchronization[stop_status_disabled]', 'label' => $this->__('Stop When Status Disabled'), @@ -74,7 +74,7 @@ protected function _prepareForm() ); $fieldset->addField('stop_out_off_stock', - 'select', + self::SELECT, [ 'name' => 'synchronization[stop_out_off_stock]', 'label' => $this->__('Stop When Out Of Stock'), @@ -91,7 +91,7 @@ protected function _prepareForm() ); $fieldset->addField('stop_qty_magento', - 'select', + self::SELECT, [ 'name' => 'synchronization[stop_qty_magento]', 'label' => $this->__('Stop When Magento Quantity Is'), @@ -133,7 +133,7 @@ protected function _prepareForm() ); $fieldset->addField('stop_qty_calculated', - 'select', + self::SELECT, [ 'name' => 'synchronization[stop_qty_calculated]', 'label' => $this->__('Stop When Calculated Quantity Is'), diff --git a/Block/Adminhtml/General.php b/Block/Adminhtml/General.php index 9f2e07263..fa9f98698 100644 --- a/Block/Adminhtml/General.php +++ b/Block/Adminhtml/General.php @@ -13,7 +13,7 @@ class General extends Magento\AbstractBlock protected function _prepareLayout() { if ($this->getIsAjax()) { - return parent::_beforeToHtml(); + return parent::_prepareLayout(); } $this->jsUrl->addUrls($this->getHelper('Data')->getControllerActions('General')); @@ -24,6 +24,12 @@ protected function _prepareLayout() $this->css->addFile('style.css'); $this->css->addFile('grid.css'); + $currentView = $this->getHelper('View')->getCurrentView(); + + if (!empty($currentView)) { + $this->css->addFile($currentView.'/style.css'); + } + return parent::_prepareLayout(); } @@ -34,7 +40,8 @@ protected function _beforeToHtml() } $this->jsUrl->addUrls([ - 'm2epro_skin_url' => $this->getViewFileUrl('Ess_M2ePro') + 'm2epro_skin_url' => $this->getViewFileUrl('Ess_M2ePro'), + 'general/getCreateAttributeHtmlPopup' => $this->getUrl('*/general/getCreateAttributeHtmlPopup') ]); $this->block_notices_show = $this->getHelper('Module') @@ -59,6 +66,7 @@ protected function _beforeToHtml() 'None' => $this->__('None'), 'Add' => $this->__('Add'), 'Save' => $this->__('Save'), + 'Send' => $this->__('Send'), 'Cancel' => $this->__('Cancel'), 'Reset' => $this->__('Reset'), 'Confirm' => $this->__('Confirm'), @@ -69,6 +77,11 @@ protected function _beforeToHtml() 'Yes' => $this->__('Yes'), 'No' => $this->__('No'), + 'Collapse' => $this->__('Collapse'), + 'Expand' => $this->__('Expand'), + + 'Reset Auto Rules' => $this->__('Reset Auto Rules'), + 'Please select the Products you want to perform the Action on.' => $this->__( 'Please select the Products you want to perform the Action on.' ), @@ -92,7 +105,8 @@ protected function _beforeToHtml() 'You should select Store View' => $this->__('You should select Store View'), 'Insert Magento Attribute in %s%' => $this->__('Insert Magento Attribute in %s%'), - 'Magento Attribute' => $this->__('Magento Attribute'), + 'Attribute' => $this->__('Attribute'), + 'Insert' => $this->__('Insert'), ]); return parent::_beforeToHtml(); diff --git a/Block/Adminhtml/General/CreateAttribute.php b/Block/Adminhtml/General/CreateAttribute.php new file mode 100644 index 000000000..35a4e27c8 --- /dev/null +++ b/Block/Adminhtml/General/CreateAttribute.php @@ -0,0 +1,30 @@ +_controller = 'adminhtml_general'; + $this->_mode = 'createAttribute'; + + // Initialization block + // --------------------------------------- + $this->setId('generalCreateAttribute'); + // --------------------------------------- + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/General/CreateAttribute/Form.php b/Block/Adminhtml/General/CreateAttribute/Form.php new file mode 100644 index 000000000..2ef0c2b25 --- /dev/null +++ b/Block/Adminhtml/General/CreateAttribute/Form.php @@ -0,0 +1,276 @@ +handlerId($this->getParentBlock()->getData('handler_id')); + $this->allowedTypes($this->getParentBlock()->getData('allowed_types')); + $this->applyToAll($this->getParentBlock()->getData('apply_to_all')); + + $form = $this->_formFactory->create(['data' => [ + 'id' => 'edit_form' + ]]); + + $form->addField('create_attribute_help_block', + self::HELP_BLOCK, + [ + 'content' => $this->__(' + This Tool allows you to quickly Create a new Magento Attribute + for the selected Option. In order to Create an Attribute, you have to fill in the Attribute Label, + Attribute Code, Catalog Input Type, Scope, Default Value and Attribute Sets fields.

    + + Note: Some of the fields may not be available for selection. The availability + depends on the Option for which the Attribute is being created.
    + Note: This Option does not imply automatic Product Attribute Value set up. + After the Attribute + becomes available in Magento, you should Manually provide the Value for the Product.' + ) + ] + ); + + $fieldset = $form->addFieldset('magento_create_custom_attribute', [ + 'legend' => ' ', 'collapsable' => false + ]); + + $fieldset->addField('store_label', + 'text', + [ + 'name' => 'store_label', + 'label' => $this->__('Default Label'), + 'required' => true + ] + ); + + $fieldset->addField('code', + 'text', + [ + 'name' => 'code', + 'label' => $this->__('Attribute Code'), + 'class' => 'validate-length maximum-length-30 M2ePro-validate-attribute-code + M2ePro-validate-attribute-code-to-be-unique', + 'required' => true + ] + ); + + $inputTypes = []; + foreach ($this->allowedTypes() as $type) { + $inputTypes[] = [ + 'value' => $type, + 'label' => $this->getTitleByType($type) + ]; + } + + $fieldset->addField('input_type_select', + self::SELECT, + [ + 'name' => 'input_type', + 'label' => $this->__('Catalog Input Type'), + 'values' => $inputTypes, + 'value' => '', + 'disabled' => $this->isOneOnlyTypeAllowed() + ] + ); + + if ($this->isOneOnlyTypeAllowed()) { + $fieldset->addField('input_type', + 'hidden', + [ + 'name' => 'input_type', + 'value' => $this->allowedTypes()[0] + ] + ); + } + + $fieldset->addField('scope', + self::SELECT, + [ + 'name' => 'scope', + 'label' => $this->__('Scope'), + 'values' => [ + ['value' => AttributeBuilder::SCOPE_STORE, + 'label' => $this->__('Store View')], + ['value' => AttributeBuilder::SCOPE_WEBSITE, + 'label' => $this->__('Website')], + ['value' => AttributeBuilder::SCOPE_GLOBAL, + 'label' => $this->__('Global')], + + ], + 'value' => '' + ] + ); + + $fieldset->addField('default_value', + 'text', + [ + 'name' => 'default_value', + 'label' => $this->__('Default Value') + ] + ); + + $attributeSets = []; + $values = []; + foreach($this->getHelper('Magento\AttributeSet')->getAll() as $item) { + $attributeSets[] = [ + 'value' => $item['attribute_set_id'], + 'label' => $item['attribute_set_name'] + ]; + $values[] = $item['attribute_set_id']; + } + + $fieldset->addField('attribute_sets_multiselect', + 'multiselect', + [ + 'name' => 'attribute_sets[]', + 'label' => $this->__('Attribute Sets'), + 'values' => $attributeSets, + 'value' => $values, + 'required' => true, + 'field_extra_attributes' => $this->applyToAll() ? 'style="display: none;"' : '' + ] + ); + + if ($this->applyToAll()) { + $fieldset->addField('attribute_sets_multiselect_note', + 'note', + [ + 'label' => $this->__('Attribute Sets'), + 'text' => ''. $this->__('Will be added to the all Attribute Sets.') + . '' + ] + ); + } + + $form->setUseContainer(true); + $this->setForm($form); + return $this; + } + + //######################################## + + protected function _toHtml() + { + $this->jsTranslator->addTranslations([ + 'Invalid attribute code' => $this->__( + 'Please use only letters (a-z), + numbers (0-9) or underscore(_) in this field, first character should be a letter.' + ), + 'Attribute with the same code already exists' => $this->__('Attribute with the same code already exists.'), + 'Attribute has been created.' => $this->__('Attribute has been created.'), + 'Please enter a valid date.' => $this->__('Please enter a valid date.'), + ]); + + $this->jsPhp->addConstants( + $this->getHelper('Data')->getClassConstants('\Ess\M2ePro\Model\Magento\Attribute\Builder') + ); + + $this->jsUrl->addUrls([ + 'general/generateAttributeCodeByLabel' => $this->getUrl('general/generateAttributeCodeByLabel'), + 'general/isAttributeCodeUnique' => $this->getUrl('general/isAttributeCodeUnique'), + 'general/createAttribute' => $this->getUrl('general/createAttribute'), + ]); + + $this->js->addRequireJs(['jQuery' => 'jquery'], <<handlerId()}']; + + jQuery.validator.addMethod('M2ePro-validate-attribute-code', function(value, element) { + return handler.validateAttributeCode(value, element); + }, M2ePro.translator.translate('Invalid attribute code')); + + jQuery.validator.addMethod('M2ePro-validate-attribute-code-to-be-unique', function(value, element) { + return handler.validateAttributeCodeToBeUnique(value, element); + }, M2ePro.translator.translate('Attribute with the same code already exists')); +JS +); + + return parent::_toHtml(); + } + + //######################################## + + public function handlerId($value = null) + { + if (is_null($value)) { + return $this->handlerId; + } + + $this->handlerId = $value; + return $this->handlerId; + } + + public function applyToAll($value = null) + { + if (is_null($value)) { + return $this->applyToAllAttributeSets; + } + + $this->applyToAllAttributeSets = $value; + return $this->applyToAllAttributeSets; + } + + public function allowedTypes($value = null) + { + if (is_null($value)) { + return count($this->allowedTypes) ? $this->allowedTypes : $this->getAllAvailableTypes(); + } + + $this->allowedTypes = $value; + return $this->allowedTypes; + } + + // --------------------------------------- + + public function getTitleByType($type) + { + $titles = array( + AttributeBuilder::TYPE_TEXT => $this->__('Text Field'), + AttributeBuilder::TYPE_TEXTAREA => $this->__('Text Area'), + AttributeBuilder::TYPE_PRICE => $this->__('Price'), + AttributeBuilder::TYPE_SELECT => $this->__('Select'), + AttributeBuilder::TYPE_MULTIPLE_SELECT => $this->__('Multiple Select'), + AttributeBuilder::TYPE_DATE => $this->__('Date'), + AttributeBuilder::TYPE_BOOLEAN => $this->__('Yes/No') + ); + + return isset($titles[$type]) ? $titles[$type] : $this->__('N/A'); + } + + public function getAllAvailableTypes() + { + return array( + AttributeBuilder::TYPE_TEXT, + AttributeBuilder::TYPE_TEXTAREA, + AttributeBuilder::TYPE_PRICE, + AttributeBuilder::TYPE_SELECT, + AttributeBuilder::TYPE_MULTIPLE_SELECT, + AttributeBuilder::TYPE_DATE, + AttributeBuilder::TYPE_BOOLEAN + ); + } + + public function isOneOnlyTypeAllowed() + { + return count($this->allowedTypes()) == 1; + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/Listing/AutoAction/Mode.php b/Block/Adminhtml/Listing/AutoAction/Mode.php index bd74d7f79..dae9260da 100644 --- a/Block/Adminhtml/Listing/AutoAction/Mode.php +++ b/Block/Adminhtml/Listing/AutoAction/Mode.php @@ -85,7 +85,8 @@ protected function getHelpBlock()

    You can always modify the add/remove settings by clicking on Edit Settings > Auto Add/Remove Rules button in your M2E Pro Listing.

    -

    More detailed information you can find here.

    ', +

    More detailed information you can find + here.

    ', $this->getHelpPageUrl() ) ]); diff --git a/Block/Adminhtml/Listing/Edit.php b/Block/Adminhtml/Listing/Edit.php index dfc21f8a4..be7429f45 100644 --- a/Block/Adminhtml/Listing/Edit.php +++ b/Block/Adminhtml/Listing/Edit.php @@ -1,9 +1,9 @@ $this->__('Creation Date'), 'align' => 'left', 'type' => 'datetime', + 'filter_time' => true, 'index' => 'create_date' )); diff --git a/Block/Adminhtml/Listing/Moving/FailedProducts.php b/Block/Adminhtml/Listing/Moving/FailedProducts.php index 9c975f4ea..b78b917e3 100644 --- a/Block/Adminhtml/Listing/Moving/FailedProducts.php +++ b/Block/Adminhtml/Listing/Moving/FailedProducts.php @@ -16,33 +16,13 @@ class FailedProducts extends \Ess\M2ePro\Block\Adminhtml\Magento\AbstractContain protected function _beforeToHtml() { - // --------------------------------------- - $data = array( - 'id' => 'failedProducts_continue_button', - 'label' => $this->__('Continue'), - 'class' => 'submit' - ); - $buttonBlock = $this->createBlock('Magento\Button')->setData($data); - $this->setChild('failedProducts_continue_button',$buttonBlock); - // --------------------------------------- - - // --------------------------------------- - $data = array( - 'id' => 'failedProducts_back_button', - 'label' => $this->__('Back'), - 'class' => 'scalable back', - ); - $buttonBlock = $this->createBlock('Magento\Button')->setData($data); - $this->setChild('failedProducts_back_button',$buttonBlock); - // --------------------------------------- - // --------------------------------------- $this->setChild( 'failedProducts_grid', $this->createBlock( 'Listing\Moving\FailedProducts\Grid','', - array('grid_url' => $this->getData('grid_url')) + ['data' => ['grid_url' => $this->getData('grid_url')]] ) ); // --------------------------------------- diff --git a/Block/Adminhtml/Listing/Moving/Grid.php b/Block/Adminhtml/Listing/Moving/Grid.php index e4314c4b0..c2cc7d0d9 100644 --- a/Block/Adminhtml/Listing/Moving/Grid.php +++ b/Block/Adminhtml/Listing/Moving/Grid.php @@ -226,9 +226,22 @@ protected function getHelpBlockHtml() return $helpBlockHtml; } + protected function getNewListingUrl() + { + $newListingUrl = $this->getUrl('*/amazon_listing_create/index', array( + 'step' => 1, + 'clear' => 1, + 'account_id' => $this->getHelper('Data\GlobalData')->getValue('accountId'), + 'marketplace_id' => $this->getHelper('Data\GlobalData')->getValue('marketplaceId'), + 'creation_mode' => \Ess\M2ePro\Helper\View::LISTING_CREATION_MODE_LISTING_ONLY, + )); + + return $newListingUrl; + } + protected function _toHtml() { - $buttonBlockHtml = ($this->canDisplayContainer()) ? $this->getNewListingBtnHtml(): ''; + $this->jsUrl->add($this->getNewListingUrl(), 'add_new_listing_url'); $this->js->add(<<getHelpBlockHtml() . parent::_toHtml() . $buttonBlockHtml; + return $this->getHelpBlockHtml() . parent::_toHtml(); } //######################################## @@ -271,33 +284,4 @@ protected function addAccountAndMarketplaceFilter($collection) } //######################################## - - protected function getNewListingBtnHtml() - { - $componentMode = $this->getHelper('Data\GlobalData')->getValue('componentMode'); - - // --------------------------------------- - $newListingUrl = $this->getUrl('*/amazon_listing_create/index', array( - 'step' => 1, - 'clear' => 1, - 'account_id' => $this->getHelper('Data\GlobalData')->getValue('accountId'), - 'marketplace_id' => $this->getHelper('Data\GlobalData')->getValue('marketplaceId'), - 'creation_mode' => \Ess\M2ePro\Helper\View::LISTING_CREATION_MODE_LISTING_ONLY, - 'component' => $componentMode - )); - - $data = array( - 'id' => 'listingProductMoving_addNew_listing_button', - 'label' => $this->__('Add New Listing'), - 'style' => 'float: right;', - 'class' => 'primary', - 'onclick' => $this->getData('moving_handler_js') . '.startListingCreation(\''.$newListingUrl.'\')' - ); - $buttonBlock = $this->createBlock('Magento\Button')->setData($data); - // --------------------------------------- - - return $buttonBlock->toHtml(); - } - - //######################################## } \ No newline at end of file diff --git a/Block/Adminhtml/Listing/Other/Log/Grid.php b/Block/Adminhtml/Listing/Other/Log/Grid.php index 86dfc212c..45921670a 100644 --- a/Block/Adminhtml/Listing/Other/Log/Grid.php +++ b/Block/Adminhtml/Listing/Other/Log/Grid.php @@ -126,6 +126,7 @@ protected function _prepareColumns() 'header' => $columnTitles['create_date'], 'align' => 'left', 'type' => 'datetime', + 'filter_time' => true, // 'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM), 'width' => '150px', 'index' => 'create_date', @@ -228,12 +229,6 @@ public function callbackColumnIdentifier($value, $row, $column, $isExport) $url = $this->getHelper('Component\Amazon')->getItemUrl($value, $marketplaceId); $identifier = '' . $value . ''; break; - -// todo NOT SUPPORTED FEATURES -// case \Ess\M2ePro\Helper\Component\Buy::NICK: -// $url = Mage::helper('M2ePro/Component_Buy')->getItemUrl($value); -// $identifier = '' . $value . ''; -// break; } return $identifier; diff --git a/Block/Adminhtml/Listing/Product/Rule.php b/Block/Adminhtml/Listing/Product/Rule.php new file mode 100644 index 000000000..148ec7dc5 --- /dev/null +++ b/Block/Adminhtml/Listing/Product/Rule.php @@ -0,0 +1,134 @@ +setId('listingProductRule'); + // --------------------------------------- + } + + //######################################## + + public function setShowHideProductsOption($isShow = true) + { + $this->_isShowHideProductsOption = $isShow; + return $this; + } + + public function isShowHideProductsOption() + { + return $this->_isShowHideProductsOption; + } + + //######################################## + + protected function _prepareLayout() + { + $this->css->add(<< legend.legend { + border-bottom: none !important; + margin-bottom: 5px !important; + } + + .advanced-filter-fieldset .field-advanced_filter { + margin-bottom: 1.5em !important; + float: left; + min-width: 50%; + } + + .advanced-filter-fieldset .rule-param .label { + font-size: 14px; + font-weight: 600; + } + + .advanced-filter-fieldset ul.rule-param-children { + margin-top: 1em; + } +CSS +); + + return parent::_prepareLayout(); + } + + //######################################## + + protected function _prepareForm() + { + $form = $this->_formFactory->create([ + 'data' => [ + 'id' => 'rule_form', + 'action' => 'javascript:void(0)', + 'method' => 'post', + 'enctype' => 'multipart/form-data', + 'onsubmit' => $this->getGridJsObjectName() . '.doFilter(event)' + ] + ]); + + $fieldset = $form->addFieldset('listing_product_rules', + [ + 'legend' => '', + 'collapsable' => false, + 'class' => 'advanced-filter-fieldset' + ] + ); + + $ruleModel = $this->getHelper('Data\GlobalData')->getValue('rule_model'); + $ruleBlock = $this->createBlock('Magento\Product\Rule') + ->setData(['rule_model' => $ruleModel]); + + $fieldset->addField('advanced_filter', + self::CUSTOM_CONTAINER, + [ + 'text' => $ruleBlock->toHtml() + ] + ); + + $form->setUseContainer(true); + $this->setForm($form); + + return parent::_prepareForm(); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/Listing/Product/ShowOthersListingsProductsFilter.php b/Block/Adminhtml/Listing/Product/ShowOthersListingsProductsFilter.php new file mode 100644 index 000000000..2f6e9e4a8 --- /dev/null +++ b/Block/Adminhtml/Listing/Product/ShowOthersListingsProductsFilter.php @@ -0,0 +1,46 @@ +getRequest()->isXmlHttpRequest()) { + $params = []; + } else { + $params = $this->getRequest()->getParams(); + } + + if ($this->isChecked()) { + unset($params[$this->getParamName()]); + } else { + $params[$this->getParamName()] = true; + } + + return $this->getUrl('*/'.$this->getData('controller').'/*', $params); + } + + public function isChecked() + { + return $this->getRequest()->getParam($this->getParamName()); + } + + //######################################## +} \ No newline at end of file diff --git a/Block/Adminhtml/Listing/View/Grid.php b/Block/Adminhtml/Listing/View/Grid.php index 59d56bc89..6ffcdd810 100644 --- a/Block/Adminhtml/Listing/View/Grid.php +++ b/Block/Adminhtml/Listing/View/Grid.php @@ -72,15 +72,6 @@ protected function _toHtml() // --------------------------------------- -// $this->js->add( -// <<select() ->from($tableName,$fields) ->where('`action_id` IN ('.$actionIdsString.')') - ->where('`type` = ?',\Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR) + ->where('`type` = ?',\Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR) ->group('description') ->order(array('count_products DESC')) ->limit(100); diff --git a/Block/Adminhtml/Log/Grid/AbstractGrid.php b/Block/Adminhtml/Log/Grid/AbstractGrid.php index 4f0248741..b7f71f61d 100644 --- a/Block/Adminhtml/Log/Grid/AbstractGrid.php +++ b/Block/Adminhtml/Log/Grid/AbstractGrid.php @@ -103,19 +103,19 @@ public function getListingProduct() protected function _getLogTypeList() { return array( - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_NOTICE => $this->__('Notice'), - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS => $this->__('Success'), - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING => $this->__('Warning'), - \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR => $this->__('Error') + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_NOTICE => $this->__('Notice'), + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_SUCCESS => $this->__('Success'), + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_WARNING => $this->__('Warning'), + \Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR => $this->__('Error') ); } protected function _getLogPriorityList() { return array( - \Ess\M2ePro\Model\Log\AbstractLog::PRIORITY_HIGH => $this->__('High'), - \Ess\M2ePro\Model\Log\AbstractLog::PRIORITY_MEDIUM => $this->__('Medium'), - \Ess\M2ePro\Model\Log\AbstractLog::PRIORITY_LOW => $this->__('Low') + \Ess\M2ePro\Model\Log\AbstractModel::PRIORITY_HIGH => $this->__('High'), + \Ess\M2ePro\Model\Log\AbstractModel::PRIORITY_MEDIUM => $this->__('Medium'), + \Ess\M2ePro\Model\Log\AbstractModel::PRIORITY_LOW => $this->__('Low') ); } @@ -133,18 +133,18 @@ public function callbackColumnType($value, $row, $column, $isExport) { switch ($row->getData('type')) { - case \Ess\M2ePro\Model\Log\AbstractLog::TYPE_NOTICE: + case \Ess\M2ePro\Model\Log\AbstractModel::TYPE_NOTICE: break; - case \Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS: + case \Ess\M2ePro\Model\Log\AbstractModel::TYPE_SUCCESS: $value = ''.$value.''; break; - case \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING: + case \Ess\M2ePro\Model\Log\AbstractModel::TYPE_WARNING: $value = ''.$value.''; break; - case \Ess\M2ePro\Model\Log\AbstractLog::TYPE_ERROR: + case \Ess\M2ePro\Model\Log\AbstractModel::TYPE_ERROR: $value = ''.$value.''; break; diff --git a/Block/Adminhtml/Magento/Button/SplitButton.php b/Block/Adminhtml/Magento/Button/SplitButton.php index 90dcf2d07..2bcb4ef0b 100644 --- a/Block/Adminhtml/Magento/Button/SplitButton.php +++ b/Block/Adminhtml/Magento/Button/SplitButton.php @@ -27,7 +27,7 @@ public function getButtonAttributesHtml() $classes = []; $classes[] = 'action-default'; $classes[] = 'primary'; - // @TODO Perhaps use $this->getButtonClass() instead + if ($this->getClass()) { $classes[] = $this->getClass(); } @@ -45,7 +45,6 @@ public function getButtonAttributesHtml() 'onclick' => !empty($onclick) ? $onclick : '', ]; - //TODO perhaps we need to skip data-mage-init when disabled="disabled" if ($this->getDataAttribute()) { $this->_getDataAttributes($this->getDataAttribute(), $attributes); } diff --git a/Block/Adminhtml/Magento/Context/Template.php b/Block/Adminhtml/Magento/Context/Template.php index a9914ae5b..175396ad5 100644 --- a/Block/Adminhtml/Magento/Context/Template.php +++ b/Block/Adminhtml/Magento/Context/Template.php @@ -22,6 +22,9 @@ class Template extends Context /** @var \Ess\M2ePro\Model\ActiveRecord\Component\Parent\Factory */ protected $parentFactory; + /** @var \Magento\Framework\Data\Form\Element\Factory */ + protected $elementFactory; + public function __construct( \Ess\M2ePro\Helper\Factory $helperFactory, \Ess\M2ePro\Model\Factory $modelFactory, @@ -32,6 +35,7 @@ public function __construct( Renderer\JsRenderer $js, Renderer\JsTranslatorRenderer $jsTranslatorRenderer, Renderer\JsUrlRenderer $jsUrlRenderer, + \Magento\Framework\Data\Form\Element\Factory $elementFactory, \Magento\Framework\App\RequestInterface $request, \Magento\Framework\View\LayoutInterface $layout, \Magento\Framework\Event\ManagerInterface $eventManager, @@ -75,6 +79,8 @@ public function __construct( $this->jsTranslator = $jsTranslatorRenderer; $this->jsUrl = $jsUrlRenderer; + $this->elementFactory = $elementFactory; + parent::__construct( $request, $layout, @@ -180,4 +186,12 @@ public function getParentFactory() { return $this->parentFactory; } + + /** + * @return \Magento\Framework\Data\Form\Element\Factory + */ + public function getElementFactory() + { + return $this->elementFactory; + } } \ No newline at end of file diff --git a/Block/Adminhtml/Magento/Form/AbstractForm.php b/Block/Adminhtml/Magento/Form/AbstractForm.php index 00ec62be1..c20601fa2 100644 --- a/Block/Adminhtml/Magento/Form/AbstractForm.php +++ b/Block/Adminhtml/Magento/Form/AbstractForm.php @@ -30,6 +30,9 @@ abstract class AbstractForm extends Generic /** @var \Ess\M2ePro\Model\ActiveRecord\Component\Parent\Factory */ protected $parentFactory; + /** @var \Magento\Framework\Data\Form\Element\Factory */ + protected $elementFactory; + public function __construct( \Ess\M2ePro\Block\Adminhtml\Magento\Context\Template $context, \Magento\Framework\Registry $registry, @@ -48,6 +51,8 @@ public function __construct( $this->jsTranslator = $context->getJsTranslator(); $this->jsUrl = $context->getJsUrl(); + $this->elementFactory = $context->getElementFactory(); + parent::__construct($context, $registry, $formFactory, $data); } @@ -62,5 +67,7 @@ protected function _prepareLayout() \Magento\Framework\Data\Form::setFieldsetRenderer( $this->createBlock('Magento\Form\Renderer\Fieldset') ); + + return $this; } } \ No newline at end of file diff --git a/Block/Adminhtml/Magento/Form/Element/Select.php b/Block/Adminhtml/Magento/Form/Element/Select.php index 986692d41..6c9d44047 100644 --- a/Block/Adminhtml/Magento/Form/Element/Select.php +++ b/Block/Adminhtml/Magento/Form/Element/Select.php @@ -13,6 +13,10 @@ public function getElementHtml() { $this->addClass('select admin__control-select'); + if ($this->getData('create_magento_attribute') === true) { + $this->addClass('M2ePro-custom-attribute-can-be-created'); + } + $html = ''; if ($this->getBeforeElementHtml()) { $html .= '