예제 #1
0
 protected function _prepareCollection()
 {
     // Get collection
     // ---------------------------------------
     $collection = $this->productFactory->create()->getCollection()->addAttributeToSelect('name');
     // ---------------------------------------
     // ---------------------------------------
     $collection->getSelect()->distinct();
     // ---------------------------------------
     // Set filter store
     // ---------------------------------------
     $store = $this->_storeManager->getStore($this->listing->getData('store_id'));
     if ($store->getId()) {
         $collection->joinAttribute('custom_name', 'catalog_product/name', 'entity_id', NULL, 'inner', $store->getId());
         $collection->joinAttribute('thumbnail', 'catalog_product/thumbnail', 'entity_id', NULL, 'left', $store->getId());
     } else {
         $collection->addAttributeToSelect('thumbnail');
     }
     // ---------------------------------------
     // ---------------------------------------
     $productAddIds = (array) json_decode($this->listing->getChildObject()->getData('product_add_ids'), true);
     $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());
     $elpTable = $this->activeRecordFactory->getObject('Ebay\\Listing\\Product')->getResource()->getMainTable();
     $collection->joinTable(array('elp' => $elpTable), 'listing_product_id=id', array('listing_product_id' => 'listing_product_id'));
     $collection->getSelect()->where('lp.id IN (?)', $productAddIds);
     // ---------------------------------------
     // Set collection to grid
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }
예제 #2
0
 protected function getParam($paramName, $default = NULL)
 {
     $session = $this->getHelper('Data\\Session');
     $sessionParamName = $this->getId() . $this->listing->getId() . $paramName;
     if ($this->getRequest()->has($paramName)) {
         $param = $this->getRequest()->getParam($paramName);
         $session->setValue($sessionParamName, $param);
         return $param;
     } elseif ($param = $session->getValue($sessionParamName)) {
         return $param;
     }
     return $default;
 }
예제 #3
0
    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();
    }
예제 #4
0
 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;
 }
예제 #5
0
 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;
 }
예제 #6
0
    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();
    }