I managed to create an own magento theme. So far all is working nice. Now I've got a question about dynamic content on a custom *.phtml
file. I'm creating a kind of configurator for cloth/materials. I'm successfully loading the products of a specific attributeset via php.
<?php
//Fetch attribute set id by attribute set name
$attrSetName = 'massanfertigung';
$attributeSetId = Mage::getModel('eav/entity_attribute_set')
->load($attrSetName, 'attribute_set_name')
->getAttributeSetId();
//Load product model collecttion filtered by attribute set id
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addFieldToFilter('attribute_set_id', $attributeSetId);
?>
Then I build a dropdown which shows all the product names:
<<div class="row" id="picdropdown">
<h1>MATERIAL</h1>
<select id="selektor" onchange="updateData();">
<?php foreach ($products as $product) { ?>
<option value="<?php echo $product->getImageUrl(); ?>"
><?php echo $product->getShortDescription(); ?></option>
<?php } ?>
</select>
</div>
On selection of one of them the updateData()
function is called - it updates the image of the currently selected material via javascript. But this only works because the images are already loaded.
I want to change the operation method to a proper one. What would be the right way to realize the following behavior:
I load via PHP the products, as already mentioned. But not with all attributes, just the short description and the ID. I know how to do that.
On a dropdown select I want a request to be sent to Magento to load the image for the given product ID.
Which technologies do I need for this? JS? JQuery? ReactJS? Ajax? What I need to understand is how can I send dynamic requests to Magento backend and display/update the data - in this case the picture. There would be other attributes to be shown, but I just want to understand the techniques.