protected function addCategoriesPath(&$data, \Ess\M2ePro\Model\Listing $listing) { $marketplaceId = $listing->getData('marketplace_id'); $accountId = $listing->getAccountId(); if (isset($data['category_main_mode'])) { if ($data['category_main_mode'] == \Ess\M2ePro\Model\Ebay\Template\Category::CATEGORY_MODE_EBAY) { $data['category_main_path'] = $this->getHelper('Component\\Ebay\\Category\\Ebay')->getPath($data['category_main_id'], $marketplaceId); } else { $data['category_main_path'] = null; } } if (isset($data['category_secondary_mode'])) { if ($data['category_secondary_mode'] == \Ess\M2ePro\Model\Ebay\Template\Category::CATEGORY_MODE_EBAY) { $data['category_secondary_path'] = $this->getHelper('Component\\Ebay\\Category\\Ebay')->getPath($data['category_secondary_id'], $marketplaceId); } else { $data['category_secondary_path'] = null; } } if (isset($data['store_category_main_mode'])) { if ($data['store_category_main_mode'] == \Ess\M2ePro\Model\Ebay\Template\Category::CATEGORY_MODE_EBAY) { $data['store_category_main_path'] = $this->getHelper('Component\\Ebay\\Category\\Store')->getPath($data['store_category_main_id'], $accountId); } else { $data['store_category_main_path'] = null; } } if (isset($data['store_category_secondary_mode'])) { if ($data['store_category_secondary_mode'] == \Ess\M2ePro\Model\Ebay\Template\Category::CATEGORY_MODE_EBAY) { $data['store_category_secondary_path'] = $this->getHelper('Component\\Ebay\\Category\\Store')->getPath($data['store_category_secondary_id'], $accountId); } else { $data['store_category_secondary_path'] = null; } } }
/** * @param \Ess\M2ePro\Model\Listing $listing * @return \Ess\M2ePro\Model\Listing\Auto\Actions\Listing */ protected function getListingObject(\Ess\M2ePro\Model\Listing $listing) { $componentMode = ucfirst($listing->getComponentMode()); /** @var \Ess\M2ePro\Model\Listing\Auto\Actions\Listing $object */ $object = $this->modelFactory->getObject($componentMode . '\\Listing\\Auto\\Actions\\Listing'); $object->setListing($listing); return $object; }
/** * @param \Magento\Catalog\Model\Product $product * @param \Ess\M2ePro\Model\Listing $listing * @throws \Ess\M2ePro\Model\Exception\Logic */ public function addProductByWebsiteListing(\Magento\Catalog\Model\Product $product, \Ess\M2ePro\Model\Listing $listing) { $logData = array('reason' => __METHOD__); $listingProduct = $this->getListing()->addProduct($product, false, true, $logData); if (!$listingProduct instanceof \Ess\M2ePro\Model\Listing\Product) { return; } /** @var \Ess\M2ePro\Model\Ebay\Listing $ebayListing */ $ebayListing = $listing->getChildObject(); $params = array('template_category_id' => $ebayListing->getAutoWebsiteAddingTemplateCategoryId(), 'template_other_category_id' => $ebayListing->getAutoWebsiteAddingTemplateOtherCategoryId()); $this->processAddedListingProduct($listingProduct, $params); }
public function getDescriptionTemplateMode() { $listingAdditionalData = $this->listing->getData('additional_data'); $listingAdditionalData = json_decode($listingAdditionalData, true); $mode = 'same'; $sessionMode = $this->getHelper('Data\\Session')->getValue('products_source'); if ($sessionMode == 'category') { $mode = $sessionMode; } if (!empty($listingAdditionalData['new_asin_mode'])) { $mode = $listingAdditionalData['new_asin_mode']; } return $mode; }
protected function _toHtml() { if ($this->getRequest()->isXmlHttpRequest()) { $this->js->add(<<<JS ListingGridHandlerObj.afterInitPage(); JS ); return parent::_toHtml(); } $showNotCompletedPopup = ''; if ($this->getRequest()->getParam('not_completed', false)) { $showNotCompletedPopup = 'ListingGridHandlerObj.showNotCompletedPopup();'; } $this->js->add(<<<JS require([ 'M2ePro/Amazon/Listing/Product/Add/SearchAsin/Grid' ],function() { ListingGridHandlerObj = new AmazonListingProductAddSearchAsinGrid( '{$this->getId()}', {$this->listing->getId()} ); ListingGridHandlerObj.actionHandler.setOptions(M2ePro); ListingGridHandlerObj.productSearchHandler.setOptions(M2ePro); ListingGridHandlerObj.afterInitPage(); {$showNotCompletedPopup} }); JS ); if (!$this->listing->getChildObject()->isGeneralIdAttributeMode() && !$this->listing->getChildObject()->isWorldwideIdAttributeMode()) { if (!$this->listing->getChildObject()->isSearchByMagentoTitleModeEnabled()) { $gridId = $this->getId(); $this->js->add(<<<JS var mmassActionEl = \$("{$gridId}_massaction-select"); if (mmassActionEl && mmassActionEl.select('option[value="assignGeneralId"]').length > 0) { var assignGeneralIdOption = mmassActionEl.select('option[value="assignGeneralId"]')[0]; assignGeneralIdOption.disabled = true; mmassActionEl.insert({bottom: assignGeneralIdOption.remove()}); } JS ); } } else { $autoSearchSetting = $this->listing->getSetting('additional_data', 'auto_search_was_performed'); if (!$autoSearchSetting) { $this->listing->setSetting('additional_data', 'auto_search_was_performed', 1); $this->listing->save(); $this->js->add(<<<JS ListingGridHandlerObj.getGridMassActionObj().selectAll(); ListingGridHandlerObj.productSearchHandler.searchGeneralIdAuto(ListingGridHandlerObj.getSelectedProductsString()); JS ); } } return parent::_toHtml(); }
private function prepareDataByCategories() { $listingProductsIds = $this->listing->getSetting('additional_data', 'adding_new_asin_listing_products_ids'); $listingProductCollection = $this->amazonFactory->getObject('Listing\\Product')->getCollection()->addFieldToFilter('id', array('in' => $listingProductsIds)); $productsIds = array(); $descriptionTemplatesIds = array(); foreach ($listingProductCollection->getData() as $item) { $productsIds[$item['id']] = $item['product_id']; $descriptionTemplatesIds[$item['id']] = $item['template_description_id']; } $productsIds = array_unique($productsIds); $categoriesIds = $this->getHelper('Magento\\Category')->getLimitedCategoriesByProducts($productsIds, $this->listing->getStoreId()); $categoriesData = array(); foreach ($categoriesIds as $categoryId) { $collection = $this->productFactory->create()->getCollection(); $collection->addFieldToFilter('entity_id', array('in' => $productsIds)); $collection->joinTable(array('ccp' => $this->resourceConnection->getTableName('catalog_category_product')), 'product_id=entity_id', array('category_id' => 'category_id')); $collection->addFieldToFilter('category_id', $categoryId); $data = $collection->getData(); foreach ($data as $item) { $categoriesData[$categoryId][] = array_search($item['entity_id'], $productsIds); } $categoriesData[$categoryId] = array_unique($categoriesData[$categoryId]); } $this->setData('categories_data', $categoriesData); $this->setData('description_templates_data', $descriptionTemplatesIds); $this->listing->setSetting('additional_data', 'adding_new_asin_description_templates_data', $descriptionTemplatesIds); $this->listing->save(); }
private function getGeneralIdColumnValueNotEmptyGeneralId($row) { $generalId = $row->getData('general_id'); $url = $this->getHelper('Component\\Amazon')->getItemUrl($generalId, $this->listing->getMarketplaceId()); $generalIdOwnerHtml = ''; if ($row->getData('is_general_id_owner') == \Ess\M2ePro\Model\Amazon\Listing\Product::IS_GENERAL_ID_OWNER_YES) { $generalIdOwnerHtml = '<br/><span style="font-size: 10px; color: grey;">' . $this->__('creator of ASIN/ISBN') . '</span>'; } if ((int) $row->getData('amazon_status') != \Ess\M2ePro\Model\Listing\Product::STATUS_NOT_LISTED) { return <<<HTML <a href="{$url}" target="_blank">{$generalId}</a>{$generalIdOwnerHtml} HTML; } $generalIdSearchInfo = $row->getData('general_id_search_info'); if (!empty($generalIdSearchInfo)) { $generalIdSearchInfo = @json_decode($generalIdSearchInfo, true); } if (!empty($generalIdSearchInfo['is_set_automatic'])) { $tip = $this->__('ASIN/ISBN was found automatically'); $text = <<<HTML <a href="{$url}" target="_blank" title="{$tip}" style="color:#40AADB;">{$generalId}</a> HTML; } else { $text = <<<HTML <a href="{$url}" target="_blank">{$generalId}</a> HTML; } return $text . $generalIdOwnerHtml; }
private function getGeneralIdColumnValueNotEmptyGeneralId($row) { $generalId = $row->getData('general_id'); $url = $this->getHelper('Component\\Amazon')->getItemUrl($generalId, $this->listing->getMarketplaceId()); $generalIdOwnerHtml = ''; if ($row->getData('is_general_id_owner') == \Ess\M2ePro\Model\Amazon\Listing\Product::IS_GENERAL_ID_OWNER_YES) { $generalIdOwnerHtml = '<br/><span style="font-size: 10px; color: grey;">' . $this->__('creator of ASIN/ISBN') . '</span>'; } if ((int) $row->getData('amazon_status') != \Ess\M2ePro\Model\Listing\Product::STATUS_NOT_LISTED) { return <<<HTML <a href="{$url}" target="_blank">{$generalId}</a>{$generalIdOwnerHtml} HTML; } $generalIdSearchInfo = $row->getData('general_id_search_info'); if (!empty($generalIdSearchInfo)) { $generalIdSearchInfo = @json_decode($generalIdSearchInfo, true); } if (!empty($generalIdSearchInfo['is_set_automatic'])) { $tip = $this->__('ASIN/ISBN was found automatically'); $text = <<<HTML <a href="{$url}" target="_blank" title="{$tip}" style="color:#40AADB;">{$generalId}</a> HTML; } else { $text = <<<HTML <a href="{$url}" target="_blank">{$generalId}</a> HTML; } // --------------------------------------- $hasInActionLock = $this->getLockedData($row); $hasInActionLock = $hasInActionLock['in_action']; // --------------------------------------- if ($hasInActionLock) { return $text . $generalIdOwnerHtml; } $listingProductId = (int) $row->getData('id'); /** @var \Ess\M2ePro\Model\Listing\Product $listingProduct */ $listingProduct = $this->amazonFactory->getObjectLoaded('Listing\\Product', $listingProductId); /** @var \Ess\M2ePro\Model\Amazon\Listing\Product\Variation\Manager $variationManager */ $variationManager = $listingProduct->getChildObject()->getVariationManager(); $variationChildStatuses = $row->getData('variation_child_statuses'); if ($variationManager->isVariationParent() && !empty($variationChildStatuses)) { $variationChildStatuses = json_decode($variationChildStatuses, true); unset($variationChildStatuses[\Ess\M2ePro\Model\Listing\Product::STATUS_NOT_LISTED]); foreach ($variationChildStatuses as $variationChildStatus) { if (!empty($variationChildStatus)) { return $text . $generalIdOwnerHtml; } } } $tip = $this->__('Unassign ASIN/ISBN'); $text .= <<<HTML <a href="javascript:;" class="amazon-listing-view-icon amazon-listing-view-generalId-remove" onclick="ListingGridHandlerObj.productSearchHandler.showUnmapFromGeneralIdPrompt({$listingProductId});" title="{$tip}"> </a>{$generalIdOwnerHtml} HTML; return $text; }
protected function getColumnActionsItems() { $categories = $this->getHelper('Component\\Ebay\\Category')->getCategoryTitles(); $actions = array('editCategories' => array('caption' => $this->__('Edit All Categories'), 'field' => 'id', 'onclick_action' => 'EbayListingProductCategorySettingsModeCategoryGridObj.' . 'actions[\'editCategoriesAction\']'), 'editPrimaryCategories' => array('caption' => $this->__('Edit %1%', $categories[\Ess\M2ePro\Helper\Component\Ebay\Category::TYPE_EBAY_MAIN]), 'field' => 'id', 'onclick_action' => 'EbayListingProductCategorySettingsModeCategoryGridObj.' . 'actions[\'editPrimaryCategoriesAction\']')); if ($this->listing->getAccount()->getChildObject()->getEbayStoreCategories()) { $actions['editStorePrimaryCategories'] = array('caption' => $this->__('Edit %1%', $categories[\Ess\M2ePro\Helper\Component\Ebay\Category::TYPE_STORE_MAIN]), 'field' => 'id', 'onclick_action' => 'EbayListingProductCategorySettingsModeCategoryGridObj.' . 'actions[\'editStorePrimaryCategoriesAction\']'); } return $actions; }
public function getAddProductsDropDownItems() { $items = []; // --------------------------------------- $url = $this->getUrl('*/ebay_listing_product_add', ['source' => \Ess\M2ePro\Block\Adminhtml\Ebay\Listing\Product\Add\SourceMode::MODE_PRODUCT, 'clear' => true, 'id' => $this->listing->getId()]); $items[] = ['label' => $this->__('From Products List'), 'onclick' => "setLocation('" . $url . "')", 'default' => true]; // --------------------------------------- // --------------------------------------- $url = $this->getUrl('*/ebay_listing_product_add', ['source' => \Ess\M2ePro\Block\Adminhtml\Ebay\Listing\Product\Add\SourceMode::MODE_CATEGORY, 'clear' => true, 'id' => $this->listing->getId()]); $items[] = ['label' => $this->__('From Categories'), 'onclick' => "setLocation('" . $url . "')"]; // --------------------------------------- return $items; }
protected function _prepareCollection() { // Get collection // --------------------------------------- /* @var $collection \Ess\M2ePro\Model\ResourceModel\Magento\Product\Collection */ $collection = $this->magentoProductCollectionFactory->create(); $collection->setListingProductModeOn(); $collection->setStoreId($this->listing->getData('store_id'))->addAttributeToSelect('name')->addAttributeToSelect('sku'); // --------------------------------------- // --------------------------------------- $listingProductsIds = $this->listing->getSetting('additional_data', 'adding_new_asin_listing_products_ids'); $lpTable = $this->activeRecordFactory->getObject('Listing\\Product')->getResource()->getMainTable(); $collection->joinTable(array('lp' => $lpTable), 'product_id=entity_id', array('id' => 'id'), '{{table}}.listing_id=' . (int) $this->listing->getId()); $alpTable = $this->activeRecordFactory->getObject('Amazon\\Listing\\Product')->getResource()->getMainTable(); $collection->joinTable(array('alp' => $alpTable), 'listing_product_id=id', array('listing_product_id' => 'listing_product_id', 'template_description_id' => 'template_description_id')); $collection->getSelect()->where('lp.id IN (?)', $listingProductsIds); $collection->getSelect()->where('alp.search_settings_status != ? OR alp.search_settings_status IS NULL', \Ess\M2ePro\Model\Amazon\Listing\Product::SEARCH_SETTINGS_STATUS_IN_PROGRESS); $collection->getSelect()->where('alp.general_id IS NULL'); // --------------------------------------- $this->setCollection($collection); parent::_prepareCollection(); return $this; }
protected function _toHtml() { if ($this->getRequest()->isXmlHttpRequest()) { return parent::_toHtml(); } // --------------------------------------- $this->jsUrl->addUrls($this->getHelper('Data')->getControllerActions('Ebay\\Listing\\AutoAction', array('id' => $this->listing->getId()))); $this->jsUrl->addUrls($this->getHelper('Data')->getControllerActions('Ebay\\Listing\\Product\\Add', array('_current' => true))); $this->jsUrl->add($this->getUrl('*/ebay_listing_product_add', array('_current' => true, 'step' => null)), 'ebay_listing_product_add'); $this->jsUrl->add($this->getUrl('*/ebay_listing_product_category_settings', array('_current' => true, 'step' => null)), 'ebay_listing_product_category_settings'); // --------------------------------------- // --------------------------------------- $this->jsTranslator->addTranslations(['eBay Categories' => $this->__('eBay Categories'), 'of Product' => $this->__('of Product'), 'Specifics' => $this->__('Specifics'), 'Auto Add/Remove Rules' => $this->__('Auto Add/Remove Rules'), 'Based on Magento Categories' => $this->__('Based on Magento Categories'), 'You must select at least 1 Category.' => $this->__('You must select at least 1 Category.'), 'Rule with the same Title already exists.' => $this->__('Rule with the same Title already exists.'), 'Listing Settings Customization' => $this->__('Listing Settings Customization')]); // --------------------------------------- // --------------------------------------- $showAutoActionPopup = !$this->getHelper('Module')->getConfig()->getGroupValue('/view/ebay/advanced/autoaction_popup/', 'shown'); $showAutoActionPopup = json_encode($showAutoActionPopup); // --------------------------------------- $this->js->add(<<<JS require([ 'M2ePro/Ebay/Listing/Product/Add', 'M2ePro/Plugin/AreaWrapper', 'M2ePro/Plugin/ProgressBar', 'M2ePro/Ebay/Listing/AutoAction' ], function(){ window.WrapperObj = new AreaWrapper('add_products_container'); window.ProgressBarObj = new ProgressBar('add_products_progress_bar'); window.ListingProductAddObj = new EbayListingProductAdd({ show_autoaction_popup: {$showAutoActionPopup}, get_selected_products: {$this->getSelectedProductsCallback()} }); window.ListingAutoActionObj = new EbayListingAutoAction(); }); JS ); return parent::_toHtml(); }
public function fillCategoriesPaths(array &$data, \Ess\M2ePro\Model\Listing $listing) { $ebayCategoryHelper = $this->getHelper('Component\\Ebay\\Category\\Ebay'); $ebayStoreCategoryHelper = $this->getHelper('Component\\Ebay\\Category\\Store'); $temp = array('category_main' => array('call' => array($ebayCategoryHelper, 'getPath'), 'arg' => $listing->getMarketplaceId()), 'category_secondary' => array('call' => array($ebayCategoryHelper, 'getPath'), 'arg' => $listing->getMarketplaceId()), 'store_category_main' => array('call' => array($ebayStoreCategoryHelper, 'getPath'), 'arg' => $listing->getAccountId()), 'store_category_secondary' => array('call' => array($ebayStoreCategoryHelper, 'getPath'), 'arg' => $listing->getAccountId())); foreach ($temp as $key => $value) { if (!isset($data[$key . '_mode']) || !empty($data[$key . '_path'])) { continue; } if ($data[$key . '_mode'] == \Ess\M2ePro\Model\Ebay\Template\Category::CATEGORY_MODE_EBAY) { $data[$key . '_path'] = call_user_func($value['call'], $data[$key . '_id'], $value['arg']); } if ($data[$key . '_mode'] == \Ess\M2ePro\Model\Ebay\Template\Category::CATEGORY_MODE_ATTRIBUTE) { $attributeLabel = $this->getHelper('Magento\\Attribute')->getAttributeLabel($data[$key . '_attribute'], $listing->getStoreId()); $data[$key . '_path'] = 'Magento Attribute' . ' > ' . $attributeLabel; } } }
protected function _getStore() { return $this->_storeManager->getStore((int) $this->listing->getStoreId()); }
private function getDataFromListing(\Ess\M2ePro\Model\Listing $source, array $params = array()) { $accountId = $source->getAccountId(); $marketplaceId = $source->getMarketplaceId(); $storeId = $source->getStoreId(); $attributeSets = $this->getHelper('Magento\\AttributeSet')->getAll(\Ess\M2ePro\Helper\Magento\AbstractHelper::RETURN_TYPE_IDS); $templates = array(); foreach ($this->templateManager->getAllTemplates() as $nick) { $manager = $this->templateManagerFactory->create()->setTemplate($nick)->setOwnerObject($source->getChildObject()); $templateId = $manager->getIdColumnValue(); $templateMode = $manager->getModeValue(); $templates[$nick] = array('id' => $templateId, 'mode' => $templateMode, 'force_parent' => false); } return array('account_id' => $accountId, 'marketplace_id' => $marketplaceId, 'store_id' => $storeId, 'attribute_sets' => $attributeSets, 'display_use_default_option' => false, 'templates' => $templates); }
protected function _toHtml() { $allIdsStr = $this->getGridIdsJson(); if ($this->getRequest()->isXmlHttpRequest()) { $this->js->add(<<<JS EbayListingProductCategorySettingsModeProductGridObj.afterInitPage(); EbayListingProductCategorySettingsModeProductGridObj.getGridMassActionObj().setGridIds('{$allIdsStr}'); JS ); return parent::_toHtml(); } // --------------------------------------- $this->jsUrl->addUrls($this->getHelper('Data')->getControllerActions('Ebay\\Listing\\Product\\Category\\Settings', array('_current' => true))); $this->jsUrl->add($this->getUrl('*/ebay_listing_product_category_settings', array('step' => 3, '_current' => true)), 'ebay_listing_product_category_settings'); $this->jsUrl->add($this->getUrl('*/ebay_category/getChooserEditHtml', array('account_id' => $this->listing->getAccountId(), 'marketplace_id' => $this->listing->getMarketplaceId())), 'ebay_category/getChooserEditHtml'); // --------------------------------------- // --------------------------------------- $translations = array(); // M2ePro_TRANSLATIONS // You have not selected the Primary eBay Category for some Products. $text = 'You have not selected the Primary eBay Category for some Products.'; $translations[$text] = $this->__($text); // M2ePro_TRANSLATIONS // Are you sure? $text = 'Are you sure?'; $translations[$text] = $this->__($text); // M2ePro_TRANSLATIONS // eBay could not assign Categories for %product_tite% Products. $text = 'eBay could not assign Categories for %product_title% Products.'; $translations[$text] = $this->__($text); // M2ePro_TRANSLATIONS // Suggested Categories were successfully Received for %product_title% Product(s). $text = 'Suggested Categories were successfully Received for %product_title% Product(s).'; $translations[$text] = $this->__($text); // M2ePro_TRANSLATIONS // Set eBay Category $text = 'Set eBay Category'; $translations[$text] = $this->__($text); // M2ePro_TRANSLATIONS // Set eBay Category for Product(s) $text = 'Set eBay Category for Product(s)'; $translations[$text] = $this->__($text); // M2ePro_TRANSLATIONS // Set eBay Primary Category for Product(s) $text = 'Set eBay Primary Category for Product(s)'; $translations[$text] = $this->__($text); $this->jsTranslator->addTranslations($translations); // --------------------------------------- // --------------------------------------- $this->jsPhp->addConstants($this->getHelper('Data')->getClassConstants('\\Ess\\M2ePro\\Helper\\Component\\Ebay\\Category')); // --------------------------------------- $getSuggested = json_encode((bool) $this->getHelper('Data\\GlobalData')->getValue('get_suggested')); $this->js->addOnReadyJs(<<<JS require([ 'M2ePro/Ebay/Listing/Product/Category/Settings/Mode/Product/Grid', 'M2ePro/Ebay/Listing/Product/Category/Settings/Mode/Product/SuggestedSearch', 'M2ePro/Plugin/ProgressBar', 'M2ePro/Plugin/AreaWrapper' ], function(){ window.WrapperObj = new AreaWrapper('products_container'); window.ProgressBarObj = new ProgressBar('products_progress_bar'); window.EbayListingProductCategorySettingsModeProductGridObj = new EbayListingProductCategorySettingsModeProductGrid('{$this->getId()}'); EbayListingProductCategorySettingsModeProductSuggestedSearchObj = new EbayListingProductCategorySettingsModeProductSuggestedSearch(); EbayListingProductCategorySettingsModeProductGridObj.afterInitPage(); EbayListingProductCategorySettingsModeProductGridObj.getGridMassActionObj().setGridIds('{$allIdsStr}'); if ({$getSuggested}) { EbayListingProductCategorySettingsModeProductGridObj.getSuggestedCategoriesForAll(); } }) JS ); return parent::_toHtml(); }
public function callbackColumnPrice($value, $row, $column, $isExport) { $onlinePrice = $row->getData('online_price'); $repricingHtml = ''; // TODO // if (Mage::helper('M2ePro/Component_Amazon_Repricing')->isEnabled() && // (bool)(int)$row->getData('is_repricing')) { // // $image = 'money'; // $text = $this->__( // 'This product is used by Amazon Repricing Tool. // The Price cannot be updated through the M2E Pro.' // ); // // if ((int)$row->getData('is_repricing_disabled') == 1) { // $image = 'money_disabled'; // $text = $this->__( // 'This product is disabled on Amazon Repricing Tool. // The Price is updated through the M2E Pro.' // ); // } // // $repricingHtml = <<<HTML //<span style="float:right; text-align: left;"> // <img class="tool-tip-image" // style="vertical-align: middle; width: 16px;" // src="{$this->getSkinUrl('M2ePro/images/'.$image.'.png')}"> // <span class="tool-tip-message tool-tip-message tip-left" style="display:none;"> // <img src="{$this->getSkinUrl('M2ePro/images/i_icon.png')}"> // <span>{$text}</span> // </span> //</span> //HTML; // } if (is_null($onlinePrice) || $onlinePrice === '') { if ($row->getData('amazon_status') == \Ess\M2ePro\Model\Listing\Product::STATUS_NOT_LISTED) { return $this->__('N/A') . $repricingHtml; } else { return '<i style="color:gray;">receiving...</i>' . $repricingHtml; } } $currency = $this->listing->getMarketplace()->getChildObject()->getDefaultCurrency(); if ((double) $onlinePrice <= 0) { $priceValue = '<span style="color: #f00;">0</span>'; } else { $priceValue = $this->convertAndFormatPriceCurrency($onlinePrice, $currency); } // TODO // if ($row->getData('is_repricing') && !$row->getData('is_repricing_disabled')) { // $this->listing = $this->getHelper('Data\GlobalData')->getValue('temp_data'); // $accountId = $this->listing['account_id']; // $sku = $row->getData('amazon_sku'); // // $priceValue =<<<HTML //<a id="m2epro_repricing_price_value_{$sku}" // class="m2epro-repricing-price-value" // sku="{$sku}" // account_id="{$accountId}" // href="javascript:void(0)" // onclick="CommonAmazonListingRepricingPriceHandlerObj.showRepricingPrice()"> // {$priceValue} //</a> //HTML; // } $resultHtml = ''; $salePrice = $row->getData('online_sale_price'); if ((double) $salePrice > 0) { $currentTimestamp = strtotime($this->getHelper('Data')->getCurrentGmtDate(false, 'Y-m-d 00:00:00')); $startDateTimestamp = strtotime($row->getData('online_sale_price_start_date')); $endDateTimestamp = strtotime($row->getData('online_sale_price_end_date')); if ($currentTimestamp <= $endDateTimestamp) { $fromDate = $this->_localeDate->formatDate($row->getData('online_sale_price_start_date'), \IntlDateFormatter::MEDIUM); $toDate = $this->_localeDate->formatDate($row->getData('online_sale_price_end_date'), \IntlDateFormatter::MEDIUM); $intervalHtml = <<<HTML <div class="m2epro-field-tooltip m2epro-field-tooltip-price-info admin__field-tooltip"> <a class="admin__field-tooltip-action" href="javascript://"></a> <div class="admin__field-tooltip-content"> <span style="color:gray;"> <strong>From:</strong> {$fromDate}<br/> <strong>To:</strong> {$toDate} </span> </div> </div> HTML; $salePriceValue = $this->convertAndFormatPriceCurrency($salePrice, $currency); if ($currentTimestamp >= $startDateTimestamp && $currentTimestamp <= $endDateTimestamp && $salePrice < (double) $onlinePrice) { $resultHtml .= '<span style="color: grey; text-decoration: line-through;">' . $priceValue . '</span>' . $repricingHtml; $resultHtml .= '<br/>' . $intervalHtml . ' ' . $salePriceValue; } else { $resultHtml .= $priceValue . $repricingHtml; $resultHtml .= '<br/>' . $intervalHtml . '<span style="color:gray;">' . ' ' . $salePriceValue . '</span>'; } } } if (empty($resultHtml)) { $resultHtml = $priceValue . $repricingHtml; } return $resultHtml; }
/** * @param \Magento\Catalog\Model\Product $product * @param \Ess\M2ePro\Model\Listing $listing * @throws \Ess\M2ePro\Model\Exception\Logic */ public function addProductByWebsiteListing(\Magento\Catalog\Model\Product $product, \Ess\M2ePro\Model\Listing $listing) { $logData = array('reason' => __METHOD__); $listingProduct = $this->getListing()->addProduct($product, false, true, $logData); if (!$listingProduct instanceof \Ess\M2ePro\Model\Listing\Product) { return; } /** @var \Ess\M2ePro\Model\Amazon\Listing $amazonListing */ $amazonListing = $listing->getChildObject(); $params = array('template_description_id' => $amazonListing->getAutoWebsiteAddingDescriptionTemplateId()); $this->processAddedListingProduct($listingProduct, $params); }
public function getGridHtml() { if ($this->getRequest()->isXmlHttpRequest()) { return parent::getGridHtml(); } $this->jsPhp->addConstants($this->getHelper('Data')->getClassConstants('\\Ess\\M2ePro\\Model\\Listing')); $showAutoAction = json_encode((bool) $this->getRequest()->getParam('auto_actions')); // --------------------------------------- $this->jsUrl->addUrls($this->getHelper('Data')->getControllerActions('Amazon\\Listing\\AutoAction', array('id' => $this->getRequest()->getParam('id')))); $path = 'amazon_listing_product_log/index'; $this->jsUrl->add($this->getUrl('*/' . $path, array('back' => $this->getHelper('Data')->makeBackUrlParam('*/amazon_listing/view', array('id' => $this->listing['id'])))), $path); $path = 'amazon_listing/duplicateProducts'; $this->jsUrl->add($this->getUrl('*/' . $path), $path); $this->jsUrl->add($this->getUrl('*/amazon_listing_log/index', array('id' => $this->listing['id'], 'back' => $this->getHelper('Data')->makeBackUrlParam('*/amazon_listing/view', ['id' => $this->listing['id']]))), 'logViewUrl'); $this->jsUrl->add($this->getUrl('*/listing/getErrorsSummary'), 'getErrorsSummary'); $this->jsUrl->addUrls($this->getHelper('Data')->getControllerActions('Amazon\\Listing')); $this->jsUrl->addUrls(['runListProducts' => $this->getUrl('*/amazon_listing/runListProducts'), 'runRelistProducts' => $this->getUrl('*/amazon_listing/runRelistProducts'), 'runReviseProducts' => $this->getUrl('*/amazon_listing/runReviseProducts'), 'runStopProducts' => $this->getUrl('*/amazon_listing/runStopProducts'), 'runStopAndRemoveProducts' => $this->getUrl('*/amazon_listing/runStopAndRemoveProducts'), 'runDeleteAndRemoveProducts' => $this->getUrl('*/amazon_listing/runDeleteAndRemoveProducts'), 'runRemoveProducts' => $this->getUrl('*/amazon_listing/runRemoveProducts')]); $this->jsUrl->addUrls($this->getHelper('Data')->getControllerActions('Amazon\\Listing\\Product')); $this->jsUrl->addUrls($this->getHelper('Data')->getControllerActions('Amazon\\Listing\\Product\\Fulfillment')); $this->jsUrl->addUrls($this->getHelper('Data')->getControllerActions('Amazon\\Listing\\Product\\Search')); $this->jsUrl->addUrls($this->getHelper('Data')->getControllerActions('Amazon\\Listing\\Product\\Template\\Description')); $this->jsUrl->addUrls($this->getHelper('Data')->getControllerActions('Amazon\\Listing\\Product\\Variation')); $this->jsUrl->addUrls($this->getHelper('Data')->getControllerActions('Amazon\\Listing\\Product\\Variation\\Manage')); $this->jsUrl->addUrls($this->getHelper('Data')->getControllerActions('Amazon\\Listing\\Product\\Variation\\Individual')); $this->jsUrl->add($this->getUrl('*/amazon_listing_view_settings_moving/moveToListingGrid', ['listing_view' => true]), '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/tryToMoveToListing'), 'tryToMoveToListing'); $this->jsUrl->add($this->getUrl('*/listing_moving/moveToListing'), 'moveToListing'); $this->jsUrl->add($this->getUrl('*/amazon_marketplace/index'), 'marketplaceSynchUrl'); $this->jsUrl->add($this->getUrl('*/listing/saveListingAdditionalData', ['id' => $this->listing['id']]), 'saveListingAdditionalData'); // TODO // $this->jsUrl->addUrls($this->getHelper('Data')->getControllerActions( // 'amazon_listing_repricing', // array( // 'id' => $this->listing['id'], // 'account_id' => $this->listing['account_id'] // ) // )); // --------------------------------------- $component = \Ess\M2ePro\Helper\Component\Amazon::NICK; $gridId = $this->getChildBlock('grid')->getId(); $ignoreListings = json_encode(array($this->listing['id'])); $marketplace = json_encode(array_merge($this->listing->getMarketplace()->getData(), $this->listing->getMarketplace()->getChildObject()->getData())); $isNewAsinAvailable = json_encode($this->listing->getMarketplace()->getChildObject()->isNewAsinAvailable()); $temp = $this->getHelper('Data\\Session')->getValue('products_ids_for_list', true); $productsIdsForList = empty($temp) ? '' : $temp; // TODO // $getUpdatedRepricingPriceBySkus = $this->getUrl( // '*/amazon_listing_repricing/getUpdatedPriceBySkus' // ); $templateDescriptionPopupTitle = $this->__('Assign Description Policy'); $popupTitle = $this->__('Moving Amazon Items'); $popupTitleSingle = $this->__('Moving Amazon Item'); $failedProductsPopupTitle = $this->__('Products failed to move'); $taskCompletedMessage = $this->__('Task completed. Please wait ...'); $taskCompletedSuccessMessage = $this->__('"%task_title%" Task has successfully submitted to be processed.'); $taskCompletedWarningMessage = $this->__('"%task_title%" Task has completed with warnings. <a target="_blank" href="%url%">View Log</a> for details.'); $taskCompletedErrorMessage = $this->__('"%task_title%" Task has completed with errors. <a target="_blank" href="%url%">View Log</a> for details.'); $lockedObjNoticeMessage = $this->__('Some Amazon request(s) are being processed now.'); $sendingDataToAmazonMessage = $this->__('Sending %product_title% Product(s) data on Amazon.'); $viewAllProductLogMessage = $this->__('View Full Product Log'); $listingLockedMessage = $this->__('The Listing was locked by another process. Please try again later.'); $listingEmptyMessage = $this->__('Listing is empty.'); $listingAllItemsMessage = $this->__('Listing All Items On Amazon'); $listingSelectedItemsMessage = $this->__('Listing Selected Items On Amazon'); $revisingSelectedItemsMessage = $this->__('Revising Selected Items On Amazon'); $relistingSelectedItemsMessage = $this->__('Relisting Selected Items On Amazon'); $stoppingSelectedItemsMessage = $this->__('Stopping Selected Items On Amazon'); $stoppingAndRemovingSelectedItemsMessage = $this->__('Stopping On Amazon And Removing From Listing Selected Items'); $deletingAndRemovingSelectedItemsMessage = $this->__('Removing From Amazon And Listing Selected Items'); $removingSelectedItemsMessage = $this->__('Removing From Listing Selected Items'); $successfullyMovedMessage = $this->__('Product(s) was successfully Moved.'); $productsWereNotMovedMessage = $this->__('Product(s) was not Moved. <a target="_blank" href="%url%">View Log</a> for details.'); $someProductsWereNotMovedMessage = $this->__('Some Product(s) was not Moved. <a target="_blank" href="%url%">View Log</a> for details.'); $selectItemsMessage = $this->__('Please select the Products you want to perform the Action on.'); $selectActionMessage = $this->__('Please select Action.'); $assignString = $this->__('Assign'); $templateShippingOverridePopupTitle = $this->__('Assign Shipping Override Policy'); $enterProductSearchQueryMessage = $this->__('Please enter Product Title or ASIN/ISBN/UPC/EAN.'); $autoMapAsinSearchProducts = $this->__('Search %product_title% Product(s) on Amazon.'); $autoMapAsinProgressTitle = $this->__('Automatic Assigning ASIN/ISBN to Item(s)'); $autoMapAsinErrorMessage = $this->__('Server is currently unavailable. Please try again later.'); $newAsinNotAvailable = $this->__('The new ASIN/ISBN creation functionality is not available in %code% Marketplace yet.'); $notSynchronizedMarketplace = $this->__('In order to use New ASIN/ISBN functionality, please re-synchronize Marketplace data.') . ' ' . $this->__('Press "Save And Update" Button after redirect on Marketplace Page.'); $noVariationsLeftText = $this->__('All variations are already added.'); $notSet = $this->__('Not Set'); $setAttributes = $this->__('Set Attributes'); $variationManageMatchedAttributesError = $this->__('Please choose valid Attributes.'); $variationManageMatchedAttributesErrorDuplicateSelection = $this->__('You can not choose the same Attribute twice.'); $variationManageSkuPopUpTitle = $this->__('Enter Amazon Parent Product SKU'); $switchToIndividualModePopUpTitle = $this->__('Change "Manage Variations" Mode'); $switchToParentModePopUpTitle = $this->__('Change "Manage Variations" Mode'); $emptySkuError = $this->__('Please enter Amazon Parent Product SKU.'); $this->jsTranslator->addTranslations(['Remove Category' => $this->__('Remove Category'), 'Add New Group' => $this->__('Add New Group'), 'Add/Edit Categories Rule' => $this->__('Add/Edit Categories Rule'), 'Auto Add/Remove Rules' => $this->__('Auto Add/Remove Rules'), 'Based on Magento Categories' => $this->__('Based on Magento Categories'), 'You must select at least 1 Category.' => $this->__('You must select at least 1 Category.'), 'Rule with the same Title already exists.' => $this->__('Rule with the same Title already exists.'), 'Clear Search Results' => $this->__('Clear Search Results'), 'popup_title' => $popupTitle, 'popup_title_single' => $popupTitleSingle, 'failed_products_popup_title' => $failedProductsPopupTitle, 'task_completed_message' => $taskCompletedMessage, 'task_completed_success_message' => $taskCompletedSuccessMessage, 'task_completed_warning_message' => $taskCompletedWarningMessage, 'task_completed_error_message' => $taskCompletedErrorMessage, 'locked_obj_notice' => $lockedObjNoticeMessage, 'sending_data_message' => $sendingDataToAmazonMessage, 'view_all_product_log_message' => $viewAllProductLogMessage, 'listing_locked_message' => $listingLockedMessage, 'listing_empty_message' => $listingEmptyMessage, 'listing_all_items_message' => $listingAllItemsMessage, 'listing_selected_items_message' => $listingSelectedItemsMessage, 'revising_selected_items_message' => $revisingSelectedItemsMessage, 'relisting_selected_items_message' => $relistingSelectedItemsMessage, 'stopping_selected_items_message' => $stoppingSelectedItemsMessage, 'stopping_and_removing_selected_items_message' => $stoppingAndRemovingSelectedItemsMessage, 'deleting_and_removing_selected_items_message' => $deletingAndRemovingSelectedItemsMessage, 'removing_selected_items_message' => $removingSelectedItemsMessage, 'successfully_moved' => $successfullyMovedMessage, 'products_were_not_moved' => $productsWereNotMovedMessage, 'some_products_were_not_moved' => $someProductsWereNotMovedMessage, 'select_items_message' => $selectItemsMessage, 'select_action_message' => $selectActionMessage, 'templateDescriptionPopupTitle' => $templateDescriptionPopupTitle, 'templateShippingOverridePopupTitle' => $templateShippingOverridePopupTitle, 'assign' => $assignString, 'enter_productSearch_query' => $enterProductSearchQueryMessage, 'automap_asin_search_products' => $autoMapAsinSearchProducts, 'automap_asin_progress_title' => $autoMapAsinProgressTitle, 'automap_error_message' => $autoMapAsinErrorMessage, 'new_asin_not_available' => $newAsinNotAvailable, 'not_synchronized_marketplace' => $notSynchronizedMarketplace, 'no_variations_left' => $noVariationsLeftText, 'not_set' => $notSet, 'set_attributes' => $setAttributes, 'variation_manage_matched_attributes_error' => $variationManageMatchedAttributesError, 'variation_manage_matched_attributes_error_duplicate' => $variationManageMatchedAttributesErrorDuplicateSelection, 'error_changing_product_options' => $this->__('Please Select Product Options.'), 'variation_manage_matched_sku_popup_title' => $variationManageSkuPopUpTitle, 'empty_sku_error' => $emptySkuError, 'switch_to_individual_mode_popup_title' => $switchToIndividualModePopUpTitle, 'switch_to_parent_mode_popup_title' => $switchToParentModePopUpTitle, 'Add New Description Policy' => $this->__('Add New Description Policy'), 'Add New Child Product' => $this->__('Add New Child Product')]); $this->js->addOnReadyJs(<<<JS require([ 'M2ePro/Amazon/Listing/View/Grid', 'M2ePro/Amazon/Listing/AfnQty', 'M2ePro/Amazon/Listing/AutoAction', 'M2ePro/Amazon/Listing/Product/Variation' ], function(){ M2ePro.productsIdsForList = '{$productsIdsForList}'; M2ePro.customData.componentMode = '{$component}'; M2ePro.customData.gridId = '{$gridId}'; M2ePro.customData.ignoreListings = '{$ignoreListings}'; M2ePro.customData.marketplace = {$marketplace}; M2ePro.customData.isNewAsinAvailable = {$isNewAsinAvailable}; ListingGridHandlerObj = new AmazonListingViewGrid( '{$gridId}', {$this->listing['id']} ); ListingGridHandlerObj.afterInitPage(); ListingGridHandlerObj.movingHandler.setOptions(M2ePro); ListingGridHandlerObj.actionHandler.setProgressBar('listing_view_progress_bar'); ListingGridHandlerObj.actionHandler.setGridWrapper('listing_view_content_container'); AmazonListingProductVariationObj = new AmazonListingProductVariation(ListingGridHandlerObj); if (M2ePro.productsIdsForList) { ListingGridHandlerObj.getGridMassActionObj().checkedString = M2ePro.productsIdsForList; ListingGridHandlerObj.actionHandler.listAction(); } window.ListingAutoActionObj = new AmazonListingAutoAction(); if ({$showAutoAction}) { ListingAutoActionObj.loadAutoActionHtml(); } AmazonListingAfnQtyObj = new AmazonListingAfnQty(); // TODO // CommonAmazonListingRepricingPriceHandlerObj = new CommonAmazonListingRepricingPriceHandler(); }); JS ); $productSearchBlock = $this->createBlock('Amazon\\Listing\\Product\\Search\\Main'); // TODO NOT SUPPORTED FEATURES "Listing header selector" // // --------------------------------------- // $listingSwitcher = $this->getLayout()->createBlock( // 'M2ePro/adminhtml_common_amazon_listing_view_listingSwitcher' // ); // // --------------------------------------- // --------------------------------------- $viewHeaderBlock = $this->createBlock('Listing\\View\\Header', '', ['data' => ['listing' => $this->listing]]); // --------------------------------------- // // --------------------------------------- // $switchToIndividualPopup = $this->getLayout()->createBlock( // 'M2ePro/adminhtml_common_amazon_listing_variation_product_switchToIndividualPopup'); // // --------------------------------------- // // // --------------------------------------- // $switchToParentPopup = $this->getLayout()->createBlock( // 'M2ePro/adminhtml_common_amazon_listing_variation_product_switchToParentPopup'); // // --------------------------------------- return $viewHeaderBlock->toHtml() . $productSearchBlock->toHtml() . parent::getGridHtml(); }