/**
  * @param Mage_Catalog_Model_Product $product
  * @param Ess_M2ePro_Model_Listing $listing
  * @throws Ess_M2ePro_Model_Exception_Logic
  */
 public function addProductByWebsiteListing(Mage_Catalog_Model_Product $product, Ess_M2ePro_Model_Listing $listing)
 {
     $listingProduct = $this->getListing()->addProduct($product);
     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);
 }
Esempio n. 2
0
 public function addProductByWebsiteListing(Mage_Catalog_Model_Product $product, Ess_M2ePro_Model_Listing $listing)
 {
     $listingProduct = $this->getListing()->addProduct($product);
     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);
 }
Esempio n. 3
0
    public function getGridHtml()
    {
        if ($this->getRequest()->isXmlHttpRequest()) {
            return parent::getGridHtml();
        }
        $html = '';
        //------------------------------
        $data = array('target_css_class' => 'edit_default_settings_drop_down', 'items' => $this->getDefaultSettingsButtonDropDownItems());
        $templatesDropDownBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_button_dropDown');
        $templatesDropDownBlock->setData($data);
        $html .= $templatesDropDownBlock->toHtml();
        //------------------------------
        //------------------------------
        $listingSwitcher = $this->getLayout()->createBlock('M2ePro/adminhtml_ebay_listing_view_listingSwitcher');
        $html .= $listingSwitcher->toHtml();
        //------------------------------
        //------------------------------
        $helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_ebay_listing_view_help');
        $html .= $helpBlock->toHtml();
        //------------------------------
        //------------------------------
        $viewHeaderBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_listing_view_header', '', array('listing' => Mage::helper('M2ePro/Data_Global')->getValue('temp_data')));
        $html .= $viewHeaderBlock->toHtml();
        //------------------------------
        //------------------------------
        if (Mage::helper('M2ePro/View_Ebay')->isSimpleMode()) {
            if ($this->listing->getChildObject()->isEstimatedFeesObtainRequired()) {
                $obtain = $this->getLayout()->createBlock('M2ePro/adminhtml_ebay_listing_view_fee_obtain');
                $obtain->setData('listing_id', $this->listing->getId());
                $html .= $obtain->toHtml();
            } elseif ($this->listing->getChildObject()->getEstimatedFees()) {
                $preview = $this->getLayout()->createBlock('M2ePro/adminhtml_ebay_listing_view_fee_preview');
                $preview->setData('fees', $this->listing->getChildObject()->getEstimatedFees());
                $preview->setData('product_name', $this->listing->getChildObject()->getEstimatedFeesSourceProductName());
                $html .= $preview->toHtml();
            }
        }
        //------------------------------
        //------------------------------
        $data = array('target_css_class' => 'add_products_drop_down', 'items' => $this->getAddProductsDropDownItems());
        $addProductsDropDownBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_button_dropDown');
        $addProductsDropDownBlock->setData($data);
        //------------------------------
        //------------------------------
        $urls = json_encode(array_merge(Mage::helper('M2ePro')->getControllerActions('adminhtml_ebay_listing', array('_current' => true)), Mage::helper('M2ePro')->getControllerActions('adminhtml_ebay_listing_autoAction', array('listing_id' => $this->getRequest()->getParam('id')))));
        //------------------------------
        //------------------------------
        $translations = json_encode(array('Automatic Actions' => $this->__('Automatic Actions'), '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.'), 'Compatibility Attribute' => $this->__('Compatibility Attribute')));
        //------------------------------
        $html .= <<<HTML
<script type="text/javascript">
    M2ePro.url.add({$urls});
    M2ePro.translator.add({$translations});
</script>
HTML;
        $javascript = '';
        if (!$this->getRequest()->isXmlHttpRequest()) {
            $html .= <<<HTML
<script type="text/javascript">
    EbayListingAutoActionHandlerObj = new EbayListingAutoActionHandler();
</script>
HTML;
        }
        //------------------------------
        return $html . $addProductsDropDownBlock->toHtml() . parent::getGridHtml() . $javascript;
    }
Esempio n. 4
0
    public function getGridHtml()
    {
        if ($this->getRequest()->isXmlHttpRequest()) {
            return parent::getGridHtml();
        }
        $html = '';
        //------------------------------
        $data = array('target_css_class' => 'edit_default_settings_drop_down', 'items' => $this->getDefaultSettingsButtonDropDownItems());
        $templatesDropDownBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_button_dropDown');
        $templatesDropDownBlock->setData($data);
        $html .= $templatesDropDownBlock->toHtml();
        //------------------------------
        //------------------------------
        $listingSwitcher = $this->getLayout()->createBlock('M2ePro/adminhtml_ebay_listing_view_listingSwitcher');
        $html .= $listingSwitcher->toHtml();
        //------------------------------
        //------------------------------
        $helpBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_ebay_listing_view_help');
        $html .= $helpBlock->toHtml();
        //------------------------------
        //------------------------------
        $viewHeaderBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_listing_view_header', '', array('listing' => Mage::helper('M2ePro/Data_Global')->getValue('temp_data')));
        $html .= $viewHeaderBlock->toHtml();
        //------------------------------
        //------------------------------
        if (Mage::helper('M2ePro/View_Ebay')->isSimpleMode()) {
            if ($this->listing->getChildObject()->isEstimatedFeesObtainRequired()) {
                $obtain = $this->getLayout()->createBlock('M2ePro/adminhtml_ebay_listing_view_fee_obtain');
                $obtain->setData('listing_id', $this->listing->getId());
                $html .= $obtain->toHtml();
            } elseif ($this->listing->getChildObject()->getEstimatedFees()) {
                $preview = $this->getLayout()->createBlock('M2ePro/adminhtml_ebay_listing_view_fee_preview');
                $preview->setData('fees', $this->listing->getChildObject()->getEstimatedFees());
                $preview->setData('product_name', $this->listing->getChildObject()->getEstimatedFeesSourceProductName());
                $html .= $preview->toHtml();
            }
        }
        //------------------------------
        //------------------------------
        $data = array('target_css_class' => 'add_products_drop_down', 'items' => $this->getAddProductsDropDownItems());
        $addProductsDropDownBlock = $this->getLayout()->createBlock('M2ePro/adminhtml_widget_button_dropDown');
        $addProductsDropDownBlock->setData($data);
        //------------------------------
        /** @var $helper Ess_M2ePro_Helper_Data */
        $helper = Mage::helper('M2ePro');
        //------------------------------
        $urls = json_encode(array_merge($helper->getControllerActions('adminhtml_ebay_listing', array('_current' => true)), $helper->getControllerActions('adminhtml_ebay_listing_autoAction', array('listing_id' => $this->getRequest()->getParam('id'))), $helper->getControllerActions('adminhtml_ebay_listing_transferring', array('listing_id' => $this->getRequest()->getParam('id'))), $helper->getControllerActions('adminhtml_ebay_account'), $helper->getControllerActions('adminhtml_ebay_listing_categorySettings'), $helper->getControllerActions('adminhtml_ebay_marketplace'), array('adminhtml_system_store/index' => Mage::helper('adminhtml')->getUrl('adminhtml/system_store/')), array('logViewUrl' => $this->getUrl('M2ePro/adminhtml_common_log/synchronization', array('back' => $helper->makeBackUrlParam('*/adminhtml_common_synchronization/index')))), array('runSynchNow' => $this->getUrl('M2ePro/adminhtml_common_marketplace/runSynchNow')), array('synchCheckProcessingNow' => $this->getUrl('M2ePro/adminhtml_common_synchronization/synchCheckProcessingNow'))));
        //------------------------------
        //------------------------------
        $translations = json_encode(array('Auto Add/Remove Rules' => $helper->__('Auto Add/Remove Rules'), 'Based on Magento Categories' => $helper->__('Based on Magento Categories'), 'You must select at least 1 Category.' => $helper->__('You must select at least 1 Category.'), 'Rule with the same Title already exists.' => $helper->__('Rule with the same Title already exists.'), 'Compatibility Attribute' => $helper->__('Compatibility Attribute'), 'Sell on Another eBay Site' => $helper->__('Sell on Another eBay Site'), 'Product' => $helper->__('Product'), 'Translation Service' => $helper->__('Translation Service'), 'You must select at least 1 Listing.' => $helper->__('You must select at least 1 Listing.'), 'Data migration.' => $helper->__('Data migration...'), 'Creating Policies in process. Please wait...' => $helper->__('Creating Policies in process. Please wait...'), 'Creating Translation Account in process. Please wait...' => $helper->__('Creating Translation Account in process. Please wait...'), 'Creating Listing in process. Please wait...' => $helper->__('Creating Listing in process. Please wait...'), 'Adding Products in process. Please wait...' => $helper->__('Adding Products in process. Please wait...'), 'Products failed to add' => $helper->__('Failed Products'), 'Migration success.' => $helper->__('The Products have been successfully added into Destination Listing.'), 'Migration error.' => $helper->__('The Products have not been added into Destination Listing' . ' because Products with the same Magento Product IDs already exist there.'), 'Some Products Categories Settings are not set or Attributes for Title or Description are empty.' => $helper->__('Some Products Categories Settings are not set' . ' or Attributes for Title or Description are empty.'), 'Another Synchronization Is Already Running.' => $helper->__('Another Synchronization Is Already Running.'), 'Getting information. Please wait ...' => $helper->__('Getting information. Please wait ...'), 'Preparing to start. Please wait ...' => $helper->__('Preparing to start. Please wait ...'), 'Synchronization has successfully ended.' => $helper->__('Synchronization has successfully ended.'), 'Synchronization ended with warnings. <a target="_blank" href="%url%">View Log</a> for details.' => $helper->__('Synchronization ended with warnings. <a target="_blank" href="%url%">View Log</a> for details.'), 'Synchronization ended with errors. <a target="_blank" href="%url%">View Log</a> for details.' => $helper->__('Synchronization ended with errors. <a target="_blank" href="%url%">View Log</a> for details.')));
        //------------------------------
        $html .= <<<HTML
<script type="text/javascript">
    M2ePro.url.add({$urls});
    M2ePro.translator.add({$translations});
</script>
HTML;
        $javascript = '';
        if (!$this->getRequest()->isXmlHttpRequest()) {
            $html .= <<<HTML
<script type="text/javascript">
    ListingAutoActionHandlerObj = new EbayListingAutoActionHandler();
</script>
HTML;
        }
        //------------------------------
        return $html . $addProductsDropDownBlock->toHtml() . parent::getGridHtml() . $javascript;
    }
Esempio n. 5
0
 private function getDataFromListing(Ess_M2ePro_Model_Listing $source, array $params = array())
 {
     //------------------------------
     $accountId = $source->getAccountId();
     $marketplaceId = $source->getMarketplaceId();
     $storeId = $source->getStoreId();
     $attributeSets = Mage::helper('M2ePro/Magento_AttributeSet')->getAll(Ess_M2ePro_Helper_Magento_Abstract::RETURN_TYPE_IDS);
     //------------------------------
     //------------------------------
     $templates = array();
     foreach (Mage::getSingleton('M2ePro/Ebay_Template_Manager')->getAllTemplates() as $nick) {
         $manager = Mage::getModel('M2ePro/Ebay_Template_Manager')->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);
 }
 private function setAutoActionData(Ess_M2ePro_Model_Listing $targetListing, Ess_M2ePro_Model_Listing $sourceListing, $isDifferentMarketplace = false)
 {
     /** @var Ess_M2ePro_Model_Ebay_Listing $sourceEbayListing */
     $sourceEbayListing = $sourceListing->getChildObject();
     $listingData = array('auto_mode' => $sourceListing->getAutoMode(), 'auto_global_adding_mode' => $sourceListing->getAutoGlobalAddingMode(), 'auto_global_adding_template_category_id' => $sourceEbayListing->getAutoGlobalAddingTemplateCategoryId(), 'auto_global_adding_template_other_category_id' => $sourceEbayListing->getAutoGlobalAddingTemplateOtherCategoryId(), 'auto_website_adding_mode' => $sourceListing->getAutoWebsiteAddingMode(), 'auto_website_adding_template_category_id' => $sourceEbayListing->getAutoWebsiteAddingTemplateCategoryId(), 'auto_website_adding_template_other_category_id' => $sourceEbayListing->getAutoWebsiteAddingTemplateOtherCategoryId(), 'auto_website_deleting_mode' => $sourceListing->getAutoWebsiteDeletingMode());
     if ($isDifferentMarketplace) {
         if ($sourceEbayListing->isAutoGlobalAddingModeAddAndAssignCategory()) {
             $listingData['auto_global_adding_mode'] = Ess_M2ePro_Model_Listing::ADDING_MODE_ADD;
             $listingData['auto_global_adding_template_category_id'] = NULL;
             $listingData['auto_global_adding_template_other_category_id'] = NULL;
         }
         if ($sourceEbayListing->isAutoWebsiteAddingModeAddAndAssignCategory()) {
             $listingData['auto_website_adding_mode'] = Ess_M2ePro_Model_Listing::ADDING_MODE_ADD;
             $listingData['auto_website_adding_template_category_id'] = NULL;
             $listingData['auto_website_adding_template_other_category_id'] = NULL;
         }
     }
     $targetListing->addData($listingData)->save();
     if ($sourceListing->isAutoModeCategory()) {
         $this->setAutoCategoryData($targetListing->getId(), $sourceListing->getId(), $isDifferentMarketplace);
     }
 }