Skip to content

Commit

Permalink
Merge pull request #512 from pmhou/pmhou/enhancement/variation-form
Browse files Browse the repository at this point in the history
Merge #512
  • Loading branch information
bummzack authored Jun 29, 2016
2 parents 73be24f + f4f7b85 commit 99701b0
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions code/product/variations/VariationForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,18 @@ public function __construct($controller, $name = "VariationForm")

if (self::$include_json) {
$vararray = array();

if ($vars = $product->Variations()) {
foreach ($vars as $var) {
$vararray[$var->ID] = $var->AttributeValues()->map('ID', 'ID')->toArray();
}

$query = $query2 = new SQLQuery();

$query->setSelect('ID')
->setFrom('ProductVariation')
->setWhere(array('ProductID' => $product->ID));

foreach ($query->execute()->column('ID') as $variationID) {
$query2->setSelect('ProductAttributeValueID')
->setFrom('ProductVariation_AttributeValues')
->setWhere(array('ProductVariationID' => $variationID));
$vararray[$variationID] = $query2->execute()->keyedColumn();
}

$fields->push(
Expand Down

0 comments on commit 99701b0

Please sign in to comment.