Skip to main content
added 3777 characters in body
Source Link
Magento 2
  • 3.8k
  • 7
  • 55
  • 107

config.xml

   <?phpxml version="1.0"?>
class<config>
 OptFirst_ReviewMyCompany_Block_Index extends Mage_Core_Block_Template <modules>
    {    <OptFirst_ReviewMyCompany>
     public function getindex()     <version>1.0.0</version>
    {    </OptFirst_ReviewMyCompany>
    </modules>
     
  $productId = 1;<frontend>
    <routers>
      <reviewmycompany>
        <use>standard</use>
          <args>
            <module>OptFirst_ReviewMyCompany</module>
            <frontName>reviewmycompany</changefrontName>
 to your product id      </args>
      </reviewmycompany>
  $collection = Mage::getModel('optfirst_reviewmycompany</new_optfirst_reviewmycompany')->getCollection()routers>
        <layout>
 ->addFieldToFilter('id_optfirst_reviewmycompany', $productId);        <updates>
           return $collection;<reviewmycompany>
              <file>reviews.xml</file>
   }         </reviewmycompany>
          </updates>
}        </layout>
  </frontend>
    
    <global>
        <blocks>
            <reviewmycompany>
                <class>OptFirst_ReviewMyCompany_Block</class>
            </reviewmycompany>
        </blocks>

        <helpers>
            <optfirst_reviewmycompany>
                <class>OptFirst_ReviewMyCompany_Helper</class>
            </optfirst_reviewmycompany>
        </helpers>

        <models>         
            <optfirst_reviewmycompany>
                <class>OptFirst_ReviewMyCompany_Model</class>
                <resourceModel>optfirst_reviewmycompany_resource</resourceModel>
            </optfirst_reviewmycompany>
            <optfirst_reviewmycompany_resource>
                <class>OptFirst_ReviewMyCompany_Model_Resource</class>
                <entities>
                    <review>
                        <table>optfirst_reviewmycompany</table>
                    </review>
                </entities>
            </optfirst_reviewmycompany_resource>
        </models>

        <resource>
            <optfirst_reviewmycompany_setup>
                <setup>
                    <module>OptFirst_ReviewMyCompany</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </optfirst_reviewmycompany_setup>
            <optfirst_reviewmycompany_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </optfirst_reviewmycompany_write>
            <optfirst_reviewmycompany_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </optfirst_reviewmycompany_read>
        </resource>
    </global>

    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <optfirst_reviewmycompany after="Mage_Adminhtml">OptFirst_ReviewMyCompany_Adminhtml</optfirst_reviewmycompany>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>

    <adminhtml>
        <layout>
            <updates>
                <optfirst_reviewmycompany>
                    <file>optfirst_reviewmycompany.xml</file>
                </optfirst_reviewmycompany>
            </updates>
        </layout>
        <translate>
            <modules>
                <optfirst_reviewmycompany>
                    <files>
                        <default>OptFirst_ReviewMyCompany.csv</default>
                    </files>
                </optfirst_reviewmycompany>
            </modules>
        </translate>
    </adminhtml>

    <default>
        <optfirst_reviewmycompany>
            <general>
                <default_sort_by><![CDATA[position]]></default_sort_by>
            </general>
        </optfirst_reviewmycompany>
    </default>
</config>

In Phtml File add thisreviews.xml

<?php
$collectionxml version = $this->index();
print_r($collection);"1.0"?>   
foreach<layout ($collectionversion="0.1.0"> as $instance) {
   <reviewmycompany_index_index>  
    <reference name="root"> echo  $instance['facebook'].'<br>';
      <action method="setTemplate"><template>page/1column.phtml</template></action>    
    </*reference> you can customize 
 code here */ <reference name="content">   
      <block type="reviewmycompany/index" name="reviewmycompany_index" template="reviews/index.phtml"/>   }
    </reference>   
  </reviewmycompany_index_index> 
</layout>  ?> 
<?php
class OptFirst_ReviewMyCompany_Block_Index extends Mage_Core_Block_Template
    {
     public function getindex()
    {
        $productId = 1;//change to your product id
        $collection = Mage::getModel('optfirst_reviewmycompany/new_optfirst_reviewmycompany')->getCollection()
         ->addFieldToFilter('id_optfirst_reviewmycompany', $productId);
           return $collection;

   }

}

In Phtml File add this

<?php
$collection = $this->index();
print_r($collection);
foreach ($collection as $instance) {
          echo  $instance['facebook'].'<br>';
          /* you can customize code here */
          }

     ?> 

config.xml

   <?xml version="1.0"?>
<config>
    <modules>
        <OptFirst_ReviewMyCompany>
            <version>1.0.0</version>
        </OptFirst_ReviewMyCompany>
    </modules>
     
    <frontend>
    <routers>
      <reviewmycompany>
        <use>standard</use>
          <args>
            <module>OptFirst_ReviewMyCompany</module>
            <frontName>reviewmycompany</frontName>
          </args>
      </reviewmycompany>
    </routers>
        <layout>
          <updates>
            <reviewmycompany>
              <file>reviews.xml</file>
            </reviewmycompany>
          </updates>
        </layout>
  </frontend>
    
    <global>
        <blocks>
            <reviewmycompany>
                <class>OptFirst_ReviewMyCompany_Block</class>
            </reviewmycompany>
        </blocks>

        <helpers>
            <optfirst_reviewmycompany>
                <class>OptFirst_ReviewMyCompany_Helper</class>
            </optfirst_reviewmycompany>
        </helpers>

        <models>         
            <optfirst_reviewmycompany>
                <class>OptFirst_ReviewMyCompany_Model</class>
                <resourceModel>optfirst_reviewmycompany_resource</resourceModel>
            </optfirst_reviewmycompany>
            <optfirst_reviewmycompany_resource>
                <class>OptFirst_ReviewMyCompany_Model_Resource</class>
                <entities>
                    <review>
                        <table>optfirst_reviewmycompany</table>
                    </review>
                </entities>
            </optfirst_reviewmycompany_resource>
        </models>

        <resource>
            <optfirst_reviewmycompany_setup>
                <setup>
                    <module>OptFirst_ReviewMyCompany</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </optfirst_reviewmycompany_setup>
            <optfirst_reviewmycompany_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </optfirst_reviewmycompany_write>
            <optfirst_reviewmycompany_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </optfirst_reviewmycompany_read>
        </resource>
    </global>

    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <optfirst_reviewmycompany after="Mage_Adminhtml">OptFirst_ReviewMyCompany_Adminhtml</optfirst_reviewmycompany>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>

    <adminhtml>
        <layout>
            <updates>
                <optfirst_reviewmycompany>
                    <file>optfirst_reviewmycompany.xml</file>
                </optfirst_reviewmycompany>
            </updates>
        </layout>
        <translate>
            <modules>
                <optfirst_reviewmycompany>
                    <files>
                        <default>OptFirst_ReviewMyCompany.csv</default>
                    </files>
                </optfirst_reviewmycompany>
            </modules>
        </translate>
    </adminhtml>

    <default>
        <optfirst_reviewmycompany>
            <general>
                <default_sort_by><![CDATA[position]]></default_sort_by>
            </general>
        </optfirst_reviewmycompany>
    </default>
</config>

reviews.xml

<?xml version = "1.0"?>   
<layout version="0.1.0">   
  <reviewmycompany_index_index>  
    <reference name="root">   
      <action method="setTemplate"><template>page/1column.phtml</template></action>    
    </reference>    
    <reference name="content">   
      <block type="reviewmycompany/index" name="reviewmycompany_index" template="reviews/index.phtml"/>   
    </reference>   
  </reviewmycompany_index_index> 
</layout>   
Source Link
Magento 2
  • 3.8k
  • 7
  • 55
  • 107

Try this,

<?php
class OptFirst_ReviewMyCompany_Block_Index extends Mage_Core_Block_Template
    {
     public function getindex()
    {
        $productId = 1;//change to your product id
        $collection = Mage::getModel('optfirst_reviewmycompany/new_optfirst_reviewmycompany')->getCollection()
         ->addFieldToFilter('id_optfirst_reviewmycompany', $productId);
           return $collection;

   }

}

In Phtml File add this

<?php
$collection = $this->index();
print_r($collection);
foreach ($collection as $instance) {
          echo  $instance['facebook'].'<br>';
          /* you can customize code here */
          }

     ?>