小编Rel*_*lja的帖子

在Magento中以编程方式创建订单

我正在使用这两种方法在Magento中以编程方式创建订单.

第一个创建一个Quote:

 public function prepareCustomerOrder($customerId, array $shoppingCart, array  $shippingAddress, array $billingAddress, 
        $shippingMethod, $couponCode = null) 
    {
        $customerObj = Mage::getModel('customer/customer')->load($customerId);
        $storeId = $customerObj->getStoreId();
        $quoteObj = Mage::getModel('sales/quote')->assignCustomer($customerObj);
        $storeObj = $quoteObj->getStore()->load($storeId);
        $quoteObj->setStore($storeObj);

        // add products to quote
        foreach($shoppingCart as $part) {
            $productModel = Mage::getModel('catalog/product');
            $productObj = $productModel->setStore($storeId)->setStoreId($storeId)->load($part['PartId']);

            $productObj->setSkipCheckRequiredOption(true);

            try{
                $quoteItem = $quoteObj->addProduct($productObj);
                $quoteItem->setPrice(20);
                $quoteItem->setQty(3);
                $quoteItem->setQuote($quoteObj);                                    
                $quoteObj->addItem($quoteItem);

            } catch (exception $e) {
            return false;
            }

            $productObj->unsSkipCheckRequiredOption();
            $quoteItem->checkData();
        }

        // addresses
        $quoteShippingAddress = new Mage_Sales_Model_Quote_Address();
        $quoteShippingAddress->setData($shippingAddress);
        $quoteBillingAddress = new Mage_Sales_Model_Quote_Address();
        $quoteBillingAddress->setData($billingAddress);
        $quoteObj->setShippingAddress($quoteShippingAddress);
        $quoteObj->setBillingAddress($quoteBillingAddress);

        // coupon …
Run Code Online (Sandbox Code Playgroud)

php magento

14
推荐指数
1
解决办法
2万
查看次数

Magento:从另一家商店获得产品价格?

我有多店Magento安装,不同的商店设置不同的产品价格.我想在一个页面上显示当前商店的实际产品价格,以及其他商店的价格(我有它的ID),但我不知道如何获得该信息?

为每个产品的每个商店视图设置价格,不使用层级定价或特殊定价.

product magento

7
推荐指数
1
解决办法
2万
查看次数

Magento:自定义总计数两次?

好吧,我创建了自定义Total类来添加特殊折扣,一切似乎都运行正常,但由于某些原因我找不到,我的总计算是两次!这导致双倍的折扣和不正确的总计.现在,这发生在购物车页面和结帐页面上...但是......当我完成订单时总计很好,只计算一次,总计很好.

这很奇怪,就像收集方法被称为购物车页面两次,但只有一次在完成订单时,但我可以"追踪所有这些发生的地方,以及为什么.

要跳过垃圾代码,我只会粘贴重要内容

     <sales>
        <quote>
            <totals>
                <mydiscount>
                    <class>ucon_mydiscount/total_mydiscount</class>
                    <before>subtotal</before>
                </mydiscount>
            </totals>
        </quote>
    </sales>
Run Code Online (Sandbox Code Playgroud)

和收藏家的方法

    public function collect(Mage_Sales_Model_Quote_Address $address)
{
    parent::collect($address);

    $quote = $address->getQuote();
    $quoteId = $quote->getEntityId();

    $items = $quote->getAllItems();
    if (!count($items)) {
        return $this;
    }       


    $discount = 0;
    $productId = 2556;  

    foreach($items as $item)
    {       
        if($item->getProduct()->getId() == $productId)
        {
            $qty = $item->getQty();
            $totalPrice = round(($item->getRowTotal()+$item->getTaxAmount()),2);

            //discount 10%              
            $discount = round($totalPrice * 0.1,2);     

            $discount = 0 - $discount;
        }
    }

    if($discount == 0)
        return $this;

    $this->_setAmount($discount);
    $this->_setBaseAmount($discount);


    return $this;
}
Run Code Online (Sandbox Code Playgroud)

和fetcher …

custom-action totals magento

5
推荐指数
1
解决办法
6675
查看次数

Zend PDF:计算旋转后的坐标

没有太多细节 - 我从Web工具获取参数(x1,x2,y1,y2,a,b,α),我需要生成一个PDF文档,使用Zend_PDF库,其中包含旋转的绿色图像和正确定位在精确坐标上.

在此输入图像描述

现在,令我困惑的是,Zend不允许旋转元素,而是旋转纸张.所以,我认为轮换需要像这样完成

$page->rotate($x1 + ($x2 - $x1) / 2, $y1 + ($y2 - $y1) / 2, - deg2rad($rotation));

因为我们希望图像的中心是旋转点,然后我们以相反的方向旋转它,这样得到的图像就会得到正确的旋转.

我遇到麻烦的棘手部分是绘制它.随着简单的电话

$page->drawImage($image, $x1, $y1, $x2, $y2);

我得到的结果如图所示 - 结果图像也需要翻译,因为(x1,y1)和(x2,y2)不再是精确坐标,但我不知道如何计算它们?有任何想法吗?

pdf zend-framework rotation draw coordinates

5
推荐指数
1
解决办法
412
查看次数

Magento数据库:发票项目数据库表?

有谁知道发票数据在Magento数据库中的存储位置?

例如,我发现订单数据存储在sales_order,sales_flat_order,sales_flat_order_item中.

我还发现主要发票数据存储在sales_order_entity,sales_order_entity_decimal和sales_order_entity_int中.通过这个,我可以更改系统中发票的小计和总计.

但!我不知道在哪里找到物品数据?对于订单,该数据在sales_flat_order_item中,但我的sales_flat_invoice_item表是空的?!

http://img809.imageshack.us/img809/1921/invoicey.jpg

database magento

2
推荐指数
1
解决办法
9069
查看次数

Magento:如何在adminhtml之外覆盖管理员控制器?

简单地说,我想覆盖Mage/Index/controllers/Admninhtml/ProcessController.php中的ProcessController.

我知道如何覆盖前端控制器,但这让我头疼几个小时了.我不能把它付诸实践.这是我的配置文件

<?xml version="1.0"?>

<config>
<global>
    <models>
        <twobuy_index>
            <class>Twobuy_Index_Model</class>
        </twobuy_index>                 
    </models>
</global>

<admin>
    <routers>
        <index>
            <args>
                <modules>
                     <Twobuy before="Mage_Index">Twobuy_Index</Twobuy>
                </modules>
            </args>            
        </index>
    </routers>
</admin>
</config>
Run Code Online (Sandbox Code Playgroud)

和控制器声明

 include_once('Mage/Index/controllers/Adminhtml/ProcessController.php');
 class Twobuy_Index_Adminhtml_ProcessController extends Mage_Index_Adminhtml_ProcessController
 {
Run Code Online (Sandbox Code Playgroud)

我尝试重写reindexAction,但我的方法永远不会被调用.

overriding controller magento

0
推荐指数
1
解决办法
2414
查看次数