本文整理匯總了PHP中type::setData方法的典型用法代碼示例。如果您正苦於以下問題:PHP type::setData方法的具體用法?PHP type::setData怎麽用?PHP type::setData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類type
的用法示例。
在下文中一共展示了type::setData方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: applyCmsBlock
/**
* CMS block cache, must use the block id from the database
*
* @param type $block
*/
public function applyCmsBlock($block)
{
// The "messages" block is session-dependent, don't cache
if (Mage::helper('cache')->responseHasMessages()) {
$block->setData('cache_lifetime', null);
return;
}
// Set cache tags
$tags = array();
$blockId = $block->getData('block_id');
if ($blockId) {
$cmsBlock = Mage::getModel('cms/block')->setStoreId(Mage::app()->getStore()->getId())->load($blockId);
if ($cmsBlock->getIsActive()) {
$tags = $block->getCacheTags();
$tags[] = Mage_Cms_Model_Block::CACHE_TAG . '_' . $cmsBlock->getId();
}
}
$block->setData('cache_tags', $tags);
// Set cache key
$keys = $block->getCacheKeys();
$blockId = $block->getData('block_id');
if ($blockId) {
$cmsBlock = Mage::getModel('cms/block')->setStoreId(Mage::app()->getStore()->getId())->load($blockId);
if ($cmsBlock->getIsActive()) {
$keys = $block->getCacheKeyInfo();
if (!is_array($keys)) {
$keys = array();
}
$keys[] = $blockId;
$keys[] = $block->getLayout()->getUpdate()->getCacheId();
}
}
$block->setData('cache_keys', $keys);
}
示例2: setTierPrice
/**
* Set tier price
*
* @param type $product
*
* @return Innoexts_StorePricing_Helper_Catalog_Product_Price
*/
public function setTierPrice($product)
{
$attribute = $this->getTierPriceAttribute();
if (!$attribute) {
return $this;
}
$backend = $attribute->getBackend();
if (!$backend) {
return $this;
}
$helper = $this->getStorePricingHelper();
$store = $helper->getCurrentStore();
$isEditMode = $product->getData('_edit_mode');
$websiteId = null;
$storeId = null;
if ($this->isGlobalScope()) {
$websiteId = null;
$storeId = null;
} else {
if ($this->isWebsiteScope() && $store->getId()) {
$websiteId = $store->getWebsiteId();
$storeId = null;
} else {
if ($this->isStoreScope() && $store->getId()) {
$websiteId = $store->getWebsiteId();
$storeId = $store->getId();
}
}
}
$typeId = $product->getTypeId();
$tierPrices = $product->getTierPrices();
if (!empty($tierPrices) && !$isEditMode) {
$tierPrices = $backend->preparePriceData2($tierPrices, $typeId, $websiteId, $storeId);
}
$product->setFinalPrice(null);
$product->setData('tier_price', $tierPrices);
return $this;
}
示例3: confirmAdjuststock
/**
* Confirm an adjust stock
*
* @param type $model
* @param type $data
* @param type $admin
*/
public function confirmAdjuststock($model, $data, $admin)
{
$model->setData('reason', $data['reason'])->setData('confirmed_by', $admin)->setData('confirmed_at', now())->setStatus(1);
$model->save();
}
示例4: getDeliverInvoiceRequest
//.........這裏部分代碼省略.........
public function getDeliverInvoiceRequest($invoice, $auth, $sveaOrderId)
{
$conf = new SveaMageConfigProvider($auth);
$sveaObject = WebPay::deliverOrder($conf);
$order = $invoice->getOrder();
$countryCode = $order->getBillingAddress()->getCountryId();
$storeId = $order->getStoreId();
$store = Mage::app()->getStore($storeId);
$taxCalculationModel = Mage::getSingleton('tax/calculation');
$taxConfig = Mage::getSingleton('tax/config');
// Add invoiced items
foreach ($invoice->getAllItems() as $item) {
$orderItem = $item->getOrderItem();
if ($orderItem->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
continue;
}
// Default to the item price
$name = $item->getName();
$price = $orderItem->getPrice();
$priceInclTax = $orderItem->getPriceInclTax();
$taxPercent = $orderItem->getTaxPercent();
if (!(int) $taxPercent) {
$taxPercent = false;
}
$parentItem = $orderItem->getParentItem();
if ($parentItem) {
switch ($parentItem->getProductType()) {
case Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE:
$price = $parentItem->getPrice();
$priceInclTax = $parentItem->getPriceInclTax();
$taxPercent = $parentItem->getTaxPercent();
break;
case Mage_Catalog_Model_Product_Type::TYPE_BUNDLE:
$taxPercent = $priceInclTax = $price = 0;
$name = '- ' . $name;
break;
}
}
if ($taxPercent === false) {
// If it's a bundle item we have to calculate the tax from
// the including/excluding tax values
$taxPercent = round(100 * ($priceInclTax / $price - 1));
}
switch (get_class($item)) {
case 'Mage_Sales_Model_Quote_Item':
case 'Mage_Sales_Model_Order_Invoice_Item':
case 'Mage_Sales_Model_Order_Creditmemo_Item':
$qty = $item->getQty();
break;
default:
$qty = $item->getQtyOrdered();
break;
}
$orderRow = WebPayItem::orderRow()->setArticleNumber($item->getSku())->setQuantity((int) $qty)->setName($name)->setUnit(Mage::helper('svea_webpay')->__('unit'))->setVatPercent((int) $taxPercent);
if ($taxConfig->priceIncludesTax($storeId)) {
$orderRow->setAmountIncVat((double) $priceInclTax);
} else {
$orderRow->setAmountExVat((double) $price);
}
$sveaObject->addOrderRow($orderRow);
}
$request = $taxCalculationModel->getRateRequest($order->getShippingAddress(), $order->getBillingAddress(), null, $store);
// Add shipping fee
if ($invoice->getShippingAmount() > 0) {
$shippingFee = WebPayItem::shippingFee()->setUnit(Mage::helper('svea_webpay')->__('unit'))->setName($order->getShippingDescription());
// We require shipping tax to be set
$shippingTaxClass = Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS, $storeId);
$rate = $taxCalculationModel->getRate($request->setProductClassId($shippingTaxClass));
$shippingFee->setVatPercent((int) $rate);
if ($taxConfig->shippingPriceIncludesTax($storeId)) {
$shippingFee->setAmountIncVat($invoice->getShippingInclTax());
} else {
$shippingFee->setAmountExVat($invoice->getShippingAmount());
}
$sveaObject->addFee($shippingFee);
}
// Possible discount
$discount = abs($invoice->getDiscountAmount());
if ($discount) {
$discountRow = WebPayItem::fixedDiscount()->setAmountIncVat($discount)->setName(Mage::helper('svea_webpay')->__('discount'))->setUnit(Mage::helper('svea_webpay')->__('unit'));
$sveaObject->addDiscount($discountRow);
}
// Gift card(s)
if (abs($order->getGiftCardsAmount())) {
$giftCardRow = WebPayItem::fixedDiscount()->setAmountIncVat(abs($order->getGiftCardsAmount()))->setUnit(Mage::helper('svea_webpay')->__('unit'));
$sveaObject->addDiscount($giftCardRow);
}
// Invoice fee
$paymentFee = $invoice->getSveaPaymentFeeAmount();
$paymentFeeInclTax = $invoice->getSveaPaymentFeeInclTax();
$invoiced = $invoice->getOrder()->getSveaPaymentFeeInvoiced();
if ($paymentFee > 0 && $invoiced == 0) {
$invoiceFee = WebPayItem::invoiceFee()->setUnit(Mage::helper('svea_webpay')->__('unit'))->setName(Mage::helper('svea_webpay')->__('invoice_fee'))->setAmountExVat($paymentFee)->setAmountIncVat($paymentFeeInclTax);
$sveaObject->addFee($invoiceFee);
$invoice->getOrder()->setSveaPaymentFeeInvoiced($paymentFeeInclTax);
}
$sveaObject = $sveaObject->setCountryCode($countryCode)->setOrderId($sveaOrderId)->setInvoiceDistributionType(Mage::getStoreConfig("payment/svea_invoice/deliver_method"));
$invoice->setData('svea_deliver_request', $sveaObject);
return $invoice->getData('svea_deliver_request');
}