Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
SAMBUMBA
pasteque-server
Commits
061b7af9
Commit
061b7af9
authored
Dec 26, 2017
by
Karamel
Browse files
Import compositions from v7 and fix toStruct for them.
parent
2e887343
Changes
2
Hide whitespace changes
Inline
Side-by-side
bin/upgrade7/importdb.php
View file @
061b7af9
...
...
@@ -455,7 +455,41 @@ if ($stmt->execute()) {
}
}
// Read compositions
// TODO compositions
$stmt3
=
$pdo
->
prepare
(
'select * from SUBGROUPS where COMPOSITION = :id '
.
'order by DISPORDER asc'
);
$stmt4
=
$pdo
->
prepare
(
'select * from SUBGROUPS_PROD where SUBGROUP = :id '
.
'order by DISPORDER asc'
);
foreach
(
$compositions
as
$id
=>
$prd
)
{
$stmt3
->
bindValue
(
':id'
,
$id
);
if
(
$stmt3
->
execute
())
{
while
(
$rowGrp
=
$stmt3
->
fetch
())
{
$group
=
new
\
Pasteque\Server\Model\CompositionGroup
();
$group
->
setLabel
(
$rowGrp
[
'NAME'
]);
$dispOrder
=
(
$rowGrp
[
'DISPORDER'
]
===
null
)
?
0
:
$rowGrp
[
'DISPORDER'
];
$group
->
setDispOrder
(
$dispOrder
);
$stmt4
->
bindValue
(
':id'
,
$rowGrp
[
'ID'
]);
if
(
$stmt4
->
execute
())
{
while
(
$rowPrd
=
$stmt4
->
fetch
())
{
$grpPrd
=
new
\
Pasteque\Server\Model\CompositionProduct
();
$dispOrder
=
(
$rowPrd
[
'DISPORDER'
]
===
null
)
?
0
:
$rowPrd
[
'DISPORDER'
];
$grpPrd
->
setDispOrder
(
$dispOrder
);
$grpPrd
->
setProduct
(
$prdMapping
[
$rowPrd
[
'PRODUCT'
]]);
$group
->
addCompositionProducts
(
$grpPrd
);
}
}
else
{
$err
=
$stmt4
->
errorInfo
();
die
(
'SUBGROUPS_PROD error '
.
$err
[
2
]);
}
$prd
->
addCompositionGroup
(
$group
);
$api
->
write
(
$prd
);
}
}
else
{
$err
=
$stmt3
->
errorInfo
();
die
(
'SUBGROUPS error '
.
$err
[
2
]);
}
}
}
else
{
$err
=
$stmt
->
errorInfo
();
die
(
'PRODUCTS error'
.
$err
[
2
]);
...
...
src/lib/Model/Product.php
View file @
061b7af9
...
...
@@ -312,14 +312,10 @@ class Product extends DoctrineModel
$struct
[
'taxedPrice'
]
=
$this
->
getTaxedPrice
();
$struct
[
'taxValue'
]
=
$this
->
getTaxValue
();
if
(
$this
->
isPrepay
())
{
// Remove irrelevent fields
unset
(
$struct
[
'compositionGroups'
]);
// Embed prepay value to be able to apply discounts on it.
$struct
[
'prepayValue'
]
=
$this
->
getPriceSell
();
}
elseif
(
$this
->
isComposition
())
{
// Disable irrelevent fields
unset
(
$struct
[
'prepay'
]);
}
else
{
}
if
(
!
$this
->
isComposition
())
{
unset
(
$struct
[
'compositionGroups'
]);
}
return
$struct
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment