Advertisement
Guest User

Untitled

a guest
Apr 7th, 2014
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. <?php
  2. class ProductPage extends Page {
  3. private static $has_many = array(
  4. 'RelatedProducts' => 'ProductPage'
  5. );
  6.  
  7. public function getCMSFields() {
  8. $fields = parent::getCMSFields();
  9. $products = Product::get()->exclude(array('ID' => $this->ID));
  10. $gridfieldConfig = GridFieldConfig::create();
  11. $gridfieldConfig->addComponent(new GridFieldManyRelationHandler($this, 'RelatedProducts'));
  12. $gridField = new GridField('products', 'Related Products', $products, $gridfieldConfig);
  13. $fields->addFieldToTab('Root.RelatedProducts', $gridField);
  14.  
  15. return $fields;
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement