File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,8 @@ public function __construct(
67
67
*/
68
68
protected function getDataLayer (): array
69
69
{
70
- $ data = $ this ->viewItem ->get ($ this ->getCurrentProduct ());
70
+ $ product = $ this ->getCurrentProduct ();
71
+ $ data = $ this ->viewItem ->get ($ product );
71
72
if ($ productId = $ this ->_request ->getParam ('mfpreselect ' )) {
72
73
try {
73
74
$ child = $ this ->productRepository ->getById ($ productId );
@@ -78,7 +79,15 @@ protected function getDataLayer(): array
78
79
79
80
$ delimiter = (false === strpos ($ childUrl , '? ' )) ? '? ' : '& ' ;
80
81
$ childUrl .= $ delimiter . 'mfpreselect= ' . $ child ->getId ();
81
-
82
+
83
+ $ attributes = $ product ->getTypeInstance ()->getConfigurableAttributes ($ product );
84
+ foreach ($ attributes as $ attribute ) {
85
+ $ attrCode = $ attribute ->getProductAttribute ()->getAttributeCode ();
86
+ $ value = $ child ->getData ($ attrCode );
87
+ $ delimiter = (false === strpos ($ childUrl , '? ' )) ? '? ' : '& ' ;
88
+ $ childUrl .= $ delimiter . $ attrCode . '= ' . $ value ;
89
+ }
90
+
82
91
$ childData ['ecommerce ' ]['items ' ][0 ]['item_url ' ] = $ childUrl ;
83
92
}
84
93
$ data = $ childData ;
Original file line number Diff line number Diff line change @@ -105,7 +105,8 @@ protected function getValue(Order $order): float
105
105
*/
106
106
protected function setMfChildrenItem ($ entity )
107
107
{
108
- foreach ($ entity ->getAllItems () as $ childrenItem ) {
108
+ // Use getItem, not getAllItems, to prevent some errors with the custom plugins
109
+ foreach ($ entity ->getItems () as $ childrenItem ) {
109
110
if ($ parentItemId = $ childrenItem ->getParentItemId ()) {
110
111
foreach ($ entity ->getAllVisibleItems () as $ parentItem ) {
111
112
if ($ parentItem ->getId () == $ parentItemId ) {
You can’t perform that action at this time.
0 commit comments