10 use Magento\CatalogRule\Test\Fixture\CatalogRule;
13 use Magento\CatalogRule\Test\Page\Adminhtml\CatalogRuleEdit;
14 use Magento\Mtf\TestStep\TestStepFactory;
15 use Magento\Mtf\Fixture\FixtureInterface;
34 const TEST_TYPE =
'acceptance_test, extended_acceptance_test';
60 CatalogRuleEdit $catalogRuleEdit,
61 TestStepFactory $stepFactory,
63 $isCronEnabled =
false,
74 \
Magento\Catalog\Test\TestStep\CreateProductsStep::class,
85 $catalogRuleEdit->open([
'id' => $catalogPriceRule->getId()]);
86 $this->catalogRuleNew->getFormPageActions()->saveAndApply();
102 $conditionEntity = explode(
'|', trim($catalogPriceRule[
'data'][
'rule'],
'[]'))[0];
103 $actionName =
'get' . $conditionEntity;
104 if (method_exists($this, $actionName)) {
107 $catalogPriceRule[
'data'][
'rule'] = str_replace($key,
$value, $catalogPriceRule[
'data'][
'rule']);
109 return $catalogPriceRule;
111 $message = sprintf(
'Method "%s" does not exist in %s', $actionName, get_class($this));
112 throw new \BadMethodCallException(
$message);
124 $result[
'%category_id%'] =
$product->getDataFieldConfig(
'category_ids')[
'source']->getIds()[0];
137 ->getAttributeSet()->getDataFieldConfig(
'assigned_attributes')[
'source']->getAttributes();
150 protected function applyCustomerGroup(array $catalogPriceRule, Customer
$customer)
153 $customerGroup =
$customer->getDataFieldConfig(
'group_id')[
'source']->getCustomerGroup();
154 $catalogPriceRule[
'data'][
'customer_group_ids'][
'option_0'] = $customerGroup->getCustomerGroupId();
156 return $catalogPriceRule;
168 array $catalogPriceRule,
172 if (isset($catalogPriceRule[
'data'][
'rule'])) {
176 $catalogPriceRule = $this->applyCustomerGroup($catalogPriceRule,
$customer);
179 $catalogPriceRule = $this->fixtureFactory->createByCode(
'catalogRule', $catalogPriceRule);
180 $catalogPriceRule->persist();
182 return $catalogPriceRule;
test(array $catalogRules, CatalogRuleEdit $catalogRuleEdit, TestStepFactory $stepFactory, Cron $cron, $isCronEnabled=false, Customer $customer=null, array $products=[], $promo=0)
getAttribute(FixtureInterface $product)
createCatalogPriceRule(array $catalogPriceRule, FixtureInterface $product, Customer $customer=null)
getCategory(FixtureInterface $product)
prepareCondition(FixtureInterface $product, array $catalogPriceRule)