attributes form wip
	
		
			
	
		
	
	
		
			
				
	
				CI / testsuite (mysql, 8.1, ) (push) Failing after 0s
				
					Details
				
			
		
			
				
	
				CI / testsuite (mysql, 8.4, ) (push) Failing after 1s
				
					Details
				
			
		
			
				
	
				CI / testsuite (pgsql, 8.1, ) (push) Failing after 1s
				
					Details
				
			
		
			
				
	
				CI / testsuite (pgsql, 8.4, ) (push) Failing after 0s
				
					Details
				
			
		
			
				
	
				CI / testsuite (sqlite, 8.1, ) (push) Failing after 0s
				
					Details
				
			
		
			
				
	
				CI / testsuite (sqlite, 8.1, prefer-lowest) (push) Failing after 1s
				
					Details
				
			
		
			
				
	
				CI / testsuite (sqlite, 8.4, ) (push) Failing after 0s
				
					Details
				
			
		
			
				
	
				CI / Coding Standard & Static Analysis (push) Failing after 0s
				
					Details
				
			
		
	
				
					
				
			
				
	
				CI / testsuite (mysql, 8.1, ) (push) Failing after 0s
				
					Details
				
			
		
			
				
	
				CI / testsuite (mysql, 8.4, ) (push) Failing after 1s
				
					Details
				
			
		
			
				
	
				CI / testsuite (pgsql, 8.1, ) (push) Failing after 1s
				
					Details
				
			
		
			
				
	
				CI / testsuite (pgsql, 8.4, ) (push) Failing after 0s
				
					Details
				
			
		
			
				
	
				CI / testsuite (sqlite, 8.1, ) (push) Failing after 0s
				
					Details
				
			
		
			
				
	
				CI / testsuite (sqlite, 8.1, prefer-lowest) (push) Failing after 1s
				
					Details
				
			
		
			
				
	
				CI / testsuite (sqlite, 8.4, ) (push) Failing after 0s
				
					Details
				
			
		
			
				
	
				CI / Coding Standard & Static Analysis (push) Failing after 0s
				
					Details
				
			
		
	This commit is contained in:
		
							parent
							
								
									732819ff73
								
							
						
					
					
						commit
						2f80ba1fa3
					
				|  | @ -161,13 +161,10 @@ class ProductCategoriesController extends AppController | |||
|                 'product_catalog_id' => $this->request->getQuery('product_catalog_id', -1), | ||||
|             ], | ||||
|         ]); | ||||
|         $form = $this->request->getQuery('form', 'product_category'); | ||||
|         if ($form === 'product') { | ||||
|             $productCategoriesQ = $productCategoriesTable | ||||
|                 ->find('treeList', keyPath: 'internal_id', valuePath: 'name'); | ||||
|         } else { | ||||
|             $productCategoriesQ = $productCategoriesTable->find('treeList'); | ||||
|         } | ||||
|         $productCategoriesQ = $this->request->getQuery('form', 'product_category') === 'product' ? | ||||
|             $productCategoriesTable->find('treeList', keyPath: 'internal_id', valuePath: 'name') : | ||||
|             $productCategoriesTable->find('treeList'); | ||||
| 
 | ||||
|         $productCategories = $productCategoriesQ | ||||
|             ->orderBy(['ProductCategories.name']) | ||||
|             ->toArray(); | ||||
|  |  | |||
|  | @ -114,11 +114,16 @@ class ProductCategoryAttributesTable extends Table | |||
|     public function getAllCategoryAttributesForCategoryId(string $internalCategoryId) | ||||
|     { | ||||
|         $category = $this->ProductCategories->find()->where(['internal_id' => $internalCategoryId])->first(); | ||||
|         $categories = []; | ||||
|         if ($category) { | ||||
|             $categories = $this->ProductCategories->find('path', for: $category->id)->all(); | ||||
|         } | ||||
| 
 | ||||
|         return $categories; | ||||
|         $this->ProductCategories->behaviors()->get('Tree')->setConfig([ | ||||
|             'scope' => [ | ||||
|                 'product_catalog_id' => $category->product_catalog_id ?? 1, | ||||
|             ], | ||||
|         ]); | ||||
| 
 | ||||
|         return $category ? $this->ProductCategories | ||||
|             ->find('path', for: $category->id) | ||||
|             ->contain(['ProductCategoryAttributes', 'ProductCategoryAttributes.ProductCategoryAttributeOptions']) | ||||
|             ->toArray() : []; | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -4,7 +4,10 @@ | |||
|  * @var \Cake\Datasource\EntityInterface $productCategory | ||||
|  * @var \Cake\Collection\CollectionInterface|string[] $productCatalogs | ||||
|  * @var \Cake\Collection\CollectionInterface|string[] $parentProductCategories | ||||
|  * | ||||
|  */ | ||||
| 
 | ||||
| 
 | ||||
| ?>
 | ||||
| <div class="row"> | ||||
|     <aside class="column"> | ||||
|  |  | |||
|  | @ -1,63 +1,36 @@ | |||
| <?php | ||||
| /** | ||||
|  * @var \App\View\AppView $this | ||||
|  * @var \Cake\Datasource\EntityInterface $productCategoryAttribute | ||||
|  * @var \Cake\Datasource\EntityInterface[]|ProductCategoryAttribute[] $productCategoryAttributes | ||||
|  */ | ||||
| 
 | ||||
| use Cake\Utility\Hash; | ||||
| use CakeProducts\Model\Entity\ProductCategoryAttribute; | ||||
| use CakeProducts\Model\Enum\ProductCategoryAttributeTypeId; | ||||
| 
 | ||||
| $this->setLayout('ajax'); | ||||
| ?>
 | ||||
| <div class="row"> | ||||
|     <aside class="column"> | ||||
|         <div class="side-nav"> | ||||
|             <h4 class="heading"><?= __('Actions') ?></h4>
 | ||||
|             <?= $this->Html->link(__('Edit Product Category Attribute'), ['action' => 'edit', $productCategoryAttribute->id], ['class' => 'side-nav-item']) ?>
 | ||||
|             <?= $this->Form->postLink(__('Delete Product Category Attribute'), ['action' => 'delete', $productCategoryAttribute->id], ['confirm' => __('Are you sure you want to delete # {0}?', $productCategoryAttribute->id), 'class' => 'side-nav-item']) ?>
 | ||||
|             <?= $this->Html->link(__('List Product Category Attributes'), ['action' => 'index'], ['class' => 'side-nav-item']) ?>
 | ||||
|             <?= $this->Html->link(__('New Product Category Attribute'), ['action' => 'add'], ['class' => 'side-nav-item']) ?>
 | ||||
|         </div> | ||||
|     </aside> | ||||
|     <div class="column column-80"> | ||||
|         <div class="productCategoryAttributes view content"> | ||||
|             <h3><?= h($productCategoryAttribute->name) ?></h3>
 | ||||
|             <table> | ||||
|                 <tr> | ||||
|                     <th><?= __('Name') ?></th>
 | ||||
|                     <td><?= h($productCategoryAttribute->name) ?></td>
 | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <th><?= __('Product Category') ?></th>
 | ||||
|                     <td><?= $productCategoryAttribute->hasValue('product_category') ? $this->Html->link($productCategoryAttribute->product_category->name, ['controller' => 'ProductCategories', 'action' => 'view', $productCategoryAttribute->product_category->id]) : '' ?></td>
 | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <th><?= __('Enabled') ?></th>
 | ||||
|                     <td><?= $productCategoryAttribute->enabled ? __('Yes') : __('No'); ?></td>
 | ||||
|                 </tr> | ||||
|             </table> | ||||
|             <div class="related"> | ||||
|                 <h4><?= __('Related Product Category Attribute Options') ?></h4>
 | ||||
|                 <?php if (!empty($productCategoryAttribute->product_category_attribute_options)) : ?>
 | ||||
|                 <div class="table-responsive"> | ||||
|                     <table> | ||||
|                         <tr> | ||||
|                             <th><?= __('Attribute Value') ?></th>
 | ||||
|                             <th><?= __('Attribute Label') ?></th>
 | ||||
|                             <th><?= __('Enabled') ?></th>
 | ||||
|                             <th class="actions"><?= __('Actions') ?></th>
 | ||||
|                         </tr> | ||||
|                         <?php foreach ($productCategoryAttribute->product_category_attribute_options as $productCategoryAttributeOptions) : ?>
 | ||||
|                         <tr> | ||||
|                             <td><?= h($productCategoryAttributeOptions->attribute_value) ?></td>
 | ||||
|                             <td><?= h($productCategoryAttributeOptions->attribute_label) ?></td>
 | ||||
|                             <td><?= h($productCategoryAttributeOptions->enabled) ?></td>
 | ||||
|                             <td class="actions"> | ||||
|                                 <?= $this->Html->link(__('View'), ['controller' => 'ProductCategoryAttributeOptions', 'action' => 'view', $productCategoryAttributeOptions->id]) ?>
 | ||||
|                                 <?= $this->Html->link(__('Edit'), ['controller' => 'ProductCategoryAttributeOptions', 'action' => 'edit', $productCategoryAttributeOptions->id]) ?>
 | ||||
|                                 <?= $this->Form->postLink(__('Delete'), ['controller' => 'ProductCategoryAttributeOptions', 'action' => 'delete', $productCategoryAttributeOptions->id], ['confirm' => __('Are you sure you want to delete # {0}?', $productCategoryAttributeOptions->id)]) ?>
 | ||||
|                             </td> | ||||
|                         </tr> | ||||
|                         <?php endforeach; ?>
 | ||||
|                     </table> | ||||
|                 </div> | ||||
|                 <?php endif; ?>
 | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
| 
 | ||||
| <?php | ||||
| $cnt = 0; | ||||
| foreach ($productCategoryAttributes as $productCategoryAttribute) { | ||||
|     echo $this->Form->hidden('product_attributes.' . $cnt . '.product_category_attribute_id', [ | ||||
|             'value' => $productCategoryAttribute->id, | ||||
|     ]); | ||||
|     $inputType = 'text'; | ||||
|     $options = []; | ||||
|     if ($productCategoryAttribute->attribute_type_id === ProductCategoryAttributeTypeId::Constrained) { | ||||
|         $inputType = 'select'; | ||||
|         $options = !empty($productCategoryAttribute->product_category_attribute_options) ? | ||||
|             Hash::combine($productCategoryAttribute->product_category_attribute_options, '{n}.id', '{n}.attribute_label') : | ||||
|             []; | ||||
|     } | ||||
|     if ($productCategoryAttribute->attribute_type_id === ProductCategoryAttributeTypeId::Integer) { | ||||
|         $inputType = 'number'; | ||||
|     } | ||||
|     echo $this->Form->control('product_attributes.' . $cnt . '.product_category_attribute_id', [ | ||||
|         'type' => $inputType, | ||||
|         'label' => $productCategoryAttribute->name, | ||||
|         'options' => $options, | ||||
|     ]); | ||||
| } | ||||
		Loading…
	
		Reference in New Issue