Magento存储明智的Invoice Increment Id组

时间:2013-10-10 14:49:43

标签: magento magento-1.7

我在一个域中共有10个多店铺,当客户从不同的商店发票增量Id和Prefix订购时创建的不同。但我只想要两种不同的发票类型,商店ID 6的前缀为“1”,所有其他商店前缀应该与“19”相同,所有增量ID应该相同。

10个不同的商店,但发票应该只有两种类型。

有什么好的解决方案,非常感谢。

感谢

1 个答案:

答案 0 :(得分:0)

You are require to follow below steps to do this:

1) - In the /Namespace/Module/etc/config.xml you have to write the following thing: 

 <config>
    <modules>
        <Namespace_Module>
            <version>0.1.0</version>
        </Namespace_Module>
    </modules>
    <global>
        <models>
            <eav>
                <rewrite>
                    <entity_store>Namespace_Module_Model_Entity_Store</entity_store>
                </rewrite>
            </eav>
        </models>
    </global>
</config> 

2) - Register module in magento module list under app/etc/modules/Namespace_Module.xml
    <config>
        <modules>
        <Namespace_Module>
            <active>true</active>
            <codePool>local</codePool>
            <depends />
        </Namespace_Module>
        </modules>
    </config>
3) - You have to copy the same code under /Mage/Eav/Model/Entity/Store.php into your file under /Namespace/Module/Model/Entity/Store.php.

4) Edit your Store.php file:  Please find below code 
 public function loadByEntityStore($entityTypeId, $storeId)
    {
        $this->_getResource()->loadByEntityStore($this, $entityTypeId, 1);//1 is your default store_id
        return $this;
    }

Replace it with below code

public function loadByEntityStore($entityTypeId, $storeId)
    {
        $this->_getResource()->loadByEntityStore($this, $entityTypeId, 1);//1 is your default store_id
        return $this;

    if($storeId==6){//6==StoreID
        $this->_getResource()->loadByEntityStore($this, $entityTypeId, 1);//1 is your default store_id
    }else{
        $this->_getResource()->loadByEntityStore($this, $entityTypeId, 19);
    } 
    }


Hope this will work for you. :)
Best of luck.


Below is the solution for all Store view. In this solution all store Ids will be same.

Find in app/code/mage/sales/model/entity/setup.php the following piece of code: 

 'invoice' => array(
                'entity_model'      => 'sales/order_invoice',
                'table'             =>'sales/order_entity',
                'increment_model' =>'eav/entity_increment_numeric',
                'increment_per_store'=>false, 

and chance 

 'increment_per_store'=>false 

To

 'increment_per_store'=>true 
相关问题