コード例 #1
0
 private function match()
 {
     $this->validate();
     /** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Matcher_Attribute $attributeMatcher */
     $attributeMatcher = Mage::getModel('M2ePro/Amazon_Listing_Product_Variation_Matcher_Attribute');
     if (!is_null($this->magentoProduct)) {
         if ($this->magentoProduct->isGroupedType()) {
             $this->matchedTheme = null;
             return $this;
         }
         $attributeMatcher->setMagentoProduct($this->magentoProduct);
     }
     if (!empty($this->sourceAttributes)) {
         $attributeMatcher->setSourceAttributes($this->sourceAttributes);
         $attributeMatcher->canUseDictionary(false);
     }
     foreach ($this->themes as $themeName => $themeAttributes) {
         $attributeMatcher->setDestinationAttributes($themeAttributes['attributes']);
         if ($attributeMatcher->isAmountEqual() && $attributeMatcher->isFullyMatched()) {
             $this->matchedTheme = $themeName;
             break;
         }
     }
     return $this;
 }
コード例 #2
0
 private function getDescription(Ess_M2ePro_Model_Magento_Product $magentoProduct, Ess_M2ePro_Model_Listing_Product $listingProduct = NULL)
 {
     $descriptionTemplateData = $this->_getSession()->getTemplateData();
     $descriptionModeProduct = Ess_M2ePro_Model_Ebay_Template_Description::DESCRIPTION_MODE_PRODUCT;
     $descriptionModeShort = Ess_M2ePro_Model_Ebay_Template_Description::DESCRIPTION_MODE_SHORT;
     $descriptionModeCustom = Ess_M2ePro_Model_Ebay_Template_Description::DESCRIPTION_MODE_CUSTOM;
     if ($descriptionTemplateData['description_mode'] == $descriptionModeProduct) {
         $description = $magentoProduct->getProduct()->getDescription();
     } elseif ($descriptionTemplateData['description_mode'] == $descriptionModeShort) {
         $description = $magentoProduct->getProduct()->getShortDescription();
     } elseif ($descriptionTemplateData['description_mode'] == $descriptionModeCustom) {
         $description = $descriptionTemplateData['description_template'];
     } else {
         $description = '';
     }
     if (empty($description)) {
         return $description;
     }
     $renderer = Mage::helper('M2ePro/Module_Renderer_Description');
     $description = $renderer->parseTemplate($description, $magentoProduct);
     if (!is_null($listingProduct)) {
         /** @var Ess_M2ePro_Model_Ebay_Listing_Product_Description_Renderer $renderer */
         $renderer = Mage::getSingleton('M2ePro/Ebay_Listing_Product_Description_Renderer');
         $renderer->setListingProduct($listingProduct->getChildObject());
         $description = $renderer->parseTemplate($description);
     }
     $this->addWatermarkInfoToDescriptionIfNeed($description);
     return $description;
 }
コード例 #3
0
 protected function getBundleProductDynamicSpecialValue(Ess_M2ePro_Model_Magento_Product $product)
 {
     if ($this->getIsSalePrice() && !$product->isSpecialPriceActual()) {
         return 0;
     }
     return parent::getBundleProductDynamicSpecialValue($product);
 }
コード例 #4
0
ファイル: Option.php プロジェクト: newedge-media/iwantmymeds
 private function getSourceOptionNames($sourceOption)
 {
     $magentoOptionNames = $this->magentoProduct->getVariationInstance()->getTitlesVariationSet();
     $resultNames = array();
     foreach ($magentoOptionNames as $attribute => $data) {
         $resultNames[$attribute] = $this->prepareOptionNames($sourceOption[$attribute], $data['values'][$sourceOption[$attribute]]);
     }
     return $resultNames;
 }
コード例 #5
0
ファイル: Service.php プロジェクト: ppkowalski/M2E
 /**
  * @param Ess_M2ePro_Model_Magento_Product $magentoProduct
  * @return Ess_M2ePro_Model_Ebay_Template_Shipping_Service_Source
  */
 public function getSource(Ess_M2ePro_Model_Magento_Product $magentoProduct)
 {
     $productId = $magentoProduct->getProductId();
     if (!empty($this->shippingServiceSourceModels[$productId])) {
         return $this->shippingServiceSourceModels[$productId];
     }
     $this->shippingServiceSourceModels[$productId] = Mage::getModel('M2ePro/Ebay_Template_Shipping_Service_Source');
     $this->shippingServiceSourceModels[$productId]->setMagentoProduct($magentoProduct);
     $this->shippingServiceSourceModels[$productId]->setShippingServiceTemplate($this);
     return $this->shippingServiceSourceModels[$productId];
 }
コード例 #6
0
 /**
  * @param Ess_M2ePro_Model_Magento_Product $magentoProduct
  * @return Ess_M2ePro_Model_Amazon_Template_Description_Specific_Source
  */
 public function getSource(Ess_M2ePro_Model_Magento_Product $magentoProduct)
 {
     $productId = $magentoProduct->getProductId();
     if (!empty($this->descriptionSpecificSourceModels[$productId])) {
         return $this->descriptionSpecificSourceModels[$productId];
     }
     $this->descriptionSpecificSourceModels[$productId] = Mage::getModel('M2ePro/Amazon_Template_Description_Specific_Source');
     $this->descriptionSpecificSourceModels[$productId]->setMagentoProduct($magentoProduct);
     $this->descriptionSpecificSourceModels[$productId]->setDescriptionSpecificTemplate($this);
     return $this->descriptionSpecificSourceModels[$productId];
 }
コード例 #7
0
 /**
  * @param Ess_M2ePro_Model_Magento_Product $magentoProduct
  * @return Ess_M2ePro_Model_Buy_Template_NewProduct_Attribute_Source
  */
 public function getSource(Ess_M2ePro_Model_Magento_Product $magentoProduct)
 {
     $productId = $magentoProduct->getProductId();
     if (!empty($this->newProductAttributeSourceModels[$productId])) {
         return $this->newProductAttributeSourceModels[$productId];
     }
     $this->newProductAttributeSourceModels[$productId] = Mage::getModel('M2ePro/Buy_Template_NewProduct_Attribute_Source');
     $this->newProductAttributeSourceModels[$productId]->setMagentoProduct($magentoProduct);
     $this->newProductAttributeSourceModels[$productId]->setNewProductAttributeTemplate($this);
     return $this->newProductAttributeSourceModels[$productId];
 }
コード例 #8
0
ファイル: Specific.php プロジェクト: ppkowalski/M2E
 /**
  * @param Ess_M2ePro_Model_Magento_Product $magentoProduct
  * @return Ess_M2ePro_Model_Ebay_Template_Category_Specific_Source
  */
 public function getSource(Ess_M2ePro_Model_Magento_Product $magentoProduct)
 {
     $productId = $magentoProduct->getProductId();
     if (!empty($this->categorySpecificSourceModels[$productId])) {
         return $this->categorySpecificSourceModels[$productId];
     }
     $this->categorySpecificSourceModels[$productId] = Mage::getModel('M2ePro/Ebay_Template_Category_Specific_Source');
     $this->categorySpecificSourceModels[$productId]->setMagentoProduct($magentoProduct);
     $this->categorySpecificSourceModels[$productId]->setCategorySpecificTemplate($this);
     return $this->categorySpecificSourceModels[$productId];
 }
コード例 #9
0
ファイル: Listing.php プロジェクト: ppkowalski/M2E
 /**
  * @param Ess_M2ePro_Model_Magento_Product $magentoProduct
  * @return Ess_M2ePro_Model_Play_Listing_Source
  */
 public function getSource(Ess_M2ePro_Model_Magento_Product $magentoProduct)
 {
     $productId = $magentoProduct->getProductId();
     if (!empty($this->listingSourceModels[$productId])) {
         return $this->listingSourceModels[$productId];
     }
     $this->listingSourceModels[$productId] = Mage::getModel('M2ePro/Play_Listing_Source');
     $this->listingSourceModels[$productId]->setMagentoProduct($magentoProduct);
     $this->listingSourceModels[$productId]->setListing($this->getParentObject());
     return $this->listingSourceModels[$productId];
 }
コード例 #10
0
ファイル: Item.php プロジェクト: newedge-media/iwantmymeds
 public function getMagentoProduct()
 {
     if (is_null($this->getProductId())) {
         return NULL;
     }
     if (is_null($this->magentoProduct)) {
         $this->magentoProduct = Mage::getModel('M2ePro/Magento_Product');
         $this->magentoProduct->setStoreId($this->getOrder()->getStoreId())->setProductId($this->getProductId());
     }
     return $this->magentoProduct;
 }
コード例 #11
0
 private function getSourceAttributesData()
 {
     if (!is_null($this->magentoProduct)) {
         $magentoAttributesNames = $this->magentoProduct->getVariationInstance()->getTitlesVariationSet();
         $resultData = array();
         foreach ($magentoAttributesNames as $attribute => $data) {
             $resultData[$attribute] = $data['titles'];
         }
         return $resultData;
     }
     return array_fill_keys($this->sourceAttributes, array());
 }
コード例 #12
0
 private function getSourceOptionNames($sourceOption)
 {
     $magentoOptionNames = $this->magentoProduct->getVariationInstance()->getTitlesVariationSet();
     $resultNames = array();
     foreach ($sourceOption as $attribute => $option) {
         $names = array();
         if (isset($magentoOptionNames[$attribute])) {
             $names = $magentoOptionNames[$attribute]['values'][$option];
         }
         $resultNames[$attribute] = $this->prepareOptionNames($option, $names);
     }
     return $resultNames;
 }
コード例 #13
0
 private function getSourceAttributesData()
 {
     if (!is_null($this->magentoProduct)) {
         $magentoAttributesNames = $this->magentoProduct->getVariationInstance()->getTitlesVariationSet();
         $magentoStandardVariations = $this->magentoProduct->getVariationInstance()->getVariationsTypeStandard();
         $resultData = array();
         foreach (array_keys($magentoStandardVariations['set']) as $attribute) {
             $titles = array();
             if (isset($magentoAttributesNames[$attribute])) {
                 $titles = $magentoAttributesNames[$attribute]['titles'];
             }
             $resultData[$attribute] = $titles;
         }
         return $resultData;
     }
     return array_fill_keys($this->getSourceAttributes(), array());
 }
コード例 #14
0
 private function getGroupedAssociatedProduct()
 {
     $variationName = array_shift($this->variation);
     //------------------------------
     $configGroup = '/order/magento/settings/';
     $configKey = 'create_with_first_product_options_when_variation_unavailable';
     $configValue = Mage::helper('M2ePro/Module')->getConfig()->getGroupValue($configGroup, $configKey);
     if ((is_null($variationName) || strlen(trim($variationName)) == 0) && !$configValue) {
         return null;
     }
     //------------------------------
     $associatedProducts = $this->magentoProduct->getProductVariationsForOrder();
     foreach ($associatedProducts as $product) {
         // return product if it's name is equal to variation name
         if (is_null($variationName) || trim(strtolower($product->getName())) == trim(strtolower($variationName))) {
             return $product;
         }
     }
     return null;
 }
コード例 #15
0
ファイル: Item.php プロジェクト: xiaoguizhidao/beut
 private function getOptions(Ess_M2ePro_Model_Magento_Product $magentoProduct)
 {
     $variation = $this->proxyItem->getLowerCasedVariation();
     $magentoOptions = $magentoProduct->getProductVariationsForOrder();
     // Variation info unavailable - return first value for each required option
     // ---------------
     if (empty($variation)) {
         $firstOptions = array();
         foreach ($magentoOptions as $option) {
             $firstOptions[$option['option_id']] = $option['values'][0]['value_id'];
         }
         return $firstOptions;
     }
     // ---------------
     // Map variation with magento options
     // ---------------
     $mappedOptions = array();
     foreach ($magentoOptions as $option) {
         $optionValueLabel = $this->getMappedOptionValueLabel($variation, $option['labels']);
         if ($optionValueLabel == '') {
             continue;
         }
         $optionValueId = $this->getMappedOptionValueId($optionValueLabel, $option['values']);
         if (is_null($optionValueId)) {
             continue;
         }
         $mappedOptions[$option['option_id']] = $optionValueId;
     }
     // ---------------
     return $mappedOptions;
 }
コード例 #16
0
ファイル: Description.php プロジェクト: aligent/M2E
 private function insertMediaGalleries($text, Ess_M2ePro_Model_Magento_Product $magentoProduct)
 {
     preg_match_all("/#media_gallery\\[(.*?)\\]#/", $text, $matches);
     if (!count($matches[0])) {
         return $text;
     }
     $blockObj = Mage::getSingleton('core/layout')->createBlock('M2ePro/adminhtml_renderer_description_gallery');
     $search = array();
     $replace = array();
     $attributeCounter = 0;
     foreach ($matches[0] as $key => $match) {
         $tempMediaGalleryAttributes = explode(',', $matches[1][$key]);
         $realMediaGalleryAttributes = array();
         for ($i = 0; $i < 8; $i++) {
             if (!isset($tempMediaGalleryAttributes[$i])) {
                 $realMediaGalleryAttributes[$i] = '';
             } else {
                 $realMediaGalleryAttributes[$i] = $tempMediaGalleryAttributes[$i];
             }
         }
         $imagesQty = (int) $realMediaGalleryAttributes[5];
         if ($imagesQty == self::IMAGES_QTY_ALL) {
             $imagesQty = $realMediaGalleryAttributes[3] == self::IMAGES_MODE_GALLERY ? 100 : 25;
         }
         $galleryImagesLinks = $magentoProduct->getGalleryImagesLinks($imagesQty);
         if (!count($galleryImagesLinks)) {
             $search = $matches[0];
             $replace = '';
             break;
         }
         if (!in_array($realMediaGalleryAttributes[4], array(self::LAYOUT_MODE_ROW, self::LAYOUT_MODE_COLUMN))) {
             $realMediaGalleryAttributes[4] = self::LAYOUT_MODE_ROW;
         }
         $data = array('width' => (int) $realMediaGalleryAttributes[0], 'height' => (int) $realMediaGalleryAttributes[1], 'margin' => (int) $realMediaGalleryAttributes[2], 'linked_mode' => (int) $realMediaGalleryAttributes[3], 'layout' => $realMediaGalleryAttributes[4], 'gallery_hint' => trim($realMediaGalleryAttributes[6], '"'), 'watermark' => (int) $realMediaGalleryAttributes[7], 'images_count' => count($galleryImagesLinks), 'image_counter' => 0);
         $tempHtml = '';
         $attributeCounter++;
         foreach ($galleryImagesLinks as $imageLink) {
             $data['image_counter']++;
             $data['attribute_counter'] = $attributeCounter;
             $data['src'] = $imageLink;
             $tempHtml .= $blockObj->addData($data)->toHtml();
         }
         $search[] = $match;
         $replace[] = preg_replace('/\\s{2,}/', '', $tempHtml);
     }
     $text = str_replace($search, $replace, $text);
     return $text;
 }
コード例 #17
0
 /**
  * @param Ess_M2ePro_Model_Magento_Product $magentoProduct
  * @return Ess_M2ePro_Model_Ebay_Template_Description_Source
  */
 public function getSource(Ess_M2ePro_Model_Magento_Product $magentoProduct)
 {
     $productId = $magentoProduct->getProductId();
     if (!empty($this->descriptionSourceModels[$productId])) {
         return $this->descriptionSourceModels[$productId];
     }
     $this->descriptionSourceModels[$productId] = Mage::getModel('M2ePro/Ebay_Template_Description_Source');
     $this->descriptionSourceModels[$productId]->setMagentoProduct($magentoProduct);
     $this->descriptionSourceModels[$productId]->setDescriptionTemplate($this->getParentObject());
     return $this->descriptionSourceModels[$productId];
 }
コード例 #18
0
ファイル: Reserve.php プロジェクト: xiaoguizhidao/bb
 private function changeProductQty(Ess_M2ePro_Model_Magento_Product $magentoProduct, Ess_M2ePro_Model_Magento_Product_StockItem $magentoStockItem, $action, $qty)
 {
     $result = true;
     switch ($action) {
         case self::ACTION_ADD:
             $magentoStockItem->addQty($qty, false);
             break;
         case self::ACTION_SUB:
             try {
                 $magentoStockItem->subtractQty($qty, false);
             } catch (Exception $e) {
                 $result = false;
                 $this->order->setActionRequired(true);
                 $this->order->addErrorLog('Qty for product "%name%" cannot be reserved. Reason: %msg%', array('!name' => $magentoProduct->getName(), 'msg' => $e->getMessage()));
             }
             break;
     }
     return $result;
 }
コード例 #19
0
ファイル: Cache.php プロジェクト: xiaoguizhidao/ecommerce
 protected function _getConfigurableOptionsForOrder()
 {
     $cacheKey = array(__METHOD__);
     if ($this->isCacheEnabled && !is_null($cacheResult = $this->getCache()->getData($cacheKey))) {
         return $cacheResult;
     }
     return $this->getCache()->setData($cacheKey, parent::_getConfigurableOptionsForOrder());
 }
コード例 #20
0
 protected function getBundleProductDynamicValue(Ess_M2ePro_Model_Magento_Product $product)
 {
     $value = 0;
     $variationsData = $product->getVariationInstance()->getVariationsTypeStandard();
     foreach ($variationsData['variations'] as $variation) {
         $variationValue = 0;
         foreach ($variation as $option) {
             /** @var $childProduct Ess_M2ePro_Model_Magento_Product */
             $childProduct = Mage::getModel('M2ePro/Magento_Product')->setProductId($option['product_id']);
             $optionValue = (double) $childProduct->getSpecialPrice();
             $optionValue <= 0 && ($optionValue = (double) $childProduct->getPrice());
             $variationValue += $optionValue;
         }
         if ($variationValue < $value || $value == 0) {
             $value = $variationValue;
         }
     }
     return $this->convertValueFromStoreToMarketplace($value);
 }
コード例 #21
0
 private function getVariationsStockAvailabilities(array $variationsProductsIds)
 {
     $productsIds = array();
     foreach ($variationsProductsIds as $variationProductsIds) {
         foreach ($variationProductsIds as $variationProductId) {
             $productsIds[] = $variationProductId;
         }
     }
     $productsIds = array_values(array_unique($productsIds));
     $catalogInventoryTable = Mage::getSingleton('core/resource')->getTableName('cataloginventory_stock_item');
     $select = $this->_getReadAdapter()->select()->from(array('cisi' => $catalogInventoryTable), array('product_id', 'is_in_stock', 'manage_stock', 'use_config_manage_stock'))->where('cisi.product_id IN (' . implode(',', $productsIds) . ')');
     $stocks = $select->query()->fetchAll();
     $variationsProductsStocks = array();
     foreach ($variationsProductsIds as $key => $variationProductsIds) {
         foreach ($variationProductsIds as $id) {
             $count = count($stocks);
             for ($i = 0; $i < $count; $i++) {
                 if ($stocks[$i]['product_id'] == $id) {
                     $stockAvailability = Ess_M2ePro_Model_Magento_Product::calculateStockAvailability($stocks[$i]['is_in_stock'], $stocks[$i]['manage_stock'], $stocks[$i]['use_config_manage_stock']);
                     $variationsProductsStocks[$key][] = $stockAvailability;
                     break;
                 }
             }
         }
     }
     $variationsStocks = array();
     foreach ($variationsProductsStocks as $key => $variationProductsStocks) {
         $variationsStocks[$key] = min($variationProductsStocks);
     }
     return $variationsStocks;
 }
コード例 #22
0
 private function getDescription($descriptionMode, $customDescription, Ess_M2ePro_Model_Magento_Product $magentoProduct, Ess_M2ePro_Model_Listing_Product $listingProduct = NULL)
 {
     $description = '';
     $descriptionModeProduct = Ess_M2ePro_Model_Ebay_Template_Description::DESCRIPTION_MODE_PRODUCT;
     $descriptionModeShort = Ess_M2ePro_Model_Ebay_Template_Description::DESCRIPTION_MODE_SHORT;
     $descriptionModeCustom = Ess_M2ePro_Model_Ebay_Template_Description::DESCRIPTION_MODE_CUSTOM;
     if ($descriptionModeProduct == $descriptionMode) {
         $description = $magentoProduct->getProduct()->getDescription();
     } elseif ($descriptionModeShort == $descriptionMode) {
         $description = $magentoProduct->getProduct()->getShortDescription();
     } elseif ($descriptionModeCustom == $descriptionMode) {
         $description = $customDescription;
     }
     if (empty($description)) {
         return $description;
     }
     $renderer = Mage::helper('M2ePro/Module_Renderer_Description');
     $description = $renderer->parseTemplate($description, $magentoProduct);
     if (!is_null($listingProduct)) {
         /** @var Ess_M2ePro_Model_Ebay_Listing_Product_Description_Renderer $renderer */
         $renderer = Mage::getSingleton('M2ePro/Ebay_Listing_Product_Description_Renderer');
         $renderer->setListingProduct($listingProduct->getChildObject());
         $description = $renderer->parseTemplate($description);
     }
     return $description;
 }