本文整理汇总了PHP中Mage_Catalog_Model_Product::getData方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Product::getData方法的具体用法?PHP Mage_Catalog_Model_Product::getData怎么用?PHP Mage_Catalog_Model_Product::getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Product
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Product::getData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isPriceSpecial
public function isPriceSpecial(Mage_Catalog_Model_Product $product)
{
/*
* Check if sale price is activated and if so if sale price is LESS than normal price
* I.E., customer might be a Member, so the member price might be less than sale price
*/
$originalPrice = $product->getPrice();
$finalPrice = $product->getFinalPrice();
if ($finalPrice < $originalPrice) {
return self::SPECIAL_PRICE;
}
/*
* check if product is new
*/
$current_date = time();
// compare date
$from_date = $product->getData('news_from_date');
// begin date
$to_date = $product->getData('news_to_date');
// end date
if ($this->isDateBetween($current_date, $from_date, $to_date)) {
return self::NEW_PRODUCT;
}
return false;
}
示例2: getValueByProductInstance
/**
* @param Mage_Catalog_Model_Product $product
* @return mixed
*/
public function getValueByProductInstance(Mage_Catalog_Model_Product $product)
{
$status = $product->getData('amazon_status');
$variationChildStatuses = $product->getData('variation_child_statuses');
if ($product->getData('is_variation_parent') && !empty($variationChildStatuses)) {
$status = json_decode($variationChildStatuses, true);
}
return $status;
}
示例3: getValueByProductInstance
/**
* @param Mage_Catalog_Model_Product $product
* @return array|mixed
*/
public function getValueByProductInstance(Mage_Catalog_Model_Product $product)
{
$minPrice = $product->getData('min_online_price');
$maxPrice = $product->getData('max_online_price');
if (!empty($minPrice) && !empty($maxPrice) && $minPrice != $maxPrice) {
return array($product->getData('min_online_price'), $product->getData('max_online_price'));
}
return $product->getData('min_online_price');
}
示例4: _getObject
protected function _getObject($field)
{
$obj = $this->_product;
if (isset($field['obj'])) {
$obj = $this->_product->getData($field['obj']);
// for example, stock_item
}
return $obj;
}
示例5: beforeProcess
public function beforeProcess()
{
$product = $this->getEvent()->getProduct();
if (!$product instanceof Mage_Catalog_Model_Product) {
throw new Ess_M2ePro_Model_Exception('Product event doesn\'t have correct Product instance.');
}
$this->product = $product;
$this->productId = (int) $this->product->getId();
$this->storeId = (int) $this->product->getData('store_id');
}
示例6: refreshUpSells
/**
* ReIndex UpSells for the product
*
* @param Mage_Catalog_Model_Product $product
*/
protected function refreshUpSells(Mage_Catalog_Model_Product $product)
{
$upSellCollection = $product->getUpSellProductCollection();
if ($upSellCollection->count() > 0) {
/** @var \Mage_Index_Model_Indexer $indexer */
$indexer = Mage::getSingleton('index/indexer');
foreach ($upSellCollection as $product) {
$indexer->processEntityAction(new Varien_Object(array('id' => $product->getId(), 'store_id' => $product->getStoreId(), 'rule' => $product->getData('rule'), 'from_date' => $product->getData('from_date'), 'to_date' => $product->getData('to_date'))), Enterprise_TargetRule_Model_Index::ENTITY_PRODUCT, Enterprise_TargetRule_Model_Index::EVENT_TYPE_REINDEX_PRODUCTS);
}
}
}
示例7: getValueByProductInstance
public function getValueByProductInstance(Mage_Catalog_Model_Product $product)
{
$generalId = $product->getData('general_id');
if (!empty($generalId)) {
return Ess_M2ePro_Model_Amazon_Listing_Product::GENERAL_ID_STATE_SET;
}
if ($product->getData('is_general_id_owner') == 1) {
return Ess_M2ePro_Model_Amazon_Listing_Product::GENERAL_ID_STATE_READY_FOR_NEW_ASIN;
}
$searchStatusActionRequired = Ess_M2ePro_Model_Amazon_Listing_Product::SEARCH_SETTINGS_STATUS_ACTION_REQUIRED;
$searchStatusNotFound = Ess_M2ePro_Model_Amazon_Listing_Product::SEARCH_SETTINGS_STATUS_NOT_FOUND;
if ($product->getData('search_settings_status') == $searchStatusActionRequired || $product->getData('search_settings_status') == $searchStatusNotFound) {
return Ess_M2ePro_Model_Amazon_Listing_Product::GENERAL_ID_STATE_ACTION_REQUIRED;
}
return Ess_M2ePro_Model_Amazon_Listing_Product::GENERAL_ID_STATE_NOT_SET;
}
示例8: 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;
}
示例9: createIndexData
public function createIndexData(Mage_Catalog_Model_Product $object, Mage_Eav_Model_Entity_Attribute_Abstract $attribute = null)
{
$data = array();
$data['store_id'] = $attribute->getStoreId();
$data['entity_id'] = $object->getId();
$data['attribute_id'] = $attribute->getId();
$result = array();
$values = $object->getData($attribute->getAttributeCode());
if (!is_array($values)) {
return $result;
}
foreach ($values as $row) {
if (isset($row['delete']) && $row['delete']) {
continue;
}
$data['qty'] = $row['price_qty'];
$data['value'] = $row['price'];
if ($row['cust_group'] == Mage_Customer_Model_Group::CUST_GROUP_ALL) {
foreach ($this->_customerGroups as $group) {
$data['customer_group_id'] = $group->getId();
$result[] = $data;
}
} else {
$data['customer_group_id'] = $row['cust_group'];
$result[] = $data;
}
}
return $result;
}
示例10: afterSave
/**
* After attribute is saved upload file to media
* folder and save it to its associated product.
*
* @param Mage_Catalog_Model_Product $object
* @return Jvs_FileAttribute_Model_Attribute_Backend_File
*/
public function afterSave($object)
{
$value = $object->getData($this->getAttribute()->getName());
if (is_array($value) && !empty($value['delete'])) {
$object->setData($this->getAttribute()->getName(), '');
$this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
return;
}
try {
$uploadedFile = new Varien_Object();
$uploadedFile->setData('name', $this->getAttribute()->getName());
$uploadedFile->setData('allowed_extensions', array('jpg', 'jpeg', 'gif', 'png', 'tif', 'tiff', 'mpg', 'mpeg', 'mp3', 'wav', 'pdf', 'txt'));
Mage::dispatchEvent('jvs_fileattribute_allowed_extensions', array('file' => $uploadedFile));
$uploader = new Mage_Core_Model_File_Uploader($this->getAttribute()->getName());
$uploader->setAllowedExtensions($uploadedFile->getData('allowed_extensions'));
$uploader->setAllowRenameFiles(true);
$uploader->setFilesDispersion(true);
$uploader->save(Mage::getBaseDir('media') . '/catalog/product');
} catch (Exception $e) {
return $this;
}
$fileName = $uploader->getUploadedFileName();
if ($fileName) {
$object->setData($this->getAttribute()->getName(), $fileName);
$this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
}
return $this;
}
示例11: afterSave
/**
* After Save Attribute manipulation
*
* @param Mage_Catalog_Model_Product $object
* @return Mage_Catalog_Model_Product_Attribute_Backend_Price
*/
public function afterSave($object)
{
$value = $object->getData($this->getAttribute()->getAttributeCode());
/**
* Orig value is only for existing objects
*/
$oridData = $object->getOrigData();
$origValueExist = $oridData && array_key_exists($this->getAttribute()->getAttributeCode(), $oridData);
if ($object->getStoreId() != 0 || !$value || $origValueExist) {
return $this;
}
if ($this->getAttribute()->getIsGlobal() == Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE) {
$baseCurrency = Mage::app()->getBaseCurrencyCode();
$storeIds = $object->getStoreIds();
if (is_array($storeIds)) {
foreach ($storeIds as $storeId) {
$storeCurrency = Mage::app()->getStore($storeId)->getBaseCurrencyCode();
if ($storeCurrency == $baseCurrency) {
continue;
}
$rate = Mage::getModel('directory/currency')->load($baseCurrency)->getRate($storeCurrency);
if (!$rate) {
$rate = 1;
}
$newValue = $value * $rate;
$object->addAttributeUpdate($this->getAttribute()->getAttributeCode(), $newValue, $storeId);
}
}
}
return $this;
}
示例12: getFullProductUrl
/**
* get the longest url for a product
* from http://magento.stackexchange.com/questions/52969/get-product-path-from-id-with-category-path-in-url
* @param Mage_Catalog_Model_Product|null $product [description]
* @return String full url of the product
*/
public static function getFullProductUrl(Mage_Catalog_Model_Product $product = null)
{
// Force display deepest child category as request path.
$categories = $product->getCategoryCollection();
$deepCatId = 0;
$path = '';
$productPath = false;
foreach ($categories as $category) {
// Look for the deepest path and save.
if (substr_count($category->getData('path'), '/') > substr_count($path, '/')) {
$path = $category->getData('path');
$deepCatId = $category->getId();
}
}
// Load category.
$category = Mage::getModel('catalog/category')->load($deepCatId);
// Remove .html from category url_path.
$categoryPath = str_replace('.html', '', $category->getData('url_path'));
// Get product url path if set.
$productUrlPath = $product->getData('url_path');
// Get product request path if set.
$productRequestPath = $product->getData('request_path');
// If URL path is not found, try using the URL key.
if ($productUrlPath === null && $productRequestPath === null) {
$productUrlPath = $product->getData('url_key');
}
// Now grab only the product path including suffix (if any).
if ($productUrlPath) {
$path = explode('/', $productUrlPath);
$productPath = array_pop($path);
} elseif ($productRequestPath) {
$path = explode('/', $productRequestPath);
$productPath = array_pop($path);
}
// Now set product request path to be our full product url including deepest category url path.
if ($productPath !== false) {
if ($categoryPath) {
// Only use the category path is one is found.
$product->setData('request_path', $categoryPath . '/' . $productPath);
} else {
$product->setData('request_path', $productPath);
}
}
return $product->getProductUrl();
}
示例13: validate
/**
* Implode data for validation
*
* @param Mage_Catalog_Model_Product $object
* @return bool
*/
public function validate($object)
{
$attributeCode = $this->getAttribute()->getAttributeCode();
$data = $object->getData($attributeCode);
if (is_array($data)) {
$object->setData($attributeCode, implode(',', array_filter($data)));
}
return parent::validate($object);
}
示例14: getAddUrl
/**
* Retrieve url for adding product to conpare list
*
* @param Mage_Catalog_Model_Product $product
* @return string
*/
public function getAddUrl($product)
{
$config = Mage::getStoreConfig('advancedcompare/general');
if ($config['removecompare'] || $config['removelink'] && (bool) $product->getData('remove_compare_link')) {
return false;
} else {
return parent::getAddUrl($product);
}
}
示例15: matchProduct
/**
* @param Mage_Catalog_Model_Product $product
* @return bool
*/
protected function matchProduct($product)
{
foreach ($this->requestConfigurableMap as $code => $values) {
if (!in_array($product->getData($code), $values)) {
return false;
}
}
return true;
}