本文整理汇总了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()));
}
示例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());
}
示例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;
}
示例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);
}
示例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());
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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();
}
示例14: _getSku
protected function _getSku()
{
return $this->_product->getSku();
}
示例15: isGiftOfferedFor
public function isGiftOfferedFor(Mage_Catalog_Model_Product $product)
{
return $product->getSku() === self::PRODUCT_SKU_TO_TARGET;
}