本文整理汇总了PHP中Mage_Catalog_Model_Product::getWeight方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Product::getWeight方法的具体用法?PHP Mage_Catalog_Model_Product::getWeight怎么用?PHP Mage_Catalog_Model_Product::getWeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Product
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Product::getWeight方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importCatalogProduct
/**
* Import item data from product model object
*
* @param Mage_Catalog_Model_Product $product
* @return Mage_Sales_Model_Quote_Item
*/
public function importCatalogProduct(Mage_Catalog_Model_Product $product)
{
$this->setProductId($product->getId())->setSku($product->getSku())->setName($product->getName())->setWeight($product->getWeight())->setTaxClassId($product->getTaxClassId())->setCost($product->getCost())->setIsQtyDecimal($product->getIsQtyDecimal());
if ($product->getSuperProduct()) {
$this->setSuperProductId($product->getSuperProduct()->getId());
if ($product->getSuperProduct()->isConfigurable()) {
$this->setName($product->getSuperProduct()->getName());
}
}
$this->setProduct($product);
return $this;
}
示例2: getProductEntity
public function getProductEntity(Mage_Catalog_Model_Product $product, $storeId, $includeExtras = true)
{
$result = array();
$result['entity_id'] = $product->getEntityId();
$result['sku'] = $product->getSku();
$result['name'] = $product->getName();
$result['price'] = $product->getPrice();
$result['special_price'] = $product->getSpecialPrice();
$result['special_from_date'] = $product->getSpecialFromDate();
$result['special_to_date'] = $product->getSpecialToDate();
$result['cost'] = $product->getCost();
$result['description'] = $product->getDescription();
$result['short_description'] = $product->getShortDescription();
$result['weight'] = $product->getWeight();
if ($product->isVisibleInSiteVisibility()) {
$result['url_path'] = $this->_getProductUrlWithCache($product);
}
$parentProduct = $this->_getParentProduct($product);
if ($parentProduct != null) {
$result['parent_id'] = $parentProduct->getEntityId();
$result['parent_sku'] = $parentProduct->getSku();
if (!$product->isVisibleInSiteVisibility()) {
$result['name'] = $parentProduct->getName();
if ($parentProduct->isVisibleInSiteVisibility()) {
$result['url_path'] = $this->_getProductUrlWithCache($parentProduct);
}
}
if ($includeExtras && Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE == $parentProduct->getTypeId()) {
$result['purchasable'] = $this->_isPurchasable($product, $parentProduct);
$attributes = $parentProduct->getTypeInstance(true)->getUsedProductAttributes($parentProduct);
$freshProduct = null;
foreach ($attributes as $attribute) {
if (!array_key_exists('configurable_attributes', $result)) {
$result['configurable_attributes'] = array();
}
$attr = array();
$attr['attribute_name'] = $attribute->getFrontend()->getLabel();
$attr['value'] = $product->getAttributeText($attribute->getAttributeCode());
if (empty($attr['value'])) {
// use the EAV tables only if the flat table doesn't work
if ($freshProduct == null) {
$freshProduct = Mage::getModel('catalog/product')->load($product->getEntityId());
}
$attr['value'] = $attribute->getFrontend()->getValue($freshProduct);
}
$result['configurable_attributes'][] = $attr;
}
}
}
if (!isset($result['purchasable'])) {
$result['purchasable'] = $this->_isPurchasable($product);
}
$images = $this->_getProductImages($product);
if (isset($images['image'])) {
$result['image'] = $images['image'];
}
if (isset($images['small_image'])) {
$result['small_image'] = $images['small_image'];
}
if (isset($images['thumbnail'])) {
$result['thumbnail'] = $images['thumbnail'];
}
if ($includeExtras) {
// Metas
$metas = $this->_getMetas($storeId, $product, $parentProduct);
if ($metas != null) {
//if(isset($metas['meta1'])) $result['meta1'] = $metas['meta1'];
//if(isset($metas['meta2'])) $result['meta2'] = $metas['meta2'];
//if(isset($metas['meta3'])) $result['meta3'] = $metas['meta3'];
//if(isset($metas['meta4'])) $result['meta4'] = $metas['meta4'];
if (isset($metas['meta5'])) {
$result['meta5'] = $metas['meta5'];
}
}
//Custom For ST Bernard Sports
// Set IsNew Flag if product is less then 45 days old.
$result['meta4'] = strtotime($product->getCreatedAt()) + 45 * 24 * 60 * 60 < time() ? "False" : "True";
// Brand and Category
$brandAndCategoryProduct = !$parentProduct || $product->isVisibleInSiteVisibility() ? $product : $parentProduct;
$setSettings = $this->_getProductAttributeSetSettings($brandAndCategoryProduct);
if ($setSettings['brandAttribute'] != null) {
$result['brand'] = $brandAndCategoryProduct->getAttributeText($setSettings['brandAttribute']);
}
if ($setSettings['catFromMagento']) {
$cats = $this->_getCategoryInformation($storeId, $brandAndCategoryProduct);
if (isset($cats['category'])) {
$result['category'] = $cats['category'];
}
if (isset($cats['sub_category'])) {
$result['sub_category'] = $cats['sub_category'];
}
//Custom For ST Bernard Sports
if (isset($cats['third_category'])) {
$result['meta3'] = $cats['third_category'];
}
} else {
if ($setSettings['catFromAttributes']) {
if ($setSettings['categoryAttribute'] != null) {
$result['category'] = $brandAndCategoryProduct->getAttributeText($setSettings['categoryAttribute']);
}
//.........这里部分代码省略.........
示例3: getWeight
/**
* @param Mage_Catalog_Model_Product $product
*
* @return mixed
*/
public function getWeight($product)
{
return $product->getWeight() * $this->_getExportHelper()->getWeightFactor();
}
示例4: getProductEntity
/**
* Inflate an API object from a product object
*
* @param Mage_Catalog_Model_Product $product Product
* @param int $storeId Magento store ID
* @param bool $includeExtras Retrieve all information
*
* @return array
*/
public function getProductEntity(Mage_Catalog_Model_Product $product, $storeId, $includeExtras = true)
{
$result = array();
$result['entity_id'] = $product->getEntityId();
$result['sku'] = $product->getSku();
$result['name'] = $product->getName();
$result['price'] = $product->getPrice();
$result['special_price'] = $product->getSpecialPrice();
$result['special_from_date'] = $product->getSpecialFromDate();
$result['special_to_date'] = $product->getSpecialToDate();
$result['cost'] = $product->getCost();
$result['description'] = $product->getDescription();
$result['short_description'] = $product->getShortDescription();
$result['weight'] = $product->getWeight();
if ($product->isVisibleInSiteVisibility()) {
$result['url_path'] = $this->_getProductUrlWithCache($product);
}
$parentProduct = $this->_getParentProduct($product);
if ($parentProduct != null) {
$result['parent_id'] = $parentProduct->getEntityId();
$result['parent_sku'] = $parentProduct->getSku();
if (!$product->isVisibleInSiteVisibility()) {
$result['name'] = $parentProduct->getName();
if ($parentProduct->isVisibleInSiteVisibility()) {
$result['url_path'] = $this->_getProductUrlWithCache($parentProduct);
}
}
if ($includeExtras && $this->_isConfigurableProduct($parentProduct)) {
$result['purchasable'] = $this->_isPurchasable($product, $parentProduct);
/* @var Mage_Catalog_Model_Product_Type_Configurable $typeInst */
$typeInst = $parentProduct->getTypeInstance(true);
$attributes = $typeInst->getUsedProductAttributes($parentProduct);
/* @var Mage_Eav_Model_Entity_Attribute_Abstract $attribute */
foreach ($attributes as $attribute) {
if (!array_key_exists('configurable_attributes', $result)) {
$result['configurable_attributes'] = array();
}
$result['configurable_attributes'][] = array('attribute_name' => $attribute->getAttributeCode());
}
}
}
if (!isset($result['purchasable'])) {
$result['purchasable'] = $this->_isPurchasable($product);
}
$images = $this->_getProductImages($product);
if (isset($images['image'])) {
$result['image'] = $images['image'];
}
if (isset($images['small_image'])) {
$result['small_image'] = $images['small_image'];
}
if (isset($images['thumbnail'])) {
$result['thumbnail'] = $images['thumbnail'];
}
if ($includeExtras) {
$metas = $this->_getMetas($storeId, $product, $parentProduct);
if ($metas != null) {
/*if (isset($metas['meta3'])) {
$result['meta3'] = $metas['meta3'];
}*/
if (isset($metas['meta4'])) {
$result['meta4'] = $metas['meta4'];
}
if (isset($metas['meta5'])) {
$result['meta5'] = $metas['meta5'];
}
}
//Custom for Sportys
$stores = array();
foreach ($product->getStoreIds() as $storeID) {
$store = Mage::getModel('core/store')->load($storeID);
$stores[] = $store->getCode();
}
$result["meta3"] = implode(',', $stores);
// Brand and Category
$brandCatProduct = $product;
if ($parentProduct && !$product->isVisibleInSiteVisibility()) {
$brandCatProduct = $parentProduct;
}
$setSettings = $this->_getProductAttributeSetSettings($brandCatProduct);
if ($setSettings['brandAttribute'] != null) {
$result['brand'] = $this->_getProductAttribute($brandCatProduct, $setSettings['brandAttribute']);
}
if ($setSettings['catFromMagento']) {
$cats = $this->_getCategoryInformation($storeId, $brandCatProduct);
if (isset($cats['category'])) {
$result['category'] = $cats['category'];
}
if (isset($cats['sub_category'])) {
$result['sub_category'] = $cats['sub_category'];
}
//.........这里部分代码省略.........
示例5: testGetWeight
public function testGetWeight()
{
$this->assertEmpty($this->_model->getWeight());
$this->_model->setWeight(10.22);
$this->assertEquals(10.22, $this->_model->getWeight());
}
示例6: action
public function action(Mage_Catalog_Model_Product $product, $action = self::SYNC_ACTION_INSERT)
{
$this->getQueue()->send(Zend_Json::encode(array('action' => $action, 'website_id' => $product->getWebsiteId(), 'plant_id' => $this->getHelper()->getPlantId(), 'deposit_number' => $this->getHelper()->getDepositorNumber(), 'product_id' => $product->getId(), 'product_sku' => $product->getSku(), 'product_weight' => $product->getWeight(), 'product_name' => $product->getName(), 'product_length' => $product->getData('yc_dimension_length'), 'product_width' => $product->getData('yc_dimension_width'), 'product_height' => $product->getData('yc_dimension_height'), 'product_uom' => $product->getData('yc_dimension_uom'), 'product_volume' => $product->getData('yc_dimension_height') * $product->getData('yc_dimension_length') * $product->getData('yc_dimension_width'), 'tara_factor' => Mage::getStoreConfig(Swisspost_YellowCube_Helper_Data::CONFIG_TARA_FACTOR, Mage::app()->getWebsite($product->getWebsiteId())->getDefaultStore()->getId()), 'product_ean' => $product->getData('yc_ean_code'), 'product_ean_type' => $product->getData('yc_ean_type'), 'product_lot_management' => $product->getData('yc_requires_lot_management'))));
return $this;
}
示例7: getProductEntity
public function getProductEntity(Mage_Catalog_Model_Product $product, $storeId, $includeExtras = true)
{
$result = array();
$result['entity_id'] = $product->getEntityId();
$result['sku'] = $product->getSku();
$result['name'] = $product->getName();
$result['price'] = $product->getPrice();
$result['special_price'] = $product->getSpecialPrice();
$result['special_from_date'] = $product->getSpecialFromDate();
$result['special_to_date'] = $product->getSpecialToDate();
$result['cost'] = $product->getCost();
$result['description'] = $product->getDescription();
$result['short_description'] = $product->getShortDescription();
$result['weight'] = $product->getWeight();
if ($product->isVisibleInSiteVisibility()) {
$prodUrlStr = $product->getProductUrl();
$prodUrl = Mage::getSingleton('core/url')->parseUrl($prodUrlStr);
$result['url_path'] = substr($prodUrl->getPath(), 1);
}
$parentProduct = $this->_getParentProduct($product);
if ($parentProduct != null) {
$result['parent_id'] = $parentProduct->getEntityId();
$result['parent_sku'] = $parentProduct->getSku();
if (!$product->isVisibleInSiteVisibility()) {
$result['name'] = $parentProduct->getName();
if ($parentProduct->isVisibleInSiteVisibility()) {
$prodUrlStr = $parentProduct->getProductUrl();
$prodUrl = Mage::getSingleton('core/url')->parseUrl($prodUrlStr);
$result['url_path'] = substr($prodUrl->getPath(), 1);
}
}
if ($includeExtras && Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE == $parentProduct->getTypeId()) {
$result['purchasable'] = $this->_isPurchasable($product, $parentProduct);
$attributes = $parentProduct->getTypeInstance(true)->getUsedProductAttributes($parentProduct);
foreach ($attributes as $attribute) {
if (!array_key_exists('configurable_attributes', $result)) {
$result['configurable_attributes'] = array();
}
$attr = array();
$attr['attribute_name'] = $attribute->getFrontend()->getLabel();
$attr['value'] = $product->getAttributeText($attribute->getAttributeCode());
$result['configurable_attributes'][] = $attr;
}
}
}
if (!isset($result['purchasable'])) {
$result['purchasable'] = $this->_isPurchasable($product);
}
$images = $this->_getProductImages($product);
if (isset($images['image'])) {
$result['image'] = $images['image'];
}
if (isset($images['small_image'])) {
$result['small_image'] = $images['small_image'];
}
if (isset($images['thumbnail'])) {
$result['thumbnail'] = $images['thumbnail'];
}
if ($includeExtras) {
// Metas
$metas = $this->_getMetas($storeId, $product, $parentProduct);
if ($metas != null) {
//if(isset($metas['meta1'])) $result['meta1'] = $metas['meta1'];
//if(isset($metas['meta2'])) $result['meta2'] = $metas['meta2'];
if (isset($metas['meta3'])) {
$result['meta3'] = $metas['meta3'];
}
if (isset($metas['meta4'])) {
$result['meta4'] = $metas['meta4'];
}
if (isset($metas['meta5'])) {
$result['meta5'] = $metas['meta5'];
}
}
// Brand and Category
$brandAndCategoryProduct = !$parentProduct || $product->isVisibleInSiteVisibility() ? $product : $parentProduct;
$setSettings = $this->_getProductAttributeSetSettings($brandAndCategoryProduct);
if ($setSettings['brandAttribute'] != null) {
$result['brand'] = $brandAndCategoryProduct->getAttributeText($setSettings['brandAttribute']);
}
if ($setSettings['catFromMagento']) {
$cats = $this->_getCategoryInformation($storeId, $brandAndCategoryProduct);
if (isset($cats['category'])) {
$result['category'] = $cats['category'];
}
if (isset($cats['sub_category'])) {
$result['sub_category'] = $cats['sub_category'];
}
} else {
if ($setSettings['catFromAttributes']) {
if ($setSettings['categoryAttribute'] != null) {
$result['category'] = $brandAndCategoryProduct->getAttributeText($setSettings['categoryAttribute']);
}
if ($setSettings['subcategoryAttribute'] != null) {
$result['sub_category'] = $brandAndCategoryProduct->getAttributeText($setSettings['subcategoryAttribute']);
}
}
}
// Inventory
$result['in_stock'] = $product->isAvailable() ? "true" : "false";
//.........这里部分代码省略.........
示例8: setWeight
/**
* set weight
*/
public function setWeight()
{
parent::setWeight(floatval(str_replace(',', '.', $this->item->getWeight())));
}