Add extra fields in manage customer and edit customer section in magento - magento-1.8

I am using Magento ver. 1.9.1.0
So please help me according to the version of magento. I am new in this.
I am facing the problem is that I want to use extra (Lat Long field in) manage customer->add new customer in magento backend, so that user can add latlong of the address(any latlong). Now I have tried the following steps from the website.
http://excellencemagentoblog.com/blog/2011/10/02/customer-registration-fields-magento1-6/
https://magento.stackexchange.com/questions/45620/how-to-add-extra-fields-in-registration-form
http://www.silksoftware.com/magento-module-creator/#instructions
but I can't solve the problem. Somewhere showing extra field for my account in frontend, but I want to use the backend extra field on manage customer as an address and save it.
So if possible please provide me the right way to do and if you have the right tutorial please reply me.
I am trying this from few days but still no luck.
Also I have tried to install some extension from mangeto connect but giving error

Thank you all, I have done this by the following queries.
INSERT INTO `sta_eav_attribute` (
attribute_id ,
entity_type_id ,
attribute_code ,
attribute_model ,
backend_model ,
backend_type ,
backend_table ,
frontend_model ,
frontend_input ,
frontend_label ,
frontend_class ,
source_model ,
is_required ,
is_user_defined ,
default_value ,
is_unique ,
note
)
VALUES (
NULL , '2', 'latlong', NULL , NULL , 'varchar', NULL , NULL , 'text', 'Lat Long', NULL , '', '1', '0', '0', '0', ''
);
INSERT INTO sta_eav_entity_attribute (
entity_attribute_id ,
entity_type_id ,
attribute_set_id ,
attribute_group_id ,
attribute_id ,
sort_order
)
VALUES (
NULL , '2', '2', '2', 'your id max of sta_eav_attribute', '200'
);
INSERT INTO sta_customer_eav_attribute (
attribute_id ,
is_visible ,
input_filter ,
multiline_count ,
validate_rules ,
is_system ,
sort_order ,
data_model
)
VALUES (
'your id max of sta_eav_attribute', '1', NULL , '1', NULL , '0', '0', NULL
);
INSERT INTO sta_customer_form_attribute (
form_code ,
attribute_id
)
VALUES (
'adminhtml_customer_address', 'your id max of sta_eav_attribute'
), (
'customer_address_edit', 'your id max of sta_eav_attribute'
), (
'customer_register_address', 'your id max of sta_eav_attribute'
);

Related

Aggregation of aggregation on Google Bigquery

My Data looks like this
WITH test AS (
SELECT * FROM UNNEST([
STRUCT('2019-10-26' as date,'1.8025137' AS article_id, 'Digital Paying' as user_type,'open' as openmode, '123' as uid),
('2019-10-26','1.8025137' , 'Digital Paying','close', '523'),
('2019-10-26','1.8025137' , 'Anonymous','open', '321'),
('2019-10-26','1.8025137' , 'Registered','close', '231'),
('2019-10-26','1.8025137' , 'Registered','open', '431'),
('2019-10-26','1.8025137' , 'Digital Paying','close', '132'),
('2019-10-26','1.8025137' , 'Anonymous','close', '111')
])
),
-- first level of aggregation, prepare for fine tuning
date_article as (
SELECT
date,
article_id,
ARRAY_AGG(struct(user_type,openmode, uid)) AS ut
FROM test
GROUP BY 1,2
)
(SELECT
date,
article_id,
-- feed sub-query output into an array "action"
array(SELECT AS STRUCT
user_type as user_type, -- re-group data within the array by field "action"
array_agg(struct(openmode as openmode,uid as uid) ) op
FROM UNNEST(ut)
GROUP BY 1
) as user_types
FROM date_article)
My goal is to aggregate the user_types.op.openmode and user_types.op.uid by
user_types.user_type without create any duplicates as :
I think you are looking for below
#standardSQL
WITH test AS (
SELECT * FROM UNNEST([
STRUCT('2019-10-26' AS DATE,'1.8025137' AS article_id, 'Digital Paying' AS user_type,'open' AS openmode, '123' AS uid),
('2019-10-26','1.8025137' , 'Digital Paying','close', '523'),
('2019-10-26','1.8025137' , 'Anonymous','open', '321'),
('2019-10-26','1.8025137' , 'Registered','close', '231'),
('2019-10-26','1.8025137' , 'Registered','open', '431'),
('2019-10-26','1.8025137' , 'Digital Paying','close', '132'),
('2019-10-26','1.8025137' , 'Anonymous','close', '111')
])
), users_agg AS (
SELECT DATE, article_id, user_type, openmode, COUNT(DISTINCT uid) AS uids
FROM test GROUP BY 1,2,3,4
), modes_agg AS (
SELECT DATE, article_id, user_type, ARRAY_AGG(STRUCT(openmode, uids)) AS modes
FROM users_agg GROUP BY 1,2,3
), types_agg AS (
SELECT DATE, article_id, ARRAY_AGG(STRUCT(user_type, modes)) types
FROM modes_agg GROUP BY 1,2
), article_agg AS (
SELECT DATE, ARRAY_AGG(STRUCT(article_id, types)) articles
FROM types_agg GROUP BY 1
)
SELECT *
FROM article_agg
with result
You were making it a bit more complicated than necessary. If possible, do your 'normal' SQL first and then format into arrays/structs afterwards.
WITH test AS (
SELECT * FROM UNNEST([
STRUCT('2019-10-26' as date,'1.8025137' AS article_id, 'Digital Paying' as user_type,'open' as openmode, '123' as uid),
('2019-10-26','1.8025137' , 'Digital Paying','close', '523'),
('2019-10-26','1.8025137' , 'Anonymous','open', '321'),
('2019-10-26','1.8025137' , 'Registered','close', '231'),
('2019-10-26','1.8025137' , 'Registered','open', '431'),
('2019-10-26','1.8025137' , 'Digital Paying','close', '132'),
('2019-10-26','1.8025137' , 'Anonymous','close', '111')
])
),
agg as (
select
date,
article_id,
user_type,
openmode,
count(distinct uid) as uids
from test
group by 1,2,3,4
),
final as (
select
date,
article_id,
user_type,
array_agg(struct(openmode, uids)) as subfields
from agg
group by 1,2,3
)
select * from final

SQL Server 2017 - Dynamically generate a string based on the number of columns in another string

I have the following table & data:
CREATE TABLE dbo.TableMapping
(
[GenericMappingKey] [nvarchar](256) NULL,
[GenericMappingValue] [nvarchar](256) NULL,
[TargetMappingKey] [nvarchar](256) NULL,
[TargetMappingValue] [nvarchar](256) NULL
)
INSERT INTO dbo.TableMapping
(
[GenericMappingKey]
,[GenericMappingValue]
,[TargetMappingKey]
,[TargetMappingValue]
)
VALUES
(
'Generic'
,'Col1Source|Col1Target;Col2Source|Col2Target;Col3Source|Col3Target;Col4Source|Col4Target;Col5Source|Col5Target;Col6Source|Col6Target'
,'Target'
,'Fruit|Apple;Car|Red;House|Bungalo;Gender|Female;Material|Brick;Solution|IT'
)
I would need to be able to automatically generate my GenericMappingValue string dynamically based on the number of column pairs in the TargetMappingValue column.
Currently, there are 6 column mapping pairs. However, if I only had two mapping column pairs in my TargetMapping such as the following...
'Fruit|Apple;Car|Red'
then I would like for the GenericMappingValue to be automatically generated (updated) such as the following since, as a consequence, I would only have 2 column pairs in my string...
'Col1Source|Col1Target;Col2Source|Col2Target'
I've started building the following query logic:
DECLARE #Mapping nvarchar(256)
SELECT #Mapping = [TargetMappingValue] from TableMapping
print #Mapping
SELECT count(*) ColumnPairCount
FROM String_split(#Mapping, ';')
The above query gives me a correct count of 6 for my column pairs.
How would I be able to continue my logic to achieve my automatically generated mapping string?
I think I understand what you are after. This should get you moving in the right direction.
Since you've tagged 2017 you can use STRING_AGG()
You'll want to split your TargetMappingValue using STRING_SPLIT() with ROW_NUMER() in a sub-query. (NOTE: We aren't guaranteed order using string_split() with ROW_NUMBER here, but will work for this situation. Example below using OPENJSON if we need to insure accurate order.)
Then you can then use that ROW_NUMBER() as the column indicator/number in a CONCAT().
Then bring it all back together using STRING_AGG()
Have a look at this working example:
DECLARE #TableMapping TABLE
(
[GenericMappingKey] [NVARCHAR](256) NULL
, [GenericMappingValue] [NVARCHAR](256) NULL
, [TargetMappingKey] [NVARCHAR](256) NULL
, [TargetMappingValue] [NVARCHAR](256) NULL
);
INSERT INTO #TableMapping (
[GenericMappingKey]
, [GenericMappingValue]
, [TargetMappingKey]
, [TargetMappingValue]
)
VALUES ( 'Generic'
, 'Col1Source|Col1Target;Col2Source|Col2Target;Col3Source|Col3Target;Col4Source|Col4Target;Col5Source|Col5Target;Col6Source|Col6Target'
, 'Target'
, 'Fruit|Apple;Car|Red;House|Bungalo;Gender|Female;Material|Brick;Solution|IT' );
SELECT [col].[GenericMappingKey]
, STRING_AGG(CONCAT('Col', [col].[ColNumber], 'Source|Col', [col].[ColNumber], 'Target'), ';') AS [GeneratedGenericMappingValue]
, [col].[TargetMappingKey]
, [col].[TargetMappingValue]
FROM (
SELECT *
, ROW_NUMBER() OVER ( ORDER BY (
SELECT 1
)
) AS [ColNumber]
FROM #TableMapping
CROSS APPLY STRING_SPLIT([TargetMappingValue], ';')
) AS [col]
GROUP BY [col].[GenericMappingKey]
, [col].[TargetMappingKey]
, [col].[TargetMappingValue];
Here's an example of what an update would look like assuming your primary key is the GenericMappingKey column:
--This what an update would look like
--Assuming your primary key is the [GenericMappingKey] column
UPDATE [upd]
SET [upd].[GenericMappingValue] = [g].[GeneratedGenericMappingValue]
FROM (
SELECT [col].[GenericMappingKey]
, STRING_AGG(CONCAT('Col', [col].[ColNumber], 'Source|Col', [col].[ColNumber], 'Target'), ';') AS [GeneratedGenericMappingValue]
, [col].[TargetMappingKey]
, [col].[TargetMappingValue]
FROM (
SELECT *
, ROW_NUMBER() OVER ( ORDER BY (
SELECT 1
)
) AS [ColNumber]
FROM #TableMapping
CROSS APPLY [STRING_SPLIT]([TargetMappingValue], ';')
) AS [col]
GROUP BY [col].[GenericMappingKey]
, [col].[TargetMappingKey]
, [col].[TargetMappingValue]
) AS [g]
INNER JOIN #TableMapping [upd]
ON [upd].[GenericMappingKey] = [g].[GenericMappingKey];
Shnugo brings up a great point in the comments in that we are not guarantee sort order with string_split() and using row number. In this particular situation it wouldn't matter as the output mappings in generic. But what if you needed to used elements from your "TargetMappingValue" column in the final "GenericMappingValue", then you would need to make sure sort order was accurate.
Here's an example showing how to use OPENJSON() and it's "key" which would guarantee that order using Shnugo example:
SELECT [col].[GenericMappingKey]
, STRING_AGG(CONCAT('Col', [col].[colNumber], 'Source|Col', [col].[colNumber], 'Target'), ';') AS [GeneratedGenericMappingValue]
, [col].[TargetMappingKey]
, [col].[TargetMappingValue]
FROM (
SELECT [tm].*
, [oj].[Key] + 1 AS [colNumber] --Use the key as our order/column number, adding 1 as it is zero based.
, [oj].[Value] -- and if needed we can bring the split value out.
FROM #TableMapping [tm]
CROSS APPLY OPENJSON('["' + REPLACE([tm].[TargetMappingValue], ';', '","') + '"]') [oj] --Basically turn the column value into JSON string.
) AS [col]
GROUP BY [col].[GenericMappingKey]
, [col].[TargetMappingKey]
, [col].[TargetMappingValue];
if the data is already in the table and you want to break it out into columns, this should work
select
v.value
,left(v.value, charindex('|',v.value) -1) col1
,reverse(left(reverse(v.value), charindex('|',reverse(v.value)) -1)) col2
from String_split(#mapping,';') v

How to grant or update the 'createsecureauth' privilege in db2 syscat.dbauth table?

With the following DB2 query, I can view the 'CREATESECUREAUTH' privilege:
select grantee, granteetype, createsecureauth from syscat.dbauth
The above query result:
GRANTEE GRANTEETYPE CREATESECUREAUTH
--------------------------------------------
DB2INST U N
Now I want to update the createsecureauth privilege from 'N' to 'Y' for grantee 'DB2INST'
But I cannot do that with 'GRANT' or 'UPDATE'.
How to do it?
That privilege is called differently, check the GRANT syntax:
GRANT CREATE_SECURE_OBJECT ON DATABASE TO USER HENRIK
The privilege allows to create secure objects, i.e., secure triggers and secure functions.
The following SQL maps the columns of SYSCAT.DBAUTH to the names of the privileges used in GRANT (or REVOKE) statements
SELECT A.GRANTEE AS AUTHID
, A.GRANTEETYPE AS AUTHIDTYPE
, B.PRIVILEGE
, CASE WHEN B.AUTH = 'G' THEN 'Y' ELSE 'N' END AS GRANTABLE
, CURRENT SERVER AS OBJECTNAME
, '' AS OBJECTSCHEMA
, CAST ('DATABASE' AS VARCHAR (11)) AS OBJECTTYPE
FROM SYSCAT.DBAUTH A
, LATERAL(VALUES
(BINDADDAUTH ,'BINDADD')
, (CONNECTAUTH ,'CONNECT')
, (CREATETABAUTH ,'CREATETAB')
, (DBADMAUTH ,'DBADM')
, (EXTERNALROUTINEAUTH ,'CREATE_EXTERNAL_ROUTINE')
, (IMPLSCHEMAAUTH ,'IMPLICIT_SCHEMA')
, (LOADAUTH ,'LOAD')
, (NOFENCEAUTH ,'CREATE_NOT_FENCED_ROUTINE')
, (QUIESCECONNECTAUTH ,'QUIESCE_CONNECT')
, (LIBRARYADMAUTH ,'LIBRARYADMAUTH')
, (SECURITYADMAUTH ,'SECADM')
, (SQLADMAUTH ,'SQLADM')
, (WLMADMAUTH ,'WLMADM')
, (EXPLAINAUTH ,'EXPLAIN')
, (DATAACCESSAUTH ,'DATAACCESS')
, (ACCESSCTRLAUTH ,'ACCESSCTRL')
) B ( AUTH, PRIVILEGE )
WHERE B.AUTH IN ('Y','G')

Can I insert null for a decimal column that allows null

I have this SqlCommandProvider:
type Insert_NewFeed =
SqlCommandProvider<
"
INSERT INTO info.LiveFeed
( Id ,
MediaId ,
FactTypeId ,
Price ,
Description ,
PhoneNumber ,
Email ,
Website ,
CreateDate ,
CityId
)
VALUES ( #id , -- Id - nvarchar(128)
#mediaId , -- MediaId - nvarchar(128)
#factTypeId , -- FactTypeId - int
#price , -- Price - decimal
#description , -- Description - nvarchar(max)
#phoneNumber , -- PhoneNumber - nvarchar(50)
#email , -- Email - nvarchar(max)
#website , -- Website - nvarchar(max)
#createDate , -- CreateDate - datetime2
#cityId -- CityId - int
)
", Admin.connectionString, ConfigFile = "Web.config">
When I call it and try to pass null for the price column, which accepts a null in the database, I get an error. Is this possible?
Table definition:
[Id] [nvarchar](128) NOT NULL,
[MediaId] [nvarchar](128) NOT NULL,
[FactTypeId] [int] NOT NULL,
[Price] [decimal](18, 2) NULL,
[Description] [nvarchar](max) NULL,
[PhoneNumber] [nvarchar](50) NULL,
[Email] [nvarchar](max) NULL,
[Website] [nvarchar](max) NULL,
[CreateDate] [datetime2](7) NOT NULL,
[CityId] [int] NULL
As per Dimitry Sevastianov's comment, here is the solution.
First, assigned true to the parameter AllParametersOptional:
type Insert_NewFeed =
SqlCommandProvider<
"
INSERT INTO info.LiveFeed
( Id ,
MediaId ,
FactTypeId ,
Price ,
Description ,
PhoneNumber ,
Email ,
Website ,
CreateDate ,
CityId
)
VALUES ( #id , -- Id - nvarchar(128)
#mediaId , -- MediaId - nvarchar(128)
#factTypeId , -- FactTypeId - int
#price , -- Price - decimal
#description , -- Description - nvarchar(max)
#phoneNumber , -- PhoneNumber - nvarchar(50)
#email , -- Email - nvarchar(max)
#website , -- Website - nvarchar(max)
#createDate , -- CreateDate - datetime2
#cityId -- CityId - int
)
", Admin.connectionString, ConfigFile = "Web.config"
, AllParametersOptional = true>
Next, make call such as this:
let rowResult = (new Insert_NewFeed())
.Execute(Some fC.Id, Some fC.MediaId, Some fC.FactTyeId,
None,
Some fC.Description, Some fC.PhoneNumber, Some fC.Email,
Some fC.Website, Some fC.CreateDate, Some fC.CityId)

Sequelizejs HasMany ternary relationship

I want to make in Sequelize a ternary relationship as seen in the picture below
Image
https://www.dropbox.com/s/v8bgsir2qqw6ccv/relationship%20.jpg
If I apply this code in sequelize
A.hasMany(B);
A.hasMany(C);
B.hasMany(C);
C.hasMany(A);
C.hasMany(B);
The resulting SQL code is as follows
CREATE TABLE IF NOT EXISTS `a_b_` (
PRIMARY KEY (`BId`,`AId`)
)
CREATE TABLE IF NOT EXISTS `a_c_` (
`CId` int(11) NOT NULL DEFAULT '0',
`AId` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`CId`,`AId`)
)
CREATE TABLE IF NOT EXISTS `b_c_` (
PRIMARY KEY (`CId`,`BId`)
)
But the result should be
CREATE TABLE IF NOT EXISTS `a_b_` (
PRIMARY KEY (`BId`,`AId`)
)
CREATE TABLE IF NOT EXISTS `a_b_c_` (
`AId` int(11) NOT NULL DEFAULT '0',
`BId` int(11) NOT NULL DEFAULT '0',
`CId` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`AId`,`BId`, 'CId')
)
I just can not get create a table with pk (AId, BId, CId) someone could indicate me which way to go or what I can do.
Thanks so much.

Resources