0

I have a module that allow a user to add/edit an item via the admin panel. The admin add/edit page contains :

  • name (text field)
  • image (file upload)
  • a store to select (standard select for a store view)
  • link to a cms page (via a custom select)

I want to show to only the cms pages that belongs to the store the user select. So, my first idea was to reload the page once a store is selected, but I am also unable to do find out a way to do that...

How can I accomplish that?

  • did you store the cms page id? – Qaisar Satti Dec 14 '15 at 5:43
  • I prepared my table with the cms_id field. My cms pages are set per store. So I would like to show only the pages that belongs to a store, in my select box. (not sure i am clear) – user2360915 Dec 14 '15 at 6:54
  • here is logic add your block with every cms page. and every cms page you will check your database value for current page and current store it the values match you will show that. – Qaisar Satti Dec 14 '15 at 6:59
  • I was thinking about something more dynamic. Like if the user select store 1 in the list, then I update via ajax the listbox containing the cms pages. I found this stackoverflow.com/questions/19235203/… that helped me adding jquery to my edit page. – user2360915 Dec 14 '15 at 7:06
  • it will update auto no need for jquery that. because when the store change the page will be reload. some time user can change from product page or any other page. – Qaisar Satti Dec 14 '15 at 7:08
1

You can use ajax & get CMS pages by below code for store filter:

$collection = Mage::getModel('cms/page')->getCollection();
$collection->getSelect()
    ->join(
         array('cms' => $collection->getTable('cms/page_store')),
               'cms.page_id = main_table.page_id AND cms.store_id != 0',
         array('store_id')
)
->columns(array('stores_count' => new Zend_Db_Expr('COUNT(cms.store_id)')))
->group('main_table.page_id')
->having('stores_count = ?', 1)
->having('cms.store_id = ?', 'YOUR_STORE_ID');
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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