Jump to content

fRAiLtY-

Members
  • Posts

    53
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://www.advantagedigitalmedia.co.uk

Profile Information

  • Gender
    Male
  • Location
    UK

fRAiLtY-'s Achievements

Member

Member (2/5)

0

Reputation

  1. Hi guys, I've got a situation where, for example, file1.php contains a method call and the echo'ing of a table. file2.php contains the method and is what processes and ultimately produces the data and sends it back to file1.php for formatting. I need to mix this up a bit by adding the table echo's to file2.php but retain the "call" in file1.php. Here's my 2 files so to speak currently: File1.php - the table view and call <?php $childProducts = Mage::getModel('catalog/product_type_configurable')->getMatrix(null, $_product); $x = array(); foreach ($childProducts as $children) { $x[$children->getAttributeText('quantity')][$children->getAttributeText('size')] = array('id'=>$children->getId(), 'price'=>number_format($children->getPrice(),'2'), 'name'=>$children->getName()); } ksort( $x ); echo '<table class="matrix"><tr><th></th>'; foreach( array_keys(current($x)) as $size ) { echo '<th>'.$size.'</th>'; } echo '</tr>'; foreach( $x as $quantity => $data ) { echo '<tr><th>'.$quantity.'</th>'; foreach( $data as $item ) { echo '<td><a href="/checkout/cart/add?product='.$item[id].'" title="Add '.$item[name].' to basket">£'.$item[price].'</a></td>'; } echo '</tr>'; } echo '</table>'; ?> File2.php - the method that processes <?php class OrganicInternet_SimpleConfigurableProducts_Catalog_Model_Product_Type_Configurable extends Mage_Catalog_Model_Product_Type_Configurable { /** * Retrieve array of "subproducts" for 300gsm flyers based on standard getUsedProducts * * @param array * @param Mage_Catalog_Model_Product $product * @return array */ public function getMatrix($requiredAttributeIds = null, $product = null) { Varien_Profiler::start('CONFIGURABLE:'.__METHOD__); if ($this->getProduct($product)->hasData($this->_usedProducts)) { if (is_null($requiredAttributeIds) and is_null($this->getProduct($product)->getData($this->_configurableAttributes))) { // If used products load before attributes, we will load attributes. $this->getConfigurableAttributes($product); // After attributes loading products loaded too. Varien_Profiler::stop('CONFIGURABLE:'.__METHOD__); return $this->getProduct($product)->getData($this->_usedProducts); } $usedProducts = array(); $collection = $this->getUsedProductCollection($product) ->addAttributeToSelect('*') ->addFieldToFilter('name', array('like' => '%300gsm Flyers%')); //->groupByAttribute('size'); $x = $collection->getSize(); // ->addFilterByRequiredOptions(); if (is_array($requiredAttributeIds)) { foreach ($requiredAttributeIds as $attributeId) { $attribute = $this->getAttributeById($attributeId, $product); if (!is_null($attribute)) $collection->addAttributeToFilter($attribute->getAttributeCode(), array('notnull'=>1)); } } foreach ($collection as $item) { $usedProducts[] = $item; } $this->getProduct($product)->setData($this->_usedProducts, $usedProducts); } Varien_Profiler::stop('CONFIGURABLE:'.__METHOD__); return $this->getProduct($product)->getData($this->_usedProducts); } } ?> I need the tabular part, from x = array downwards from File1.php to be part of File2.php, however I need to retain the $childProducts = Mage.... part in File1.php and pass any necessary data through to the method, however which ever way I try it I end up with errors about undefined methods etc. Visually I will see no difference on screen as it should still create the same table in the same way, however I'm going to be using AJAX to produce a new table on select so need the table as part of the method. Any help is greatly appreciated as I keep breaking it! Cheers.
  2. Ah OK gotcha. One last thing, I'm working on a Magento platform which uses prototype. Is prototype "just another" library like jQuery or mootools, and as such a good option to try and work within this or is it not the case? I've read that libraries can conflict with each other and have used jQuery noConflict in the past to great effect, but am wondering if I have the choice to start with it might be be an idea to try and avoid the conflicts? Cheers
  3. So if I read what you're saying is right, and referring back to my original post, if I want to pass a different value to PHP for data retrieval it's AJAX I'll need, not jQuery? My table is prepoluated with "default" values, however on select of a drop-down will pass a value to a PHP to potentially change the data in that table. Cheers.
  4. Hi thorpe, Thanks for the response. So just to confirm, going on my description jQuery is the solution, not AJAX? I find the 2 a bit confusing that's all as to their differences! Cheers.
  5. Hi guys, Here's my dev page: http://dev4.printpartnerships.com/flyer-printing Thanks to the awesome help I got in the PHP part I've got that table displaying correctly underneath the drop-downs, it's dynamically created. As you can see, I have 4 drop-down boxes. The third one is where you choose the paper, although you can't operate it until you've filled the other 2 out. Once you select an option in there, for example 300gsm stock, I need the table to change. Now, currently I use a function called getFlyers300gsm in my PHP so rather than having a function for every paper stock I was hoping I could have a function called getMatrix() or similar in PHP that passes a variable to the function depending on the value of that dropdown, thus manipulating the table and reloading it. So to summarise, table loads a default set of figures on page load, drop-down box is changed, value is passed to PHP and table is reloaded. I'm not sure whether this is jQuery or Javascript or AJAX so forgive me if this post needs to be moved, I have little experience in JS. The PHP part of the equation I believe I can handle, it's just this part stumps me. If anyone can give me some help I'd greatly appreciate it. Cheers.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.