product attributes increment was missing on form, view product attributes on view product page
This commit is contained in:
@@ -13,24 +13,35 @@ $this->setLayout('ajax');
|
||||
|
||||
<?php
|
||||
$cnt = 0;
|
||||
foreach ($productCategoryAttributes as $productCategoryAttribute) {
|
||||
echo $this->Form->hidden('product_attributes.' . $cnt . '.product_category_attribute_id', [
|
||||
foreach ($productCategories as $productCategory) {
|
||||
foreach ($productCategory->product_category_attributes 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') :
|
||||
[];
|
||||
]);
|
||||
$inputType = 'text';
|
||||
$options = [];
|
||||
if ($productCategoryAttribute->attribute_type_id === ProductCategoryAttributeTypeId::Integer) {
|
||||
$inputType = 'number';
|
||||
}
|
||||
if ($productCategoryAttribute->attribute_type_id === ProductCategoryAttributeTypeId::Constrained) {
|
||||
echo $this->Form->hidden('product_attributes.' . $cnt . '.attribute_value', [
|
||||
'value' => '',
|
||||
]);
|
||||
$options = !empty($productCategoryAttribute->product_category_attribute_options) ?
|
||||
Hash::combine($productCategoryAttribute->product_category_attribute_options, '{n}.id', '{n}.attribute_label') :
|
||||
[];
|
||||
echo $this->Form->control('product_attributes.' . $cnt . '.product_category_attribute_option_id', [
|
||||
'type' => 'select',
|
||||
'label' => $productCategoryAttribute->name,
|
||||
'options' => $options,
|
||||
]);
|
||||
} else {
|
||||
echo $this->Form->control('product_attributes.' . $cnt . '.attribute_value', [
|
||||
'type' => $inputType,
|
||||
'label' => $productCategoryAttribute->name,
|
||||
'options' => $options,
|
||||
]);
|
||||
}
|
||||
$cnt++;
|
||||
}
|
||||
if ($productCategoryAttribute->attribute_type_id === ProductCategoryAttributeTypeId::Integer) {
|
||||
$inputType = 'number';
|
||||
}
|
||||
echo $this->Form->control('product_attributes.' . $cnt . '.attribute_value', [
|
||||
'type' => $inputType,
|
||||
'label' => $productCategoryAttribute->name,
|
||||
'options' => $options,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user