本文整理汇总了PHP中Varien_Object::getSku方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Object::getSku方法的具体用法?PHP Varien_Object::getSku怎么用?PHP Varien_Object::getSku使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Object
的用法示例。
在下文中一共展示了Varien_Object::getSku方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: inventoryPush
/**
* Update stock data of multiple products at once
*
* @param array $itemData
* @return array
*/
public function inventoryPush($itemData)
{
if (isset($itemData['records'])) {
$itemData = $itemData['records'];
}
$response = array();
$response['records'] = array();
$orderItemsCollection = Mage::getResourceModel('retailops_api/api')->getRetailopsReadyOrderItems();
$orderItems = $this->filterOrderItems($orderItemsCollection);
$productIds = $this->getProductIds($itemData);
foreach ($itemData as $item) {
try {
$itemObj = new Varien_Object($item);
Mage::dispatchEvent('retailops_inventory_push_record', array('record' => $itemObj));
$result = array();
$result['sku'] = $itemObj->getSku();
$itemObj->setQty($itemObj->getQuantity());
// api update accepts qty not quantity parameter
$qty = $itemObj->getQty();
if (isset($orderItems[$itemObj->getSku()])) {
$qty = $itemObj->getQty() - $orderItems[$itemObj->getSku()];
}
$itemObj->setQty($qty);
Mage::dispatchEvent('retailops_inventory_push_record_qty_processed', array('record' => $itemObj));
$this->update($productIds[$itemObj->getSku()], $itemObj->getData());
$result['status'] = RetailOps_Api_Helper_Data::API_STATUS_SUCCESS;
} catch (Mage_Core_Exception $e) {
$result['status'] = RetailOps_Api_Helper_Data::API_STATUS_FAIL;
$result['error'] = array('code' => $e->getCode(), 'message' => $e->getMessage());
}
$response['records'][] = $result;
}
return $response;
}
示例2: _beforeSave
protected function _beforeSave(Varien_Object $object)
{
if (!$object->getId() && $object->getSku()) {
$object->setId($this->getIdBySku($object->getSku()));
}
if (is_array($object->getData('category_ids'))) {
$object->setData('category_ids', implode(',', $object->getData('category_ids')));
}
return parent::_beforeSave($object);
}
示例3: validate
public function validate(Varien_Object $object)
{
// for optimization if we no conditions
if (!$this->getConditions()) {
return true;
}
$origProduct = null;
if ($object->getHasChildren() && $object->getProductType() == 'configurable') {
//remember original product
$origProduct = $object->getProduct();
$origSku = $object->getSku();
foreach ($object->getChildren() as $child) {
// only one itereation.
$categoryIds = array_merge($child->getProduct()->getCategoryIds(), $origProduct->getCategoryIds());
$categoryIds = array_unique($categoryIds);
$object->setProduct($child->getProduct());
$object->setSku($child->getSku());
$object->getProduct()->setCategoryIds($categoryIds);
}
}
$result = @Mage_Rule_Model_Condition_Combine::validate($object);
if ($origProduct) {
// restore original product
$object->setProduct($origProduct);
$object->setSku($origSku);
}
return $result;
}
示例4: validate
public function validate(Varien_Object $object)
{
$product = false;
if ($object->getProduct() instanceof Mage_Catalog_Model_Product) {
$product = $object->getProduct();
} else {
$product = Mage::getModel('catalog/product')->load($object->getProductId());
}
$product->setQuoteItemQty($object->getQty())->setQuoteItemPrice($object->getPrice())->setQuoteItemRowTotal($object->getBaseRowTotal())->setQuoteItemSku($object->getSku());
return parent::validate($product);
}
示例5: validate
/**
* Validate Product Rule Condition
*
* @param Varien_Object $object
* @return bool
*/
public function validate(Varien_Object $object)
{
$product = false;
if ($object->getProduct() instanceof Mage_Catalog_Model_Product) {
$product = $object->getProduct();
} else {
$product = Mage::getModel('catalog/product')->load($object->getProductId());
}
$product->setQuoteItemSku($object->getSku());
//$newObject = new Varien_Object();
$object->setProduct($product);
return parent::validate($object);
}
示例6: _beforeSave
protected function _beforeSave(Varien_Object $object)
{
if ($object->hasCategoryIds()) {
$categoryIds = Mage::getResourceSingleton('catalog/category')->verifyIds($object->getCategoryIds());
$object->setCategoryIds($categoryIds);
}
if (!$object->getSku() && Mage::getStoreConfigFlag('udprod/general/auto_sku')) {
$adapter = $this->_getReadAdapter();
$pidSuffix = $adapter->fetchOne($adapter->select()->from($this->getEntityTable(), 'max(entity_id)'));
do {
$object->setSku($object->getUdropshipVendor() . '-' . ++$pidSuffix);
} while (Mage::helper('udropship/catalog')->getPidBySku($object->getSku(), $object->getId()));
}
$vId = Mage::getSingleton('udropship/session')->getVendorId();
if (!$vId && Mage::app()->getStore()->isAdmin() && Mage::helper('udropship')->isModuleActive('umicrosite') && ($v = Mage::helper('umicrosite')->getAdminhtmlVendor())) {
$vId = $v->getId();
} else {
$vId = $object->getData('udropship_vendor');
}
if (Mage::getStoreConfigFlag('udprod/general/prefix_sku_vid') && $vId && 0 !== strpos($object->getSku(), $vId . '-')) {
$object->setSku($vId . '-' . $object->getSku());
}
if (Mage::getStoreConfigFlag('udprod/general/unique_vendor_sku') && $vId && !Mage::helper('udropship')->isUdmultiActive()) {
$vSkuAttr = Mage::getStoreConfig('udropship/vendor/vendor_sku_attribute');
if ($vSkuAttr && $vSkuAttr != 'sku') {
if (!$object->getData($vSkuAttr)) {
Mage::throwException('Vendor SKU attribute is empty');
} elseif (Mage::helper('udropship/catalog')->getPidByVendorSku($object->getData($vSkuAttr), $vId, $object->getId())) {
Mage::throwException(Mage::helper('udropship')->__('Vendor SKU "%s" is already used', $object->getData($vSkuAttr)));
}
}
}
if (Mage::helper('udropship')->hasMageFeature('resource_1.6')) {
return Mage_Catalog_Model_Resource_Abstract::_beforeSave($object);
} else {
return Mage_Catalog_Model_Resource_Eav_Mysql4_Abstract::_beforeSave($object);
}
}
示例7: validate
public function validate(Varien_Object $object)
{
if ($this->getAttribute() == 'sku') {
$sku = explode(',', $this->getValue());
foreach ($sku as $skuA) {
foreach ($object->getSku() as $skuB) {
if ($skuA == $skuB) {
return true;
}
}
}
return false;
}
if ($this->getAttribute() == 'category') {
return $this->validateAttribute($object->getCategories());
}
return parent::validate($object);
}
示例8: validate
/**
* Validate Product Rule Condition
*
* @param Varien_Object $object
*
* @return bool
*/
public function validate(Varien_Object $object)
{
/** @var Mage_Catalog_Model_Product $product */
$product = $object->getProduct();
if (!$product instanceof Mage_Catalog_Model_Product) {
$product = Mage::getModel('catalog/product')->load($object->getProductId());
}
$product->setQuoteItemQty($object->getQty())->setQuoteItemPrice($object->getPrice())->setQuoteItemRowTotal($object->getBaseRowTotal());
// Allows attributes to take custom option SKU into consideration
if ($this->getAttribute() === self::QUOTE_ITEM_SKU) {
$product->setData($this->getAttribute(), $object->getSku());
$valid = Mage_Rule_Model_Condition_Product_Abstract::validate($product);
} else {
$valid = parent::validate($object);
}
if (!$valid && $product->getTypeId() == Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) {
$children = $object->getChildren();
$valid = $children && $this->validate($children[0]);
}
return $valid;
}
示例9: _prepareCollection
/**
* Prepare collection of errors
*
* @return Enterprise_Checkout_Block_Adminhtml_Sku_Errors_Grid
*/
protected function _prepareCollection()
{
$collection = new Varien_Data_Collection();
$removeButtonHtml = $this->getLayout()->createBlock('adminhtml/widget_button', '', array('class' => 'delete', 'label' => '', 'onclick' => 'addBySku.removeFailedItem(this)', 'type' => 'button'))->toHtml();
/* @var $parentBlock Enterprise_Checkout_Block_Adminhtml_Sku_Errors_Abstract */
$parentBlock = $this->getParentBlock();
foreach ($parentBlock->getFailedItems() as $affectedItem) {
// Escape user-submitted input
if (isset($affectedItem['item']['qty'])) {
$affectedItem['item']['qty'] = empty($affectedItem['item']['qty']) ? '' : (double) $affectedItem['item']['qty'];
}
$item = new Varien_Object();
$item->setCode($affectedItem['code']);
if (isset($affectedItem['error'])) {
$item->setError($affectedItem['error']);
}
$item->addData($affectedItem['item']);
$item->setId($item->getSku());
/* @var $product Mage_Catalog_Model_Product */
$product = Mage::getModel('catalog/product');
if (isset($affectedItem['item']['id'])) {
$productId = $affectedItem['item']['id'];
$item->setProductId($productId);
$product->load($productId);
/* @var $stockStatus Mage_CatalogInventory_Model_Stock_Status */
$stockStatus = Mage::getModel('cataloginventory/stock_status');
$status = $stockStatus->getProductStatus($productId, $this->getWebsiteId());
if (!empty($status[$productId])) {
$product->setIsSalable($status[$productId]);
}
$item->setPrice(Mage::helper('core')->formatPrice($product->getPrice()));
}
$descriptionBlock = $this->getLayout()->createBlock('enterprise_checkout/adminhtml_sku_errors_grid_description', '', array('product' => $product, 'item' => $item));
$item->setDescription($descriptionBlock->toHtml());
$item->setRemoveButton($removeButtonHtml);
$collection->addItem($item);
}
$this->setCollection($collection);
return $this;
}
示例10: validate
/**
* Validate Product Rule Condition
*
* @param Varien_Object $object
* @return bool
*/
public function validate(Varien_Object $object)
{
$product = false;
if ($object->getProduct() instanceof Mage_Catalog_Model_Product) {
$product = $object->getProduct();
} else {
$product = Mage::getModel('catalog/product')->load($object->getProductId());
}
if (Mage::getStoreConfig('amrules/general/options_values')) {
$options = $product->getTypeInstance(true)->getOrderOptions($product);
$values = '';
if (isset($options['options'])) {
foreach ($options['options'] as $option) {
$values .= '|' . $option['value'];
}
}
$product->setQuoteItemValue($values);
}
$product->setQuoteItemSku($object->getSku());
$object->setProduct($product);
return parent::validate($object);
}
开发者ID:ankita-parashar,项目名称:magento,代码行数:28,代码来源:Amasty_Rules_Model_SalesRule_Rule_Condition_Product.php
示例11: _beforeSave
/**
* Process product data before save
*
* @param Varien_Object $object
* @return Mage_Catalog_Model_Resource_Product
*/
protected function _beforeSave(Varien_Object $object)
{
/**
* Try detect product id by sku if id is not declared
*/
if (!$object->getId() && $object->getSku()) {
$object->setId($this->getIdBySku($object->getSku()));
}
/**
* Check if declared category ids in object data.
*/
if ($object->hasCategoryIds()) {
$categoryIds = Mage::getResourceSingleton('catalog/category')->verifyIds($object->getCategoryIds());
$object->setCategoryIds($categoryIds);
}
return parent::_beforeSave($object);
}
示例12: _addRegularItem
/**
* Add a usual line item with amount and qty
*
* @param Varien_Object $salesItem
* @return Varien_Object
*/
protected function _addRegularItem(Varien_Object $salesItem)
{
if ($this->_salesEntity instanceof Mage_Sales_Model_Order) {
$qty = (int) $salesItem->getQtyOrdered();
$amount = (double) $salesItem->getBasePrice();
// TODO: nominal item for order
} else {
$qty = (int) $salesItem->getTotalQty();
$amount = $salesItem->isNominal() ? 0 : (double) $salesItem->getBaseCalculationPrice();
}
// workaround in case if item subtotal precision is not compatible with PayPal (.2)
$subAggregatedLabel = '';
if ($amount - round($amount, 2)) {
$amount = $amount * $qty;
$subAggregatedLabel = ' x' . $qty;
$qty = 1;
}
// aggregate item price if item qty * price does not match row total
if ($amount * $qty != $salesItem->getBaseRowTotal()) {
$amount = (double) $salesItem->getBaseRowTotal();
$subAggregatedLabel = ' x' . $qty;
$qty = 1;
}
return $this->addItem($salesItem->getName() . $subAggregatedLabel, $qty, $amount, $salesItem->getSku());
}
示例13: _getItemId
/**
* Get the item id for an item based on the item's sku, client id
* and catalog id.
* @param Varien_Object $item
* @return string
*/
protected function _getItemId(Varien_Object $item)
{
return $this->_formatId($item->getSku(), $item->getClientId(), $item->getCatalogId());
}
示例14: getOptionValues
public function getOptionValues()
{
$data = array();
$optionsArr = '';
$session = Mage::getSingleton('adminhtml/session');
if ($data = $session->getData('customoptions_data')) {
if (isset($data['general']['hash_options'])) {
$optionsArr = $data['general']['hash_options'];
}
} elseif (Mage::registry('customoptions_data')) {
$data = Mage::registry('customoptions_data')->getData();
if (isset($data['hash_options'])) {
$optionsArr = $data['hash_options'];
}
}
$groupId = (int) $this->getRequest()->getParam('group_id');
if ($optionsArr) {
$optionsArr = unserialize($optionsArr);
}
$storeOptionsArr = array();
$groupStore = Mage::getSingleton('customoptions/group_store')->loadByGroupAndStore($groupId, $this->getStoreId());
if ($groupStore->getHashOptions()) {
$storeOptionsArr = unserialize($groupStore->getHashOptions());
}
$product = Mage::getSingleton('catalog/product_option');
if (!$this->_values && $optionsArr) {
$values = array();
$sortOrder = array();
$scope = (int) Mage::app()->getStore()->getConfig(Mage_Core_Model_Store::XML_PATH_PRICE_SCOPE);
$optionItemCount = count($optionsArr);
foreach ($optionsArr as $optionId => $option) {
$option = new Varien_Object($option);
$value = array();
if ($option->getIsDelete() != '1') {
$value['id'] = $option->getOptionId();
$value['item_count'] = $optionItemCount;
$value['option_id'] = $option->getOptionId();
$value['title'] = $this->htmlEscape(isset($storeOptionsArr[$optionId]['title']) ? $storeOptionsArr[$optionId]['title'] : $option->getTitle());
$value['type'] = $option->getType();
$value['is_require'] = $option->getIsRequire();
$value['is_enabled'] = $option->getIsEnabled();
$value['is_dependent'] = $option->getIsDependent();
$value['code'] = $this->htmlEscape($option->getCode());
$value['option_code'] = $option->getOptionCode();
$value['customoptions_is_onetime'] = $option->getCustomoptionsIsOnetime();
$value['qnty_input'] = $option->getQntyInput() ? 'checked' : '';
$value['qnty_input_disabled'] = $option->getType() == 'drop_down' || $option->getType() == 'radio' || $option->getType() == 'checkbox' ? '' : 'disabled';
$value['description'] = $this->htmlEscape(isset($storeOptionsArr[$optionId]['description']) ? $storeOptionsArr[$optionId]['description'] : $option->getDescription());
$value['block_title'] = $this->htmlEscape(isset($storeOptionsArr[$optionId]['block_title']) ? $storeOptionsArr[$optionId]['block_title'] : $option->getBlockTitle());
if (Mage::helper('customoptions')->isCustomerGroupsEnabled() && $option->getCustomerGroups() != null) {
$value['customer_groups'] = implode(',', $option->getCustomerGroups());
}
$value['in_group_id'] = $option->getInGroupId();
$value['in_group_id_view'] = $option->getInGroupId();
$value['sort_order'] = $this->_getSortOrder($option);
if ($this->getStoreId() != '0') {
$value['checkboxScopeTitle'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'title', !isset($storeOptionsArr[$optionId]['title']));
$value['scopeTitleDisabled'] = !isset($storeOptionsArr[$optionId]['title']) ? 'disabled' : null;
$value['checkboxScopeDescription'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'description', !isset($storeOptionsArr[$optionId]['description']));
$value['scopeDescriptionDisabled'] = !isset($storeOptionsArr[$optionId]['description']) ? 'disabled' : null;
$value['checkboxScopeBlockTitle'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'block_title', !isset($storeOptionsArr[$optionId]['block_title']));
$value['scopeBlockTitleDisabled'] = !isset($storeOptionsArr[$optionId]['block_title']) ? 'disabled' : null;
}
if ($product->getGroupByType($option->getType()) == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT) {
$countValues = count($option->getValues());
if ($countValues > 0) {
foreach ($option->getValues() as $key => $_value) {
$_value = new Varien_Object($_value);
$_value->setOptionTypeId($key);
if ($_value->getIsDelete() != '1') {
$defaultArray = $option->getDefault() !== null ? $option->getDefault() : array();
$value['optionValues'][$key] = array('item_count' => $countValues, 'option_id' => $option->getOptionId(), 'option_type_id' => $_value->getOptionTypeId(), 'title' => $this->htmlEscape(isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['title']) ? $storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['title'] : $_value->getTitle()), 'price' => $this->getPriceValue(isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price']) ? $storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price'] : $_value->getPrice(), $_value->getPriceType()), 'price_type' => isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price_type']) ? $storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price_type'] : $_value->getPriceType(), 'sku' => $this->htmlEscape($_value->getSku()), 'code' => $this->htmlEscape($_value->getCode()), 'tier' => $_value->getTier(), 'sort_order' => $this->_getSortOrder($_value), 'customoptions_qty' => $_value->getCustomoptionsQty(), 'checked' => array_search($_value->getOptionTypeId(), $defaultArray) !== false ? 'checked' : '', 'default_type' => $option->getType() == 'checkbox' || $option->getType() == 'multiple' ? 'checkbox' : 'radio', 'in_group_id' => $_value->getInGroupId(), 'in_group_id_view' => $_value->getInGroupId(), 'dependent_ids' => $_value->getDependentIds());
$value['optionValues'][$key]['image_button_label'] = Mage::helper('customoptions')->__('Add Image');
$imgHtml = Mage::helper('customoptions')->getImgHtml($_value->getImagePath(), $option->getId(), $_value->getOptionTypeId());
if ($imgHtml) {
$value['optionValues'][$key]['image'] = $imgHtml;
$value['optionValues'][$key]['image_button_label'] = Mage::helper('customoptions')->__('Change Image');
}
if ($this->getStoreId() != '0') {
$value['optionValues'][$key]['checkboxScopeTitle'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'title', !isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['title']), $_value->getOptionTypeId());
$value['optionValues'][$key]['scopeTitleDisabled'] = !isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['title']) ? 'disabled' : null;
if ($scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE) {
$value['optionValues'][$key]['checkboxScopePrice'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'price', is_null($_value->getstorePrice()), $_value->getOptionTypeId());
$value['optionValues'][$key]['scopePriceDisabled'] = is_null($_value->getStorePrice()) ? 'disabled' : null;
}
}
}
}
$value['optionValues'] = array_values($value['optionValues']);
}
} else {
$value['price'] = $this->getPriceValue(isset($storeOptionsArr[$optionId]['price']) ? $storeOptionsArr[$optionId]['price'] : $option->getPrice(), $option->getPriceType());
$value['price_type'] = isset($storeOptionsArr[$optionId]['price_type']) ? $storeOptionsArr[$optionId]['price_type'] : $option->getPriceType();
$value['sku'] = $this->htmlEscape($option->getSku());
$value['code'] = $this->htmlEscape($option->getCode());
$value['max_characters'] = $option->getMaxCharacters();
$value['file_extension'] = $option->getFileExtension();
$value['image_size_x'] = $option->getImageSizeX();
$value['image_size_y'] = $option->getImageSizeY();
$value['image_button_label'] = Mage::helper('customoptions')->__('Add Image');
//.........这里部分代码省略.........
示例15: _getItemId
/**
* Substitute the product sku for entity_id as all products processed from the
* feeds will have a sku. This makes looking up a product by SKU more
* reasonable and allows for newly created items to be looked up after being
* added to the collection but before the collection has been saved.
* @param Varien_Object $item
* @return string
*/
protected function _getItemId(Varien_Object $item)
{
return $item->getSku();
}