<commit_before>Sprangular.controller 'ProductCtrl', ($scope, Status, product, Cart) ->
  $scope.product = product
  $scope.adding = false
  $scope.selected =
    image: product.variants[0].images[0]
    quantity: 1
    variant: null

  if !product.hasVariants
    $scope.selected.variant = product.master

  Status.pageTitle = $scope.product.name

  $scope.$watch 'selected.variant', (variant) ->
    $scope.selected.image = variant.images[0] if variant

  $scope.changeQuantity = (val) ->
    $scope.selected.quantity = val

  $scope.changeImage = (image) ->
    $scope.selected.image = image

  $scope.hasVariant = ->
    Cart.hasVariant($scope.selected.variant)
<commit_msg>Updated product controller to use product master variants images<commit_after>Sprangular.controller 'ProductCtrl', ($scope, Status, product, Cart) ->
  $scope.product = product
  $scope.adding = false
  $scope.selected =
    image: null
    images: []
    quantity: 1
    variant: null

  if !product.hasVariants
    $scope.selected.variant = product.master

  Status.pageTitle = $scope.product.name

  $scope.$watch 'selected.variant', (variant) ->
    if variant && variant.images.length > 0
      $scope.selected.images = variant.images
    else if product.hasVariants
      $scope.selected.images = product.variants[0].images
    else
      $scope.selected.images = product.images

    $scope.selected.image = $scope.selected.images[0]

  $scope.changeQuantity = (val) ->
    $scope.selected.quantity = val

  $scope.changeImage = (image) ->
    $scope.selected.image = image

  $scope.hasVariant = ->
    Cart.hasVariant($scope.selected.variant)

{'fraction_non_alphanumeric': 0.13206388206388206, 'fraction_numerical': 0.004914004914004914, 'mean_word_length': 3.463013698630137, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3748402', 'n_tokens_mistral': 507, 'n_tokens_neox': 483, 'n_words': 101}