Получить другие идентификаторы продавца
Как получить последние 5 идентификаторов продавца. Предположим, я Продавец в бэкэнде, у меня есть опция, чтобы другой продавец заблокировал показ моего профиля. В вышеупомянутом изображении я обновляю идентификатор продавца, он будет отображаться, но теперь я хочу автоматически получить последний идентификатор продавца 5. Проверьте этот URL-адрес, это мой метод продавца
public function updateOtherSellersAction() {
$fieldId = (int) $this->getRequest()->getParam('id');
$otherSellerIds = $this->getRequest()->getParam('include_in_othersellers');
try {
if ($fieldId) {
$model = Mage::getModel('marketplace/sellerprofile')->load($fieldId, 'seller_id');
$model->setData ( 'include_in_othersellers', $otherSellerIds)->save ();
}
}
catch ( Exception $e ) {
Mage::getSingleton ( 'adminhtml/session' )->addError ( $e->getMessage () );
}
}
Здесь я хочу показать свой другой идентификатор продавца
. пхтмл
<script type="text/javascript">
function updateOtherSellersField(button, fieldId)
{
new Ajax.Request('<?php echo Mage::helper('adminhtml')->getUrl('*/*/updateOtherSellers') ?>', {
method: 'post',
parameters: { id: fieldId, include_in_othersellers: $(button).previous('input').getValue() },
complete : alert("Other Sellers Block list has been updated successfully.")
});
}
</script>
Сетка администратора
$this->addColumn('include_in_othersellers', array(
'header' => Mage::helper('marketplace')->__('Include in Other Sellers Block'),
'align' => 'center',
'renderer' => 'marketplace/adminhtml_widget_grid_column_renderer_inline',
'index' => 'include_in_othersellers',
));
<?php
class Apptha_Marketplace_Block_Adminhtml_Widget_Grid_Column_Renderer_Inline
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Input
{
public function render(Varien_Object $row)
{
$list = $this->OtherSellerList($row);
$html .= '<input type="text" name="'.$row->getId().'" value = "'.$list.'"/>';
$html .= '<button onclick="updateOtherSellersField(this, '. $row->getId() .'); return false">' . Mage::helper('marketplace')->__('Update') . '</button>';
return $html;
}
public function OtherSellerList(Varien_Object $row)
{
$id = $row->getData();
foreach ($id as $_id) {
$sellerProduct = Mage::helper('marketplace/marketplace')->getSellerCollection($_id);
return $sellerProduct['include_in_othersellers'];
}
}
}
1
Author: Qaisar Satti, 2016-03-12
2 answers
$model = Mage::getModel('marketplace/sellerprofile')->load($fieldId); // you current seller id
echo $model->getIncludeInOthersellers(); // this will give you desired
В визуализаторе добавьте этот код для получения значений
public function OtherSellerList(Varien_Object $row)
{
$id = $row->getId();
$otherseller = Mage::getModel('marketplace/sellerprofile')->getCollection();
$otherseller->setPageSize(5)
;
$otherseller->getSelect()->order(new Zend_Db_Expr('RAND()'));
$sellerid=array();
foreach($otherseller as $seller)
{
$sellerid[]=$seller->getId();
}
return implode(',',$sellerid);
}
2
Author: Qaisar Satti, 2016-03-15 07:26:53
Вам нужно отсортировать коллекцию по идентификатору продавца в порядке убывания, как показано ниже
$model = Mage::getModel('marketplace/sellerprofile')->getCollection()->setOrder('seller_id', 'desc');
$model->getSelect()->limit(5);
1
Author: Prashant Valanda, 2016-03-12 21:53:30