Javascript magento下拉列表属性未保存在数据库中

Javascript magento下拉列表属性未保存在数据库中,javascript,php,database,magento,Javascript,Php,Database,Magento,我们正在使用magento多供应商网站 我们使用下面的代码来更新自定义属性“local”,使其工作正常 Catalog Input Type for Store Owner : Textfield phtml <?php $attribute = $products->getResource()->getAttribute('local');?> <?php if($attribute):?> <?php $attribute_value = $att

我们正在使用magento多供应商网站

我们使用下面的代码来更新自定义属性“local”,使其工作正常

Catalog Input Type for Store Owner : Textfield
phtml

<?php $attribute = $products->getResource()->getAttribute('local');?>
<?php if($attribute):?>
<?php $attribute_value = $attribute ->getFrontend()->getValue($products); ?>

<input class="ama1" type = "text" id = "local_<?php echo $products->getId(); ?>" onkeydown="validateNumbers(event)" name= "local[]" value = "<?php echo $attribute_value; ?>" style = ""/>
<?php endif; ?>


<input type="hidden" name="localcurr_<?php echo $products->getId(); ?>" id="localcurr_<?php echo $products->getId(); ?>" value="<?php echo $products->getLocal(); ?>" /> 

<p id="updatedlocal_<?php echo $products->getId(); ?>" style = "display:none;color:red; position:relative; top:16px;">Updated</p>
<br/>
<button id="local_update_button_<?php echo $products->getId(); ?>" class="update" onclick="updateFieldLocal('<?php echo $products->getId(); ?>'); return false;" >
<span><span style="font-size:12px;"><?php echo $helper->__('Update') ?></span></span>
</button>

<button id="local_reset_button_<?php echo $products->getId(); ?>" type="reset" class="cancel" onclick="hideResetLocal('<?php echo $products->getId(); ?>','<?php echo $products->getPrice(); ?>'); return false;">
<span><span><?php echo $helper->__('Cancel') ?></span></span>
</button>
</span>
<?php $attribute = $products->getResource()->getAttribute('cod');?>
<?php if($attribute):?>
<?php $attribute_value = $attribute ->getFrontend()->getValue($products); ?>

<input class="ama1" type = "text" id = "cod_<?php echo $products->getId(); ?>"  name= "cod[]" value = "<?php echo $attribute_value; ?>" style = ""/>
<?php endif; ?>


<input type="hidden" name="codcurr_<?php echo $products->getId(); ?>" id="codcurr_<?php echo $products->getId(); ?>" value="<?php echo $products->getCod(); ?>" /> 

<p id="updatedcod_<?php echo $products->getId(); ?>" style = "display:none;color:red; position:relative; top:16px;">Updated</p>
<br/>
<button id="cod_update_button_<?php echo $products->getId(); ?>" class="update" onclick="updateFieldCod('<?php echo $products->getId(); ?>'); return false;" >
<span><span style="font-size:12px;"><?php echo $helper->__('Update') ?></span></span>
</button>

<button id="cod_reset_button_<?php echo $products->getId(); ?>" type="reset" class="cancel" onclick="hideResetCod('<?php echo $products->getId(); ?>','<?php echo $products->getPrice(); ?>'); return false;">
<span><span><?php echo $helper->__('Cancel') ?></span></span>
</button>
</span>
同样,我们使用以下代码来更新自定义属性:“cod”。 但它并没有保存在数据库中

Catalog Input Type for Store Owner : Dropdown
phtml

<?php $attribute = $products->getResource()->getAttribute('local');?>
<?php if($attribute):?>
<?php $attribute_value = $attribute ->getFrontend()->getValue($products); ?>

<input class="ama1" type = "text" id = "local_<?php echo $products->getId(); ?>" onkeydown="validateNumbers(event)" name= "local[]" value = "<?php echo $attribute_value; ?>" style = ""/>
<?php endif; ?>


<input type="hidden" name="localcurr_<?php echo $products->getId(); ?>" id="localcurr_<?php echo $products->getId(); ?>" value="<?php echo $products->getLocal(); ?>" /> 

<p id="updatedlocal_<?php echo $products->getId(); ?>" style = "display:none;color:red; position:relative; top:16px;">Updated</p>
<br/>
<button id="local_update_button_<?php echo $products->getId(); ?>" class="update" onclick="updateFieldLocal('<?php echo $products->getId(); ?>'); return false;" >
<span><span style="font-size:12px;"><?php echo $helper->__('Update') ?></span></span>
</button>

<button id="local_reset_button_<?php echo $products->getId(); ?>" type="reset" class="cancel" onclick="hideResetLocal('<?php echo $products->getId(); ?>','<?php echo $products->getPrice(); ?>'); return false;">
<span><span><?php echo $helper->__('Cancel') ?></span></span>
</button>
</span>
<?php $attribute = $products->getResource()->getAttribute('cod');?>
<?php if($attribute):?>
<?php $attribute_value = $attribute ->getFrontend()->getValue($products); ?>

<input class="ama1" type = "text" id = "cod_<?php echo $products->getId(); ?>"  name= "cod[]" value = "<?php echo $attribute_value; ?>" style = ""/>
<?php endif; ?>


<input type="hidden" name="codcurr_<?php echo $products->getId(); ?>" id="codcurr_<?php echo $products->getId(); ?>" value="<?php echo $products->getCod(); ?>" /> 

<p id="updatedcod_<?php echo $products->getId(); ?>" style = "display:none;color:red; position:relative; top:16px;">Updated</p>
<br/>
<button id="cod_update_button_<?php echo $products->getId(); ?>" class="update" onclick="updateFieldCod('<?php echo $products->getId(); ?>'); return false;" >
<span><span style="font-size:12px;"><?php echo $helper->__('Update') ?></span></span>
</button>

<button id="cod_reset_button_<?php echo $products->getId(); ?>" type="reset" class="cancel" onclick="hideResetCod('<?php echo $products->getId(); ?>','<?php echo $products->getPrice(); ?>'); return false;">
<span><span><?php echo $helper->__('Cancel') ?></span></span>
</button>
</span>
替换

<input class="ama1" type = "text" id = "cod_<?php echo $products->getId(); ?>"  name= "cod[]" value = "<?php echo $attribute_value; ?>" style = ""/>

我也需要将此字段设置为textfield。如果设置为yes和not,则无法更改iti。我希望有一个选项可以像其他属性一样编辑“yes”或“no”。但如何限制用户仅选择yes和no?下拉列表是最好的选择。请帮助我制作下拉列表:
public function updateFieldCodAction(){
        Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);      
        $id= $this->getRequest()->getParam('id');
        $customerid=Mage::getSingleton('customer/session')->getCustomerId();
        $collection_product = Mage::getModel('marketplace/product')->getCollection()->addFieldToFilter('mageproductid',array('eq'=>$id))->addFieldToFilter('userid',array('eq'=>$customerid));

        try{
        $upd_cod = $this->getRequest()->getParam('cod');
        $product = Mage::getModel('catalog/product')->load($id);        

        $product->setCod($upd_cod);

        $product->save();

        echo $cod = $product->getCod();
        echo $name = $product->getName();

        $response['message'] = 'Your Product Is Been Sucessfully Updated';
        $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response)); 

        }catch(Exception $e){
        echo "Not Saving"; exit;    
        Mage::log($e->getMessage());
        }

      }
<input class="ama1" type = "text" id = "cod_<?php echo $products->getId(); ?>"  name= "cod[]" value = "<?php echo $attribute_value; ?>" style = ""/>
   <?php  $attribute_code = "cod"; $attribute_details = Mage::getSingleton("eav/config")->getAttribute("catalog_product", $attribute_code); $options = $attribute_details->getSource()->getAllOptions(false); ?>
<select  id = "cod_<?php echo $products->getId(); ?>"  name= "cod[]" ">
<?php foreach($options as $option){ 
       ?>
<option vaule="<?php echo echo $option["value"]; ?>"><?php echo $option["label"]; ?></option>


<?php } ?> </select>