Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to specify a store view and/or website in a scenario #18

Open
Vinai opened this issue May 21, 2013 · 1 comment
Open

Ability to specify a store view and/or website in a scenario #18

Vinai opened this issue May 21, 2013 · 1 comment

Comments

@Vinai
Copy link
Contributor

Vinai commented May 21, 2013

Any specified store view will be overridden by MageTest\MagentoExtension\Fixture\Product::create()

@zuernBernhard
Copy link

I have a step-definition to view a product in a specific store. Perhaps it helps you.

And I visit the product with the sku "123test" in the "Brand abc" store

Step-Definition

/**
   * @Given I visit the product with the sku :sku in the :site store
   */
  public function iVisitTheProductWithTheSkuInTheStore($sku, $site) {
    $websites = Mage::app()->getWebsites();
    foreach ($websites as $website) {
      $name = $website->getName();
      if ($site == $name) {
        // Open Webpage.
        Mage::app()->setCurrentStore($website->getId());
        $product = Mage::getModel('catalog/product')
          ->loadByAttribute('sku', $sku);
        if (!$product) {
          throw new Exception("A product with the sku " . $sku . " does not exist.");
        }
        $url = $product->getProductUrl();

        return $this->visit($url);
      }
    }
    throw new Exception("Website " . $site . " does not exist.");
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants