public function callbackColumnProductId($value, $row, $column, $isExport) { $productId = (int) $row->getData('entity_id'); $storeId = (int) $this->listing->getData('store_id'); $url = $this->getUrl('adminhtml/catalog_product/edit', array('id' => $productId)); $htmlWithoutThumbnail = '<a href="' . $url . '" target="_blank">' . $productId . '</a>'; $showProductsThumbnails = (bool) (int) Mage::helper('M2ePro/Module')->getConfig()->getGroupValue('/view/', 'show_products_thumbnails'); if (!$showProductsThumbnails) { return $htmlWithoutThumbnail; } /** @var $magentoProduct Ess_M2ePro_Model_Magento_Product */ $magentoProduct = Mage::getModel('M2ePro/Magento_Product'); $magentoProduct->setProductId($productId); $magentoProduct->setStoreId($storeId); $thumbnail = $magentoProduct->getThumbnailImageLink(); if (is_null($thumbnail)) { return $htmlWithoutThumbnail; } return <<<HTML <a href="{$url}" target="_blank"> {$productId} <hr style="border: 1px solid silver; border-bottom: none;"> <img src="{$thumbnail}" /> </a> HTML; }
/** * @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_Amazon_Listing_Auto_Actions_Listing $object */ $object = Mage::getModel('M2ePro/' . $componentMode . '_Listing_Auto_Actions_Listing'); $object->setListing($listing); return $object; }
/** * @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); }
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); }
/** * @return Ess_M2ePro_Model_Ebay_Listing_Product_Action_Logger */ protected function getLogger() { if (is_null($this->logger)) { /** @var Ess_M2ePro_Model_Ebay_Listing_Product_Action_Logger $logger */ $logger = Mage::getModel('M2ePro/Ebay_Listing_Product_Action_Logger'); if (isset($this->params['logs_action_id'])) { $logger->setActionId((int) $this->params['logs_action_id']); } else { $logger->setActionId(Mage::getModel('M2ePro/Listing_Log')->getNextActionId()); } $logger->setAction($this->getLogAction()); switch ($this->params['status_changer']) { case Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_UNKNOWN: $initiator = Ess_M2ePro_Helper_Data::INITIATOR_UNKNOWN; break; case Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_USER: $initiator = Ess_M2ePro_Helper_Data::INITIATOR_USER; break; default: $initiator = Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION; break; } $logger->setInitiator($initiator); $logger->setListingId($this->listing->getId()); $this->logger = $logger; } return $this->logger; }
private function addBaseListingsLogsMessage($listingProduct, array $message, $priority = Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM) { $action = $this->getListingsLogsCurrentAction(); is_null($action) && ($action = Ess_M2ePro_Model_Listing_Log::ACTION_UNKNOWN); if (!isset($message[parent::MESSAGE_TEXT_KEY]) || $message[parent::MESSAGE_TEXT_KEY] == '') { return; } $text = $message[parent::MESSAGE_TEXT_KEY]; if (!isset($message[parent::MESSAGE_TYPE_KEY]) || $message[parent::MESSAGE_TYPE_KEY] == '') { return; } $type = Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR; switch ($message[parent::MESSAGE_TYPE_KEY]) { case parent::MESSAGE_TYPE_ERROR: $type = Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR; $this->setStatus(self::STATUS_ERROR); break; case parent::MESSAGE_TYPE_WARNING: $type = Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING; $this->setStatus(self::STATUS_WARNING); break; case parent::MESSAGE_TYPE_SUCCESS: $type = Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS; $this->setStatus(self::STATUS_SUCCESS); break; case parent::MESSAGE_TYPE_NOTICE: $type = Ess_M2ePro_Model_Log_Abstract::TYPE_NOTICE; $this->setStatus(self::STATUS_SUCCESS); break; default: $type = Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR; $this->setStatus(self::STATUS_ERROR); break; } $initiator = Ess_M2ePro_Model_Log_Abstract::INITIATOR_UNKNOWN; if ($this->params['status_changer'] == Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_UNKNOWN) { $initiator = Ess_M2ePro_Model_Log_Abstract::INITIATOR_UNKNOWN; } else { if ($this->params['status_changer'] == Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_USER) { $initiator = Ess_M2ePro_Model_Log_Abstract::INITIATOR_USER; } else { $initiator = Ess_M2ePro_Model_Log_Abstract::INITIATOR_EXTENSION; } } $logModel = Mage::getModel('M2ePro/Listing_Log'); $logModel->setComponentMode(Ess_M2ePro_Helper_Component_Ebay::NICK); if (is_null($listingProduct)) { $logModel->addListingMessage($this->listing->getId(), $initiator, $this->logsActionId, $action, $text, $type, $priority); } else { $logModel->addProductMessage($this->listing->getId(), $listingProduct->getProductId(), $listingProduct->getId(), $initiator, $this->logsActionId, $action, $text, $type, $priority); } }
public function getAddProductsDropDownItems() { $items = array(); //------------------------------ $url = $this->getUrl('*/adminhtml_ebay_listing_productAdd', array('source' => 'products', 'clear' => true, 'listing_id' => $this->listing->getId())); $items[] = array('url' => $url, 'label' => Mage::helper('M2ePro')->__('From Products List')); //------------------------------ //------------------------------ $url = $this->getUrl('*/adminhtml_ebay_listing_productAdd', array('source' => 'categories', 'clear' => true, 'listing_id' => $this->listing->getId())); $items[] = array('url' => $url, 'label' => Mage::helper('M2ePro')->__('From Categories')); //------------------------------ return $items; }
public function fillCategoriesPaths(array &$data, Ess_M2ePro_Model_Listing $listing) { $ebayCategoryHelper = Mage::helper('M2ePro/Component_Ebay_Category_Ebay'); $ebayStoreCategoryHelper = Mage::helper('M2ePro/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 = Mage::helper('M2ePro/Magento_Attribute')->getAttributeLabel($data[$key . '_attribute'], $listing->getStoreId()); $data[$key . '_path'] = 'Magento Attribute' . ' -> ' . $attributeLabel; } } }
protected function _toHtml() { //------------------------------ $urls = Mage::helper('M2ePro')->getControllerActions('adminhtml_ebay_listing_categorySettings', array('_current' => true)); $path = 'adminhtml_ebay_listing_categorySettings'; $urls[$path] = $this->getUrl('*/' . $path, array('step' => 3, '_current' => true)); $path = 'adminhtml_ebay_category/getChooserEditHtml'; $urls[$path] = $this->getUrl('*/' . $path, array('account_id' => $this->listing->getAccountId(), 'marketplace_id' => $this->listing->getMarketplaceId())); $urls = json_encode($urls); //------------------------------ //------------------------------ $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] = Mage::helper('M2ePro')->__($text); // M2ePro_TRANSLATIONS // Are you sure? $text = 'Are you sure?'; $translations[$text] = Mage::helper('M2ePro')->__($text); // M2ePro_TRANSLATIONS // eBay could not assign categories for %product_tite% products. $text = 'eBay could not assign categories for %product_title% products.'; $translations[$text] = Mage::helper('M2ePro')->__($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] = Mage::helper('M2ePro')->__($text); // M2ePro_TRANSLATIONS // Set eBay Category $text = 'Set eBay Category'; $translations[$text] = Mage::helper('M2ePro')->__($text); // M2ePro_TRANSLATIONS // Set eBay Category for Product(s) $text = 'Set eBay Category for Product(s)'; $translations[$text] = Mage::helper('M2ePro')->__($text); // M2ePro_TRANSLATIONS // Set eBay Primary Category for Product(s) $text = 'Set eBay Primary Category for Product(s)'; $translations[$text] = Mage::helper('M2ePro')->__($text); $translations = json_encode($translations); //------------------------------ //------------------------------ $constants = Mage::helper('M2ePro')->getClassConstantAsJson('Ess_M2ePro_Helper_Component_Ebay_Category'); //------------------------------ $getSuggested = json_encode((bool) Mage::helper('M2ePro/Data_Global')->getValue('get_suggested')); $commonJs = <<<HTML <script type="text/javascript"> EbayListingCategoryProductGridHandlerObj.afterInitPage(); EbayListingCategoryProductGridHandlerObj.getGridMassActionObj().setGridIds('{$this->getGridIdsJson()}'); </script> HTML; $additionalJs = ''; if (!$this->getRequest()->isXmlHttpRequest()) { $additionalJs = <<<HTML <script type="text/javascript"> M2ePro.url.add({$urls}); M2ePro.translator.add({$translations}); M2ePro.php.setConstants({$constants},'Ess_M2ePro_Helper_Component_Ebay_Category'); WrapperObj = new AreaWrapper('products_container'); ProgressBarObj = new ProgressBar('products_progress_bar'); EbayListingCategoryProductGridHandlerObj = new EbayListingCategoryProductGridHandler('{$this->getId()}'); EbayListingCategoryProductSuggestedSearchHandlerObj = new EbayListingCategoryProductSuggestedSearchHandler(); if ({$getSuggested}) { Event.observe(window, 'load', function() { EbayListingCategoryProductGridHandlerObj.getSuggestedCategoriesForAll(); }); } </script> HTML; } return parent::_toHtml() . $additionalJs . $commonJs; }
private function addCategoriesPath(&$templateData, Ess_M2ePro_Model_Listing $listing) { $marketplaceId = $listing->getData('marketplace_id'); $accountId = $listing->getAccountId(); if (isset($templateData['category_main_mode'])) { if ($templateData['category_main_mode'] == Ess_M2ePro_Model_Ebay_Template_Category::CATEGORY_MODE_EBAY) { $templateData['category_main_path'] = Mage::helper('M2ePro/Component_Ebay_Category_Ebay')->getPath($templateData['category_main_id'], $marketplaceId); } else { $templateData['category_main_path'] = null; } } if (isset($templateData['category_secondary_mode'])) { if ($templateData['category_secondary_mode'] == Ess_M2ePro_Model_Ebay_Template_Category::CATEGORY_MODE_EBAY) { $templateData['category_secondary_path'] = Mage::helper('M2ePro/Component_Ebay_Category_Ebay')->getPath($templateData['category_secondary_id'], $marketplaceId); } else { $templateData['category_secondary_path'] = null; } } if (isset($templateData['store_category_main_mode'])) { if ($templateData['store_category_main_mode'] == Ess_M2ePro_Model_Ebay_Template_Category::CATEGORY_MODE_EBAY) { $templateData['store_category_main_path'] = Mage::helper('M2ePro/Component_Ebay_Category_Store')->getPath($templateData['store_category_main_id'], $accountId); } else { $templateData['store_category_main_path'] = null; } } if (isset($templateData['store_category_secondary_mode'])) { if ($templateData['store_category_secondary_mode'] == Ess_M2ePro_Model_Ebay_Template_Category::CATEGORY_MODE_EBAY) { $templateData['store_category_secondary_path'] = Mage::helper('M2ePro/Component_Ebay_Category_Store')->getPath($templateData['store_category_secondary_id'], $accountId); } else { $templateData['store_category_secondary_path'] = null; } } }
public function deleteProductFromListing(Ess_M2ePro_Model_Listing $listing, Mage_Catalog_Model_Product $productNew, $deletingMode) { if ($deletingMode == Ess_M2ePro_Model_Ebay_Listing::DELETING_MODE_NONE) { return; } $listingsProducts = $listing->getProducts(true, array('product_id' => (int) $productNew->getId())); if (count($listingsProducts) <= 0) { return; } foreach ($listingsProducts as $listingProduct) { if (!$listingProduct instanceof Ess_M2ePro_Model_Listing_Product) { return; } try { if ($deletingMode == Ess_M2ePro_Model_Ebay_Listing::DELETING_MODE_STOP) { $listingProduct->isStoppable() && Mage::getModel('M2ePro/StopQueue')->add($listingProduct); } if ($deletingMode == Ess_M2ePro_Model_Ebay_Listing::DELETING_MODE_STOP_REMOVE) { $listingProduct->isStoppable() && Mage::getModel('M2ePro/StopQueue')->add($listingProduct); $listingProduct->addData(array('status' => Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED))->save(); $listingProduct->deleteInstance(); } } catch (Exception $exception) { } } }
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); } }