Tuesday, August 9, 2016

Magento 2.x: Multi Store with distinct websites and langauges.

This post suggest how you should configure the index file to run multiple stores and assumes that you have confifured your domains properly.

Here we have:
1. en.domain.com/ for English users
2. dk.domain.com/ For Danish Users

The two domains/sub domains should point to the same folder on your web server.

.htaccess. Add this lines appropriately.

RewriteCond %{HTTP_HOST} ^(.*)en\.domain.\com
RewriteRule .* – [E=MAGE_RUN_CODE:en]
RewriteCond %{HTTP_HOST} ^(.*)en\.domain.\com
RewriteRule .* – [E=MAGE_RUN_TYPE:website]



RewriteCond %{HTTP_HOST} ^(.*)dk
\.domain.\com
RewriteRule .* – [E=MAGE_RUN_CODE:dk]
RewriteCond %{HTTP_HOST} ^(.*)dk\.domain.\com
RewriteRule .* – [E=MAGE_RUN_TYPE:website]

 
index.php:  In your index.php file, replace with the following
$params = $_SERVER;
switch ($_SERVER['HTTP_HOST']) {
    case 'nautical-antiques.eu':
        $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'en';
        $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';
        break;
    case 'nautikvariat.dk':
        $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'dk';
        $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';
        break;
}
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
$app = $bootstrap->createApplication('Magento\Framework\App\Http');
$bootstrap->run($app);


en and dk are the codes for magento websites.

 

 
 


Sunday, February 26, 2012

Oracle Forms- Insert an auto-increment( next val)

Here are two ways to create an auto-increment on Oracle forms 10g.
1. Create a sequence number,

CREATE SEQUENCE s_customer_id
MINVALUE 1
MAXVALUE 9999999
INCREMENT BY 1
START WITH 216
NOCACHE
NOORDER
NOCYCLE

On the object navigator click on the item and right click on the item the select smart trigger, then when-new-item-instance, then type the following on the pl/sql editor,

DECLARE
new_account_id accounts.account_id%type;
begin
select s_account_id.nextval into new_account_id from dual;
:account_id:=new_account_id;
end;
Then run the form, on every new instance, a new is inserted.
2. Using A PRE-INSERT- a trigger that fires once before each new record is inserted in a commit process

Create a Trigger
In the Object Navigator, highlight the Trigger item under the form data block and click on the green ‘+’ sign to create a trigger.

PRE-INSERT trigger
In the Trigger window, type ‘P’ then ‘R,’ and then select the ‘PRE-INSERT’ trigger.
PL/SQL Editor
In the PL/SQL Editor, write a select statement to assign a new sequence number to account_id
(PL/SQL Editor)
SELECT s_account_id.nextval INTO :accounts.account_id
FROM dual;
Compile a trigger
Compile the trigger and then close the window.
Run the Form
Run the application.

In case of any query, don't hesitate to ask.