国际电子商务技术 & Magento开发公司

Maishen technologies

Welcome visitor! You canlogin orcreate an account.

热线:+86-0532-58973093

麦神科技有限公司
Mygod Technologies

官方认证开发工程师

关于文章段落出界的问题的处理

2012年1月15日星期日 Asia/Shanghai下午1:51:53

在处理文章段落的时候会出现文章段落出去了,不换行,如果用overflow,加上滑动条,是不实际的,我们希望的是自动换行,css其实是有这个属性了,查了一番找到了就是如下的css属性:

 word-wrapbreak-word;

在p标签的上层加一个div,然后css属性加上这个就可以了!

0 Comments | Posted By terry water

Magento: Get all shopping cart items and totals

2012年1月14日星期六 Asia/Shanghai下午5:04:11

Here, I will show you how you can get information about all items in your Magento Shopping Cart. You will see how you can :-

- Get products id, name, price, quantity, etc. present in your cart.
- Get number of items in cart and total quantity in cart.
- Get base total price and grand total price of items in cart.

 

Get all items information in cart

// $items = Mage::getModel('checkout/cart')->getQuote()->getAllItems();
$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();

foreach($items as $item) {
	echo 'ID: '.$item->getProductId().'<br />';
	echo 'Name: '.$item->getName().'<br />';
	echo 'Sku: '.$item->getSku().'<br />';
	echo 'Quantity: '.$item->getQty().'<br />';
	echo 'Price: '.$item->getPrice().'<br />';
	echo "<br />";
}

Get total items and total quantity in cart

$totalItems = Mage::getModel('checkout/cart')->getQuote()->getItemsCount();
$totalQuantity = Mage::getModel('checkout/cart')->getQuote()->getItemsQty();

Get subtotal and grand total price of cart

$subTotal = Mage::getModel('checkout/cart')->getQuote()->getSubtotal();
$grandTotal = Mage::getModel('checkout/cart')->getQuote()->getGrandTotal();

Hope this helps. Thanks.

转载地址:http://blog.chapagain.com.np/magento-get-all-shopping-cart-items-and-totals/

0 Comments | Posted in magento日常所用 By terry water

在购物车cart中加入产品的short description

2012年1月14日星期六 Asia/Shanghai下午4:47:44

Magento- Adding Short Description to the View Cart page

magento默认的购物车如下:

我们想在购物车的产品名字下面加上产品的short description
我们可以这样,在文件/app/design/frontend/default/default/template/checkout/cart/item/default.phtml,

At line 34, 找到如下

<h2>
<?php if ($this->hasProductUrl()):?>
<a href=”<?php echo $this->getProductUrl() ?>”><?php echo $this->htmlEscape($this->getProductName()) ?></a>
<?php else: ?>
<?php echo $this->htmlEscape($this->getProductName()) ?>
<?php endif; ?>
</h2>

我们在下面加入如下代码:

<?php
$custom = Mage::getModel(‘catalog/product’)->load($_item->getProductId());
echo $custom->getShortDescription();
?>

将会出现下面的图片样子的short description:

当您有其他自己加入的属性也想让他显示出来,可以这样:如下!

<h2>
<?php if ($this->hasProductUrl()):?>
<a href=”<?php echo $this->getProductUrl() ?>”><?php echo $this->htmlEscape($this->getProductName()) ?></a>
<?php else: ?>
<?php echo $this->htmlEscape($this->getProductName()) ?>
<?php endif; ?>
</h2>
<?php
$custom = Mage::getModel(‘catalog/product’)->load($_item->getProductId());
echo $custom->getdimensions();
?>
<?php
$custom = Mage::getModel(‘catalog/product’)->load($_item->getProductId());
echo $custom->getShortDescription();
?>

 

0 Comments | Posted in Magento开发 By terry water

magento的message的使用

2012年1月11日星期三 Asia/Shanghai下午5:52:53

在magento中发送消息,实例代码如下,含有失败和成功的方法,当做新的模块扩展的时候,在一些提交操作的成功和失败的判断的时候,可以使用下面代码进行判断是否成功和失败!

 

 try {
                    $mail->send();
                    $message = $this->__('You have Register Successfully');
                    
                    Mage::getSingleton('core/session')->addSuccess($message);
                     $this->_redirect('sendemail/index/wholesale');
                }
                catch(Exception $ex) {
                    // I assume you have your custom module.
                    // If not, you may keep 'customer' instead of 'yourmodule'.
                    Mage::getSingleton('core/session')
                        ->addError(Mage::helper('yourmodule')
                        ->__('Unable to send email.'));
                     $this->_redirect('sendemail/index/wholesale');
                }

0 Comments | Posted in magento二次开发 By terry water

magento发送邮件机制

2012年1月11日星期三 Asia/Shanghai下午5:26:58

magento的邮件非常的领过,但是使用起来有点复杂,下面是实用的zend机制发送邮件的简单方法,如下:

public function sendEmail()
{
    $fromEmail = "[email protected]"; // sender email address
    $fromName = "John Doe"; // sender name
 
    $toEmail = "[email protected]"; // recipient email address
    $toName = "Mark Doe"; // recipient name
 
    $body = "This is Test Email!"; // body text
    $subject = "Test Subject"; // subject text
 
    $mail = new Zend_Mail();       
 
    $mail->setBodyText($body);
 
    $mail->setFrom($fromEmail, $fromName);
 
    $mail->addTo($toEmail, $toName);
 
    $mail->setSubject($subject);
 
    try {
        $mail->send();
    }
    catch(Exception $ex) {
        // I assume you have your custom module.
        // If not, you may keep 'customer' instead of 'yourmodule'.
        Mage::getSingleton('core/session')
            ->addError(Mage::helper('yourmodule')
            ->__('Unable to send email.'));
    }
}
如果想发送html代码
则实用方法:
$mail = new Zend_Mail("UTF-8"); 
$mail->setBodyHtml($body);
如果想用magento的邮件机制,可以参看如下链接:http://magentocookbook.wordpress.com/2009/06/26/magento-email/
0 Comments | Posted in magento二次开发 By terry water
 
  • Mygod Technologies
  • 麦神科技有限公司
  • 香港中路8号
  • 中铁青岛中心大厦A3001
  • 市南区, 青岛, 266000
  • 电话: 0532-5897-3093

订阅我们的最新消息。

我们将严格尊重您的隐私。

关注我们的微信
获取外贸电子商务最新资讯;跨境推广最新策略;电子商务网站技术最新趋势。

2018 Mygod Technologies. 保留所有权. Privacy Policy