getQuote(); } /** * @return Orange35_ImageConstructor_Helper_Matches */ protected function getMatchesHelper() { return Mage::helper('orange35_imageConstructor/matches'); } protected function makeImagesArray($cartItems, $size = "full", $keepFrame = false) { $allProductsImages = array (); /** @var $item Mage_Sales_Model_Quote_Item */ if(!empty($cartItems) && isset($cartItems)){ foreach ($cartItems as $item){ $options = $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct()); $options = $options["info_buyRequest"]; $allImageUrl = array(); $matches = $this->getMatchesHelper()->getImagesUrlByProductId($item->getProductId(), $size, $keepFrame); if (!empty($options) && !empty($options["options"])){ foreach($options["options"] as $optionId => $valueId){ if (!is_array($valueId)){ if(isset($matches[$optionId][$valueId])){ array_push($allImageUrl, $matches[$optionId][$valueId]); } }else{ foreach($valueId as $multiValueId){ if(isset($matches[$optionId][$multiValueId])){ array_push($allImageUrl, $matches[$optionId][$multiValueId]); } } }; } } array_push($allProductsImages,$allImageUrl); } } return $allProductsImages; } public function getVisibleProductImages($size = "full", $keepFrame = false) { $cartItems = $this->getQuote()->getAllVisibleItems(); return json_encode(array_reverse($this->makeImagesArray($cartItems, $size, $keepFrame))); } public function getAllProductImages($size = "full", $keepFrame = false) { $cartItems = $this->getQuote()->getAllItems(); return json_encode($this->makeImagesArray($cartItems, $size, $keepFrame)); } public function getWishlistProductImages($size = "full", $keepFrame = false) { $customer = Mage::getSingleton('customer/session')->getCustomer(); if ($customer->getId()) { $wishlist = Mage::getModel('wishlist/wishlist')->loadByCustomer($customer, true); $wishListItemCollection = $wishlist->getItemCollection(); return json_encode(array_reverse($this->makeImagesArray($wishListItemCollection, $size, $keepFrame))); } return false; } }