/**
  * Add image and deep link information to product row
  *
  * @param array $productIndex
  * @param array $productData
  * @param int   $storeId
  *
  * @return array
  */
 protected function _exportImageAndDeepLink($productIndex, $productData, $storeId)
 {
     if ($this->_getIfExportImageAndDeeplink($storeId)) {
         $baseAdminUrl = Mage::app()->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
         if ($storeId !== null) {
             $currentBaseUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
         }
         $imageType = Mage::getStoreConfig('factfinder/export/suggest_image_type', $storeId);
         $imageSize = Mage::getStoreConfig('factfinder/export/suggest_image_size', $storeId);
         $product = Mage::getModel('catalog/product');
         $product->setStoreId($storeId);
         $product->load($productData['entity_id']);
         $image = $this->_imageHelper->init($product, $imageType);
         if (isset($imageSize) && $imageSize > 0) {
             $image->resize($imageSize);
         }
         $image = (string) $image;
         if ($storeId !== null) {
             $image = str_replace($baseAdminUrl, $currentBaseUrl, $image);
         }
         $productIndex[] = $image;
         $productIndex[] = $product->getProductUrl();
         $product->clearInstance();
     }
     return $productIndex;
 }
Exemple #2
0
 public function setProduct($product)
 {
     $configurableCodes = Mage::getStoreConfig('amshopby/general/configurable_images');
     if (!empty($configurableCodes) && $product->isConfigurable() && $product->isSaleable()) {
         $configurableCodes = explode(",", trim($configurableCodes));
         $productTypeIns = $product->getTypeInstance(true);
         $childIds = $productTypeIns->getChildrenIds($product->getId());
         $requestParams = Mage::app()->getRequest()->getParams();
         foreach ($childIds[0] as $childId) {
             $hasInRequest = 0;
             $hasMatch = 0;
             $childProduct = Mage::getModel('catalog/product')->setStoreId($product->getStoreId())->load($childId);
             foreach ($configurableCodes as $filterCode) {
                 if (in_array($filterCode, array_keys($requestParams))) {
                     $hasInRequest++;
                     $value = $requestParams[$filterCode];
                     if (strpos($value, ",") !== false) {
                         $value = explode(",", $value);
                     } else {
                         $value = array($value);
                     }
                     if (in_array($childProduct->getData($filterCode), array_values($value))) {
                         $hasMatch++;
                     }
                 }
             }
             if ($hasInRequest != 0 && $hasInRequest == $hasMatch) {
                 $product = $childProduct;
             }
         }
     }
     parent::setProduct($product);
 }
Exemple #3
0
 /**
  * Add the nice cache name to the image model
  *
  * @param Mage_Catalog_Model_Product $product
  * @param string $attributeName
  * @param string  $imageFile
  * @return Netzarbeiter_NicerImageNames_Helper_Image
  */
 public function init(Mage_Catalog_Model_Product $product, $attributeName, $imageFile = null)
 {
     parent::init($product, $attributeName, $imageFile);
     if (!Mage::getStoreConfig("catalog/nicerimagenames/disable_ext")) {
         $this->_getModel()->setNiceCacheName($this->_getNiceCacheName($attributeName));
     }
     return $this;
 }
 public function __toString()
 {
     $imageFile = $this->_getRequestedImageFile();
     if ($this->_imageShouldComeFromCloudinary($imageFile)) {
         $image = Image::fromPath($imageFile);
         $transformation = $this->_configuration->getDefaultTransformation()->withDimensions($this->_dimensions);
         return (string) $this->_imageProvider->transformImage($image, $transformation);
     }
     return parent::__toString();
 }
 public function setProduct($product)
 {
     if (!isset($this->requestConfigurableMap)) {
         $this->computeRequestConfigurableMap();
     }
     if ($this->requestConfigurableMap && $product->isConfigurable() && $product->isSaleable()) {
         $child = $this->getMatchingSimpleProduct($product);
         if (is_object($child)) {
             $product = $child;
         }
     }
     parent::setProduct($product);
 }
Exemple #6
0
 public function init(Mage_Catalog_Model_Product $product, $attributeName, $imageFile = null)
 {
     if (!Mage::helper('magefm_cdn')->isEnabled()) {
         return parent::init($product, $attributeName, $imageFile);
     }
     $this->_reset();
     $this->_setModel(Mage::getModel('catalog/product_image'));
     $this->_getModel()->setDestinationSubdir($attributeName);
     $this->setProduct($product);
     if ($imageFile) {
         $this->setImageFile($imageFile);
     } else {
         $this->_getModel()->setBaseFile($this->getProduct()->getData($this->_getModel()->getDestinationSubdir()));
     }
     return $this;
 }
Exemple #7
0
 public function resize($width, $height = null)
 {
     $p = Mage::getModel('catalog/product')->load($this->getProduct()->getId());
     if (!$p->getData('is_product_gift_enabled')) {
         return parent::resize($width, $height);
     }
     $type_img = $this->_getModel()->getDestinationSubdir();
     if ($type_img != 'small_image') {
         return parent::resize($width, $height);
     }
     parent::resize($width, $height);
     $w_w = (int) ($width / 4);
     $img_size = $w_w . 'x' . $w_w;
     $this->watermark('gift1e.png', 'bottom-right', $img_size, '100');
     return $this;
 }
 public function setProduct($product)
 {
     if (!isset($this->requestConfigurableMap)) {
         $this->computeRequestConfigurableMap();
     }
     if ($this->requestConfigurableMap && $product->isConfigurable() && $product->isSaleable()) {
         $children = $this->getPossibleSimpleProducts($product);
         foreach ($children as $childProduct) {
             if ($this->matchProduct($childProduct)) {
                 $product = $childProduct;
                 $product->load($product->getId());
                 break;
             }
         }
     }
     parent::setProduct($product);
 }
 public function init(Mage_Catalog_Model_Product $product, $attributeName, $imageFile = null)
 {
     $ModuleName = Mage::app()->getRequest()->getModuleName();
     $ControllerName = Mage::app()->getRequest()->getControllerName();
     $ActionName = Mage::app()->getRequest()->getActionName();
     $RouteName = Mage::app()->getRequest()->getRouteName();
     $controller = "{$ModuleName}_{$ControllerName}_{$ActionName}";
     Mage::getModel('catalog/session')->setCurrentSimpleProduct(null);
     Mage::getModel('catalog/session')->setCurrentSimpleProductId(null);
     if ('catalog_product_view' == $controller && is_object($this->getProduct()) && Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE == $this->getProduct()->getTypeId()) {
         $attributes = Mage::helper('core')->decorateArray($this->getProduct()->getTypeInstance(true)->getConfigurableAttributes($this->getProduct()));
         $selectedAttributeCode = false;
         foreach ($attributes as $attribute) {
             $selectedOption = Mage::app()->getRequest()->getParam($attribute->getProductAttribute()->getAttributeCode(), false);
             if ($selectedOption) {
                 $selectedAttributeCode = $attribute->getProductAttribute()->getAttributeCode();
             }
         }
         if ($selectedAttributeCode) {
             $allProducts = $this->getProduct()->getTypeInstance(true)->getUsedProducts(null, $this->getProduct());
             foreach ($allProducts as $simpleProduct) {
                 if ($simpleProduct->isSaleable() && $simpleProduct->getData($selectedAttributeCode) == Mage::app()->getRequest()->getParam($selectedAttributeCode)) {
                     $simpleProduct->load();
                     if (count($simpleProduct->getMediaGalleryImages()) > 0) {
                         $products[] = $simpleProduct;
                     }
                 }
             }
         }
         if (isset($products) && is_array($products) && count($products) > 0) {
             $product = $this->_currentSimpleProduct = $products[0];
             Mage::getModel('catalog/session')->setCurrentSimpleProduct($product);
             Mage::getModel('catalog/session')->setCurrentSimpleProductId($product->getId());
             if (Mage::getStoreConfig('smdesign_colorswatch/general/update_more_view')) {
                 $this->getProduct()->setData('media_gallery_images', $product->getMediaGalleryImages());
             }
         }
     }
     return parent::init($product, $attributeName, $imageFile);
 }
Exemple #10
0
 public function init(Mage_Catalog_Model_Product $product, $attributeName, $imageFile = null)
 {
     parent::init($product, $attributeName, $imageFile);
     $this->backgroundColor(Mage::helper('yomarketsettings')->getImageBackgroundColor());
     return $this;
 }
 /**
  * Return Image URL
  *
  * @return string
  */
 public function __toString()
 {
     $url = parent::__toString();
     $imagePath = $url;
     $baseUrl = Mage::getStoreConfig('web/unsecure/base_url');
     $imagePath = str_replace($baseUrl, '/', $imagePath);
     $imagePath = str_replace('/', DS, $imagePath);
     // decrypt image path
     $imagePath = Mage::helper('core')->encrypt(base64_encode($imagePath));
     $imagePath = str_replace('+', 'plus', $imagePath);
     $imagePath = urlencode($imagePath);
     $imageUrl = $baseUrl . 'totowatermarkplus/index/index?image=' . $imagePath;
     return $imageUrl;
 }
Exemple #12
0
 /**
  * In older versions of Magento (<1.1.3) this method was used to get an image URL.
  * However, 1.1.3 now uses the getUrl() method in the product > image model. This code
  * was added for backwards compatibility.
  *
  * @return string
  */
 public function __toString()
 {
     parent::__toString();
     return $this->_getModel()->getUrl();
 }
 /**
  * Reset all previous data
  *
  * @return Mage_Catalog_Helper_Image
  */
 protected function _reset()
 {
     $this->_keepAspectRatio = true;
     $this->_keepFrame = true;
     $this->_keepTransparency = true;
     $this->_outputFile = null;
     return parent::_reset();
 }
Exemple #14
0
 /**
  * Update height & width in storage metadata
  *
  * @return self
  */
 protected function _updateMetadata()
 {
     $this->_originalWidth = parent::getOriginalWidth();
     $this->_originalHeight = parent::getOriginalHeight();
     $storageModel = Mage::getSingleton('core/file_storage')->getStorageModel();
     $storageModel->updateMetadata($this->_getModel()->getBaseFile(), ['width' => $this->_originalWidth, 'height' => $this->_originalHeight]);
     return $this;
 }
 /**
  * Reset all previous data
  *
  * @return Mage_Catalog_Helper_Image
  */
 protected function _reset()
 {
     parent::_reset();
     $this->_scheduleAdaptiveResize = false;
     return $this;
 }
Exemple #16
0
 /**
  * Initialize image by specified type
  *
  * @param string $imageType
  * @return Mage_Catalog_Helper_Image
  */
 protected function _init($imageType = 'image')
 {
     return $this->_helper->init(self::$_product, $imageType);
 }
 /**
  * Reset all previous data
  *
  * @return Bolevar_AdaptiveResize_Helper_Image
  */
 protected function _reset()
 {
     $this->_scheduleAdaptiveResize = false;
     $this->_cropPosition = 0;
     parent::_reset();
 }
Exemple #18
0
 protected function setImageFile($file)
 {
     $this->_getModel()->setBaseFile($file);
     return parent::setImageFile($file);
 }
Exemple #19
0
 /**
  * Retrieve Original image size as array
  * 0 - width, 1 - height
  *
  * @return array
  */
 public function getOriginalSizeArray()
 {
     // try to catch chili document
     $product = $this->getProduct();
     $documentId = Mage::helper('web2print')->getItemId($product->getWeb2printDocumentId());
     if ($documentId && $this->chiliPreviewAllowed()) {
         $cached = $this->getCacheImage($documentId);
         if (!$cached) {
             $cached = $this->generateCachedImage($documentId);
         }
         $this->_getModel()->setBaseFile($cached);
         // try to fetch the image size from chili:
         $info = $this->getRemoteImageSize($cached);
         if ($info) {
             return array_slice($info, 0, 2);
         }
     }
     return parent::getOriginalSizeArray();
 }