Mage_Catalog_Helper_Product
extends Mage_Core_Helper_Url
in package
Table of Contents
Constants
- DEFAULT_QTY : mixed = 1
- XML_PATH_PRODUCT_URL_SUFFIX : mixed = 'catalog/seo/product_url_suffix'
- XML_PATH_PRODUCT_URL_USE_CATEGORY : mixed = 'catalog/seo/product_use_categories'
- XML_PATH_USE_PRODUCT_CANONICAL_TAG : mixed = 'catalog/seo/product_canonical_tag'
Properties
- $_layout : Mage_Core_Model_Layout
- Layout model object
- $_moduleName : string
- Helper module name
- $_priceBlock : mixed
- $_productUrlSuffix : array<string|int, mixed>
- Cache for product rewrite suffix
- $_request : Mage_Core_Controller_Request_Http
- Request object
- $_skipSaleableCheck : bool
- Flag that shows if Maho has to check product to be salable (enabled and/or inStock)
- $_statuses : mixed
- $modulesDisabled : array<string|int, mixed>
Methods
- __() : string
- Translate
- addOrRemoveTrailingSlash() : string
- Add or remove trailing slash from URL based on store config
- addParamsToBuyRequest() : DataObject
- Process $buyRequest and sets its options before saving configuration to some product item.
- addRequestParam() : string
- Add query parameter into url
- addRouteParam() : string
- Add or update varien route param in URL
- addTrailingSlash() : string
- Add trailing slash to URL
- buildUrl() : string
- Build a URL from the result of PHP's parse_url()
- canShow() : bool
- Check if a product can be shown
- canUseCanonicalTag() : bool
- Check if <link rel="canonical"> can be used for product
- decodePunycode() : string
- Retrieve decoding domain name from punycode
- encodePunycode() : string
- Retrieve encoding domain name in punycode
- escapeHtml() : ($data is array ? ?string[] : ?string)
- Escape html entities
- escapeScriptIdentifiers() : string
- Remove `javascript:`, `vbscript:`, `data:` words from the string.
- escapeSpecial() : string
- Remove `\t`,`\n`,`\r`,`\0`,`\x0B:` symbols from the string.
- escapeUrl() : string
- Escape html entities in url
- getAttributeBackendModelByInputType() : string|null
- Return default attribute backend model by input type
- getAttributeFrontendModelByInputType() : string|null
- Return default attribute frontend model by input type
- getAttributeInputTypes() : array<string|int, mixed>
- Return information array of product attribute input types Only a small number of settings returned, so we won't break anything in current dataflow As soon as development process goes on we need to add there all possible settings
- getAttributeSourceModelByInputType() : string|null
- Return default attribute source model by input type
- getCurrentBase64Url() : string
- Retrieve current url in base64 encoding
- getCurrentUrl() : string
- Retrieve current url
- getDefaultProductValue() : int
- Get default product value by field name
- getDefaultQty() : int|float
- Get default qty - either as preconfigured, or as 1.
- getEncodedUrl() : string
- Return encoded url
- getFieldset() : array<string|int, mixed>|null
- Return array from config by fieldset name and area
- getFinalPrice() : float
- Retrieve product final price
- getFullProductUrl() : string
- Retrieve product view page url including provided category Id
- getHomeUrl() : string
- Retrieve homepage url
- getImageUrl() : string
- Retrieve base image url
- getLayout() : Mage_Core_Model_Layout
- Retrieve layout model object
- getMinimalQty() : float|null
- Gets minimal sales quantity
- getPrice() : float
- Retrieve product price
- getProduct() : Mage_Catalog_Model_Product
- Return loaded product instance
- getProductUrl() : string|false
- Retrieve product view page url
- getProductUrlSuffix() : string
- Retrieve product rewrite sufix for store
- getRequestPathCandidates() : array<int, string>
- Build the request path candidates that URL rewrite lookups try, in order of preference: with the original trailing slash state first, then the alternate one.
- getRewriteQueryString() : string|false
- Query string of the request without the internal ___ parameters, or false when empty
- getSkipSaleableCheck() : bool
- Get flag that shows if Maho has to check product to be saleable (enabled and/or inStock)
- getSmallImageUrl() : string
- getStatuses() : array<string|int, mixed>
- getThumbnailUrl() : string
- hasTags() : bool
- Check for tags in multidimensional arrays
- initProduct() : false|Mage_Catalog_Model_Product
- Inits product to be used for product controller actions and layouts $params can have following data: 'category_id' - id of category to check and append to product as current.
- isInternalUrl() : bool
- Check whether a URL points at this store, i.e. is safe to redirect to.
- isModuleEnabled() : bool
- Check is module exists and enabled in global config.
- isModuleOutputEnabled() : bool
- Check whether the module output is enabled in Configuration
- isRequestPathGone() : bool
- Whether the originally requested path belongs to a deleted entity and must return 410 Gone
- isVisibleInStore() : bool
- Return whether the storefront of the store $storeId shows $product: canShow(), and the product is in the website.
- jsEscape() : string
- Encode $data as a complete JavaScript literal. The result includes its own quotes.
- jsQuoteEscape() : string
- Put a backslash before each $quote in $data. Use the result inside a JavaScript string that the template quotes with the same $quote. The result has no quotes of its own.
- prepareProductOptions() : $this
- Prepares product options by buyRequest: retrieves values and assigns them as default.
- quoteEscape() : string
- Escape quotes inside html attributes Use $addSlashes = false for escaping js that inside html attribute (onClick, onSubmit etc)
- removeRequestParam() : string
- Remove query parameter from url
- removeRouteParam() : string
- Remove varien route param from URL
- removeTags() : string
- Remove html tags, but leave "<" and ">" signs
- removeTrailingSlash() : string
- Remove trailing slash from URL
- setLayout() : Mage_Core_Helper_Abstract
- Declare layout
- setRouteParams() : string
- Add, update, or remove multiple varien route params in URL
- setSkipSaleableCheck() : $this
- Set flag that shows if Maho has to check product to be saleable (enabled and/or inStock)
- stripTags() : string
- Wrapper for standard strip_tags() function with extra functionality for html entities
- translateArray() : array<string|int, mixed>
- Translate array
- urlDecode() : string
- base64_decode() for URLs decoding
- urlDecodeAndEscape() : string
- base64_decode() and escape quotes in url
- urlEncode() : string
- base64_encode() for URLs encoding
- _cleanCache() : Mage_Core_Helper_Abstract
- Cleaning cache
- _getModuleName() : string
- Retrieve helper module name
- _getRequest() : Mage_Core_Controller_Request_Http
- Retrieve request object
- _getUrl() : string
- Retrieve url
- _loadCache() : mixed
- Loading cache data
- _prepareString() : string
- Formatting string
- _removeCache() : Mage_Core_Helper_Abstract
- Removing cache
- _saveCache() : Mage_Core_Helper_Abstract
- Saving cache
Constants
DEFAULT_QTY
public
mixed
DEFAULT_QTY
= 1
XML_PATH_PRODUCT_URL_SUFFIX
public
mixed
XML_PATH_PRODUCT_URL_SUFFIX
= 'catalog/seo/product_url_suffix'
XML_PATH_PRODUCT_URL_USE_CATEGORY
public
mixed
XML_PATH_PRODUCT_URL_USE_CATEGORY
= 'catalog/seo/product_use_categories'
XML_PATH_USE_PRODUCT_CANONICAL_TAG
public
mixed
XML_PATH_USE_PRODUCT_CANONICAL_TAG
= 'catalog/seo/product_canonical_tag'
Properties
$_layout
Layout model object
protected
Mage_Core_Model_Layout
$_layout
$_moduleName
Helper module name
protected
string
$_moduleName
= 'Mage_Catalog'
Attributes
- #[Override]
$_priceBlock
protected
mixed
$_priceBlock
$_productUrlSuffix
Cache for product rewrite suffix
protected
array<string|int, mixed>
$_productUrlSuffix
= []
$_request
Request object
protected
Mage_Core_Controller_Request_Http
$_request
$_skipSaleableCheck
Flag that shows if Maho has to check product to be salable (enabled and/or inStock)
protected
bool
$_skipSaleableCheck
= \false
$_statuses
protected
mixed
$_statuses
$modulesDisabled
protected
array<string|int, mixed>
$modulesDisabled
= []
Methods
__()
Translate
public
__() : string
Return values
stringaddOrRemoveTrailingSlash()
Add or remove trailing slash from URL based on store config
public
addOrRemoveTrailingSlash(string $url[, int|Mage_Core_Model_Store|null $store = null ]) : string
Parameters
- $url : string
- $store : int|Mage_Core_Model_Store|null = null
Return values
stringaddParamsToBuyRequest()
Process $buyRequest and sets its options before saving configuration to some product item.
public
addParamsToBuyRequest(DataObject|array<string|int, mixed> $buyRequest, DataObject|array<string|int, mixed> $params) : DataObject
This method is used to attach additional parameters to processed buyRequest.
$params holds parameters of what operation must be performed:
- 'current_config', \Maho\DataObject or array - current buyRequest that configures product in this item, used to restore currently attached files
- 'files_prefix': string[a-z0-9_] - prefix that was added at frontend to names of file inputs, so they won't intersect with other submitted options
Parameters
- $buyRequest : DataObject|array<string|int, mixed>
- $params : DataObject|array<string|int, mixed>
Return values
DataObjectaddRequestParam()
Add query parameter into url
public
addRequestParam(string $url, array<string|int, mixed> $param) : string
Parameters
- $url : string
- $param : array<string|int, mixed>
-
( 'key' => value )
Return values
stringaddRouteParam()
Add or update varien route param in URL
public
addRouteParam(string $url, string $paramKey, mixed $value) : string
Parameters
- $url : string
- $paramKey : string
- $value : mixed
Return values
stringaddTrailingSlash()
Add trailing slash to URL
public
addTrailingSlash(string $url) : string
Parameters
- $url : string
Return values
stringbuildUrl()
Build a URL from the result of PHP's parse_url()
public
buildUrl(array<string|int, mixed> $parts) : string
Parameters
- $parts : array<string|int, mixed>
Return values
stringcanShow()
Check if a product can be shown
public
canShow(Mage_Catalog_Model_Product|int $product[, string $where = 'catalog' ]) : bool
Parameters
- $product : Mage_Catalog_Model_Product|int
- $where : string = 'catalog'
Return values
boolcanUseCanonicalTag()
Check if <link rel="canonical"> can be used for product
public
canUseCanonicalTag([null|string|bool|int|Mage_Core_Model_Store $store = null ]) : bool
Parameters
- $store : null|string|bool|int|Mage_Core_Model_Store = null
Return values
booldecodePunycode()
Retrieve decoding domain name from punycode
public
decodePunycode(string $url) : string
Parameters
- $url : string
-
decode url from Punycode
Tags
Return values
stringencodePunycode()
Retrieve encoding domain name in punycode
public
encodePunycode(string $url) : string
Parameters
- $url : string
-
encode url to Punycode
Return values
stringescapeHtml()
Escape html entities
public
escapeHtml(null|string|array<string|int, string> $data[, null|array<string|int, string> $allowedTags = null ]) : ($data is array ? ?string[] : ?string)
Parameters
- $data : null|string|array<string|int, string>
- $allowedTags : null|array<string|int, string> = null
Return values
($data is array ? ?string[] : ?string)escapeScriptIdentifiers()
Remove `javascript:`, `vbscript:`, `data:` words from the string.
public
escapeScriptIdentifiers(string $data) : string
Parameters
- $data : string
Return values
stringescapeSpecial()
Remove `\t`,`\n`,`\r`,`\0`,`\x0B:` symbols from the string.
public
escapeSpecial(string $data) : string
Parameters
- $data : string
Return values
stringescapeUrl()
Escape html entities in url
public
escapeUrl(string $data) : string
Parameters
- $data : string
Return values
stringgetAttributeBackendModelByInputType()
Return default attribute backend model by input type
public
getAttributeBackendModelByInputType(string $inputType) : string|null
Parameters
- $inputType : string
Return values
string|nullgetAttributeFrontendModelByInputType()
Return default attribute frontend model by input type
public
getAttributeFrontendModelByInputType(string $inputType) : string|null
Parameters
- $inputType : string
Return values
string|nullgetAttributeInputTypes()
Return information array of product attribute input types Only a small number of settings returned, so we won't break anything in current dataflow As soon as development process goes on we need to add there all possible settings
public
getAttributeInputTypes([string $inputType = null ]) : array<string|int, mixed>
Parameters
- $inputType : string = null
Return values
array<string|int, mixed>getAttributeSourceModelByInputType()
Return default attribute source model by input type
public
getAttributeSourceModelByInputType(string $inputType) : string|null
Parameters
- $inputType : string
Return values
string|nullgetCurrentBase64Url()
Retrieve current url in base64 encoding
public
getCurrentBase64Url() : string
Return values
stringgetCurrentUrl()
Retrieve current url
public
getCurrentUrl() : string
Return values
stringgetDefaultProductValue()
Get default product value by field name
public
getDefaultProductValue(string $fieldName, string $productType) : int
Parameters
- $fieldName : string
- $productType : string
Return values
intgetDefaultQty()
Get default qty - either as preconfigured, or as 1.
public
getDefaultQty(Mage_Catalog_Model_Product $product) : int|float
Also restricts it by minimal qty.
Parameters
- $product : Mage_Catalog_Model_Product
Return values
int|floatgetEncodedUrl()
Return encoded url
public
getEncodedUrl([null|string $url = null ]) : string
Parameters
- $url : null|string = null
Return values
stringgetFieldset()
Return array from config by fieldset name and area
public
getFieldset([null|string $field = null ][, string $fieldset = 'catalog_product_dataflow' ][, string $area = 'admin' ]) : array<string|int, mixed>|null
Parameters
- $field : null|string = null
- $fieldset : string = 'catalog_product_dataflow'
- $area : string = 'admin'
Return values
array<string|int, mixed>|nullgetFinalPrice()
Retrieve product final price
public
getFinalPrice(Mage_Catalog_Model_Product $product) : float
Parameters
- $product : Mage_Catalog_Model_Product
Return values
floatgetFullProductUrl()
Retrieve product view page url including provided category Id
public
getFullProductUrl(int $productId[, int $categoryId = null ]) : string
Parameters
- $productId : int
- $categoryId : int = null
Return values
stringgetHomeUrl()
Retrieve homepage url
public
getHomeUrl() : string
Return values
stringgetImageUrl()
Retrieve base image url
public
getImageUrl(Mage_Catalog_Model_Product $product) : string
Parameters
- $product : Mage_Catalog_Model_Product
Return values
stringgetLayout()
Retrieve layout model object
public
getLayout() : Mage_Core_Model_Layout
Return values
Mage_Core_Model_LayoutgetMinimalQty()
Gets minimal sales quantity
public
getMinimalQty(Mage_Catalog_Model_Product $product) : float|null
Parameters
- $product : Mage_Catalog_Model_Product
Return values
float|nullgetPrice()
Retrieve product price
public
getPrice(Mage_Catalog_Model_Product $product) : float
Parameters
- $product : Mage_Catalog_Model_Product
Return values
floatgetProduct()
Return loaded product instance
public
getProduct(int|string $productId, int|null $store[, string $identifierType = null ]) : Mage_Catalog_Model_Product
Parameters
- $productId : int|string
-
(SKU or ID)
- $store : int|null
- $identifierType : string = null
Return values
Mage_Catalog_Model_ProductgetProductUrl()
Retrieve product view page url
public
getProductUrl(Mage_Catalog_Model_Product|string|int $product) : string|false
Parameters
- $product : Mage_Catalog_Model_Product|string|int
Return values
string|falsegetProductUrlSuffix()
Retrieve product rewrite sufix for store
public
getProductUrlSuffix([int $storeId = null ]) : string
Parameters
- $storeId : int = null
Return values
stringgetRequestPathCandidates()
Build the request path candidates that URL rewrite lookups try, in order of preference: with the original trailing slash state first, then the alternate one.
public
getRequestPathCandidates(string $pathInfo[, string|false $queryString = false ]) : array<int, string>
Parameters
- $pathInfo : string
- $queryString : string|false = false
Return values
array<int, string>getRewriteQueryString()
Query string of the request without the internal ___ parameters, or false when empty
public
getRewriteQueryString(Mage_Core_Controller_Request_Http $request) : string|false
Parameters
- $request : Mage_Core_Controller_Request_Http
Return values
string|falsegetSkipSaleableCheck()
Get flag that shows if Maho has to check product to be saleable (enabled and/or inStock)
public
getSkipSaleableCheck() : bool
Return values
boolgetSmallImageUrl()
public
getSmallImageUrl(Mage_Catalog_Model_Product $product) : string
a product has one image, use getImageUrl()
Parameters
- $product : Mage_Catalog_Model_Product
Return values
stringgetStatuses()
public
getStatuses() : array<string|int, mixed>
Return values
array<string|int, mixed>getThumbnailUrl()
public
getThumbnailUrl(Mage_Catalog_Model_Product $product) : string
a product has one image, use getImageUrl()
Parameters
- $product : Mage_Catalog_Model_Product
Return values
stringhasTags()
Check for tags in multidimensional arrays
public
hasTags(string|array<string|int, mixed> $data[, array<string|int, mixed> $arrayKeys = [] ][, bool $skipTags = true ]) : bool
Parameters
- $data : string|array<string|int, mixed>
- $arrayKeys : array<string|int, mixed> = []
-
keys of the array being checked that are excluded and included in the check
- $skipTags : bool = true
-
skip transferred array keys, if false then check only them
Return values
boolinitProduct()
Inits product to be used for product controller actions and layouts $params can have following data: 'category_id' - id of category to check and append to product as current.
public
initProduct(int $productId, Mage_Core_Controller_Front_Action $controller[, DataObject $params = null ]) : false|Mage_Catalog_Model_Product
If empty (except FALSE) - will be guessed (e.g. from last visited) to load as current.
Parameters
- $productId : int
- $controller : Mage_Core_Controller_Front_Action
- $params : DataObject = null
Return values
false|Mage_Catalog_Model_ProductisInternalUrl()
Check whether a URL points at this store, i.e. is safe to redirect to.
public
isInternalUrl(string $url) : bool
Parameters
- $url : string
Return values
boolisModuleEnabled()
Check is module exists and enabled in global config.
public
isModuleEnabled([string $moduleName = null ]) : bool
Parameters
- $moduleName : string = null
-
the full module name, example Mage_Core
Return values
boolisModuleOutputEnabled()
Check whether the module output is enabled in Configuration
public
isModuleOutputEnabled([string $moduleName = null ]) : bool
Parameters
- $moduleName : string = null
-
Full module name
Return values
boolisRequestPathGone()
Whether the originally requested path belongs to a deleted entity and must return 410 Gone
public
isRequestPathGone(Mage_Core_Controller_Request_Http $request) : bool
Parameters
- $request : Mage_Core_Controller_Request_Http
Return values
boolisVisibleInStore()
Return whether the storefront of the store $storeId shows $product: canShow(), and the product is in the website.
public
isVisibleInStore(Mage_Catalog_Model_Product $product, int $storeId) : bool
Parameters
- $product : Mage_Catalog_Model_Product
- $storeId : int
Return values
booljsEscape()
Encode $data as a complete JavaScript literal. The result includes its own quotes.
public
jsEscape(mixed $data) : string
The result is HTML-safe. Use it in an HTML attribute or in a script block without escapeHtml().
Parameters
- $data : mixed
Return values
stringjsQuoteEscape()
Put a backslash before each $quote in $data. Use the result inside a JavaScript string that the template quotes with the same $quote. The result has no quotes of its own.
public
jsQuoteEscape(string $data[, string $quote = '\'' ]) : string
The result is not HTML-safe. Backslashes and newlines are not escaped. Prefer jsEscape(): it returns a complete and HTML-safe JavaScript literal.
Parameters
- $data : string
- $quote : string = '\''
Tags
Return values
stringprepareProductOptions()
Prepares product options by buyRequest: retrieves values and assigns them as default.
public
prepareProductOptions(Mage_Catalog_Model_Product $product, DataObject $buyRequest) : $this
Also parses and adds product management related values - e.g. qty
Parameters
- $product : Mage_Catalog_Model_Product
- $buyRequest : DataObject
Return values
$thisquoteEscape()
Escape quotes inside html attributes Use $addSlashes = false for escaping js that inside html attribute (onClick, onSubmit etc)
public
quoteEscape(string $data[, bool $addSlashes = false ]) : string
Parameters
- $data : string
- $addSlashes : bool = false
Return values
stringremoveRequestParam()
Remove query parameter from url
public
removeRequestParam(string $url, string $paramKey[, bool $caseSensitive = false ]) : string
Parameters
- $url : string
- $paramKey : string
- $caseSensitive : bool = false
Return values
stringremoveRouteParam()
Remove varien route param from URL
public
removeRouteParam(string $url, string $paramKey) : string
Parameters
- $url : string
- $paramKey : string
Return values
stringremoveTags()
Remove html tags, but leave "<" and ">" signs
public
removeTags(string $html) : string
Parameters
- $html : string
Return values
stringremoveTrailingSlash()
Remove trailing slash from URL
public
removeTrailingSlash(string $url) : string
Parameters
- $url : string
Return values
stringsetLayout()
Declare layout
public
setLayout(Mage_Core_Model_Layout $layout) : Mage_Core_Helper_Abstract
Parameters
- $layout : Mage_Core_Model_Layout
Return values
Mage_Core_Helper_AbstractsetRouteParams()
Add, update, or remove multiple varien route params in URL
public
setRouteParams(string $url[, array<string|int, mixed> $params = [] ]) : string
Parameters
- $url : string
- $params : array<string|int, mixed> = []
Return values
stringsetSkipSaleableCheck()
Set flag that shows if Maho has to check product to be saleable (enabled and/or inStock)
public
setSkipSaleableCheck([bool $skipSaleableCheck = false ]) : $this
For instance, during order creation in the backend admin has ability to add any products to order
Parameters
- $skipSaleableCheck : bool = false
Return values
$thisstripTags()
Wrapper for standard strip_tags() function with extra functionality for html entities
public
stripTags(string $data[, null|string|array<string|int, string> $allowableTags = null ][, bool $escape = false ]) : string
Parameters
- $data : string
- $allowableTags : null|string|array<string|int, string> = null
- $escape : bool = false
Return values
stringtranslateArray()
Translate array
public
translateArray([mixed $arr = [] ]) : array<string|int, mixed>
@param array $arr
Parameters
- $arr : mixed = []
Return values
array<string|int, mixed>urlDecode()
base64_decode() for URLs decoding
public
urlDecode(mixed $url) : string
@param string $url
Parameters
- $url : mixed
Return values
stringurlDecodeAndEscape()
base64_decode() and escape quotes in url
public
urlDecodeAndEscape(mixed $url) : string
@param string $url
Parameters
- $url : mixed
Return values
stringurlEncode()
base64_encode() for URLs encoding
public
urlEncode(mixed $url) : string
@param string $url
Parameters
- $url : mixed
Return values
string_cleanCache()
Cleaning cache
protected
_cleanCache([array<string|int, mixed> $tags = [] ]) : Mage_Core_Helper_Abstract
Parameters
- $tags : array<string|int, mixed> = []
Return values
Mage_Core_Helper_Abstract_getModuleName()
Retrieve helper module name
protected
_getModuleName() : string
Return values
string_getRequest()
Retrieve request object
protected
_getRequest() : Mage_Core_Controller_Request_Http
Return values
Mage_Core_Controller_Request_Http_getUrl()
Retrieve url
protected
_getUrl(string $route[, array<string|int, mixed> $params = [] ]) : string
Parameters
- $route : string
- $params : array<string|int, mixed> = []
Return values
string_loadCache()
Loading cache data
protected
_loadCache(string $id) : mixed
Parameters
- $id : string
_prepareString()
Formatting string
protected
_prepareString(string $string) : string
Parameters
- $string : string
Return values
string_removeCache()
Removing cache
protected
_removeCache(string $id) : Mage_Core_Helper_Abstract
Parameters
- $id : string
Return values
Mage_Core_Helper_Abstract_saveCache()
Saving cache
protected
_saveCache(mixed $data, string $id[, array<string|int, mixed> $tags = [] ][, null|false|int $lifeTime = false ]) : Mage_Core_Helper_Abstract
Parameters
- $data : mixed
- $id : string
- $tags : array<string|int, mixed> = []
- $lifeTime : null|false|int = false