當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Mage_Catalog_Model_Product::getSku方法代碼示例

本文整理匯總了PHP中Mage_Catalog_Model_Product::getSku方法的典型用法代碼示例。如果您正苦於以下問題:PHP Mage_Catalog_Model_Product::getSku方法的具體用法?PHP Mage_Catalog_Model_Product::getSku怎麽用?PHP Mage_Catalog_Model_Product::getSku使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mage_Catalog_Model_Product的用法示例。


在下文中一共展示了Mage_Catalog_Model_Product::getSku方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _relateProducts

 private function _relateProducts(Mage_Catalog_Model_Product $_product, $data)
 {
     $this->log($this->__('Relating products for %s', $_product->getSku()));
     $relatableData = array();
     foreach ($data as $i => $relatedSku) {
         $relatedProductId = Mage::getModel('catalog/product')->getIdBySku($relatedSku);
         if (!$relatedProductId) {
             throw new Exception($this->__('No product with sku: %s' . $relatedSku));
         }
         $relatableData[$relatedProductId] = array('position' => $i);
         $this->log($this->__('Related %s', $relatedSku), 1);
     }
     $_product->setRelatedLinkData($relatableData);
     $_product->save();
     $this->log($this->__('Finished relating products for %s', $_product->getSku()));
 }
開發者ID:mblarsen,項目名稱:magento-configurator,代碼行數:16,代碼來源:RelatedProducts.php

示例2: testDuplicateSkuGeneration

 public function testDuplicateSkuGeneration()
 {
     $this->_model->load(1);
     $this->assertEquals('simple', $this->_model->getSku());
     $duplicated = $this->_model->duplicate();
     $this->assertEquals('simple-1', $duplicated->getSku());
 }
開發者ID:natxetee,項目名稱:magento2,代碼行數:7,代碼來源:ProductTest.php

示例3: getUpdateListingWrapper

 public function getUpdateListingWrapper(Mage_Catalog_Model_Product $product)
 {
     $reverbListingWrapper = Mage::getModel('reverbSync/wrapper_listing');
     $sku = $product->getSku();
     // $condition = $this->_getCondition();
     $fieldsArray = array('sku' => $sku);
     if ($this->_getListingsUpdateSyncHelper()->isTitleUpdateEnabled()) {
         $fieldsArray['title'] = $product->getName();
     }
     if ($this->_getListingsUpdateSyncHelper()->isPriceUpdateEnabled()) {
         $fieldsArray['price'] = $this->getProductPrice($product);
     }
     if ($this->_getListingsUpdateSyncHelper()->isDescriptionUpdateEnabled()) {
         $fieldsArray['description'] = $this->getProductDescription($product);
     }
     if ($this->_getListingsUpdateSyncHelper()->isInventoryQtyUpdateEnabled()) {
         $hasInventory = $this->_getHasInventory();
         $fieldsArray['has_inventory'] = $hasInventory;
         $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
         $fieldsArray['inventory'] = $stock->getQty();
     }
     $this->_addMappedAttributes($fieldsArray, $product);
     $this->_addArbitraryMappedAttributes($fieldsArray, $product);
     $this->_addProductAcceptOffers($fieldsArray, $product);
     $this->addCategoryToFieldsArray($fieldsArray, $product);
     $this->addProductConditionIfSet($fieldsArray, $product);
     $reverbListingWrapper->setApiCallContentData($fieldsArray);
     $reverbListingWrapper->setMagentoProduct($product);
     return $reverbListingWrapper;
 }
開發者ID:zztimur,項目名稱:reverb-magento,代碼行數:30,代碼來源:Product.php

示例4: validate

 /**
  * Validate SKU
  *
  * @param Mage_Catalog_Model_Product $object
  * @throws Mage_Core_Exception
  * @return bool
  */
 public function validate($object)
 {
     $helper = Mage::helper('core/string');
     if ($helper->strlen($object->getSku()) > self::SKU_MAX_LENGTH) {
         Mage::throwException(Mage::helper('catalog')->__('SKU length should be %s characters maximum.', self::SKU_MAX_LENGTH));
     }
     return parent::validate($object);
 }
開發者ID:SalesOneGit,項目名稱:s1_magento,代碼行數:15,代碼來源:Sku.php

示例5: testGenerateUniqueSkuExistingProduct

 /**
  * @magentoDataFixture Mage/Catalog/_files/product_simple.php
  */
 public function testGenerateUniqueSkuExistingProduct()
 {
     $product = new Mage_Catalog_Model_Product();
     $product->load(1);
     $product->setId(null);
     $this->assertEquals('simple', $product->getSku());
     $product->getResource()->getAttribute('sku')->getBackend()->beforeSave($product);
     $this->assertEquals('simple-1', $product->getSku());
 }
開發者ID:nayanchamp,項目名稱:magento2,代碼行數:12,代碼來源:SkuTest.php

示例6: getProductData

 /**
  * Create Product array from Mage_Catalog_Model_Product
  *
  * @param Mage_Catalog_Model_Product $product
  * @return array
  */
 public function getProductData(Mage_Catalog_Model_Product $product)
 {
     try {
         $data = array('url' => $product->getProductUrl(), 'title' => htmlspecialchars($product->getName()), 'spider' => 1, 'price' => $product->getPrice(), 'description' => urlencode($product->getDescription()), 'tags' => htmlspecialchars($product->getMetaKeyword()), 'images' => array(), 'vars' => array('sku' => $product->getSku(), 'storeId' => '', 'typeId' => $product->getTypeId(), 'status' => $product->getStatus(), 'categoryId' => $product->getCategoryId(), 'categoryIds' => $product->getCategoryIds(), 'websiteIds' => $product->getWebsiteIds(), 'storeIds' => $product->getStoreIds(), 'groupPrice' => $product->getGroupPrice(), 'formatedPrice' => $product->getFormatedPrice(), 'calculatedFinalPrice' => $product->getCalculatedFinalPrice(), 'minimalPrice' => $product->getMinimalPrice(), 'specialPrice' => $product->getSpecialPrice(), 'specialFromDate' => $product->getSpecialFromDate(), 'specialToDate' => $product->getSpecialToDate(), 'relatedProductIds' => $product->getRelatedProductIds(), 'upSellProductIds' => $product->getUpSellProductIds(), 'getCrossSellProductIds' => $product->getCrossSellProductIds(), 'isSuperGroup' => $product->isSuperGroup(), 'isGrouped' => $product->isGrouped(), 'isConfigurable' => $product->isConfigurable(), 'isSuper' => $product->isSuper(), 'isSalable' => $product->isSalable(), 'isAvailable' => $product->isAvailable(), 'isVirtual' => $product->isVirtual(), 'isRecurring' => $product->isRecurring(), 'isInStock' => $product->isInStock(), 'weight' => $product->getSku()));
         // Add product images
         if (self::validateProductImage($product->getImage())) {
             $data['images']['full'] = array("url" => $product->getImageUrl());
         }
         if (self::validateProductImage($product->getSmallImage())) {
             $data['images']['smallImage'] = array("url" => $product->getSmallImageUrl($width = 88, $height = 77));
         }
         if (self::validateProductImage($product->getThumbnail())) {
             $data['images']['thumb'] = array("url" => $product->getThumbnailUrl($width = 75, $height = 75));
         }
         return $data;
         return $data;
     } catch (Exception $e) {
         Mage::logException($e);
     }
 }
開發者ID:xiaoguizhidao,項目名稱:sailthru-magento-extension,代碼行數:26,代碼來源:Content.php

示例7: setIdentifiers

 /**
  * set identifiers
  */
 public function setIdentifiers()
 {
     $result = array();
     $identifierItemObject = new Shopgate_Model_Catalog_Identifier();
     $identifierItemObject->setType('SKU');
     $identifierItemObject->setValue($this->item->getSku());
     $result[] = $identifierItemObject;
     $this->_getIdentifierByType('ean', $result);
     $this->_getIdentifierByType('upc', $result);
     parent::setIdentifiers($result);
 }
開發者ID:buttasg,項目名稱:cowgirlk,代碼行數:14,代碼來源:Xml.php

示例8: 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;
 }
開發者ID:arslbbt,項目名稱:mangentovies,代碼行數:18,代碼來源:Abstract.php

示例9: validate

 /**
  * Validate SKU
  *
  * @param Mage_Catalog_Model_Product $object
  * @throws Mage_Core_Exception
  * @return bool
  */
 public function validate($object)
 {
     $helper = Mage::helper('Mage_Core_Helper_String');
     $attrCode = $this->getAttribute()->getAttributeCode();
     $value = $object->getData($attrCode);
     if ($this->getAttribute()->getIsRequired() && $this->getAttribute()->isValueEmpty($value)) {
         return false;
     }
     if ($helper->strlen($object->getSku()) > self::SKU_MAX_LENGTH) {
         Mage::throwException(Mage::helper('Mage_Catalog_Helper_Data')->__('SKU length should be %s characters maximum.', self::SKU_MAX_LENGTH));
     }
     return true;
 }
開發者ID:natxetee,項目名稱:magento2,代碼行數:20,代碼來源:Sku.php

示例10: testDuplicate

 /**
  * @magentoAppIsolation enabled
  */
 public function testDuplicate()
 {
     $this->_model->load(1);
     // fixture
     $duplicate = $this->_model->duplicate();
     try {
         $this->assertNotEmpty($duplicate->getId());
         $this->assertNotEquals($duplicate->getId(), $this->_model->getId());
         $this->assertNotEquals($duplicate->getSku(), $this->_model->getSku());
         $this->assertEquals(Mage_Catalog_Model_Product_Status::STATUS_DISABLED, $duplicate->getStatus());
         $this->_undo($duplicate);
     } catch (Exception $e) {
         $this->_undo($duplicate);
         throw $e;
     }
 }
開發者ID:nemphys,項目名稱:magento2,代碼行數:19,代碼來源:ProductTest.php

示例11: getSimpleProductsForConfigurableProduct

 /**
  * @param Mage_Catalog_Model_Product $configurableProduct
  * @return array
  * @throws Exception
  */
 public function getSimpleProductsForConfigurableProduct($configurableProduct)
 {
     if ($configurableProduct->getTypeId() != Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
         $error_message = $this->__(self::ERROR_PRODUCT_NOT_CONFIGURABLE, $configurableProduct->getSku());
         throw new Exception($error_message);
     }
     $parent_id = $configurableProduct->getId();
     $child_product_ids_return = $this->_getConfigurableProductTypeModel()->getChildrenIds($parent_id);
     $child_product_ids = reset($child_product_ids_return);
     $child_products_array = array();
     foreach ($child_product_ids as $child_product_id) {
         $childProduct = Mage::getModel('catalog/product')->load($child_product_id);
         if (is_object($childProduct) && $childProduct->getId()) {
             $child_products_array[] = $childProduct;
         }
     }
     return $child_products_array;
 }
開發者ID:zztimur,項目名稱:reverb-magento,代碼行數:23,代碼來源:Product.php

示例12: testDuplicate

 /**
  * @magentoAppIsolation enabled
  */
 public function testDuplicate()
 {
     $undo = function ($duplicate) {
         Mage::app()->getStore()->setId(Mage_Core_Model_App::ADMIN_STORE_ID);
         $duplicate->delete();
     };
     $this->_model->load(1);
     // fixture
     $duplicate = $this->_model->duplicate();
     try {
         $this->assertNotEmpty($duplicate->getId());
         $this->assertNotEquals($duplicate->getId(), $this->_model->getId());
         $this->assertNotEquals($duplicate->getSku(), $this->_model->getSku());
         $this->assertEquals(Mage_Catalog_Model_Product_Status::STATUS_DISABLED, $duplicate->getStatus());
         $undo($duplicate);
     } catch (Exception $e) {
         $undo($duplicate);
         throw $e;
     }
 }
開發者ID:relue,項目名稱:magento2,代碼行數:23,代碼來源:ProductTest.php

示例13: extractUrlKeyValue

 /**
  * extract the the title value from the DOMNodelist object if value not empty
  * simply append the store id and return the vlaue. if the value is empty
  * append the a know string string with the sku and the store id and return
  * @param DOMNodeList $nodes
  * @param Mage_Catalog_Model_Product $product
  * @return string
  */
 public function extractUrlKeyValue(DOMNodeList $nodes, Mage_Catalog_Model_Product $product)
 {
     $urlKey = $this->coreHelper->extractNodeVal($nodes);
     return $urlKey !== '' ? $urlKey . '-' . $product->getStoreId() : 'Incomplete Product: ' . $product->getSku() . '-' . $product->getStoreId();
 }
開發者ID:sirishreddyg,項目名稱:magento-retail-order-management,代碼行數:13,代碼來源:Map.php

示例14: _getSku

 protected function _getSku()
 {
     return $this->_product->getSku();
 }
開發者ID:ridhoq,項目名稱:mxpi-twitter,代碼行數:4,代碼來源:Offer.php

示例15: isGiftOfferedFor

 public function isGiftOfferedFor(Mage_Catalog_Model_Product $product)
 {
     return $product->getSku() === self::PRODUCT_SKU_TO_TARGET;
 }
開發者ID:mgeoffray,項目名稱:magento1x-continuousphp,代碼行數:4,代碼來源:Observer.php


注:本文中的Mage_Catalog_Model_Product::getSku方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。