Exemple #1
0
 /**
  * Set current attribute to entry (for specified product)
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Google_Service_ShoppingContent_Product $shoppingProduct
  * @return Google_Service_ShoppingContent_Product
  */
 public function convertAttribute($product, $shoppingProduct)
 {
     $url = $product->getProductUrl(false);
     if ($url) {
         $config = Mage::getSingleton('googleshoppingapi/config');
         if (!Mage::getStoreConfigFlag('web/url/use_store') && $config->getAddStoreCodeToUrl()) {
             Mage::log($config->getAddStoreCodeToUrl() ? "true" : "false");
             $urlInfo = parse_url($url);
             $store = $product->getStore()->getCode();
             if (isset($urlInfo['query']) && $urlInfo['query'] != '') {
                 $url .= '&___store=' . $store;
             } else {
                 $url .= '?___store=' . $store;
             }
         }
         if ($config->getAddUtmSrcGshopping($product->getStoreId())) {
             $url .= '&utm_source=GoogleShopping';
         }
         if ($customUrlParameters = $config->getCustomUrlParameters($product->getStoreId())) {
             $url .= $customUrlParameters;
         }
         $shoppingProduct->setLink($url);
     }
     return $shoppingProduct;
 }
Exemple #2
0
 /**
  * Set current attribute to entry (for specified product)
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Varien_Gdata_Gshopping_Entry $entry
  * @return Varien_Gdata_Gshopping_Entry
  */
 public function convertAttribute($product, $entry)
 {
     $url = $product->getProductUrl(false);
     if ($url) {
         if (!Mage::getStoreConfigFlag('web/url/use_store')) {
             $urlInfo = parse_url($url);
             $store = $product->getStore()->getCode();
             if (isset($urlInfo['query']) && $urlInfo['query'] != '') {
                 $url .= '&___store=' . $store;
             } else {
                 $url .= '?___store=' . $store;
             }
         }
         $links = $entry->getLink();
         if (!is_array($links)) {
             $links = array();
         }
         $link = $entry->getService()->newLink();
         $link->setHref($url);
         $link->setRel('alternate');
         $link->setType('text/html');
         if ($product->getName()) {
             $link->setTitle($product->getName());
         }
         $links[0] = $link;
         $entry->setLink($links);
     }
     return $entry;
 }
Exemple #3
0
 /**
  * @param Mage_Catalog_Model_Product $product
  */
 public function __construct(Mage_Catalog_Model_Product $product)
 {
     // Get the locale of this product.  Should probably do this for all stores
     $locale = $product->getStore()->getConfig('general/locale/code');
     $this->_product = $product;
     $this->_locale = preg_split('/_/', $locale);
     $this->_currency = Mage::app()->getBaseCurrencyCode();
     $this->setData($this->_createProduct($product));
 }
Exemple #4
0
 /**
  * Returns url to product image
  *
  * @param  Mage_Catalog_Model_Product $product
  * @return string|false
  */
 public function getUrl($product)
 {
     $image = $product->getData($this->getAttribute()->getAttributeCode());
     if ($image) {
         $url = Mage::app()->getStore($product->getStore())->getBaseUrl('media') . 'catalog/product/' . $image;
     } else {
         $url = false;
     }
     return $url;
 }
 /**
  * Retrieve current tax percent for customer based on subscription and product
  *
  * @param Adyen_Subscription_Model_Subscription $subscription
  * @param Mage_Catalog_Model_Product $product
  * @return int
  */
 public function getCustomerTaxPercent(Adyen_Subscription_Model_Subscription $subscription, Mage_Catalog_Model_Product $product)
 {
     $percent = $product->getTaxPercent();
     $includingPercent = null;
     $taxClassId = $product->getTaxClassId();
     if (is_null($percent)) {
         if ($taxClassId) {
             $request = Mage::getSingleton('tax/calculation')->getRateRequest($subscription->getShippingAddress(), $subscription->getBillingAddress(), $subscription->getCustomer()->getTaxClassId(), $product->getStore());
             $percent = Mage::getSingleton('tax/calculation')->getRate($request->setProductClassId($taxClassId));
         }
     }
     return $percent ?: 0;
 }
Exemple #6
0
 /**
  * Get downloadable product links
  *
  * @param Mage_Catalog_Model_Product $product
  * @return array
  */
 public function getLinks($product)
 {
     if (is_null($product->getDownloadableLinks())) {
         $_linkCollection = Mage::getModel('Mage_Downloadable_Model_Link')->getCollection()->addProductToFilter($product->getId())->addTitleToResult($product->getStoreId())->addPriceToResult($product->getStore()->getWebsiteId());
         $linksCollectionById = array();
         foreach ($_linkCollection as $link) {
             /* @var Mage_Downloadable_Model_Link $link */
             $link->setProduct($product);
             $linksCollectionById[$link->getId()] = $link;
         }
         $product->setDownloadableLinks($linksCollectionById);
     }
     return $product->getDownloadableLinks();
 }
Exemple #7
0
 /**
  * Set current attribute to entry (for specified product)
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Google_Service_ShoppingContent_Product $shoppingProduct
  * @return Google_Service_ShoppingContent_Product
  */
 public function convertAttribute($product, $shoppingProduct)
 {
     $parentId = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
     $parentItem = Mage::getModel('catalog/product')->load($parentId);
     $cCatId = array_reverse($childItem->getCategoryIds());
     $pCatId = array_reverse($parentItem->getCategoryIds());
     $cCat = Mage::getModel('catalog/category')->load($cCatId[0]);
     $pCat = Mage::getModel('catalog/category')->load($pCatId[0]);
     $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
     if (!Mage::getStoreConfig('web/seo/use_rewrites')) {
         if ($product->getTypeId() == 'simple' && $parentItem->getTypeId() == 'configurable' || 'bundle' || 'grouped') {
             $url = $parentItem->getProductUrl(false);
         } else {
             $url = $childItem->getProductUrl(false);
         }
     } else {
         if ($product->getTypeId() == 'simple' && $parentItem->getTypeId() == 'configurable' || 'bundle' || 'grouped') {
             $url = "{$baseUrl}{$parentItem->getUrlPath($pCat)}";
         } else {
             $url = "{$baseUrl}{$product->getUrlPath($cCat)}";
         }
     }
     if ($url) {
         $config = Mage::getSingleton('googleshoppingapi/config');
         if (!Mage::getStoreConfigFlag('web/url/use_store') && $config->getAddStoreCodeToUrl()) {
             Mage::log($config->getAddStoreCodeToUrl() ? "true" : "false");
             $urlInfo = parse_url($url);
             $store = $product->getStore()->getCode();
             if (isset($urlInfo['query']) && $urlInfo['query'] != '') {
                 $url .= '&___store=' . $store;
             } else {
                 $url .= '?___store=' . $store;
             }
         }
         if ($config->getAddUtmSrcGshopping($product->getStoreId())) {
             $url .= '&utm_source=GoogleShopping';
         }
         if ($customUrlParameters = $config->getCustomUrlParameters($product->getStoreId())) {
             $url .= $customUrlParameters;
         }
         $shoppingProduct->setLink($url);
     }
     return $shoppingProduct;
 }
Exemple #8
0
 /**
  * Set current attribute to entry (for specified product)
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Google_Service_ShoppingContent_Product $shoppingProduct
  * @return Google_Service_ShoppingContent_Product
  */
 public function convertAttribute($product, $shoppingProduct)
 {
     $parentId = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
     $parentItem = Mage::getModel('catalog/product')->load($parentId);
     $category = Mage::getModel('catalog/category')->load();
     if (!Mage::getStoreConfig('web/seo/use_rewrites')) {
         if ($product->getTypeId() == 'simple' && $parentItem->getTypeId() == 'configurable' || 'bundle' || 'grouped') {
             $url = $parentItem->getProductUrl(false);
         } else {
             $url = $product->getProductUrl(false);
         }
     } else {
         if ($product->getTypeId() == 'simple' && $parentItem->getTypeId() == 'configurable' || 'bundle' || 'grouped') {
             $url = sprintf('%s%s', Mage::getBaseUrl(), $parentItem->getUrlPath($category));
         } else {
             $url = sprintf('%s%s', Mage::getBaseUrl(), $product->getUrlPath($category));
         }
     }
     if ($url) {
         if (!Mage::getStoreConfigFlag('web/url/use_store')) {
             $urlInfo = parse_url($url);
             $store = $product->getStore()->getCode();
             if (isset($urlInfo['query']) && $urlInfo['query'] != '') {
                 $url .= '&___store=' . $store;
             } else {
                 $url .= '?___store=' . $store;
             }
         }
         $config = Mage::getSingleton('googleshoppingapi/config');
         if ($config->getAddUtmSrcGshopping($product->getStoreId())) {
             $url .= '&utm_source=GoogleShopping';
         }
         if ($customUrlParameters = $config->getCustomUrlParameters($product->getStoreId())) {
             $url .= $customUrlParameters;
         }
         $shoppingProduct->setLink($url);
     }
     return $shoppingProduct;
 }
 /**
  * Add price index to bundle product after load
  *
  * @param Mage_Catalog_Model_Product $product
  * @return Mage_Bundle_Model_Price_Index
  */
 public function addPriceIndexToProduct($product)
 {
     $websiteId = $product->getStore()->getWebsiteId();
     $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
     $prices = $this->_getResource()->loadPriceIndex($product->getId(), $websiteId, $groupId);
     if (isset($prices[$product->getId()])) {
         $product->setData('_price_index', true)->setData('_price_index_min_price', $prices[$product->getId()]['min_price'])->setData('_price_index_max_price', $prices[$product->getId()]['max_price']);
     }
     return $this;
 }
 /**
  * Assign Stock Status to Product
  *
  * @param Mage_Catalog_Model_Product $product
  * @param int $stockId
  * @param int $stockStatus
  * @return Mage_CatalogInventory_Model_Stock_Status
  */
 public function assignProduct(Mage_Catalog_Model_Product $product, $stockId = 1, $stockStatus = null)
 {
     if (is_null($stockStatus)) {
         $websiteId = $product->getStore()->getWebsiteId();
         $status = $this->getProductStatus($product->getId(), $websiteId, $stockId);
         $stockStatus = isset($status[$product->getId()]) ? $status[$product->getId()] : null;
     }
     $product->setIsSalable($stockStatus);
     return $this;
 }
 /**
  * Initialize collection parent product and add limitation join
  *
  * @param Mage_Catalog_Model_Product $product
  * @return Mage_Catalog_Model_Resource_Product_Link_Product_Collection
  */
 public function setProduct(Mage_Catalog_Model_Product $product)
 {
     $this->_product = $product;
     if ($product && $product->getId()) {
         $this->_hasLinkFilter = true;
         $this->setStore($product->getStore());
     }
     return $this;
 }
Exemple #12
0
 /**
  * Apply special price for bundle
  *
  * @param   Mage_Catalog_Model_Product $product
  * @param   decimal $finalPrice
  * @return  decimal
  */
 protected function _applySpecialPrice($product, $finalPrice)
 {
     $specialPrice = $product->getSpecialPrice();
     if (is_numeric($specialPrice)) {
         $storeDate = Mage::app()->getLocale()->storeDate($product->getStore());
         $fromDate = Mage::app()->getLocale()->date($product->getSpecialFromDate(), null, null, false);
         $toDate = Mage::app()->getLocale()->date($product->getSpecialToDate(), null, null, false);
         if ($product->getSpecialFromDate() && $storeDate->compare($fromDate) < 0) {
         } elseif ($product->getSpecialToDate() && $storeDate->compare($toDate) > 0) {
         } else {
             // special price in percents
             $specialPrice = $finalPrice * $specialPrice / 100;
             $finalPrice = min($finalPrice, $specialPrice);
         }
     }
     return $finalPrice;
 }
Exemple #13
0
 protected function _renderPrice(Mage_Catalog_Model_Product $product, $price)
 {
     $store = $product->getStore();
     $convertedPrice = $store->roundPrice($store->convertPrice($price));
     $price = Mage::helper('tax')->getPrice($product, $convertedPrice);
     return Mage::helper('core')->formatPrice($price);
 }
Exemple #14
0
 /**
  * Apply special price for product if not return price that was before
  *
  * @param   Mage_Catalog_Model_Product $product
  * @param   double $finalPrice
  * @return  double
  */
 protected function _applySpecialPrice($product, $finalPrice)
 {
     $specialPrice = $product->getSpecialPrice();
     if (is_numeric($specialPrice)) {
         $storeDate = Mage::app()->getLocale()->storeDate($product->getStore());
         $fromDate = Mage::app()->getLocale()->date($product->getSpecialFromDate(), null, null, false);
         $toDate = Mage::app()->getLocale()->date($product->getSpecialToDate(), null, null, false);
         if ($product->getSpecialFromDate() && $storeDate->compare($fromDate, Zend_Date::DATES) < 0) {
         } elseif ($product->getSpecialToDate() && $storeDate->compare($toDate, Zend_Date::DATES) > 0) {
         } else {
             $finalPrice = min($finalPrice, $specialPrice);
         }
     }
     return $finalPrice;
 }
 /**
  * Get an item in the collection for the given product using the sku
  * of the product and the configured client id and catalog id for the store
  * the product was loaded within the context of.
  * @param  Mage_Catalog_Model_Product $product
  * @return EbayEnterprise_Catalog_Model_Pim_Product
  */
 public function getItemForProduct(Mage_Catalog_Model_Product $product)
 {
     $cfg = Mage::helper('eb2ccore')->getConfigModel($product->getStore());
     return $this->getItemById($this->_formatId($product->getSku(), $cfg->clientId, $cfg->catalogId));
 }
Exemple #16
0
 /**
  * Catalog product initialize after loading
  *
  * @param Mage_Catalog_Model_Product $model
  * @return void
  */
 public function catalogProductLoadAfter($model)
 {
     if (!$model->getId()) {
         return;
     }
     if (!$this->_role->hasWebsiteAccess($model->getWebsiteIds())) {
         $this->_throwLoad();
     }
     //var_dump($this->_role->hasExclusiveAccess($model->getWebsiteIds()));
     //echo "|";
     if (!$this->_role->hasExclusiveAccess($model->getWebsiteIds())) {
         //echo "here?";
         $model->unlockAttributes();
         $attributes = $model->getAttributes();
         foreach ($attributes as $attribute) {
             /* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
             if ($attribute->isScopeGlobal() || $attribute->isScopeWebsite() && count($this->_role->getWebsiteIds()) == 0 || !in_array($model->getStore()->getId(), $this->_role->getStoreIds())) {
                 $model->lockAttribute($attribute->getAttributeCode());
             }
         }
         $model->setInventoryReadonly(true);
         $model->setRelatedReadonly(true);
         $model->setCrosssellReadonly(true);
         $model->setUpsellReadonly(true);
         $model->setWebsitesReadonly(true);
         $model->lockAttribute('website_ids');
         $model->setOptionsReadonly(true);
         $model->setCompositeReadonly(true);
         if (!in_array($model->getStore()->getId(), $this->_role->getStoreIds())) {
             $model->setAttributesConfigurationReadonly(true);
         }
         $model->setDownloadableReadonly(true);
         $model->setGiftCardReadonly(true);
         $model->setIsDeleteable(false);
         $model->setIsDuplicable(false);
         $model->unlockAttribute('category_ids');
         foreach ($model->getCategoryCollection() as $category) {
             $path = implode("/", array_reverse($category->getPathIds()));
             if (!$this->_role->hasExclusiveCategoryAccess($path)) {
                 $model->setCategoriesReadonly(true);
                 $model->lockAttribute('category_ids');
                 break;
             }
         }
         if (!$this->_role->hasStoreAccess($model->getStoreIds())) {
             $model->setIsReadonly(true);
         }
     } else {
         /*
          * We should check here amount of websites to which admin user assigned
          * and not to those product itself. So if admin user assigned
          * only to one website we will disable ability to unassign product
          * from this one website
          */
         if (count($this->_role->getWebsiteIds()) == 1) {
             $model->setWebsitesReadonly(true);
             $model->lockAttribute('website_ids');
         }
     }
 }
Exemple #17
0
 /**
  * Get all prices for bundle option selection
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Mage_Bundle_Model_Option $option
  * @param bool $takeTierPrice
  * @param bool|null $includeTax
  * @return array
  */
 protected function _getSelectionPrices($product, $option, $takeTierPrice, $includeTax)
 {
     $selectionPrices = array();
     $taxHelper = $this->_getHelperData('tax');
     $taxCalcMethod = $taxHelper->getConfig()->getAlgorithm($product->getStore());
     $isPriceFixedType = $product->getPriceType() == self::PRICE_TYPE_FIXED;
     $selections = $option->getSelections();
     if (!$selections) {
         return $selectionPrices;
     }
     foreach ($selections as $selection) {
         /* @var $selection Mage_Bundle_Model_Selection */
         if (!$selection->isSalable()) {
             /**
              * @todo CatalogInventory Show out of stock Products
              */
             continue;
         }
         $item = $isPriceFixedType ? $product : $selection;
         $selectionUnitPrice = $this->getSelectionFinalTotalPrice($product, $selection, 1, null, false, $takeTierPrice);
         $selectionQty = $selection->getSelectionQty();
         if ($isPriceFixedType || $taxCalcMethod == Mage_Tax_Model_Calculation::CALC_TOTAL_BASE) {
             $selectionPrice = $selectionQty * $taxHelper->getPrice($item, $selectionUnitPrice, $includeTax, null, null, null, null, null, false);
             $selectionPrices[] = $selectionPrice;
         } else {
             if ($taxCalcMethod == Mage_Tax_Model_Calculation::CALC_ROW_BASE) {
                 $selectionPrice = $taxHelper->getPrice($item, $selectionUnitPrice * $selectionQty, $includeTax);
                 $selectionPrices[] = $selectionPrice;
             } else {
                 //dynamic price and Mage_Tax_Model_Calculation::CALC_UNIT_BASE
                 $selectionPrice = $taxHelper->getPrice($item, $selectionUnitPrice, $includeTax) * $selectionQty;
                 $selectionPrices[] = $selectionPrice;
             }
         }
     }
     return $selectionPrices;
 }
Exemple #18
0
 /**
  * Apply special price for product if not return price that was before
  *
  * @param   Mage_Catalog_Model_Product $product
  * @param   float $finalPrice
  * @return  float
  */
 protected function _applySpecialPrice($product, $finalPrice)
 {
     return $this->calculateSpecialPrice($finalPrice, $product->getSpecialPrice(), $product->getSpecialFromDate(), $product->getSpecialToDate(), $product->getStore());
 }
 protected function handlePrice(Mage_Catalog_Model_Product &$product, $sub_products, &$customData)
 {
     $fields = $this->getFields($product->getStore());
     $customer_groups_enabled = $this->config->isCustomerGroupsEnabled($product->getStoreId());
     $store = $product->getStore();
     $type = $this->config->getMappedProductType($product->getTypeId());
     /** @var Mage_Directory_Model_Currency $directoryCurrency */
     $directoryCurrency = Mage::getModel('directory/currency');
     $currencies = $directoryCurrency->getConfigAllowCurrencies();
     $baseCurrencyCode = $store->getBaseCurrencyCode();
     $groups = array();
     if ($customer_groups_enabled) {
         $groups = Mage::getModel('customer/group')->getCollection();
     }
     /** @var Mage_Tax_Helper_Data $taxHelper */
     $taxHelper = Mage::helper('tax');
     /** @var Mage_Directory_Helper_Data $directoryHelper */
     $directoryHelper = Mage::helper('directory');
     foreach ($fields as $field => $with_tax) {
         $customData[$field] = array();
         foreach ($currencies as $currency_code) {
             $customData[$field][$currency_code] = array();
             $price = (double) $taxHelper->getPrice($product, $product->getPrice(), $with_tax, null, null, null, $product->getStore(), null);
             $price = $directoryHelper->currencyConvert($price, $baseCurrencyCode, $currency_code);
             $customData[$field][$currency_code]['default'] = $price;
             $customData[$field][$currency_code]['default_formated'] = $this->formatPrice($price, false, $currency_code);
             $special_price = (double) $taxHelper->getPrice($product, $product->getFinalPrice(), $with_tax, null, null, null, $product->getStore(), null);
             $special_price = $directoryHelper->currencyConvert($special_price, $baseCurrencyCode, $currency_code);
             if ($customer_groups_enabled) {
                 // If fetch special price for groups
                 foreach ($groups as $group) {
                     $group_id = (int) $group->getData('customer_group_id');
                     $product->setCustomerGroupId($group_id);
                     $discounted_price = $product->getPriceModel()->getFinalPrice(1, $product);
                     $discounted_price = $directoryHelper->currencyConvert($discounted_price, $baseCurrencyCode, $currency_code);
                     if ($discounted_price !== false) {
                         $customData[$field][$currency_code]['group_' . $group_id] = (double) $taxHelper->getPrice($product, $discounted_price, $with_tax, null, null, null, $product->getStore(), null);
                         $customData[$field][$currency_code]['group_' . $group_id] = $directoryHelper->currencyConvert($customData[$field][$currency_code]['group_' . $group_id], $baseCurrencyCode, $currency_code);
                         $customData[$field][$currency_code]['group_' . $group_id . '_formated'] = $store->formatPrice($customData[$field][$currency_code]['group_' . $group_id], false, $currency_code);
                     } else {
                         $customData[$field][$currency_code]['group_' . $group_id] = $customData[$field][$currency_code]['default'];
                         $customData[$field][$currency_code]['group_' . $group_id . '_formated'] = $customData[$field][$currency_code]['default_formated'];
                     }
                 }
                 $product->setCustomerGroupId(null);
             }
             $customData[$field][$currency_code]['special_from_date'] = strtotime($product->getSpecialFromDate());
             $customData[$field][$currency_code]['special_to_date'] = strtotime($product->getSpecialToDate());
             if ($customer_groups_enabled) {
                 foreach ($groups as $group) {
                     $group_id = (int) $group->getData('customer_group_id');
                     if ($special_price && $special_price < $customData[$field][$currency_code]['group_' . $group_id]) {
                         $customData[$field][$currency_code]['group_' . $group_id . '_original_formated'] = $customData[$field][$currency_code]['default_formated'];
                         $customData[$field][$currency_code]['group_' . $group_id] = $special_price;
                         $customData[$field][$currency_code]['group_' . $group_id . '_formated'] = $this->formatPrice($special_price, false, $currency_code);
                     }
                 }
             } else {
                 if ($special_price && $special_price < $customData[$field][$currency_code]['default']) {
                     $customData[$field][$currency_code]['default_original_formated'] = $customData[$field][$currency_code]['default_formated'];
                     $customData[$field][$currency_code]['default'] = $special_price;
                     $customData[$field][$currency_code]['default_formated'] = $this->formatPrice($special_price, false, $currency_code);
                 }
             }
             if ($type == 'grouped' || $type == 'bundle') {
                 $min = PHP_INT_MAX;
                 $max = 0;
                 if ($type == 'bundle') {
                     $_priceModel = $product->getPriceModel();
                     list($min, $max) = $_priceModel->getTotalPrices($product, null, $with_tax, true);
                     $min = (double) $min;
                     $max = (double) $max;
                 }
                 if ($type == 'grouped') {
                     if (count($sub_products) > 0) {
                         foreach ($sub_products as $sub_product) {
                             $price = (double) $taxHelper->getPrice($product, $sub_product->getFinalPrice(), $with_tax, null, null, null, $product->getStore(), null);
                             $min = min($min, $price);
                             $max = max($max, $price);
                         }
                     } else {
                         $min = $max;
                     }
                     // avoid to have PHP_INT_MAX in case of no subproducts (Corner case of visibility and stock options)
                 }
                 if ($min != $max) {
                     $min = $directoryHelper->currencyConvert($min, $baseCurrencyCode, $currency_code);
                     $max = $directoryHelper->currencyConvert($max, $baseCurrencyCode, $currency_code);
                     $dashed_format = $this->formatPrice($min, false, $currency_code) . ' - ' . $this->formatPrice($max, false, $currency_code);
                     if (isset($customData[$field][$currency_code]['default_original_formated']) === false || $min <= $customData[$field][$currency_code]['default']) {
                         $customData[$field][$currency_code]['default_formated'] = $dashed_format;
                         //// Do not keep special price that is already taken into account in min max
                         unset($customData['price']['special_from_date']);
                         unset($customData['price']['special_to_date']);
                         unset($customData['price']['default_original_formated']);
                         $customData[$field][$currency_code]['default'] = 0;
                         // will be reset just after
                     }
                     if ($customer_groups_enabled) {
                         foreach ($groups as $group) {
                             $group_id = (int) $group->getData('customer_group_id');
                             if ($min != $max && $min <= $customData[$field][$currency_code]['group_' . $group_id]) {
                                 $customData[$field][$currency_code]['group_' . $group_id] = 0;
                             } else {
                                 $customData[$field][$currency_code]['group_' . $group_id] = $customData[$field][$currency_code]['default'];
                             }
                             $customData[$field][$currency_code]['group_' . $group_id . '_formated'] = $dashed_format;
                         }
                     }
                 }
                 if ($customData[$field][$currency_code]['default'] == 0) {
                     $customData[$field][$currency_code]['default'] = $min;
                     if ($min === $max) {
                         $customData[$field][$currency_code]['default_formated'] = $this->formatPrice($min, false, $currency_code);
                     }
                 }
                 if ($customer_groups_enabled) {
                     foreach ($groups as $group) {
                         $group_id = (int) $group->getData('customer_group_id');
                         if ($customData[$field][$currency_code]['group_' . $group_id] == 0) {
                             $customData[$field][$currency_code]['group_' . $group_id] = $min;
                             if ($min === $max) {
                                 $customData[$field][$currency_code]['group_' . $group_id . '_formated'] = $customData[$field][$currency_code]['default_formated'];
                             }
                         }
                     }
                 }
             }
         }
     }
 }