I try to get from collection, City ID and City Name, to put in module Meanbee/Shippingrules as new condition All it's good but on multtiple select filed I get city iD-s, I supose to get name as Label and Id as Option. enter image description here

class Meanbee_Shippingrules_Model_Rule_Condition_Source_City {
public function getCitiesAsOptions()    {
    $cityCollection = Mage::getModel('romcity/romcity')->getCollection();
    $cityCollection->addFieldToSelect('cityname', $cityname);
    $cityCollectionMetods = array();
    // LOg

    foreach ($cityCollection as $cityName => $cityName) {
        $cityCollectionMetods[] = array(
            'label' => $cityName,
            'value' => $CityId

    return $cityCollectionMetods;


Where I am wrong ?

enter image description here

closed as off-topic by sv3n, Priyank, Keyur Shah, Jai, Manoj Deswal Mar 26 '18 at 0:39

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced OR seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – sv3n, Priyank, Keyur Shah, Jai, Manoj Deswal
If this question can be reworded to fit the rules in the help center, please edit the question.


You can try this:

$cityCollection->addFieldToSelect(array('cityname', 'citiy_id'));
foreach ($cityCollection as $city) {
    $cityCollectionMetods[] = array(
        'label' => $city->getCityname(),
        'value' => $city->getCityId()
  • Nope now, fileds is blank, I think first need to loop in city_id – Tudor Mihai Mar 25 '18 at 14:57
  • @TudorMihai can you please log foreach ($cityCollection as $city) { Mage::log($city->getData()? – sv3n Mar 25 '18 at 15:00
  • ` class Meanbee_Shippingrules_Model_Rule_Condition_Source_City { public function getCitiesAsOptions(){ $cityCollection = Mage::getModel('romcity/romcity')->getCollection(); foreach ($cityCollection as $city) { Mage::log($city->getData()); } }` This is code now , but nothing genereated in var/logs Note: logs are active – Tudor Mihai Mar 25 '18 at 15:13
  • test.log not generated as well – Tudor Mihai Mar 25 '18 at 15:20
  • 1
    It solved with your code @sv3n :) $cityCollection->addFieldToSelect(array('cityname', 'citiy_id')); SO happy – Tudor Mihai Mar 25 '18 at 15:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.