Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

How to convert this in magento format
 
naujasdizainas
Sr. Member
 
Avatar
Total Posts:  128
Joined:  2007-11-04
Lithuania, Vilnius
 

How make this in magento code? Thanks for lite help.. wink

// Retrieve all the data from the table
$result mysql_query("SELECT cms_page.identifier AS link, cms_page.title AS title
FROM  cms_page
  INNER JOIN cms_page_store ON (cms_page.page_id = cms_page_store.page_id) 
  WHERE cms_page.page_id > 1
  GROUP by cms_page_store.page_id  
  "
)
or die(
mysql_error());  

// store the record of the  table into $row

while($row mysql_fetch_array($result)){
echo "<a href='$row[link]' target='_self'>$row[title]</a><br>"
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
alistek
Sr. Member
 
Total Posts:  293
Joined:  2008-04-02
Normal, IL
 

Well it depends on what you mean in Magento code.  If you want to put that in a template file and have it work, the reason it won’t right away is because (unless that isn’t all of the script) you are missing any sql connection data.  It needs to know what database and username/login info to use.  Now if you want to replicate that query using Magento conventions then you would have to do that in the Collection.php file in the module you want to use but you would have to use the Zend database access functions.

-Adam

 
Magento Community Magento Community
Magento Community
Magento Community
 
naujasdizainas
Sr. Member
 
Avatar
Total Posts:  128
Joined:  2007-11-04
Lithuania, Vilnius
 

Explain the issue. Conect to the database does not specifically shown. The question that - for transfer to magento format, the module will have to do or can do without it. If it could have an example to understand the principle of action, because nothing has not found not in a wiki is not the forum

 
Magento Community Magento Community
Magento Community
Magento Community
 
alistek
Sr. Member
 
Total Posts:  293
Joined:  2008-04-02
Normal, IL
 

Ok, what I meant is that you have two ways to do that.

The way you listed above is something you could put in a template file that given the standard PHP Mysql connection data, would connect to the Magento database, just like any other, and allow you to pull out data through queries such as the above.  This is not the “Magento” way of doing things, as it does not utilize the functions and programming methods inherent in the Magento architecture.

If you want to do it the Magento way you have to look at the way the modules are coded.  They follow an Model-View-Controller structure that determines how the data is accessed and displayed.  Magento is built upon Zend platform and further abstracts the code from there.  The Models are where all the data is actually pulled from and where you can run queries such as the above.  When I said that you would need to use the Zend functions in the Models I meant that there isn’t a one-to-one correlation between all SQL statements and a Zend database function so you have to look at what functions are available.

-Adam

 
Magento Community Magento Community
Magento Community
Magento Community
 
naujasdizainas
Sr. Member
 
Avatar
Total Posts:  128
Joined:  2007-11-04
Lithuania, Vilnius
 

Thank you will try to look magento structure. But the query in my example looks clean and simple, but is not sure that it correct to magento system

 
Magento Community Magento Community
Magento Community
Magento Community
 
alistek
Sr. Member
 
Total Posts:  293
Joined:  2008-04-02
Normal, IL
 

Yes and that query would be fine, it is all a matter of what you ultimately are trying to accomplish.  Good luck!

-Adam

 
Magento Community Magento Community
Magento Community
Magento Community
 
naujasdizainas
Sr. Member
 
Avatar
Total Posts:  128
Joined:  2007-11-04
Lithuania, Vilnius
 

I want to show CMS page links not manually, but show inline

 
Magento Community Magento Community
Magento Community
Magento Community
 
Webkrebse
Member
 
Avatar
Total Posts:  40
Joined:  2009-02-15
Germany
 

Hi,

I’ve got a similar problem.

I want to display the category description in the product view.

I guess I should update the

app/design/frontend/INTERFACE/THEME/template/catalog/product/view/description.phtml

But how to access category data in this view?

The following gives me the ID. How do I get the object/data belonging to that ID?

<?php
     $_product        
$this->getProduct();
     
$_categories    $_product->getCategoryIds();
     
$_categoryId    $_categories[0];
?>

Extending this: I like to store more redundant data of products on the category level. Besides the decription some images, the price, and some more attributes are shared by all products of a category. In opposite to the description these fields don’t exist on the category level!!! Any ideas?

--- Thank you very much ---

Dorothea

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top