30

The core always return $this; in the context of observer methods - but there doesn't actually appear to be a reason for it. Tracing back through dispatchEvent() you'll find the main method that calls observer methods (in ./app/Core/Model/App.php) protected function _callObserverMethod($object, $method, $observer) { if (method_exists($object, $method)) {...


24

Multiselect attributes can be set as a comma separated list (or also an array) containing the attribute value ids. So first we have to convert the actual values to Magento's internal ids. $attrCode = 'color_base'; $sourceModel = Mage::getModel('catalog/product')->getResource() ->getAttribute($attrCode)->getSource(); $valuesText = explode(',', ...


21

Like this: Mage::getModel('core/store')->load($storeId)->getWebsiteId() Or do a direct database lookup on the core_store table.


16

Usually, you're not supposed to do this. Mage::getStoreConfig() will automatically return the store value, the website value, the global value, or the default value depending on the configuration of the field. However, if you really need to disregard the store value and get the website value, you can do it this way: Mage::app()->getWebsite()->...


13

Just for completeness: From the current store you're in, you could retrieve the websiteId as follows: Mage::app()->getStore()->getWebsiteId();


12

There is a list of design patterns which are used in Magento on Stack Overflow From the article: The obvious ones are: Factory: $product = Mage::getModel('catalog/product'); Singleton: $category = Mage::getSingleton('catalog/session'); Registry: $currentCategory = Mage::registry('current_category'); View Helper: Mage::helper('...


9

Surprised no answers with so many votes/views, so I'll bite: This would be dependant on the old POS system, massage the data during import. Familiarize yourself with Varien_Io, particularly Varien_Io_File. Since you'll most likely be dealing with such a large collection of data, keep in mind to use streams such as StreamReadCsv and StreamWriteCsv. More ...


8

$this (pun intended) is called a fluent interface. It allows you to call multiple methods within an object without having refer back to a defined variable.


8

This is a rare case, as settings are inherited to store level and usually getStoreConfig() takes the website settings into account. You can use Mage_Core_Model_Website::getConfig() - but be a aware that there is a slight difference to Mage_Core_Model_Store::getConfig() where also some processing is being done (for example substitution of {{...}}) - this ...


7

What Tim means is your local.xml file inside your template directory like /app/design/frontend/default/YOURTEMPLATE/layout If the file does not exist, create it with the following content: <?xml version="1.0"?> <layout version="0.1.0"> <cms_index_index> <reference name="root"> <remove name="breadcrumbs"/> </...


6

This can be derived using the specific website code if known. $value = Mage::getConfig()->getNode('websites/[website_code]/section/group/field'); var_dump($value[0]);


6

You can use reset(); Mage::getModel('catalog/product')->load(1)->reset(); that calls _clearData, if you check in the Mage_Catalog_Model_Product you can see that this function resets all variables.


6

In Magento 2 to you can find the Website Id using store id like this: $this->_storeManager->getStore($storeID)->getWebsiteId();


6

getTrackingInfo has to return an object with the url field defined. The variable $tracking contains the tracking number. public function getTrackingInfo($tracking) { $track = Mage::getModel('shipping/tracking_result_status'); $track->setUrl('http://www.example.com/' . $tracking) ->setTracking($tracking) ->setCarrierTitle($...


5

It's just a Magento convention to always return $this instead of void (nothing) if a method has no other return value, regardless of it actually being used for a fluent interface anywhere or not. The advantage is, that you don't need to think about if it's useful or not, and a superfluous fluent interface is better than a missing one. Also, Magento might ...


5

This can be edited in the db. A few thoughts, though: Don't edit the db directly. Because this is a config setting you can call saveConfig(); Make an upgrade script (example saveConfig below) This value won't exist in core_config_data if you've never saved it in the admin panel. Example: $config = Mage::getModel('core/config'); $config->saveConfig('...


5

This is kind of broad and opinion based. But I will give it a try. The best way to learn Magento (in my opinion) is by trying to solve specific tasks. yes, tutorials are nice to go through, but they won't help you much when you have small business specific tasks. It will help you only get a big picture of how things are done. The first thing you should do ...


5

Mage::getModel() Mage::getModel() will create a new instance of an object each time even such object exists in configuration. Example $product1 = Mage::getModel('catalog/product'); $product2 = Mage::getModel('catalog/product'); $product1 and $product2 both have different instant of same object and also occupy different memory Mage::getResourceModel() ...


5

The methods Mage_Core_Model_Abstract::getResource() and Mage_Core_Model_Abstract::getCollection() are just handy shortcuts if you want to get the resource model or collection for an existing model instance. They eventually call Mage::getResourceModel(), so if you don't already have an instantiated model, the more straightforward way to instantiate a ...


4

Like all of Magento, the answer's in the source — all you need to do is go digging (or hop to then end of this post). First, find the class for the attribute source $source = Mage::getResourceModel('catalog/product') ->getAttribute('color') ->getSource(); var_dump(get_class($source)); exit; In modern versions of Magento, this should point to ...


4

The PHP fatal error is stemming from a bug in the convert method where it assumes that $toCurrency is an object. The error, however, is being caused when it's trying to throw an exception: throw new Exception(Mage::helper('directory')->__('Undefined rate from "%s-%s".', $this->getCode(), $toCurrency->getCode())); The meaning of this error is that ...


4

Theres information missing, however I will answer it using assumptions. Using a clean install of Magento CE, I attempted to use the code above to recreate a existing complete order. Some of the assumptions I made are: Existing Completed Order One product ordered Billing/Shipping address the same Payment Method: Check/Money Order Shipping Method: Flat rate ...


4

There is no method addWebsiteFilter for the product model. The method is available for the product collection. If you want to use load you have to do the check for website later. $product = Mage::getModel('catalog/product')->load($productId); $productWebsites = $product->getWebsiteIds(); Then you have to check if your websites are in the $...


4

$array = array(); $array['currentTime'] = date("H:i", time()); $array['someValue'] = 123; $this->loadLayout(); $this->getLayout() ->getBlock('newsletter_popup') ->assign('array', $array); $this->renderLayout();


3

In short, the answer here is that the factory Mage::getModel returns the actual object (catalog/category, in your example, which maps to Mage_Catalog_Model_Category). The object, now an rvalue, is available for you to invoke any method on in immediately. In your example, this is getCollection. If getCollection returns $this, you may then use the fluent ...


3

I actually figured this out by looking at the source and you can pass an associated child product into getFinalPrice: $qty = 1 $configurable_product->getFinalPrice( $qty, $associated_product );


3

Your edit to your question pretty much sums it up. You use $this when the block is an instance of what you are trying to access, within reason of course. A Block isn't going to be the equivalent of the respective Model you need. But in terms of passing data to and through blocks, you can use XML or PHP to achieve it. In PHP $this->getLayout()->...


3

If you have access to the command-line you can use wget or curl to load the page. (Given the fact that the page is accessible via a url) wget http://domain.com/page/that/you/want/to/load.html?really OR curl http://domain.com/page/that/you/want/to/load.html?really >/dev/null 2>&1 As mentioned in the comments you still need to provide more ...


3

If you want to remove breadcrumbs on every CMS Pages, try removing from System-->Web-->Default Pages-->Show Breadcrumbs for CMS Pages


3

Thinking about the impact these historic orders would have on the magento/mysql performance plus the fact that any product lines that have been discontinued would need to be imported too then it might be worth considering storing the historic orders along with the customer and products in something like an elasticsearch index and perform a search on demand....


Only top voted, non community-wiki answers of a minimum length are eligible