本文整理汇总了PHP中Mage_Catalog_Model_Product::hasData方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Product::hasData方法的具体用法?PHP Mage_Catalog_Model_Product::hasData怎么用?PHP Mage_Catalog_Model_Product::hasData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Product
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Product::hasData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _createProduct
/**
* @param Mage_Catalog_Model_Product $product
* @return array
*/
protected function _createProduct(Mage_Catalog_Model_Product $product)
{
$brand = null;
if ($product->hasData('brand')) {
$brand = $product->getAttributeText('brand');
}
$manufacturer = null;
if ($product->hasData('manufacturer')) {
$manufacturer = $product->getAttributeText('manufacturer');
}
$data = array('id' => $product->getEntityId(), 'productTypeId' => $this->_getProductTypeId($product), 'name' => array($this->_createLocalizedValue($product->getName())), 'shortDescription' => array($this->_createLocalizedValue($product->getShortDescription())), 'description' => array($this->_createLocalizedValue($product->getDescription())), 'GTIN' => $product->hasData('gtin') ? $product->getAttributeText('gtin') : null, 'brand' => !empty($brand) ? array($this->_createLocalizedValue($brand)) : null, 'manufacturer' => !empty($manufacturer) ? array($this->_createLocalizedValue($manufacturer)) : null, 'MPN' => $product->hasData('mpn') ? $product->getAttributeText('mpn') : null, 'MSRP' => $this->_getMsrp($product), 'MAP' => $product->hasData('map') ? $this->_getCurrencyAmount($product->getAttributeText('map')) : null, 'images' => $this->_createImageUrls($product), 'attributes' => $this->_createAttributes($product), 'variationFactors' => $this->_createVariationFactors($product), 'skuList' => $this->_createSkus($product));
return $data;
}
示例2: hasLinks
/**
* Check if product has links
*
* @param Mage_Catalog_Model_Product $product
* @return boolean
*/
public function hasLinks($product)
{
if ($product->hasData('links_exist')) {
return $product->getData('links_exist');
}
return count($this->getLinks($product)) > 0;
}
示例3: getAdjustmentAmount
public function getAdjustmentAmount(Mage_Catalog_Model_Product $product, $default = 0.0)
{
$default = round($default, 2);
if ($product->hasData('lokey_pisa_amount')) {
$adjustment = round($product->getData('lokey_pisa_amount'), 2);
} else {
$adjustment = $default;
}
return max($adjustment, 0.0);
}
示例4: isBundleProductSimple
/**
* @param Mage_Catalog_Model_Product $product
* @return bool
* @todo
*/
public function isBundleProductSimple(Mage_Catalog_Model_Product $product)
{
if (!$product->hasData('is_bundle_simple')) {
/** @var Ho_SimpleBundle_Model_Bundle_Product_Type $typeInstance */
$typeInstance = $product->getTypeInstance(true);
$optionsCollection = $typeInstance->getOptionsCollection($product);
$optionsCollection->addFieldToFilter('type', array('neq' => 'fixed'));
$select = $optionsCollection->getSelect();
$select->reset('columns');
$select->columns('type');
$result = $optionsCollection->getConnection()->fetchCol($select);
$product->setData('is_bundle_simple', !count($result));
}
return $product->getData('is_bundle_simple');
}
示例5: getProductSplashPage
/**
* Retrieve a splash page for the product / attribute code combination
*
* @param Mage_Catalog_Model_Product $product
* @param $attributeCode
* @return Fishpig_AttributeSplash_Model_Splash|null
*/
public function getProductSplashPage(Mage_Catalog_Model_Product $product, $attributeCode)
{
$key = $attributeCode . '_splash_page';
if (!$product->hasData($key)) {
$product->setData($key, false);
$collection = Mage::getResourceModel('attributeSplash/page_collection')->addStoreFilter(Mage::app()->getStore())->addAttributeCodeFilter($attributeCode)->addProductFilter($product)->setPageSize(1)->setCurPage(1)->load();
if (count($collection) > 0) {
$page = $collection->getFirstItem();
if ($page->getId()) {
$product->setData($key, $page);
}
}
}
return $product->getData($key);
}
示例6: loadProductSubscriptionData
/**
* @param Mage_Catalog_Model_Product $product
*
* @return $this
*/
public function loadProductSubscriptionData(Mage_Catalog_Model_Product $product)
{
if ($product->hasData('adyen_subscription_data')) {
return $this;
}
/** @var Mage_Catalog_Model_Product $product */
if ($product->getData('adyen_subscription_type') > 0) {
$subscriptionCollection = Mage::getResourceModel('adyen_subscription/product_subscription_collection')->addProductFilter($product);
if (!$product->getStore()->isAdmin()) {
$subscriptionCollection->addStoreFilter($product->getStore());
}
$subscriptionCollection->setOrder('sort_order', 'ASC');
$product->setData('adyen_subscription_data', $subscriptionCollection);
} else {
$product->setData('adyen_subscription_data', null);
}
return $this;
}
示例7: _resizeProductImage
/**
* Resize specified type of image on the product for use in the fallback and returns the image URL
* or returns the image URL for the specified image path if present
*
* @param Mage_Catalog_Model_Product $product
* @param string $type
* @param bool $keepFrame
* @param string $image
* @param bool $placeholder
* @return string|bool
*/
protected function _resizeProductImage($product, $type, $keepFrame, $image = null, $placeholder = false)
{
$hasTypeData = $product->hasData($type) && $product->getData($type) != 'no_selection';
if ($image == 'no_selection') {
$image = null;
}
if ($hasTypeData || $placeholder || $image) {
$helper = Mage::helper('catalog/image')->init($product, $type, $image)->keepFrame($hasTypeData || $image ? $keepFrame : false);
$size = Mage::getStoreConfig(Mage_Catalog_Helper_Image::XML_NODE_PRODUCT_BASE_IMAGE_WIDTH);
if ($type == 'small_image') {
$size = Mage::getStoreConfig(Mage_Catalog_Helper_Image::XML_NODE_PRODUCT_SMALL_IMAGE_WIDTH);
}
if (is_numeric($size)) {
if ($type == "small_image") {
$helper->constrainOnly(true)->resize(500, 500);
} else {
$helper->constrainOnly(true)->resize($size);
}
}
return (string) $helper;
}
return false;
}
示例8: getProductAttributeValue
/**
* Retrieve Product Attribute Value
*
* @param Mage_Catalog_Model_Product $product
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
* @return string
*/
public function getProductAttributeValue($product, $attribute)
{
if (!$product->hasData($attribute->getAttributeCode())) {
return ' ';
}
if ($attribute->getSourceModel() || in_array($attribute->getFrontendInput(), array('select', 'boolean', 'multiselect'))) {
//$value = $attribute->getSource()->getOptionText($product->getData($attribute->getAttributeCode()));
$value = $attribute->getFrontend()->getValue($product);
} else {
$value = $product->getData($attribute->getAttributeCode());
}
return $value ? $value : ' ';
}
示例9: getSelectionsCollection
/**
* Retrive bundle selections collection based on used options
*
* @param array $optionIds
* @param Mage_Catalog_Model_Product $product
* @return Mage_Bundle_Model_Resource_Selection_Collection
*/
public function getSelectionsCollection($optionIds, $product)
{
$keyOptionIds = is_array($optionIds) ? implode('_', $optionIds) : '';
$key = $this->_keySelectionsCollection . $keyOptionIds;
if (!$product->hasData($key)) {
$storeId = $product->getStoreId();
$selectionsCollection = Mage::getResourceModel('Mage_Bundle_Model_Resource_Selection_Collection')->addAttributeToSelect(Mage::getSingleton('Mage_Catalog_Model_Config')->getProductAttributes())->addAttributeToSelect('tax_class_id')->setFlag('require_stock_items', true)->setFlag('product_children', true)->setPositionOrder()->addStoreFilter($this->getStoreFilter($product))->setStoreId($storeId)->addFilterByRequiredOptions()->setOptionIdsFilter($optionIds);
if (!Mage::helper('Mage_Catalog_Helper_Data')->isPriceGlobal() && $storeId) {
$websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
$selectionsCollection->joinPrices($websiteId);
}
$product->setData($key, $selectionsCollection);
}
return $product->getData($key);
}
示例10: getAssociatedProductIds
/**
* Retrieve related products identifiers
*
* @param Mage_Catalog_Model_Product $product
* @return array
*/
public function getAssociatedProductIds($product)
{
if (!$product->hasData($this->_keyAssociatedProductIds)) {
$associatedProductIds = array();
foreach ($this->getAssociatedProducts($product) as $item) {
$associatedProductIds[] = $item->getId();
}
$product->setData($this->_keyAssociatedProductIds, $associatedProductIds);
}
return $product->getData($this->_keyAssociatedProductIds);
}
示例11: getProductUrl
/**
* Get product url
*
* @param Mage_Catalog_Model_Product $product
* @param bool $useSid
* @return string
*/
public function getProductUrl($product, $useSid = null)
{
if ($useSid === null) {
$useSid = Mage::app()->getUseSessionInUrl();
}
$categoryId = $product->getCategoryId() && !$product->getDoNotUseCategoryId() ? $product->getCategoryId() : 0;
$cacheUrlKey = sprintf('url_%d_%d', $categoryId, $useSid);
$url = $product->getData($cacheUrlKey);
if (is_null($url)) {
if ($product->getStoreId()) {
$this->getUrlInstance()->setStore($product->getStoreId());
}
// auto add SID to URL
$originalSid = $this->getUrlInstance()->getUseSession();
if ($originalSid != $useSid) {
$this->getUrlInstance()->setUseSession($useSid);
}
if ($product->hasData('request_path') && $product->getRequestPath() != '') {
$this->setData($cacheUrlKey, $this->getUrlInstance()->getDirectUrl($product->getRequestPath()));
$this->getUrlInstance()->setUseSession($originalSid);
return $this->getData($cacheUrlKey);
}
Varien_Profiler::start('REWRITE: ' . __METHOD__);
$rewrite = $this->getUrlRewrite();
if ($product->getStoreId()) {
$rewrite->setStoreId($product->getStoreId());
} else {
$rewrite->setStoreId(Mage::app()->getStore()->getId());
}
$idPath = 'product/' . $product->getId();
if ($product->getCategoryId() && !$product->getDoNotUseCategoryId() && Mage::getStoreConfig('catalog/seo/product_use_categories')) {
$idPath .= '/' . $product->getCategoryId();
}
$rewrite->loadByIdPath($idPath);
//echo $this->getUrlInstance()->getBaseUrl();
if ($rewrite->getId()) {
$this->setData($cacheUrlKey, $this->getUrlInstance()->getDirectUrl($rewrite->getRequestPath()));
Varien_Profiler::stop('REWRITE: ' . __METHOD__);
$this->getUrlInstance()->setUseSession($originalSid);
return $this->getData($cacheUrlKey);
}
Varien_Profiler::stop('REWRITE: ' . __METHOD__);
Varien_Profiler::start('REGULAR: ' . __METHOD__);
$url = $this->getUrlInstance()->getUrl('catalog/product/view', array('id' => $product->getId(), 's' => $product->getUrlKey(), 'category' => $product->getCategoryId()));
$this->getUrlInstance()->setUseSession($originalSid);
Varien_Profiler::stop('REGULAR: ' . __METHOD__);
}
return $url;
}
示例12: loadProductRules
/**
* Load matched product rules to the product
*
* @param Mage_Catalog_Model_Product $product
* @return $this
*/
public function loadProductRules(Mage_Catalog_Model_Product $product)
{
if (!$product->hasData('matched_rules')) {
$product->setMatchedRules($this->getResource()->getProductRuleIds($product->getId()));
}
return $this;
}
示例13: _writeOrderProductAttribute
protected function _writeOrderProductAttribute(Mage_Catalog_Model_Product $product, XMLWriter $xml, $storeId = null)
{
// custom attributes are specified in Admin > Configuration > Sales > Auctane Shipstation API
// static because attributes can be cached, they do not change during a request
static $attrs = null;
if (is_null($attrs)) {
$attrs = Mage::getResourceModel('eav/entity_attribute_collection');
$attrIds = explode(',', Mage::getStoreConfig('sales/auctaneapi/customattributes', $storeId));
$attrs->addFieldToFilter('attribute_id', $attrIds);
}
/* @var $attr Mage_Eav_Model_Entity_Attribute */
foreach ($attrs as $attr) {
if ($product->hasData($attr->getName())) {
// if an attribute has options/labels
if (in_array($attr->getFrontendInput(), array('select', 'multiselect'))) {
$value = $product->getAttributeText($attr->getName());
if (is_array($value)) {
$value = implode(',', $value);
}
} else {
$value = $product->getDataUsingMethod($attr->getName());
}
// fake an item option
$option = array('value' => $value, 'label' => $attr->getFrontendLabel());
$this->_writeOrderItemOption($option, $xml, $storeId);
}
}
}
示例14: _resizeProductImage
/**
* Resize specified type of image on the product for use in the fallback and returns the image URL
* or returns the image URL for the specified image path if present
*
* @param Mage_Catalog_Model_Product $product
* @param string $type
* @param bool $keepFrame
* @param string $image
* @param bool $placeholder
* @return string|bool
*/
protected function _resizeProductImage($product, $type, $keepFrame, $image = null, $placeholder = false, $imgWidth = null, $imgHeight = null)
{
$hasTypeData = $product->hasData($type) && $product->getData($type) != 'no_selection';
if ($image == 'no_selection') {
$image = null;
}
if ($hasTypeData || $placeholder || $image) {
$helper = Mage::helper('catalog/image')->init($product, $type, $image)->keepFrame($hasTypeData || $image ? $keepFrame : false);
if ($keepFrame) {
$helper->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize($imgWidth);
} else {
if ($imgHeight != null) {
$helper->constrainOnly(true)->resize($imgWidth, $imgHeight);
} else {
$helper->constrainOnly(true)->resize($imgWidth);
}
}
return (string) $helper;
}
return false;
}
示例15: getUsedProducts
/**
* Retrieve array of "subproducts"
*
* @param Mage_Catalog_Model_Product $product
* @param array $requiredAttributeIds
* @return array
*/
public function getUsedProducts($product, $requiredAttributeIds = null)
{
Magento_Profiler::start('CONFIGURABLE:' . __METHOD__);
if (!$product->hasData($this->_usedProducts)) {
if (is_null($requiredAttributeIds) and is_null($product->getData($this->_configurableAttributes))) {
// If used products load before attributes, we will load attributes.
$this->getConfigurableAttributes($product);
// After attributes loading products loaded too.
Magento_Profiler::stop('CONFIGURABLE:' . __METHOD__);
return $product->getData($this->_usedProducts);
}
$usedProducts = array();
$collection = $this->getUsedProductCollection($product)->addAttributeToSelect('*')->addFilterByRequiredOptions();
if (is_array($requiredAttributeIds)) {
foreach ($requiredAttributeIds as $attributeId) {
$attribute = $this->getAttributeById($attributeId, $product);
if (!is_null($attribute)) {
$collection->addAttributeToFilter($attribute->getAttributeCode(), array('notnull' => 1));
}
}
}
foreach ($collection as $item) {
$usedProducts[] = $item;
}
$product->setData($this->_usedProducts, $usedProducts);
}
Magento_Profiler::stop('CONFIGURABLE:' . __METHOD__);
return $product->getData($this->_usedProducts);
}