Documentation

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

$_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 = []

$_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
string

addOrRemoveTrailingSlash()

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
string

addParamsToBuyRequest()

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
DataObject

addRequestParam()

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
string

addRouteParam()

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
string

addTrailingSlash()

Add trailing slash to URL

public addTrailingSlash(string $url) : string
Parameters
$url : string
Return values
string

buildUrl()

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
string

canUseCanonicalTag()

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
bool

decodePunycode()

Retrieve decoding domain name from punycode

public decodePunycode(string $url) : string
Parameters
$url : string

decode url from Punycode

Tags
throws
Exception
Return values
string

encodePunycode()

Retrieve encoding domain name in punycode

public encodePunycode(string $url) : string
Parameters
$url : string

encode url to Punycode

Return values
string

escapeHtml()

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
string

escapeSpecial()

Remove `\t`,`\n`,`\r`,`\0`,`\x0B:` symbols from the string.

public escapeSpecial(string $data) : string
Parameters
$data : string
Return values
string

escapeUrl()

Escape html entities in url

public escapeUrl(string $data) : string
Parameters
$data : string
Return values
string

getAttributeBackendModelByInputType()

Return default attribute backend model by input type

public getAttributeBackendModelByInputType(string $inputType) : string|null
Parameters
$inputType : string
Return values
string|null

getAttributeFrontendModelByInputType()

Return default attribute frontend model by input type

public getAttributeFrontendModelByInputType(string $inputType) : string|null
Parameters
$inputType : string
Return values
string|null

getAttributeInputTypes()

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|null

getCurrentBase64Url()

Retrieve current url in base64 encoding

public getCurrentBase64Url() : string
Return values
string

getCurrentUrl()

Retrieve current url

public getCurrentUrl() : string
Return values
string

getDefaultProductValue()

Get default product value by field name

public getDefaultProductValue(string $fieldName, string $productType) : int
Parameters
$fieldName : string
$productType : string
Return values
int

getEncodedUrl()

Return encoded url

public getEncodedUrl([null|string $url = null ]) : string
Parameters
$url : null|string = null
Return values
string

getFieldset()

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>|null

getFullProductUrl()

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
string

getHomeUrl()

Retrieve homepage url

public getHomeUrl() : string
Return values
string

getProduct()

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_Product

getProductUrlSuffix()

Retrieve product rewrite sufix for store

public getProductUrlSuffix([int $storeId = null ]) : string
Parameters
$storeId : int = null
Return values
string

getRequestPathCandidates()

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>

getSkipSaleableCheck()

Get flag that shows if Maho has to check product to be saleable (enabled and/or inStock)

public getSkipSaleableCheck() : bool
Return values
bool

getStatuses()

public getStatuses() : array<string|int, mixed>
Return values
array<string|int, mixed>

hasTags()

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
bool

initProduct()

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_Product

isInternalUrl()

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
bool

isModuleEnabled()

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
bool

isModuleOutputEnabled()

Check whether the module output is enabled in Configuration

public isModuleOutputEnabled([string $moduleName = null ]) : bool
Parameters
$moduleName : string = null

Full module name

Return values
bool

isVisibleInStore()

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
bool

jsEscape()

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
string

jsQuoteEscape()

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
used-by
Mage_Core_Helper_Js::getDeleteConfirmJs()
Mage_Core_Helper_Js::getConfirmSetLocationJs()
Return values
string

quoteEscape()

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
string

removeRequestParam()

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
string

removeRouteParam()

Remove varien route param from URL

public removeRouteParam(string $url, string $paramKey) : string
Parameters
$url : string
$paramKey : string
Return values
string

removeTags()

Remove html tags, but leave "<" and ">" signs

public removeTags(string $html) : string
Parameters
$html : string
Return values
string

removeTrailingSlash()

Remove trailing slash from URL

public removeTrailingSlash(string $url) : string
Parameters
$url : string
Return values
string

setRouteParams()

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
string

setSkipSaleableCheck()

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
$this

stripTags()

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
string

translateArray()

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
string

urlDecodeAndEscape()

base64_decode() and escape quotes in url

public urlDecodeAndEscape(mixed $url) : string

@param string $url

Parameters
$url : mixed
Return values
string

urlEncode()

base64_encode() for URLs encoding

public urlEncode(mixed $url) : string

@param string $url

Parameters
$url : mixed
Return values
string

_getModuleName()

Retrieve helper module name

protected _getModuleName() : string
Return values
string

_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

_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
Return values
Mage_Core_Helper_Abstract
On this page

Search results