/**
  * @param \Spryker\Zed\Gui\Communication\Table\TableConfiguration $config
  *
  * @return array
  */
 protected function prepareData(TableConfiguration $config)
 {
     $query = $this->productCategoryQueryContainer->queryProductsAbstractBySearchTerm(null, $this->locale);
     $query->setModelAlias('spy_product_abstract');
     $queryResults = $this->runQuery($query, $config);
     $results = [];
     foreach ($queryResults as $product) {
         $info = ['id' => $product[SpyProductAbstractTableMap::COL_ID_PRODUCT_ABSTRACT], 'sku' => $product[SpyProductAbstractTableMap::COL_SKU], 'name' => urlencode($product['name'])];
         $checkbox_html = sprintf("<input id='all_products_checkbox_%d' class='all-products-checkbox' type='checkbox' data-info='%s'>", $product[SpyProductAbstractTableMap::COL_ID_PRODUCT_ABSTRACT], Json::encode($info));
         $results[] = [SpyProductAbstractTableMap::COL_ID_PRODUCT_ABSTRACT => $product[SpyProductAbstractTableMap::COL_ID_PRODUCT_ABSTRACT], SpyProductAbstractTableMap::COL_SKU => $product[SpyProductAbstractTableMap::COL_SKU], SpyProductAbstractLocalizedAttributesTableMap::COL_NAME => $product['name'], self::COL_CHECKBOX => $checkbox_html];
     }
     unset($queryResults);
     return $results;
 }
 /**
  * @param int $idCategory
  *
  * @return void
  */
 protected function removeMappings($idCategory)
 {
     $assignedProducts = $this->productCategoryQueryContainer->queryProductCategoryMappingsByCategoryId($idCategory)->find();
     $productIdsToUnAssign = [];
     foreach ($assignedProducts as $mapping) {
         $productIdsToUnAssign[] = $mapping->getFkProductAbstract();
     }
     $this->removeProductCategoryMappings($idCategory, $productIdsToUnAssign);
 }
 /**
  * @param array $productCategory
  *
  * @return string
  */
 protected function getProductOptionsComboBoxItems($productCategory)
 {
     $preConfigQuery = $this->productCategoryQueryContainer->queryProductCategoryPreConfig($this->idCategory, $productCategory['id_product_abstract'])->orderByFormat();
     $preconfigItems = $preConfigQuery->find();
     $items = '<option value="0">Default</option>';
     foreach ($preconfigItems as $preconfigItem) {
         $selected = '';
         if ((int) $productCategory['preconfig_product'] === (int) $preconfigItem->getIdProduct()) {
             $selected = 'selected="selected"';
         }
         $items .= '<option value="' . $preconfigItem->getIdProduct() . '" ' . $selected . '>' . $preconfigItem->getFormat() . '</option>';
     }
     return $items;
 }