What i ended up doing is when the thumbnail image gets clicked a hidden text box gets the product_id of that shirt and then when you go to the next page it automatically pulls the product image of that product. I have inserted the code for my entire form incase anyone ever needs to do this in the future :)
Happy Coding!
<form id="GoTie_Builder" method="POST" action="/gotie/mixandmatch/tie">
<script>
function changeInput(pro_id)
{
var my_form = document.getElementById('GoTie_Builder');
my_form.shirt_color.value = pro_id;
}
function changePattern(pattern)
{
var my_div = document.getElementById('shirt_zoom');
my_div.innerHTML = '<img src="http://www.tuxedojunction.com/Content/Products/Vests/LegacyBlueVelvet_s_1.jpg" />';
}
</script>
<div id="shirt_zoom" style="width:300px; height:100px;">
<img src="http://www.tuxedojunction.com/Content/Products/Vests/LegacyBlueVelvet_s_1.jpg" />
</div>
<div class="Builder_thumbnails" style="float:left;">
<?php
$cat_id = 8;
$products = Mage::getModel('catalog/category')->load($cat_id)->getProductCollection();
echo '<input id="shirt_color" type="text" name="shirt_color" value="0">';
foreach($products as $prod) {
$product = Mage::getModel('catalog/product')->load($prod->getId());
$pattern = $this->helper('catalog/image')->init($product, 'thumbnail');
//echo "<img onclick='changeInput($pro_id)' class='product_thumbnail' src='".$pattern."' alt='".$pro_id."' width='100px'/>";
$pro_id = $product->getId();
$pro_title = $product->getName();
$img = $product->getImageUrl();
$input_id = "shirt_color";
echo "<a href='".$img."' title='".$pro_title."' rel='enlargeimage' rev='targetdiv:loadarea,enabletitle:no,trigger:click,preload:none,fx:fade'><img onclick='changeInput($pro_id)' class='product_thumbnail' src='".$this->helper('catalog/image')->init($product, 'thumbnail')."' alt='".$pro_id."' width='100px' height='100px'/></a>";
}?>
</div>
<div id="loadarea" style="width:300px;top: 0px;right: 0px;float: right;position: relative;"><img src="http://cdn4.blackenterprise.com/wp-content/blogs.dir/1/files/2011/07/White-Shirt-620x480.jpg" width="500px;"/>
</div>
<input type="submit" value="Choose a Tie" />
</form>
If the wrong session is used, it is because the session_name is wrong. The session name is set in Mage_Core_Model_Session_Abstract_Varien::setSessionName()
.
But after a look on the Stacktrace, I have no idea, why overwriting _construct
or even __construct
should be a problem here:
#0 Mage_Core_Model_Session_Abstract_Varien->setSessionName(frontend) called at [app/code/core/Mage/Core/Model/Session/Abstract/Varien.php:111]
#1 Mage_Core_Model_Session_Abstract_Varien->start(frontend) called at [app/code/core/Mage/Core/Model/Session/Abstract/Varien.php:166]
#2 Mage_Core_Model_Session_Abstract_Varien->init(core, frontend) called at [app/code/core/Mage/Core/Model/Session/Abstract.php:84]
#3 Mage_Core_Model_Session_Abstract->init(core, frontend) called at [app/code/core/Mage/Core/Model/Session.php:42]
#4 Mage_Core_Model_Session->__construct(Array ([name] => frontend)) called at [app/code/core/Mage/Core/Model/Config.php:1348]
#5 Mage_Core_Model_Config->getModelInstance(core/session, Array ([name] => frontend)) called at [app/Mage.php:462]
#6 Mage::getModel(core/session, Array ([name] => frontend)) called at [app/Mage.php:476]
#7 Mage::getSingleton(core/session, Array ([name] => frontend)) called at [app/code/core/Mage/Core/Controller/Varien/Action.php:494]
#8 Mage_Core_Controller_Varien_Action->preDispatch() called at [app/code/core/Mage/Core/Controller/Front/Action.php:64]
#9 Mage_Core_Controller_Front_Action->preDispatch() called at [app/code/core/Mage/Core/Controller/Varien/Action.php:408]
#10 Mage_Core_Controller_Varien_Action->dispatch(view) called at [app/code/core/Mage/Core/Controller/Varien/Router/Standard.php:250]
#11 Mage_Core_Controller_Varien_Router_Standard->match(Mage_Core_Controller_Request_Http Object ([] => /test.html,[] => ,[] => /test.html,[] => ,[] => ,[] => Array (),[] => catalog,[] => ,[] => Mage_Catalog,[] => ,[] => Array (),[] => Array ([0] => _GET,[1] => _POST),[] => /catalog/product/view/id/21,[] => ,[] => ,[] => catalog/product/view/id/21,[] => Array ([id] => 21),[] => ,[] => Array ([rewrite_request_path] => test.html),[] => 1,[] => catalog,[] => module,[] => product,[] => controller,[] => view,[] => action)) called at [app/code/core/Mage/Core/Controller/Varien/Front.php:176]
#12 Mage_Core_Controller_Varien_Front->dispatch() called at [app/code/core/Mage/Core/Model/App.php:354]
#13 Mage_Core_Model_App->run(Array ([scope_code] => ,[scope_type] => store,[options] => Array ())) called at [app/Mage.php:683]
#14 Mage::run(, store) called at [index.php:87]
Best Answer
Include Mage.php from Magento in your external application
You have two options then, for the session name, "frontend" for frontend session or "adminhtml" for admin session:
This will get the session of the current logged in user.
And this will login to Magento from outside:
$row['mail']
is the email with user is registered$row['field_magentopass_value']
is the passwordSource: http://louisjohn.wordpress.com/category/magento/magento-functions-outside-magento-folder/