I have total 10 multi-store in a single domain, when customer ordering from different store invoice increment Id and Prefix is creating different. but I want only two different invoice type, prefix "1" for store id 6 and all other store prefix's should be same like '19' and all increment id should be same.
10 different store but invoice should be only two types.
Is there any good solution, highly appreciated.
thanks
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
Related
Hi I have a issue which I don't understand, please someone could help me.
I'm on the 1.8.1
I have a Module in app->code->local->Mycompany
Mycampany
TestModel
etc
config.xml
Model
FirstModel.php
code in config.xml
<?xml version="1.0"?>
<config>
<modules>
<Mycompany_TestModel>
<version>0.1.0</version>
</Mycompany_TestModel>
</modules>
<global>
<models>
<TestModel>
<class>Mycompany_TestModel_Model</class>
</TestModel>
</models>
</global>
</config>
code in FirstModel.php
class Mycompany_TestModel_Model_FirstModel extends Mage_Core_Model_Abstract {
public function output()
{
echo "get";
}
}
When I use
Mage::getModel('TestModel/FirstModel')
magento can not load the class.
I tested and it is working on my local machine.
Please help.
Plus. I also tried:
<?xml version="1.0"?>
<config>
<modules>
<Mycompany_TestModel>
<version>0.1.0</version>
</Mycompany_TestModel>
</modules>
<global>
<models>
<testmodel> /* instead of <TestModel> */
<class>Mycompany_TestModel_Model</class>
</testmodel>
</models>
</global>
</config>
I still can not get anything in
Mage::getModel('testmodel/FirstModel')
Thanks very much.
As you use magento fatory method [Mage::getModel('testmodel/FirstModel') ]
that means you need to use it procedure to define an model.
As per as magento, when autoloader execute testmodel/FirstModel run like:
testmodel=Mycompany_TestModel_Model
and
FirsModel is wrong ,File and name should be Firstmodel as after model model folder( Mycompany/TestModel/Model) all folders and files name should first letter with uppercase case and after that all should be lower a
That means file should be
Firstmodel.php instead of FirstModel
and testmodel/FirstModel should be testmodel/firstmodel
NO underscore should be use in folders and file name
I'm trying to find a configuration that allows one of my customer groups (wholesale) to add any given number of items to their shopping carts, but have a restricted checkout equal or greater than 16 items in total.
For example:
8 items from product A
2 items from product B
6 items from product C
That would be a total of 16 items and it would be possible for them to checkout.
I tried configuring the Minimum Qty Allowed in Shopping Cart, but then, they have to get 16 items of each product.
Do you know if there is a way to configure, add an extension or hardcode something to solve this problem?
Thank you for your time!
Easiest way is to set a minimum order amount
/admin/system_config/edit/section/sales
To implement a minimum item restriction, you can place an observer to fire on one page checkout which checks the item quantity it cart and redirects you back to the cart if its below your threshold with a message.
Full prototype, flavor as needed:
app\etc\modules\Spirit_Cms.xml
<?xml version="1.0"?>
<config>
<modules>
<Spirit_Cms>
<active>true</active>
<codePool>local</codePool>
</Spirit_Cms>
</modules>
</config>
app\code\local\Spirit\Cms\etc\config.xml
<?xml version="1.0"?>
<config>
<modules>
<Spirit_Cms>
<version>0.0.1</version>
</Spirit_Cms>
</modules>
<frontend>
<events>
<controller_action_predispatch_checkout_onepage_index>
<observers>
<spirit_cms_restrict_checkout>
<class>Spirit_Cms_Model_Observer</class>
<method>restrictCheckout</method>
</spirit_cms_restrict_checkout>
</observers>
</controller_action_predispatch_checkout_onepage_index>
</events>
</frontend>
<global>
<models>
<spirit_cms>
<class>Spirit_Cms_Model</class>
</spirit_cms>
</models>
</global>
</config>
app\code\local\Spirit\Cms\Model\Observer.php
<?php
class Spirit_Cms_Model_Observer
{
public function restrictCheckout( $oObserver )
{
// Ensure we only observe once.
if( Mage::registry( 'restrict_checkout_flag' ) )
{
return $this;
}
else
{
$oQuote = Mage::getSingleton( 'checkout/cart' )->getQuote();
$oCartItems = $oQuote->getAllItems();
$iTotalQty = 0;
foreach( $oCartItems as $oCartItem )
{
$iTotalQty = $iTotalQty + $oCartItem->getQty();
}
if( $iTotalQty < 12 )
{
$oSession = Mage::getSingleton( 'checkout/session' );
$oSession->addError( 'Please add at least 12 items to your cart.' );
Mage::app()->getResponse()->setRedirect( Mage::getUrl( 'checkout/cart' ) );
}
Mage::register( 'restrict_checkout_flag', 1, TRUE );
}
}
}
?>
I'm trying to add an 'a href' / link in an Attribute Field for a product.
However, the methods that I'm using are not working - although they work in CMS page content. When I view the product, the attribute with the link is displayed, but the actual URL does not seem to be generated correctly (404 error)
I've tried the following:
1. Test link 1
2. Test link 2
3. Test link 3
What am I doing wrong?
Your help is appreciated in advance
Thank you!
Magento EAV attributes values will not be parsed by PHP on their own. For display to the user, they are rendered through a frontend model. See eav_attribute table for examples.
Based on the "we do not want to display the entire url, just a text link" comment, you need an attribute with a custom frontend model. I'm guessing that it was added via the Admin Panel, which won't allow to add custom frontend models. Whereas adding the frontend model requires a script, I'd recommend adding the attribute via script in the first place.
To install this attribute properly , Magento needs to execute a setup script, which is a Magento term for (usually) PHP code which is executed exactly once with the ability to manipulate the database. Running these presupposes a module exists:
app/etc/modules/Your_Module.xml:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Your_Module>
<active>true</active>
<codePool>local</codePool>
</Your_Module>
</modules>
</config>
app/code/local/Your/Module/etc/config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Your_Module>
<version>1.0.0.0</version>
</Your_Module>
</modules>
<global>
<models>
<your_module>
<class>Your_Module_Model</class>
</your_module>
</models>
<resources>
<your_module_setup>
<setup>
<module>Your_Module</module>
</setup>
</your_module_setup>
</resources>
</global>
</config>
app/code/local/Your/Module/sql/your_module_setup/install-1.0.0.0.php:
<?php
$installer = Mage::getResourceModel('catalog/setup','catalog_setup');
/* #var $installer Mage_Catalog_Model_Resource_Setup */
$installer->startSteup();
$installer->addAttribute(
'catalog_product',
'unique_attr_code',
array(
'label' => 'Link to Product',
'required' => 'false', //or true if appropriate
'group' => 'General', //Adds to all sets
'frontend' => 'your_module/frontend_url'
)
);
$installer->endSetup();
app/code/local/Your/Module/Model/Frontend/Url.php:
class Your_Module_Model_Frontend_Url
extends Mage_Eav_Model_Entity_Attribute_Frontend_Abstract
{
public function getUrl($object)
{
$url = false;
if ($path = $object->getData($this->getAttribute()->getAttributeCode())) {
$url = Mage::getUrl('path');
}
return $url;
}
}
Stemming from my last question, I am stumped trying to do an override. I am doing exactly what MudithaE's answer here did, too.
I want to implement my own _prepareColumns() as found in the file app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php. I set up my module's directories and the files as below. While researching, I saw a lot of developers like to do Dev_Module_Block_Adminhtml_blah, so I tried changing the directory structure and class names everywhere in my code. No change. My Cycleworks_SalesGridImproved module appears in the System -> Config -> Advanced listing, too.
Files:
app/code/local/Cycleworks/SalesGridImproved/Adminhtml/Block/Sales/Order/Grid.php:
<?php
class Cycleworks_SalesGridImproved_Adminhtml_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid {
protected function _prepareColumns() // tried public too
{
parent::_prepareColumns();
...
...
$this->addColumn('created_at', array(
'header' => Mage::helper('sales')->__('Purchased On'),
'index' => 'created_at',
'type' => 'datetime',
'format' => 'MMM d, h:mm a',
'width' => '165px',
));
...
...
return $this;
}
}
app/code/local/Cycleworks/SalesGridImproved/etc/config.xml:
<?xml version="1.0"?>
<config>
<modules>
<!-- also tried: Cycleworks_SalesGridImproved -->
<Cycleworks_Adminhtml>
<version>0.0.01</version>
</Cycleworks_Adminhtml>
</modules>
<global>
<blocks>
<adminhtml>
<salesgridimproved>
<class>Cycleworks_SalesGridImproved_Adminhtml_Block_Sales_Order_Grid</class>
</salesgridimproved>
<rewrite>
<sales_order_grid>Cycleworks_SalesGridImproved_Adminhtml_Block_Sales_Order_Grid</sales_order_grid>
</rewrite>
</adminhtml>
</blocks>
</global>
</config>
And in /app/etc/modules/Cycleworks_SalesGridImproved.xml:
<?xml version="1.0"?>
<config>
<modules>
<Cycleworks_SalesGridImproved>
<active>true</active>
<codePool>local</codePool>
</Cycleworks_SalesGridImproved>
</modules>
</config>
Please show me see what I'm missing... Thanks!
Update:
Just found out the extension EM_DeleteOrder is also overriding the same sales order grid class that I am. His extension's configuration is more complicated than mine, as his is set up to be called before the Mage core. The config.xml sure is busy!
<?xml version="1.0"?>
<config>
<modules>
<EM_DeleteOrder>
<version>1.0.0</version>
</EM_DeleteOrder>
</modules>
<global>
<rewrite>
<em_emadmin_adminhtml_sales_order>
<from><![CDATA[#/admin/sales_order/#]]></from>
<to>/emadmin/adminhtml_sales_order/</to>
</em_emadmin_adminhtml_sales_order>
</rewrite>
<blocks>
<adminhtml>
<rewrite>
<sales_order_grid>EM_DeleteOrder_Block_Adminhtml_Sales_Order_Grid</sales_order_grid>
</rewrite>
</adminhtml>
</blocks>
</global>
<admin>
<routers>
<em_deleteorder>
<use>admin</use>
<args>
<module>EM_DeleteOrder</module>
<frontName>emadmin</frontName>
</args>
</em_deleteorder>
<adminhtml>
<args>
<modules>
<EM_DeleteOrder_Adminhtml before="Mage_Adminhtml">EM_DeleteOrder_Adminhtml</EM_DeleteOrder_Adminhtml>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
Do you have any thoughts how I can use similar syntax and get my module to work and not have to hack his code? Like with an after="Mage_Adminhtml"?
Final Update:
Sadly, the 3 answers below weren't the answer, it was the extension conflict. I'll answer my own question and mark it answered.
I just tried this and it works. I think by returning parent::_prepareColumns() that it's ignoring your change. Adding it at the top of the function then returning $this works fine for me.
<?php
class Cycleworks_SalesGridImproved_Adminhtml_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid {
protected function _prepareColumns() // tried public too
{
// ...
// ...
parent::_prepareColumns();
$this->addColumn('created_at', array(
'header' => Mage::helper('sales')->__('Purchased On'),
'index' => 'created_at',
'type' => 'datetime',
'format' => 'MMM d, h:mm a',
'width' => '165px',
));
// ...
// ...
return $this; #parent::_prepareColumns();
}
}
I'm answering myself, as this was a big lesson in extension conflicts and their resolution. Further, I learned a lot about our particular installation and how sloppy extensions can break everything.
As in the update, EM_DeleteOrder was overriding Adminhtml Block Sales Order Grid (absog). I also used the extension MDN_ExtensionConflict and while it wasn't detecting my exact conflict, it did show me that EM_DeleteOrder was using absog. I searched for extensions that would allow deletion of orders without using absog, which must be the easy way to go about it.
The extension Asperience_DeleteAllOrders manages to do this without overwriting the whole page and instead catches something in the router. Its config.xml is abstract art to me, so if you're an advanced developer, I think you'd appreciate his work more than I.
Ultimately, I found MageWorx_ExtendedOrders which replaces the entire absog with their own grid and has configurable additional columns. Included are custom shipping rates, order editing, deletion of orders, and order archiving. I am impressed with this extension for $149. I also am going through deleting the multiple extensions that were replaced with MageWorx_ExtendedOrders. I'm hacking their extension's code to put the columns in my desired order and to update the date format (and I'll share my changes with them as feature suggestions).
_prepareColumns() is protected, not public.
Try putting adminhtml folder inside block folder i.e. app/code/local/Cycleworks/SalesGridImproved/Block/Adminhtml/Sales/Order/Grid
I am trying to create a link from my helpdesk software to the sales order page in the backend of magento.
Magento constructs the url as the example below where the number represents the Order ID.
/index.php/admin/sales_order/view/order_id/12394/
However, the Order Id does not equal the Order Number because credit invoices etc. are included in the count.
Is there an other way for me to link to the order page using the Order Number.
Thanks!
There are 2 types of order number in magento
Order increment id
Order id (mostly use internal in magento).
The admin uses the order id while the number on you invoice is the order increment id.
The quickest way to get around this is to create a custom module that look up order id by order increment id and the redirect to the view page using the order id.
In /app/etc/modules/MageIgniter_OrderRedirect.xml
<?xml version="1.0"?>
<config>
<modules>
<MageIgniter_OrderRedirect>
<active>true</active>
<codePool>local</codePool>
</MageIgniter_OrderRedirect>
</modules>
</config>
In /app/code/local/MageIgniter/OrderRedirect/controllers/RedirectOrderController.php
<?php
class MageIgniter_OrderRedirect_RedirectOrderController extends Mage_Core_Controller_Front_Action
{
public function viewAction(){
$increment_id = Mage::app()->getRequest()->getParam('id');
$order = Mage::getModel('sales/order')->loadByIncrementId($increment_id);
$order_id = $order->getId();
Mage::app()->getResponse()->setRedirect(Mage::helper('adminhtml')->getUrl("adminhtml/sales_order/view", array('order_id'=> $order_id)));
}
}
in In /app/code/local/MageIgniter/OrderRedirect/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<MageIgniter_OrderRedirect>
<version>0.1.0</version>
</MageIgniter_OrderRedirect>
</modules>
<frontend>
<routers>
<orderredirect>
<use>standard</use>
<args>
<module>MageIgniter_OrderRedirect</module>
<frontName>orderredirect</frontName>
</args>
</orderredirect>
</routers>
</frontend>
<global>
<helpers>
<orderredirect>
<class>MageIgniter_OrderRedirect_Helper</class>
</orderredirect>
</helpers>
</global>
</config>
url
www.site.com/orderredirect/redirectOrder/view/id/101512486