From 30b82a2a6bd3b1cb117d8daff96d5b89bcab80c2 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sun, 23 Jun 2019 18:22:19 +0200 Subject: [PATCH] Mage_ConfigurableSwatches - DOC block update - doc blocks added/fixed - PSR2 fixes (whitespaces, linebreaks, ...) --- .../Block/Catalog/Layer/State/Swatch.php | 26 +++++- .../Block/Catalog/Media/Js/Abstract.php | 22 +++-- .../Block/Catalog/Media/Js/List.php | 16 ++-- .../Block/Catalog/Media/Js/Product.php | 12 +-- .../Block/Catalog/Product/List/Price.php | 8 +- .../View/Type/Configurable/Swatches.php | 23 ++++- .../Mage/ConfigurableSwatches/Helper/Data.php | 7 +- .../Helper/List/Price.php | 83 +++++++++---------- .../Helper/Mediafallback.php | 41 +++++---- .../Helper/Productimg.php | 30 +++++-- .../Helper/Productlist.php | 1 - .../Helper/Swatchdimensions.php | 3 +- .../ConfigurableSwatches/Model/Observer.php | 26 +++--- .../Product/Attribute/Super/Collection.php | 16 ++-- .../Catalog/Product/Type/Configurable.php | 6 +- .../Type/Configurable/Product/Collection.php | 6 +- .../Catalog/Product/Configattribute.php | 1 + .../Product/Configattribute/Select.php | 3 +- 18 files changed, 201 insertions(+), 129 deletions(-) diff --git a/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Layer/State/Swatch.php b/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Layer/State/Swatch.php index ee87da189ad..92467d85523 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Layer/State/Swatch.php +++ b/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Layer/State/Swatch.php @@ -23,6 +23,20 @@ * @copyright Copyright (c) 2006-2019 Magento, Inc. (http://www.magento.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ + +/** + * Class Mage_ConfigurableSwatches_Block_Catalog_Layer_State_Swatch + * + * @method $this setJsonConfig(string $value) + * @method int getSwatchInnerHeight() + * @method $this setSwatchInnerHeight(int $value) + * @method int getSwatchInnerWidth() + * @method $this setSwatchInnerWidth(int $value) + * @method $this setSwatchOuterHeight(int $value) + * @method $this setSwatchOuterWidth(int $value) + * @method string getSwatchUrl() + * @method $this setSwatchUrl(string $value) + */ class Mage_ConfigurableSwatches_Block_Catalog_Layer_State_Swatch extends Mage_Core_Block_Template { protected $_initDone = false; @@ -57,13 +71,17 @@ protected function _init($filter) if (!$this->_initDone) { $dimHelper = Mage::helper('configurableswatches/swatchdimensions'); $this->setSwatchInnerWidth( - $dimHelper->getInnerWidth(Mage_ConfigurableSwatches_Helper_Swatchdimensions::AREA_LAYER)); + $dimHelper->getInnerWidth(Mage_ConfigurableSwatches_Helper_Swatchdimensions::AREA_LAYER) + ); $this->setSwatchInnerHeight( - $dimHelper->getInnerHeight(Mage_ConfigurableSwatches_Helper_Swatchdimensions::AREA_LAYER)); + $dimHelper->getInnerHeight(Mage_ConfigurableSwatches_Helper_Swatchdimensions::AREA_LAYER) + ); $this->setSwatchOuterWidth( - $dimHelper->getOuterWidth(Mage_ConfigurableSwatches_Helper_Swatchdimensions::AREA_LAYER)); + $dimHelper->getOuterWidth(Mage_ConfigurableSwatches_Helper_Swatchdimensions::AREA_LAYER) + ); $this->setSwatchOuterHeight( - $dimHelper->getOuterHeight(Mage_ConfigurableSwatches_Helper_Swatchdimensions::AREA_LAYER)); + $dimHelper->getOuterHeight(Mage_ConfigurableSwatches_Helper_Swatchdimensions::AREA_LAYER) + ); $swatchUrl = Mage::helper('configurableswatches/productimg') ->getGlobalSwatchUrl( diff --git a/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Media/Js/Abstract.php b/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Media/Js/Abstract.php index b5c65ad2c82..36155dac8f7 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Media/Js/Abstract.php +++ b/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Media/Js/Abstract.php @@ -23,6 +23,10 @@ * @copyright Copyright (c) 2006-2019 Magento, Inc. (http://www.magento.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ + +/** + * Class Mage_ConfigurableSwatches_Block_Catalog_Media_Js_Abstract + */ abstract class Mage_ConfigurableSwatches_Block_Catalog_Media_Js_Abstract extends Mage_Core_Block_Template { protected $_template = 'configurableswatches/catalog/media/js.phtml'; @@ -47,8 +51,9 @@ abstract public function getProducts(); * @param array $imageFallback * @return string */ - protected function _getJsImageFallbackString(array $imageFallback) { - /* @var $coreHelper Mage_Core_Helper_Data */ + protected function _getJsImageFallbackString(array $imageFallback) + { + /* @var Mage_Core_Helper_Data $coreHelper */ $coreHelper = Mage::helper('core'); return $coreHelper->jsonEncode($imageFallback); @@ -68,8 +73,9 @@ abstract protected function _getImageSizes(); * @param null $keepFrame * @return array */ - public function getProductImageFallbacks($keepFrame = null) { - /* @var $helper Mage_ConfigurableSwatches_Helper_Mediafallback */ + public function getProductImageFallbacks($keepFrame = null) + { + /* @var Mage_ConfigurableSwatches_Helper_Mediafallback $helper */ $helper = Mage::helper('configurableswatches/mediafallback'); $fallbacks = array(); @@ -80,7 +86,7 @@ public function getProductImageFallbacks($keepFrame = null) { $keepFrame = $this->isKeepFrame(); } - /* @var $product Mage_Catalog_Model_Product */ + /* @var Mage_Catalog_Model_Product $product */ foreach ($products as $product) { $imageFallback = $helper->getConfigurableImagesFallbackArray($product, $this->_getImageSizes(), $keepFrame); @@ -117,7 +123,8 @@ public function isKeepFrame() * * @return string */ - public function getImageType() { + public function getImageType() + { return parent::getImageType(); } @@ -127,7 +134,8 @@ public function getImageType() { * * @return string */ - protected function _toHtml() { + protected function _toHtml() + { if (!Mage::helper('configurableswatches')->isEnabled()) { // functionality disabled return ''; // do not render block } diff --git a/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Media/Js/List.php b/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Media/Js/List.php index 0a215e9d299..894ae4c3808 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Media/Js/List.php +++ b/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Media/Js/List.php @@ -23,8 +23,11 @@ * @copyright Copyright (c) 2006-2019 Magento, Inc. (http://www.magento.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_ConfigurableSwatches_Block_Catalog_Media_Js_List - extends Mage_ConfigurableSwatches_Block_Catalog_Media_Js_Abstract + +/** + * Class Mage_ConfigurableSwatches_Block_Catalog_Media_Js_List + */ +class Mage_ConfigurableSwatches_Block_Catalog_Media_Js_List extends Mage_ConfigurableSwatches_Block_Catalog_Media_Js_Abstract { /** * Get target product IDs from product collection @@ -32,7 +35,8 @@ class Mage_ConfigurableSwatches_Block_Catalog_Media_Js_List * * @return array */ - public function getProducts() { + public function getProducts() + { return $this->getProductCollection(); } @@ -41,7 +45,8 @@ public function getProducts() { * * @return string */ - public function getImageType() { + public function getImageType() + { $type = parent::getImageType(); if (empty($type)) { @@ -56,7 +61,8 @@ public function getImageType() { * * @return array */ - protected function _getImageSizes() { + protected function _getImageSizes() + { return array('small_image'); } } diff --git a/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Media/Js/Product.php b/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Media/Js/Product.php index 352f57dceb5..1ea06a4b1ce 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Media/Js/Product.php +++ b/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Media/Js/Product.php @@ -23,15 +23,15 @@ * @copyright Copyright (c) 2006-2019 Magento, Inc. (http://www.magento.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_ConfigurableSwatches_Block_Catalog_Media_Js_Product - extends Mage_ConfigurableSwatches_Block_Catalog_Media_Js_Abstract +class Mage_ConfigurableSwatches_Block_Catalog_Media_Js_Product extends Mage_ConfigurableSwatches_Block_Catalog_Media_Js_Abstract { /** * Return array of single product -- current product * * @return array */ - public function getProducts() { + public function getProducts() + { $product = Mage::registry('product'); if (!$product) { @@ -46,7 +46,8 @@ public function getProducts() { * * @return string */ - public function getImageType() { + public function getImageType() + { $type = parent::getImageType(); if (empty($type)) { @@ -61,7 +62,8 @@ public function getImageType() { * * @return array */ - protected function _getImageSizes() { + protected function _getImageSizes() + { return array('image'); } } diff --git a/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Product/List/Price.php b/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Product/List/Price.php index f60628f8625..7cbbbc9a1bf 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Product/List/Price.php +++ b/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Product/List/Price.php @@ -24,6 +24,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +/** + * Class Mage_ConfigurableSwatches_Block_Catalog_Product_List_Price + * + * @method Mage_Eav_Model_Entity_Collection_Abstract getProductCollection() + */ class Mage_ConfigurableSwatches_Block_Catalog_Product_List_Price extends Mage_Core_Block_Template { /** @@ -56,7 +61,7 @@ public function getJsonConfig() 'generalConfig' => $compositeProductHelper->prepareJsonGeneralConfig() ); foreach ($this->getProducts() as $product) { - /** @var $product Mage_Catalog_Model_Product */ + /** @var Mage_Catalog_Model_Product $product */ if (!$product->getSwatchPrices()) { continue; } @@ -91,5 +96,4 @@ protected function _toHtml() return parent::_toHtml(); } - } diff --git a/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Product/View/Type/Configurable/Swatches.php b/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Product/View/Type/Configurable/Swatches.php index 62610f70f0f..a57190fd32f 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Product/View/Type/Configurable/Swatches.php +++ b/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Product/View/Type/Configurable/Swatches.php @@ -1,4 +1,5 @@ setSwatchInnerWidth( - $dimHelper->getInnerWidth(Mage_ConfigurableSwatches_Helper_Swatchdimensions::AREA_DETAIL)); + $dimHelper->getInnerWidth(Mage_ConfigurableSwatches_Helper_Swatchdimensions::AREA_DETAIL) + ); $this->setSwatchInnerHeight( - $dimHelper->getInnerHeight(Mage_ConfigurableSwatches_Helper_Swatchdimensions::AREA_DETAIL)); + $dimHelper->getInnerHeight(Mage_ConfigurableSwatches_Helper_Swatchdimensions::AREA_DETAIL) + ); $this->setSwatchOuterWidth( - $dimHelper->getOuterWidth(Mage_ConfigurableSwatches_Helper_Swatchdimensions::AREA_DETAIL)); + $dimHelper->getOuterWidth(Mage_ConfigurableSwatches_Helper_Swatchdimensions::AREA_DETAIL) + ); $this->setSwatchOuterHeight( - $dimHelper->getOuterHeight(Mage_ConfigurableSwatches_Helper_Swatchdimensions::AREA_DETAIL)); + $dimHelper->getOuterHeight(Mage_ConfigurableSwatches_Helper_Swatchdimensions::AREA_DETAIL) + ); $this->_initDone = true; } diff --git a/app/code/core/Mage/ConfigurableSwatches/Helper/Data.php b/app/code/core/Mage/ConfigurableSwatches/Helper/Data.php index b7fa7c97582..75ef57d2cc8 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Helper/Data.php +++ b/app/code/core/Mage/ConfigurableSwatches/Helper/Data.php @@ -74,10 +74,11 @@ public function getHyphenatedString($str) * Trims and lower-cases strings used as array indexes in json and for string matching in a * multi-byte compatible way if the mbstring module is available. * - * @param $key + * @param string $key * @return string */ - public static function normalizeKey($key) { + public static function normalizeKey($key) + { if (function_exists('mb_strtolower')) { return trim(mb_strtolower($key, 'UTF-8')); } @@ -123,7 +124,7 @@ public function attrIsSwatchType($attr) public function getSwatchesProductJs() { /** - * @var $product Mage_Catalog_Model_Product + * @var Mage_Catalog_Model_Product $product */ $product = Mage::registry('current_product'); if ($this->isEnabled() && $product) { diff --git a/app/code/core/Mage/ConfigurableSwatches/Helper/List/Price.php b/app/code/core/Mage/ConfigurableSwatches/Helper/List/Price.php index 47b3e0bbd6e..c2505074510 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Helper/List/Price.php +++ b/app/code/core/Mage/ConfigurableSwatches/Helper/List/Price.php @@ -48,51 +48,51 @@ public function attachConfigurableProductChildrenPricesMapping(array $products, $listSwatchAttrId = Mage::helper('configurableswatches/productlist')->getSwatchAttributeId(); $result = array(); - foreach ($products as $product) { - /** @var $product Mage_Catalog_Model_Product */ - if ($product->getTypeId() !== Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE + foreach ($products as $product) { + /** @var Mage_Catalog_Model_Product $product */ + if ($product->getTypeId() !== Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE && !is_array($product->getChildrenProducts()) - ) { - continue; - } + ) { + continue; + } - /** @var Mage_Catalog_Model_Product_Type_Configurable $typeInstance */ - $typeInstance = $product->getTypeInstance(); - $allowedAttributes = $typeInstance->getConfigurableAttributeCollection($product); - foreach ($allowedAttributes as $attribute) { - /** @var $attribute Mage_Catalog_Model_Product_Type_Configurable_Attribute */ - if ($attribute->getAttributeId() !== $listSwatchAttrId) { - continue; - } + /** @var Mage_Catalog_Model_Product_Type_Configurable $typeInstance */ + $typeInstance = $product->getTypeInstance(); + $allowedAttributes = $typeInstance->getConfigurableAttributeCollection($product); + foreach ($allowedAttributes as $attribute) { + /** @var Mage_Catalog_Model_Product_Type_Configurable_Attribute $attribute */ + if ($attribute->getAttributeId() !== $listSwatchAttrId) { + continue; + } - foreach ($attribute->getPrices() as $attributePrice) { - $product->setConfigurablePrice( - $this->_getHelper()->preparePrice( - $product, - $attributePrice['pricing_value'], - $attributePrice['is_percent'], - $storeId - ) - ); - Mage::dispatchEvent( - 'catalog_product_type_configurable_price', - array('product' => $product) - ); - $configurablePrice = $product->getConfigurablePrice(); - $cofigurableSwatchesHelper = Mage::helper('configurableswatches'); - $result[$cofigurableSwatchesHelper::normalizeKey($attributePrice['store_label'])] = array( + foreach ($attribute->getPrices() as $attributePrice) { + $product->setConfigurablePrice( + $this->_getHelper()->preparePrice( + $product, + $attributePrice['pricing_value'], + $attributePrice['is_percent'], + $storeId + ) + ); + Mage::dispatchEvent( + 'catalog_product_type_configurable_price', + array('product' => $product) + ); + $configurablePrice = $product->getConfigurablePrice(); + $cofigurableSwatchesHelper = Mage::helper('configurableswatches'); + $result[$cofigurableSwatchesHelper::normalizeKey($attributePrice['store_label'])] = array( 'price' => $configurablePrice, - 'oldPrice' => $this->_getHelper()->prepareOldPrice( - $product, - $attributePrice['pricing_value'], - $attributePrice['is_percent'], - $storeId - ), - ); - } - } - $product->setSwatchPrices($result); - } + 'oldPrice' => $this->_getHelper()->prepareOldPrice( + $product, + $attributePrice['pricing_value'], + $attributePrice['is_percent'], + $storeId + ), + ); + } + } + $product->setSwatchPrices($result); + } } /** @@ -114,5 +114,4 @@ public function isEnabled() { return Mage::getStoreConfigFlag(self::XML_PATH_SWATCH_PRICE); } - } diff --git a/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php b/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php index 49d70eebaa6..10d83d819a3 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php +++ b/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php @@ -38,7 +38,7 @@ class Mage_ConfigurableSwatches_Helper_Mediafallback extends Mage_Core_Helper_Ab * * @param array $parentProducts * @deprecated use $this->attachProductChildrenAttributeMapping() instead - * @param $storeId + * @param int $storeId * @return void */ public function attachConfigurableProductChildrenAttributeMapping(array $parentProducts, $storeId) @@ -52,13 +52,13 @@ public function attachConfigurableProductChildrenAttributeMapping(array $parentP * - product must have children products attached * * @param array $parentProducts - * @param $storeId + * @param int $storeId * @param bool $onlyListAttributes * @return void */ public function attachProductChildrenAttributeMapping(array $parentProducts, $storeId, $onlyListAttributes = false) { - /** @var $listSwatchAttr Mage_Eav_Model_Attribute */ + /** @var Mage_Eav_Model_Attribute $listSwatchAttr */ $listSwatchAttr = Mage::helper('configurableswatches/productlist')->getSwatchAttribute(); $swatchAttributeIds = array(); if (!$onlyListAttributes) { @@ -72,7 +72,7 @@ public function attachProductChildrenAttributeMapping(array $parentProducts, $st } $parentProductIds = array(); - /* @var $parentProduct Mage_Catalog_Model_Product */ + /* @var Mage_Catalog_Model_Product $parentProduct */ foreach ($parentProducts as $parentProduct) { $parentProductIds[] = $parentProduct->getId(); } @@ -99,15 +99,14 @@ public function attachProductChildrenAttributeMapping(array $parentProducts, $st $listSwatchValues = array(); $listSwatchStockValues = array(); - /* @var $attribute Mage_Catalog_Model_Product_Type_Configurable_Attribute */ + /* @var Mage_Catalog_Model_Product_Type_Configurable_Attribute $attribute */ foreach ($configAttributes as $attribute) { - /* @var $childProduct Mage_Catalog_Model_Product */ + /* @var Mage_Catalog_Model_Product $childProduct */ if (!is_array($parentProduct->getChildrenProducts())) { continue; } foreach ($parentProduct->getChildrenProducts() as $childProduct) { - // product has no value for attribute or not available, we can't process it $isInStock = $childProduct->getStockItem()->getIsInStock(); if (!$childProduct->hasData($attribute->getAttributeCode()) @@ -153,8 +152,10 @@ public function attachProductChildrenAttributeMapping(array $parentProducts, $st } if (count($listSwatchValues)) { - $listSwatchValues = array_replace(array_intersect_key($optionLabels, $listSwatchValues), - $listSwatchValues); + $listSwatchValues = array_replace( + array_intersect_key($optionLabels, $listSwatchValues), + $listSwatchValues + ); } $parentProduct->setChildAttributeLabelMapping($mapping) ->setListSwatchAttrValues($listSwatchValues) @@ -171,9 +172,12 @@ public function attachProductChildrenAttributeMapping(array $parentProducts, $st * * @param Mage_Catalog_Model_Product $product * @param array $imageTypes - image types to select for child products + * @param bool $keepFrame * @return array */ - public function getConfigurableImagesFallbackArray(Mage_Catalog_Model_Product $product, array $imageTypes, + public function getConfigurableImagesFallbackArray( + Mage_Catalog_Model_Product $product, + array $imageTypes, $keepFrame = false ) { if (!$product->hasConfigurableImagesFallbackArray()) { @@ -235,7 +239,7 @@ public function getConfigurableImagesFallbackArray(Mage_Catalog_Model_Product $p // iterate image types to build image array, normally one type is passed in at a time, but could be two foreach ($imageTypes as $imageType) { // load image from the configurable product's children for swapping - /* @var $childProduct Mage_Catalog_Model_Product */ + /* @var Mage_Catalog_Model_Product $childProduct */ if ($product->hasChildrenProducts()) { foreach ($product->getChildrenProducts() as $childProduct) { $image = $this->_resizeProductImage($childProduct, $imageType, $keepFrame); @@ -343,13 +347,13 @@ public function groupMediaGalleryImages(Mage_Catalog_Model_Product $product) public function attachGallerySetToCollection(array $products, $storeId) { $productIds = array(); - /* @var $product Mage_Catalog_Model_Product */ + /* @var Mage_Catalog_Model_Product $product */ foreach ($products as $product) { $productIds[] = $product->getId(); if (!is_array($product->getChildrenProducts())) { continue; } - /* @var $childProduct Mage_Catalog_Model_Product */ + /* @var Mage_Catalog_Model_Product $childProduct */ foreach ($product->getChildrenProducts() as $childProduct) { $productIds[] = $childProduct->getId(); } @@ -357,7 +361,7 @@ public function attachGallerySetToCollection(array $products, $storeId) $attrCode = self::MEDIA_GALLERY_ATTRIBUTE_CODE; - /* @var $resourceModel Mage_Catalog_Model_Resource_Product_Attribute_Backend_Media */ + /* @var Mage_Catalog_Model_Resource_Product_Attribute_Backend_Media $resourceModel */ $resourceModel = Mage::getResourceModel('catalog/product_attribute_backend_media'); $images = $resourceModel->loadGallerySet($productIds, $storeId); @@ -370,7 +374,7 @@ public function attachGallerySetToCollection(array $products, $storeId) continue; } - /* @var $childProduct Mage_Catalog_Model_Product */ + /* @var Mage_Catalog_Model_Product $childProduct */ foreach ($product->getChildrenProducts() as $childProduct) { $relationship[$childProduct->getId()] = $product->getId(); } @@ -433,13 +437,14 @@ protected function _getChildrenProductsAttributes() public function attachChildrenProducts(array $products, $storeId) { $productIds = array(); - /* @var $product Mage_Catalog_Model_Product */ + /* @var Mage_Catalog_Model_Product $product */ foreach ($products as $product) { $productIds[] = $product->getId(); } $collection = Mage::getResourceModel( - 'configurableswatches/catalog_product_type_configurable_product_collection'); + 'configurableswatches/catalog_product_type_configurable_product_collection' + ); $collection->setFlag('product_children', true) ->addStoreFilter($storeId) @@ -449,7 +454,7 @@ public function attachChildrenProducts(array $products, $storeId) $collection->load(); $mapping = array(); - /* @var $childProduct Mage_Catalog_Model_Product */ + /* @var Mage_Catalog_Model_Product $childProduct */ foreach ($collection as $childProduct) { foreach ($childProduct->getParentIds() as $parentId) { if (!isset($mapping[$parentId])) { diff --git a/app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php b/app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php index 9839e9677c8..0b4cc6bb77f 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php +++ b/app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php @@ -93,7 +93,7 @@ public function getProductImgByLabel($text, $product, $type = null) * * @param Mage_Catalog_Model_Product $product * @param array|null $preValues - * @return Mage_ConfigurableSwatches_Helper_Data + * @return void */ public function indexProductImages($product, $preValues = null) { @@ -148,7 +148,8 @@ public function indexProductImages($product, $preValues = null) $imageKeys[$swatchLabel] = array_search($swatchLabel, $imageHaystack); if ($imageKeys[$swatchLabel] === false && isset($mapping[$label]['default_label'])) { $imageKeys[$swatchLabel] = array_search( - $mapping[$label]['default_label'] . self::SWATCH_LABEL_SUFFIX, $imageHaystack + $mapping[$label]['default_label'] . self::SWATCH_LABEL_SUFFIX, + $imageHaystack ); } @@ -170,12 +171,17 @@ public function indexProductImages($product, $preValues = null) * @param string $value * @param int $width * @param int $height - * @param $swatchType + * @param string $swatchType * @param string $fallbackFileExt * @return string */ - public function getSwatchUrl($product, $value, $width = self::SWATCH_DEFAULT_WIDTH, - $height = self::SWATCH_DEFAULT_HEIGHT, &$swatchType, $fallbackFileExt = null + public function getSwatchUrl( + $product, + $value, + $width = self::SWATCH_DEFAULT_WIDTH, + $height = self::SWATCH_DEFAULT_HEIGHT, + &$swatchType, + $fallbackFileExt = null ) { $url = ''; $swatchType = 'none'; @@ -220,8 +226,12 @@ public function getSwatchUrl($product, $value, $width = self::SWATCH_DEFAULT_WID * @throws Mage_Core_Exception * @return string */ - public function getGlobalSwatchUrl($object, $value, $width = self::SWATCH_DEFAULT_WIDTH, - $height = self::SWATCH_DEFAULT_HEIGHT, $fileExt = null + public function getGlobalSwatchUrl( + $object, + $value, + $width = self::SWATCH_DEFAULT_WIDTH, + $height = self::SWATCH_DEFAULT_HEIGHT, + $fileExt = null ) { if (is_null($fileExt)) { $fileExt = self::SWATCH_FILE_EXT; @@ -341,7 +351,9 @@ public function filterImageInGallery($product, $image) $this->_productImageFilters[$product->getId()] = $filters; } - return !in_array(Mage_ConfigurableSwatches_Helper_Data::normalizeKey($image->getLabel()), - $this->_productImageFilters[$product->getId()]); + return !in_array( + Mage_ConfigurableSwatches_Helper_Data::normalizeKey($image->getLabel()), + $this->_productImageFilters[$product->getId()] + ); } } diff --git a/app/code/core/Mage/ConfigurableSwatches/Helper/Productlist.php b/app/code/core/Mage/ConfigurableSwatches/Helper/Productlist.php index c2a279768ed..d304277feb9 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Helper/Productlist.php +++ b/app/code/core/Mage/ConfigurableSwatches/Helper/Productlist.php @@ -62,7 +62,6 @@ public function convertLayerBlock($blockName) && ($block = Mage::app()->getLayout()->getBlock($blockName)) && $block instanceof Mage_Catalog_Block_Layer_View ) { - // First, set a new template for the attribute that should show as a swatch if ($layer = $block->getLayer()) { foreach ($layer->getFilterableAttributes() as $attribute) { diff --git a/app/code/core/Mage/ConfigurableSwatches/Helper/Swatchdimensions.php b/app/code/core/Mage/ConfigurableSwatches/Helper/Swatchdimensions.php index e405d1fd471..d6f66c1f466 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Helper/Swatchdimensions.php +++ b/app/code/core/Mage/ConfigurableSwatches/Helper/Swatchdimensions.php @@ -54,7 +54,8 @@ class Mage_ConfigurableSwatches_Helper_Swatchdimensions extends Mage_Core_Helper public function getDimension($area, $dimension, $outer = false) { $dimension = (int) Mage::getStoreConfig( - Mage_ConfigurableSwatches_Helper_Data::CONFIG_PATH_BASE . '/' . $area . '/' . $dimension); + Mage_ConfigurableSwatches_Helper_Data::CONFIG_PATH_BASE . '/' . $area . '/' . $dimension + ); if ($outer) { $dimension += $this->_dimensionBuffer; } diff --git a/app/code/core/Mage/ConfigurableSwatches/Model/Observer.php b/app/code/core/Mage/ConfigurableSwatches/Model/Observer.php index 490c34e5058..d2b37f18b09 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Model/Observer.php +++ b/app/code/core/Mage/ConfigurableSwatches/Model/Observer.php @@ -37,13 +37,13 @@ public function productListCollectionLoadAfter(Varien_Event_Observer $observer) return; // exit without loading swatch functionality } - /* @var $mediaHelper Mage_ConfigurableSwatches_Helper_Mediafallback */ + /* @var Mage_ConfigurableSwatches_Helper_Mediafallback $mediaHelper */ $mediaHelper = Mage::helper('configurableswatches/mediafallback'); - /** @var $priceHelper Mage_ConfigurableSwatches_Helper_List_Price */ + /** @var Mage_ConfigurableSwatches_Helper_List_Price $priceHelper */ $priceHelper = Mage::helper('configurableswatches/list_price'); - /* @var $collection Mage_Catalog_Model_Resource_Product_Collection */ + /* @var Mage_Catalog_Model_Resource_Product_Collection $collection */ $collection = $observer->getCollection(); if ($collection @@ -64,13 +64,12 @@ public function productListCollectionLoadAfter(Varien_Event_Observer $observer) $mediaHelper->attachGallerySetToCollection($products, $collection->getStoreId()); - /* @var $product Mage_Catalog_Model_Product */ + /* @var Mage_Catalog_Model_Product $product */ foreach ($products as $product) { $mediaHelper->groupMediaGalleryImages($product); Mage::helper('configurableswatches/productimg') ->indexProductImages($product, $product->getListSwatchAttrValues()); } - } /** @@ -79,16 +78,17 @@ public function productListCollectionLoadAfter(Varien_Event_Observer $observer) * * @param Varien_Event_Observer $observer */ - public function productLoadAfter(Varien_Event_Observer $observer) { + public function productLoadAfter(Varien_Event_Observer $observer) + { if (!Mage::helper('configurableswatches')->isEnabled()) { // functionality disabled return; // exit without loading swatch functionality } - /* @var $helper Mage_ConfigurableSwatches_Helper_Mediafallback */ + /* @var Mage_ConfigurableSwatches_Helper_Mediafallback $helper */ $helper = Mage::helper('configurableswatches/mediafallback'); - /* @var $product Mage_Catalog_Model_Product */ + /* @var Mage_Catalog_Model_Product $product */ $product = $observer->getDataObject(); if ($product->getTypeId() != Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) { @@ -107,22 +107,23 @@ public function productLoadAfter(Varien_Event_Observer $observer) { * * @param Varien_Event_Observer $observer */ - public function loadChildProductImagesOnMediaLoad(Varien_Event_Observer $observer) { + public function loadChildProductImagesOnMediaLoad(Varien_Event_Observer $observer) + { if (!Mage::helper('configurableswatches')->isEnabled()) { // functionality disabled return; // exit without loading swatch functionality } - /* @var $eventWrapper Varien_Object */ + /* @var Varien_Object $eventWrapper */ $eventWrapper = $observer->getEventObjectWrapper(); - /* @var $product Mage_Catalog_Model_Product */ + /* @var Mage_Catalog_Model_Product $product */ $product = $eventWrapper->getProduct(); if ($product->getTypeId() != Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) { return; } - /* @var $productType Mage_Catalog_Model_Product_Type_Configurable */ + /* @var Mage_Catalog_Model_Product_Type_Configurable $productType */ $productType = Mage::getModel('catalog/product_type_configurable'); $childrenProducts = $productType->getUsedProducts(null, $product); @@ -157,7 +158,6 @@ public function convertLayerBlock(Varien_Event_Observer $observer) // Perform this operation if we're on a category view page or search results page if (($front == 'catalog' && $controller == 'category' && $action == 'view') || ($front == 'catalogsearch' && $controller == 'result' && $action == 'index')) { - // Block name for layered navigation differs depending on which Magento edition we're in $blockName = 'catalog.leftnav'; if (Mage::getEdition() == Mage::EDITION_ENTERPRISE) { diff --git a/app/code/core/Mage/ConfigurableSwatches/Model/Resource/Catalog/Product/Attribute/Super/Collection.php b/app/code/core/Mage/ConfigurableSwatches/Model/Resource/Catalog/Product/Attribute/Super/Collection.php index 6005a4c9b65..d09280b6065 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Model/Resource/Catalog/Product/Attribute/Super/Collection.php +++ b/app/code/core/Mage/ConfigurableSwatches/Model/Resource/Catalog/Product/Attribute/Super/Collection.php @@ -23,8 +23,7 @@ * @copyright Copyright (c) 2006-2019 Magento, Inc. (http://www.magento.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_ConfigurableSwatches_Model_Resource_Catalog_Product_Attribute_Super_Collection - extends Mage_Catalog_Model_Resource_Product_Type_Configurable_Attribute_Collection +class Mage_ConfigurableSwatches_Model_Resource_Catalog_Product_Attribute_Super_Collection extends Mage_Catalog_Model_Resource_Product_Type_Configurable_Attribute_Collection { private $_eavAttributesJoined = false; private $_storeId = null; @@ -35,7 +34,8 @@ class Mage_ConfigurableSwatches_Model_Resource_Catalog_Product_Attribute_Super_C * @param array $parentProductIds * @return $this */ - public function addParentProductsFilter(array $parentProductIds) { + public function addParentProductsFilter(array $parentProductIds) + { $this->addFieldToFilter('product_id', array('in' => $parentProductIds)); return $this; } @@ -45,9 +45,10 @@ public function addParentProductsFilter(array $parentProductIds) { * * @return $this */ - public function attachEavAttributes() { + public function attachEavAttributes() + { if ($this->_eavAttributesJoined) { - return; + return $this; } $this->join( @@ -62,10 +63,11 @@ public function attachEavAttributes() { /** * Set store ID * - * @param $storeId + * @param int $storeId * @return $this */ - public function setStoreId($storeId) { + public function setStoreId($storeId) + { $this->_storeId = $storeId; return $this; } diff --git a/app/code/core/Mage/ConfigurableSwatches/Model/Resource/Catalog/Product/Type/Configurable.php b/app/code/core/Mage/ConfigurableSwatches/Model/Resource/Catalog/Product/Type/Configurable.php index 75f1f4d8829..ab9ff0f5de7 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Model/Resource/Catalog/Product/Type/Configurable.php +++ b/app/code/core/Mage/ConfigurableSwatches/Model/Resource/Catalog/Product/Type/Configurable.php @@ -23,8 +23,7 @@ * @copyright Copyright (c) 2006-2019 Magento, Inc. (http://www.magento.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_ConfigurableSwatches_Model_Resource_Catalog_Product_Type_Configurable - extends Mage_Catalog_Model_Resource_Product_Type_Configurable +class Mage_ConfigurableSwatches_Model_Resource_Catalog_Product_Type_Configurable extends Mage_Catalog_Model_Resource_Product_Type_Configurable { /** @@ -36,7 +35,8 @@ class Mage_ConfigurableSwatches_Model_Resource_Catalog_Product_Type_Configurable * @return array * @see Mage_Catalog_Model_Resource_Product_Type_Configurable::getChildrenIds() */ - public function getChildrenIds($parentId, $required = true) { + public function getChildrenIds($parentId, $required = true) + { if (is_array($parentId)) { $childrenIds = array(); if (!empty($parentId)) { diff --git a/app/code/core/Mage/ConfigurableSwatches/Model/Resource/Catalog/Product/Type/Configurable/Product/Collection.php b/app/code/core/Mage/ConfigurableSwatches/Model/Resource/Catalog/Product/Type/Configurable/Product/Collection.php index c9b75f68ffb..ebd636dcba5 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Model/Resource/Catalog/Product/Type/Configurable/Product/Collection.php +++ b/app/code/core/Mage/ConfigurableSwatches/Model/Resource/Catalog/Product/Type/Configurable/Product/Collection.php @@ -23,15 +23,15 @@ * @copyright Copyright (c) 2006-2019 Magento, Inc. (http://www.magento.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_ConfigurableSwatches_Model_Resource_Catalog_Product_Type_Configurable_Product_Collection - extends Mage_Catalog_Model_Resource_Product_Type_Configurable_Product_Collection +class Mage_ConfigurableSwatches_Model_Resource_Catalog_Product_Type_Configurable_Product_Collection extends Mage_Catalog_Model_Resource_Product_Type_Configurable_Product_Collection { /** * Filter by parent product set * * @param array $productIds */ - public function addProductSetFilter(array $productIds) { + public function addProductSetFilter(array $productIds) + { $this->getSelect()->where('link_table.parent_id in (?)', $productIds); } diff --git a/app/code/core/Mage/ConfigurableSwatches/Model/System/Config/Source/Catalog/Product/Configattribute.php b/app/code/core/Mage/ConfigurableSwatches/Model/System/Config/Source/Catalog/Product/Configattribute.php index 1e304916084..47cd2ee12dd 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Model/System/Config/Source/Catalog/Product/Configattribute.php +++ b/app/code/core/Mage/ConfigurableSwatches/Model/System/Config/Source/Catalog/Product/Configattribute.php @@ -50,6 +50,7 @@ public function toOptionArray() ->setOrder('frontend_label', Varien_Data_Collection::SORT_ORDER_ASC); $this->_attributes = array(); + /** @var Mage_Eav_Model_Attribute $attribute */ foreach ($attrCollection as $attribute) { $this->_attributes[] = array( 'label' => $attribute->getFrontendLabel(), diff --git a/app/code/core/Mage/ConfigurableSwatches/Model/System/Config/Source/Catalog/Product/Configattribute/Select.php b/app/code/core/Mage/ConfigurableSwatches/Model/System/Config/Source/Catalog/Product/Configattribute/Select.php index 67e9c954b5b..09beed09389 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Model/System/Config/Source/Catalog/Product/Configattribute/Select.php +++ b/app/code/core/Mage/ConfigurableSwatches/Model/System/Config/Source/Catalog/Product/Configattribute/Select.php @@ -23,8 +23,7 @@ * @copyright Copyright (c) 2006-2019 Magento, Inc. (http://www.magento.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_ConfigurableSwatches_Model_System_Config_Source_Catalog_Product_Configattribute_Select - extends Mage_ConfigurableSwatches_Model_System_Config_Source_Catalog_Product_Configattribute +class Mage_ConfigurableSwatches_Model_System_Config_Source_Catalog_Product_Configattribute_Select extends Mage_ConfigurableSwatches_Model_System_Config_Source_Catalog_Product_Configattribute { /** * Retrieve attributes as array